Examples of HNode


Examples of edu.isi.karma.rep.HNode

    StringBuilder str = new StringBuilder();
    for (TemplateTerm term:termSet) {
      if (term instanceof StringTemplateTerm) {
        str.append(term.getTemplateTermValue());
      } else if (term instanceof ColumnTemplateTerm) {
        HNode hNode = factory.getHNode(term.getTemplateTermValue());
        if (hNode != null) {
          String colNameStr = "";
          try {
            JSONArray colNameArr = hNode.getJSONArrayRepresentation(factory);
            if (colNameArr.length() == 1) {
              colNameStr = (String)
                  (((JSONObject)colNameArr.get(0)).get("columnName"));
            } else {
              JSONArray colNames = new JSONArray();
View Full Code Here

Examples of edu.isi.karma.rep.HNode

    StringBuilder str = new StringBuilder();
    for (TemplateTerm term:termSet) {
      if (term instanceof StringTemplateTerm) {
        str.append(term.getTemplateTermValue());
      } else if (term instanceof ColumnTemplateTerm) {
        HNode hNode = factory.getHNode(term.getTemplateTermValue());
        if (hNode != null) {
          String colNameStr = "";
          try {
            JSONArray colNameArr = hNode.getJSONArrayRepresentation(factory);
            if (colNameArr.length() == 1) {
              colNameStr = (String)
                  (((JSONObject)colNameArr.get(0)).get("columnName"));
            } else {
              JSONArray colNames = new JSONArray();
View Full Code Here

Examples of edu.isi.karma.rep.HNode

  }

  protected
  void visit(PythonTransformationColumnToken pythonTransformationToken) {
   
    HNode columnHNode = referenceHNode.getNeighborByColumnName(pythonTransformationToken.toString(), factory);
    String columnName = translator.getColumnNameForHNodeId(columnHNode.getId());
    tts.addTemplateTermToSet(new ColumnTemplateTerm(columnName));
   
  }
View Full Code Here

Examples of edu.isi.karma.rep.HNode

  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    RepFactory f = workspace.getFactory();
    HNode hNode = f.getHNode(hNodeId);
    inputColumns.clear();
    outputColumns.clear();
    outputColumns.add(targetHNodeId);
    ExecutionController ctrl = WorkspaceRegistry.getInstance().getExecutionController(
        workspace.getId());
View Full Code Here

Examples of edu.isi.karma.rep.HNode

            "Add column failed to create " + newColumnName
                + " because it already exists!"));
      }  
      //add new column to this table
      //add column after the column with hNodeId
      HNode ndid = hTable.addNewHNodeAfter(hNodeId, HNodeType.Transformation, workspace.getFactory(), newColumnName, worksheet,true);
      if(ndid == null)
      {
        logger.error("Unable to add new HNode!");
        throw new KarmaException("Unable to add new HNode!");
      }
      //add as first column in the table if hNodeId is null
      //HNode ndid = currentTable.addNewHNodeAfter(null, vWorkspace.getRepFactory(), newColumnName, worksheet,true);

      //save the new hNodeId for undo
      newHNodeId = ndid.getId();
     
      // Populate the column with default value if default value is present
      if (this.defaultValue != null && !this.defaultValue.equals("")) {
        populateRowsWithDefaultValues(worksheet, workspace.getFactory());
      }
     
      //create container and return hNodeId of newly created column
      UpdateContainer c =  new UpdateContainer(new AddColumnUpdate(newHNodeId, worksheetId));
     
      c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet)));
      c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace, ndid.getHNodePath(workspace.getFactory())));
      return c;
    } catch (Exception e) {
      logger.error("Error in AddColumnCommand" + e.toString());
      Util.logException(logger, e);
      return new UpdateContainer(new ErrorUpdate(e.getMessage()));
View Full Code Here

Examples of edu.isi.karma.rep.HNode

    inputColumns.clear();
    outputColumns.clear();
//    outputColumns.add(targetHNodeId);
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    RepFactory f = workspace.getFactory();
    HNode hNode = f.getHNode(hNodeId);
    String hTableId = hNode.getHTableId();
    HTable hTable = hNode.getHTable(f);
    String nodeId = hTable.getHNodeIdFromColumnName(newColumnName);
    inputColumns.clear();
    ExecutionController ctrl = WorkspaceRegistry.getInstance().getExecutionController(
        workspace.getId());

    // Invoke the add column command
    logger.debug("SubmitPythonTranformation: " + hNodeId + ":" + nodeId);
    try
    {
      HNode newColumnNameHNode = hTable.getHNodeFromColumnName(newColumnName);
      if(null != newColumnNameHNode ) //Column name already exists
      {
        pythonNodeId = nodeId;

        saveOrResetColumnValues(workspace, ctrl);
View Full Code Here

Examples of edu.isi.karma.rep.HNode

  protected void saveColumnValues(Workspace workspace) {
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    SuperSelection selection = getSuperSelection(worksheet);
    RepFactory f = workspace.getFactory();
    HNode hNode = f.getHNode(pythonNodeId);

    this.originalColumnValues = new ArrayList<String>();
    Collection<Node> nodes = new ArrayList<Node>();
    worksheet.getDataTable().collectNodes(hNode.getHNodePath(f), nodes, selection);
    for(Node node : nodes) {
      originalColumnValues.add(node.getValue().asString());
    }
  }
View Full Code Here

Examples of edu.isi.karma.rep.HNode

  public void resetColumnValues(Workspace workspace) {
    if(this.originalColumnValues != null) {
      Worksheet worksheet = workspace.getWorksheet(worksheetId);
      SuperSelection selection = getSuperSelection(worksheet);
      RepFactory f = workspace.getFactory();
      HNode hNode = f.getHNode(pythonNodeId);

      worksheet.getDataTable().setCollectedNodeValues(hNode.getHNodePath(f), this.originalColumnValues, f, selection);
    }
  }
View Full Code Here

Examples of edu.isi.karma.rep.HNode

    while (c != ']') {
      if (maxNumLines > 0 && numObjects >= maxNumLines)
        break;
      if (c != '{' && c != '[') {
        token.back();
        HNode hNode = addHNode(headers, HTable.VALUES_COLUMN, DataStructure.PRIMITIVE, factory, worksheet);
        String hNodeId = hNode == null ? null : hNode.getId();
        String value = token.nextValue().toString();
        if (hNodeId != null) {
          Row row = dataTable.addRow(factory);
          numObjects++;
          row.setValue(hNodeId, value, factory);
        }
      }
      else if (c == '{') {
        if (maxNumLines <= 0 || numObjects < maxNumLines) {
          if (headers != null && dataTable != null)
            numObjects++;
          addKeysAndValues(token, headers, dataTable);
        }
      }
      else if (c == '[') {
        if (maxNumLines <= 0 || numObjects < maxNumLines) {
          HNode hNode = addHNode(headers, "nested array", DataStructure.COLLECTION, factory, worksheet);
          String hNodeId = hNode == null ? null : hNode.getId();
          if (hNodeId != null) {
            Row row = dataTable.addRow(factory);
            numObjects++;
            if (maxNumLines > 0 && numObjects >= maxNumLines)
              return;
View Full Code Here

Examples of edu.isi.karma.rep.HNode

  }

  public HNode addHNode(HTable headers, String key, DataStructure dataStructure, RepFactory factory, Worksheet worksheet) {
    if (headers == null)
      return null;
    HNode hn = headers.getHNodeFromColumnName(key);
    if (hn == null && isVisible(headers, key, factory)) {
      hn = headers.addHNode(key, HNodeType.Regular, worksheet, factory);
      Worksheet ws = worksheet;
      ws.getMetadataContainer().getColumnMetadata().addColumnDataStructure(hn.getId(), dataStructure);
    }
    return hn;
  }
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.