
org.ow2.bonita.facade.runtime.impl.TaskFullInstanceImpl Maven / Gradle / Ivy
/**
* Copyright (C) 2007 Bull S. A. S.
* Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301, USA.
**/
package org.ow2.bonita.facade.runtime.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.ow2.bonita.facade.runtime.ActivityState;
import org.ow2.bonita.facade.runtime.AssignUpdate;
import org.ow2.bonita.facade.runtime.TaskFullInstance;
import org.ow2.bonita.facade.uuid.TaskUUID;
import org.ow2.bonita.util.Misc;
import org.ow2.bonita.util.Misc.NullCheckResult;
/**
* @author Guillaume Porcher
*
*/
public class TaskFullInstanceImpl extends TaskInstanceImpl implements TaskFullInstance {
/**
*
*/
private static final long serialVersionUID = -5734692788679987686L;
protected TaskFullInstanceImpl() {
}
public TaskFullInstanceImpl(final TaskUUID taskUUID, final ActivityState state, final Date createdDate, final String userId) {
super(taskUUID, createdDate);
final NullCheckResult checkResult = Misc.findNull(taskUUID, state, createdDate);
if (checkResult.hasNull()) {
final List message = Misc.getStringFrom(checkResult, "taskUUID", "initialState", "createdDate");
throw new IllegalArgumentException("These arguments are null: " + message);
}
setActivityState(state, userId);
}
public TaskFullInstanceImpl(final TaskFullInstanceImpl task) {
super(task);
}
public void setStartedBy(final String userId) {
Misc.badStateIfNotNull(getStartedBy(), "startedBy can not be set twice!");
this.startedBy = userId;
}
public void setEndedBy(final String userId) {
Misc.badStateIfNotNull(getEndedBy(), "endedBy can not be set twice!");
Misc.badStateIfNull(getStartedBy(), "endedBy can not be set before startedBy!");
this.endedBy = userId;
}
public void setTaskAssign(final ActivityState taskState,
final String loggedInUserId,
final Set candidates,
final String assignedUserId) {
if (getAssignUpdates() == null) {
this.assignUpdates = new ArrayList();
} else {
if (!getAssignUpdates().isEmpty()
&& new Date().before(getAssignUpdates().get(getAssignUpdates().size() - 1).getUpdatedDate())) {
UpdateImpl.logClockInconsistency();
}
}
this.getAssignUpdates().add(new AssignUpdateImpl(new Date(), taskState, loggedInUserId, candidates, assignedUserId));
}
public long getDbid() {
return this.dbid;
}
public void setDueDate(final Date dueDate) {
this.dueDate = dueDate;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy