Package edu.isi.karma.controller.command

Examples of edu.isi.karma.controller.command.Command


  public Command createCommand(JSONArray inputJson, Workspace workspace)
      throws JSONException, KarmaException {
    String worksheetId = CommandInputJSONUtil.getStringValue(Arguments.worksheetId.name(), inputJson);
    String selectionName = CommandInputJSONUtil.getStringValue(Arguments.selectionName.name(), inputJson);
    String hNodeId = CommandInputJSONUtil.getStringValue(Arguments.hNodeId.name(), inputJson);
    Command cmd = new RefreshSelectionCommand(getNewId(workspace), worksheetId, selectionName, hNodeId);
    cmd.setInputParameterJson(inputJson.toString());
    return cmd;
  }
View Full Code Here


    String newColName = HistoryJsonUtil.getStringValue(Arguments.newColName.name(), inputJson);
    String newHNodeId = null;
    if(HistoryJsonUtil.valueExits(Arguments.newHNodeId.name(), inputJson))
      newHNodeId = HistoryJsonUtil.getStringValue(Arguments.newHNodeId.name(), inputJson);
    String selectionName = CommandInputJSONUtil.getStringValue(Arguments.selectionName.name(), inputJson);
    Command comm = new SplitValuesCommand(getNewId(workspace),
        worksheetId, hNodeId,
        delimiter, newColName, newHNodeId, selectionName);
    comm.setInputParameterJson(inputJson.toString());
    return comm;
  }
View Full Code Here

      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) {
       
      }
View Full Code Here

    for (Command c : commands) {
      if (c instanceof OperateSelectionCommand) {
        OperateSelectionCommand t = (OperateSelectionCommand)c;
        if (isSamehTableId(t.getHNodeId(), hNodeId, workspace)) {
          JSONObject obj = workspace.getCommandHistory().getCommandJSON(workspace, t);
          Command tmp = generateCommandFromJSON(workspace, obj);
          if (tmp != null)
            operationCommands.add(tmp);
        }
      }
    }
View Full Code Here

    JSONArray inputParamArr = (JSONArray) obj.get(HistoryArguments.inputParameters.name());
    String commandName = (String)obj.get(HistoryArguments.commandName.name());
    WorksheetCommandHistoryExecutor ex = new WorksheetCommandHistoryExecutor(worksheetId, workspace);
    ex.normalizeCommandHistoryJsonInput(workspace, worksheetId, inputParamArr, commandName, true);
    try {
      Command c = new OperateSelectionCommandFactory().createCommand(inputParamArr, workspace);
      return c;
    } catch (Exception e) {
      return null;
    }
  }
View Full Code Here

    boolean isPreview = Boolean.parseBoolean(request.getParameter("isPreview"));
    boolean isUserInteraction = Boolean.parseBoolean(request.getParameter("isUserInteraction"));
    boolean isExecute = Boolean.parseBoolean(request.getParameter("execute"));
    if (isUserInteraction) {
      String commandId = request.getParameter("commandId");
      Command currentCommand = (Command) ctrl.getWorkspace().getCommandHistory().getPreviewCommand(commandId);
      try {
        UpdateContainer updateContainer;
        if (!isExecute)
          updateContainer = ((IPreviewable) currentCommand).handleUserActions(request);
        else {
          ((IPreviewable) currentCommand).handleUserActions(request);
          updateContainer = ctrl.invokeCommand(currentCommand);
        }
        updateContainer.applyUpdates(vWorkspace);
        responseString = updateContainer.generateJson(vWorkspace);
      } catch (Exception e) {
        responseString = getErrorMessage(vWorkspace, e);
      }
    }
    else if (isPreview) {
      Command command = ctrl.getCommand(request);
      try {
        UpdateContainer updateContainer = ((IPreviewable) command).showPreview(request);
        ctrl.getWorkspace().getCommandHistory().addPreviewCommand(command);
        updateContainer.applyUpdates(vWorkspace);
        responseString = updateContainer.generateJson(vWorkspace);
      } catch (CommandException e) {
        responseString = getErrorMessage(vWorkspace, e);
      }

    }
    else {
      Command command = ctrl.getCommand(request);
      try {
        UpdateContainer updateContainer =ctrl.invokeCommand(command);
        updateContainer.applyUpdates(vWorkspace);
        responseString = updateContainer.generateJson(vWorkspace);
      } catch(Exception e) {
View Full Code Here

    List<Command> refinedCommands = new ArrayList<Command>();
    for (Command command : commands) {
      if (command instanceof UnassignSemanticTypeCommand) {
        Iterator<Command> itr = refinedCommands.iterator();
        while(itr.hasNext()) {
          Command tmp = itr.next();
          if (tmp.getOutputColumns().equals(command.getOutputColumns()) && (tmp instanceof SetSemanticTypeCommand || tmp instanceof SetMetaPropertyCommand)) {
            tmp.getOutputColumns().clear();
            command.getOutputColumns().clear();
          }
        }
      }
      refinedCommands.add(command);
View Full Code Here

      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, workspace);
        c.doIt(workspace);
      } catch (Exception e) {
       
      }
    }
    UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, currentSel);
View Full Code Here

    String selectionName = CommandInputJSONUtil.getStringValue(Arguments.selectionName.name(), inputJson);
    String hNodeId = CommandInputJSONUtil.getStringValue(Arguments.hNodeId.name(), inputJson);
    String operation = CommandInputJSONUtil.getStringValue(Arguments.operation.name(), inputJson);
    String pythonCode = CommandInputJSONUtil.getStringValue(Arguments.pythonCode.name(), inputJson);
    boolean onError = Boolean.parseBoolean(CommandInputJSONUtil.getStringValue(Arguments.onError.name(), inputJson));
    Command cmd = new OperateSelectionCommand(getNewId(workspace), worksheetId, selectionName, hNodeId,
        operation, pythonCode, onError);
    cmd.setInputParameterJson(inputJson.toString());
    return cmd;
  }
View Full Code Here

      throws JSONException, KarmaException {
    String worksheetId = CommandInputJSONUtil.getStringValue(Arguments.worksheetId.name(), inputJson);
    String hNodeId = CommandInputJSONUtil.getStringValue(Arguments.hNodeId.name(), inputJson);
    String type = CommandInputJSONUtil.getStringValue(Arguments.type.name(), inputJson);
    String selectionName = CommandInputJSONUtil.getStringValue(Arguments.selectionName.name(), inputJson);
    Command cmd = new ClearSelectionCommand(getNewId(workspace), worksheetId, selectionName, hNodeId, type);
    cmd.setInputParameterJson(inputJson.toString());
    return cmd;
  }
View Full Code Here

TOP

Related Classes of edu.isi.karma.controller.command.Command

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.