1 package org.smartcomps.twister.engine.priv.core.dynamic.impl;
2
3 import org.smartcomps.twister.engine.priv.core.dynamic.ProcessInstance;
4 import org.smartcomps.twister.engine.priv.core.dynamic.ExecutionContext;
5 import org.smartcomps.twister.engine.priv.core.dynamic.ValuedProperty;
6 import org.smartcomps.twister.engine.priv.core.definition.TwisterProcess;
7
8 import java.util.Collection;
9 import java.util.HashSet;
10 import java.util.Iterator;
11
12 /***
13 * Persistent implementation of the ProcessInstance interface.
14 */
15 public class ProcessInstanceImpl implements ProcessInstance {
16
17 private Long id;
18 private int status;
19
20 private TwisterProcess process;
21 private ExecutionContext childExecutionContext;
22
23 private Collection events = new HashSet();
24 private Collection properties = new HashSet();
25
26 public Long getId() {
27 return id;
28 }
29
30 public void setId(Long id) {
31 this.id = id;
32 }
33
34 public int getStatus() {
35 return status;
36 }
37
38 public void setStatus(int status) {
39 this.status = status;
40 }
41
42 public Collection getEvents() {
43 return events;
44 }
45
46 public void setEvents(Collection events) {
47 this.events = events;
48 }
49
50 public TwisterProcess getProcess() {
51 return process;
52 }
53
54 public void setProcess(TwisterProcess process) {
55 this.process = process;
56 }
57
58 public ExecutionContext getChildExecutionContext() {
59 return childExecutionContext;
60 }
61
62 public void setChildExecutionContext(ExecutionContext childExecutionContext) {
63 this.childExecutionContext = childExecutionContext;
64 }
65
66 public Collection getProperties() {
67 return properties;
68 }
69
70 public void setProperties(Collection properties) {
71 this.properties = properties;
72 }
73
74 public void addProperty(ValuedProperty property) {
75 this.properties.add(property);
76 }
77
78 public ValuedProperty getPropertyFromName(String name) {
79 for (Iterator propsIter = properties.iterator(); propsIter.hasNext();) {
80 ValuedProperty valuedProperty = (ValuedProperty) propsIter.next();
81 if (valuedProperty.getName().equals(name)) {
82 return valuedProperty;
83 }
84 }
85 return null;
86 }
87
88 public void notifyExecution(ExecutionContext ec) {
89 this.setStatus(ACTIVE);
90 }
91
92 public void notifyTermination(ExecutionContext ec) {
93 this.setStatus(COMPLETED);
94 }
95
96 }
This page was automatically generated by Maven