public StateUpdateImpl(final StateUpdate src) { super(src); initialState = src.getInitialState(); }
@Override public void recordTaskResumed(final ActivityInstanceUUID taskUUID, final String loggedInUserId) { Misc.checkArgsNotNull(taskUUID); final TaskInstance task = getTaskInstance(taskUUID); ActivityState stateBeforeSuspend = null; for (final StateUpdate su : task.getStateUpdates()) { if (su.getActivityState().equals(ActivityState.SUSPENDED)) { stateBeforeSuspend = su.getInitialState(); } } ((InternalActivityInstance) task).setActivityState(stateBeforeSuspend, loggedInUserId); }
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 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)); }
private Date getLastUpdateDate(final ActivityInstanceUUID activityUUID) throws ActivityNotFoundException { final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("getActivity for getLastAttachment "); stringBuilder.append(activityUUID); Misc.log(Level.FINE, stringBuilder.toString()); final ActivityInstance activity = getActivityInstance(activityUUID); Date date = null; if (!activity.getState().equals(ActivityState.READY) && !activity.getState().equals(ActivityState.SUSPENDED) && !activity.getState().equals(ActivityState.EXECUTING)) { date = activity.getLastStateUpdate().getUpdatedDate(); } else { date = new Date(); } return date; }
public ActivityState getState() { if (getStateUpdates() != null && !getStateUpdates().isEmpty()) { final StateUpdate stateUpdate = getStateUpdates().get(getStateUpdates().size() - 1); if (stateUpdate.getActivityState() != null) { return stateUpdate.getActivityState(); } } return ActivityState.INITIAL; }
public TaskState getState() { if (getStateUpdates() != null && !getStateUpdates().isEmpty()) { StateUpdate stateUpdate = getStateUpdates().get(getStateUpdates().size() - 1); if (stateUpdate.getTaskState() != null) { return stateUpdate.getTaskState(); } } throw new IllegalStateException("The state of the task: " + this.getUUID() + " is null"); }
private static long getActivityScopeDate(final ActivityInstance activityInstance, final long defaultDate) { long maxDate = -1; if (!activityInstance.getState().equals(ActivityState.READY) && !activityInstance.getState().equals(ActivityState.SUSPENDED) && !activityInstance.getState().equals(ActivityState.EXECUTING)) { maxDate = activityInstance.getLastStateUpdate().getUpdatedDate().getTime(); } else { maxDate = defaultDate; } return maxDate; }
public StateUpdateImpl(final StateUpdate src) { super(src); initialState = src.getInitialState(); }
public StateUpdateImpl(StateUpdate src) { super(src); this.initialState = src.getInitialState(); }
public StateUpdateImpl(StateUpdate src) { super(src); this.initialState = src.getInitialState(); }