Author: rebody
Date: 2010-08-15 11:14:11 -0400 (Sun, 15 Aug 2010)
New Revision: 6595
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceCreate.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java
Log:
JBPM-2927 replace Session to DbSession.
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java 2010-08-15
06:10:08 UTC (rev 6594)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/AddParticipationCmd.java 2010-08-15
15:14:11 UTC (rev 6595)
@@ -21,16 +21,16 @@
*/
package org.jbpm.pvm.internal.cmd;
-import org.hibernate.Session;
import org.jbpm.api.JbpmException;
import org.jbpm.api.cmd.Environment;
+import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.task.TaskImpl;
/**
* @author Tom Baeyens
*/
public class AddParticipationCmd extends AbstractCommand<Object> {
-
+
private static final long serialVersionUID = 1L;
protected String taskId;
@@ -38,7 +38,7 @@
protected String userId;
protected String groupId;
protected String type;
-
+
public AddParticipationCmd(String taskId, String swimlaneId, String userId, String
groupId, String type) {
this.taskId = taskId;
this.swimlaneId = swimlaneId;
@@ -48,12 +48,12 @@
}
public Object execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
-
- if (taskId!=null) {
- TaskImpl task = (TaskImpl) session.get(TaskImpl.class, Long.parseLong(taskId));
- if (task==null) {
- throw new JbpmException("task "+taskId+" was not found");
+ DbSession dbSession = environment.get(DbSession.class);
+
+ if (taskId != null) {
+ TaskImpl task = (TaskImpl) dbSession.get(TaskImpl.class, Long.parseLong(taskId));
+ if (task == null) {
+ throw new JbpmException("task " + taskId + " was not
found");
}
task.addParticipation(userId, groupId, type);
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java 2010-08-15
06:10:08 UTC (rev 6594)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteDeploymentCmd.java 2010-08-15
15:14:11 UTC (rev 6595)
@@ -23,8 +23,6 @@
import java.util.List;
-import org.hibernate.Session;
-
import org.jbpm.api.JbpmException;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.cmd.Command;
@@ -41,16 +39,16 @@
public class DeleteDeploymentCmd implements Command<Object> {
private static final Log log = Log.getLog(DeleteDeploymentCmd.class.getName());
-
+
private static final long serialVersionUID = 1L;
-
+
String deploymentId;
boolean cascade;
-
+
public DeleteDeploymentCmd(String deploymentId) {
this.deploymentId = deploymentId;
}
-
+
public DeleteDeploymentCmd(String deploymentId, boolean cascade) {
this.deploymentId = deploymentId;
this.cascade = cascade;
@@ -61,32 +59,38 @@
List<ProcessDefinition> processDefinitions =
repositorySession.createProcessDefinitionQuery()
.deploymentId(deploymentId)
.list();
-
- DbSession dbSession = environment.get(DbSession.class);
+ DbSession dbSession = environment.get(DbSession.class);
+
for (ProcessDefinition processDefinition: processDefinitions) {
String processDefinitionId = processDefinition.getId();
List<String> processInstanceIds =
dbSession.findProcessInstanceIds(processDefinitionId);
-
+
if (cascade) {
- for (String processInstanceId: processInstanceIds) {
+ for (String processInstanceId : processInstanceIds) {
dbSession.deleteProcessInstance(processInstanceId, true);
}
dbSession.deleteProcessDefinitionHistory(processDefinitionId);
-
+
} else {
if (!processInstanceIds.isEmpty()) {
- throw new JbpmException("cannot delete deployment
"+deploymentId+": still executions for "+processDefinition+":
"+processInstanceIds);
+ throw new JbpmException("cannot delete deployment "
+ + deploymentId
+ + ": still executions for "
+ + processDefinition
+ + ": "
+ + processInstanceIds);
}
}
}
-
- Session session = environment.get(Session.class);
- DeploymentImpl deployment = (DeploymentImpl) session.load(DeploymentImpl.class,
Long.parseLong(deploymentId));
- log.debug("deleting deployment "+deploymentId);
- session.delete(deployment);
-
+
+ DeploymentImpl deployment = (DeploymentImpl) dbSession.get(DeploymentImpl.class,
Long.parseLong(deploymentId));
+ if (log.isDebugEnabled()) {
+ log.debug("deleting deployment " + deploymentId);
+ }
+ dbSession.delete(deployment);
+
RepositoryCache repositoryCache = environment.get(RepositoryCache.class);
repositoryCache.remove(deploymentId);
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java 2010-08-15
06:10:08 UTC (rev 6594)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/RemoveParticipantCmd.java 2010-08-15
15:14:11 UTC (rev 6595)
@@ -24,9 +24,9 @@
import java.util.HashSet;
import java.util.Set;
-import org.hibernate.Session;
import org.jbpm.api.JbpmException;
import org.jbpm.api.cmd.Environment;
+import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.task.ParticipationImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
@@ -37,35 +37,35 @@
public class RemoveParticipantCmd extends AbstractCommand<Object> {
private static final long serialVersionUID = 1L;
-
+
protected Long taskDbid;
protected Long swimlaneId;
protected String userId;
protected String groupId;
protected String participationType;
-
+
public RemoveParticipantCmd(String taskId, String swimlaneId, String userId, String
groupId, String participationType) {
- this.swimlaneId = (swimlaneId!=null ? Long.parseLong(swimlaneId) : null );
- this.taskDbid = (taskId!=null ? Long.parseLong(taskId) : null );
+ this.swimlaneId = (swimlaneId != null ? Long.parseLong(swimlaneId) : null);
+ this.taskDbid = (taskId != null ? Long.parseLong(taskId) : null );
this.userId = userId;
this.groupId = groupId;
this.participationType = participationType;
}
public Object execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
+ DbSession dbSession = environment.get(DbSession.class);
- if (taskDbid!=null) {
- TaskImpl task = (TaskImpl) session.get(TaskImpl.class, taskDbid);
- if (task==null) {
- throw new JbpmException("task "+taskDbid+" was not found");
+ if (taskDbid != null) {
+ TaskImpl task = (TaskImpl) dbSession.get(TaskImpl.class, taskDbid);
+ if (task == null) {
+ throw new JbpmException("task " + taskDbid + " was not
found");
}
Set<ParticipationImpl> participations = new
HashSet<ParticipationImpl>(task.getParticipations());
for (ParticipationImpl participation : participations) {
boolean userMatch = userId!=null ? userId.equals(participation.getUserId()) :
false;
boolean groupMatch = groupId!=null ? groupId.equals(participation.getGroupId()) :
false;
- if ( ( userMatch || groupMatch )
+ if ( ( userMatch || groupMatch )
&& participation.getType().equals(participationType)
) {
task.removeParticipant(participation);
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceCmd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceCmd.java 2010-08-15
06:10:08 UTC (rev 6594)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceCmd.java 2010-08-15
15:14:11 UTC (rev 6595)
@@ -23,12 +23,12 @@
import java.util.Map;
-import org.hibernate.Session;
import org.jbpm.api.JbpmException;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.cmd.Environment;
import org.jbpm.pvm.internal.client.ClientProcessDefinition;
import org.jbpm.pvm.internal.client.ClientProcessInstance;
+import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.session.RepositorySession;
/**
@@ -37,7 +37,7 @@
public class StartProcessInstanceCmd extends VariablesCmd<ProcessInstance> {
private static final long serialVersionUID = 1L;
-
+
protected String processDefinitionId;
protected String executionKey;
@@ -54,14 +54,14 @@
if (processDefinition==null) {
throw new JbpmException("no process definition with id
'"+processDefinitionId+"'");
}
-
+
ClientProcessInstance processInstance =
processDefinition.createProcessInstance(executionKey);
processInstance.setVariables(variables);
processInstance.start();
if (!processInstance.isEnded()) {
- Session session = environment.get(Session.class);
- session.save(processInstance);
+ DbSession dbSession = environment.get(DbSession.class);
+ dbSession.save(processInstance);
}
return processInstance;
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java 2010-08-15
06:10:08 UTC (rev 6594)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java 2010-08-15
15:14:11 UTC (rev 6595)
@@ -21,10 +21,10 @@
*/
package org.jbpm.pvm.internal.history.events;
-import org.hibernate.Session;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.util.Clock;
@@ -36,7 +36,7 @@
private static final long serialVersionUID = 1L;
protected String transitionName;
-
+
public ActivityEnd() {
}
@@ -45,12 +45,12 @@
}
public void process() {
- Session session = EnvironmentImpl.getFromCurrent(Session.class);
+ DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
- HistoryActivityInstanceImpl historyActivityInstance = (HistoryActivityInstanceImpl)
- session.load(getHistoryActivityInstanceClass(), historyActivityInstanceDbId);
+ HistoryActivityInstanceImpl historyActivityInstance = (HistoryActivityInstanceImpl)
+ dbSession.get(getHistoryActivityInstanceClass(), historyActivityInstanceDbId);
updateHistoryActivityInstance(historyActivityInstance);
- session.update(historyActivityInstance);
+ dbSession.update(historyActivityInstance);
}
protected void updateHistoryActivityInstance(HistoryActivityInstanceImpl
historyActivityInstance) {
@@ -61,9 +61,9 @@
protected Class<? extends HistoryActivityInstanceImpl>
getHistoryActivityInstanceClass() {
return HistoryActivityInstanceImpl.class;
}
-
+
public String getTransitionName() {
return transitionName;
}
-
+
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceCreate.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceCreate.java 2010-08-15
06:10:08 UTC (rev 6594)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceCreate.java 2010-08-15
15:14:11 UTC (rev 6595)
@@ -21,12 +21,11 @@
*/
package org.jbpm.pvm.internal.history.events;
-import org.hibernate.Session;
-
import org.jbpm.api.history.HistoryProcessInstance;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+import org.jbpm.pvm.internal.session.DbSession;
/**
* @author Tom Baeyens
@@ -34,10 +33,10 @@
public class ProcessInstanceCreate extends HistoryEvent {
private static final long serialVersionUID = 1L;
-
+
public void process() {
HistoryProcessInstance historyProcessInstanceImpl = new
HistoryProcessInstanceImpl(execution);
- Session session = EnvironmentImpl.getFromCurrent(Session.class);
- session.save(historyProcessInstanceImpl);
+ DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
+ dbSession.save(historyProcessInstanceImpl);
}
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2010-08-15
06:10:08 UTC (rev 6594)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2010-08-15
15:14:11 UTC (rev 6595)
@@ -21,10 +21,10 @@
*/
package org.jbpm.pvm.internal.history.events;
-import org.hibernate.Session;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.util.Clock;
/**
@@ -35,11 +35,12 @@
private static final long serialVersionUID = 1L;
public void process() {
- Session session = EnvironmentImpl.getFromCurrent(Session.class);
- HistoryProcessInstanceImpl historyProcessInstanceImpl = (HistoryProcessInstanceImpl)
- session.load(HistoryProcessInstanceImpl.class, execution.getDbid());
+ DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
+ HistoryProcessInstanceImpl historyProcessInstanceImpl = (HistoryProcessInstanceImpl)
+ dbSession.get(HistoryProcessInstanceImpl.class, execution.getDbid());
historyProcessInstanceImpl.setEndTime(Clock.getTime());
historyProcessInstanceImpl.setState(execution.getState());
historyProcessInstanceImpl.setEndActivityName(execution.getActivityName());
+ dbSession.update(historyProcessInstanceImpl);
}
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java 2010-08-15
06:10:08 UTC (rev 6594)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java 2010-08-15
15:14:11 UTC (rev 6595)
@@ -21,12 +21,12 @@
*/
package org.jbpm.pvm.internal.history.events;
-import org.hibernate.Session;
import org.jbpm.api.history.HistoryTask;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
+import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.util.Clock;
@@ -37,7 +37,7 @@
public class TaskComplete extends HistoryEvent {
private static final long serialVersionUID = 1L;
-
+
protected String outcome;
public TaskComplete(String outcome) {
@@ -45,10 +45,10 @@
}
public void process() {
- Session session = EnvironmentImpl.getFromCurrent(Session.class);
+ DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
- HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl)
- session.load(HistoryTaskInstanceImpl.class, historyActivityInstanceDbId);
+ HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl)
+ dbSession.get(HistoryTaskInstanceImpl.class, historyActivityInstanceDbId);
historyTaskInstance.setEndTime(Clock.getTime());
historyTaskInstance.setTransitionName(outcome);
@@ -57,11 +57,11 @@
historyTask.setEndTime(Clock.getTime());
historyTask.setState(HistoryTask.STATE_COMPLETED);
- session.update(historyTaskInstance);
+ dbSession.update(historyTaskInstance);
}
public String getOutcome() {
return outcome;
}
-
+
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java 2010-08-15
06:10:08 UTC (rev 6594)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskSkip.java 2010-08-15
15:14:11 UTC (rev 6595)
@@ -21,12 +21,12 @@
*/
package org.jbpm.pvm.internal.history.events;
-import org.hibernate.Session;
import org.jbpm.api.history.HistoryTask;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
import org.jbpm.pvm.internal.history.model.HistoryTaskImpl;
import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
+import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.task.TaskImpl;
import org.jbpm.pvm.internal.util.Clock;
@@ -52,10 +52,10 @@
HistoryActivityInstanceImpl historyActivityInstance) {
super.updateHistoryActivityInstance(historyActivityInstance);
- Session session = EnvironmentImpl.getFromCurrent(Session.class);
+ DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
Long historyTaskInstanceId = execution.getHistoryActivityInstanceDbid();
- HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl) session
- .load(HistoryTaskInstanceImpl.class, historyTaskInstanceId);
+ HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl) dbSession
+ .get(HistoryTaskInstanceImpl.class, historyTaskInstanceId);
historyTaskInstance.setEndTime(Clock.getTime());
historyTaskInstance.setTransitionName(outcome);
@@ -64,7 +64,7 @@
historyTask.setEndTime(Clock.getTime());
historyTask.setState(HistoryTask.STATE_OBSOLETE);
- session.update(historyTaskInstance);
+ dbSession.update(historyTaskInstance);
}
@Override
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java 2010-08-15
06:10:08 UTC (rev 6594)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java 2010-08-15
15:14:11 UTC (rev 6595)
@@ -23,17 +23,17 @@
import java.io.Serializable;
-import org.hibernate.Session;
import org.jbpm.api.JbpmException;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.id.DbidGenerator;
+import org.jbpm.pvm.internal.session.DbSession;
/**
* @author Tom Baeyens
*/
public class DeploymentProperty implements Serializable {
-
+
private static final long serialVersionUID = 1L;
long dbid;
@@ -42,20 +42,20 @@
protected String key;
protected String stringValue;
protected Long longValue;
-
+
public DeploymentProperty() {
}
-
+
public DeploymentProperty(DeploymentImpl deployment, String objectName, String key) {
this.dbid = DbidGenerator.getDbidGenerator().getNextId();
- EnvironmentImpl.getFromCurrent(Session.class).save(this);
+ EnvironmentImpl.getFromCurrent(DbSession.class).save(this);
this.deployment = deployment;
this.objectName = objectName;
this.key = key;
}
-
+
public String toString() {
- return
"{"+objectName+","+key+","+(stringValue!=null?stringValue:longValue)+"}";
+ return "{" + objectName + "," + key + "," +
(stringValue != null ? stringValue : longValue) + "}";
}
public String getObjectName() {
@@ -81,20 +81,20 @@
}
public void setValue(Object value) {
- if (value==null) {
+ if (value == null) {
stringValue = null;
longValue = null;
} else if (value instanceof String) {
- stringValue = (String)value;
+ stringValue = (String) value;
} else if (value instanceof Long) {
- longValue = (Long)value;
+ longValue = (Long) value;
} else {
- throw new JbpmException("value type "+value.getClass().getName()+"
not supported (only string and long)");
+ throw new JbpmException("value type " + value.getClass().getName() +
" not supported (only string and long)");
}
}
-
+
public Object getValue() {
- if (stringValue!=null) {
+ if (stringValue != null) {
return stringValue;
}
return longValue;