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

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

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

Worksheet.getHeaders介绍

暂无

代码示例

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

public void populateHNodeIdAndColumnNameMaps()
{
  HTable hTable = worksheet.getHeaders();
  populateHNodeIdAndColumnNameMapsForHTable(hTable);
}
private void populateHNodeIdAndColumnNameMapsForHTable(HTable hTable) {

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

private List<String> addHeaders (Worksheet wk, List<String> columnNames,
      RepFactory factory) {
    HTable headers = wk.getHeaders();
    List<String> headersList = new ArrayList<>();

    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;
  }
}

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

private Map<String, String> getColumnMap() {
  // Prepare a map of the column names that we use for descriptions
  List<HNode> sortedLeafHNodes = new ArrayList<>();
  worksheet.getHeaders().getSortedLeafHNodes(sortedLeafHNodes);
  Map<String, String> columnNameMap = new HashMap<>();
  for (HNode hNode : sortedLeafHNodes) {
    columnNameMap.put(hNode.getId(), hNode.getColumnName());
  }
  return columnNameMap;
}

代码示例来源: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) {
  JSONObject response = new JSONObject();
  response.put(AbstractUpdate.GenericJsonKeys.updateType.name(), 
      "PreviewHeaderUpdate");
  JSONArray columns = getColumnsJsonArray(worksheet.getHeaders().getHNodes());
  response.put(JsonKeys.columns.name(), columns);
  pw.println(response.toString());
}

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

private static List<String> addHeaders(List<Attribute> tableHeader, Worksheet worksheet, RepFactory factory) {
  HTable headers = worksheet.getHeaders();
  List<String> headersList = new ArrayList<>();
  
  for (int i = 0; i < tableHeader.size(); i++) {
    Attribute att = tableHeader.get(i);
    HNode hNode = headers.addHNode(att.getName(), HNodeType.Regular, worksheet, factory);
    headersList.add(hNode.getId());
    
    // very important 
    // update the hNodeId of the input/output attributes
    att.sethNodeId(hNode.getId());
  }
  return headersList;
}

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

private int hTableDepth(HTable hTable, RepFactory factory) {
  int depth = 0;
  while (hTable != factory.getWorksheet(worksheetId).getHeaders()) {
    depth++;
    hTable = hTable.getParentHNode().getHTable(factory);
  }
  return depth;
}

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

public SemanticTypeColumnModel predictColumnSemanticType(Workspace workspace, Worksheet worksheet, String hNodeId, int numSuggestions, SuperSelection sel) {
  HNodePath currentColumnPath = null;
  List<HNodePath> paths = worksheet.getHeaders().getAllPaths();
  for (HNodePath path : paths) {
    if (path.getLeaf().getId().equals(hNodeId)) {
      currentColumnPath = path;
      break;
    }
  }
  if(currentColumnPath != null)
    return predictColumnSemanticType(workspace, worksheet,currentColumnPath, numSuggestions, sel);
  return null;
}

代码示例来源: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

private Map<Integer, String> addHeaders(Worksheet worksheet, RepFactory fac,
    String[] rowValues, CSVReader reader) throws IOException {
  HTable headers = worksheet.getHeaders();
  Map<Integer, String> headersMap = new HashMap<>();
  for (int i = 0; i < rowValues.length; i++) {
    HNode hNode = null;
    if (headerRowIndex == 0) {
      if (isVisible("Column_" + (i + 1)))
        hNode = headers.addHNode("Column_" + (i + 1), HNodeType.Regular, worksheet, fac);
    } else {
      if (isVisible(rowValues[i]))
        hNode = headers.addHNode(rowValues[i], HNodeType.Regular, worksheet, fac);
    }
    if (hNode != null)
      headersMap.put(i, hNode.getId());
  }
  return headersMap;
}

代码示例来源: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

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 updateColumnNodesInAlignment(Worksheet worksheet) {
  for (HNodePath path : worksheet.getHeaders().getAllPaths()) {
    HNode node = path.getLeaf();
    String hNodeId = node.getId();
    Node n = getNodeById(hNodeId);
    if (n == null) {
      addColumnNode(hNodeId, node.getColumnName(), null, null);
    }
  }

  
}

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

@Override
public UpdateContainer undoIt(Workspace workspace) {
  UpdateContainer c = new UpdateContainer();
  
  // Create new vWorksheet using the new header order
  List<HNodePath> columnPaths = new ArrayList<>();
  for (HNode node : worksheetBeforeInvocation.getHeaders().getSortedHNodes()) {
    HNodePath path = new HNodePath(node);
    columnPaths.add(path);
  }
  workspace.getFactory().replaceWorksheet(this.worksheetId, this.worksheetBeforeInvocation);
  
  c.add(new ReplaceWorksheetUpdate(worksheetId, this.worksheetBeforeInvocation));
  c.append(WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, getSuperSelection(workspace),workspace.getContextId()));
  
  return c;	
  
}

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

@Override
public void applyUpdate(VWorkspace vWorkspace)
{
  VWorksheet vWorksheet =  vWorkspace.getViewFactory().getVWorksheetByWorksheetId(worksheetId);
  Worksheet worksheet = vWorksheet.getWorksheet();
  vWorkspace.getViewFactory().updateWorksheet(vWorksheet.getId(), worksheet,
      worksheet.getHeaders().getAllPaths(), vWorkspace);
}

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

@Override
public void applyUpdate(VWorkspace vWorkspace)
{
  VWorksheet vWorksheet = vWorkspace.getViewFactory().getVWorksheetByWorksheetId(worksheetId);
  Worksheet worksheet = vWorksheet.getWorksheet();
  vWorkspace.getViewFactory().updateWorksheet(vWorksheet.getId(), worksheetBeforeInvocation,
      worksheet.getHeaders().getAllPaths(), vWorkspace);
}

代码示例来源: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 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

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

Worksheet newws = factory.createWorksheet("GroupBy: " + oldws.getTitle(), workspace, oldws.getEncoding());
newws.getMetadataContainer().getWorksheetProperties().setPropertyValue(Property.sourceType, oldws.getMetadataContainer().getWorksheetProperties().getPropertyValue(Property.sourceType));
HTable newht =  newws.getHeaders();
ArrayList<Row> rows = oldws.getDataTable().getRows(0, oldws.getDataTable().getNumRows(), selection);
HTable oldht =  oldws.getHeaders();
Map<String, ArrayList<String>> hash = new TreeMap<>();
for (Row row : rows) {

相关文章