Examples of HNode


Examples of edu.isi.karma.rep.HNode

  public UpdateContainer undoIt(Workspace workspace) {
    inputColumns.clear();
    outputColumns.clear();
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    SuperSelection superSel = getSuperSelection(worksheet);
    HNode hNode = workspace.getFactory().getHNode(hNodeId);
    Selection currentSel = superSel.getSelection(hNode.getHTableId());
    if (previousSelection != null) {
      superSel.addSelection(previousSelection);
      outputColumns.addAll(previousSelection.getInputColumns());
    }
    if (currentSel != null) {
View Full Code Here

Examples of edu.isi.karma.rep.HNode

       */
      HTable headers = getWorksheet().getHeaders();
      List<String> headersList = new ArrayList<String>();
      for (int i = 0; i < data.get(0).size(); i++)
      {
        HNode hNode = null;
        hNode = headers.addHNode(data.get(0).get(i), HNodeType.Regular, getWorksheet(), getFactory());
        headersList.add(hNode.getId());
      }

      /**
       * Add the data *
       */
 
View Full Code Here

Examples of edu.isi.karma.rep.HNode

    try {
      AddValuesCommandFactory factory = new AddValuesCommandFactory();
      cmd = (AddValuesCommand) factory.createCommand(addValues, workspace, hNodeId, worksheetId,
          ht.getId(), HNodeType.Transformation, selection.getName());
     
      HNode hnode = repFactory.getHNode(hNodeId);
      cmd.setColumnName(hnode.getColumnName()+" Extractions");
      cmd.doIt(workspace);

      newHNodeId = cmd.getNewHNodeId();
     
      UpdateContainer c = new UpdateContainer(new InfoUpdate("Extracted Entities"));
View Full Code Here

Examples of edu.isi.karma.rep.HNode

    }
    return operationCommands; 
  }

  private boolean isSamehTableId(String hNodeId1, String hNodeId2, Workspace workspace) {
    HNode hNode1 = workspace.getFactory().getHNode(hNodeId1);
    HNode hNode2 = workspace.getFactory().getHNode(hNodeId2);
    if (hNode1 == null || hNode2 == null)
      return false;
    return hNode1.getHTableId().equals(hNode2.getHTableId());

  }
View Full Code Here

Examples of edu.isi.karma.rep.HNode

    inputColumns.clear();
    outputColumns.clear();
    inputColumns.add(hNodeId);
    outputColumns.add(hNodeId);
    try {
      HNode hn = workspace.getFactory().getHNode(hNodeId);
      labelName = hn.getColumnName();
    }catch(Exception e) {
     
    }
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    SuperSelection selection = getSuperSelection(worksheet);
View Full Code Here

Examples of edu.isi.karma.rep.HNode

  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    Worksheet wk = workspace.getWorksheet(worksheetId);
    UpdateContainer c = new UpdateContainer();
    SuperSelection selection = getSuperSelection(wk);
    // Get the HNode
    HNode hNode = workspace.getFactory().getHNode(hNodeId);
    columnName = hNode.getColumnName();
    // The column should not have a nested table but check to make sure!
    if (hNode.hasNestedTable()) {
      c.add(new ErrorUpdate("Cannot split column with nested table!"));
      return c;
    }
   
    if (columnName.equals(newColName)) {
      splitCommaCommand = new SplitByCommaCommand(workspace.getFactory().getNewId("C"), worksheetId, hNodeId, delimiter, selectionId);
      return splitCommaCommand.doIt(workspace);
    }

    logger.info("SplitValuesCommand:" + newColName + ", columnName:" + columnName);
   
    HNode newhNode = null;
    if(newHNodeId != null && newHNodeId.length() > 0)
      newhNode = workspace.getFactory().getHNode(newHNodeId);
    boolean isUpdate = false;
    if(newhNode == null) {
      HTable hTable = workspace.getFactory().getHTable(hNode.getHTableId());
      newhNode = hTable.getHNodeFromColumnName(newColName);
      if(newhNode == null)
      {
        newhNode = hTable.addHNode(newColName, HNodeType.Transformation, wk, workspace.getFactory());
      }
      if(newhNode.getNestedTable() == null)
      {
        HTable newTable = newhNode.addNestedTable("Comma Split Values", wk, workspace.getFactory());
        newTable.addHNode("Values", HNodeType.Transformation, wk, workspace.getFactory());
      }
      newHNodeId = newhNode.getId();
      hNode.addAppliedCommand("SplitValuesCommand", newhNode);
    } else {
      logger.info("Column names are same, re-compute the split values");
      isUpdate = true;
    }
   
   
   
    SplitColumnByDelimiter split = new SplitColumnByDelimiter(hNodeId, newhNode.getId(), wk, delimiter, workspace, selection);
    try {
      if(isUpdate)
        split.empty();
      split.split();
    } catch (IOException e) {
View Full Code Here

Examples of edu.isi.karma.rep.HNode

    Worksheet wk = workspace.getWorksheet(worksheetId);
    SuperSelection selection = getSuperSelection(wk);
    if (splitCommaCommand != null)
      return splitCommaCommand.undoIt(workspace);
    RepFactory factory = workspace.getFactory();
    HNode hNode = factory.getHNode(newHNodeId);
    HTable hTable = factory.getHTable(hNode.getHTableId());
    hTable.removeHNode(newHNodeId, factory.getWorksheet(worksheetId));
    hNode.removeNestedTable();
    return WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, selection);
  }
View Full Code Here

Examples of edu.isi.karma.rep.HNode

  }

  public void split(HashMap<Node, CellValue> oldNodeValueMap,
      HashMap<Node, NodeStatus> oldNodeStatusMap) {
    RepFactory factory = workspace.getFactory();
    HNode hNode = factory.getHNode(hNodeId);

    // The column should not have a nested table but check to make sure!
    if (hNode.hasNestedTable()) {
      logger.error("Column has nested table. Cannot perform split operation.");
      return;
    }

    HNodePath selectedPath = null;
    List<HNodePath> columnPaths = worksheet.getHeaders().getAllPaths();
    for (HNodePath path : columnPaths) {
      if (path.getLeaf().getId().equals(hNodeId)) {
        hNode = path.getLeaf();
        selectedPath = path;
        break;
      }
    }

    // Convert the delimiter into character primitive type
    char delimiterChar = ',';
    if (delimiter.equalsIgnoreCase("space"))
      delimiterChar = ' ';
    else if (delimiter.equalsIgnoreCase("tab"))
      delimiterChar = '\t';
    else {
      delimiterChar = new Character(delimiter.charAt(0));
    }

    Collection<Node> nodes = new ArrayList<Node>();
    worksheet.getDataTable().collectNodes(selectedPath, nodes, selection);

    //pedro: 2012-10-09
    // Need to save and clear the values before adding the nested table.
    // Otherwise we have both a value and a nested table, which is not legal.
    for (Node node : nodes) {
      if (oldNodeValueMap != null)
        oldNodeValueMap.put(node, node.getValue());
      if (oldNodeStatusMap != null)
        oldNodeStatusMap.put(node, node.getStatus());

      node.clearValue(NodeStatus.edited);
    }

    //pedro: 2012-10-09
    // Now that we cleared the values it is safe to add the nested table.
    //
    // Add the nested new HTable to the hNode
    HTable newTable = hNode.addNestedTable("Comma Split Values", worksheet,
        factory);
    splitValueHNodeId = newTable.addHNode("Values", HNodeType.Transformation, worksheet, factory)
        .getId();

    for (Node node : nodes) {
View Full Code Here

Examples of edu.isi.karma.rep.HNode

      HTable headers = vWorksheet.getWorksheet().getHeaders();
      for (int columnNum = 0; columnNum < hNodeIdList.size(); columnNum++) {
        String hNodeId = hNodeIdList.get(columnNum);
        ColumnNode node = columnNodes.get(hNodeId);
        JSONObject anchorObj;
        HNode hNode = headers.getHNode(hNodeId, true);
        if (node != null) {
          anchorObj = getForceLayoutColumnJsonObject(columnNum,
              hNode.getColumnName(), node.getId(), node.getType()
                  .name(), node.isForced(), hNodeId,
              node.getUri(), columnNum);
        } else {
         
          anchorObj = getForceLayoutColumnJsonObject(columnNum,
              hNode.getColumnName(), hNode.getId(), "ColumnNode",
              false, hNodeId, "", columnNum);
        }
        anchorsArr.put(anchorObj);
        verticesIndex.put(node, columnNum);
      }
View Full Code Here

Examples of edu.isi.karma.rep.HNode

    Set<String> inputColumns = historyUtil.generateInputColumns();
    Set<String> outputColumns = historyUtil.generateOutputColumns();
    JSONArray inputColumnsArray = new JSONArray();
    JSONArray outputColumnsArray = new JSONArray();
    for (String hNodeId : inputColumns) {
      HNode hnode = workspace.getFactory().getHNode(hNodeId);
      JSONArray hNodeRepresentation = hnode.getJSONArrayRepresentation(workspace.getFactory());
      inputColumnsArray.put(hNodeRepresentation);
    }

    for (String hNodeId : outputColumns) {
      HNode hnode = workspace.getFactory().getHNode(hNodeId);
      JSONArray hNodeRepresentation = hnode.getJSONArrayRepresentation(workspace.getFactory());
      outputColumnsArray.put(hNodeRepresentation);
    }
    worksheet.getMetadataContainer().getWorksheetProperties().setPropertyValue(
        Property.inputColumns, inputColumnsArray.toString());
    worksheet.getMetadataContainer().getWorksheetProperties().setPropertyValue(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.