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 [7/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/o...
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessDaoImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessDaoImpl.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessDaoImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,319 @@
+/*
+ * 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.hib.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.DeferredProcessInstanceCleanable;
+import org.apache.ode.dao.bpel.ProcessDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.bpel.iapi.ProcessConf.CLEANUP_CATEGORY;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HActivityRecovery;
+import org.apache.ode.dao.hib.bpel.hobj.HBpelEvent;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationSet;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelator;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorMessage;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelatorSelector;
+import org.apache.ode.dao.hib.bpel.hobj.HFaultData;
+import org.apache.ode.dao.hib.bpel.hobj.HLargeData;
+import org.apache.ode.dao.hib.bpel.hobj.HMessage;
+import org.apache.ode.dao.hib.bpel.hobj.HMessageExchange;
+import org.apache.ode.dao.hib.bpel.hobj.HMessageExchangeProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HObject;
+import org.apache.ode.dao.hib.bpel.hobj.HPartnerLink;
+import org.apache.ode.dao.hib.bpel.hobj.HProcess;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+import org.apache.ode.dao.hib.bpel.hobj.HScope;
+import org.apache.ode.dao.hib.bpel.hobj.HVariableProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HXmlData;
+import org.hibernate.Criteria;
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.LockMode;
+import org.hibernate.Query;
+import org.hibernate.criterion.Expression;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
+
+import javax.xml.namespace.QName;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Hibernate-based {@link ProcessDAO} implementation.
+ */
+public class ProcessDaoImpl extends HibernateDao implements ProcessDAO, DeferredProcessInstanceCleanable {
+ private static final Log __log = LogFactory.getLog(ProcessDaoImpl.class);
+
+ private static final String QRY_CORRELATOR = "where this.correlatorId = ?";
+
+ private HProcess _process;
+
+ public ProcessDaoImpl(SessionManager sm, HProcess process) {
+ super(sm,process);
+ entering("ProcessDaoImpl.ProcessDaoImpl");
+ _process = process;
+ }
+
+ public QName getProcessId() {
+ return QName.valueOf(_process.getProcessId());
+ }
+
+ public ProcessInstanceDAO getInstance(Long iid) {
+ entering("ProcessDaoImpl.getInstance");
+ ProcessInstanceDAO instance = BpelDAOConnectionImpl._getInstance(_sm, getSession(), iid);
+ if (instance == null || !instance.getProcess().getProcessId().equals(getProcessId()))
+ return null;
+ return instance;
+ }
+
+ @SuppressWarnings("unchecked")
+ public CorrelatorDAO getCorrelator(String corrId) {
+ entering("ProcessDaoImpl.getCorrelator");
+ Iterator results;
+ Query q = getSession().createFilter(_process.getCorrelators(),
+ QRY_CORRELATOR);
+ results = q.setString(0, corrId).iterate();
+
+ if(!results.hasNext()){
+ String msg = "no such correlator: corrId = " + corrId;
+ throw new IllegalArgumentException(msg);
+ }
+ try {
+ return new CorrelatorDaoImpl(_sm, (HCorrelator)results.next());
+ } finally {
+ Hibernate.close(results);
+ }
+ }
+
+ public void removeRoutes(String routeId, ProcessInstanceDAO target) {
+ entering("ProcessDaoImpl.removeRoutes");
+ for (HCorrelator hCorrelator : _process.getCorrelators()) {
+ new CorrelatorDaoImpl(_sm, hCorrelator).removeRoutes(routeId, target);
+ }
+ }
+
+ public ProcessInstanceDAO createInstance(CorrelatorDAO correlator) {
+ entering("ProcessDaoImpl.createInstance");
+ HProcessInstance instance = new HProcessInstance();
+ if (correlator != null)
+ instance.setInstantiatingCorrelator((HCorrelator)((CorrelatorDaoImpl)correlator).getHibernateObj());
+ instance.setProcess(_process);
+ instance.setCreated(new Date());
+ getSession().save(instance);
+// _process.addInstance(instance);
+
+ return new ProcessInstanceDaoImpl(_sm,instance);
+ }
+
+ public Collection<ProcessInstanceDAO> findInstance(CorrelationKey key) {
+ return findInstance(key, true);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessDAO#findInstance(CorrelationKey)
+ */
+ @SuppressWarnings("unchecked")
+ public Collection<ProcessInstanceDAO> findInstance(CorrelationKey ckeyValue, boolean wait) {
+ try {
+ entering("ProcessDaoImpl.findInstance");
+ Criteria correlationSet = getSession().createCriteria(HCorrelationSet.class);
+ Criteria instance = correlationSet.createCriteria("scope").createCriteria("instance");
+ instance.addOrder(Order.desc("created"));
+ Criteria process = instance.createCriteria("process");
+ process.add(Restrictions.eq("id", _process.getId()));
+ correlationSet.add(Expression.eq("value", ckeyValue.toCanonicalString()));
+ // TODO: compare against the correlation set in question
+ // correlationSet.add(Expression.eq("name", ckeyValue.getCSetId()));
+ correlationSet.setLockMode(wait ? LockMode.UPGRADE : LockMode.UPGRADE_NOWAIT);
+ List<HCorrelationSet> sets = correlationSet.list();
+ Collection<ProcessInstanceDAO> result = new ArrayList<ProcessInstanceDAO>();
+ for (HCorrelationSet set : sets){
+ result.add(new ProcessInstanceDaoImpl(_sm, set.getScope().getInstance()));
+ }
+ return result;
+ } catch (HibernateException he) {
+ return Collections.EMPTY_LIST;
+ }
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessDAO#instanceCompleted(ProcessInstanceDAO)
+ */
+ public void instanceCompleted(ProcessInstanceDAO instance) {
+ // nothing to do here (yet?)
+ }
+
+ @SuppressWarnings("unchecked")
+ public void deleteProcessAndRoutes() {
+ entering("ProcessDaoImpl.delete");
+
+ // delete routes
+ deleteByIds(HCorrelatorSelector.class, getSession().getNamedQuery(HCorrelatorSelector.SELECT_MESSAGE_ROUTE_IDS_BY_PROCESS).setParameter("process", _process).list());
+
+ // delete process dao
+ deleteByIds(HCorrelator.class, getSession().getNamedQuery(HCorrelator.SELECT_CORRELATOR_IDS_BY_PROCESS).setParameter("process", _process).list());
+ getSession().delete(_process); // this deletes HCorrelator -> HCorrelatorSelector
+
+ // after this delete, we have a use case that creates the process with the same procid.
+ // for hibernate to work without the database deferred constraint check, let's just flush the session.
+ getSession().flush();
+ }
+
+ @SuppressWarnings("unchecked")
+ public int deleteInstances(int transactionSize) {
+ entering("ProcessDaoImpl.delete");
+
+ if( transactionSize < 1 ) {
+ if(__log.isWarnEnabled()) __log.warn("A zero or negative value was given for the transaction size of process dao deletion; overriding to '1'. Not using bulk deletion of rows may result in performance degradation.");
+ transactionSize = 1;
+ }
+
+ Collection<HProcessInstance> instances = getSession().getNamedQuery(HProcessInstance.SELECT_INSTANCES_BY_PROCESS).setParameter("process", _process).setMaxResults(transactionSize).list();
+ if( !instances.isEmpty() ) {
+ deleteEvents(instances);
+ deleteCorrelations(instances);
+ deleteMessages(instances);
+ deleteVariables(instances);
+ deleteProcessInstances(instances);
+ }
+
+ return instances.size();
+ }
+
+ public int deleteInstances(Collection<HProcessInstance> instances, Set<CLEANUP_CATEGORY> categories) {
+ entering("ProcessDaoImpl.deleteInstances");
+
+ if( !instances.isEmpty() ) {
+ if( categories.contains(CLEANUP_CATEGORY.EVENTS)) {
+ deleteEvents(instances);
+ }
+ if( categories.contains(CLEANUP_CATEGORY.CORRELATIONS)) {
+ deleteCorrelations(instances);
+ }
+ if( categories.contains(CLEANUP_CATEGORY.MESSAGES)) {
+ deleteMessages(instances);
+ }
+ if( categories.contains(CLEANUP_CATEGORY.VARIABLES)) {
+ deleteVariables(instances);
+ }
+ if( categories.contains(CLEANUP_CATEGORY.INSTANCE)) {
+ deleteProcessInstances(instances);
+ }
+ }
+
+ return instances.size();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteProcessInstances(Collection<HProcessInstance> instances) {
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_ACTIVITY_RECOVERY_LDATA_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HActivityRecovery.class, getSession().getNamedQuery(HActivityRecovery.SELECT_ACTIVITY_RECOVERY_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_FAULT_LDATA_IDS_BY_INSTANCE_IDS).setParameterList("instanceIds", HObject.toIdArray(instances)).list());
+ deleteByIds(HFaultData.class, getSession().getNamedQuery(HFaultData.SELECT_FAULT_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_JACOB_LDATA_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ List<Long> instanceIds = new ArrayList<Long>();
+ for( HProcessInstance instance : instances ) {
+ instanceIds.add(instance.getId());
+ }
+ deleteByIds(HProcessInstance.class, instanceIds);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteVariables(Collection<HProcessInstance> instances) {
+ deleteByIds(HVariableProperty.class, getSession().getNamedQuery(HVariableProperty.SELECT_VARIABLE_PROPERTY_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_XMLDATA_LDATA_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HXmlData.class, getSession().getNamedQuery(HXmlData.SELECT_XMLDATA_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_PARTNER_LINK_LDATA_IDS_BY_INSTANCES_1).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_PARTNER_LINK_LDATA_IDS_BY_INSTANCES_2).setParameterList("instances", instances).list());
+ deleteByIds(HPartnerLink.class, getSession().getNamedQuery(HPartnerLink.SELECT_PARTNER_LINK_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HScope.class, getSession().getNamedQuery(HScope.SELECT_SCOPE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteMessages(Collection<HProcessInstance> instances) {
+ deleteByIds(HActivityRecovery.class, getSession().getNamedQuery(HCorrelatorMessage.SELECT_CORMESSAGE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_MESSAGE_LDATA_IDS_BY_INSTANCES_1).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_MESSAGE_LDATA_IDS_BY_INSTANCES_2).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_MESSAGE_LDATA_IDS_BY_INSTANCES_3).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_MESSAGE_LDATA_IDS_BY_INSTANCES_4).setParameterList("instances", instances).list());
+ deleteByIds(HMessage.class, getSession().getNamedQuery(HMessage.SELECT_MESSAGE_IDS_BY_INSTANCES_1).setParameterList("instances", instances).list());
+ deleteByIds(HMessage.class, getSession().getNamedQuery(HMessage.SELECT_MESSAGE_IDS_BY_INSTANCES_2).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_MEX_LDATA_IDS_BY_INSTANCES_1).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_MEX_LDATA_IDS_BY_INSTANCES_2).setParameterList("instances", instances).list());
+ deleteByIds(HMessageExchange.class, getSession().getNamedQuery(HMessageExchange.SELECT_MEX_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ List<Long> mex = getSession().getNamedQuery(HMessageExchange.SELECT_MEX_IDS_BY_INSTANCES).setParameterList("instances", instances).list();
+ deleteByColumn(HMessageExchangeProperty.class, "mex.id", mex);
+ deleteByIds(HMessageExchange.class, mex);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteCorrelations(Collection<HProcessInstance> instances) {
+ deleteByIds(HCorrelationProperty.class, getSession().getNamedQuery(HCorrelationProperty.SELECT_CORPROP_IDS_BY_INSTANCES).setParameterList ("instances", instances).list());
+ deleteByIds(HCorrelationSet.class, getSession().getNamedQuery(HCorrelationSet.SELECT_CORSET_IDS_BY_INSTANCES).setParameterList ("instances", instances).list());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteEvents(Collection<HProcessInstance> instances) {
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_EVENT_LDATA_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HBpelEvent.class, getSession().getNamedQuery(HBpelEvent.SELECT_EVENT_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ public QName getType() {
+ return new QName(_process.getTypeNamespace(), _process.getTypeName());
+ }
+
+ public long getVersion() {
+ return _process.getVersion();
+ }
+
+ public CorrelatorDAO addCorrelator(String corrid) {
+ entering("ProcessDaoImpl.addCorrelator");
+ HCorrelator correlator = new HCorrelator();
+ correlator.setCorrelatorId(corrid);
+ correlator.setProcess(_process);
+ correlator.setCreated(new Date());
+// _process.addCorrelator(correlator);
+ getSession().save(correlator);
+ getSession().saveOrUpdate(_process);
+ return new CorrelatorDaoImpl(_sm, correlator);
+ }
+
+ public int getNumInstances() {
+ entering("ProcessDaoImpl.getNumInstances");
+ // this should be efficient if the relation is tagged as extra-lazy.
+ // If the collection is not initialized yet, Hibernate will do a count(*) and the whole collection will not be fetched.
+ return _process.getInstances().size();
+ }
+
+ public String getGuid() {
+ return _process.getGuid();
+ }
+
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessInstanceDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessInstanceDaoImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessInstanceDaoImpl.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessInstanceDaoImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,568 @@
+/*
+ * 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.hib.bpel;
+
+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.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.*;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.QNameUtils;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.UnaryFunction;
+import org.hibernate.Criteria;
+import org.hibernate.Hibernate;
+import org.hibernate.Query;
+import org.hibernate.criterion.Projections;
+import org.hibernate.criterion.Restrictions;
+import org.w3c.dom.Element;
+
+import javax.xml.namespace.QName;
+import java.util.*;
+
+/**
+ * Hibernate-based {@link ProcessInstanceDAO} implementation.
+ */
+public class ProcessInstanceDaoImpl extends HibernateDao implements ProcessInstanceDAO {
+ private static final Log __log = LogFactory.getLog(ProcessInstanceDaoImpl.class);
+
+ /** Query for removing selectors. */
+ private static final String QRY_DELSELECTORS = "delete from " + HCorrelatorSelector.class.getName() + " where instance = ?";
+
+ private static final String QRY_VARIABLES = "from " + HXmlData.class.getName()
+ + " as x where x.name = ? and x.scope.scopeModelId = ? and x.scope.instance.id = ?";
+
+ private static final String QRY_RECOVERIES = "from " + HActivityRecovery.class.getName() + " AS x WHERE x.instance.id = ?";
+
+ private HProcessInstance _instance;
+
+ private ScopeDAO _root;
+
+ public ProcessInstanceDaoImpl(SessionManager sm, HProcessInstance instance) {
+ super(sm, instance);
+ entering("ProcessInstanceDaoImpl.ProcessInstanceDaoImpl");
+ _instance = instance;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getCreateTime()
+ */
+ public Date getCreateTime() {
+ return _instance.getCreated();
+ }
+
+ public void setFault(FaultDAO fault) {
+ entering("ProcessInstanceDaoImpl.setFault");
+ _instance.setFault(((FaultDAOImpl) fault)._self);
+ getSession().update(_instance);
+
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#setFault(javax.xml.namespace.QName, String, int, int, org.w3c.dom.Element)
+ */
+ public void setFault(QName name, String explanation, int lineNo, int activityId, Element faultData) {
+ entering("ProcessInstanceDaoImpl.setFault");
+ if (_instance.getFault() != null)
+ getSession().delete(_instance.getFault());
+
+ HFaultData fault = new HFaultData();
+ fault.setName(QNameUtils.fromQName(name));
+ fault.setExplanation(explanation);
+ fault.setLineNo(lineNo);
+ fault.setActivityId(activityId);
+ if (faultData != null) {
+ HLargeData ld = new HLargeData(DOMUtils.domToString(faultData));
+ fault.setData(ld);
+ getSession().save(ld);
+ }
+
+ _instance.setFault(fault);
+ getSession().save(fault);
+ getSession().update(_instance);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getFault()
+ */
+ public FaultDAO getFault() {
+ entering("ProcessInstanceDaoImpl.getFault");
+ if (_instance.getFault() == null) return null;
+ else return new FaultDAOImpl(_sm, _instance.getFault());
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getExecutionState()
+ */
+ public byte[] getExecutionState() {
+ entering("ProcessInstanceDaoImpl.getExecutionState");
+ if (_instance.getJacobState() == null) return null;
+ return _instance.getJacobState().getBinary();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#setExecutionState(byte[])
+ */
+ public void setExecutionState(byte[] bytes) {
+ entering("ProcessInstanceDaoImpl.setExecutionState");
+ if (_instance.getJacobState() != null)
+ getSession().delete(_instance.getJacobState());
+ if (bytes.length > 0) {
+ HLargeData ld = new HLargeData(bytes);
+ _instance.setJacobState(ld);
+ getSession().save(ld);
+ }
+ getSession().update(_instance);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getProcess()
+ */
+ public ProcessDAO getProcess() {
+ entering("ProcessInstanceDaoImpl.getProcess");
+ return new ProcessDaoImpl(_sm, _instance.getProcess());
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getRootScope()
+ */
+ public ScopeDAO getRootScope() {
+ entering("ProcessInstanceDaoImpl.getRootScope");
+ if (_root != null)
+ return _root;
+ Query rootQry = getSession().createFilter(_instance.getScopes(), "where this.parentScope is null");
+ HScope hroot = (HScope) rootQry.uniqueResult();
+ if (hroot == null)
+ return null;
+ return _root = new ScopeDaoImpl(_sm, hroot);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#setState(short)
+ */
+ public void setState(short state) {
+ entering("ProcessInstanceDaoImpl.setState");
+ _instance.setPreviousState(_instance.getState());
+ _instance.setState(state);
+ if(state==ProcessState.STATE_TERMINATED) {
+ clearSelectors();
+ }
+ getSession().update(_instance);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getState()
+ */
+ public short getState() {
+ return _instance.getState();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getPreviousState()
+ */
+ public short getPreviousState() {
+ return _instance.getPreviousState();
+ }
+
+
+ public ScopeDAO createScope(ScopeDAO parentScope, String name, int scopeModelId) {
+ entering("ProcessInstanceDaoImpl.createScope");
+ HScope scope = new HScope();
+ scope.setParentScope(parentScope != null
+ ? (HScope)((ScopeDaoImpl)parentScope).getHibernateObj()
+ : null);
+ scope.setName(name);
+ scope.setScopeModelId(scopeModelId);
+ scope.setState(ScopeStateEnum.ACTIVE.toString());
+ scope.setInstance(_instance);
+ scope.setCreated(new Date());
+// _instance.addScope(scope);
+ getSession().save(scope);
+
+ return new ScopeDaoImpl(_sm, scope);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getInstanceId()
+ */
+ public Long getInstanceId() {
+ return _instance.getId();
+ }
+
+ public ScopeDAO getScope(Long scopeInstanceId) {
+ entering("ProcessInstanceDaoImpl.getScope");
+ Long id = Long.valueOf(scopeInstanceId);
+ HScope scope = (HScope)getSession().get(HScope.class, id);
+ return scope != null
+ ? new ScopeDaoImpl(_sm, scope)
+ : null;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getScopes(java.lang.String)
+ */
+ @SuppressWarnings("unchecked")
+ public Collection<ScopeDAO> getScopes(String scopeName) {
+ entering("ProcessInstanceDaoImpl.getScopes");
+ Collection<HScope> hscopes;
+ if (scopeName != null) {
+ Query filter = _sm.getSession().createFilter(_instance.getScopes(), "where this.name=?");
+ filter.setString(0, scopeName);
+ hscopes = filter.list();
+ } else
+ hscopes = _instance.getScopes();
+ ArrayList<ScopeDAO> ret = new ArrayList<ScopeDAO>();
+ CollectionsX.transform(ret, hscopes, new UnaryFunction<HScope, ScopeDAO>() {
+ public ScopeDAO apply(HScope x) {
+ return new ScopeDaoImpl(_sm, x);
+ }
+ });
+ return ret;
+ }
+
+ public Collection<ScopeDAO> getScopes() {
+ return getScopes(null);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getInstantiatingCorrelator()
+ */
+ public CorrelatorDAO getInstantiatingCorrelator() {
+ entering("ProcessInstanceDaoImpl.getInstantiatingCorrelator");
+ return new CorrelatorDaoImpl(_sm, _instance.getInstantiatingCorrelator());
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getLastActiveTime()
+ */
+ public Date getLastActiveTime() {
+ return _instance.getLastActiveTime();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#setLastActiveTime(java.util.Date)
+ */
+ public void setLastActiveTime(Date dt) {
+ entering("ProcessInstanceDaoImpl.setLastActiveTime");
+ _instance.setLastActiveTime(dt);
+ }
+
+ public Set<CorrelationSetDAO> getCorrelationSets() {
+ entering("ProcessInstanceDaoImpl.getCorrelationSets");
+ Set<CorrelationSetDAO> results = new HashSet<CorrelationSetDAO>();
+
+ for (HCorrelationSet hCorrelationSet : _instance.getCorrelationSets()) {
+ results.add(new CorrelationSetDaoImpl(_sm, hCorrelationSet));
+ }
+
+ return results;
+ }
+
+ public CorrelationSetDAO getCorrelationSet(String name) {
+ entering("ProcessInstanceDaoImpl.getCorrelationSet");
+ for (HCorrelationSet hCorrelationSet : _instance.getCorrelationSets()) {
+ if (hCorrelationSet.getName().equals(name))
+ return new CorrelationSetDaoImpl(_sm, hCorrelationSet);
+ }
+ return null;
+ }
+
+ /**
+ * TODO this is never used, except by test cases - should be removed
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#getVariables(java.lang.String, int)
+ */
+ public XmlDataDAO[] getVariables(String variableName, int scopeModelId) {
+ entering("ProcessInstanceDaoImpl.getVariables");
+ List<XmlDataDAO> results = new ArrayList<XmlDataDAO>();
+
+ Iterator iter;
+ Query qry = getSession().createQuery(QRY_VARIABLES);
+ qry.setString(0, variableName);
+ qry.setInteger(1, scopeModelId);
+ qry.setLong(2, _instance.getId());
+ iter = qry.iterate();
+
+ while (iter.hasNext()) {
+ results.add(new XmlDataDaoImpl(_sm, (HXmlData) iter.next()));
+ }
+ Hibernate.close(iter);
+
+ return results.toArray(new XmlDataDAO[results.size()]);
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ProcessInstanceDAO#finishCompletion()
+ */
+ public void finishCompletion() {
+ entering("ProcessInstanceDaoImpl.finishCompletion");
+ // make sure we have completed.
+ assert (ProcessState.isFinished(this.getState()));
+ // let our process know that we've done our work.
+ this.getProcess().instanceCompleted(this);
+ }
+
+ public boolean delete(Set<CLEANUP_CATEGORY> cleanupCategories) {
+ entering("ProcessInstanceDaoImpl.delete");
+ boolean instanceDeleted = false;
+
+ if(__log.isDebugEnabled()) __log.debug("Cleaning up instance data with categories = " + cleanupCategories);
+
+ if( _instance.getJacobState() != null ) {
+ getSession().delete(_instance.getJacobState());
+ _instance.setJacobState(null);
+ }
+
+ HProcessInstance[] instances = new HProcessInstance[] {_instance};
+
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.EVENTS) ) {
+ deleteEvents(instances);
+ }
+
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.CORRELATIONS) ) {
+ deleteCorrelations(instances);
+ }
+
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.MESSAGES) ) {
+ deleteMessages(instances);
+ }
+
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.VARIABLES) ) {
+ deleteVariables(instances);
+ }
+
+ if( cleanupCategories.contains(CLEANUP_CATEGORY.INSTANCE) ) {
+ deleteInstances(instances);
+ instanceDeleted = true;
+ }
+
+ getSession().flush();
+
+ if(__log.isDebugEnabled()) __log.debug("Instance data cleaned up and flushed.");
+
+ return instanceDeleted;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteInstances(HProcessInstance[] instances) {
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_FAULT_LDATA_IDS_BY_INSTANCE_IDS).setParameterList("instanceIds", HObject.toIdArray(instances)).list());
+ deleteByIds(HFaultData.class, getSession().getNamedQuery(HFaultData.SELECT_FAULT_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ getSession().delete(_instance); // this deletes JcobState, HActivityRecovery -> ActivityRecovery-LData
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteVariables(HProcessInstance[] instances) {
+ deleteByIds(HCorrelationProperty.class, getSession().getNamedQuery(HCorrelationProperty.SELECT_CORPROP_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HCorrelationSet.class, getSession().getNamedQuery(HCorrelationSet.SELECT_CORSET_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ deleteByIds(HVariableProperty.class, getSession().getNamedQuery(HVariableProperty.SELECT_VARIABLE_PROPERTY_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_XMLDATA_LDATA_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HXmlData.class, getSession().getNamedQuery(HXmlData.SELECT_XMLDATA_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_PARTNER_LINK_LDATA_IDS_BY_INSTANCES_1).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_PARTNER_LINK_LDATA_IDS_BY_INSTANCES_2).setParameterList("instances", instances).list());
+ deleteByIds(HPartnerLink.class, getSession().getNamedQuery(HPartnerLink.SELECT_PARTNER_LINK_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ deleteByIds(HScope.class, getSession().getNamedQuery(HScope.SELECT_SCOPE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteMessages(HProcessInstance[] instances) {
+ // there are chances that some unmatched messages are still there
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_MESSAGE_LDATA_IDS_BY_INSTANCES_1).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_MESSAGE_LDATA_IDS_BY_INSTANCES_2).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_MESSAGE_LDATA_IDS_BY_INSTANCES_3).setParameterList("instances", instances).list());
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_MESSAGE_LDATA_IDS_BY_INSTANCES_4).setParameterList("instances", instances).list());
+
+ deleteByIds(HMessage.class, getSession().getNamedQuery(HMessage.SELECT_MESSAGE_IDS_BY_INSTANCES_1).setParameterList("instances", instances).list());
+ deleteByIds(HMessage.class, getSession().getNamedQuery(HMessage.SELECT_MESSAGE_IDS_BY_INSTANCES_2).setParameterList("instances", instances).list());
+
+ deleteByIds(HCorrelatorMessage.class, getSession().getNamedQuery(HCorrelatorMessage.SELECT_CORMESSAGE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HCorrelatorSelector.class, getSession().getNamedQuery(HCorrelatorSelector.SELECT_MESSAGE_ROUTE_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+
+ List<Long> mex = getSession().getNamedQuery(HMessageExchange.SELECT_MEX_IDS_BY_INSTANCES).setParameterList("instances", instances).list();
+ deleteByColumn(HMessageExchangeProperty.class, "mex.id", mex);
+ deleteByIds(HMessageExchange.class, mex);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteCorrelations(HProcessInstance[] instances) {
+ deleteByIds(HCorrelationProperty.class, getSession().getNamedQuery(HCorrelationProperty.SELECT_CORPROP_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HCorrelationSet.class, getSession().getNamedQuery(HCorrelationSet.SELECT_CORSET_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void deleteEvents(HProcessInstance[] instances) {
+ deleteByIds(HLargeData.class, getSession().getNamedQuery(HLargeData.SELECT_EVENT_LDATA_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ deleteByIds(HBpelEvent.class, getSession().getNamedQuery(HBpelEvent.SELECT_EVENT_IDS_BY_INSTANCES).setParameterList("instances", instances).list());
+ }
+
+ public void insertBpelEvent(ProcessInstanceEvent event) {
+ entering("ProcessInstanceDaoImpl.insertBpelEvent");
+ // Defer to the BpelDAOConnectionImpl
+ BpelDAOConnectionImpl._insertBpelEvent(getSession(), event, this.getProcess(), this);
+ }
+
+ public EventsFirstLastCountTuple getEventsFirstLastCount() {
+ entering("ProcessInstanceDaoImpl.getEventsFirstLastCount");
+ // Using a criteria, find the min,max, and count of event tstamps.
+ Criteria c = getSession().createCriteria(HBpelEvent.class);
+ c.add(Restrictions.eq("instance",_instance));
+ c.setProjection(Projections.projectionList().add(Projections.min("tstamp"))
+ .add(Projections.max("tstamp"))
+ .add(Projections.count("tstamp")));
+
+ Object[] ret = (Object[]) c.uniqueResult();
+ EventsFirstLastCountTuple flc = new EventsFirstLastCountTuple();
+ flc.first = (Date) ret[0];
+ flc.last = (Date) ret[1];
+ flc.count = (Integer)ret[2];
+ return flc;
+ }
+
+ public Collection<MessageExchangeDAO> getMessageExchanges() {
+ Collection<MessageExchangeDAO> exchanges = new ArrayList<MessageExchangeDAO>();
+
+ for( HMessageExchange exchange : _instance.getMessageExchanges() ) {
+ exchanges.add(new MessageExchangeDaoImpl(_sm, exchange));
+ }
+
+ return exchanges;
+ }
+
+ public long genMonotonic() {
+ entering("ProcessInstanceDaoImpl.genMonotonic");
+ long seq = _instance.getSequence()+1;
+ _instance.setSequence(seq);
+ return seq;
+ }
+
+ protected void clearSelectors() {
+ entering("ProcessInstanceDaoImpl.clearSelectors");
+ Query q = getSession().createQuery(QRY_DELSELECTORS);
+ q.setEntity(0, _instance);
+ q.executeUpdate();
+ }
+
+ public int getActivityFailureCount() {
+ return _instance.getActivityFailureCount();
+ }
+
+ public Date getActivityFailureDateTime() {
+ return _instance.getActivityFailureDateTime();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<ActivityRecoveryDAO> getActivityRecoveries() {
+ entering("ProcessInstanceDaoImpl.getActivityRecoveries");
+ List<ActivityRecoveryDAO> results = new ArrayList<ActivityRecoveryDAO>();
+ Query qry = getSession().createQuery(QRY_RECOVERIES);
+ qry.setLong(0, _instance.getId());
+ Iterator iter = qry.iterate();
+ while (iter.hasNext())
+ results.add(new ActivityRecoveryDaoImpl(_sm, (HActivityRecovery) iter.next()));
+ Hibernate.close(iter);
+ return results;
+ }
+
+ public void createActivityRecovery(String channel, long activityId, String reason,
+ Date dateTime, Element data, String[] actions, int retries) {
+ entering("ProcessInstanceDaoImpl.createActivityRecovery");
+ HActivityRecovery recovery = new HActivityRecovery();
+ recovery.setInstance(_instance);
+ recovery.setChannel(channel);
+ recovery.setActivityId(activityId);
+ recovery.setReason(reason);
+ recovery.setDateTime(dateTime);
+ recovery.setRetries(retries);
+ if (data != null) {
+ HLargeData ld = new HLargeData(DOMUtils.domToString(data));
+ recovery.setDetails(ld);
+ getSession().save(ld);
+ }
+ String list = actions[0];
+ for (int i = 1; i < actions.length; ++i)
+ list += " " + actions[i];
+ recovery.setActions(list);
+// _instance.addRecovery(recovery);
+ getSession().save(recovery);
+ _instance.setActivityFailureDateTime(dateTime);
+ _instance.setActivityFailureCount(_instance.getActivityFailureCount() + 1);
+ getSession().update(_instance);
+ }
+
+ /**
+ * Delete previously registered activity recovery.
+ */
+ public void deleteActivityRecovery(String channel) {
+ entering("ProcessInstanceDaoImpl.deleteActivityRecovery");
+ for (HActivityRecovery recovery : _instance.getActivityRecoveries()) {
+ if (recovery.getChannel().equals(channel)) {
+ getSession().delete(recovery);
+ _instance.setActivityFailureCount(_instance.getActivityFailureCount() - 1);
+ getSession().update(_instance);
+ return;
+ }
+ }
+ }
+
+ public BpelDAOConnection getConnection() {
+ entering("ProcessInstanceDaoImpl.getConnection");
+ return new BpelDAOConnectionImpl(_sm);
+ }
+
+ public int getExecutionStateCounter() {
+ return _instance.getExecutionStateCounter();
+ }
+
+ public void setExecutionStateCounter(int stateCounter) {
+ _instance.setExecutionStateCounter(stateCounter);
+ }
+
+ public String getInstantiatingUrl() {
+ return _instance.getInstantiatingUrl();
+ }
+
+ public void setInstantiatingUrl(String url) {
+ _instance.setInstantiatingUrl(url);
+ }
+
+ public void createResourceRoute(String url, String method, String pickResponseChannel, int selectorIdx) {
+ HResourceRoute resRoute = new HResourceRoute();
+ resRoute.setUrl(url);
+ resRoute.setMethod(method);
+ resRoute.setChannelId(pickResponseChannel);
+ resRoute.setIndex(selectorIdx);
+ resRoute.setInstance(_instance);
+ getSession().save(resRoute);
+ }
+
+ public Set<String> getAllResourceRoutes() {
+ Set<HResourceRoute> rr = _instance.getResourceRoutes();
+ HashSet<String> rs = new HashSet<String>();
+ for (HResourceRoute hResourceRoute : rr) {
+ rs.add(hResourceRoute.getUrl() + "~" + hResourceRoute.getMethod());
+ }
+ return rs;
+ }
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessManagementDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessManagementDaoImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessManagementDaoImpl.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ProcessManagementDaoImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,49 @@
+package org.apache.ode.dao.hib.bpel;
+
+import java.util.Collection;
+import java.util.List;
+
+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;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HProcessInstance;
+import org.hibernate.Query;
+import org.hibernate.transform.ResultTransformer;
+
+public class ProcessManagementDaoImpl extends HibernateDao implements ProcessManagementDAO {
+ protected ProcessManagementDaoImpl(SessionManager sessionManager) {
+ super(sessionManager, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object[] findFailedCountAndLastFailedDateForProcessId(BpelDAOConnection conn, String status, String processId) {
+ Object[] results = new Object[] {0, null};
+
+ Query query = getSession().getNamedQuery(HProcessInstance.COUNT_FAILED_INSTANCES_BY_PROCESS_IDS_AND_STATES);
+ query.setParameterList("states", new InstanceFilter("status=" + status).convertFilterState());
+ query.setParameterList("processIds", new String[] {processId});
+ query.setResultTransformer(new ResultTransformer() {
+ private static final long serialVersionUID = 8034301512569916379L;
+
+ public List transformList(List collection) {
+ return collection;
+ }
+ public Object transformTuple(Object[] tuple, String[] aliases) {
+ return tuple;
+ }
+ });
+
+ List result = query.list();
+ if( !result.isEmpty() ) {
+ results = (Object[])result.iterator().next();
+ }
+
+ return results;
+ }
+
+ public void prefetchActivityFailureCounts(Collection<ProcessInstanceDAO> instances) {
+ // do nothing; activity failures counts are already in a column
+ }
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ResourceRouteDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ResourceRouteDaoImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ResourceRouteDaoImpl.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ResourceRouteDaoImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,52 @@
+package org.apache.ode.dao.hib.bpel;
+
+import org.apache.ode.dao.bpel.ResourceRouteDAO;
+import org.apache.ode.dao.bpel.ProcessInstanceDAO;
+import org.apache.ode.dao.hib.bpel.hobj.HResourceRoute;
+import org.apache.ode.dao.hib.SessionManager;
+
+public class ResourceRouteDaoImpl extends HibernateDao implements ResourceRouteDAO {
+
+ HResourceRoute _self;
+
+ public ResourceRouteDaoImpl(SessionManager sessionManager, HResourceRoute hrr) {
+ super(sessionManager, hrr);
+ _self = hrr;
+ }
+
+ public String getUrl() {
+ return _self.getUrl();
+ }
+
+ public void setUrl(String url) {
+ _self.setUrl(url);
+ }
+
+ public String getMethod() {
+ return _self.getMethod();
+ }
+
+ public void setMethod(String method) {
+ _self.setMethod(method);
+ }
+
+ public String getPickResponseChannel() {
+ return _self.getChannelId();
+ }
+
+ public void setPickResponseChannel(String channelId) {
+ _self.setChannelId(channelId);
+ }
+
+ public int getSelectorIdx() {
+ return _self.getIndex();
+ }
+
+ public void setSelectorIdx(int index) {
+ _self.setIndex(index);
+ }
+
+ public ProcessInstanceDAO getInstance() {
+ return new ProcessInstanceDaoImpl(_sm, _self.getInstance());
+ }
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ScopeDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ScopeDaoImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ScopeDaoImpl.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/ScopeDaoImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,261 @@
+/*
+ * 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.hib.bpel;
+
+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 org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HBpelEvent;
+import org.apache.ode.dao.hib.bpel.hobj.HCorrelationSet;
+import org.apache.ode.dao.hib.bpel.hobj.HPartnerLink;
+import org.apache.ode.dao.hib.bpel.hobj.HScope;
+import org.apache.ode.dao.hib.bpel.hobj.HXmlData;
+import org.apache.ode.utils.SerializableUtils;
+import org.apache.ode.utils.stl.CollectionsX;
+import org.apache.ode.utils.stl.UnaryFunction;
+import org.apache.ode.utils.stl.UnaryFunctionEx;
+import org.hibernate.Criteria;
+import org.hibernate.Query;
+import org.hibernate.criterion.Restrictions;
+
+import java.util.*;
+
+/**
+ * Hibernate-based {@link ScopeDAO} implementation.
+ */
+class ScopeDaoImpl extends HibernateDao implements ScopeDAO {
+
+
+ private static final String QRY_VARIABLE = "from " + HXmlData.class.getName() +
+ " as x where x.name = ? and x.scope.id = ?";
+
+ private static final String QRY_CSET = "from " + HCorrelationSet.class.getName() +
+ " as c where c.name = ? and c.scope.id = ?";
+
+ private static final String QRY_SCOPE_EPR = "from " + HPartnerLink.class.getName() +
+ " as e where e.modelId = ? and e.scope = ?";
+
+ private HScope _scope;
+
+ private HashMap<String,XmlDataDAO> _variables = new HashMap<String,XmlDataDAO>();
+
+ public ScopeDaoImpl(SessionManager sm, HScope scope) {
+ super(sm, scope);
+ entering("ScopeDaoImpl.ScopeDaoImpl");
+ _scope = scope;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getCorrelationSet(java.lang.String)
+ */
+ public CorrelationSetDAO getCorrelationSet(String corrSetName) {
+ entering("ScopeDaoImpl.getCorrelationSet");
+ Query qry = getSession().createQuery(QRY_CSET);
+ qry.setString(0,corrSetName);
+ qry.setLong(1,_scope.getId());
+ HCorrelationSet cs;
+ List res = qry.list();
+
+ if(res.size() == 0){
+ // if it doesn't exist, we make it
+ cs = new HCorrelationSet(_scope, corrSetName);
+// _scope.addCorrelationSet(cs);
+ getSession().save(cs);
+ } else {
+ cs = (HCorrelationSet)res.get(0);
+ }
+ return new CorrelationSetDaoImpl(_sm, cs);
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getParentScope()
+ */
+ public ScopeDAO getParentScope() {
+ entering("ScopeDaoImpl.getParentScope");
+ return _scope.getParentScope() != null
+ ? new ScopeDaoImpl(_sm, _scope.getParentScope())
+ : null;
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getProcessInstance()
+ */
+ public ProcessInstanceDAO getProcessInstance() {
+ entering("ScopeDaoImpl.getProcessInstance");
+ return new ProcessInstanceDaoImpl(_sm, _scope.getInstance());
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#setState(org.apache.ode.dao.bpel.ScopeStateEnum)
+ */
+ public void setState(ScopeStateEnum state) {
+ entering("ScopeDaoImpl.setState");
+ _scope.setState(state.toString());
+ getSession().update(_scope);
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getState()
+ */
+ public ScopeStateEnum getState() {
+ return new ScopeStateEnum(_scope.getState());
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getName()
+ */
+ public String getName() {
+ return _scope.getName();
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getVariable(java.lang.String)
+ */
+ public XmlDataDAO getVariable(String varName) {
+ entering("ScopeDaoImpl.getVariable");
+ XmlDataDAO cached = _variables.get(varName);
+ if (cached != null) return _variables.get(varName);
+
+ HXmlData data = null;
+ for (HXmlData e : _scope.getVariables()) {
+ if (e.getName().equals(varName) && e.getScope().getId().equals(_scope.getId())) {
+ data = e;
+ }
+ }
+ if (data == null) {
+ data = new HXmlData();
+ data.setName(varName);
+ data.setScope(_scope);
+ _scope.getVariables().add(data);
+ }
+
+ XmlDataDaoImpl varDao = new XmlDataDaoImpl(_sm, data);
+ _variables.put(varName, varDao);
+ return varDao;
+ }
+
+ public PartnerLinkDAO createPartnerLink(int modelId, String pLinkName, String myRole, String partnerRole) {
+ entering("ScopeDaoImpl.createPartnerLink");
+ HPartnerLink epr = new HPartnerLink();
+ epr.setModelId(modelId);
+ epr.setLinkName(pLinkName);
+ epr.setMyRole(myRole);
+ epr.setPartnerRole(partnerRole);
+ epr.setScope(_scope);
+// _scope.addPartnerLink(epr);
+ getSession().save(epr);
+ PartnerLinkDAOImpl eprDao = new PartnerLinkDAOImpl(_sm, epr);
+ return eprDao;
+ }
+
+ public PartnerLinkDAO getPartnerLink(int plinkId) {
+ entering("ScopeDaoImpl.getPartnerLink");
+ Query qry = getSession().createQuery(QRY_SCOPE_EPR);
+ qry.setInteger(0,plinkId);
+ qry.setEntity(1,_scope);
+ HPartnerLink hpl = (HPartnerLink) qry.uniqueResult();
+ if (hpl == null)
+ return null;
+ return new PartnerLinkDAOImpl(_sm, hpl);
+ }
+
+ public Collection<PartnerLinkDAO> getPartnerLinks() {
+ entering("ScopeDaoImpl.getPartnerLinks");
+ ArrayList<PartnerLinkDAO> plinks = new ArrayList<PartnerLinkDAO>();
+ for (HPartnerLink hPartnerLink : _scope.getPartnerLinks()) {
+ plinks.add(new PartnerLinkDAOImpl(_sm, hPartnerLink));
+ }
+ return plinks;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getScopeInstanceId()
+ */
+ public Long getScopeInstanceId() {
+ return _scope.getId();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.ScopeDAO#getModelId()
+ */
+ public int getModelId() {
+ return _scope.getScopeModelId();
+ }
+
+ public Set<CorrelationSetDAO> getCorrelationSets() {
+ entering("ScopeDaoImpl.getCorrelationSets");
+ Set<CorrelationSetDAO> results = new HashSet<CorrelationSetDAO>();
+ for (HCorrelationSet hCorrelationSet : _scope.getCorrelationSets()) {
+ results.add(new CorrelationSetDaoImpl(_sm, hCorrelationSet));
+ }
+ return results;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public Collection<ScopeDAO> getChildScopes() {
+ entering("ScopeDaoImpl.getChildScopes");
+ Query q = getSession().createQuery("from " + HScope.class.getName() + " as x where x.parentScope=?");
+ q.setEntity(0, _scope);
+ Collection<HScope> hscopes = q.list();
+ return CollectionsX.transform(new LinkedList<ScopeDAO>(), hscopes, new UnaryFunction<HScope,ScopeDAO>() {
+ public ScopeDAO apply(HScope x) {
+ return new ScopeDaoImpl(_sm,x);
+ }
+
+ });
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<XmlDataDAO> getVariables() {
+ entering("ScopeDaoImpl.getVariables");
+ Query q = getSession().createFilter(_scope.getVariables(), "where this.scope=?");
+ q.setEntity(0, _scope);
+ return CollectionsX.transform(new LinkedList<XmlDataDAO>(), (Collection<HXmlData>)q.list(), new UnaryFunction<HXmlData,XmlDataDAO>() {
+ public XmlDataDAO apply(HXmlData x) {
+ return new XmlDataDaoImpl(_sm,x);
+ }
+
+ });
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<BpelEvent> listEvents() {
+ entering("ScopeDaoImpl.listEvents");
+// CriteriaBuilder cb = new CriteriaBuilder();
+ Criteria crit = _sm.getSession().createCriteria(HBpelEvent.class);
+// if (efilter != null)
+// cb.buildCriteria(crit, efilter);
+ crit.add(Restrictions.eq("scopeId",_scope.getId()));
+
+ List<HBpelEvent> hevents = crit.list();
+ List<BpelEvent> ret = new ArrayList<BpelEvent>(hevents.size());
+ try {
+ CollectionsX.transformEx(ret,hevents,new UnaryFunctionEx<HBpelEvent,BpelEvent>() {
+ public BpelEvent apply(HBpelEvent x) throws Exception{
+ return (BpelEvent) SerializableUtils.toObject(x.getData().getBinary(),BpelEvent.class.getClassLoader());
+ }
+
+ });
+ }catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ return ret;
+ }
+
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/XmlDataDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/XmlDataDaoImpl.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/XmlDataDaoImpl.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/XmlDataDaoImpl.java Sun May 2 17:02:51 2010
@@ -0,0 +1,183 @@
+/*
+ * 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.hib.bpel;
+
+import org.apache.ode.dao.bpel.ScopeDAO;
+import org.apache.ode.dao.bpel.XmlDataDAO;
+import org.apache.ode.dao.hib.SessionManager;
+import org.apache.ode.dao.hib.bpel.hobj.HLargeData;
+import org.apache.ode.dao.hib.bpel.hobj.HVariableProperty;
+import org.apache.ode.dao.hib.bpel.hobj.HXmlData;
+import org.apache.ode.utils.DOMUtils;
+
+import java.util.Iterator;
+
+import org.hibernate.Query;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+/**
+ * Hibernate-based {@link XmlDataDAO} implementation.
+ */
+class XmlDataDaoImpl extends HibernateDao implements XmlDataDAO {
+
+
+ private static final String QUERY_PROPERTY =
+ "from " + HVariableProperty.class.getName() +
+ " as p where p.xmlData.id = ? and p.name = ?";
+
+ private HXmlData _data;
+ private Node _node;
+
+ /**
+ * @param hobj
+ */
+ public XmlDataDaoImpl(SessionManager sm, HXmlData hobj) {
+ super(sm, hobj);
+ entering("XmlDataDaoImpl.XmlDataDaoImpl");
+ _data = hobj;
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#isNull()
+ */
+ public boolean isNull() {
+ entering("XmlDataDaoImpl.isNull");
+ return _data.getData() == null;
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#get()
+ */
+ public Node get() {
+ entering("XmlDataDaoImpl.get");
+ if(_node == null){
+ _node = prepare();
+ }
+ return _node;
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#remove()
+ */
+ public void remove() {
+
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#set(org.w3c.dom.Node)
+ */
+ public void set(Node val) {
+ entering("XmlDataDaoImpl.set");
+ _node = val;
+ _data.setSimpleType(!(val instanceof Element));
+
+ HLargeData ld = _data.getData();
+
+ if (ld == null) {
+ ld = new HLargeData();
+ } else {
+ ld.setBinary(null);
+ }
+
+ if(_data.isSimpleType()) {
+ ld.setBinary(_node.getNodeValue().getBytes());
+ _data.setData(ld);
+ } else {
+ ld.setBinary(DOMUtils.domToString(_node).getBytes());
+ _data.setData(ld);
+ }
+ getSession().saveOrUpdate(ld);
+ getSession().saveOrUpdate(_data);
+ leaving("XmlDataDaoImpl.set");
+ }
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#getProperty(java.lang.String)
+ */
+ public String getProperty(String propertyName) {
+ entering("XmlDataDaoImpl.getProperty");
+ HVariableProperty p = _getProperty(propertyName);
+ return p == null
+ ? null
+ : p.getValue();
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#setProperty(java.lang.String, java.lang.String)
+ */
+ public void setProperty(String pname, String pvalue) {
+ entering("XmlDataDaoImpl.setProperty");
+ HVariableProperty p = _getProperty(pname);
+ if(p == null){
+ p = new HVariableProperty(_data, pname, pvalue);
+ getSession().save(p);
+// _data.addProperty(p);
+ }else{
+ p.setValue(pvalue);
+ getSession().update(p);
+ }
+ }
+
+ /**
+ * @see org.apache.ode.dao.bpel.XmlDataDAO#getScopeDAO()
+ */
+ public ScopeDAO getScopeDAO() {
+ entering("XmlDataDaoImpl.getScopeDAO");
+ return new ScopeDaoImpl(_sm,_data.getScope());
+ }
+
+ private HVariableProperty _getProperty(String propertyName){
+ entering("XmlDataDaoImpl._getProperty");
+ Iterator iter;
+ Query qry = getSession().createQuery(QUERY_PROPERTY);
+ qry.setLong(0, _data.getId());
+ qry.setString(1, propertyName);
+ iter = qry.iterate();
+ return iter.hasNext()
+ ? (HVariableProperty)iter.next()
+ : null;
+ }
+
+ private Node prepare(){
+ if(_data.getData() == null)
+ return null;
+ String data = _data.getData().getText();
+ if(_data.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);
+ return tnode;
+ }else{
+ try{
+ return DOMUtils.stringToDOM(data);
+ }catch(Exception e){
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public String getName() {
+ return _data.getName();
+ }
+
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HActivityRecovery.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HActivityRecovery.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HActivityRecovery.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HActivityRecovery.java Sun May 2 17:02:51 2010
@@ -0,0 +1,133 @@
+/*
+ * 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.hib.bpel.hobj;
+
+import java.util.Date;
+
+/**
+ * Persistent representation of activity recovery information.
+ *
+ * @hibernate.class table="BPEL_ACTIVITY_RECOVERY"
+ * @hibernate.query name="SELECT_ACTIVITY_RECOVERY_IDS_BY_INSTANCES" query="select id from HActivityRecovery as a where a.instance in (:instances)"
+ */
+public class HActivityRecovery extends HObject {
+ public final static String SELECT_ACTIVITY_RECOVERY_IDS_BY_INSTANCES = "SELECT_ACTIVITY_RECOVERY_IDS_BY_INSTANCES";
+
+ /** Process instance to which this scope belongs. */
+ private HProcessInstance _instance;
+ private long _activityId;
+ private String _channel;
+ private String _reason;
+ private Date _dateTime;
+ private HLargeData _details;
+ private String _actions;
+ private int _retries;
+
+ /**
+ * Get the {@link HProcessInstance} to which this scope object belongs.
+ *
+ * @hibernate.many-to-one column="PIID" foreign-key="none"
+ */
+ public HProcessInstance getInstance() {
+ return _instance;
+ }
+
+ /** @see #getInstance() */
+ public void setInstance(HProcessInstance instance) {
+ _instance = instance;
+ }
+
+ /**
+ * @hibernate.property column="AID"
+ */
+ public long getActivityId() {
+ return _activityId;
+ }
+
+ public void setActivityId(long activityId) {
+ _activityId = activityId;
+ }
+
+ /**
+ * @hibernate.property column="CHANNEL"
+ */
+ public String getChannel() {
+ return _channel;
+ }
+
+ public void setChannel(String channel) {
+ _channel = channel;
+ }
+
+ /**
+ * @hibernate.property column="REASON"
+ */
+ public String getReason() {
+ return _reason;
+ }
+
+ public void setReason(String reason) {
+ _reason = reason;
+ }
+
+ /**
+ * @hibernate.property column="DATE_TIME"
+ */
+ public Date getDateTime() {
+ return _dateTime;
+ }
+
+ public void setDateTime(Date dateTime) {
+ _dateTime = dateTime;
+ }
+
+ /**
+ * @hibernate.many-to-one column="LDATA_ID" cascade="delete" foreign-key="none"
+ */
+ public HLargeData getDetails() {
+ return _details;
+ }
+
+ public void setDetails(HLargeData details) {
+ _details = details;
+ }
+
+ /**
+ * @hibernate.property column="ACTIONS"
+ */
+ public String getActions() {
+ return _actions;
+ }
+
+ public void setActions(String actions) {
+ _actions = actions;
+ }
+
+ /**
+ * @hibernate.property column="RETRIES"
+ */
+ public int getRetries() {
+ return _retries;
+ }
+
+ public void setRetries(int retries) {
+ _retries = retries;
+ }
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HBpelEvent.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HBpelEvent.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HBpelEvent.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HBpelEvent.java Sun May 2 17:02:51 2010
@@ -0,0 +1,128 @@
+/*
+ * 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.hib.bpel.hobj;
+
+import java.sql.Timestamp;
+
+/**
+ * Row representation of a BPEL event.
+ *
+ * @hibernate.class table="BPEL_EVENT"
+ * @hibernate.query name="SELECT_EVENT_IDS_BY_INSTANCES" query="select id from HBpelEvent as e where e.instance in (:instances)"
+ */
+public class HBpelEvent extends HObject {
+ public static final String SELECT_EVENT_IDS_BY_INSTANCES = "SELECT_EVENT_IDS_BY_INSTANCES";
+
+ private Timestamp _tstamp;
+ private String _type;
+ private String _detail;
+
+ private HProcess _process;
+ private HProcessInstance _instance;
+ private HLargeData _data;
+
+ /** Scope identifier, possibly null. */
+ private Long _scopeId;
+
+ /**
+ * @hibernate.many-to-one column="IID" foreign-key="none"
+ */
+ public HProcessInstance getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(HProcessInstance instance) {
+ _instance = instance;
+ }
+
+ /**
+ * @hibernate.many-to-one column="PID" foreign-key="none"
+ */
+ public HProcess getProcess() {
+ return _process;
+ }
+
+ public void setProcess(HProcess process) {
+ _process = process;
+ }
+
+ /**
+ * @hibernate.property column="TSTAMP"
+ */
+ public Timestamp getTstamp() {
+ return _tstamp;
+ }
+
+ public void setTstamp(Timestamp tstamp) {
+ _tstamp = tstamp;
+ }
+
+ /**
+ * @hibernate.property column="TYPE"
+ */
+ public String getType() {
+ return _type;
+ }
+
+ public void setType(String type) {
+ _type = type;
+ }
+
+ /**
+ * TODO Check 32000 is enough for details
+ */
+ /**
+ * @hibernate.property column="DETAIL" type="text" length="32000"
+ */
+ public String getDetail() {
+ return _detail;
+ }
+
+ public void setDetail(String detail) {
+ _detail = detail;
+ }
+
+ /**
+ * @hibernate.many-to-one column="LDATA_ID" cascade="delete" foreign-key="none"
+ */
+ public HLargeData getData() {
+ return _data;
+ }
+
+ public void setData(HLargeData data) {
+ _data = data;
+ }
+
+ /**
+ * Get the scope identifier of the scope associated with this event. Note,
+ * that this is not implemented as a many-to-one relationship because when
+ * scopes are deleted from the database we do not want their events to
+ * suffer the same fate.
+ *
+ * @hibernate.property column="SID"
+ */
+ public Long getScopeId() {
+ return _scopeId;
+ }
+
+ public void setScopeId(Long scopeId) {
+ _scopeId = scopeId;
+ }
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HContextValue.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HContextValue.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HContextValue.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HContextValue.java Sun May 2 17:02:51 2010
@@ -0,0 +1,118 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+/**
+ * Hibernate table-mapped class representing one valued property in a
+ * context.
+ *
+ * @hibernate.class table="BPEL_CONTEXT_VALUE"
+ */
+public class HContextValue extends HObject {
+ private String _key;
+ private String _data;
+ private String _value;
+ private String _namespace;
+
+ private HPartnerLink _partnerLink;
+
+ /**
+ * @hibernate.property
+ * @hibernate.column name="NAMESPACE" length="100" not-null="true" index="IDX_CTX_NSKEY"
+ */
+ public String getNamespace() {
+ return _namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ _namespace = namespace;
+ }
+
+ /**
+ * @hibernate.property
+ * @hibernate.column name="KEY_NAME" length="100" not-null="true" index="IDX_CTX_NSKEY"
+ */
+ public String getKey() {
+ return _key;
+ }
+
+ public void setKey(String key) {
+ _key = key;
+ }
+
+ /**
+ * @hibernate.property
+ * @hibernate.column name="VALUE" length="255" not-null="true" index="IDX_CTX_VAL"
+ */
+ public String getInternalValue() {
+ return _value;
+ }
+
+ public void setInternalValue(String value) {
+ _value = value;
+ }
+
+ /**
+ * @hibernate.property
+ * @hibernate.column name="DATA" sql-type="blob(2G)"
+ */
+ public String getData() {
+ return _data;
+ }
+
+ public void setData(String data) {
+ _data = data;
+ }
+
+ public String getValue() {
+ if (_value != null) {
+ return _value;
+ }
+
+ if (_data != null) {
+ return _data;
+ }
+
+ return null;
+ }
+
+ public void setValue(String value) {
+ // store large data in the clob, small data indexable in a varchar
+ if (value.length() <= 250) {
+ _value = value;
+ _data = null;
+ } else {
+ _value = null;
+ _data = value;
+ }
+ }
+
+ /**
+ * @hibernate.many-to-one column="PARTNERLINK" foreign-key="none"
+ */
+ public HPartnerLink getPartnerLink() {
+ return _partnerLink;
+ }
+
+ public void setPartnerLink(HPartnerLink pl) {
+ _partnerLink = pl;
+ }
+
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationProperty.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationProperty.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationProperty.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationProperty.java Sun May 2 17:02:51 2010
@@ -0,0 +1,108 @@
+/*
+ * 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.hib.bpel.hobj;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Hibernate table-mapped class representing one valued property in a
+ * correlation set.
+ *
+ * @hibernate.class table="BPEL_CORRELATION_PROP"
+ * @hibernate.query name="SELECT_CORPROP_IDS_BY_INSTANCES" query="select id from HCorrelationProperty as p where p.correlationSet in(select s from HCorrelationSet as s where s.instance in (:instances))"
+ */
+public class HCorrelationProperty extends HObject {
+ public final static String SELECT_CORPROP_IDS_BY_INSTANCES = "SELECT_CORPROP_IDS_BY_INSTANCES";
+
+ private String _name;
+ private String _namespace;
+ private String _value;
+ private HCorrelationSet _correlationSet;
+
+ public HCorrelationProperty() {
+ super();
+ }
+
+ public HCorrelationProperty(String name, String namespace, String value,
+ HCorrelationSet correlationSet) {
+ super();
+ _name = name;
+ _namespace = namespace;
+ _value = value;
+ _correlationSet = correlationSet;
+ }
+
+ public HCorrelationProperty(QName qname, String value,
+ HCorrelationSet correlationSet) {
+ super();
+ _name = qname.getLocalPart();
+ _namespace = qname.getNamespaceURI();
+ _value = value;
+ _correlationSet = correlationSet;
+ }
+
+ /**
+ * @hibernate.property column="NAME"
+ */
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /**
+ * @hibernate.property column="NAMESPACE"
+ */
+ public String getNamespace() {
+ return _namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ _namespace = namespace;
+ }
+
+ /**
+ * @hibernate.property column="VALUE"
+ */
+ public String getValue() {
+ return _value;
+ }
+
+ public void setValue(String value) {
+ _value = value;
+ }
+
+ /**
+ * @hibernate.many-to-one column="CORR_SET_ID" foreign-key="none"
+ */
+ public HCorrelationSet getCorrelationSet() {
+ return _correlationSet;
+ }
+
+ public void setCorrelationSet(HCorrelationSet correlationSet) {
+ _correlationSet = correlationSet;
+ }
+
+ public QName getQName() {
+ return new QName(getNamespace(), getName());
+ }
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationSet.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationSet.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationSet.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelationSet.java Sun May 2 17:02:51 2010
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.dao.hib.bpel.hobj;
+
+import java.util.HashSet;
+import java.util.Collection;
+
+/**
+ * Hibernate table representing correlation set values.
+ *
+ * @hibernate.class table="BPEL_CORRELATION_SET"
+ * @hibernate.query name="SELECT_CORSET_IDS_BY_INSTANCES" query="select id from HCorrelationSet as c where c.instance in (:instances)"
+ * @hibernate.query name="SELECT_CORSETS_BY_INSTANCES" query="from HCorrelationSet as c left join fetch c.properties where c.instance.id in (:instances)"
+ * @hibernate.query name="SELECT_CORSETS_BY_PROCESS_STATES" query="from HCorrelationSet as c left join fetch c.process left join fetch c.instance where c.instance.state in (:states)"
+ */
+public class HCorrelationSet extends HObject{
+ public static final String SELECT_CORSET_IDS_BY_INSTANCES = "SELECT_CORSET_IDS_BY_INSTANCES";
+ public static final String SELECT_CORSETS_BY_INSTANCES = "SELECT_CORSETS_BY_INSTANCES";
+ public static final String SELECT_CORSETS_BY_PROCESS_STATES = "SELECT_CORSETS_BY_PROCESS_STATES";
+
+ private HProcess _process;
+ private HProcessInstance _instance;
+ private Collection<HCorrelationProperty> _properties = new HashSet<HCorrelationProperty>();
+ private HScope _scope;
+ private String _name;
+ private String _value;
+
+ public HCorrelationSet() {
+ super();
+ }
+
+ public HCorrelationSet(HScope scope, String name) {
+ super();
+ _scope = scope;
+ _instance = scope.getInstance();
+ _process = _instance.getProcess();
+ _name = name;
+ }
+
+ /**
+ * @hibernate.property column="VALUE"
+ */
+ public String getValue() {
+ return _value;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
+
+ public void setScope(HScope scope) {
+ _scope = scope;
+ }
+
+ public void setValue(String value) {
+ _value = value;
+ }
+
+ /**
+ * @hibernate.property column="CORR_SET_NAME" length="255"
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * @hibernate.many-to-one column="SCOPE_ID" foreign-key="none"
+ */
+ public HScope getScope() {
+ return _scope;
+ }
+
+ /**
+ * @hibernate.many-to-one column="PIID" foreign-key="none"
+ */
+ public HProcessInstance getInstance() {
+ return _instance;
+ }
+
+ public void setInstance(HProcessInstance instance) {
+ _instance = instance;
+ }
+
+ /**
+ * @hibernate.many-to-one column="PROCESS_ID" foreign-key="none"
+ */
+ public HProcess getProcess() {
+ return _process;
+ }
+
+ public void setProcess(HProcess process) {
+ _process = process;
+ }
+
+ /**
+ * @hibernate.set lazy="true" inverse="true" cascade="delete"
+ * @hibernate.collection-key column="CORR_SET_ID" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HCorrelationProperty"
+ */
+ public Collection<HCorrelationProperty> getProperties() {
+ return _properties;
+ }
+
+ public void setProperties(Collection<HCorrelationProperty> properties) {
+ _properties = properties;
+ }
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelator.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelator.java?rev=940263&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelator.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/dao/hib/bpel/hobj/HCorrelator.java Sun May 2 17:02:51 2010
@@ -0,0 +1,117 @@
+/*
+ * 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.hib.bpel.hobj;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Hibernate table representing a BPEL correlator, or message-router. This class
+ * maintains a set of <em>selectors</em> and <em>messages</em>. The
+ * selector set is a database representation of the pick/receive activities that
+ * need to be matched up to a message, while the message set is the database
+ * representation of the messages that have been received that need to be
+ * matched up to a pcik/receive.
+ *
+ * @hibernate.class table="BPEL_CORRELATOR"
+ * @hibernate.query name="SELECT_CORRELATOR_IDS_BY_PROCESS" query="select id from HCorrelator as c where c.process = :process"
+ */
+public class HCorrelator extends HObject {
+ public final static String SELECT_CORRELATOR_IDS_BY_PROCESS = "SELECT_CORRELATOR_IDS_BY_PROCESS";
+
+ private HProcess _process;
+
+ private String _correlatorId;
+
+ /** Receives/picks waiting for message. */
+ private Set<HCorrelatorSelector> _selectors = new HashSet<HCorrelatorSelector>();
+
+ /** Messages waiting for picks/receives. */
+ private Set<HCorrelatorMessage> _messages = new HashSet<HCorrelatorMessage>();
+
+ /** Constructor. */
+ public HCorrelator() {
+ super();
+ }
+
+ /**
+ * Get the set of {@link HCorrelatorMessage} objects representing the
+ * messages that need matching to a selector (i.e. pick/receive).
+ *
+ * @hibernate.set lazy="true" inverse="true"
+ * @hibernate.collection-key column="CORRELATOR" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HCorrelatorMessage"
+ */
+ public Set<HCorrelatorMessage> getMessageCorrelations() {
+ return _messages;
+ }
+
+ /** Hibernate-mandated setter. */
+ public void setMessageCorrelations(Set<HCorrelatorMessage> messages) {
+ _messages = messages;
+ }
+
+ /**
+ * @hibernate.property
+ * @hibernate.column name="CID" index="IDX_CORRELATOR_CID"
+ */
+ public String getCorrelatorId() {
+ return _correlatorId;
+ }
+
+ /** Hibernate-mandated setter. */
+ public void setCorrelatorId(String correlatorId) {
+ _correlatorId = correlatorId;
+ }
+
+ /**
+ * @hibernate.many-to-one column="PROCESS_ID" foreign-key="none"
+ */
+ public HProcess getProcess() {
+ return _process;
+ }
+
+ /** Hibernate-mandated setter. */
+ public void setProcess(HProcess process) {
+ _process = process;
+ }
+
+ /**
+ * Get the set of {@link HCorrelatorSelector} objects representing the
+ * selectors (i.e. pick/receive) that need matching to an input message.
+ *
+ * @hibernate.set lazy="true" inverse="true"
+ * @hibernate.collection-key column="CORRELATOR" foreign-key="none"
+ * @hibernate.collection-one-to-many class="org.apache.ode.dao.hib.bpel.hobj.HCorrelatorSelector"
+ */
+ public Set<HCorrelatorSelector> getSelectors() {
+ return _selectors;
+ }
+
+ /** Hibernate-mandated setter. */
+ public void setSelectors(Set<HCorrelatorSelector> selectors) {
+ _selectors = selectors;
+ }
+
+ @Override
+ public String toString() {
+ return "{HCorrelator process=" + _process.getProcessId() + ", cid=" + _correlatorId + "}";
+ }
+}