edu.isi.karma.rep.Worksheet.getDataTable()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中edu.isi.karma.rep.Worksheet.getDataTable()方法的一些代码示例,展示了Worksheet.getDataTable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Worksheet.getDataTable()方法的具体详情如下:
包路径:edu.isi.karma.rep.Worksheet
类名称:Worksheet
方法名:getDataTable

Worksheet.getDataTable介绍

暂无

代码示例

代码示例来源:origin: usc-isi-i2/Web-Karma

private ArrayList<Row> getRows() {
  int numRows = worksheet.getDataTable().getNumRows();
  return worksheet.getDataTable().getRows(0, numRows, selection);
}

代码示例来源:origin: usc-isi-i2/Web-Karma

private ArrayList<Row> getRows() {
  int numRows = worksheet.getDataTable().getNumRows();
  return worksheet.getDataTable().getRows(0, numRows, selection);
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public TablePager getTopTablePager() {
  return tableId2TablePager.get(worksheet.getDataTable().getId());
}

代码示例来源:origin: usc-isi-i2/Web-Karma

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<>();
  Collection<Node> nodes = new ArrayList<>();
  worksheet.getDataTable().collectNodes(hNode.getHNodePath(f), nodes, selection);
  for(Node node : nodes) {
    originalColumnValues.add(node.serializeToJSON(selection, f).toString());
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

SuperSelection selection = getSuperSelection(wk);
List<String> requestURLStrings = new ArrayList<>();
List<Row> rows = wk.getDataTable().getRows(0, wk.getDataTable().getNumRows(), selection);
if (rows == null || rows.isEmpty()) {
  logger.error("Data table does not have any row.");

代码示例来源:origin: usc-isi-i2/Web-Karma

public static void populateEmptyWorksheet(Table table, Worksheet worksheet, RepFactory factory) {
  logger.info("Populating an empty worksheet with the service data ...");
  List<String> hNodeIdList = addHeaders(table.getHeaders(), worksheet, factory);
  edu.isi.karma.rep.Table dataTable = worksheet.getDataTable();
  addRows(table.getValues(), worksheet, factory, hNodeIdList, dataTable);
}

代码示例来源:origin: usc-isi-i2/Web-Karma

private void populateRowsWithDefaultValues(Worksheet worksheet, RepFactory factory) {
  SuperSelection selection = getSuperSelection(worksheet);
  HNodePath selectedPath = null;
  List<HNodePath> columnPaths = worksheet.getHeaders().getAllPaths();
  for (HNodePath path : columnPaths) {
    if (path.getLeaf().getId().equals(newHNodeId)) {
      selectedPath = path;
    }
  }
  Collection<Node> nodes = new ArrayList<>(Math.max(1000, worksheet.getDataTable().getNumRows()));
  worksheet.getDataTable().collectNodes(selectedPath, nodes, selection);	
  for (Node node : nodes) {
    node.setValue(this.defaultValue, NodeStatus.original, factory);
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public void removeWorksheet(String id, CommandHistory history) {
  if(worksheets.containsKey(id)) {
    Worksheet worksheet = worksheets.get(id);
    removeHTableRecursive(worksheet.getHeaders());
    removeDataTableRecursive(worksheet.getDataTable());
    worksheet.getMetadataContainer().setColumnMetadata(null);
    worksheet.setMetadataContainer(null);
    history.removeCommands(id);
    worksheets.remove(id);
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public static void populateWorksheet(Table table, Worksheet worksheet, RepFactory factory, SuperSelection sel) {
  logger.info("Populating existing worksheet with the service data ...");
  List<String> oldHNodeIdList = new ArrayList<>(worksheet.getHeaders().getHNodeIds());
  List<String> hNodeIdList = addHeaders(table.getHeaders(), worksheet, factory);
  edu.isi.karma.rep.Table dataTable = worksheet.getDataTable();
  updateRows(table.getValues(), table.getRowIds(), worksheet, factory, oldHNodeIdList, hNodeIdList, dataTable, sel);
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public void replaceWorksheet(String id, Worksheet worksheet) {
  Worksheet oldWorksheet = worksheets.get(id);
  if (oldWorksheet != null) {
    removeHTableRecursive(oldWorksheet.getHeaders());
    removeDataTableRecursive(oldWorksheet.getDataTable());
    oldWorksheet.getMetadataContainer().setColumnMetadata(null);
    oldWorksheet.setMetadataContainer(null);
    worksheets.put(id, worksheet);
    hTables.put(worksheet.getHeaders().getId(), worksheet.getHeaders());
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

@Override
public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) {
  VWorksheet vWorksheet =  vWorkspace.getViewFactory().getVWorksheetByWorksheetId(worksheetId);
  try {
    JSONObject response = new JSONObject();
    response.put(JsonKeys.worksheetId.name(), worksheetId);
    response.put(AbstractUpdate.GenericJsonKeys.updateType.name(), 
        this.getClass().getSimpleName());
    Worksheet wk = vWorksheet.getWorksheet();
    Table dataTable = wk.getDataTable();
    TablePager pager = vWorksheet.getTopTablePager();
    JSONArray rows = getRowsUsingPager(
        pager, vWorksheet,
        vWorksheet.getHeaderViewNodes(), vWorkspace.getPreferences().getIntViewPreferenceValue(
            ViewPreference.maxCharactersInCell));
    int rowsLeft = dataTable.getNumRows() - rows.length();
    rowsLeft = rowsLeft < 0 ? 0 : rowsLeft;
    response.put(JsonKeys.additionalRowsCount.name(), rowsLeft);
    response.put(JsonKeys.tableId.name(), dataTable.getId());
    response.put(JsonKeys.rows.name(), rows);
    pw.println(response.toString());
  } catch (JSONException e) {
    logger.error("JSONException", e);
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

protected Map<String, String> gatherTransformedResults(Workspace workspace, String hNodeId) {
  Map<String, String> rowToValueMapping = new HashMap<>();
  HNodePath hNodePath = workspace.getFactory().getHNode(hNodeId).getHNodePath(workspace.getFactory());
  List<Node> nodes = new ArrayList<>();
  workspace.getWorksheet(worksheetId).getDataTable().collectNodes(hNodePath, nodes, getSuperSelection(workspace));
  for (Node node : nodes) {
    rowToValueMapping.put(node.getBelongsToRow().getId(), node.getValue().asString());
    node.clearValue(NodeStatus.original);
    affectedNodes.add(node);
  }
  return rowToValueMapping;
}

代码示例来源:origin: usc-isi-i2/Web-Karma

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<>();
  for (HNode hnode : hnodes) {
    if (hnode.hasNestedTable()) {
      for (HNode hn : hnode.getNestedTable().getHNodes()) {
        childHNodes.add(hn);
      }
    }
  }
  Map<String, String> mapping = CloneTableUtils.cloneHTable(newht, oldws, factory, childHNodes, true);
  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);
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

private void populateSelection() {
  final ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(workspace.getContextId());
  List<Table> tables = new ArrayList<>();
  Worksheet worksheet = workspace.getWorksheet(worksheetId);
  CloneTableUtils.getDatatable(worksheet.getDataTable(), workspace.getFactory().getHTable(hTableId), tables, SuperSelectionManager.DEFAULT_SELECTION);
  String selectionId = String.format("%d_%d_%s", System.currentTimeMillis(), Thread.currentThread().getId(), this.superSelectionName);//Thread.currentThread().getId() + this.superSelectionName;
  PythonRepository repo = PythonRepositoryRegistry.getInstance().getPythonRepository(contextParameters.getParameterValue(ContextParameter.USER_PYTHON_SCRIPTS_DIRECTORY));
  PythonInterpreter interpreter = repo.getInterpreter();
  repo.initializeInterpreter(interpreter);
  PyCode code;
  try {
    code = getCompiledCode(pythonCode, interpreter, selectionId);
    interpreter.getLocals().__setitem__("selection", interpreter.get("selection"+selectionId));
    
  
    for (Table t : tables) {
      for (Row r : t.getRows(0, t.getNumRows(), SuperSelectionManager.DEFAULT_SELECTION)) {
        if (code == null)
          selectedRowsCache.put(r, onError);
        else
          selectedRowsCache.put(r, evaluatePythonExpression(r, code, interpreter));
      }
    }
  } catch(Exception e) {
    logger.error("Unable to populate selection");
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public void empty() {
  RepFactory factory = workspace.getFactory();
  HTable ht = factory.getHTable(factory.getHNode(hNodeId).getHTableId());
  List<Table> tables = new ArrayList<>();
  
  CloneTableUtils.getDatatable(worksheet.getDataTable(), ht, tables, selection);
  for (Table t : tables) {
    for (Row r : t.getRows(0, t.getNumRows(), selection)) {
      Node newNode = r.getNeighbor(newhNodeId);
      newNode.getNestedTable().removeAllRows();
    }
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public void resetColumnValues(Workspace workspace) {
  if(this.originalColumnValues != null) {
    removeNestedTable(workspace);
    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);
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

VWorksheet(String id, Worksheet worksheet, List<HNodePath> columns,
    VWorkspace vWorkspace) {
  super(id);
  this.worksheet = worksheet;
  //this.columns = columns;
  this.maxRowsToShowInNestedTables = vWorkspace.getPreferences()
      .getIntViewPreferenceValue(
          ViewPreference.maxRowsToShowInNestedTables);
  // Force creation of the TablePager for the top table.
  getTablePager(worksheet.getDataTable(),
      vWorkspace.getPreferences().getIntViewPreferenceValue(
          ViewPreference.defaultRowsToShowInTopTables));
  
  
  this.headerViewNodes = initHeaderViewNodes(worksheet.getHeaders());
}

代码示例来源:origin: usc-isi-i2/Web-Karma

private void removeNestedTable(Workspace workspace) {
  HNode hNode = workspace.getFactory().getHNode(pythonNodeId);
  hNode.removeNestedTable();
  List<Node> nodes = new ArrayList<>();
  workspace.getWorksheet(worksheetId).getDataTable().collectNodes(hNode.getHNodePath(workspace.getFactory()), nodes, getSuperSelection(workspace.getWorksheet(worksheetId)));
  for (Node node : nodes) {
    node.setNestedTable(null, workspace.getFactory());
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public VWorksheet createVWorksheetWithDefaultPreferences(
      VWorkspace vWorkspace, Worksheet w) {

    ViewPreferences pref = vWorkspace.getPreferences();
    return vWorkspace
        .getViewFactory()
        .createVWorksheet(
            w,
            w.getHeaders().getAllPaths(),
            w.getDataTable()
                .getRows(
                    0,
                    pref.getIntViewPreferenceValue(ViewPreference.defaultRowsToShowInTopTables),
                    SuperSelectionManager.DEFAULT_SELECTION),
            vWorkspace);
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public HTable addNestedHTable(HNode hNode, String key, Row row) {
  HTable ht = hNode.getNestedTable();
  if (ht == null) {
    ht = hNode.addNestedTable(createNestedTableName(key),
        worksheet, factory);
    // Check for all the nodes that have value and nested tables
    Collection<Node> nodes = new ArrayList<>();
    worksheet.getDataTable().collectNodes(
        hNode.getHNodePath(factory), nodes, SuperSelectionManager.DEFAULT_SELECTION);
    for (Node node : nodes) {
      if (node.getBelongsToRow() == row)
        break;
      // Add an empty row for each nested table that does not have any
      // row
      if (node.getNestedTable().getNumRows() == 0) {
        addEmptyRow(node.getNestedTable(), hNode);
      }
    }
  }
  return ht;
}

相关文章