diff options
author | Christian Wagner <c.wagner@datentechnik-innovation.com> | 2015-02-02 12:45:40 +0100 |
---|---|---|
committer | Christian Wagner <c.wagner@datentechnik-innovation.com> | 2015-02-02 12:45:40 +0100 |
commit | 2e27b939251017882b323b6478c345439d486494 (patch) | |
tree | a2e37d74cb6f1868f73fecff016b61aad36402b0 /id/server/idserverlib/src/main/java | |
parent | 730cb523e5d29dee54c7fb1c0219efa879362813 (diff) | |
download | moa-id-spss-2e27b939251017882b323b6478c345439d486494.tar.gz moa-id-spss-2e27b939251017882b323b6478c345439d486494.tar.bz2 moa-id-spss-2e27b939251017882b323b6478c345439d486494.zip |
fix process instance persistence
Diffstat (limited to 'id/server/idserverlib/src/main/java')
2 files changed, 15 insertions, 14 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/ProcessInstance.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/ProcessInstance.java index ef69451eb..a6cf3b57f 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/ProcessInstance.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/ProcessInstance.java @@ -5,6 +5,8 @@ import java.util.Date; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.time.DurationFormatUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import at.gv.egovernment.moa.id.process.api.ExecutionContext; import at.gv.egovernment.moa.id.process.model.ProcessDefinition; @@ -27,21 +29,12 @@ public class ProcessInstance implements Serializable { private ExecutionContext executionContext; private ProcessInstanceState state = ProcessInstanceState.NOT_STARTED; - /** - * Creates a new process instance, based on a given process definition.<p/> - * An execution context will be created internally. - * - * @param processDefinition - * The process definition. - */ - ProcessInstance(ProcessDefinition processDefinition) { - this(processDefinition, null); - } + private Logger log = LoggerFactory.getLogger(getClass()); /** * Creates a new process instance, based on a given process definition and a * given execution context. If the given execution context is {@code null} a new execution context will be created.<p/> - * The process instance id of the execution context will automatically be set (and overwritten if already set). + * The process instance id of the execution context will be newly generated if it is {@code null} in the execution context. * * @param processDefinition * The process definition. @@ -51,12 +44,17 @@ public class ProcessInstance implements Serializable { ProcessInstance(ProcessDefinition processDefinition, ExecutionContext executionContext) { this.processDefinition = processDefinition; nextId = processDefinition.getStartEvent().getId(); - String pdIdLocalPart = RandomStringUtils.random(RND_ID_LENGTH, 0, 0, true, true, null, - SecureRandomHolder.getInstance()); if (executionContext == null) { executionContext = new ExecutionContextImpl(); } - executionContext.setProcessInstanceId(this.processDefinition.getId() + "-" + pdIdLocalPart); + if (executionContext.getProcessInstanceId() == null) { + String pdIdLocalPart = RandomStringUtils.random(RND_ID_LENGTH, 0, 0, true, true, null, + SecureRandomHolder.getInstance()); + executionContext.setProcessInstanceId(this.processDefinition.getId() + "-" + pdIdLocalPart); + } else { + log.debug("Using process instance id from execution context."); + } + log.debug("Creating process instance with id '{}'.", executionContext.getProcessInstanceId()); this.executionContext = executionContext; touch(); } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/dao/ProcessInstanceStore.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/dao/ProcessInstanceStore.java index c86d0de3d..010f8d984 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/dao/ProcessInstanceStore.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/process/dao/ProcessInstanceStore.java @@ -4,9 +4,11 @@ import java.io.Serializable; import java.util.Map; import javax.persistence.Column; +import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; +import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.Table; @@ -36,6 +38,7 @@ public class ProcessInstanceStore { @Column(name = "executionContextData", nullable = false) @Lob + @ElementCollection(fetch=FetchType.EAGER) private Map<String, Serializable> executionContextData; public String getProcessInstanceId() { |