You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by je...@apache.org on 2010/05/02 19:03:00 UTC
svn commit: r940263 [12/16] - in /ode/trunk: ./ axis2-war/
axis2-war/src/main/assembly/
axis2-war/src/main/webapp/WEB-INF/conf.hib-derby/
axis2-war/src/main/webapp/WEB-INF/conf.jpa-derby/
axis2-war/src/main/webapp/WEB-INF/conf/ axis2-war/src/test/java/...
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageExchangeDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageExchangeDAOImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageExchangeDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageExchangeDAOImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,463 @@
+/*
+ * 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.bpel;
+
+import java.io.Serializable;
+import java.util.*;
+
+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.JoinColumn;
+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.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.dao.bpel.MessageDAO;
+import org.apache.ode.dao.bpel.MessageExchangeDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.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")
+@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 BpelDAO implements MessageExchangeDAO, Serializable {
+ 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" , nullable = false)
+ @Temporal(TemporalType.DATE)
+ private Date _createTime;
+ @Basic @Column(name="DIRECTION" ,nullable=false)
+ private char _direction;
+ @Lob @Column(name="EPR")
+ private String _epr;
+ @Basic @Column(name="RESOURCE", length=255)
+ private String _resource;
+ @Transient private
+ Element _eprElement;
+ @Basic @Column(name="FAULT")
+ private String _fault;
+ @Basic @Column(name="FAULT_EXPLANATION")
+ private String _faultExplanation;
+ /*The following three properties should be not null but the
+ BpelDAOConnection.createMessageExchange does not allow values for them so
+ the entity could not be persisted if they are marked nullable
+ */
+ @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="ACK_TYPE")
+ private String _ackType;
+
+ @OneToMany(targetEntity=MexProperty.class,mappedBy="_mex",fetch=FetchType.EAGER,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
+ private Collection<MexProperty> _props = new ArrayList<MexProperty>();
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="INSTANCE")
+ private ProcessInstanceDAOImpl _processInst;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PLINK")
+ private PartnerLinkDAOImpl _partnerLink;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PROCESS")
+ private ProcessDAOImpl _process;
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) @JoinColumn(name="REQUEST")
+ private MessageDAOImpl _request;
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) @JoinColumn(name="RESPONSE")
+ private MessageDAOImpl _response;
+
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(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;
+
+ @Basic @Column(name="INST_RES")
+ private boolean _instantiatingResource;
+
+ 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 Map<String,String> getProperties() {
+ HashMap<String,String> res = new HashMap<String, String>();
+ for (MexProperty prop : _props) {
+ res.put(prop.getPropertyKey(), prop.getPropertyValue());
+ }
+ return res;
+ }
+
+ 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(boolean doClean) {
+ if( __log.isDebugEnabled() ) __log.debug("INSTANCE CLEANUP(MEX, doClean=" + doClean + ")");
+ if( doClean ) {
+ deleteMessages();
+ }
+ }
+
+ public void deleteMessages() {
+ if( __log.isDebugEnabled() ) __log.debug("INSTANCE CLEANUP(MEX:" + _id + "(request:" + _request + ", response:" + _response);
+
+ getEM().remove(_request);
+ getEM().remove(_response);
+ getEM().createNamedQuery(MexProperty.DELETE_MEX_PROPERTIES_BY_MEX_ID).setParameter("mexId", _id).executeUpdate();
+ getEM().remove(this); // This deletes MexProperty, REQUEST MessageDAO, RESPONSE MessageDAO
+ }
+
+ 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();
+ }
+
+ public String getResource() {
+ return _resource;
+ }
+
+ public void setResource(String resourceStr) {
+ _resource = resourceStr;
+ }
+
+ public boolean isInstantiatingResource() {
+ return _instantiatingResource;
+ }
+
+ public void setInstantiatingResource(boolean inst) {
+ _instantiatingResource = inst;
+ }
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageRouteDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageRouteDAOImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageRouteDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MessageRouteDAOImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,95 @@
+/*
+ * 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.bpel;
+
+import java.io.Serializable;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.dao.bpel.MessageRouteDAO;
+import org.apache.ode.dao.bpel.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.JoinColumn;
+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, Serializable {
+ 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="PROCESS_INSTANCE_ID", insertable=false, updatable=false, nullable=true)
+ @SuppressWarnings("unused")
+ private int _instanceId;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PROCESS_INSTANCE_ID")
+ private ProcessInstanceDAOImpl _processInst;
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(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;
+ }
+
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MexProperty.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MexProperty.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MexProperty.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/MexProperty.java Sun May 2 17:02:51 2010
@@ -0,0 +1,88 @@
+/*
+ * 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.bpel;
+
+import java.io.Serializable;
+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.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_MEX_PROP")
+@NamedQueries({
+ @NamedQuery(name=MexProperty.DELETE_MEX_PROPERTIES_BY_MEX_IDS, query="delete from MexProperty as p where p._mexId in (:mexIds)"),
+ @NamedQuery(name=MexProperty.DELETE_MEX_PROPERTIES_BY_MEX_ID, query="delete from MexProperty as p where p._mexId = :mexId")
+})
+public class MexProperty implements Serializable {
+ public final static String DELETE_MEX_PROPERTIES_BY_MEX_IDS = "DELETE_MEX_PROPERTIES_BY_MEX_IDS";
+ public final static String DELETE_MEX_PROPERTIES_BY_MEX_ID = "DELETE_MEX_PROPERTIES_BY_MEX_ID";
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private Long _id;
+ @Basic @Column(name="PROP_KEY")
+ private String propertyKey;
+ @Basic @Column(name="PROP_VALUE", length=2000)
+ private String propertyValue;
+
+ @Basic @Column(name="MEX_ID", insertable=false, updatable=false, nullable=true)
+ @SuppressWarnings("unused")
+ private String _mexId;
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST})
+ @JoinColumn(name="MEX_ID")
+ private MessageExchangeDAOImpl _mex;
+
+ public MexProperty() {
+ }
+ public MexProperty(String propertyKey, String propertyValue, MessageExchangeDAOImpl mex) {
+ this.propertyKey = propertyKey;
+ this.propertyValue = propertyValue;
+ this._mex = mex;
+ }
+
+ public String getPropertyKey() {
+ return propertyKey;
+ }
+
+ public void setPropertyKey(String propertyKey) {
+ this.propertyKey = propertyKey;
+ }
+
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+ public void setPropertyValue(String propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/PartnerLinkDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/PartnerLinkDAOImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/PartnerLinkDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/PartnerLinkDAOImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +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.bpel;
+
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+
+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.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Query;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.xml.namespace.QName;
+
+import org.apache.ode.dao.bpel.ContextValueDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+
+@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 extends BpelDAO implements PartnerLinkDAO, Serializable {
+ 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;
+
+ @Basic @Column(name="SCOPE_ID", nullable=true, insertable=false, updatable=false)
+ @SuppressWarnings("unused")
+ private Long _scopeId;
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="SCOPE_ID")
+ @SuppressWarnings("unused")
+ private ScopeDAOImpl _scope;
+
+ @OneToMany(targetEntity=ContextValueDAOImpl.class,mappedBy="_partnerLink",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
+ private Collection<ContextValueDAO> _contextValues = new ArrayList<ContextValueDAO>();
+
+ 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;
+ }
+
+ public Collection<ContextValueDAO> getContextValues() {
+ return _contextValues;
+ }
+
+ public void removeContextValue(String namespace, String key) {
+ Query q = getEM().createNamedQuery(ContextValueDAOImpl.DELETE_CONTEXT_VALUES_BY_KEYS);
+ q.setParameter("namespace", namespace);
+ q.setParameter("key", key);
+ }
+
+ public void setContextValue(String namespace, String key, String value) {
+ ContextValueDAO val = null;
+ for (ContextValueDAO v : getContextValues()) {
+ if (v.getNamespace().equals(namespace) && v.getKey().equals(key)) {
+ val = v;
+ }
+ }
+
+ if (val == null) {
+ val = new ContextValueDAOImpl(this, namespace, key);
+ getEM().persist(val);
+ _contextValues.add(val);
+ }
+
+ val.setValue(value);
+ }
+
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessDAOImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessDAOImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,230 @@
+/*
+ * 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.bpel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.dao.bpel.CorrelatorDAO;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+
+import javax.persistence.*;
+import javax.xml.namespace.QName;
+
+import java.io.Serializable;
+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 BpelDAO implements ProcessDAO, Serializable {
+ private static final Log __log = LogFactory.getLog(ProcessDAOImpl.class);
+
+ @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 Serializable getId() {
+ return _id;
+ }
+
+ public void setId(Long id) {
+ _id = id;
+ }
+
+ 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;
+ }
+
+ public Collection<ProcessInstanceDAO> findInstance(CorrelationKey key) {
+ return findInstance(key, true);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<ProcessInstanceDAO> findInstance(CorrelationKey ckey, boolean wait) {
+ 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);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void deleteProcessAndRoutes() {
+ // delete routes
+ 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();
+
+ deleteInstances(Integer.MAX_VALUE);
+
+ // delete process dao
+ getEM().remove(this); // This deletes CorrelatorDAO
+ getEM().flush();
+ }
+
+ private int deleteInstances(int transactionSize) {
+ if(__log.isDebugEnabled()) __log.debug("Cleaning up process data.");
+
+ deleteEvents();
+ deleteCorrelations();
+ deleteMessages();
+ deleteVariables();
+ deleteProcessInstances();
+
+ return 0;
+ }
+
+ @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() {
+ Collection eventIds = getEM().createNamedQuery(MessageDAOImpl.SELECT_REQUEST_MESSAGE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(eventIds.iterator(), getEM().createNamedQuery(MessageDAOImpl.DELETE_MESSAGES_BY_IDS), "ids");
+ eventIds = getEM().createNamedQuery(MessageDAOImpl.SELECT_RESPONSE_MESSAGE_IDS_BY_PROCESS).setParameter("process", this).getResultList();
+ batchUpdateByIds(eventIds.iterator(), getEM().createNamedQuery(MessageDAOImpl.DELETE_MESSAGES_BY_IDS), "ids");
+ 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;
+ }
+
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessInstanceDAOImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,420 @@
+/*
+ * 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.bpel;
+
+import java.io.Serializable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.dao.bpel.*;
+import org.apache.ode.bpel.evt.ProcessInstanceEvent;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+import org.w3c.dom.Element;
+
+import javax.persistence.*;
+import javax.xml.namespace.QName;
+import java.util.*;
+
+@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"),
+ @NamedQuery(name=ProcessInstanceDAOImpl.DELETE_INSTANCES_BY_PROCESS, query="delete from ProcessInstanceDAOImpl as i where i._process = :process"),
+ @NamedQuery(name=ProcessInstanceDAOImpl.SELECT_INSTANCE_IDS_BY_PROCESS, query="select i._instanceId from ProcessInstanceDAOImpl as i where i._process = :process"),
+ @NamedQuery(name=ProcessInstanceDAOImpl.SELECT_FAULT_IDS_BY_PROCESS, query="select i._faultId from ProcessInstanceDAOImpl as i where i._process = :process and i._faultId is not null"),
+ @NamedQuery(name=ProcessInstanceDAOImpl.COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID,
+ query="select count(i._instanceId), max(i._lastRecovery) from ProcessInstanceDAOImpl as i where i._process._processId = :processId and i._state in(:states) and exists(select r from ActivityRecoveryDAOImpl r where i = r._instance)")
+})
+
+public class ProcessInstanceDAOImpl extends BpelDAO implements ProcessInstanceDAO, Serializable {
+ private static final Log __log = LogFactory.getLog(ProcessInstanceDAOImpl.class);
+
+ public final static String DELETE_INSTANCES_BY_PROCESS = "DELETE_INSTANCES_BY_PROCESS";
+ public final static String SELECT_INSTANCE_IDS_BY_PROCESS = "SELECT_INSTANCE_IDS_BY_PROCESS";
+
+ public final static String SELECT_FAULT_IDS_BY_PROCESS = "SELECT_FAULT_IDS_BY_PROCESS";
+
+ public final static String COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID = "COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID";
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ private Long _instanceId;
+ @Basic @Column(name="LAST_RECOVERY_DATE")
+ @Temporal(TemporalType.DATE)
+ private Date _lastRecovery;
+ @Basic @Column(name="LAST_ACTIVE_TIME")
+ @Temporal(TemporalType.DATE)
+ 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")
+ @Temporal(TemporalType.DATE)
+ private Date _dateCreated = new Date();
+
+ @Basic @Column(name="INSTANTIATE_URL", length=255)
+ private String _instantiatingUrl;
+
+ @Basic @Column(name="EXEC_STATE_COUNTER")
+ private int _execStateCounter;
+
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) @JoinColumn(name="ROOT_SCOPE_ID")
+ private ScopeDAOImpl _rootScope;
+ @OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_processInstance",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
+ 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>();
+ @Basic @Column(name="FAULT_ID", insertable=false, updatable=false, nullable=true)
+ @SuppressWarnings("unused")
+ private long _faultId;
+ @OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}) @JoinColumn(name="FAULT_ID")
+ private FaultDAOImpl _fault;
+ @OneToMany(targetEntity=ResourceRouteDAOImpl.class,mappedBy="_instance",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<ResourceRouteDAO> _resourceRoutes = new ArrayList<ResourceRouteDAO>();
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PROCESS_ID")
+ private ProcessDAOImpl _process;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="INSTANTIATING_CORRELATOR_ID")
+ private CorrelatorDAOImpl _instantiatingCorrelator;
+
+ private transient int _activityFailureCount = -1;
+
+ 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;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<CorrelationSetDAO> selectCorrelationSets(Collection<ProcessInstanceDAO> instances) {
+ return getEM().createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SETS_BY_INSTANCES).setParameter("instances", instances).getResultList();
+ }
+
+ public boolean delete(Set<CLEANUP_CATEGORY> cleanupCategories) {
+ if(__log.isDebugEnabled()) __log.debug("Cleaning up instance Data with " + cleanupCategories);
+
+ boolean instanceDeleted = false;
+
+ // remove jacob state
+ setExecutionState(null);
+ if (getEM() != null) {
+ if( !cleanupCategories.isEmpty() ) {
+ // by default, we do not flush before select; flush it, so we can delete no matter if an entity is loaded up
+ // or not; more importantly, OpenJPA will secretly load from the entire table if some entities reside only
+ // in memory
+ getEM().flush();
+ }
+
+ if (cleanupCategories.contains(CLEANUP_CATEGORY.EVENTS)) {
+ deleteEvents();
+ }
+ if (cleanupCategories.contains(CLEANUP_CATEGORY.CORRELATIONS)) {
+ deleteCorrelations();
+ }
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.MESSAGES) ) {
+ deleteMessageRoutes();
+ }
+ if (cleanupCategories.contains(CLEANUP_CATEGORY.VARIABLES)) {
+ deleteVariables();
+ }
+ if (cleanupCategories.contains(CLEANUP_CATEGORY.INSTANCE)) {
+ deleteInstance();
+ instanceDeleted = true;
+ }
+
+ getEM().flush();
+ }
+
+ return instanceDeleted;
+ }
+
+ private void deleteInstance() {
+ if( _fault != null ) {
+ getEM().remove(_fault);
+ }
+ getEM().remove(this); // This deletes ActivityRecoveryDAO
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteVariables() {
+ Collection xmlDataIds = getEM().createNamedQuery(XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_INSTANCE).setParameter("instance", 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_INSTANCE).setParameter("instance", this).getResultList();
+ batchUpdateByIds(scopeIds.iterator(), getEM().createNamedQuery(XmlDataDAOImpl.DELETE_XMLDATA_BY_SCOPE_IDS), "scopeIds");
+
+ 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");
+ }
+
+ private void deleteMessageRoutes() {
+ getEM().createNamedQuery(MessageRouteDAOImpl.DELETE_MESSAGE_ROUTES_BY_INSTANCE).setParameter ("instance", this).executeUpdate();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteCorrelations() {
+ Collection corrSetIds = getEM().createNamedQuery(CorrelationSetDAOImpl.SELECT_CORRELATION_SET_IDS_BY_INSTANCE).setParameter("instance", 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");
+ }
+
+ private void deleteEvents() {
+ getEM().createNamedQuery(EventDAOImpl.DELETE_EVENTS_BY_INSTANCE).setParameter ("instance", this).executeUpdate();
+ }
+
+ 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 String getInstantiatingUrl() {
+ return _instantiatingUrl;
+ }
+
+ public void setInstantiatingUrl(String url) {
+ _instantiatingUrl = url;
+ }
+
+ public void createResourceRoute(String url, String method, String pickResponseChannel, int selectorIdx) {
+ ResourceRouteDAOImpl rr = new ResourceRouteDAOImpl(url, method, pickResponseChannel, selectorIdx, this);
+ rr.setInstance(this);
+ _resourceRoutes.add(rr);
+ }
+
+ public Set<String> getAllResourceRoutes() {
+ HashSet<String> rs = new HashSet<String>();
+ for (ResourceRouteDAO resourceRoute : _resourceRoutes) {
+ rs.add(resourceRoute.getUrl() + "~" + resourceRoute.getMethod());
+ }
+ return rs;
+ }
+
+ 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() {
+ if( _activityFailureCount == -1 ) {
+ _activityFailureCount = _recoveries.size();
+ }
+
+ return _activityFailureCount;
+ }
+
+ public void setActivityFailureCount(int activityFailureCount) {
+ _activityFailureCount = activityFailureCount;
+ }
+
+ 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() {
+ Query eventQ = getEM().createQuery("SELECT MAX(e._tstamp), MIN(e._tstamp), COUNT(e._tstamp) FROM EventDAOImpl e WHERE e._instance = :instanceId");
+ eventQ.setParameter("instanceId", this);
+ List results = eventQ.getResultList();
+
+ if(!results.isEmpty()){
+ EventsFirstLastCountTuple flc = new EventsFirstLastCountTuple();
+ Object[] res = (Object[]) results.get(0);
+ flc.first = (Date)res[1];
+ flc.last = (Date)res[0];
+ flc.count = ((Long)res[2]).intValue();
+
+ return flc;
+ }
+ 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 BpelDAOConnectionImpl.getThreadLocal().get();
+ }
+
+ public int getExecutionStateCounter() {
+ return _execStateCounter;
+ }
+ public void setExecutionStateCounter(int stateCounter) {
+ _execStateCounter = stateCounter;
+ }
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessManagementDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessManagementDAOImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessManagementDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ProcessManagementDAOImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,56 @@
+package org.apache.ode.dao.jpa.bpel;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.dao.bpel.BpelDAOConnection;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ProcessManagementDAO;
+
+public class ProcessManagementDAOImpl implements ProcessManagementDAO {
+ private static final Log __log = LogFactory.getLog(ProcessManagementDAOImpl.class);
+
+ private EntityManager em;
+
+ public ProcessManagementDAOImpl(EntityManager em) {
+ this.em = em;
+ }
+
+ public Object[] findFailedCountAndLastFailedDateForProcessId(BpelDAOConnection conn, String status, String processId) {
+ Query query = em.createNamedQuery(ProcessInstanceDAOImpl.COUNT_FAILED_INSTANCES_BY_STATUS_AND_PROCESS_ID);
+ query.setParameter("states", new InstanceFilter("status=" + status).convertFilterState());
+ query.setParameter("processId", processId);
+
+ return (Object[])query.getSingleResult();
+ }
+
+ public void prefetchActivityFailureCounts(Collection<ProcessInstanceDAO> instances) {
+ if(__log.isTraceEnabled()) __log.trace("Prefetching activity failure counts for " + instances.size() + " instances.");
+
+ if( instances.isEmpty() ) return;
+
+ Query query = em.createNamedQuery(ActivityRecoveryDAOImpl.COUNT_ACTIVITY_RECOVERIES_BY_INSTANCES);
+ query.setParameter("instances", instances);
+
+ Map<Long, Long> countsByInstanceId = new HashMap<Long, Long>();
+ for( Object instanceIdAndCount : query.getResultList() ) {
+ Object instanceId = ((Object[])instanceIdAndCount)[0];
+ Object count = ((Object[])instanceIdAndCount)[0];
+ countsByInstanceId.put((Long)instanceId, (Long)count);
+ }
+
+ for( ProcessInstanceDAO instance : instances ) {
+ Long count = countsByInstanceId.get(instance.getInstanceId());
+ if( count != null ) {
+ ((ProcessInstanceDAOImpl)instance).setActivityFailureCount(count.intValue());
+ }
+ }
+ }
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ResourceRouteDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ResourceRouteDAOImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ResourceRouteDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ResourceRouteDAOImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,84 @@
+package org.apache.ode.dao.jpa.bpel;
+
+import java.io.Serializable;
+import org.apache.ode.dao.bpel.ResourceRouteDAO;
+
+import javax.persistence.*;
+
+@Entity
+@Table(name="ODE_RESOURCE_ROUTE")
+public class ResourceRouteDAOImpl extends BpelDAO implements ResourceRouteDAO, Serializable {
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ private Long _id;
+ @Basic @Column(name="URL", length=255)
+ private String _url;
+ @Basic @Column(name="METHOD", length=8)
+ private String _method;
+ @Basic @Column(name="CHANNEL")
+ private String _channelId;
+ @Basic @Column(name="ROUTE_INDEX")
+ private int _index;
+
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="INSTANCE_ID")
+ private ProcessInstanceDAOImpl _instance;
+
+ public ResourceRouteDAOImpl() { }
+
+ public ResourceRouteDAOImpl(String url, String method, String channelId, int index, ProcessInstanceDAOImpl instance) {
+ _url = url;
+ _channelId = channelId;
+ _index = index;
+ _instance = instance;
+ _method = method;
+ }
+
+ public Long getId() {
+ return _id;
+ }
+
+ public void setId(Long id) {
+ _id = id;
+ }
+
+ public String getUrl() {
+ return _url;
+ }
+
+ public void setUrl(String url) {
+ _url = url;
+ }
+
+ public String getPickResponseChannel() {
+ return _channelId;
+ }
+
+ public void setPickResponseChannel(String channelId) {
+ _channelId = channelId;
+ }
+
+ public int getSelectorIdx() {
+ return _index;
+ }
+
+ public void setSelectorIdx(int index) {
+ _index = index;
+ }
+
+ public String getMethod() {
+ return _method;
+ }
+
+ public void setMethod(String method) {
+ _method = method;
+ }
+
+ public ProcessInstanceDAOImpl getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(ProcessInstanceDAOImpl instance) {
+ _instance = instance;
+ }
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ScopeDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ScopeDAOImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ScopeDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/ScopeDAOImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,205 @@
+/*
+ * 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.bpel;
+
+import java.io.Serializable;
+import org.apache.ode.dao.bpel.CorrelationSetDAO;
+import org.apache.ode.dao.bpel.PartnerLinkDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.ScopeStateEnum;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.apache.ode.bpel.evt.BpelEvent;
+
+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.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Query;
+import javax.persistence.Table;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+@Entity
+@Table(name="ODE_SCOPE")
+@NamedQueries({
+ @NamedQuery(name="ScopeEvents", query="SELECT se FROM EventDAOImpl as se WHERE se._scopeId = :sid"),
+ @NamedQuery(name=ScopeDAOImpl.SELECT_SCOPE_IDS_BY_PROCESS, query="select s._scopeInstanceId from ScopeDAOImpl as s where s._processInstance._process = :process"),
+ @NamedQuery(name=ScopeDAOImpl.SELECT_SCOPE_IDS_BY_INSTANCE, query="select s._scopeInstanceId from ScopeDAOImpl as s where s._processInstance = :instance"),
+ @NamedQuery(name=ScopeDAOImpl.DELETE_SCOPES_BY_SCOPE_IDS, query="delete from ScopeDAOImpl as s where s._scopeInstanceId in(:ids)")
+})
+public class ScopeDAOImpl extends BpelDAO implements ScopeDAO, Serializable {
+ public final static String SELECT_SCOPE_IDS_BY_PROCESS = "SELECT_SCOPE_IDS_BY_PROCESS";
+ public final static String SELECT_SCOPE_IDS_BY_INSTANCE = "SELECT_SCOPE_IDS_BY_INSTANCE";
+ public final static String DELETE_SCOPES_BY_SCOPE_IDS = "DELETE_SCOPES_BY_SCOPE_IDS";
+
+ @Id @Column(name="SCOPE_ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ private Long _scopeInstanceId;
+
+ @Basic @Column(name="MODEL_ID")
+ private int _modelId;
+ @Basic @Column(name="SCOPE_NAME")
+ private String _name;
+ @Basic @Column(name="SCOPE_STATE")
+ private String _scopeState;
+
+ @ManyToOne(targetEntity=ScopeDAOImpl.class,fetch=FetchType.LAZY,cascade={CascadeType.PERSIST})
+ @JoinColumn(name="PARENT_SCOPE_ID")
+ private ScopeDAOImpl _parentScope;
+
+ @OneToMany(targetEntity=ScopeDAOImpl.class,mappedBy="_parentScope",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
+ private Collection<ScopeDAO> _childScopes = new ArrayList<ScopeDAO>();
+ @OneToMany(targetEntity=CorrelationSetDAOImpl.class,mappedBy="_scope",fetch=FetchType.LAZY,cascade={CascadeType.ALL})
+ private Collection<CorrelationSetDAO> _correlationSets = new ArrayList<CorrelationSetDAO>();
+ @OneToMany(targetEntity=PartnerLinkDAOImpl.class,mappedBy="_scope",fetch= FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
+ private Collection<PartnerLinkDAO> _partnerLinks = new ArrayList<PartnerLinkDAO>();
+ @OneToMany(targetEntity=XmlDataDAOImpl.class,mappedBy="_scope",fetch=FetchType.LAZY,cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
+ private Collection<XmlDataDAO> _variables = new ArrayList<XmlDataDAO>();
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="PROCESS_INSTANCE_ID")
+ private ProcessInstanceDAOImpl _processInstance;
+
+ public ScopeDAOImpl() {}
+ public ScopeDAOImpl(ScopeDAOImpl parentScope, String name, int scopeModelId, ProcessInstanceDAOImpl pi) {
+ _parentScope = parentScope;
+ if (parentScope!=null){
+ parentScope.getChildScopes().add(this);
+ }
+ _name = name;
+ _modelId = scopeModelId;
+ _processInstance = pi;
+ }
+
+ public PartnerLinkDAO createPartnerLink(int plinkModelId, String pLinkName,
+ String myRole, String partnerRole) {
+ PartnerLinkDAOImpl pl = new PartnerLinkDAOImpl(plinkModelId, pLinkName, myRole, partnerRole);
+ pl.setScope(this);
+ _partnerLinks.add(pl);
+ return pl;
+ }
+
+ public Collection<ScopeDAO> getChildScopes() {
+ return _childScopes;
+ }
+
+ public CorrelationSetDAO getCorrelationSet(String corrSetName) {
+ CorrelationSetDAO ret = null;
+ for (CorrelationSetDAO csElement : _correlationSets) {
+ if ( csElement.getName().equals(corrSetName)) ret = csElement;
+ }
+
+ if ( ret == null ) {
+ // Apparently the caller knows there should be a correlation set
+ // in here. Create a new set if one does not exist.
+ // Not sure I understand this implied object creation and why
+ // an explicit create pattern isn't used ( i.e. similar to
+ // PartnerLink creation )
+ ret = new CorrelationSetDAOImpl(this,corrSetName);
+ // Persist the new correlation set to generate an ID
+ getEM().persist(ret);
+ _correlationSets.add(ret);
+ }
+
+ return ret;
+ }
+
+ public Collection<CorrelationSetDAO> getCorrelationSets() {
+ return _correlationSets;
+ }
+
+ public int getModelId() {
+ return _modelId;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public ScopeDAO getParentScope() {
+ return _parentScope;
+ }
+
+ public PartnerLinkDAO getPartnerLink(int plinkModelId) {
+ for (PartnerLinkDAO pLink : getPartnerLinks()) {
+ if (pLink.getPartnerLinkModelId() == plinkModelId) {
+ return pLink;
+ }
+ }
+ return null;
+ }
+
+ public Collection<PartnerLinkDAO> getPartnerLinks() {
+ return _partnerLinks;
+ }
+
+ public ProcessInstanceDAO getProcessInstance() {
+ return _processInstance;
+ }
+
+ public Long getScopeInstanceId() {
+ return _scopeInstanceId;
+ }
+
+ public ScopeStateEnum getState() {
+ return new ScopeStateEnum(_scopeState);
+ }
+
+ public XmlDataDAO getVariable(String varName) {
+ XmlDataDAO ret = null;
+
+ for (XmlDataDAO xmlElement : _variables) {
+ if ( xmlElement.getName().equals(varName)) return xmlElement;
+ }
+
+ ret = new XmlDataDAOImpl(this,varName);
+ _variables.add(ret);
+
+ return ret;
+ }
+
+ public Collection<XmlDataDAO> getVariables() {
+ return _variables;
+ }
+
+ public List<BpelEvent> listEvents() {
+ List<BpelEvent> result = new ArrayList<BpelEvent>();
+ Query qry = getEM().createNamedQuery("ScopeEvents");
+ qry.setParameter("sid", _scopeInstanceId);
+ for (Object eventDao : qry.getResultList()) {
+ result.add(((EventDAOImpl)eventDao).getEvent());
+ }
+ return result;
+ }
+
+ public void setState(ScopeStateEnum state) {
+ _scopeState = state.toString();
+ }
+
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataDAOImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataDAOImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,166 @@
+/*
+ * 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.bpel;
+
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+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.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_XML_DATA")
+@NamedQueries({
+ @NamedQuery(name=XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_PROCESS, query="select distinct x._id from XmlDataDAOImpl as x where x._scope._processInstance._process = :process"),
+ @NamedQuery(name=XmlDataDAOImpl.SELECT_XMLDATA_IDS_BY_INSTANCE, query="select distinct x._id from XmlDataDAOImpl as x where x._scope._processInstance = :instance"),
+ @NamedQuery(name=XmlDataDAOImpl.DELETE_XMLDATA_BY_SCOPE_IDS, query="delete from XmlDataDAOImpl as x where x._scopeId in(:scopeIds)")
+})
+public class XmlDataDAOImpl implements XmlDataDAO {
+ public final static String SELECT_XMLDATA_IDS_BY_PROCESS = "SELECT_XMLDATA_IDS_BY_PROCESS";
+ public final static String SELECT_XMLDATA_IDS_BY_INSTANCE = "SELECT_XMLDATA_IDS_BY_INSTANCE";
+ public final static String DELETE_XMLDATA_BY_SCOPE_IDS = "DELETE_XMLDATA_BY_SCOPE_IDS";
+
+ @Id @Column(name="XML_DATA_ID")
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+ @Lob @Column(name="DATA")
+ private String _data;
+ @Transient
+ private Node _node;
+ @Basic @Column(name="IS_SIMPLE_TYPE")
+ private boolean _isSimpleType;
+ @Basic @Column(name="NAME")
+ private String _name;
+
+ @OneToMany(targetEntity=XmlDataProperty.class,mappedBy="_xmlData",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
+ private Collection<XmlDataProperty> _props = new ArrayList<XmlDataProperty>();
+
+ @Basic @Column(name="SCOPE_ID", nullable=true, insertable=false, updatable=false)
+ @SuppressWarnings("unused")
+ private Long _scopeId;
+ @ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @JoinColumn(name="SCOPE_ID")
+ private ScopeDAOImpl _scope;
+
+ public XmlDataDAOImpl() {}
+ public XmlDataDAOImpl(ScopeDAOImpl scope, String name){
+ _scope = scope;
+ _name = name;
+ }
+
+ public Node get() {
+ if ( _node == null && _data != null ) {
+ if(_isSimpleType){
+ Document d = DOMUtils.newDocument();
+ // we create a dummy wrapper element
+ // prevents some apps from complaining
+ // when text node is not actual child of document
+ Element e = d.createElement("text-node-wrapper");
+ Text tnode = d.createTextNode(_data);
+ d.appendChild(e);
+ e.appendChild(tnode);
+ _node = tnode;
+ }else{
+ try{
+ _node = DOMUtils.stringToDOM(_data);
+ }catch(Exception e){
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ return _node;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public String getProperty(String propertyName) {
+ for (XmlDataProperty prop : _props) {
+ if (prop.getPropertyKey().equals(propertyName)) return prop.getPropertyValue();
+ }
+ return null;
+ }
+
+ private XmlDataProperty getPropertyObject(String propertyName) {
+ for (XmlDataProperty prop : _props) {
+ if (prop.getPropertyKey().equals(propertyName)) return prop;
+ }
+ return null;
+ }
+
+ public ScopeDAO getScopeDAO() {
+ return _scope;
+ }
+
+ public boolean isNull() {
+ return _data == null;
+ }
+
+ public void remove() {
+
+ }
+
+ public void set(Node val) {
+ _node = val;
+ if ( val instanceof Element ) {
+ _isSimpleType = false;
+ _data = DOMUtils.domToString(val);
+ } else if (_node != null) {
+ _isSimpleType = true;
+ _data = _node.getNodeValue();
+ }
+ }
+
+ public void setProperty(String pname, String pvalue) {
+ XmlDataProperty prop = getPropertyObject(pname);
+ if (prop == null) {
+ _props.add(new XmlDataProperty(pname, pvalue, this));
+ } else {
+ prop.setPropertyValue(pvalue);
+ }
+ }
+
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataProperty.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataProperty.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataProperty.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/bpel/XmlDataProperty.java Sun May 2 17:02:51 2010
@@ -0,0 +1,89 @@
+/*
+ * 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.bpel;
+
+import java.io.Serializable;
+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.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_XML_DATA_PROP")
+@NamedQueries({
+ @NamedQuery(name=XmlDataProperty.DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS, query="delete from XmlDataProperty as p where p._xmlDataId in (:xmlDataIds)")
+})
+public class XmlDataProperty implements Serializable {
+ public final static String DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS = "DELETE_XML_DATA_PROPERTIES_BY_XML_DATA_IDS";
+
+ @Id @Column(name="ID")
+ @GeneratedValue(strategy= GenerationType.AUTO)
+ @SuppressWarnings("unused")
+ private Long _id;
+ @Basic @Column(name="PROP_KEY")
+ private String propertyKey;
+ @Basic @Column(name="PROP_VALUE")
+ private String propertyValue;
+
+ @Basic @Column(name="XML_DATA_ID", insertable=false, updatable=false, nullable=true)
+ @SuppressWarnings("unused")
+ private Long _xmlDataId;
+ @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST})
+ @JoinColumn(name="XML_DATA_ID")
+ @SuppressWarnings("unused")
+ private XmlDataDAOImpl _xmlData;
+
+ public XmlDataProperty() {
+ }
+ public XmlDataProperty(String propertyKey, String propertyValue, XmlDataDAOImpl xmlData) {
+ this.propertyKey = propertyKey;
+ this.propertyValue = propertyValue;
+ this._xmlData = xmlData;
+ }
+
+ public String getPropertyKey() {
+ return propertyKey;
+ }
+
+ public void setPropertyKey(String propertyKey) {
+ this.propertyKey = propertyKey;
+ }
+
+ public String getPropertyValue() {
+ return propertyValue;
+ }
+
+ public void setPropertyValue(String propertyValue) {
+ this.propertyValue = propertyValue;
+ }
+
+}
Added: ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/scheduler/JobDAOImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/scheduler/JobDAOImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/scheduler/JobDAOImpl.java (added)
+++ ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/scheduler/JobDAOImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,249 @@
+/*
+ * 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.scheduler;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Map;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.iapi.Scheduler;
+import org.apache.ode.bpel.iapi.Scheduler.JobDetails;
+import org.apache.ode.dao.scheduler.JobDAO;
+
+/**
+ */
+@Entity
+@Table(name = "ODE_JOB")
+@NamedQueries({
+ @NamedQuery(name = "deleteJobs", query = "DELETE FROM JobDAOImpl AS j WHERE j.jobId = :job AND j.nodeId = :node"),
+ @NamedQuery(name = "nodeIds", query = "SELECT DISTINCT j.nodeId FROM JobDAOImpl AS j WHERE j.nodeId IS NOT NULL"),
+ @NamedQuery(name = "dequeueImmediate", query = "SELECT j FROM JobDAOImpl AS j WHERE j.nodeId = :node AND j.scheduled = false AND j.timestamp < :time ORDER BY j.timestamp"),
+ @NamedQuery(name = "updateScheduled", query = "UPDATE JobDAOImpl AS j SET j.scheduled = true WHERE j.jobId in (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)"),
+ @NamedQuery(name = "updateAssignToNode", query = "UPDATE JobDAOImpl AS j SET j.nodeId = :node WHERE j.nodeId IS NULL AND j.scheduled = false AND mod(j.timestamp,:numNode) = :i AND j.timestamp < :maxTime"),
+ @NamedQuery(name = "updateReassign", query = "UPDATE JobDAOImpl AS j SET j.nodeId = :newNode, j.scheduled = false WHERE j.nodeId = :oldNode")
+})
+public class JobDAOImpl implements JobDAO, Serializable {
+
+ private static final Log __log = LogFactory.getLog(JobDAOImpl.class);
+ private String _jobId;
+ private long _ts;
+ private String _nodeId;
+ private boolean _scheduled;
+ private boolean _transacted;
+ private boolean _persisted = true;
+ JobDetails _details = new Scheduler.JobDetails();
+
+ //JobDAO methods
+ @Id
+ @Column(name = "JOB_ID", length = 64)
+ public String getJobId() {
+ return _jobId;
+ }
+
+ @Column(name = "TRANSACTED", nullable = false)
+ public boolean isTransacted() {
+ return _transacted;
+ }
+
+ @Transient
+ public JobDetails getDetails() {
+ return _details;
+ }
+
+ @Transient
+ public boolean isPersisted() {
+ return _persisted;
+ }
+
+ @Transient
+ public long getScheduledDate() {
+ return getTimestamp();
+ }
+
+ //JPA Job getters/setters
+ public void setJobId(String jobId) {
+ _jobId = jobId;
+ }
+
+ @Column(name = "TS", nullable = false)
+ public long getTimestamp() {
+ return _ts;
+ }
+
+ public void setTimestamp(long ts) {
+ _ts = ts;
+ }
+
+ @Column(name = "NODE_ID", length = 64)
+ public String getNodeId() {
+ return _nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ _nodeId = nodeId;
+ }
+
+ @Column(name = "SCHEDULED", nullable = false)
+ public boolean isScheduled() {
+ return _scheduled;
+ }
+
+ public void setScheduled(boolean scheduled) {
+ this._scheduled = scheduled;
+ }
+
+ public void setTransacted(boolean transacted) {
+ this._transacted = transacted;
+ }
+
+ public void setPersisted(boolean persisted) {
+ this._persisted = persisted;
+ }
+
+ public void setDetails(JobDetails details) {
+ _details = details;
+ }
+
+ //JPA JobDetails getters/setters
+ @Column(name = "INSTANCE_ID")
+ public long getInstanceId() {
+ return _details.instanceId == null ? 0L : _details.instanceId.longValue();
+ }
+
+ public void setInstanceId(long instanceId) {
+ _details.instanceId = instanceId;
+ }
+
+ @Column(name = "MEX_ID")
+ public String getMexId() {
+ return _details.mexId;
+ }
+
+ public void setMexId(String mexId) {
+ _details.mexId = mexId;
+ }
+
+ @Column(name = "PROCESS_ID")
+ public String getProcessId() {
+ return _details.processId;
+ }
+
+ public void setProcessId(String processId) {
+ _details.processId = processId;
+ }
+
+ @Column(name = "TYPE")
+ public String getType() {
+ return _details.type;
+ }
+
+ public void setType(String type) {
+ _details.type = type!=null?type:"";
+ }
+
+ @Column(name = "CHANNEL")
+ public String getChannel() {
+ return _details.channel;
+ }
+
+ public void setChannel(String channel) {
+ _details.channel = channel;
+ }
+
+ @Column(name = "CORRELATOR_ID")
+ public String getCorrelatorId() {
+ return _details.correlatorId;
+ }
+
+ public void setCorrelatorId(String correlatorId) {
+ _details.correlatorId = correlatorId;
+ }
+
+ @Column(name = "CORRELATION_KEY")
+ public String getCorrelationKey() {
+ return _details.correlationKey;
+ }
+
+ public void setCorrelationKey(String correlationKey) {
+ _details.correlationKey = correlationKey;
+ }
+
+ @Column(name = "RETRY_COUNT")
+ public int getRetryCount() {
+ return _details.retryCount == null ? 0 : _details.retryCount.intValue();
+ }
+
+ public void setRetryCount(int retryCount) {
+ _details.retryCount = retryCount;
+ }
+
+ @Column(name = "IN_MEM")
+ public boolean isInMem() {
+ return _details.inMem == null ? false : _details.inMem.booleanValue();
+ }
+
+ public void setInMem(boolean inMem) {
+ _details.inMem = inMem;
+ }
+
+ //should not lazy load, it is possible getDetails() called before this
+ @Lob
+ @Column(name = "DETAILS_EXT")
+ public byte[] getDetailsExt() {
+ if (_details.detailsExt != null) {
+ try {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream os = new ObjectOutputStream(bos);
+ os.writeObject(_details.detailsExt);
+ os.close();
+ return bos.toByteArray();
+ } catch (Exception e) {
+ __log.error("Error in getDetailsExt ", e);
+ }
+ }
+ return null;
+ }
+
+ public void setDetailsExt(byte[] detailsExt) {
+ if (detailsExt != null) {
+ try {
+ ByteArrayInputStream bis = new ByteArrayInputStream(detailsExt);
+ ObjectInputStream is = new ObjectInputStream(bis);
+ _details.detailsExt = (Map<String, Object>) is.readObject();
+ is.close();
+ } catch (Exception e) {
+ __log.error("Error in setDetailsExt ", e);
+ }
+ }
+ }
+}