1 package org.jbpm.bpel.service.def; 2 3 import java.io.Serializable ; 4 import java.util.HashMap ; 5 import java.util.Iterator ; 6 import java.util.Map ; 7 8 import org.jbpm.graph.exe.Token; 9 10 import org.jbpm.bpel.data.exe.MessageVariableInstance; 11 import org.jbpm.bpel.service.def.Correlation.Initiate; 12 import org.jbpm.bpel.service.exe.CorrelationSetInstance; 13 14 21 public class Correlations implements Serializable { 22 23 private static final long serialVersionUID = 1L; 24 25 long id; 26 private Map correlations; 27 28 public Correlations() { 29 } 30 31 public void addCorrelation(Correlation correlation) { 32 if (correlations == null) { 33 correlations = new HashMap (); 34 } 35 correlations.put(correlation.getSet().getName(), correlation); 36 } 37 38 public Correlation getCorrelation(String setName) { 39 return (Correlation) correlations.get(setName); 40 } 41 42 public Map getCorrelations() { 43 return correlations; 44 } 45 46 public void setCorrelations(Map correlations) { 47 this.correlations = correlations; 48 } 49 50 public Map getReceptionProperties(Token token) { 51 Map receptionProperties = new HashMap (); 52 Iterator correlationIter = correlations.values().iterator(); 53 while (correlationIter.hasNext()) { 54 Correlation correlation = (Correlation) correlationIter.next(); 55 Initiate initiate = correlation.getInitiate(); 56 if (initiate != Initiate.YES) { 57 CorrelationSetInstance setInstance = correlation.getSet().getInstance(token); 58 if (initiate == Initiate.NO || setInstance.isInitialized()) { 59 receptionProperties.putAll(setInstance.getProperties()); 60 } 61 } 62 } 63 return receptionProperties; 64 } 65 66 public void ensureConstraint(MessageVariableInstance messageInstance, Token token) { 67 Iterator correlationIter = correlations.values().iterator(); 68 while (correlationIter.hasNext()) { 69 Correlation correlation = (Correlation) correlationIter.next(); 70 CorrelationSetInstance setInstance = correlation.getSet().getInstance(token); 71 Initiate initiate = correlation.getInitiate(); 72 if (initiate == Initiate.YES) { 73 setInstance.initialize(messageInstance); 74 } 75 else if (initiate == Initiate.NO) { 76 setInstance.validateConstraint(messageInstance); 77 } 78 else if (initiate == Initiate.RENDEZVOUS) { 79 if (setInstance.isInitialized()) 80 setInstance.validateConstraint(messageInstance); 81 else 82 setInstance.initialize(messageInstance); 83 } 84 else throw new IllegalStateException ("illegal property value: initiate=" + initiate); 85 } 86 } 87 } 88 | Popular Tags |