public void setTaskState(TaskState newState, String userId) { TaskState oldState; if (getStateUpdates() == null) { this.stateUpdates = new ArrayList<StateUpdate>(); oldState = TaskState.INITIAL; } else { if (!getStateUpdates().isEmpty() && new Date().before(getStateUpdates().get(getStateUpdates().size() - 1).getUpdatedDate())) { Misc.unreachableStatement(); } //get the old task state from the previous update oldState = this.getStateUpdates().get(getStateUpdates().size() - 1).getTaskState(); } //add a state update this.getStateUpdates().add(new StateUpdateImpl(new Date(), newState, oldState, userId)); }
protected ActivityBodyImpl(final ActivityBody activityBody) { super(); this.uuid = activityBody.getUUID().copy(); this.startedDate = activityBody.getStartedDate(); this.endedDate = activityBody.getEndedDate(); this.readyDate = activityBody.getReadyDate(); final List<StateUpdate> stateList = activityBody.getStateUpdates(); if (stateList != null && !stateList.isEmpty()) { this.stateUpdates = new ArrayList<StateUpdate>(); for (final StateUpdate update : stateList) { this.stateUpdates.add(new StateUpdateImpl(update)); } } }
public void setActivityState(final ActivityState newState, final String userId) { // TODO: why not simply calling getState() to have old state ? ActivityState oldState; final Date actual = new Date(); if (getStateUpdates().isEmpty()) { oldState = ActivityState.INITIAL; } else { // get last state update final StateUpdate oldStateUpdate = getStateUpdates().get(getStateUpdates().size() - 1); final Date lastUpdate = oldStateUpdate.getUpdatedDate(); //get the old task state from the previous update oldState = oldStateUpdate.getActivityState(); // check last state update append before this state update if (actual.before(lastUpdate)) { UpdateImpl.logClockInconsistency(); } } //add a state update this.getStateUpdates().add(new StateUpdateImpl(actual, newState, oldState, userId)); } }
public ActivityInstanceImpl(final ActivityInstance src) { super(src); clientVariables = src.getVariablesBeforeStarted(); final List<VariableUpdate> list = src.getVariableUpdates(); if (list != null && !list.isEmpty()) { variableUpdates = new ArrayList<VariableUpdate>(); for (final VariableUpdate varUpdate : list) { variableUpdates.add(new VariableUpdateImpl(varUpdate)); } } final List<StateUpdate> stateList = src.getStateUpdates(); if (stateList != null && !stateList.isEmpty()) { stateUpdates = new ArrayList<StateUpdate>(); for (final StateUpdate update : stateList) { stateUpdates.add(new StateUpdateImpl(update)); } } if (src.isTask()) { final TaskInstance task = src.getTask(); final List<AssignUpdate> assignList = task.getAssignUpdates(); if (assignList != null && !assignList.isEmpty()) { assignUpdates = new ArrayList<AssignUpdate>(); for (final AssignUpdate update : assignList) { assignUpdates.add(new AssignUpdateImpl(update)); } } candidates = CopyTool.copy(task.getTaskCandidates()); } }
public ActivityInstanceImpl(final ActivityInstance src) { super(src); clientVariables = src.getVariablesBeforeStarted(); final List<VariableUpdate> list = src.getVariableUpdates(); if (list != null && !list.isEmpty()) { variableUpdates = new ArrayList<VariableUpdate>(); for (final VariableUpdate varUpdate : list) { variableUpdates.add(new VariableUpdateImpl(varUpdate)); } } final List<StateUpdate> stateList = src.getStateUpdates(); if (stateList != null && !stateList.isEmpty()) { stateUpdates = new ArrayList<StateUpdate>(); for (final StateUpdate update : stateList) { stateUpdates.add(new StateUpdateImpl(update)); } } if (src.isTask()) { final TaskInstance task = src.getTask(); final List<AssignUpdate> assignList = task.getAssignUpdates(); if (assignList != null && !assignList.isEmpty()) { assignUpdates = new ArrayList<AssignUpdate>(); for (final AssignUpdate update : assignList) { assignUpdates.add(new AssignUpdateImpl(update)); } } candidates = CopyTool.copy(task.getTaskCandidates()); } }
/** * @param processDefinitionUUID * @param deploymentId */ public TaskInstanceImpl(final TaskInstanceImpl taskInstance) { super(taskInstance.getUUID()); this.startedDate = taskInstance.getStartedDate(); this.startedBy = taskInstance.getStartedBy(); this.endedDate = taskInstance.getEndedDate(); this.endedBy = taskInstance.getEndedBy(); this.dueDate = taskInstance.getDueDate(); this.createdDate = taskInstance.getCreatedDate(); List<StateUpdate> stateList = taskInstance.getStateUpdates(); if (stateList != null && !stateList.isEmpty()) { this.stateUpdates = new ArrayList<StateUpdate>(); for (StateUpdate update : stateList) { this.stateUpdates.add(new StateUpdateImpl(update)); } } List<AssignUpdate> assignList = taskInstance.getAssignUpdates(); if (assignList != null && !assignList.isEmpty()) { this.assignUpdates = new ArrayList<AssignUpdate>(); for (AssignUpdate update : assignList) { this.assignUpdates.add(new AssignUpdateImpl(update)); } } }
final Date actual = new Date(); getStateUpdates().add(new StateUpdateImpl(actual, newState, oldState, userId)); if (ActivityState.READY.equals(newState)) { readyDate = actual.getTime();