Package edu.isi.karma.controller.command

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


      if (command instanceof SubmitEditPythonTransformationCommand) {
        Iterator<Command> itr = refinedCommands.iterator();
        boolean flag = true;
        boolean found = false;
        while(itr.hasNext()) {
          Command tmp = itr.next();
          if (tmp.getOutputColumns().equals(command.getOutputColumns()) && tmp instanceof SubmitPythonTransformationCommand && !(tmp instanceof SubmitEditPythonTransformationCommand)) {
//            System.out.println("May Consolidate");
            SubmitPythonTransformationCommand py = (SubmitPythonTransformationCommand)tmp;
            SubmitPythonTransformationCommand edit = (SubmitPythonTransformationCommand)command;
            JSONArray inputJSON = new JSONArray(py.getInputParameterJson());
            HistoryJsonUtil.setArgumentValue("transformationCode", edit.getTransformationCode(), inputJSON);
            py.setInputParameterJson(inputJSON.toString());
            py.setTransformationCode(edit.getTransformationCode());
            flag = false;
//            System.out.println(py.getInputParameterJson());
            try {
              py.doIt(workspace);
            } catch (CommandException e) {
              // TODO Auto-generated catch block
            }
            found = true;
            //PlaceHolder
          }
          if (tmp.getOutputColumns().equals(command.getOutputColumns()) && tmp instanceof SubmitEditPythonTransformationCommand && command instanceof SubmitEditPythonTransformationCommand) {
//            System.out.println("Here");
            found = true;
            itr.remove();
          }
        }
View Full Code Here


          JSONArray inputParamArr = (JSONArray) commObject.get(HistoryArguments.inputParameters.name());
          CommandFactory cf = commandFactoryMap.get(commObject.get(HistoryArguments.commandName.name()));
          if(cf != null && cf instanceof JSONInputCommandFactory) {

            JSONInputCommandFactory scf = (JSONInputCommandFactory)cf;
            Command comm = null;
            try {
              comm = scf.createCommand(inputParamArr, workspace);
            } catch (JSONException | KarmaException e) {
              logger.error("Unable to parse command from worksheet history");
            }
View Full Code Here

      } else {
        // do nothing
      }
    }
    if (comm instanceof Command) {
      Command tmp = (Command)comm;
      JSONArray inputArray = new JSONArray();
      for (String hNodeId : tmp.getInputColumns()) {
        HNode node = workspace.getFactory().getHNode(hNodeId);
        JSONArray hNodeRepresentation = node.getJSONArrayRepresentation(workspace.getFactory());
        JSONObject obj1 = new JSONObject();
        obj1.put(ClientJsonKeys.value.name(), hNodeRepresentation);
        inputArray.put(obj1);
      }
      JSONObject obj = HistoryJsonUtil.getJSONObjectWithName("inputColumns", inputArr);     
      if (obj == null) {
        obj = new JSONObject();
        obj.put(ClientJsonKeys.name.name(), "inputColumns");
        obj.put(ClientJsonKeys.value.name(), inputArray.toString());
        obj.put(ClientJsonKeys.type.name(), ParameterType.hNodeIdList.name());
        inputArr.put(obj);
      }
      else {
        obj.put(ClientJsonKeys.value.name(), inputArray.toString());
      }

      JSONArray outputArray = new JSONArray();
      for (String hNodeId : tmp.getOutputColumns()) {
        HNode node = workspace.getFactory().getHNode(hNodeId);
        JSONArray hNodeRepresentation = node.getJSONArrayRepresentation(workspace.getFactory());
        JSONObject obj1 = new JSONObject();
        obj1.put(ClientJsonKeys.value.name(), hNodeRepresentation);
        outputArray.put(obj1);
View Full Code Here

          HashMap<String, CommandFactory> commandFactoryMap = ctrl.getCommandFactoryMap();
          JSONArray inputParamArr = (JSONArray)rco.historyObject.get(HistoryArguments.inputParameters.name());
          String commandName = (String)rco.historyObject.get(HistoryArguments.commandName.name());
          executor.normalizeCommandHistoryJsonInput(workspace, worksheetId, inputParamArr, commandName, true);
          CommandFactory cf = commandFactoryMap.get(rco.historyObject.get(HistoryArguments.commandName.name()));
          Command comm = cf.createCommand(inputParamArr, workspace);
          effects.append(comm.doIt(workspace));
          history.add(comm);
        }catch(Exception e) {
          history.add(rco.command);
          effects.append(rco.command.doIt(workspace));
        }
View Full Code Here

      if(command instanceof Command && command.isSavedInHistory() && (command.hasTag(CommandTag.Modeling)
          || command.hasTag(CommandTag.Transformation))) {
        JSONArray json = new JSONArray(command.getInputParameterJson());
        if (HistoryJsonUtil.getStringValue(HistoryArguments.worksheetId.name(), json).equals(worksheetId)) {
          commandsToBeRemoved.add(command);
          Command tmp = (Command)command;
          if (tmp.getCommandType() == CommandType.undoable) {
            try {
              tmp.undoIt(workspace);
            }catch(Exception e) {

            }
          }
        }
View Full Code Here

        uc = new UpdateContainer();
      }
      CommandFactory cf = commandFactoryMap.get(commObject.get(HistoryArguments.commandName.name()));
      if(cf != null) {
        try { // This is sort of a hack the way I did this, but could not think of a better way to get rid of the dependency
          Command comm = cf.createCommand(inputParamArr, workspace);
          if(comm != null){
            try {
              comm.setExecutedInBatch(true);
              logger.info("Executing command: " + commandName);
              uc.append(workspace.getCommandHistory().doCommand(comm, workspace, saveToHistory));
              comm.setExecutedInBatch(false);
            } catch(Exception e) {
              logger.error("Error executing command: "+ commandName + ". Please notify this error");
              Util.logException(logger, e);
              //make these InfoUpdates so that the UI can still process the rest of the model
              return new UpdateContainer(new TrivialErrorUpdate("Error executing command " + commandName + " from history"));
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.