本文整理了Java中edu.isi.karma.rep.Worksheet
类的一些代码示例,展示了Worksheet
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Worksheet
类的具体详情如下:
包路径:edu.isi.karma.rep.Worksheet
类名称:Worksheet
暂无
代码示例来源:origin: usc-isi-i2/Web-Karma
private Worksheet groupByTopLevel(Worksheet oldws, Workspace workspace, List<String> hnodeIDs, List<HNode> keyhnodes, List<HNode> valuehnodes, RepFactory factory) {
SuperSelection selection = getSuperSelection(oldws);
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) {
for (Entry<String, ArrayList<String>> stringArrayListEntry : hash.entrySet()) {
ArrayList<String> r = stringArrayListEntry.getValue();
Row lastRow = CloneTableUtils.cloneDataTable(factory.getRow(r.get(0)), newws.getDataTable(), newht, keyhnodes, factory, selection);
for (String rowid : r) {
Row cur = factory.getRow(rowid);
newWorksheetId = newws.getId();
return newws;
代码示例来源:origin: usc-isi-i2/Web-Karma
public SuperSelection getSuperSelection(Worksheet worksheet) {
if (selectionId == null || selectionId.trim().isEmpty())
return SuperSelectionManager.DEFAULT_SELECTION;
return worksheet.getSuperSelectionManager().getSuperSelection(selectionId);
}
代码示例来源: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
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 generateWorksheetListJson(String prefix, PrintWriter pw) {
pw.println(prefix + "{");
String newPref = prefix + " ";
pw.println(newPref
+ JSONUtil.json(WorksheetListUpdate.JsonKeys.worksheetId, this.getWorksheetId()));
pw.println(newPref
+ JSONUtil.json(WorksheetListUpdate.JsonKeys.isUpToDate, upToDate));
pw.println(newPref
+ JSONUtil.json(WorksheetListUpdate.JsonKeys.isCollapsed, collapsed));
pw.println(newPref
+ JSONUtil.json(WorksheetListUpdate.JsonKeys.encoding,
worksheet.getEncoding()));
pw.println(newPref
+ JSONUtil.jsonLast(WorksheetListUpdate.JsonKeys.title,
worksheet.getTitle()));
pw.println(prefix + "}");
}
}
代码示例来源:origin: usc-isi-i2/Web-Karma
public String publishCSV() throws FileNotFoundException {
String filename = worksheet.getTitle() + ".csv";
String outputFile = contextParameters.getParameterValue(ContextParameter.CSV_PUBLISH_DIR) +
filename;
for (SemanticType type : worksheet.getSemanticTypes().getListOfTypes()) {
modeledColumnTable.put(type.getHNodeId(),"");
int numRows = worksheet.getDataTable().getNumRows();
if(numRows==0)
return "";
StringBuilder sb = new StringBuilder();
ArrayList<Row> rows = worksheet.getDataTable().getRows(0, numRows, SuperSelectionManager.DEFAULT_SELECTION);
List<HNode> sortedLeafHNodes = new ArrayList<>();
List<String> hNodeIdList = new ArrayList<>();
worksheet.getHeaders().getSortedLeafHNodes(sortedLeafHNodes);
for (HNode hNode : sortedLeafHNodes) {
if(modeledColumnTable.containsKey(hNode.getId())) {
代码示例来源:origin: usc-isi-i2/Web-Karma
public boolean containSource() {
if (this.getMetadataContainer() == null) {
return false;
}
if (this.getMetadataContainer().getSource() == null) {
return false;
}
return true;
}
代码示例来源:origin: usc-isi-i2/Web-Karma
public String getWorksheetId() {
return worksheet.getId();
}
代码示例来源:origin: usc-isi-i2/Web-Karma
String path = contextParameters
.getParameterValue(ContextParameter.PRELOADED_ONTOLOGY_DIRECTORY)
+ worksheet.getTitle() + ".owl";
try {
autoOntology.Build(path);
getNewId(workspace), model, worksheet.getId());
type = new SemanticType(hNodeId, typeName, domainName, domainId,
false, Origin.User, 1.00);
worksheet.getSemanticTypes().addType(type);
代码示例来源:origin: usc-isi-i2/Web-Karma
public JsonImport(Object json, RepFactory repFactory, Worksheet wk, Workspace workspace,
int maxNumLines) {
super(repFactory, wk);
this.json = json;
this.workspace = workspace;
this.maxNumLines = maxNumLines;
this.worksheetName = wk.getTitle();
this.encoding = "UTF-8";
}
代码示例来源: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 void populateHNodeIdAndColumnNameMaps()
{
HTable hTable = worksheet.getHeaders();
populateHNodeIdAndColumnNameMapsForHTable(hTable);
}
private void populateHNodeIdAndColumnNameMapsForHTable(HTable hTable) {
代码示例来源:origin: usc-isi-i2/Web-Karma
Value srcNameVal = f.createLiteral(worksheet.getTitle());
con.add(mappingRes, repoURIs.get(Uris.KM_SOURCE_NAME_URI), srcNameVal);
String inputColumns = worksheet.getMetadataContainer().getWorksheetProperties().getPropertyValue(
Property.inputColumns);
String outputColumns = worksheet.getMetadataContainer().getWorksheetProperties().getPropertyValue(
Property.outputColumns);
String oldHistory = worksheet.getMetadataContainer().getWorksheetProperties().getPropertyValue(
Property.oldCommandHistory);
String graphLabel = worksheet.getMetadataContainer().getWorksheetProperties().getPropertyValue(
Property.graphLabel);
String baseURI = worksheet.getMetadataContainer().getWorksheetProperties().getPropertyValue(
Property.baseURI);
代码示例来源:origin: usc-isi-i2/Web-Karma
protected UpdateContainer savePreset(Workspace workspace, final Worksheet wsht) throws FileNotFoundException {
final ServletContextParameterMap contextParameters = ContextParametersRegistry.getInstance().getContextParameters(workspace.getContextId());
final String jsonFileName = workspace.getCommandPreferencesId() + wsht.getId() + "-" +
wsht.getTitle().replaceAll("\\.", "_") + "-preset"+".json";
final String jsonFileLocalPath = contextParameters.getParameterValue(ContextParameter.JSON_PUBLISH_DIR) +
jsonFileName;
PrintWriter printWriter = new PrintWriter(jsonFileLocalPath);
printWriter.println(new JSONArray(columnsJson).toString(4));
printWriter.close();
return new UpdateContainer(new AbstractUpdate() {
@Override
public void generateJson(String prefix, PrintWriter pw, VWorkspace vWorkspace) {
JSONObject outputObject = new JSONObject();
try {
outputObject.put(JsonKeys.updateType.name(),
"PublishPresetUpdate");
outputObject.put(JsonKeys.fileUrl.name(),
contextParameters.getParameterValue(ContextParameter.JSON_PUBLISH_RELATIVE_DIR) + jsonFileName);
outputObject.put(JsonKeys.worksheetId.name(),
wsht.getId());
pw.println(outputObject.toString(4));
} catch (JSONException e) {
logger.error("Error occured while generating JSON!");
}
}
});
}
代码示例来源:origin: usc-isi-i2/Web-Karma
Worksheet worksheet = workspace.getWorksheet(worksheetId);
worksheetName = worksheet.getTitle();
Label internalNodeLabel = new Label(ns + worksheet.getTitle().trim().replaceAll(" ", "_"), ns, "karma");
Node classNode = alignment.addInternalNode(internalNodeLabel);
worksheet.getHeaders().getSortedLeafHNodes(sortedLeafHNodes);
for (HNode hNode : sortedLeafHNodes){
String columnName = hNode.getColumnName().trim().replaceAll(" ", "_");
worksheet.getSemanticTypes().addType(type);
saveSemanticTypesInformation(worksheet, workspace, worksheet.getSemanticTypes().getListOfTypes());
代码示例来源:origin: usc-isi-i2/Web-Karma
Worksheet worksheet = workspace.getWorksheet(worksheetId);
SemanticTypes types = worksheet.getSemanticTypes();
oldSemanticTypes = types.getSemanticTypeForHNodeId(hNodeId);
HashMap<String, SemanticType> semanticIdMap = new HashMap<>();
List<HNodePath> columnPaths = worksheet.getHeaders().getAllPaths();
for (HNodePath path : columnPaths) {
if (path.getLeaf().getId().equals(hNodeId)) {
worksheet.getDataTable().collectNodes(currentPath, nodes, SuperSelectionManager.DEFAULT_SELECTION);
Set<String> nodeIds = new HashSet<>();
for (edu.isi.karma.rep.Node node : nodes) {
代码示例来源: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();
List<VHNode> viewHeaders = vWorksheet.getHeaderViewNodes();
JSONArray columns = getColumnsJsonArray(viewHeaders, wk.getSemanticTypes());
response.put(JsonKeys.columns.name(), columns);
pw.println(response.toString());
if (deleteAfterGenerate) {
vWorkspace.getWorkspace().getFactory().removeWorksheet(wk.getId(), vWorkspace.getWorkspace().getCommandHistory());
vWorkspace.getViewFactory().removeWorksheet(wk.getId());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
代码示例来源:origin: usc-isi-i2/Web-Karma
public void Build(String path) throws IOException {
worksheet.getHeaders().getSortedLeafHNodes(sortedLeafHNodes);
OntModel autoOntology = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
String ns = Namespaces.KARMA;
autoOntology.setNsPrefix("karma", ns);
OntClass topClass = autoOntology.createClass( ns + worksheet.getTitle().replaceAll(" ", "_")); // replace blank spaces with undrscore
for (HNode hNode : sortedLeafHNodes){
DatatypeProperty dp = autoOntology.createDatatypeProperty(ns+hNode.getColumnName().trim().replaceAll(" ", "_"));
代码示例来源:origin: usc-isi-i2/Web-Karma
@Override
public UpdateContainer doIt(Workspace workspace) throws CommandException {
UpdateContainer c = new UpdateContainer();
try {
Import imp = createImport(workspace);
Worksheet wsht = imp.generateWorksheet();
if (hasRevisionId()) {
Worksheet revisedWorksheet = workspace.getWorksheet(getRevisionId());
wsht.setRevisedWorksheet(revisedWorksheet);
}
c.add(new WorksheetListUpdate());
c.append(WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(wsht.getId(), SuperSelectionManager.DEFAULT_SELECTION, workspace.getContextId()));
} catch (JSONException | IOException | KarmaException | NullPointerException | ClassNotFoundException e) {
logger.error("Error occured while generating worksheet from " + getTitle() + "!", e);
return new UpdateContainer(new ErrorUpdate(
"Error occured during import: " + e.getMessage()));
}
return c;
}
代码示例来源:origin: usc-isi-i2/Web-Karma
@Override
public UpdateContainer undoIt(Workspace workspace) {
inputColumns.clear();
outputColumns.clear();
RepFactory factory = workspace.getFactory();
Worksheet worksheet = workspace.getWorksheet(worksheetId);
SuperSelection superSel = getSuperSelection(worksheet);
HNode hNode = workspace.getFactory().getHNode(hNodeId);
Selection currentSel = superSel.getSelection(hNode.getHTableId());
if (previousSelection != null) {
superSel.addSelection(previousSelection);
outputColumns.addAll(previousSelection.getInputColumns());
}
if (currentSel != null) {
worksheet.getSelectionManager().removeSelection(currentSel);
superSel.removeSelection(currentSel);
}
worksheet.getMetadataContainer().getColumnMetadata().removeSelectionPythonCode(factory.getHTable(factory.getHNode(hNodeId).getHTableId()).getId());
WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, superSel, workspace.getContextId());
uc.add(new WorksheetSuperSelectionListUpdate(worksheetId));
return uc;
}
内容来源于网络,如有侵权,请联系作者删除!