private JSONArray getMultiCellValueEditInputJSON(JSONArray rowsArray, String newHNodeId) throws JSONException { JSONArray arr = new JSONArray(); arr.put(CommandInputJSONUtil.createJsonObject(MultipleValueEditColumnCommandFactory.Arguments.worksheetId.name(), worksheetId, ParameterType.worksheetId)); arr.put(CommandInputJSONUtil.createJsonObject(MultipleValueEditColumnCommandFactory.Arguments.hNodeID.name(), newHNodeId, ParameterType.worksheetId)); arr.put(CommandInputJSONUtil.createJsonObject(MultipleValueEditColumnCommandFactory.Arguments.rows.name(), rowsArray, ParameterType.other)); return arr; }
private JSONArray getMultiCellValueEditInputJSON(JSONArray rowsArray, String newHNodeId) throws JSONException { JSONArray arr = new JSONArray(); arr.put(CommandInputJSONUtil.createJsonObject(MultipleValueEditColumnCommandFactory.Arguments.worksheetId.name(), worksheetId, ParameterType.worksheetId)); arr.put(CommandInputJSONUtil.createJsonObject(MultipleValueEditColumnCommandFactory.Arguments.hNodeID.name(), newHNodeId, ParameterType.worksheetId)); arr.put(CommandInputJSONUtil.createJsonObject(MultipleValueEditColumnCommandFactory.Arguments.rows.name(), rowsArray, ParameterType.other)); return arr; } }
private JSONArray getAddColumnCommandInputJSON(String hTableId) throws JSONException { JSONArray arr = new JSONArray(); arr.put(CommandInputJSONUtil.createJsonObject(AddColumnCommandFactory.Arguments.newColumnName.name(), newColumnName, ParameterType.other)); arr.put(CommandInputJSONUtil.createJsonObject(AddColumnCommandFactory.Arguments.hTableId.name(), hTableId, ParameterType.other)); arr.put(CommandInputJSONUtil.createJsonObject(AddColumnCommandFactory.Arguments.worksheetId.name(), worksheetId, ParameterType.worksheetId)); arr.put(CommandInputJSONUtil.createJsonObject(AddColumnCommandFactory.Arguments.hNodeId.name(), hNodeId, ParameterType.worksheetId)); return arr; }
if (!tmp.isEmpty()) { 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 {
@Override public UpdateContainer doIt(Workspace workspace) throws CommandException { Worksheet worksheet = workspace.getWorksheet(worksheetId); SuperSelection currentSel = getSuperSelection(worksheet); List<SelectionWithPriority> selections = new ArrayList<>(); for (Selection sel : currentSel.getAllSelection()) { HTable ht = workspace.getFactory().getHTable(sel.getHTableId()); selections.add(new SelectionWithPriority(sel, hTableDepth(ht, workspace.getFactory()))); } Collections.sort(selections); for (SelectionWithPriority s : selections) { Selection sel = s.sel; JSONArray inputJSON = new JSONArray(); HTable ht = workspace.getFactory().getHTable(sel.getHTableId()); Iterator<String> itr = ht.getHNodeIds().iterator(); inputJSON.put(CommandInputJSONUtil.createJsonObject("worksheetId", worksheetId, ParameterType.worksheetId)); inputJSON.put(CommandInputJSONUtil.createJsonObject("hNodeId", itr.next(), ParameterType.hNodeId)); inputJSON.put(CommandInputJSONUtil.createJsonObject("selectionName", currentSel.getName(), ParameterType.other)); try { Command c = new RefreshSelectionCommandFactory().createCommand(inputJSON, model, workspace); c.doIt(workspace); } catch (Exception e) { logger.error("Exception happened", e); } } UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, currentSel, workspace.getContextId()); uc.add(new HistoryUpdate(workspace.getCommandHistory())); return uc; }
protected void normalizeSelectionId(String worksheetId, JSONArray inputJson, Workspace workspace) { Worksheet worksheet = workspace.getWorksheet(worksheetId); String selectionName = CommandInputJSONUtil.getStringValue(Arguments.selectionName.name(), inputJson); if (worksheet == null) return; SuperSelection sel = worksheet.getSuperSelectionManager().getSuperSelection(selectionName); JSONObject obj = CommandInputJSONUtil.getJSONObjectWithName(selectionName, inputJson); if (obj != null) obj.put("value", sel.getName()); else CommandInputJSONUtil.createJsonObject(Arguments.selectionName.name(), sel.getName(), ParameterType.other); } }