Package edu.isi.karma.rep

Examples of edu.isi.karma.rep.HNode


  }

  private boolean isVisible(HTable headers, String key, RepFactory factory) {
    if (columnsJson == null)
      return true;
    HNode hn = headers.getParentHNode();   
    if (hn != null) {
      HNodePath hPath = hn.getHNodePath(factory);
      String path = hPath.toColumnNamePath() + "/" + key;
      Boolean b = columnsCache.get(path);
      if (b != null)
        return b;
      HNode first = null;
      JSONArray t = columnsJson;
      JSONObject tree = null;
      while (first != hn) {       
        first = hPath.getFirst();
        tree = getCorrespondingObject(t, first.getColumnName());
        if (tree == null || !tree.has("children")) {
          columnsCache.put(path, true);
          return true;
        }
        t = tree.getJSONArray("children");
View Full Code Here


      if(hTable == null) {
        return false;
      }
      String nameObjColumnName = cNameObj.getString("columnName");
      logger.debug("Column being normalized: "+ nameObjColumnName);
      HNode node = hTable.getHNodeFromColumnName(nameObjColumnName);
      if(node == null && !ignoreIfBeforeColumnDoesntExist(commandName)) { //Because add column can happen even if the column after which it is to be added is not present
        logger.info("null HNode " + nameObjColumnName + " while normalizing JSON input for the command " + commandName);
        return false;
      }

      if (j == hNodeJSONRep.length()-1) {    // Found!
        if(node != null)
          hnodeJSON.put(ClientJsonKeys.id.name(), node.getId());
        else {
          //Get the id of the last node in the table
          ArrayList<String> allNodeIds = hTable.getOrderedNodeIds();
          String lastNodeId = allNodeIds.get(allNodeIds.size()-1);
          hnodeJSON.put(ClientJsonKeys.id.name(), lastNodeId);
        }
        hTable = workspace.
            getWorksheet(worksheetId).getHeaders();
      } else if(node != null) {
        hTable = node.getNestedTable();
      }
    }
    return true;
  }
View Full Code Here

      ht = factory.getHTable(factory.getHNode(hNodeId).getHTableId());
    else
      ht = oldws.getHeaders();
    for (int i = 0; i < checked.length(); i++) {
      JSONObject t = (checked.getJSONObject(i));
      HNode hNode = ht.getHNode(t.getString("value"));
      if (hNode != null) {
        hnodes.add(hNode);
        hNodeName.add(hNode.getColumnName());
      }     
    }
    if (ht != oldws.getHeaders())
      glueNestedTable(oldws, workspace, ht, hnodes, factory);
    else
View Full Code Here

  @Override
  public UpdateContainer undoIt(Workspace workspace) {
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    UpdateContainer uc = new UpdateContainer();
    HNode ndid = workspace.getFactory().getHNode(newhNodeId);
    HTable currentTable = workspace.getFactory().getHTable(ndid.getHTableId());
    ndid.removeNestedTable();
    //remove the new column
    currentTable.removeHNode(newhNodeId, worksheet);
    uc.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet)));
    uc.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
    return uc;
View Full Code Here

    for (Table tmp : parentTables) {
      for (Row row : tmp.getRows(0, tmp.getNumRows(), selection)) {
        parentRows.add(row);
      }
    }
    HNode newNode = ht.addHNode(ht.getNewColumnName("Glue"), HNodeType.Transformation, oldws, factory);
    outputColumns.add(newNode.getId());
    newhNodeId = newNode.getId();
    HTable newht = newNode.addNestedTable(newNode.getColumnName(), oldws, factory);
    List<HNode> childHNodes = new ArrayList<HNode>();
    for (HNode hnode : hnodes) {
      if (hnode.hasNestedTable()) {
        for (HNode hn : hnode.getNestedTable().getHNodes()) {
          childHNodes.add(hn);
        }
      }
    }
    Map<String, String> mapping = CloneTableUtils.cloneHTable(ht, newht, oldws, factory, childHNodes, selection);
    for (Entry<String, String> entry : mapping.entrySet()) {
      outputColumns.add(entry.getValue());
    }
    for (Row parentRow : parentRows) {
      Table t = null;
      for (Node node : parentRow.getNodes()) {
        if (node.hasNestedTable() && node.getNestedTable().getHTableId().compareTo(ht.getId()) == 0) {
          t = node.getNestedTable();
          break;
       
      }
      ArrayList<Row> rows = t.getRows(0, t.getNumRows(), selection);
      for (Row row : rows) {
        Table nestedTable = row.getNeighbor(newNode.getId()).getNestedTable();
        generateRows(hnodes, selection, row, nestedTable, factory, mapping, childHNodes, newht);
      }

    }
  }
View Full Code Here

  }

  private void glueTopLevel(Worksheet oldws, Workspace workspace, List<HNode> hnodes, RepFactory factory) {
    HTable parentHT = oldws.getHeaders();
    SuperSelection selection = getSuperSelection(oldws);
    HNode newNode = parentHT.addHNode(parentHT.getNewColumnName("Glue"), HNodeType.Transformation, oldws, factory);
    newhNodeId = newNode.getId();
    outputColumns.add(newhNodeId);
    HTable newht = newNode.addNestedTable(newNode.getColumnName(), oldws, factory);
    List<HNode> childHNodes = new ArrayList<HNode>();
    for (HNode hnode : hnodes) {
      if (hnode.hasNestedTable()) {
        for (HNode hn : hnode.getNestedTable().getHNodes()) {
          childHNodes.add(hn);
        }
      }
    }
    Map<String, String> mapping = CloneTableUtils.cloneHTable(oldws.getHeaders(), newht, oldws, factory, childHNodes, selection);
    for (Entry<String, String> entry : mapping.entrySet()) {
      outputColumns.add(entry.getValue());
    }
    ArrayList<Row> rows = oldws.getDataTable().getRows(0, oldws.getDataTable().getNumRows(), selection);
    for (Row row : rows) {
      Table nestedTable = row.getNeighbor(newNode.getId()).getNestedTable();
      generateRows(hnodes, selection, row, nestedTable, factory, mapping, childHNodes, newht);
    }

  }
View Full Code Here

      int enumeration[] = new int[size + 1];
      while(enumeration[size] != 1) {
        Row r = nestedTable.addRow(factory);
        for (int i = 0; i < tablesToCross.size(); i++) {
          Row nestedRow = tablesToCross.get(i).get(enumeration[i]);
          HNode hnode = factory.getHNode(nestedRow.getBelongsToTable().getNestedTableInNode().getHNodeId());
          CloneTableUtils.cloneDataTableExistingRow(nestedRow, r, nestedTable, hnode.getNestedTable(), newht, childHNodes, factory, mapping, selection);
        }
        enumeration[0]++;
        for (int i = 0; i < tablesToCross.size(); i++) {
          if (enumeration[i] == tablesToCross.get(i).size()) {
            enumeration[i + 1]++;
View Full Code Here

    return false;
  }
 
  private static boolean isChildHTable(HTable parent, HTable child, RepFactory factory) {
    while (child != null) {
      HNode parentHN = child.getParentHNode();
      child = null;
      if (parentHN != null)
        child = parentHN.getHTable(factory);
      if (parent == child)
        return true;
    }
    return false;
  }
View Full Code Here

  private List<String> addHeaders (Worksheet wk, List<String> columnNames,
      RepFactory factory) {
    HTable headers = wk.getHeaders();
    ArrayList<String> headersList = new ArrayList<String>();
        for(int i=0; i< columnNames.size(); i++){
          HNode hNode = null;
          hNode = headers.addHNode(columnNames.get(i), HNodeType.Regular, wk, factory);
          headersList.add(hNode.getId());
        }
        return headersList;
  }
View Full Code Here

      writer.key(JsonKeys.Types.name());
      writer.array();
      // Iterate through all the columns
      for (HNodePath path : worksheet.getHeaders().getAllPaths()) {
        HNode node = path.getLeaf();
        String nodeId = node.getId();

        writer.object();

        // Check if a semantic type exists for the HNode
        SemanticType type = types.getSemanticTypeForHNodeId(nodeId);
View Full Code Here

TOP

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

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.