Package edu.isi.karma.controller.command

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


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


    CommandFactory cf = ctrl.getCommandFactoryMap().get(
        MultipleValueEditColumnCommand.class.getSimpleName());
    JSONInputCommandFactory scf = (JSONInputCommandFactory) cf;

    // TODO handle exceptions intelligently
    Command comm = scf.createCommand(inputParamArr, workspace);
    if (comm != null) {
      // logger.info("Executing command: " +
      // commObject.get(HistoryArguments.commandName.name()));
      workspace.getCommandHistory().doCommand(comm, workspace);
    }
View Full Code Here

    ExecutionController ctrl = WorkspaceRegistry.getInstance()
        .getExecutionController(workspace.getId());
    CommandFactory cf0 = ctrl.getCommandFactoryMap().get(
        AddColumnCommand.class.getSimpleName());
    JSONInputCommandFactory scf1 = (JSONInputCommandFactory) cf0;
    Command comm1 = null;

    // TODO handle exceptions intelligently
    try {
      comm1 = scf1.createCommand(inputParamArr0, workspace);
    } catch (JSONException e1) {
      logger.error(
          "Error creating new "
              + AddColumnCommand.class.getSimpleName(), e1);
    } catch (KarmaException e1) {
      logger.error(
          "Error creating new "
              + AddColumnCommand.class.getSimpleName(), e1);
    }
    if (comm1 != null) {
      try {
        comm1.saveInHistory(false);
        workspace.getCommandHistory().doCommand(comm1, workspace);
      } catch (CommandException e) {
        logger.error(
            "Error executing new "
                + AddColumnCommand.class.getSimpleName(), e);
View Full Code Here

      }
      System.out.println(inputParamArr.toString(4));
      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);
          comm.setOutputColumns(newOutputColumns);
          if(comm != null){
            commands.add(comm);
            //TODO consolidate update
            uc.append(workspace.getCommandHistory().doCommand(comm, workspace, true));
          }
View Full Code Here

  }

  public void removeCommands(CommandTag tag) {
    Iterator<Command> commandItr = commands.iterator();
    while (commandItr.hasNext()) {
      Command command = commandItr.next();
      if(command.hasTag(tag))
        commandItr.remove();
    }
  }
View Full Code Here

  }

  public void removeCommands(String hNodeId) {
    Iterator<Command> commandItr = commands.iterator();
    while (commandItr.hasNext()) {
      Command command = commandItr.next();
      if(command.getOutputColumns().contains(hNodeId))
        commandItr.remove();
    }
  }
View Full Code Here

          semanticType.put(ClientJsonKeys.FullType.name(), Uris.CLASS_INSTANCE_LINK_URI);
        }


        semanticTypesArray.put(semanticType);
        Command sstCommand = sstFactory.createCommand(workspace, worksheetId, nestedHNodeId, false, semanticTypesArray, false, "", selection.getName());
        appliedCommands.push(sstCommand);
        sstCommand.doIt(workspace);
        if(!resultClass.get(i).trim().isEmpty())
        {
          ChangeInternalNodeLinksCommandFactory cinlcf = new ChangeInternalNodeLinksCommandFactory();
          SetMetaPropertyCommandFactory smpcf = new SetMetaPropertyCommandFactory();
          JSONArray newEdges = new JSONArray();
          JSONObject newEdge = new JSONObject();
          String sourceId = n.getId();
          Set<edu.isi.karma.rep.alignment.Node> tempnodes = new HashSet<edu.isi.karma.rep.alignment.Node>();
          tempnodes.addAll(alignment.getNodesByUri(resultClass.get(i)));
          tempnodes.removeAll(oldNodes);

          edu.isi.karma.rep.alignment.Node target = tempnodes.iterator().next();
          String targetId = target.getId();
          String targetUri = target.getLabel().getUri();
          String edgeUri = resultPredicates.get(i);
          if (!incoming) {
            newEdge.put(ChangeInternalNodeLinksCommand.JsonKeys.edgeSourceId.name(), sourceId);
            newEdge.put(ChangeInternalNodeLinksCommand.JsonKeys.edgeTargetId.name(), targetId);
            newEdge.put(ChangeInternalNodeLinksCommand.JsonKeys.edgeId.name(), edgeUri);
          }
          else {
            newEdge.put(ChangeInternalNodeLinksCommand.JsonKeys.edgeSourceId.name(), targetId);
            newEdge.put(ChangeInternalNodeLinksCommand.JsonKeys.edgeTargetId.name(), sourceId);
            newEdge.put(ChangeInternalNodeLinksCommand.JsonKeys.edgeId.name(), edgeUri);
          }
          newEdges.put(newEdge);
          Command changeInternalNodeLinksCommand = cinlcf.createCommand(worksheetId, alignmentId, new JSONArray(), newEdges, workspace);
          changeInternalNodeLinksCommand.doIt(workspace);
          appliedCommands.push(changeInternalNodeLinksCommand);
          Command setMetaDataCommand = smpcf.createCommand(workspace, nestedHNodeId, worksheetId, "isUriOfClass",
              targetUri, targetId, "", selection.getName());
          setMetaDataCommand.doIt(workspace);
          appliedCommands.push(setMetaDataCommand);
        }
      }

    }
View Full Code Here

  @Override
  public UpdateContainer undoIt(Workspace workspace) {
    UpdateContainer c =  new UpdateContainer();
    while (!appliedCommands.isEmpty()) {
      Command command = appliedCommands.pop();
      command.undoIt(workspace);
    }
    c.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(workspace)));
    c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
    return c;
  }
View Full Code Here

    t.put("type", HistoryJsonUtil.ParameterType.other.name());
    t.put("value", newEdges);
    inputJSON.put(t);
    if (newEdges.length() > 0 || initialEdges.length() > 0) {
      try {
        Command changeInternalNodeLinksCommand = cinlcf.createCommand(inputJSON, workspace);
        workspace.getCommandHistory().doCommand(changeInternalNodeLinksCommand, workspace);
        uc.add(new HistoryUpdate(workspace.getCommandHistory()));
        uc.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet)));
        uc.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
      }catch(Exception e)
View Full Code Here

      String context = (modelContext != null && !modelContext.isEmpty()? (modelContext + "/") : "");
      URL url = new URL(baseUrl + context + modelURL + "?modelRepository=" + modelRepository);

      File file = new File("tmp.ttl")
      FileUtils.copyURLToFile(url, file);
      Command cmd = factory.createCommandFromFile(worksheetId, file, workspace, override);
      UpdateContainer uc = cmd.doIt(workspace);
      workspace.getWorksheet(worksheetId).getMetadataContainer().getWorksheetProperties().setPropertyValue(Property.modelUrl, modelURL);
      workspace.getWorksheet(worksheetId).getMetadataContainer().getWorksheetProperties().setPropertyValue(Property.modelContext, modelContext);
      workspace.getWorksheet(worksheetId).getMetadataContainer().getWorksheetProperties().setPropertyValue(Property.modelRepository, modelRepository);
      file.delete();
      return uc;
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.