You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by va...@apache.org on 2008/05/23 01:26:18 UTC
svn commit: r659307 [22/24] - in /ode/trunk:
axis2-war/src/main/webapp/WEB-INF/ axis2-war/src/main/webapp/WEB-INF/classes/
axis2-war/src/test/resources/XSDReferences/
axis2-war/src/test/resources/XSDReferences/BPMN/
axis2-war/src/test/resources/XSDRefe...
Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,107 +1,107 @@
-/*
- * 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 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.Table;
-import javax.persistence.Transient;
-import javax.xml.namespace.QName;
-
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.utils.DOMUtils;
-import org.w3c.dom.Element;
-
-
-@Entity
-@Table(name="ODE_MESSAGE")
-public class MessageDAOImpl implements MessageDAO {
-
- @Id @Column(name="MESSAGE_ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- 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;
-
- public MessageDAOImpl() {
-
- }
- public MessageDAOImpl(QName type, MessageExchangeDAOImpl me) {
- _type = type.toString();
- }
-
- 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 QName getType() {
- return _type == null ? null : QName.valueOf(_type);
- }
-
- public void setData(Element value) {
- if (value == null) return;
- _data = DOMUtils.domToString(value);
- _element = value;
- }
-
- public void setType(QName type) {
- _type = type.toString();
- }
-
- 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;
- }
-
-}
+/*
+ * 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 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.Table;
+import javax.persistence.Transient;
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.dao.MessageDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+
+@Entity
+@Table(name="ODE_MESSAGE")
+public class MessageDAOImpl implements MessageDAO {
+
+ @Id @Column(name="MESSAGE_ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ 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;
+
+ public MessageDAOImpl() {
+
+ }
+ public MessageDAOImpl(QName type, MessageExchangeDAOImpl me) {
+ _type = type.toString();
+ }
+
+ 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 QName getType() {
+ return _type == null ? null : QName.valueOf(_type);
+ }
+
+ public void setData(Element value) {
+ if (value == null) return;
+ _data = DOMUtils.domToString(value);
+ _element = value;
+ }
+
+ public void setType(QName type) {
+ _type = type.toString();
+ }
+
+ 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;
+ }
+
+}
Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,406 +1,406 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-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.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-import javax.xml.namespace.QName;
-
-import org.apache.ode.bpel.common.CorrelationKey;
-import org.apache.ode.bpel.dao.MessageDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.PartnerLinkDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.iapi.InvocationStyle;
-import org.apache.ode.bpel.iapi.MessageExchange.AckType;
-import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
-import org.apache.ode.bpel.iapi.MessageExchange.MessageExchangePattern;
-import org.apache.ode.bpel.iapi.MessageExchange.Status;
-import org.apache.ode.utils.DOMUtils;
-import org.w3c.dom.Element;
-
-@Entity
-@Table(name="ODE_MESSAGE_EXCHANGE")
-public class MessageExchangeDAOImpl implements MessageExchangeDAO {
-
- @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" , nullable = false)
- private Date _createTime;
- @Basic @Column(name="DIRECTION" ,nullable=false)
- 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", nullable=false)
- private String _operation;
- @Basic @Column(name="PARTNER_LINK_MODEL_ID", nullable=false)
- private int _partnerLinkModelId;
- @Basic @Column(name="PATTERN", nullable=false)
- 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="ACK_TYPE")
- private String _ackType;
-
- @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="INSTANCE")
- private ProcessInstanceDAOImpl _processInst;
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PLINK")
- private PartnerLinkDAOImpl _partnerLink;
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS")
- private ProcessDAOImpl _process;
- @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="REQUEST")
- private MessageDAOImpl _request;
- @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="RESPONSE")
- private MessageDAOImpl _response;
-
- @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="CORRELATOR")
- private CorrelatorDAOImpl _correlator;
-
- @Basic @Column(name="ISTYLE")
- private String _istyle;
-
- @Basic @Column(name="TIMEOUT")
- private long _timeout;
-
- @Basic @Column(name="FAILURE_TYPE")
- private String _failureType;
-
- @Basic @Column(name="PIPED_PID")
- private String _pipedPid;
-
- public MessageExchangeDAOImpl() {}
-
- public MessageExchangeDAOImpl(String mexId, char direction){
- _direction = direction;
- _id = mexId;
- _createTime = new Date();
- }
-
- 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 getPartnersKey() {
- 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 MessageExchangePattern getPattern() {
- return _pattern == null ? null : MessageExchangePattern.valueOf(_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 Status getStatus() {
- return _status == null ? null : Status.valueOf(_status);
- }
-
- public void setCallee(QName callee) {
- _callee = callee.toString();
- }
-
- public void setChannel(String channel) {
- _channel = channel;
- }
-
- public void setPartnersKey(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(MessageExchangePattern pattern) {
- _pattern = pattern == null ? null : pattern.toString();
- }
-
- 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(Status status) {
- _status = status == null ? null : status.toString();
- }
-
- public String getPipedMessageExchangeId() {
- return _pipedMessageExchangeId;
- }
-
- public void setPipedMessageExchangeId(String pipedMessageExchangeId) {
- _pipedMessageExchangeId = pipedMessageExchangeId;
- }
-
- public void addCorrelationKey(CorrelationKey correlationKey) {
- if (_correlationKeys == null)
- _correlationKeys = correlationKey.toCanonicalString();
- else
- _correlationKeys = _correlationKeys + "^" + correlationKey.toCanonicalString();
- }
-
- public Collection<CorrelationKey> getCorrelationKeys() {
- ArrayList<CorrelationKey> correlationKeys = new ArrayList<CorrelationKey>();
- if (_correlationKeys != null) {
- if (_correlationKeys.indexOf("^") > 0) {
- for (StringTokenizer tokenizer = new StringTokenizer(_correlationKeys, "^"); tokenizer.hasMoreTokens();) {
- String corrStr = tokenizer.nextToken();
- correlationKeys.add(new CorrelationKey(corrStr));
- }
- return correlationKeys;
- } else correlationKeys.add(new CorrelationKey(_correlationKeys));
- }
- return correlationKeys;
- }
-
-
- public void release() {
- // no-op for now, could be used to do some cleanup
- }
-
- public CorrelatorDAOImpl getCorrelator() {
- return _correlator;
- }
-
- public void setCorrelator(CorrelatorDAOImpl correlator) {
- _correlator = correlator;
- }
-
- public InvocationStyle getInvocationStyle() {
- return _istyle == null ? null : InvocationStyle.valueOf(_istyle);
- }
-
-
- public long getTimeout() {
- return _timeout;
- }
-
- public void setFailureType(FailureType failureType) {
- _failureType = failureType == null ? null :failureType.toString();
- }
-
- public FailureType getFailureType() {
- return _failureType == null ? null : FailureType.valueOf(_failureType);
- }
-
- public void setInvocationStyle(InvocationStyle invocationStyle) {
- _istyle = invocationStyle == null ? null : invocationStyle.toString();
- }
-
- public void setTimeout(long timeout) {
- _timeout = timeout;
- }
-
- public AckType getAckType() {
- return _ackType == null ? null : AckType.valueOf(_ackType);
- }
-
- public void setAckType(AckType ackType) {
- _ackType = ackType == null ? null :ackType.toString();
- }
-
- public QName getPipedPID() {
- return _pipedPid == null ? null : QName.valueOf(_pipedPid);
- }
-
- public void setPipedPID(QName pipedPid) {
- _pipedPid = pipedPid == null ? null : pipedPid.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 java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+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.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.xml.namespace.QName;
+
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.dao.MessageDAO;
+import org.apache.ode.bpel.dao.MessageExchangeDAO;
+import org.apache.ode.bpel.dao.PartnerLinkDAO;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.iapi.InvocationStyle;
+import org.apache.ode.bpel.iapi.MessageExchange.AckType;
+import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
+import org.apache.ode.bpel.iapi.MessageExchange.MessageExchangePattern;
+import org.apache.ode.bpel.iapi.MessageExchange.Status;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+@Entity
+@Table(name="ODE_MESSAGE_EXCHANGE")
+public class MessageExchangeDAOImpl implements MessageExchangeDAO {
+
+ @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" , nullable = false)
+ private Date _createTime;
+ @Basic @Column(name="DIRECTION" ,nullable=false)
+ 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", nullable=false)
+ private String _operation;
+ @Basic @Column(name="PARTNER_LINK_MODEL_ID", nullable=false)
+ private int _partnerLinkModelId;
+ @Basic @Column(name="PATTERN", nullable=false)
+ 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="ACK_TYPE")
+ private String _ackType;
+
+ @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="INSTANCE")
+ private ProcessInstanceDAOImpl _processInst;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PLINK")
+ private PartnerLinkDAOImpl _partnerLink;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS")
+ private ProcessDAOImpl _process;
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="REQUEST")
+ private MessageDAOImpl _request;
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="RESPONSE")
+ private MessageDAOImpl _response;
+
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="CORRELATOR")
+ private CorrelatorDAOImpl _correlator;
+
+ @Basic @Column(name="ISTYLE")
+ private String _istyle;
+
+ @Basic @Column(name="TIMEOUT")
+ private long _timeout;
+
+ @Basic @Column(name="FAILURE_TYPE")
+ private String _failureType;
+
+ @Basic @Column(name="PIPED_PID")
+ private String _pipedPid;
+
+ public MessageExchangeDAOImpl() {}
+
+ public MessageExchangeDAOImpl(String mexId, char direction){
+ _direction = direction;
+ _id = mexId;
+ _createTime = new Date();
+ }
+
+ 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 getPartnersKey() {
+ 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 MessageExchangePattern getPattern() {
+ return _pattern == null ? null : MessageExchangePattern.valueOf(_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 Status getStatus() {
+ return _status == null ? null : Status.valueOf(_status);
+ }
+
+ public void setCallee(QName callee) {
+ _callee = callee.toString();
+ }
+
+ public void setChannel(String channel) {
+ _channel = channel;
+ }
+
+ public void setPartnersKey(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(MessageExchangePattern pattern) {
+ _pattern = pattern == null ? null : pattern.toString();
+ }
+
+ 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(Status status) {
+ _status = status == null ? null : status.toString();
+ }
+
+ public String getPipedMessageExchangeId() {
+ return _pipedMessageExchangeId;
+ }
+
+ public void setPipedMessageExchangeId(String pipedMessageExchangeId) {
+ _pipedMessageExchangeId = pipedMessageExchangeId;
+ }
+
+ public void addCorrelationKey(CorrelationKey correlationKey) {
+ if (_correlationKeys == null)
+ _correlationKeys = correlationKey.toCanonicalString();
+ else
+ _correlationKeys = _correlationKeys + "^" + correlationKey.toCanonicalString();
+ }
+
+ public Collection<CorrelationKey> getCorrelationKeys() {
+ ArrayList<CorrelationKey> correlationKeys = new ArrayList<CorrelationKey>();
+ if (_correlationKeys != null) {
+ if (_correlationKeys.indexOf("^") > 0) {
+ for (StringTokenizer tokenizer = new StringTokenizer(_correlationKeys, "^"); tokenizer.hasMoreTokens();) {
+ String corrStr = tokenizer.nextToken();
+ correlationKeys.add(new CorrelationKey(corrStr));
+ }
+ return correlationKeys;
+ } else correlationKeys.add(new CorrelationKey(_correlationKeys));
+ }
+ return correlationKeys;
+ }
+
+
+ public void release() {
+ // no-op for now, could be used to do some cleanup
+ }
+
+ public CorrelatorDAOImpl getCorrelator() {
+ return _correlator;
+ }
+
+ public void setCorrelator(CorrelatorDAOImpl correlator) {
+ _correlator = correlator;
+ }
+
+ public InvocationStyle getInvocationStyle() {
+ return _istyle == null ? null : InvocationStyle.valueOf(_istyle);
+ }
+
+
+ public long getTimeout() {
+ return _timeout;
+ }
+
+ public void setFailureType(FailureType failureType) {
+ _failureType = failureType == null ? null :failureType.toString();
+ }
+
+ public FailureType getFailureType() {
+ return _failureType == null ? null : FailureType.valueOf(_failureType);
+ }
+
+ public void setInvocationStyle(InvocationStyle invocationStyle) {
+ _istyle = invocationStyle == null ? null : invocationStyle.toString();
+ }
+
+ public void setTimeout(long timeout) {
+ _timeout = timeout;
+ }
+
+ public AckType getAckType() {
+ return _ackType == null ? null : AckType.valueOf(_ackType);
+ }
+
+ public void setAckType(AckType ackType) {
+ _ackType = ackType == null ? null :ackType.toString();
+ }
+
+ public QName getPipedPID() {
+ return _pipedPid == null ? null : QName.valueOf(_pipedPid);
+ }
+
+ public void setPipedPID(QName pipedPid) {
+ _pipedPid = pipedPid == null ? null : pipedPid.toString();
+ }
+}
Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,82 +1,82 @@
-/*
- * 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.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.Table;
-
-@Entity
-@Table(name="ODE_MESSAGE_ROUTE")
-public class MessageRouteDAOImpl implements MessageRouteDAO {
-
- @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;
-
- @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")
- private CorrelatorDAOImpl _correlator;
-
- public MessageRouteDAOImpl() {}
- public MessageRouteDAOImpl(CorrelationKey key, String groupId, int index,
- ProcessInstanceDAOImpl processInst, CorrelatorDAOImpl correlator) {
- _correlationKey = key.toCanonicalString();
- _groupId = groupId;
- _index = index;
- _processInst = processInst;
- _correlator = correlator;
- }
-
- public CorrelationKey getCorrelationKey() {
- return new CorrelationKey(_correlationKey);
- }
-
- public String getGroupId() {
- return _groupId;
- }
-
- public int getIndex() {
- return _index;
- }
-
- public ProcessInstanceDAO getTargetInstance() {
- return _processInst;
- }
-
-}
+/*
+ * 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.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.Table;
+
+@Entity
+@Table(name="ODE_MESSAGE_ROUTE")
+public class MessageRouteDAOImpl implements MessageRouteDAO {
+
+ @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;
+
+ @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")
+ private CorrelatorDAOImpl _correlator;
+
+ public MessageRouteDAOImpl() {}
+ public MessageRouteDAOImpl(CorrelationKey key, String groupId, int index,
+ ProcessInstanceDAOImpl processInst, CorrelatorDAOImpl correlator) {
+ _correlationKey = key.toCanonicalString();
+ _groupId = groupId;
+ _index = index;
+ _processInst = processInst;
+ _correlator = correlator;
+ }
+
+ public CorrelationKey getCorrelationKey() {
+ return new CorrelationKey(_correlationKey);
+ }
+
+ public String getGroupId() {
+ return _groupId;
+ }
+
+ public int getIndex() {
+ return _index;
+ }
+
+ public ProcessInstanceDAO getTargetInstance() {
+ return _processInst;
+ }
+
+}
Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/PartnerLinkDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,163 +1,163 @@
-/*
- * 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.Table;
-import javax.persistence.Transient;
-import javax.xml.namespace.QName;
-
-@Entity
-@Table(name="ODE_PARTNER_LINK")
-public class PartnerLinkDAOImpl implements PartnerLinkDAO {
-
- @Id @Column(name="PARTNER_LINK_ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- 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;
-
- @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="SCOPE_ID")
- 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.Table;
+import javax.persistence.Transient;
+import javax.xml.namespace.QName;
+
+@Entity
+@Table(name="ODE_PARTNER_LINK")
+public class PartnerLinkDAOImpl implements PartnerLinkDAO {
+
+ @Id @Column(name="PARTNER_LINK_ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ 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;
+
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="SCOPE_ID")
+ 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/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,143 +1,143 @@
-/*
- * 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.dao.CorrelatorDAO;
-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="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 {
-
- @Id @Column(name="ID")
- @GeneratedValue(strategy= GenerationType.AUTO)
- 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;
- }
-
- 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;
- }
-
- @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() {
- getEM().remove(this);
- }
-
- 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;
- }
-
-}
+/*
+ * 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.dao.CorrelatorDAO;
+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="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 {
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ 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;
+ }
+
+ 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;
+ }
+
+ @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() {
+ getEM().remove(this);
+ }
+
+ 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;
+ }
+
+}
Modified: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java?rev=659307&r1=659306&r2=659307&view=diff
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java (original)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessInstanceDAOImpl.java Thu May 22 16:25:57 2008
@@ -1,305 +1,305 @@
-/*
- * 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.ProcessState;
-import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.FaultDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.ScopeStateEnum;
-import org.apache.ode.bpel.dao.XmlDataDAO;
-import org.apache.ode.bpel.evt.ProcessInstanceEvent;
-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.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.Query;
-import javax.persistence.Table;
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-@Entity
-@Table(name="ODE_PROCESS_INSTANCE")
-@NamedQueries({
- @NamedQuery(name="ScopeById", query="SELECT s FROM ScopeDAOImpl as s WHERE s._scopeInstanceId = :sid and s._processInstance = :instance")
- })
-public class ProcessInstanceDAOImpl extends OpenJPADAO implements ProcessInstanceDAO {
-
- @Id @Column(name="ID")
- @GeneratedValue(strategy=GenerationType.AUTO)
- private Long _instanceId;
- @Basic @Column(name="LAST_RECOVERY_DATE")
- private Date _lastRecovery;
- @Basic @Column(name="LAST_ACTIVE_TIME")
- private Date _lastActive;
- @Basic @Column(name="INSTANCE_STATE")
- private short _state;
- @Basic @Column(name="PREVIOUS_STATE")
- private short _previousState;
- @Lob @Column(name="EXECUTION_STATE")
- private byte[] _executionState;
- @Basic @Column(name="SEQUENCE")
- private long _sequence;
- @Basic @Column(name="DATE_CREATED")
- private Date _dateCreated = new Date();
-
- @Basic @Column(name="EXEC_STATE_COUNTER")
- private int _execStateCounter;
-
- @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="ROOT_SCOPE_ID")
- private ScopeDAOImpl _rootScope;
- @OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_processInstance",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
- private Collection<ScopeDAO> _scopes = new ArrayList<ScopeDAO>();
- @OneToMany(targetEntity=ActivityRecoveryDAOImpl.class,mappedBy="_instance",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
- private Collection<ActivityRecoveryDAO> _recoveries = new ArrayList<ActivityRecoveryDAO>();
- @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="FAULT_ID")
- private FaultDAOImpl _fault;
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_ID")
- private ProcessDAOImpl _process;
- @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="INSTANTIATING_CORRELATOR_ID")
- private CorrelatorDAOImpl _instantiatingCorrelator;
-
- public ProcessInstanceDAOImpl() {}
- public ProcessInstanceDAOImpl(CorrelatorDAOImpl correlator, ProcessDAOImpl process) {
- _instantiatingCorrelator = correlator;
- _process = process;
- }
-
- public void createActivityRecovery(String channel, long activityId,
- String reason, Date dateTime, Element data, String[] actions,
- int retries) {
- ActivityRecoveryDAOImpl ar = new ActivityRecoveryDAOImpl(channel, activityId, reason, dateTime, data, actions, retries);
- _recoveries.add(ar);
- ar.setInstance(this);
- _lastRecovery = dateTime;
- }
-
- public ScopeDAO createScope(ScopeDAO parentScope, String name, int scopeModelId) {
- ScopeDAOImpl ret = new ScopeDAOImpl((ScopeDAOImpl)parentScope,name,scopeModelId,this);
- ret.setState(ScopeStateEnum.ACTIVE);
- _scopes.add(ret);
- _rootScope = (parentScope == null)?ret:_rootScope;
-
- // Must persist the scope to generate a scope ID
- getEM().persist(ret);
- return ret;
- }
-
- public void delete() {
- if (getEM() != null ) {
- getEM().remove(this);
- }
- }
-
- public void deleteActivityRecovery(String channel) {
- ActivityRecoveryDAOImpl toRemove = null;
- for (ActivityRecoveryDAO _recovery : _recoveries) {
- ActivityRecoveryDAOImpl arElement = (ActivityRecoveryDAOImpl) _recovery;
- if (arElement.getChannel().equals(channel)) {
- toRemove = arElement;
- break;
- }
- }
- if (toRemove != null) {
- getEM().remove(toRemove);
- _recoveries.remove(toRemove);
- }
-
- }
-
- public void finishCompletion() {
- // make sure we have completed.
- assert (ProcessState.isFinished(this.getState()));
- // let our process know that we've done our work.
- }
-
- public long genMonotonic() {
- return _sequence++;
- }
-
- public int getActivityFailureCount() {
- return _recoveries.size();
- }
-
- public Date getActivityFailureDateTime() {
- return _lastRecovery;
- }
-
- public Collection<ActivityRecoveryDAO> getActivityRecoveries() {
- return _recoveries;
- }
-
- public CorrelationSetDAO getCorrelationSet(String name) {
- // TODO: should this method be deprecated?
-
- // Its not clear where the correlation set for the process is used
- // or populated.
-
- throw new UnsupportedOperationException();
-
- //return null;
- }
-
- public Set<CorrelationSetDAO> getCorrelationSets() {
- // TODO: should this method be deprecated?
- // Its not clear where the correlation set for the process is used
- // or populated.
- return new HashSet<CorrelationSetDAO>();
- }
-
- public Date getCreateTime() {
- return _dateCreated;
- }
-
- public EventsFirstLastCountTuple getEventsFirstLastCount() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public byte[] getExecutionState() {
- return _executionState;
- }
-
- public FaultDAO getFault() {
- return _fault;
- }
-
- public Long getInstanceId() {
- return _instanceId;
- }
-
- public CorrelatorDAO getInstantiatingCorrelator() {
- return _instantiatingCorrelator;
- }
-
- public Date getLastActiveTime() {
- return _lastActive;
- }
-
- public short getPreviousState() {
- return _previousState;
- }
-
- public ProcessDAO getProcess() {
- return _process;
- }
-
- public ScopeDAO getRootScope() {
- return _rootScope;
- }
-
- public ScopeDAO getScope(Long scopeInstanceId) {
- return getEM().find(ScopeDAOImpl.class, scopeInstanceId);
- }
-
- public Collection<ScopeDAO> getScopes(String scopeName) {
- Collection<ScopeDAO> ret = new ArrayList<ScopeDAO>();
-
- for (ScopeDAO sElement : _scopes) {
- if ( sElement.getName().equals(scopeName)) ret.add(sElement);
- }
- return ret;
- }
-
- public Collection<ScopeDAO> getScopes() {
- return _scopes;
- }
-
- public short getState() {
- return _state;
- }
-
- public XmlDataDAO[] getVariables(String variableName, int scopeModelId) {
-
- //TODO: This method is not used and should be considered a deprecation candidate.
-
- List<XmlDataDAO> results = new ArrayList<XmlDataDAO>();
-
- for (ScopeDAO sElement : _scopes) {
- if ( sElement.getModelId() == scopeModelId) {
- XmlDataDAO var = sElement.getVariable(variableName);
- if ( var != null ) results.add(var);
- }
- }
- return results.toArray(new XmlDataDAO[results.size()]);
- }
-
- public void insertBpelEvent(ProcessInstanceEvent event) {
- getConn().insertBpelEvent(event, getProcess(), this);
- }
-
- public void setExecutionState(byte[] execState) {
- _executionState = execState;
- }
-
- public void setFault(FaultDAO fault) {
- _fault = (FaultDAOImpl)fault;
- }
-
- public void setFault(QName faultName, String explanation, int faultLineNo,
- int activityId, Element faultMessage) {
- _fault = new FaultDAOImpl(faultName,explanation,faultLineNo,activityId,faultMessage);
- }
-
- public void setLastActiveTime(Date dt) {
- _lastActive = dt;
- }
-
- public void setState(short state) {
- _previousState = _state;
- _state = state;
- }
-
- void removeRoutes(String routeGroupId) {
- _process.removeRoutes(routeGroupId, this);
- }
-
- public BpelDAOConnection getConnection() {
- return new BPELDAOConnectionImpl(getEM());
- }
- public int getExecutionStateCounter() {
- return _execStateCounter;
- }
- public void setExecutionStateCounter(int stateCounter) {
- _execStateCounter = stateCounter;
- }
-}
+/*
+ * 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.ProcessState;
+import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
+import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.bpel.dao.CorrelationSetDAO;
+import org.apache.ode.bpel.dao.CorrelatorDAO;
+import org.apache.ode.bpel.dao.FaultDAO;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.dao.ScopeStateEnum;
+import org.apache.ode.bpel.dao.XmlDataDAO;
+import org.apache.ode.bpel.evt.ProcessInstanceEvent;
+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.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Query;
+import javax.persistence.Table;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+@Entity
+@Table(name="ODE_PROCESS_INSTANCE")
+@NamedQueries({
+ @NamedQuery(name="ScopeById", query="SELECT s FROM ScopeDAOImpl as s WHERE s._scopeInstanceId = :sid and s._processInstance = :instance")
+ })
+public class ProcessInstanceDAOImpl extends OpenJPADAO implements ProcessInstanceDAO {
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private Long _instanceId;
+ @Basic @Column(name="LAST_RECOVERY_DATE")
+ private Date _lastRecovery;
+ @Basic @Column(name="LAST_ACTIVE_TIME")
+ private Date _lastActive;
+ @Basic @Column(name="INSTANCE_STATE")
+ private short _state;
+ @Basic @Column(name="PREVIOUS_STATE")
+ private short _previousState;
+ @Lob @Column(name="EXECUTION_STATE")
+ private byte[] _executionState;
+ @Basic @Column(name="SEQUENCE")
+ private long _sequence;
+ @Basic @Column(name="DATE_CREATED")
+ private Date _dateCreated = new Date();
+
+ @Basic @Column(name="EXEC_STATE_COUNTER")
+ private int _execStateCounter;
+
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="ROOT_SCOPE_ID")
+ private ScopeDAOImpl _rootScope;
+ @OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_processInstance",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<ScopeDAO> _scopes = new ArrayList<ScopeDAO>();
+ @OneToMany(targetEntity=ActivityRecoveryDAOImpl.class,mappedBy="_instance",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<ActivityRecoveryDAO> _recoveries = new ArrayList<ActivityRecoveryDAO>();
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="FAULT_ID")
+ private FaultDAOImpl _fault;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="PROCESS_ID")
+ private ProcessDAOImpl _process;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.ALL}) @Column(name="INSTANTIATING_CORRELATOR_ID")
+ private CorrelatorDAOImpl _instantiatingCorrelator;
+
+ public ProcessInstanceDAOImpl() {}
+ public ProcessInstanceDAOImpl(CorrelatorDAOImpl correlator, ProcessDAOImpl process) {
+ _instantiatingCorrelator = correlator;
+ _process = process;
+ }
+
+ public void createActivityRecovery(String channel, long activityId,
+ String reason, Date dateTime, Element data, String[] actions,
+ int retries) {
+ ActivityRecoveryDAOImpl ar = new ActivityRecoveryDAOImpl(channel, activityId, reason, dateTime, data, actions, retries);
+ _recoveries.add(ar);
+ ar.setInstance(this);
+ _lastRecovery = dateTime;
+ }
+
+ public ScopeDAO createScope(ScopeDAO parentScope, String name, int scopeModelId) {
+ ScopeDAOImpl ret = new ScopeDAOImpl((ScopeDAOImpl)parentScope,name,scopeModelId,this);
+ ret.setState(ScopeStateEnum.ACTIVE);
+ _scopes.add(ret);
+ _rootScope = (parentScope == null)?ret:_rootScope;
+
+ // Must persist the scope to generate a scope ID
+ getEM().persist(ret);
+ return ret;
+ }
+
+ public void delete() {
+ if (getEM() != null ) {
+ getEM().remove(this);
+ }
+ }
+
+ public void deleteActivityRecovery(String channel) {
+ ActivityRecoveryDAOImpl toRemove = null;
+ for (ActivityRecoveryDAO _recovery : _recoveries) {
+ ActivityRecoveryDAOImpl arElement = (ActivityRecoveryDAOImpl) _recovery;
+ if (arElement.getChannel().equals(channel)) {
+ toRemove = arElement;
+ break;
+ }
+ }
+ if (toRemove != null) {
+ getEM().remove(toRemove);
+ _recoveries.remove(toRemove);
+ }
+
+ }
+
+ public void finishCompletion() {
+ // make sure we have completed.
+ assert (ProcessState.isFinished(this.getState()));
+ // let our process know that we've done our work.
+ }
+
+ public long genMonotonic() {
+ return _sequence++;
+ }
+
+ public int getActivityFailureCount() {
+ return _recoveries.size();
+ }
+
+ public Date getActivityFailureDateTime() {
+ return _lastRecovery;
+ }
+
+ public Collection<ActivityRecoveryDAO> getActivityRecoveries() {
+ return _recoveries;
+ }
+
+ public CorrelationSetDAO getCorrelationSet(String name) {
+ // TODO: should this method be deprecated?
+
+ // Its not clear where the correlation set for the process is used
+ // or populated.
+
+ throw new UnsupportedOperationException();
+
+ //return null;
+ }
+
+ public Set<CorrelationSetDAO> getCorrelationSets() {
+ // TODO: should this method be deprecated?
+ // Its not clear where the correlation set for the process is used
+ // or populated.
+ return new HashSet<CorrelationSetDAO>();
+ }
+
+ public Date getCreateTime() {
+ return _dateCreated;
+ }
+
+ public EventsFirstLastCountTuple getEventsFirstLastCount() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public byte[] getExecutionState() {
+ return _executionState;
+ }
+
+ public FaultDAO getFault() {
+ return _fault;
+ }
+
+ public Long getInstanceId() {
+ return _instanceId;
+ }
+
+ public CorrelatorDAO getInstantiatingCorrelator() {
+ return _instantiatingCorrelator;
+ }
+
+ public Date getLastActiveTime() {
+ return _lastActive;
+ }
+
+ public short getPreviousState() {
+ return _previousState;
+ }
+
+ public ProcessDAO getProcess() {
+ return _process;
+ }
+
+ public ScopeDAO getRootScope() {
+ return _rootScope;
+ }
+
+ public ScopeDAO getScope(Long scopeInstanceId) {
+ return getEM().find(ScopeDAOImpl.class, scopeInstanceId);
+ }
+
+ public Collection<ScopeDAO> getScopes(String scopeName) {
+ Collection<ScopeDAO> ret = new ArrayList<ScopeDAO>();
+
+ for (ScopeDAO sElement : _scopes) {
+ if ( sElement.getName().equals(scopeName)) ret.add(sElement);
+ }
+ return ret;
+ }
+
+ public Collection<ScopeDAO> getScopes() {
+ return _scopes;
+ }
+
+ public short getState() {
+ return _state;
+ }
+
+ public XmlDataDAO[] getVariables(String variableName, int scopeModelId) {
+
+ //TODO: This method is not used and should be considered a deprecation candidate.
+
+ List<XmlDataDAO> results = new ArrayList<XmlDataDAO>();
+
+ for (ScopeDAO sElement : _scopes) {
+ if ( sElement.getModelId() == scopeModelId) {
+ XmlDataDAO var = sElement.getVariable(variableName);
+ if ( var != null ) results.add(var);
+ }
+ }
+ return results.toArray(new XmlDataDAO[results.size()]);
+ }
+
+ public void insertBpelEvent(ProcessInstanceEvent event) {
+ getConn().insertBpelEvent(event, getProcess(), this);
+ }
+
+ public void setExecutionState(byte[] execState) {
+ _executionState = execState;
+ }
+
+ public void setFault(FaultDAO fault) {
+ _fault = (FaultDAOImpl)fault;
+ }
+
+ public void setFault(QName faultName, String explanation, int faultLineNo,
+ int activityId, Element faultMessage) {
+ _fault = new FaultDAOImpl(faultName,explanation,faultLineNo,activityId,faultMessage);
+ }
+
+ public void setLastActiveTime(Date dt) {
+ _lastActive = dt;
+ }
+
+ public void setState(short state) {
+ _previousState = _state;
+ _state = state;
+ }
+
+ void removeRoutes(String routeGroupId) {
+ _process.removeRoutes(routeGroupId, this);
+ }
+
+ public BpelDAOConnection getConnection() {
+ return new BPELDAOConnectionImpl(getEM());
+ }
+ public int getExecutionStateCounter() {
+ return _execStateCounter;
+ }
+ public void setExecutionStateCounter(int stateCounter) {
+ _execStateCounter = stateCounter;
+ }
+}