コード例 #1
0
ファイル: JsonImport.java プロジェクト: khazelton/Web-Karma
 private HNode addHNode(HTable headers, String key) {
   HNode hn = headers.getHNodeFromColumnName(key);
   if (hn == null) {
     hn = headers.addHNode(key, getWorksheet(), getFactory());
   }
   return hn;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
ファイル: JsonImport.java プロジェクト: khazelton/Web-Karma
 private void addEmptyRow(Table nestedTable, HNode hNode) {
   HTable headersNestedTable = hNode.getNestedTable();
   Row emptyRow = nestedTable.addRow(getFactory());
   for (HNode nestedHNode : headersNestedTable.getHNodes()) {
     if (nestedHNode.hasNestedTable()) {
       addEmptyRow(emptyRow.getNode(nestedHNode.getId()).getNestedTable(), nestedHNode);
     } else {
       emptyRow.setValue(nestedHNode.getId(), "", getFactory());
     }
   }
 }
コード例 #4
0
 private void getHNodesForWorksheet(HTable htable, Set<String> hnodes, RepFactory factory) {
   for (HNode hnode : htable.getHNodes()) {
     hnodes.add(hnode.getJSONArrayRepresentation(factory).toString());
     if (hnode.hasNestedTable()) {
       getHNodesForWorksheet(hnode.getNestedTable(), hnodes, factory);
     }
   }
 }
コード例 #5
0
  @Override
  public UpdateContainer doIt(Workspace workspace) throws CommandException {
    Worksheet worksheet = workspace.getWorksheet(worksheetId);
    RepFactory factory = workspace.getFactory();
    SuperSelection superSel = getSuperSelection(worksheet);
    HTable hTable = factory.getHTable(factory.getHNode(hNodeId).getHTableId());
    Selection currentSel = superSel.getSelection(hTable.getId());
    if (currentSel != null) {
      currentSel.updateSelection();
    }
    CommandHistory history = workspace.getCommandHistory();
    List<Command> tmp =
        gatherAllOperateSelectionCommands(
            history.getCommandsFromWorksheetId(worksheetId), workspace);
    if (tmp.size() > 0) {
      JSONArray inputJSON = new JSONArray();
      inputJSON.put(
          CommandInputJSONUtil.createJsonObject(
              "worksheetId", worksheetId, ParameterType.worksheetId));
      inputJSON.put(
          CommandInputJSONUtil.createJsonObject("hNodeId", hNodeId, ParameterType.hNodeId));
      inputJSON.put(
          CommandInputJSONUtil.createJsonObject(
              "operation", Operation.Intersect.name(), ParameterType.other));
      inputJSON.put(
          CommandInputJSONUtil.createJsonObject(
              "pythonCode", SelectionManager.defaultCode, ParameterType.other));
      inputJSON.put(CommandInputJSONUtil.createJsonObject("onError", "false", ParameterType.other));
      inputJSON.put(
          CommandInputJSONUtil.createJsonObject(
              "selectionName", superSel.getName(), ParameterType.other));
      Command t = null;
      try {
        t = new OperateSelectionCommandFactory().createCommand(inputJSON, workspace);
      } catch (Exception e) {

      }
      if (t != null) history._getHistory().add(t);
      history._getHistory().addAll(tmp);
    }
    UpdateContainer uc =
        WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(
            worksheetId, superSel);
    uc.add(new HistoryUpdate(history));
    return uc;
  }