@Override public Command createCommand(JSONArray inputJson, String model, Workspace workspace) throws JSONException, KarmaException { String hNodeId = HistoryJsonUtil.getStringValue(Arguments.hNodeId.name(), inputJson); String worksheetId = HistoryJsonUtil.getStringValue(Arguments.worksheetId.name(), inputJson); METAPROPERTY_NAME prop = METAPROPERTY_NAME.valueOf( HistoryJsonUtil.getStringValue(Arguments.metaPropertyName.name(), inputJson)); String propUri, propId; if (HistoryJsonUtil.valueExits(Arguments.metaPropertyUri.name(), inputJson)) { propUri = HistoryJsonUtil.getStringValue(Arguments.metaPropertyUri.name(), inputJson); propId = HistoryJsonUtil.getStringValue(Arguments.metaPropertyId.name(), inputJson); } else { propUri = HistoryJsonUtil.getStringValue(ArgumentsOld.metaPropertyValue.name(), inputJson); propId = propUri; } boolean train = HistoryJsonUtil.getBooleanValue(Arguments.trainAndShowUpdates.name(), inputJson); String rdfLiteralType = HistoryJsonUtil.getStringValue(Arguments.rdfLiteralType.name(), inputJson); this.normalizeSelectionId(worksheetId, inputJson, workspace); String selectionName = CommandInputJSONUtil.getStringValue(Arguments.selectionName.name(), inputJson); SetMetaPropertyCommand comm = new SetMetaPropertyCommand( getNewId(workspace), model, worksheetId, hNodeId, prop, propUri, propId, train, rdfLiteralType, selectionName); comm.setInputParameterJson(inputJson.toString()); return comm; }
@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; }