You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2009/01/24 00:53:21 UTC

svn commit: r737256 [11/12] - in /ode/branches/APACHE_ODE_1.X: bpel-test/src/test/resources/ bpel-test/src/test/resources/bpel/2.0/TestAlarm/ bpel-test/src/test/resources/bpel/2.0/TestAssignComplex/ bpel-test/src/test/resources/bpel/2.0/TestAssignDate/...

Modified: ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java?rev=737256&r1=737255&r2=737256&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/FaultDAOImpl.java Fri Jan 23 23:53:17 2009
@@ -1,100 +1,100 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.ode.bpel.dao.FaultDAO;
-import org.apache.ode.utils.DOMUtils;
-import org.w3c.dom.Element;
-
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.xml.namespace.QName;
-
-
-@Entity
-@Table(name="ODE_FAULT")
-@NamedQueries({
-	@NamedQuery(name=FaultDAOImpl.DELETE_FAULTS_BY_IDS, query="delete from FaultDAOImpl as f where f._id in(:ids)")
-})
-public class FaultDAOImpl implements FaultDAO {
-	public final static String DELETE_FAULTS_BY_IDS = "DELETE_FAULTS_BY_IDS";
-	
-	@Id @Column(name="FAULT_ID") 
-	@GeneratedValue(strategy=GenerationType.AUTO)
-	@SuppressWarnings("unused")
-	private Long _id;
-	@Basic @Column(name="NAME")
-    private String _name;
-	@Basic @Column(name="MESSAGE", length=4000)
-    private String _explanation;
-	@Lob @Column(name="DATA")
-    private String _data;
-	@Basic @Column(name="LINE_NUMBER")
-    private int _lineNo;
-	@Basic @Column(name="ACTIVITY_ID")
-    private int _activityId;
-
-	public FaultDAOImpl() {}
-	public FaultDAOImpl(QName faultName, String explanation, int faultLineNo,
-			int activityId, Element faultMessage) {
-		_name = faultName.toString();
-		_explanation = explanation;
-		_lineNo = faultLineNo;
-		_activityId = activityId;
-		_data = (faultMessage == null)?null:DOMUtils.domToString(faultMessage);
-	}
-	
-	public int getActivityId() {
-		return _activityId;
-	}
-
-	public Element getData() {
-		Element ret = null;
-		
-		try {
-			ret = (_data == null)?null:DOMUtils.stringToDOM(_data);
-		} catch (Exception e) {
-			throw new RuntimeException(e);
-		}
-		
-		return ret;
-	}
-
-	public String getExplanation() {
-		return _explanation;
-	}
-
-	public int getLineNo() {
-		return _lineNo;
-	}
-
-	public QName getName() {
-		return _name == null ? null : QName.valueOf(_name);
-	}
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.dao.jpa;
+
+import org.apache.ode.bpel.dao.FaultDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.xml.namespace.QName;
+
+
+@Entity
+@Table(name="ODE_FAULT")
+@NamedQueries({
+	@NamedQuery(name=FaultDAOImpl.DELETE_FAULTS_BY_IDS, query="delete from FaultDAOImpl as f where f._id in(:ids)")
+})
+public class FaultDAOImpl implements FaultDAO {
+	public final static String DELETE_FAULTS_BY_IDS = "DELETE_FAULTS_BY_IDS";
+	
+	@Id @Column(name="FAULT_ID") 
+	@GeneratedValue(strategy=GenerationType.AUTO)
+	@SuppressWarnings("unused")
+	private Long _id;
+	@Basic @Column(name="NAME")
+    private String _name;
+	@Basic @Column(name="MESSAGE", length=4000)
+    private String _explanation;
+	@Lob @Column(name="DATA")
+    private String _data;
+	@Basic @Column(name="LINE_NUMBER")
+    private int _lineNo;
+	@Basic @Column(name="ACTIVITY_ID")
+    private int _activityId;
+
+	public FaultDAOImpl() {}
+	public FaultDAOImpl(QName faultName, String explanation, int faultLineNo,
+			int activityId, Element faultMessage) {
+		_name = faultName.toString();
+		_explanation = explanation;
+		_lineNo = faultLineNo;
+		_activityId = activityId;
+		_data = (faultMessage == null)?null:DOMUtils.domToString(faultMessage);
+	}
+	
+	public int getActivityId() {
+		return _activityId;
+	}
+
+	public Element getData() {
+		Element ret = null;
+		
+		try {
+			ret = (_data == null)?null:DOMUtils.stringToDOM(_data);
+		} catch (Exception e) {
+			throw new RuntimeException(e);
+		}
+		
+		return ret;
+	}
+
+	public String getExplanation() {
+		return _explanation;
+	}
+
+	public int getLineNo() {
+		return _lineNo;
+	}
+
+	public QName getName() {
+		return _name == null ? null : QName.valueOf(_name);
+	}
+
+}

Modified: ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java?rev=737256&r1=737255&r2=737256&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java Fri Jan 23 23:53:17 2009
@@ -1,123 +1,123 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ode.dao.jpa;
-
-
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.utils.DOMUtils;
-import org.w3c.dom.Element;
-
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import javax.xml.namespace.QName;
-
-@Entity
-@Table(name="ODE_MESSAGE")
-@NamedQueries({
-	@NamedQuery(name=MessageDAOImpl.DELETE_MESSAGES_BY_PROCESS, query="delete from MessageDAOImpl as m where m._messageExchange._process = :process")
-})
-public class MessageDAOImpl implements MessageDAO {
-	public final static String DELETE_MESSAGES_BY_PROCESS = "DELETE_MESSAGES_BY_PROCESS";
-	
-	@Id @Column(name="MESSAGE_ID") 
-	@GeneratedValue(strategy=GenerationType.AUTO)
-	@SuppressWarnings("unused")
-	private Long _id;
-	@Basic @Column(name="TYPE")
-    private String _type;
-	@Lob @Column(name="DATA")
-    private String _data;
-	@Lob @Column(name="HEADER")
-    private String _header;
-	@Transient
-    private Element _element;
-	@Transient
-    private Element _headerElement;
-	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="MESSAGE_EXCHANGE_ID")
-	private MessageExchangeDAOImpl _messageExchange;
-
-	public MessageDAOImpl() {
-	}
-	
-	public MessageDAOImpl(QName type, MessageExchangeDAOImpl me) {
-		_type = type.toString();
-		_messageExchange = me;
-	}
-	
-	public Element getData() {
-		if ( _element == null && _data != null && !"".equals(_data)) {
-			try {
-				_element = DOMUtils.stringToDOM(_data);
-			} catch (Exception e) {
-				throw new RuntimeException(e);
-			}
-		}
-		return _element;
-	}
-
-	public void setData(Element value) {
-        if (value == null) return;
-        _data = DOMUtils.domToString(value);
-		_element = value;
-	}
-
-	public Element getHeader() {
-		if ( _headerElement == null && _header != null && !"".equals(_header)) {
-			try {
-				_headerElement = DOMUtils.stringToDOM(_header);
-			} catch (Exception e) {
-				throw new RuntimeException(e);
-			}
-		}
-		return _headerElement;
-	}
-
-	public void setHeader(Element value) {
-        if (value == null) return;
-        _header = DOMUtils.domToString(value);
-		_headerElement = value;
-	}
-
-    public MessageExchangeDAO getMessageExchange() {
-        return _messageExchange;
-    }
-
-    public QName getType() {
-        return _type == null ? null : QName.valueOf(_type);
-    }
-
-	public void setType(QName type) {
-		_type = type.toString();
-	}
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.dao.jpa;
+
+
+import org.apache.ode.bpel.dao.MessageDAO;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.xml.namespace.QName;
+
+@Entity
+@Table(name="ODE_MESSAGE")
+@NamedQueries({
+	@NamedQuery(name=MessageDAOImpl.DELETE_MESSAGES_BY_PROCESS, query="delete from MessageDAOImpl as m where m._messageExchange._process = :process")
+})
+public class MessageDAOImpl implements MessageDAO {
+	public final static String DELETE_MESSAGES_BY_PROCESS = "DELETE_MESSAGES_BY_PROCESS";
+	
+	@Id @Column(name="MESSAGE_ID") 
+	@GeneratedValue(strategy=GenerationType.AUTO)
+	@SuppressWarnings("unused")
+	private Long _id;
+	@Basic @Column(name="TYPE")
+    private String _type;
+	@Lob @Column(name="DATA")
+    private String _data;
+	@Lob @Column(name="HEADER")
+    private String _header;
+	@Transient
+    private Element _element;
+	@Transient
+    private Element _headerElement;
+	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="MESSAGE_EXCHANGE_ID")
+	private MessageExchangeDAOImpl _messageExchange;
+
+	public MessageDAOImpl() {
+	}
+	
+	public MessageDAOImpl(QName type, MessageExchangeDAOImpl me) {
+		_type = type.toString();
+		_messageExchange = me;
+	}
+	
+	public Element getData() {
+		if ( _element == null && _data != null && !"".equals(_data)) {
+			try {
+				_element = DOMUtils.stringToDOM(_data);
+			} catch (Exception e) {
+				throw new RuntimeException(e);
+			}
+		}
+		return _element;
+	}
+
+	public void setData(Element value) {
+        if (value == null) return;
+        _data = DOMUtils.domToString(value);
+		_element = value;
+	}
+
+	public Element getHeader() {
+		if ( _headerElement == null && _header != null && !"".equals(_header)) {
+			try {
+				_headerElement = DOMUtils.stringToDOM(_header);
+			} catch (Exception e) {
+				throw new RuntimeException(e);
+			}
+		}
+		return _headerElement;
+	}
+
+	public void setHeader(Element value) {
+        if (value == null) return;
+        _header = DOMUtils.domToString(value);
+		_headerElement = value;
+	}
+
+    public MessageExchangeDAO getMessageExchange() {
+        return _messageExchange;
+    }
+
+    public QName getType() {
+        return _type == null ? null : QName.valueOf(_type);
+    }
+
+	public void setType(QName type) {
+		_type = type.toString();
+	}
+
+}

Modified: ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java?rev=737256&r1=737255&r2=737256&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java Fri Jan 23 23:53:17 2009
@@ -1,376 +1,376 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.common.CorrelationKeySet;
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.dao.*;
-import org.apache.ode.utils.DOMUtils;
-import org.apache.ode.utils.uuid.UUID;
-import org.w3c.dom.Element;
-
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-@Entity
-@Table(name="ODE_MESSAGE_EXCHANGE")
-@NamedQueries({
-    @NamedQuery(name=MessageExchangeDAOImpl.DELETE_MEXS_BY_PROCESS, query="delete from MessageExchangeDAOImpl as m where m._process = :process"),
-    @NamedQuery(name=MessageExchangeDAOImpl.SELECT_MEX_IDS_BY_PROCESS, query="select m._id from MessageExchangeDAOImpl as m where m._process = :process")
-})
-public class MessageExchangeDAOImpl extends OpenJPADAO implements MessageExchangeDAO, CorrelatorMessageDAO {
-	private static final Log __log = LogFactory.getLog(MessageExchangeDAOImpl.class);
-	
-	public final static String DELETE_MEXS_BY_PROCESS = "DELETE_MEXS_BY_PROCESS";
-	public final static String SELECT_MEX_IDS_BY_PROCESS = "SELECT_MEX_IDS_BY_PROCESS";
-	
-	@Id @Column(name="MESSAGE_EXCHANGE_ID") 
-	private String _id;
-	@Basic @Column(name="CALLEE")
-    private String _callee;
-	@Basic @Column(name="CHANNEL")
-    private String _channel;
-	@Basic @Column(name="CORRELATION_ID")
-    private String _correlationId;
-	@Basic @Column(name="CORRELATION_STATUS")
-    private String _correlationStatus;
-	@Basic @Column(name="CREATE_TIME")
-    private Date _createTime;
-	@Basic @Column(name="DIRECTION")
-    private char _direction;
-	@Lob   @Column(name="EPR")
-    private String _epr;
-	@Transient private
-    Element _eprElement;
-	@Basic @Column(name="FAULT")
-    private String _fault;
-	@Basic @Column(name="FAULT_EXPLANATION")
-    private String _faultExplanation;
-	@Basic @Column(name="OPERATION")
-    private String _operation;
-	@Basic @Column(name="PARTNER_LINK_MODEL_ID")
-    private int _partnerLinkModelId;
-	@Basic @Column(name="PATTERN")
-    private String _pattern;
-	@Basic @Column(name="PORT_TYPE")
-    private String _portType;
-	@Basic @Column(name="PROPAGATE_TRANS")
-    private boolean _propagateTransactionFlag;
-	@Basic @Column(name="STATUS")
-    private String _status;
-    @Basic @Column(name="CORRELATION_KEYS")
-    private String _correlationKeys;
-    @Basic @Column(name="PIPED_ID")
-    private String _pipedMessageExchangeId;
-    @Basic @Column(name="SUBSCRIBER_COUNT")
-    private int _subscriberCount;
-
-    @OneToMany(targetEntity=MexProperty.class,mappedBy="_mex",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
-    private Collection<MexProperty> _props = new ArrayList<MexProperty>();
-	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_INSTANCE_ID")
-	private ProcessInstanceDAOImpl _processInst;
-	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PARTNER_LINK_ID")
-	private PartnerLinkDAOImpl _partnerLink;
-	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_ID")
-	private ProcessDAOImpl _process;
-	@OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="REQUEST_MESSAGE_ID")
-	private MessageDAOImpl _request;
-	@OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="RESPONSE_MESSAGE_ID")
-	private MessageDAOImpl _response;
-
-    @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="CORR_ID")
-    private CorrelatorDAOImpl _correlator;
-
-    public MessageExchangeDAOImpl() {
-    }
-    
-	public MessageExchangeDAOImpl(char direction){
-		_direction = direction;
-		_id = new UUID().toString();
-	}
-	
-	public MessageDAO createMessage(QName type) {
-		MessageDAOImpl ret = new MessageDAOImpl(type,this);
-		return ret ;
-	}
-
-	public QName getCallee() {
-		return _callee == null ? null : QName.valueOf(_callee);
-	}
-
-	public String getChannel() {
-		return _channel;
-	}
-
-	public String getCorrelationId() {
-		return _correlationId;
-	}
-
-	public String getCorrelationStatus() {
-		return _correlationStatus;
-	}
-
-	public Date getCreateTime() {
-		return _createTime;
-	}
-
-	public char getDirection() {
-		return _direction;
-	}
-
-	public Element getEPR() {
-		if ( _eprElement == null && _epr != null && !"".equals(_epr)) {
-			try {
-				_eprElement = DOMUtils.stringToDOM(_epr);
-			} catch (Exception e) {
-				throw new RuntimeException(e);
-			}
-		}
-		return _eprElement;
-	}
-
-	public QName getFault() {
-		return _fault == null ? null : QName.valueOf(_fault);
-	}
-
-	public String getFaultExplanation() {
-		return _faultExplanation;
-	}
-
-	public ProcessInstanceDAO getInstance() {
-		return _processInst;
-	}
-
-	public String getMessageExchangeId() {
-		//return _messageExchangeId;
-		return _id.toString();
-	}
-
-	public String getOperation() {
-		return _operation;
-	}
-
-	public PartnerLinkDAO getPartnerLink() {
-		return _partnerLink;
-	}
-
-	public int getPartnerLinkModelId() {
-		return _partnerLinkModelId;
-	}
-
-	public String getPattern() {
-		return _pattern;
-	}
-
-	public QName getPortType() {
-		return _portType == null ? null : QName.valueOf(_portType);
-	}
-
-	public ProcessDAO getProcess() {
-		return _process;
-	}
-
-	public boolean getPropagateTransactionFlag() {
-		return _propagateTransactionFlag;
-	}
-
-	public String getProperty(String key) {
-        for (MexProperty prop : _props) {
-            if (prop.getPropertyKey().equals(key)) return prop.getPropertyValue();
-        }
-        return null;
-	}
-
-	public Set<String> getPropertyNames() {
-        HashSet<String> propNames = new HashSet<String>();
-        for (MexProperty prop : _props) {
-            propNames.add(prop.getPropertyKey());
-        }
-        return propNames;
-	}
-
-	public MessageDAO getRequest() {
-		return _request;
-	}
-
-	public MessageDAO getResponse() {
-		return _response;
-	}
-
-	public String getStatus() {
-		return _status;
-	}
-
-	public void setCallee(QName callee) {
-		_callee = callee.toString();
-	}
-
-	public void setChannel(String channel) {
-		_channel = channel;
-	}
-
-	public void setCorrelationId(String correlationId) {
-		_correlationId = correlationId;
-	}
-
-	public void setCorrelationStatus(String cstatus) {
-		_correlationStatus = cstatus;
-	}
-
-	public void setEPR(Element epr) {
-		_eprElement = epr;
-		_epr = DOMUtils.domToString(epr);
-	}
-
-	public void setFault(QName faultType) {
-		_fault = faultType == null ? null : faultType.toString();
-	}
-
-	public void setFaultExplanation(String explanation) {
-		_faultExplanation = explanation;
-	}
-
-	public void setInstance(ProcessInstanceDAO dao) {
-		_processInst = (ProcessInstanceDAOImpl)dao;
-	}
-
-	public void setOperation(String opname) {
-		_operation = opname;
-	}
-
-	public void setPartnerLink(PartnerLinkDAO plinkDAO) {
-		_partnerLink = (PartnerLinkDAOImpl)plinkDAO;
-	}
-
-	public void setPartnerLinkModelId(int modelId) {
-		_partnerLinkModelId = modelId;
-	}
-
-	public void setPattern(String pattern) {
-		_pattern = pattern;
-	}
-
-	public void setPortType(QName porttype) {
-		_portType = porttype.toString();
-	}
-
-	public void setProcess(ProcessDAO process) {
-		_process = (ProcessDAOImpl)process;
-	}
-
-	public void setProperty(String key, String value) {
-        _props.add(new MexProperty(key, value, this));
-	}
-
-	public void setRequest(MessageDAO msg) {
-		_request = (MessageDAOImpl)msg;
-	}
-
-	public void setResponse(MessageDAO msg) {
-		_response = (MessageDAOImpl)msg;
-	}
-
-	public void setStatus(String status) {
-		_status = status;
-	}
-
-    public String getPipedMessageExchangeId() {
-        return _pipedMessageExchangeId;
-    }
-
-    public void setPipedMessageExchangeId(String pipedMessageExchangeId) {
-        _pipedMessageExchangeId = pipedMessageExchangeId;
-    }
-
-    void setCorrelationKeySet(CorrelationKeySet correlationKeySet) {
-    	_correlationKeys = correlationKeySet.toCanonicalString();
-	}
-
-	CorrelationKeySet getCorrelationKeySet() {
-		return new CorrelationKeySet(_correlationKeys);
-    }
-
-    public CorrelationKey getCorrelationKey() {
-        if (_correlationKeys == null) return null;
-        return getCorrelationKeySet().iterator().next();
-    }
-
-    public void setCorrelationKey(CorrelationKey ckey) {
-        _correlationKeys = ckey.toCanonicalString();
-    }
-
-
-	public void release(boolean doClean) {
-		if( doClean ) {
-			deleteMessages();
-		}
-	}
-
-	public void deleteMessages() {
-		if( __log.isDebugEnabled() ) __log.debug("Deleting message on MEX release.");
-		
-		getEM().remove(this); // This deletes MexProperty, REQUEST MessageDAO, RESPONSE MessageDAO
-	}
-
-	public CorrelatorDAOImpl getCorrelator() {
-        return _correlator;
-    }
-
-    public void setCorrelator(CorrelatorDAOImpl correlator) {
-        _correlator = correlator;
-    }
-
-	public int getSubscriberCount() {
-		return _subscriberCount;
-	}
-	
-	public void setSubscriberCount(int subscriberCount) {
-		this._subscriberCount = subscriberCount;
-	}
-
-	public void incrementSubscriberCount() {
-		++_subscriberCount;
-	}
-	
-    public void release() {
-        // no-op for now, could be used to do some cleanup
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.dao.jpa;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.dao.*;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.uuid.UUID;
+import org.w3c.dom.Element;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+@Entity
+@Table(name="ODE_MESSAGE_EXCHANGE")
+@NamedQueries({
+    @NamedQuery(name=MessageExchangeDAOImpl.DELETE_MEXS_BY_PROCESS, query="delete from MessageExchangeDAOImpl as m where m._process = :process"),
+    @NamedQuery(name=MessageExchangeDAOImpl.SELECT_MEX_IDS_BY_PROCESS, query="select m._id from MessageExchangeDAOImpl as m where m._process = :process")
+})
+public class MessageExchangeDAOImpl extends OpenJPADAO implements MessageExchangeDAO, CorrelatorMessageDAO {
+	private static final Log __log = LogFactory.getLog(MessageExchangeDAOImpl.class);
+	
+	public final static String DELETE_MEXS_BY_PROCESS = "DELETE_MEXS_BY_PROCESS";
+	public final static String SELECT_MEX_IDS_BY_PROCESS = "SELECT_MEX_IDS_BY_PROCESS";
+	
+	@Id @Column(name="MESSAGE_EXCHANGE_ID") 
+	private String _id;
+	@Basic @Column(name="CALLEE")
+    private String _callee;
+	@Basic @Column(name="CHANNEL")
+    private String _channel;
+	@Basic @Column(name="CORRELATION_ID")
+    private String _correlationId;
+	@Basic @Column(name="CORRELATION_STATUS")
+    private String _correlationStatus;
+	@Basic @Column(name="CREATE_TIME")
+    private Date _createTime;
+	@Basic @Column(name="DIRECTION")
+    private char _direction;
+	@Lob   @Column(name="EPR")
+    private String _epr;
+	@Transient private
+    Element _eprElement;
+	@Basic @Column(name="FAULT")
+    private String _fault;
+	@Basic @Column(name="FAULT_EXPLANATION")
+    private String _faultExplanation;
+	@Basic @Column(name="OPERATION")
+    private String _operation;
+	@Basic @Column(name="PARTNER_LINK_MODEL_ID")
+    private int _partnerLinkModelId;
+	@Basic @Column(name="PATTERN")
+    private String _pattern;
+	@Basic @Column(name="PORT_TYPE")
+    private String _portType;
+	@Basic @Column(name="PROPAGATE_TRANS")
+    private boolean _propagateTransactionFlag;
+	@Basic @Column(name="STATUS")
+    private String _status;
+    @Basic @Column(name="CORRELATION_KEYS")
+    private String _correlationKeys;
+    @Basic @Column(name="PIPED_ID")
+    private String _pipedMessageExchangeId;
+    @Basic @Column(name="SUBSCRIBER_COUNT")
+    private int _subscriberCount;
+
+    @OneToMany(targetEntity=MexProperty.class,mappedBy="_mex",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
+    private Collection<MexProperty> _props = new ArrayList<MexProperty>();
+	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_INSTANCE_ID")
+	private ProcessInstanceDAOImpl _processInst;
+	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PARTNER_LINK_ID")
+	private PartnerLinkDAOImpl _partnerLink;
+	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_ID")
+	private ProcessDAOImpl _process;
+	@OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="REQUEST_MESSAGE_ID")
+	private MessageDAOImpl _request;
+	@OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="RESPONSE_MESSAGE_ID")
+	private MessageDAOImpl _response;
+
+    @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="CORR_ID")
+    private CorrelatorDAOImpl _correlator;
+
+    public MessageExchangeDAOImpl() {
+    }
+    
+	public MessageExchangeDAOImpl(char direction){
+		_direction = direction;
+		_id = new UUID().toString();
+	}
+	
+	public MessageDAO createMessage(QName type) {
+		MessageDAOImpl ret = new MessageDAOImpl(type,this);
+		return ret ;
+	}
+
+	public QName getCallee() {
+		return _callee == null ? null : QName.valueOf(_callee);
+	}
+
+	public String getChannel() {
+		return _channel;
+	}
+
+	public String getCorrelationId() {
+		return _correlationId;
+	}
+
+	public String getCorrelationStatus() {
+		return _correlationStatus;
+	}
+
+	public Date getCreateTime() {
+		return _createTime;
+	}
+
+	public char getDirection() {
+		return _direction;
+	}
+
+	public Element getEPR() {
+		if ( _eprElement == null && _epr != null && !"".equals(_epr)) {
+			try {
+				_eprElement = DOMUtils.stringToDOM(_epr);
+			} catch (Exception e) {
+				throw new RuntimeException(e);
+			}
+		}
+		return _eprElement;
+	}
+
+	public QName getFault() {
+		return _fault == null ? null : QName.valueOf(_fault);
+	}
+
+	public String getFaultExplanation() {
+		return _faultExplanation;
+	}
+
+	public ProcessInstanceDAO getInstance() {
+		return _processInst;
+	}
+
+	public String getMessageExchangeId() {
+		//return _messageExchangeId;
+		return _id.toString();
+	}
+
+	public String getOperation() {
+		return _operation;
+	}
+
+	public PartnerLinkDAO getPartnerLink() {
+		return _partnerLink;
+	}
+
+	public int getPartnerLinkModelId() {
+		return _partnerLinkModelId;
+	}
+
+	public String getPattern() {
+		return _pattern;
+	}
+
+	public QName getPortType() {
+		return _portType == null ? null : QName.valueOf(_portType);
+	}
+
+	public ProcessDAO getProcess() {
+		return _process;
+	}
+
+	public boolean getPropagateTransactionFlag() {
+		return _propagateTransactionFlag;
+	}
+
+	public String getProperty(String key) {
+        for (MexProperty prop : _props) {
+            if (prop.getPropertyKey().equals(key)) return prop.getPropertyValue();
+        }
+        return null;
+	}
+
+	public Set<String> getPropertyNames() {
+        HashSet<String> propNames = new HashSet<String>();
+        for (MexProperty prop : _props) {
+            propNames.add(prop.getPropertyKey());
+        }
+        return propNames;
+	}
+
+	public MessageDAO getRequest() {
+		return _request;
+	}
+
+	public MessageDAO getResponse() {
+		return _response;
+	}
+
+	public String getStatus() {
+		return _status;
+	}
+
+	public void setCallee(QName callee) {
+		_callee = callee.toString();
+	}
+
+	public void setChannel(String channel) {
+		_channel = channel;
+	}
+
+	public void setCorrelationId(String correlationId) {
+		_correlationId = correlationId;
+	}
+
+	public void setCorrelationStatus(String cstatus) {
+		_correlationStatus = cstatus;
+	}
+
+	public void setEPR(Element epr) {
+		_eprElement = epr;
+		_epr = DOMUtils.domToString(epr);
+	}
+
+	public void setFault(QName faultType) {
+		_fault = faultType == null ? null : faultType.toString();
+	}
+
+	public void setFaultExplanation(String explanation) {
+		_faultExplanation = explanation;
+	}
+
+	public void setInstance(ProcessInstanceDAO dao) {
+		_processInst = (ProcessInstanceDAOImpl)dao;
+	}
+
+	public void setOperation(String opname) {
+		_operation = opname;
+	}
+
+	public void setPartnerLink(PartnerLinkDAO plinkDAO) {
+		_partnerLink = (PartnerLinkDAOImpl)plinkDAO;
+	}
+
+	public void setPartnerLinkModelId(int modelId) {
+		_partnerLinkModelId = modelId;
+	}
+
+	public void setPattern(String pattern) {
+		_pattern = pattern;
+	}
+
+	public void setPortType(QName porttype) {
+		_portType = porttype.toString();
+	}
+
+	public void setProcess(ProcessDAO process) {
+		_process = (ProcessDAOImpl)process;
+	}
+
+	public void setProperty(String key, String value) {
+        _props.add(new MexProperty(key, value, this));
+	}
+
+	public void setRequest(MessageDAO msg) {
+		_request = (MessageDAOImpl)msg;
+	}
+
+	public void setResponse(MessageDAO msg) {
+		_response = (MessageDAOImpl)msg;
+	}
+
+	public void setStatus(String status) {
+		_status = status;
+	}
+
+    public String getPipedMessageExchangeId() {
+        return _pipedMessageExchangeId;
+    }
+
+    public void setPipedMessageExchangeId(String pipedMessageExchangeId) {
+        _pipedMessageExchangeId = pipedMessageExchangeId;
+    }
+
+    void setCorrelationKeySet(CorrelationKeySet correlationKeySet) {
+    	_correlationKeys = correlationKeySet.toCanonicalString();
+	}
+
+	CorrelationKeySet getCorrelationKeySet() {
+		return new CorrelationKeySet(_correlationKeys);
+    }
+
+    public CorrelationKey getCorrelationKey() {
+        if (_correlationKeys == null) return null;
+        return getCorrelationKeySet().iterator().next();
+    }
+
+    public void setCorrelationKey(CorrelationKey ckey) {
+        _correlationKeys = ckey.toCanonicalString();
+    }
+
+
+	public void release(boolean doClean) {
+		if( doClean ) {
+			deleteMessages();
+		}
+	}
+
+	public void deleteMessages() {
+		if( __log.isDebugEnabled() ) __log.debug("Deleting message on MEX release.");
+		
+		getEM().remove(this); // This deletes MexProperty, REQUEST MessageDAO, RESPONSE MessageDAO
+	}
+
+	public CorrelatorDAOImpl getCorrelator() {
+        return _correlator;
+    }
+
+    public void setCorrelator(CorrelatorDAOImpl correlator) {
+        _correlator = correlator;
+    }
+
+	public int getSubscriberCount() {
+		return _subscriberCount;
+	}
+	
+	public void setSubscriberCount(int subscriberCount) {
+		this._subscriberCount = subscriberCount;
+	}
+
+	public void incrementSubscriberCount() {
+		++_subscriberCount;
+	}
+	
+    public void release() {
+        // no-op for now, could be used to do some cleanup
+    }
+
+}

Modified: ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java?rev=737256&r1=737255&r2=737256&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java Fri Jan 23 23:53:17 2009
@@ -1,115 +1,115 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.common.CorrelationKeySet;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="ODE_MESSAGE_ROUTE")
-@NamedQueries ({
-	@NamedQuery(name=MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS, query="delete from MessageRouteDAOImpl as r where r._instanceId in(:instanceIds)"),
-	@NamedQuery(name=MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE, query="delete from MessageRouteDAOImpl as r where r._processInst = :instance")
-})
-public class MessageRouteDAOImpl implements MessageRouteDAO {
-	public final static String DELETE_MESSAGE_ROUTES_BY_INSTANCE = "DELETE_MESSAGE_ROUTES_BY_INSTANCE";
-	public final static String DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS = "DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS";
-	
-	@Id @Column(name="MESSAGE_ROUTE_ID") 
-	@GeneratedValue(strategy=GenerationType.AUTO)
-	private Long _id;
-	@Basic @Column(name="GROUP_ID")
-    private String _groupId;
-	@Basic @Column(name="ROUTE_INDEX")
-    private int _index;
-	@Basic @Column(name="CORRELATION_KEY")
-    private String _correlationKey;
-	@Basic @Column(name="ROUTE_POLICY", length=16)
-    private String _routePolicy;	
-
-	@SuppressWarnings("unused")
-	@Basic @Column(name="PROCESS_INSTANCE_ID", insertable=false, updatable=false, nullable=true)
-    private int _instanceId;
-    @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_INSTANCE_ID")
-    private ProcessInstanceDAOImpl _processInst;
-    
-    @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="CORR_ID")
-    @SuppressWarnings("unused")
-    private CorrelatorDAOImpl _correlator;
-
-    public MessageRouteDAOImpl() {}
-	public MessageRouteDAOImpl(CorrelationKeySet keySet, String groupId, int index,
-                               ProcessInstanceDAOImpl processInst, CorrelatorDAOImpl correlator, String routePolicy) {
-		_correlationKey = keySet.toCanonicalString();
-		_groupId = groupId;
-		_index = index;
-		_processInst = processInst;
-        _correlator = correlator;
-        _routePolicy = routePolicy;
-    }
-
-    public Long getId() {
-        return _id;
-    }
-
-    public CorrelationKey getCorrelationKey() {
-		return new CorrelationKey(_correlationKey);
-	}
-    
-    public void setCorrelationKey(CorrelationKey key) {
-        _correlationKey = key.toCanonicalString();
-    }
-
-	public String getGroupId() {
-		return _groupId;
-	}
-
-	public int getIndex() {
-		return _index;
-	}
-
-	public ProcessInstanceDAO getTargetInstance() {
-		return _processInst;
-	}
-	
-	public String getRoute() {
-		return _routePolicy;
-	}
-	
-	public CorrelationKeySet getCorrelationKeySet() {
-		return new CorrelationKeySet(_correlationKey);
-	}
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.dao.jpa;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.bpel.dao.MessageRouteDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="ODE_MESSAGE_ROUTE")
+@NamedQueries ({
+	@NamedQuery(name=MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS, query="delete from MessageRouteDAOImpl as r where r._instanceId in(:instanceIds)"),
+	@NamedQuery(name=MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE, query="delete from MessageRouteDAOImpl as r where r._processInst = :instance")
+})
+public class MessageRouteDAOImpl implements MessageRouteDAO {
+	public final static String DELETE_MESSAGE_ROUTES_BY_INSTANCE = "DELETE_MESSAGE_ROUTES_BY_INSTANCE";
+	public final static String DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS = "DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS";
+	
+	@Id @Column(name="MESSAGE_ROUTE_ID") 
+	@GeneratedValue(strategy=GenerationType.AUTO)
+	private Long _id;
+	@Basic @Column(name="GROUP_ID")
+    private String _groupId;
+	@Basic @Column(name="ROUTE_INDEX")
+    private int _index;
+	@Basic @Column(name="CORRELATION_KEY")
+    private String _correlationKey;
+	@Basic @Column(name="ROUTE_POLICY", length=16)
+    private String _routePolicy;	
+
+	@SuppressWarnings("unused")
+	@Basic @Column(name="PROCESS_INSTANCE_ID", insertable=false, updatable=false, nullable=true)
+    private int _instanceId;
+    @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_INSTANCE_ID")
+    private ProcessInstanceDAOImpl _processInst;
+    
+    @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="CORR_ID")
+    @SuppressWarnings("unused")
+    private CorrelatorDAOImpl _correlator;
+
+    public MessageRouteDAOImpl() {}
+	public MessageRouteDAOImpl(CorrelationKeySet keySet, String groupId, int index,
+                               ProcessInstanceDAOImpl processInst, CorrelatorDAOImpl correlator, String routePolicy) {
+		_correlationKey = keySet.toCanonicalString();
+		_groupId = groupId;
+		_index = index;
+		_processInst = processInst;
+        _correlator = correlator;
+        _routePolicy = routePolicy;
+    }
+
+    public Long getId() {
+        return _id;
+    }
+
+    public CorrelationKey getCorrelationKey() {
+		return new CorrelationKey(_correlationKey);
+	}
+    
+    public void setCorrelationKey(CorrelationKey key) {
+        _correlationKey = key.toCanonicalString();
+    }
+
+	public String getGroupId() {
+		return _groupId;
+	}
+
+	public int getIndex() {
+		return _index;
+	}
+
+	public ProcessInstanceDAO getTargetInstance() {
+		return _processInst;
+	}
+	
+	public String getRoute() {
+		return _routePolicy;
+	}
+	
+	public CorrelationKeySet getCorrelationKeySet() {
+		return new CorrelationKeySet(_correlationKey);
+	}
+
+}

Modified: ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java?rev=737256&r1=737255&r2=737256&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java Fri Jan 23 23:53:17 2009
@@ -1,174 +1,174 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ode.dao.jpa;
-
-
-import org.apache.ode.bpel.dao.PartnerLinkDAO;
-import org.apache.ode.utils.DOMUtils;
-import org.w3c.dom.Element;
-
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import javax.xml.namespace.QName;
-
-@Entity
-@Table(name="ODE_PARTNER_LINK")
-@NamedQueries({
-    @NamedQuery(name=PartnerLinkDAOImpl.DELETE_PARTNER_LINKS_BY_SCOPE_IDS, query="delete from PartnerLinkDAOImpl as l where l._scopeId in (:scopeIds)")
-})
-public class PartnerLinkDAOImpl implements PartnerLinkDAO {
-	public final static String DELETE_PARTNER_LINKS_BY_SCOPE_IDS = "DELETE_PARTNER_LINKS_BY_SCOPE_IDS";
-	
-	@Id @Column(name="PARTNER_LINK_ID") 
-	@GeneratedValue(strategy=GenerationType.AUTO)
-	@SuppressWarnings("unused")
-	private Long _id;
-	@Lob @Column(name="MY_EPR")
-    private String _myEPR;
-	@Transient
-    private Element _myEPRElement;
-	@Basic @Column(name="MY_ROLE_NAME")
-    private String _myRoleName;
-	@Basic @Column(name="MY_ROLE_SERVICE_NAME")
-    private String _myRoleServiceName;
-	@Basic @Column(name="MY_SESSION_ID")
-    private String _mySessionId;
-	@Lob @Column(name="PARTNER_EPR")
-    private String _partnerEPR;
-	@Transient
-    private Element _partnerEPRElement;
-	@Basic @Column(name="PARTNER_LINK_MODEL_ID")
-    private int _partnerLinkModelId;
-	@Basic @Column(name="PARTNER_LINK_NAME")
-    private String _partnerLinkName;
-	@Basic @Column(name="PARTNER_ROLE_NAME")
-    private String _partnerRoleName;
-	@Basic @Column(name="PARTNER_SESSION_ID")
-    private String _partnerSessionId;
-
-	@SuppressWarnings("unused")
-	@Basic @Column(name="SCOPE_ID", nullable=true, insertable=false, updatable=false)
-    private Long _scopeId;
-    @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="SCOPE_ID")
-    @SuppressWarnings("unused")
-    private ScopeDAOImpl _scope;
-
-    public PartnerLinkDAOImpl() {}
-	public PartnerLinkDAOImpl(int modelId, String name, String myRole, String partnerRole) {
-		_partnerLinkModelId = modelId;
-		_partnerLinkName = name;
-		_myRoleName = myRole;
-		_partnerRoleName = partnerRole;
-	}
-
-	public Element getMyEPR() {
-		if (_myEPRElement == null && _myEPR != null && !"".equals(_myEPR)) {
-			try {
-				_myEPRElement = DOMUtils.stringToDOM(_myEPR);
-			} catch (Exception e) {
-				throw new RuntimeException(e);
-			}	
-		}
-		
-		return _myEPRElement;
-	}
-
-	public String getMyRoleName() {
-		return _myRoleName;
-	}
-
-	public QName getMyRoleServiceName() {
-		return _myRoleServiceName == null ? null : QName.valueOf(_myRoleServiceName);
-	}
-
-	public String getMySessionId() {
-		return _mySessionId;
-	}
-
-	public Element getPartnerEPR() {
-		if ( _partnerEPRElement == null && _partnerEPR != null && !"".equals(_partnerEPR)) {
-			try {
-				_partnerEPRElement = DOMUtils.stringToDOM(_partnerEPR);
-			} catch (Exception e) {
-				throw new RuntimeException(e);
-			}	
-		}
-		return _partnerEPRElement;
-	}
-
-	public int getPartnerLinkModelId() {
-		return _partnerLinkModelId;
-	}
-
-	public String getPartnerLinkName() {
-		return _partnerLinkName;
-	}
-
-	public String getPartnerRoleName() {
-		return _partnerRoleName;
-	}
-
-	public String getPartnerSessionId() {
-		return _partnerSessionId;
-	}
-
-	public void setMyEPR(Element val) {
-		_myEPRElement = val;
-		_myEPR = DOMUtils.domToString(val);
-
-	}
-
-	public void setMyRoleServiceName(QName svcName) {
-		_myRoleServiceName = svcName.toString();
-
-	}
-
-	public void setMySessionId(String sessionId) {
-		_mySessionId = sessionId;
-
-	}
-
-	public void setPartnerEPR(Element val) {
-		_partnerEPRElement = val;
-		_partnerEPR = DOMUtils.domToString(val);
-
-	}
-
-	public void setPartnerSessionId(String session) {
-		_partnerSessionId = session;
-
-	}
-
-    public void setScope(ScopeDAOImpl scope) {
-        _scope = scope;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.dao.jpa;
+
+
+import org.apache.ode.bpel.dao.PartnerLinkDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.xml.namespace.QName;
+
+@Entity
+@Table(name="ODE_PARTNER_LINK")
+@NamedQueries({
+    @NamedQuery(name=PartnerLinkDAOImpl.DELETE_PARTNER_LINKS_BY_SCOPE_IDS, query="delete from PartnerLinkDAOImpl as l where l._scopeId in (:scopeIds)")
+})
+public class PartnerLinkDAOImpl implements PartnerLinkDAO {
+	public final static String DELETE_PARTNER_LINKS_BY_SCOPE_IDS = "DELETE_PARTNER_LINKS_BY_SCOPE_IDS";
+	
+	@Id @Column(name="PARTNER_LINK_ID") 
+	@GeneratedValue(strategy=GenerationType.AUTO)
+	@SuppressWarnings("unused")
+	private Long _id;
+	@Lob @Column(name="MY_EPR")
+    private String _myEPR;
+	@Transient
+    private Element _myEPRElement;
+	@Basic @Column(name="MY_ROLE_NAME")
+    private String _myRoleName;
+	@Basic @Column(name="MY_ROLE_SERVICE_NAME")
+    private String _myRoleServiceName;
+	@Basic @Column(name="MY_SESSION_ID")
+    private String _mySessionId;
+	@Lob @Column(name="PARTNER_EPR")
+    private String _partnerEPR;
+	@Transient
+    private Element _partnerEPRElement;
+	@Basic @Column(name="PARTNER_LINK_MODEL_ID")
+    private int _partnerLinkModelId;
+	@Basic @Column(name="PARTNER_LINK_NAME")
+    private String _partnerLinkName;
+	@Basic @Column(name="PARTNER_ROLE_NAME")
+    private String _partnerRoleName;
+	@Basic @Column(name="PARTNER_SESSION_ID")
+    private String _partnerSessionId;
+
+	@SuppressWarnings("unused")
+	@Basic @Column(name="SCOPE_ID", nullable=true, insertable=false, updatable=false)
+    private Long _scopeId;
+    @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="SCOPE_ID")
+    @SuppressWarnings("unused")
+    private ScopeDAOImpl _scope;
+
+    public PartnerLinkDAOImpl() {}
+	public PartnerLinkDAOImpl(int modelId, String name, String myRole, String partnerRole) {
+		_partnerLinkModelId = modelId;
+		_partnerLinkName = name;
+		_myRoleName = myRole;
+		_partnerRoleName = partnerRole;
+	}
+
+	public Element getMyEPR() {
+		if (_myEPRElement == null && _myEPR != null && !"".equals(_myEPR)) {
+			try {
+				_myEPRElement = DOMUtils.stringToDOM(_myEPR);
+			} catch (Exception e) {
+				throw new RuntimeException(e);
+			}	
+		}
+		
+		return _myEPRElement;
+	}
+
+	public String getMyRoleName() {
+		return _myRoleName;
+	}
+
+	public QName getMyRoleServiceName() {
+		return _myRoleServiceName == null ? null : QName.valueOf(_myRoleServiceName);
+	}
+
+	public String getMySessionId() {
+		return _mySessionId;
+	}
+
+	public Element getPartnerEPR() {
+		if ( _partnerEPRElement == null && _partnerEPR != null && !"".equals(_partnerEPR)) {
+			try {
+				_partnerEPRElement = DOMUtils.stringToDOM(_partnerEPR);
+			} catch (Exception e) {
+				throw new RuntimeException(e);
+			}	
+		}
+		return _partnerEPRElement;
+	}
+
+	public int getPartnerLinkModelId() {
+		return _partnerLinkModelId;
+	}
+
+	public String getPartnerLinkName() {
+		return _partnerLinkName;
+	}
+
+	public String getPartnerRoleName() {
+		return _partnerRoleName;
+	}
+
+	public String getPartnerSessionId() {
+		return _partnerSessionId;
+	}
+
+	public void setMyEPR(Element val) {
+		_myEPRElement = val;
+		_myEPR = DOMUtils.domToString(val);
+
+	}
+
+	public void setMyRoleServiceName(QName svcName) {
+		_myRoleServiceName = svcName.toString();
+
+	}
+
+	public void setMySessionId(String sessionId) {
+		_mySessionId = sessionId;
+
+	}
+
+	public void setPartnerEPR(Element val) {
+		_partnerEPRElement = val;
+		_partnerEPR = DOMUtils.domToString(val);
+
+	}
+
+	public void setPartnerSessionId(String session) {
+		_partnerSessionId = session;
+
+	}
+
+    public void setScope(ScopeDAOImpl scope) {
+        _scope = scope;
+    }
+}

Modified: ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java?rev=737256&r1=737255&r2=737256&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java Fri Jan 23 23:53:17 2009
@@ -1,213 +1,213 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ode.dao.jpa;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.common.ProcessState;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-
-import javax.persistence.*;
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Matthieu Riou <mriou at apache dot org>
- */
-@Entity
-@Table(name="ODE_PROCESS")
-@NamedQueries({
-    @NamedQuery(name="ActiveInstances", query="select i from ProcessInstanceDAOImpl as i where i._process = :process and i._state = :state"),
-    @NamedQuery(name="InstanceByCKey", query="select cs._scope._processInstance from CorrelationSetDAOImpl as cs where cs._correlationKey = :ckey"),
-    @NamedQuery(name="CorrelatorByKey", query="select c from CorrelatorDAOImpl as c where c._correlatorKey = :ckey and c._process = :process")
-})
-public class ProcessDAOImpl extends OpenJPADAO implements ProcessDAO {
-	private static final Log __log = LogFactory.getLog(ProcessDAOImpl.class);
-	
-    @Id @Column(name="ID")
-    @GeneratedValue(strategy= GenerationType.AUTO)
-    @SuppressWarnings("unused")
-    private Long _id;
-
-    @Basic @Column(name="PROCESS_ID")
-    private String _processId;
-	@Transient
-    private int _numInstances;
-	@Basic @Column(name="PROCESS_TYPE")
-    private String _processType;
-	@Basic @Column(name="GUID")
-    private String _guid;
-	@Basic @Column(name="VERSION")
-    private long _version;
-
-	@OneToMany(targetEntity=CorrelatorDAOImpl.class,mappedBy="_process",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
-    private Collection<CorrelatorDAOImpl> _correlators = new ArrayList<CorrelatorDAOImpl>();
-
-	public ProcessDAOImpl() {}
-	public ProcessDAOImpl(QName pid, QName type, String guid, long version) {
-        _processId = pid.toString();
-		_processType = type.toString();
-		_guid = guid;
-        _version = version;
-    }
-	
-	public CorrelatorDAO addCorrelator(String correlator) {
-		CorrelatorDAOImpl corr = new CorrelatorDAOImpl(correlator, this);
-		_correlators.add(corr);
-        return corr;
-    }
-
-	@SuppressWarnings("unchecked")
-    public CorrelatorDAO getCorrelator(String correlatorId) {
-        Query qry = getEM().createNamedQuery("CorrelatorByKey");
-        qry.setParameter("ckey", correlatorId);
-        qry.setParameter("process", this);
-        List res = qry.getResultList();
-        if (res.size() == 0) return null;
-        return (CorrelatorDAO) res.get(0);
-    }
-
-    public ProcessInstanceDAO createInstance(
-			CorrelatorDAO instantiatingCorrelator) {
-		ProcessInstanceDAOImpl inst = new ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, this);
-		getEM().persist(inst);
-		_numInstances++;
-		return inst;
-	}
-
-    public ProcessInstanceDAO createInstance(
-			CorrelatorDAO instantiatingCorrelator, MessageExchangeDAO mex) {
-		ProcessInstanceDAOImpl inst = new ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, this);
-		getEM().persist(inst);
-		_numInstances++;
-		return inst;
-	}
-
-    @SuppressWarnings("unchecked")
-    public Collection<ProcessInstanceDAO> findInstance(CorrelationKey ckey) {
-		Query qry = getEM().createNamedQuery("InstanceByCKey");
-        qry.setParameter("ckey", ckey.toCanonicalString());
-        return qry.getResultList();
-	}
-
-	public ProcessInstanceDAO getInstance(Long iid) {
-		return getEM().find(ProcessInstanceDAOImpl.class, iid);
-	}
-
-	public QName getProcessId() {
-		return QName.valueOf(_processId);
-	}
-
-	public QName getType() {
-		return QName.valueOf(_processType);
-	}
-
-    public void delete() {
-		if(__log.isDebugEnabled()) __log.debug("Cleaning up process data.");
-
-        deleteEvents();
-        deleteCorrelations();
-		deleteMessages();
-		deleteVariables();
-		deleteProcessInstances();
-        getEM().remove(this); // This deletes CorrelatorDAO
-        getEM().flush();
-    }
-
-    @SuppressWarnings("unchecked")
-    private void deleteProcessInstances() {
-  		Collection faultIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_FAULT_IDS_BY_PROCESS).setParameter("process", this).getResultList();
-  		batchUpdateByIds(faultIds.iterator(), getEM().createNamedQuery(FaultDAOImpl.DELETE_FAULTS_BY_IDS), "ids");
-  		Collection instanceIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
-  		batchUpdateByIds(instanceIds.iterator(), getEM().createNamedQuery(ActivityRecoveryDAOImpl.DELETE_ACTIVITY_RECOVERIES_BY_IDS), "ids");
-  		getEM().createNamedQuery(ProcessInstanceDAOImpl.DELETE_INSTANCES_BY_PROCESS).setParameter("process", this).executeUpdate();
-    }
-
-    @SuppressWarnings("unchecked")
-    private void deleteVariables() {
-  		Collection xmlDataIds = getEM().createNamedQuery(XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_PROCESS).setParameter("process", this).getResultList();
-  		batchUpdateByIds(xmlDataIds.iterator(), getEM().createNamedQuery(XmlDataProperty.DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS), "xmlDataIds");
-  		Collection scopeIds = getEM().createNamedQuery(ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
-  		batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(XmlDataDAOImpl.DELETE_XMLDATA_BY_SCOPE_IDS), "scopeIds");
-
-//  		Collection scopeIds = getEM().createNamedQuery(ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
-		batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(PartnerLinkDAOImpl.DELETE_PARTNER_LINKS_BY_SCOPE_IDS), "scopeIds");
-  		batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(ScopeDAOImpl.DELETE_SCOPES_BY_SCOPE_IDS), "ids");
-    }
-
-    @SuppressWarnings("unchecked")
-  	private void deleteMessages() {
-  		getEM().createNamedQuery(MessageDAOImpl.DELETE_MESSAGES_BY_PROCESS).setParameter("process", this).executeUpdate();
-  		Collection mexIds = getEM().createNamedQuery(MessageExchangeDAOImpl.SELECT_MEX_IDS_BY_PROCESS).setParameter("process", this).getResultList();
-  		batchUpdateByIds(mexIds.iterator(), getEM().createNamedQuery(MexProperty.DELETE_MEX_PROPERTIES_BY_MEX_IDS), "mexIds");
-  		getEM().createNamedQuery(MessageExchangeDAOImpl.DELETE_MEXS_BY_PROCESS).setParameter("process", this).executeUpdate();
-  		Collection instanceIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
-  		batchUpdateByIds(instanceIds.iterator(), getEM().createNamedQuery(MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS), "instanceIds");
-  		getEM().createNamedQuery(CorrelatorDAOImpl.DELETE_CORRELATORS_BY_PROCESS).setParameter("process", this).executeUpdate();
-  	}
-
-    @SuppressWarnings("unchecked")
-    private void deleteCorrelations() {
-  		Collection corrSetIds = getEM().createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_PROCESS).setParameter("process", this).getResultList();
-  		batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrSetProperty.DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS), "corrSetIds");
-  		batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_IDS), "ids");
-    }
-
-    @SuppressWarnings("unchecked")
-    private void deleteEvents() {
-    	Collection eventIds = getEM().createNamedQuery(EventDAOImpl.SELECT_EVENT_IDS_BY_PROCESS).setParameter("process", this).getResultList();
-    	batchUpdateByIds(eventIds.iterator(), getEM().createNamedQuery(EventDAOImpl.DELETE_EVENTS_BY_IDS), "ids");
-  	}
-
-    public int getNumInstances() {
-        return _numInstances;
-    }
-
-    public long getVersion() {
-        return _version;
-    }
-
-    public void instanceCompleted(ProcessInstanceDAO instance) {
-        // nothing to do here (yet?)
-    }
-
-    public void removeRoutes(String routeId, ProcessInstanceDAO target) {
-        for (CorrelatorDAO c : _correlators) {
-            ((CorrelatorDAOImpl)c).removeLocalRoutes(routeId, target);
-        }
-    }
-
-    public String getGuid() {
-        return _guid;
-    }
-
-    public Collection<ProcessInstanceDAO> getActiveInstances() {
-        Query qry = getEM().createNamedQuery("ActiveInstances");
-        qry.setParameter("process", this);
-        qry.setParameter("state", ProcessState.STATE_ACTIVE);
-        return qry.getResultList();
-    }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ode.dao.jpa;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.bpel.dao.CorrelatorDAO;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+
+import javax.persistence.*;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_PROCESS")
+@NamedQueries({
+    @NamedQuery(name="ActiveInstances", query="select i from ProcessInstanceDAOImpl as i where i._process = :process and i._state = :state"),
+    @NamedQuery(name="InstanceByCKey", query="select cs._scope._processInstance from CorrelationSetDAOImpl as cs where cs._correlationKey = :ckey"),
+    @NamedQuery(name="CorrelatorByKey", query="select c from CorrelatorDAOImpl as c where c._correlatorKey = :ckey and c._process = :process")
+})
+public class ProcessDAOImpl extends OpenJPADAO implements ProcessDAO {
+	private static final Log __log = LogFactory.getLog(ProcessDAOImpl.class);
+	
+    @Id @Column(name="ID")
+    @GeneratedValue(strategy= GenerationType.AUTO)
+    @SuppressWarnings("unused")
+    private Long _id;
+
+    @Basic @Column(name="PROCESS_ID")
+    private String _processId;
+	@Transient
+    private int _numInstances;
+	@Basic @Column(name="PROCESS_TYPE")
+    private String _processType;
+	@Basic @Column(name="GUID")
+    private String _guid;
+	@Basic @Column(name="VERSION")
+    private long _version;
+
+	@OneToMany(targetEntity=CorrelatorDAOImpl.class,mappedBy="_process",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+    private Collection<CorrelatorDAOImpl> _correlators = new ArrayList<CorrelatorDAOImpl>();
+
+	public ProcessDAOImpl() {}
+	public ProcessDAOImpl(QName pid, QName type, String guid, long version) {
+        _processId = pid.toString();
+		_processType = type.toString();
+		_guid = guid;
+        _version = version;
+    }
+	
+	public CorrelatorDAO addCorrelator(String correlator) {
+		CorrelatorDAOImpl corr = new CorrelatorDAOImpl(correlator, this);
+		_correlators.add(corr);
+        return corr;
+    }
+
+	@SuppressWarnings("unchecked")
+    public CorrelatorDAO getCorrelator(String correlatorId) {
+        Query qry = getEM().createNamedQuery("CorrelatorByKey");
+        qry.setParameter("ckey", correlatorId);
+        qry.setParameter("process", this);
+        List res = qry.getResultList();
+        if (res.size() == 0) return null;
+        return (CorrelatorDAO) res.get(0);
+    }
+
+    public ProcessInstanceDAO createInstance(
+			CorrelatorDAO instantiatingCorrelator) {
+		ProcessInstanceDAOImpl inst = new ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, this);
+		getEM().persist(inst);
+		_numInstances++;
+		return inst;
+	}
+
+    public ProcessInstanceDAO createInstance(
+			CorrelatorDAO instantiatingCorrelator, MessageExchangeDAO mex) {
+		ProcessInstanceDAOImpl inst = new ProcessInstanceDAOImpl((CorrelatorDAOImpl)instantiatingCorrelator, this);
+		getEM().persist(inst);
+		_numInstances++;
+		return inst;
+	}
+
+    @SuppressWarnings("unchecked")
+    public Collection<ProcessInstanceDAO> findInstance(CorrelationKey ckey) {
+		Query qry = getEM().createNamedQuery("InstanceByCKey");
+        qry.setParameter("ckey", ckey.toCanonicalString());
+        return qry.getResultList();
+	}
+
+	public ProcessInstanceDAO getInstance(Long iid) {
+		return getEM().find(ProcessInstanceDAOImpl.class, iid);
+	}
+
+	public QName getProcessId() {
+		return QName.valueOf(_processId);
+	}
+
+	public QName getType() {
+		return QName.valueOf(_processType);
+	}
+
+    public void delete() {
+		if(__log.isDebugEnabled()) __log.debug("Cleaning up process data.");
+
+        deleteEvents();
+        deleteCorrelations();
+		deleteMessages();
+		deleteVariables();
+		deleteProcessInstances();
+        getEM().remove(this); // This deletes CorrelatorDAO
+        getEM().flush();
+    }
+
+    @SuppressWarnings("unchecked")
+    private void deleteProcessInstances() {
+  		Collection faultIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_FAULT_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+  		batchUpdateByIds(faultIds.iterator(), getEM().createNamedQuery(FaultDAOImpl.DELETE_FAULTS_BY_IDS), "ids");
+  		Collection instanceIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+  		batchUpdateByIds(instanceIds.iterator(), getEM().createNamedQuery(ActivityRecoveryDAOImpl.DELETE_ACTIVITY_RECOVERIES_BY_IDS), "ids");
+  		getEM().createNamedQuery(ProcessInstanceDAOImpl.DELETE_INSTANCES_BY_PROCESS).setParameter("process", this).executeUpdate();
+    }
+
+    @SuppressWarnings("unchecked")
+    private void deleteVariables() {
+  		Collection xmlDataIds = getEM().createNamedQuery(XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+  		batchUpdateByIds(xmlDataIds.iterator(), getEM().createNamedQuery(XmlDataProperty.DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS), "xmlDataIds");
+  		Collection scopeIds = getEM().createNamedQuery(ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+  		batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(XmlDataDAOImpl.DELETE_XMLDATA_BY_SCOPE_IDS), "scopeIds");
+
+//  		Collection scopeIds = getEM().createNamedQuery(ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+		batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(PartnerLinkDAOImpl.DELETE_PARTNER_LINKS_BY_SCOPE_IDS), "scopeIds");
+  		batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(ScopeDAOImpl.DELETE_SCOPES_BY_SCOPE_IDS), "ids");
+    }
+
+    @SuppressWarnings("unchecked")
+  	private void deleteMessages() {
+  		getEM().createNamedQuery(MessageDAOImpl.DELETE_MESSAGES_BY_PROCESS).setParameter("process", this).executeUpdate();
+  		Collection mexIds = getEM().createNamedQuery(MessageExchangeDAOImpl.SELECT_MEX_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+  		batchUpdateByIds(mexIds.iterator(), getEM().createNamedQuery(MexProperty.DELETE_MEX_PROPERTIES_BY_MEX_IDS), "mexIds");
+  		getEM().createNamedQuery(MessageExchangeDAOImpl.DELETE_MEXS_BY_PROCESS).setParameter("process", this).executeUpdate();
+  		Collection instanceIds = getEM().createNamedQuery(ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+  		batchUpdateByIds(instanceIds.iterator(), getEM().createNamedQuery(MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE_IDS), "instanceIds");
+  		getEM().createNamedQuery(CorrelatorDAOImpl.DELETE_CORRELATORS_BY_PROCESS).setParameter("process", this).executeUpdate();
+  	}
+
+    @SuppressWarnings("unchecked")
+    private void deleteCorrelations() {
+  		Collection corrSetIds = getEM().createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+  		batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrSetProperty.DELETE_CORSET_PROPERTIES_BY_PROPERTY_IDS), "corrSetIds");
+  		batchUpdateByIds(corrSetIds.iterator(), getEM().createNamedQuery(CorrelationSetDAOImpl.DELETE_CORRELATION_SETS_BY_IDS), "ids");
+    }
+
+    @SuppressWarnings("unchecked")
+    private void deleteEvents() {
+    	Collection eventIds = getEM().createNamedQuery(EventDAOImpl.SELECT_EVENT_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+    	batchUpdateByIds(eventIds.iterator(), getEM().createNamedQuery(EventDAOImpl.DELETE_EVENTS_BY_IDS), "ids");
+  	}
+
+    public int getNumInstances() {
+        return _numInstances;
+    }
+
+    public long getVersion() {
+        return _version;
+    }
+
+    public void instanceCompleted(ProcessInstanceDAO instance) {
+        // nothing to do here (yet?)
+    }
+
+    public void removeRoutes(String routeId, ProcessInstanceDAO target) {
+        for (CorrelatorDAO c : _correlators) {
+            ((CorrelatorDAOImpl)c).removeLocalRoutes(routeId, target);
+        }
+    }
+
+    public String getGuid() {
+        return _guid;
+    }
+
+    public Collection<ProcessInstanceDAO> getActiveInstances() {
+        Query qry = getEM().createNamedQuery("ActiveInstances");
+        qry.setParameter("process", this);
+        qry.setParameter("state", ProcessState.STATE_ACTIVE);
+        return qry.getResultList();
+    }
 }
\ No newline at end of file