Package edu.isi.karma.rep

Examples of edu.isi.karma.rep.Worksheet


            InvocationManager invocatioManager = new InvocationManager(null, ids, urls, encoding);
            String json = invocatioManager.getServiceJson(includeInputAttributes);
      logger.debug(json);
            Import imp = new JsonImport(json, worksheetName, workspace, encoding, -1);

            Worksheet wsht = imp.generateWorksheet();
            c.add(new ImportServiceCommandPreferencesUpdate(serviceUrl, worksheetName));

            c.add(new WorksheetListUpdate());
            c.append(WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(wsht.getId(), SuperSelectionManager.DEFAULT_SELECTION));
            return c;
        } catch (Exception e) {
            logger.error("Error occured while creating worksheet from web-service: " + serviceUrl);
            return new UpdateContainer(new ErrorUpdate("Error creating worksheet from web-service"));
        }
View Full Code Here


  @Override
  public UpdateContainer undoIt(Workspace workspace) {
   
    UpdateContainer c = new UpdateContainer();
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    OntologyManager ontologyManager = workspace.getOntologyManager();
    if(ontologyManager.isEmpty())
      return new UpdateContainer(new ErrorUpdate("No ontology loaded."));
   
    String alignmentId = AlignmentManager.Instance().constructAlignmentId(workspace.getId(), worksheetId);
    Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId);
    if (alignment == null) {
      logger.info("Alignment is NULL for " + worksheetId);
      return new UpdateContainer(new ErrorUpdate(
          "Please align the worksheet before generating R2RML Model!"));
    }

//    Set<ColumnNode> alignmentColumnNodes = alignment.getSourceColumnNodes();
//    if (alignmentColumnNodes != null) {
//      for (ColumnNode cn : alignmentColumnNodes) {
//        if (!cn.hasUserType())
//          worksheet.getSemanticTypes().unassignColumnSemanticType(cn.getHNodeId());
//      }
//    }

    alignment = initialAlignment;
    alignment.setGraph(initialGraph);
    if(!this.isExecutedInBatch())
      alignment.align();
    AlignmentManager.Instance().addAlignmentToMap(alignmentId, alignment);
   

    try {
      // Save the semantic types in the input parameter JSON
      saveSemanticTypesInformation(worksheet, workspace, worksheet.getSemanticTypes().getListOfTypes());
     
      // Add the visualization update
      c.add(new SemanticTypesUpdate(worksheet, worksheetId, alignment));
      c.add(new AlignmentSVGVisualizationUpdate(
          worksheetId, alignment));
View Full Code Here

  @Override
  public void generateJson(String prefix, PrintWriter pw,
      VWorkspace vWorkspace) {
    VWorksheet vWorksheet = vWorkspace.getViewFactory().getVWorksheetByWorksheetId(worksheetId);
    Worksheet worksheet = vWorksheet.getWorksheet();
    List<HNodePath> columnPaths = worksheet.getHeaders().getAllPaths();
    ColumnMetadata colMetadata = worksheet.getMetadataContainer().getColumnMetadata();

    List<String> columnsInvoked = new ArrayList<String>();

    for (HNodePath path:columnPaths) {
      String leafHNodeId = path.getLeaf().getId();
      List<Node> nodes = new ArrayList<Node>(Math.max(1000, worksheet.getDataTable().getNumRows()));
      worksheet.getDataTable().collectNodes(path, nodes, selection);
      final int sampleSize = (nodes.size() > 1000) ? 1000 : nodes.size();
      columnsInvoked.add(leafHNodeId);
      try {
        // Check if the column metadata doesn't contains the cleaning information
        if (colMetadata.getColumnHistogramData(leafHNodeId) == null
View Full Code Here

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    inputColumns.clear();
    outputColumns.clear();
    RepFactory factory = workspace.getFactory();
    Worksheet oldws = workspace.getWorksheet(worksheetId);
    Object para = JSONUtil.createJson(this.getInputParameterJson());
    List<String> hnodeIDs = new ArrayList<String>();
    List<HNode> keyhnodes = new ArrayList<HNode>();
    List<HNode> valuehnodes = new ArrayList<HNode>();
    JSONArray checked = (JSONArray) JSONUtil.createJson(CommandInputJSONUtil.getStringValue("values", (JSONArray)para));
    HTable ht;
    if (hNodeId.compareTo("") != 0)
      ht = factory.getHTable(factory.getHNode(hNodeId).getHTableId());
    else
      ht = oldws.getHeaders();
    for (int i = 0; i < checked.length(); i++) {
      JSONObject t = (checked.getJSONObject(i));
      hnodeIDs.add((String) t.get("value"));
      keyhnodes.add(ht.getHNode((String) t.get("value")));
    }

    for (HNode oldhnode : ht.getHNodes()) {
      boolean found = false;
      for (HNode keynode : keyhnodes) {
        if (keynode.getId().compareTo(oldhnode.getId()) == 0)
          found = true;
      }
      if (!found)
        valuehnodes.add(oldhnode);
    }

    Worksheet newws = null;
    if (ht == oldws.getHeaders())
      newws = groupByTopLevel(oldws, workspace, hnodeIDs, keyhnodes, valuehnodes, factory);
    else {
      inputColumns.addAll(hnodeIDs);
      groupByNestedTable(oldws, workspace, ht, hnodeIDs, keyhnodes, valuehnodes, factory);
    }
    try{
      UpdateContainer c =  new UpdateContainer();
      WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
      c.add(new WorksheetListUpdate());
      if (newws == null)
        c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(oldws.getId(), getSuperSelection(oldws)));
      if (newws != null) {
        c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(newws.getId(), SuperSelectionManager.DEFAULT_SELECTION));
        //c.append(WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(newws.getId()));
        Alignment alignment = AlignmentManager.Instance().getAlignmentOrCreateIt(workspace.getId(), newws.getId(), workspace.getOntologyManager());
        c.append(WorksheetUpdateFactory.createSemanticTypesAndSVGAlignmentUpdates(newws.getId(), workspace, alignment));
      }
      //c.append(WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(oldws.getId()));
      c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
      return c;
    } catch (Exception e) {
View Full Code Here

      workspace.getFactory().removeWorksheet(newWorksheetId, workspace.getCommandHistory());
      c.add(new WorksheetListUpdate());
      c.add(new WorksheetDeleteUpdate(newWorksheetId));
    }
    if (this.newHNodeId != null) {
      Worksheet worksheet = workspace.getWorksheet(worksheetId);
      HNode ndid = workspace.getFactory().getHNode(newHNodeId);
      HTable currentTable = workspace.getFactory().getHTable(ndid.getHTableId());
      ndid.removeNestedTable();
      //remove the new column
      currentTable.removeHNode(newHNodeId, worksheet);
View Full Code Here

    return c;
  }

  private Worksheet groupByTopLevel(Worksheet oldws, Workspace workspace, List<String> hnodeIDs, List<HNode> keyhnodes, List<HNode> valuehnodes, RepFactory factory) {
    SuperSelection selection = getSuperSelection(oldws);
    Worksheet newws = factory.createWorksheet("GroupBy: " + oldws.getTitle(), workspace, oldws.getEncoding());
    newws.getMetadataContainer().getWorksheetProperties().setPropertyValue(Property.sourceType, oldws.getMetadataContainer().getWorksheetProperties().getPropertyValue(Property.sourceType));
    HTable newht =  newws.getHeaders();
    ArrayList<Row> rows = oldws.getDataTable().getRows(0, oldws.getDataTable().getNumRows(), selection);
    HTable oldht =  oldws.getHeaders();
    Map<String, ArrayList<String>> hash = new TreeMap<String, ArrayList<String>>();
    for (Row row : rows) {
      String hashValue = HashValueManager.getHashValue(row, hnodeIDs);
      ArrayList<String> ids = hash.get(hashValue);
      if (ids == null)
        ids = new ArrayList<String>();
      ids.add(row.getId());
      hash.put(hashValue, ids);
      //System.out.println("Hash: " + HashValueManager.getHashValue(row, hnodeIDs));
   
    //HTable newKeyTable = newht.getHNodeFromColumnName("Keys").addNestedTable("Table for keys", newws, factory);
    //newValueTable.addHNode("Values", newws, factory);
    //HTable newValueNestedTable = newValueTable.getHNodeFromColumnName("Values").addNestedTable("Table for nested values", newws, factory);
    CloneTableUtils.cloneHTable(oldht, newht, newws, factory, keyhnodes, selection);
    newht.addHNode("Values", HNodeType.Transformation, newws, factory);
    HTable newValueTable = newht.getHNodeFromColumnName("Values").addNestedTable("Table for values", newws, factory);
    CloneTableUtils.cloneHTable(oldht, newValueTable, newws, factory, valuehnodes, selection);
    for (String key : hash.keySet()) {
      //System.out.println("key: " + hash.get(key));
      ArrayList<String> r = hash.get(key);
      Row lastRow = CloneTableUtils.cloneDataTable(factory.getRow(r.get(0)), newws.getDataTable(), oldws.getHeaders(), newht, keyhnodes, factory, selection);
      for (String rowid : r) {
        Row cur = factory.getRow(rowid);
        Table dataTable = lastRow.getNeighborByColumnName("Values", factory).getNestedTable();
        CloneTableUtils.cloneDataTable(cur, dataTable, oldws.getHeaders(), newValueTable, valuehnodes, factory, selection);
      }
    }
    newWorksheetId = newws.getId();
    return newws;
  }
View Full Code Here

      JSONObject response = new JSONObject();
      response.put(JsonKeys.worksheetId.name(), worksheetId);
      response.put(AbstractUpdate.GenericJsonKeys.updateType.name(),
          this.getClass().getSimpleName());
     
      Worksheet wk = vWorksheet.getWorksheet();
      ColumnMetadata colMeta = wk.getMetadataContainer().getColumnMetadata();
      List<VHNode> viewHeaders = vWorksheet.getHeaderViewNodes();
     
      JSONArray columns = getColumnsJsonArray(viewHeaders, colMeta);
      response.put(JsonKeys.columns.name(), columns);
     
View Full Code Here

    return CommandType.notInHistory;
  }

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    HTable ht = worksheet.getHeaders();   
    if (hNodeId.compareTo("") != 0) {
      HNode hNode = workspace.getFactory().getHNode(hNodeId);
      HTable parentHT = workspace.getFactory().getHTable(hNode.getHTableId());
      if (commandName.compareTo("GroupBy") == 0 || commandName.compareTo("Fold") == 0 || commandName.compareTo("Glue") == 0)
        ht = hNode.getNestedTable();
View Full Code Here

    // String alignmentId =
    // AlignmentManager.Instance().constructAlignmentId(workspace.getId(),
    // worksheetId);
    Alignment alignment = AlignmentManager.Instance().getAlignment(
        alignmentId);
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    OntologyManager ontMgr = workspace.getOntologyManager();

    // Save the original alignment for undo
    oldAlignment = alignment.getAlignmentClone();
    oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>) alignment
View Full Code Here

    }
  }

  @Override
  public UpdateContainer undoIt(Workspace workspace) {
    Worksheet worksheet = workspace.getWorksheet(worksheetId);

    // Revert to the old alignment
    AlignmentManager.Instance()
        .addAlignmentToMap(alignmentId, oldAlignment);
    oldAlignment.setGraph(oldGraph);
View Full Code Here

TOP

Related Classes of edu.isi.karma.rep.Worksheet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.