/** * Commands go onto the history when they have all their arguments and are * ready to be executed. If a command needs multiple user interactions to * define the parameters, then the command object must be created, * interacted with and then executed. * * @param command * @param workspace * @return UpdateContainer with all the changes done by the command. * @throws CommandException */ public UpdateContainer doCommand(Command command, Workspace workspace) throws CommandException { return doCommand(command, workspace, true); }
public UpdateContainer invokeCommand(Command command) { synchronized (this) { try { UpdateContainer updateContainer = workspace.getCommandHistory().doCommand(command, workspace); return updateContainer; } catch (CommandException e) { logger.error( "Error occured with command " + command.toString(), e); UpdateContainer updateContainer = new UpdateContainer(); updateContainer.add(new ErrorUpdate("Error occured with command " + command.toString())); return updateContainer; // TODO probably need a return that indicates an // error. } } } }
private UpdateContainer addNewLinks(WorksheetCommandHistoryExecutor histExecutor, Workspace workspace, Alignment alignment, OntologyManager ontMgr) throws JSONException { UpdateContainer uc = new UpdateContainer(); boolean saveToHistory = !this.isExecutedInBatch(); for (int i = 0; i < newEdges.length(); i++) { JSONObject newEdge = newEdges.getJSONObject(i); try { Command cmd = (new AddLinkCommandFactory()).createCommand(worksheetId, alignmentId, newEdge, model, workspace); cmd.setExecutedInBatch(this.isExecutedInBatch()); uc.append(workspace.getCommandHistory().doCommand(cmd, workspace, saveToHistory && i==newEdges.length()-1)); } catch(CommandException e) { logger.error("Error adding a new link: " + newEdge.toString(), e); } } return uc; }
container.append(doCommand((Command) lastCommand.getCommand(), workspace));
Command cmd = (new DeleteLinkCommandFactory()).createCommand(worksheetId, alignmentId, initialEdge, model, workspace); cmd.setExecutedInBatch(this.isExecutedInBatch()); uc.append(workspace.getCommandHistory().doCommand(cmd, workspace, saveToHistory && i==initialEdges.length()-1));
comm.setExecutedInBatch(true); logger.debug("Executing command: " + commandName); uc.append(workspace.getCommandHistory().doCommand(comm, workspace, saveToHistory)); comm.setExecutedInBatch(false); } catch(Exception e) {
SetSemanticTypeCommand cmd = (SetSemanticTypeCommand)wkCommand; if(cmd.hasProvenanceType()) { uc.append(workspace.getCommandHistory().doCommand(cmd, workspace, false)); uc.append(workspace.getCommandHistory().doCommand(cmd, workspace, false)); try { Command changeInternalNodeLinksCommand = cinlcf.createCommand(inputJSON, model, workspace); workspace.getCommandHistory().doCommand(changeInternalNodeLinksCommand, workspace); uc.add(new HistoryUpdate(workspace.getCommandHistory())); uc.append(WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, getSuperSelection(worksheet), workspace.getContextId()));