private void addTransformedValue(JSONArray transformedRows, Row row, String transformedValue) throws JSONException { JSONObject transformedRow = new JSONObject(); transformedRow.put( MultipleValueEditColumnCommandFactory.Arguments.rowID.name(), row.getId()); transformedRow.put( MultipleValueEditColumnCommandFactory.Arguments.value.name(), transformedValue); transformedRows.put(transformedRow); }
public Command createCommand(JSONArray inputJson, String model, Workspace workspace) throws JSONException, KarmaException { /** Parse the input arguments and create proper data structues to be passed to the command **/ String hNodeID = CommandInputJSONUtil.getStringValue(Arguments.hNodeID.name(), inputJson); String worksheetId = CommandInputJSONUtil.getStringValue(Arguments.worksheetId.name(), inputJson); JSONArray rows = CommandInputJSONUtil.getJSONArrayValue(Arguments.rows.name(), inputJson); Map<String, String> rowValueMap = new HashMap<>(); for (int i=0; i<rows.length(); i++) { JSONObject rowObj = rows.getJSONObject(i); rowValueMap.put(rowObj.getString(Arguments.rowID.name()), rowObj.getString(Arguments.value.name())); } return new MultipleValueEditColumnCommand(getNewId(workspace), model, worksheetId, hNodeID, rowValueMap); }
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; }