Author: mriou
Date: Fri Oct 20 10:12:11 2006
New Revision: 466211

URL: http://svn.apache.org/viewvc?view=rev&rev=466211
Log:
Filling endpoints information on TScopeInfo.

Modified:
    
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
    
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ScopeDAO.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java
    
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ScopeDaoImpl.java

Modified: 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java?view=diff&rev=466211&r1=466210&r2=466211
==============================================================================
--- 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
 (original)
+++ 
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
 Fri Oct 20 10:12:11 2006
@@ -89,6 +89,7 @@
                     odeMex.getOperationName());
             options.setAction(soapAction);
             options.setTimeOutInMilliSeconds(60000);
+            
 
             ConfigurationContext ctx = new ConfigurationContext(_axisConfig);
             final ServiceClient serviceClient = new ServiceClient(ctx, null);

Modified: 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ScopeDAO.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ScopeDAO.java?view=diff&rev=466211&r1=466210&r2=466211
==============================================================================
--- 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ScopeDAO.java
 (original)
+++ 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ScopeDAO.java
 Fri Oct 20 10:12:11 2006
@@ -32,97 +32,103 @@
  */
 public interface ScopeDAO  {
 
-  /**
-   * Get the unique identifier for this scope instance.
-   * @return scope instance id
-   */
-  Long getScopeInstanceId();
-
-  /**
-   * Get the scope model id from the object
-   * @return scope model id
-   */
-  int getModelId();
-
-
-  /**
-   * Get scope name (from the definition / or auto-generated).
-   * NOTE: the scope names are not necessarily unique. 
-   * @return scope name
-   */
-  String getName();
-
-  /**
-   * Get a correlation set by name.
-   * @param corrSetName correlation set name
-   * @return correlation set instance
-   */
-  CorrelationSetDAO getCorrelationSet(String corrSetName);
-
-  /**
-   * Gets all correlation sets for this scope
-   * @return correlation set instances
-   */
-  Collection<CorrelationSetDAO> getCorrelationSets();
-
-  /**
-   * Get the parent scope.
-   * @return parent scope
-   */
-  ScopeDAO getParentScope();
-
-  Collection<ScopeDAO> getChildScopes();
-
-  /**
-   * Get the process instance to which this scope belongs.
-   * @return owner [EMAIL PROTECTED] ProcessInstanceDAO}
-   */
-  ProcessInstanceDAO getProcessInstance();
-
-  /**
-   * Set current state of the scope.
-   * @param state new scope state
-   */
-  void setState(ScopeStateEnum state);
-
-  /**
-   * Get current state of the scope.
-   * @return current scope state
-   */
-  ScopeStateEnum getState();
-
-  /**
-   * Get a variable by name.
-   * @param varName variable name
-   * @return [EMAIL PROTECTED] XmlDataDAO} object representing the requested 
variable
-   */
-  XmlDataDAO getVariable(String varName);
-
-  /**
-   * Get a colleciton of all the variables belonging to this scope. 
-   * @return collection of variables
-   */
-  Collection<XmlDataDAO> getVariables();
-
-  /**
-   * Get an ordered list of events associated with this scope.
-   * @return collection of bpel events.
-   */
-  List<BpelEvent> listEvents(BpelEventFilter efilter);
-
-  /**
-   * Create a storage space for partner link values for the scope. 
-   * @param plinkModelId partner link model id
-   * @param pLinkName partner link name
-   * @return [EMAIL PROTECTED] PartnerLinkDAO} object representing the created 
endpoint reference
-   */
-  PartnerLinkDAO createPartnerLink(int plinkModelId, String pLinkName, String 
myRole, String partnerRole);
-
-  /**
-   * Get the parnter link storage object associated with this scope instance
-   * and the provided partner link model id.
-   * @param plinkModelId partner link model id 
-   * @return [EMAIL PROTECTED] PartnerLinkDAO} object representing the 
requested endpoint reference
-   */
-  PartnerLinkDAO getPartnerLink(int plinkModelId);
+    /**
+     * Get the unique identifier for this scope instance.
+     * @return scope instance id
+     */
+    Long getScopeInstanceId();
+
+    /**
+     * Get the scope model id from the object
+     * @return scope model id
+     */
+    int getModelId();
+
+
+    /**
+     * Get scope name (from the definition / or auto-generated).
+     * NOTE: the scope names are not necessarily unique.
+     * @return scope name
+     */
+    String getName();
+
+    /**
+     * Get a correlation set by name.
+     * @param corrSetName correlation set name
+     * @return correlation set instance
+     */
+    CorrelationSetDAO getCorrelationSet(String corrSetName);
+
+    /**
+     * Gets all correlation sets for this scope
+     * @return correlation set instances
+     */
+    Collection<CorrelationSetDAO> getCorrelationSets();
+
+    /**
+     * Get the parent scope.
+     * @return parent scope
+     */
+    ScopeDAO getParentScope();
+
+    Collection<ScopeDAO> getChildScopes();
+
+    /**
+     * Get the process instance to which this scope belongs.
+     * @return owner [EMAIL PROTECTED] ProcessInstanceDAO}
+     */
+    ProcessInstanceDAO getProcessInstance();
+
+    /**
+     * Set current state of the scope.
+     * @param state new scope state
+     */
+    void setState(ScopeStateEnum state);
+
+    /**
+     * Get current state of the scope.
+     * @return current scope state
+     */
+    ScopeStateEnum getState();
+
+    /**
+     * Get a variable by name.
+     * @param varName variable name
+     * @return [EMAIL PROTECTED] XmlDataDAO} object representing the requested 
variable
+     */
+    XmlDataDAO getVariable(String varName);
+
+    /**
+     * Get a colleciton of all the variables belonging to this scope.
+     * @return collection of variables
+     */
+    Collection<XmlDataDAO> getVariables();
+
+    /**
+     * Get an ordered list of events associated with this scope.
+     * @return collection of bpel events.
+     */
+    List<BpelEvent> listEvents(BpelEventFilter efilter);
+
+    /**
+     * Create a storage space for partner link values for the scope.
+     * @param plinkModelId partner link model id
+     * @param pLinkName partner link name
+     * @return [EMAIL PROTECTED] PartnerLinkDAO} object representing the 
created endpoint reference
+     */
+    PartnerLinkDAO createPartnerLink(int plinkModelId, String pLinkName, 
String myRole, String partnerRole);
+
+    /**
+     * Get the parnter link storage object associated with this scope instance
+     * and the provided partner link model id.
+     * @param plinkModelId partner link model id
+     * @return [EMAIL PROTECTED] PartnerLinkDAO} object representing the 
requested endpoint reference
+     */
+    PartnerLinkDAO getPartnerLink(int plinkModelId);
+
+    /**
+     * Get all partner link storage object associated with this scope instance.
+     * @return List of [EMAIL PROTECTED] PartnerLinkDAO} objects
+     */
+    Collection<PartnerLinkDAO> getPartnerLinks();
 }

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java?view=diff&rev=466211&r1=466210&r2=466211
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
 Fri Oct 20 10:12:11 2006
@@ -24,14 +24,7 @@
 import org.apache.ode.bpel.common.BpelEventFilter;
 import org.apache.ode.bpel.common.InstanceFilter;
 import org.apache.ode.bpel.common.ProcessFilter;
-import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.bpel.dao.CorrelationSetDAO;
-import org.apache.ode.bpel.dao.ProcessDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
-import org.apache.ode.bpel.dao.ProcessPropertyDAO;
-import org.apache.ode.bpel.dao.ScopeDAO;
-import org.apache.ode.bpel.dao.XmlDataDAO;
+import org.apache.ode.bpel.dao.*;
 import org.apache.ode.bpel.evt.*;
 import org.apache.ode.bpel.evtproc.ActivityStateDocumentBuilder;
 import org.apache.ode.bpel.iapi.EndpointReference;
@@ -836,6 +829,22 @@
                   }
                 }
                 activities.addNewActivityInfo().set(ai.getActivityInfo());
+            }
+        }
+
+        Collection<PartnerLinkDAO> plinks = scope.getPartnerLinks();
+        if (plinks.size() > 0) {
+            TEndpointReferences refs = scopeInfo.addNewEndpoints();
+            for (PartnerLinkDAO plink : plinks) {
+                if (plink.getPartnerRoleName() != null && 
plink.getPartnerRoleName().length() > 0) {
+                    TEndpointReferences.EndpointRef ref = 
refs.addNewEndpointRef();
+                    ref.setPartnerLink(plink.getPartnerLinkName());
+                    ref.setPartnerRole(plink.getPartnerRoleName());
+                    if (plink.getPartnerEPR() != null) {
+                        Document eprNodeDoc = 
ref.getDomNode().getOwnerDocument();
+                        
ref.getDomNode().appendChild(eprNodeDoc.importNode(plink.getPartnerEPR(), 
true));
+                    }
+                }
             }
         }
     }

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java?view=diff&rev=466211&r1=466210&r2=466211
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ScopeDaoImpl.java
 Fri Oct 20 10:12:11 2006
@@ -23,143 +23,143 @@
  * A very simple, in-memory implementation of the [EMAIL PROTECTED] ScopeDAO} 
interface.
  */
 class ScopeDaoImpl extends DaoBaseImpl implements ScopeDAO {
-  private String _type;
-  private ScopeStateEnum _state;
-  private Map<String, XmlDataDAO> _variables = new HashMap<String, 
XmlDataDAO>();
-  private Map<String, CorrelationSetDAO> _correlations = new HashMap<String, 
CorrelationSetDAO>();
-  private Map<Integer, PartnerLinkDAO> _eprs = new HashMap<Integer, 
PartnerLinkDAO>();
-  private ProcessInstanceDaoImpl _processInstance;
-  private org.apache.ode.bpel.dao.ScopeDAO _parent;
-  private Long _instanceId;
-  private int _scopeModelId;
-
-  /**
-   * Constructor.
-   * @param owner process instance owner
-   * @param parent scope parent
-   * @param type scope type (name)
-   * @param scopeModelId
-   */
-  public ScopeDaoImpl(ProcessInstanceDaoImpl owner, ScopeDAO parent, String 
type, int scopeModelId) {
-    _processInstance = owner;
-    _parent = parent;
-    _type = type;
-    _instanceId = IdGen.newScopeId();
-    _scopeModelId = scopeModelId;
-  }
-
-
-  /**
-   * @see org.apache.ode.bpel.dao.ScopeDAO#getCorrelationSet(java.lang.String)
-   */
-  public CorrelationSetDAO getCorrelationSet(String corrSetName) {
-    CorrelationSetDAO corr = _correlations.get(corrSetName);
-
-    if (corr == null) {
-      corr = new CorrelationSetDaoImpl(corrSetName, this);
-      _correlations.put(corrSetName, corr);
-    }
-
-    return corr;
-  }
-
-  /**
-   * @see org.apache.ode.bpel.dao.ScopeDAO#getParentScope()
-   */
-  public org.apache.ode.bpel.dao.ScopeDAO getParentScope() {
-    return _parent;
-  }
-
-  /**
-   * @see org.apache.ode.bpel.dao.ScopeDAO#getProcessInstance()
-   */
-  public org.apache.ode.bpel.dao.ProcessInstanceDAO getProcessInstance() {
-    return _processInstance;
-  }
-
-  /**
-   * @see 
org.apache.ode.bpel.dao.ScopeDAO#setState(org.apache.ode.bpel.dao.ScopeStateEnum)
-   */
-  public void setState(org.apache.ode.bpel.dao.ScopeStateEnum state) {
-    _state = state;
-  }
-
-  /**
-   * @see org.apache.ode.bpel.dao.ScopeDAO#getState()
-   */
-  public org.apache.ode.bpel.dao.ScopeStateEnum getState() {
-    return _state;
-  }
-
-  /**
-   * @see org.apache.ode.bpel.dao.ScopeDAO#getName()
-   */
-  public String getName() {
-    return _type;
-  }
-
-  /**
-   * @see org.apache.ode.bpel.dao.ScopeDAO#getVariable(java.lang.String)
-   */
-  public XmlDataDAO getVariable(String varName) {
-    XmlDataDAO v = _variables.get(varName);
-
-    if (v == null) {
-      v = new XmlDataDaoImpl(this,varName);
-      _variables.put(varName, v);
-    }
-
-    return v;
-  }
-
-  public Collection<CorrelationSetDAO> getCorrelationSets() {
-    return _correlations.values();
-  }
-
-  /**
-   * @see org.apache.ode.bpel.dao.ScopeDAO#getScopeInstanceId()
-   */
-  public Long getScopeInstanceId() {
-    return _instanceId;
-  }
-
-  /**
-   * @see org.apache.ode.bpel.dao.ScopeDAO#getModelId()
-   */
-  public int getModelId() {
-    return _scopeModelId;
-  }
-
-
-  public Collection<ScopeDAO> getChildScopes() {
-    // TODO Auto-generated method stub
-    throw new UnsupportedOperationException();
-  }
-
-
-  public Collection<XmlDataDAO> getVariables() {
-    return _variables.values();
-  }
-
-  public List<BpelEvent> listEvents(BpelEventFilter efilter) {
-    // TODO: provide a better implementation.
-    return new ArrayList<BpelEvent>();
-  }
-
-  public PartnerLinkDAO createPartnerLink(int plinkModelId, String pLinkName, 
String myRole, String partnerRole) {
-    PartnerLinkDAOImpl eprImpl = new PartnerLinkDAOImpl();
-    eprImpl.setPartnerLinkModelId(plinkModelId);
-    eprImpl.setPartnerLinkName(pLinkName);
-    eprImpl.setMyRoleName(myRole);
-    eprImpl.setPartnerRoleName(partnerRole);
-    _eprs.put(plinkModelId, eprImpl);
-    return eprImpl;
-  }
-
-
-  public PartnerLinkDAO getPartnerLink(int modelId) {
-    return _eprs.get(modelId);
-  }
+    private String _type;
+    private ScopeStateEnum _state;
+    private Map<String, XmlDataDAO> _variables = new HashMap<String, 
XmlDataDAO>();
+    private Map<String, CorrelationSetDAO> _correlations = new HashMap<String, 
CorrelationSetDAO>();
+    private Map<Integer, PartnerLinkDAO> _eprs = new HashMap<Integer, 
PartnerLinkDAO>();
+    private ProcessInstanceDaoImpl _processInstance;
+    private org.apache.ode.bpel.dao.ScopeDAO _parent;
+    private Long _instanceId;
+    private int _scopeModelId;
+
+    /**
+     * Constructor.
+     * @param owner process instance owner
+     * @param parent scope parent
+     * @param type scope type (name)
+     * @param scopeModelId
+     */
+    public ScopeDaoImpl(ProcessInstanceDaoImpl owner, ScopeDAO parent, String 
type, int scopeModelId) {
+        _processInstance = owner;
+        _parent = parent;
+        _type = type;
+        _instanceId = IdGen.newScopeId();
+        _scopeModelId = scopeModelId;
+    }
+
+
+    /**
+     * @see 
org.apache.ode.bpel.dao.ScopeDAO#getCorrelationSet(java.lang.String)
+     */
+    public CorrelationSetDAO getCorrelationSet(String corrSetName) {
+        CorrelationSetDAO corr = _correlations.get(corrSetName);
+
+        if (corr == null) {
+            corr = new CorrelationSetDaoImpl(corrSetName, this);
+            _correlations.put(corrSetName, corr);
+        }
+
+        return corr;
+    }
+
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getParentScope()
+     */
+    public org.apache.ode.bpel.dao.ScopeDAO getParentScope() {
+        return _parent;
+    }
+
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getProcessInstance()
+     */
+    public org.apache.ode.bpel.dao.ProcessInstanceDAO getProcessInstance() {
+        return _processInstance;
+    }
+
+    /**
+     * @see 
org.apache.ode.bpel.dao.ScopeDAO#setState(org.apache.ode.bpel.dao.ScopeStateEnum)
+     */
+    public void setState(org.apache.ode.bpel.dao.ScopeStateEnum state) {
+        _state = state;
+    }
+
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getState()
+     */
+    public org.apache.ode.bpel.dao.ScopeStateEnum getState() {
+        return _state;
+    }
+
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getName()
+     */
+    public String getName() {
+        return _type;
+    }
+
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getVariable(java.lang.String)
+     */
+    public XmlDataDAO getVariable(String varName) {
+        XmlDataDAO v = _variables.get(varName);
+
+        if (v == null) {
+            v = new XmlDataDaoImpl(this,varName);
+            _variables.put(varName, v);
+        }
+
+        return v;
+    }
 
+    public Collection<CorrelationSetDAO> getCorrelationSets() {
+        return _correlations.values();
+    }
+
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getScopeInstanceId()
+     */
+    public Long getScopeInstanceId() {
+        return _instanceId;
+    }
+
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getModelId()
+     */
+    public int getModelId() {
+        return _scopeModelId;
+    }
+
+    public Collection<ScopeDAO> getChildScopes() {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public Collection<XmlDataDAO> getVariables() {
+        return _variables.values();
+    }
+
+    public List<BpelEvent> listEvents(BpelEventFilter efilter) {
+        // TODO: provide a better implementation.
+        return new ArrayList<BpelEvent>();
+    }
+
+    public PartnerLinkDAO createPartnerLink(int plinkModelId, String 
pLinkName, String myRole, String partnerRole) {
+        PartnerLinkDAOImpl eprImpl = new PartnerLinkDAOImpl();
+        eprImpl.setPartnerLinkModelId(plinkModelId);
+        eprImpl.setPartnerLinkName(pLinkName);
+        eprImpl.setMyRoleName(myRole);
+        eprImpl.setPartnerRoleName(partnerRole);
+        _eprs.put(plinkModelId, eprImpl);
+        return eprImpl;
+    }
+
+    public PartnerLinkDAO getPartnerLink(int modelId) {
+        return _eprs.get(modelId);
+    }
+
+    public Collection<PartnerLinkDAO> getPartnerLinks() {
+        return _eprs.values();
+    }
 
 }

Modified: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ScopeDaoImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ScopeDaoImpl.java?view=diff&rev=466211&r1=466210&r2=466211
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ScopeDaoImpl.java
 (original)
+++ 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ScopeDaoImpl.java
 Fri Oct 20 10:12:11 2006
@@ -54,201 +54,209 @@
  */
 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_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_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 static final String QRY_SCOPE_EPR = "from " + 
HPartnerLink.class.getName() +
+            " as e where e.modelId = ? and e.scope = ?";
 
-  private HScope _scope;
-
-
-       public ScopeDaoImpl(SessionManager sm, HScope scope) {
-    super(sm, scope);
-               _scope = scope;
-       }
-
-  /**
-        * @see 
org.apache.ode.bpel.dao.ScopeDAO#getCorrelationSet(java.lang.String)
-        */
-       public CorrelationSetDAO getCorrelationSet(String corrSetName) {
-    Query qry = getSession().createQuery(QRY_CSET);
-    qry.setString(0,corrSetName);
-    qry.setLong(1,_scope.getId());
-    HCorrelationSet cs;
-    Iterator iter = qry.iterate();
-    
-    if(!iter.hasNext()){
-      // if it doesn't exist, we make it
-      cs = new HCorrelationSet(_scope, corrSetName);
-      _scope.getCorrelationSets().add(cs);
-      getSession().save(cs);
-    }else{
-      cs = (HCorrelationSet)iter.next();
-    }
-
-    Hibernate.close(iter);
-    return new CorrelationSetDaoImpl(_sm, cs);
-  }
-  /**
-   * @see org.apache.ode.bpel.dao.ScopeDAO#getParentScope()
-   */
-  public ScopeDAO getParentScope() {
-    return _scope.getParentScope() != null
-      ? new ScopeDaoImpl(_sm, _scope.getParentScope())
-      : null;
-       }
-       /**
-        * @see org.apache.ode.bpel.dao.ScopeDAO#getProcessInstance()
-        */
-       public ProcessInstanceDAO getProcessInstance() {
-               return new ProcessInstanceDaoImpl(_sm, _scope.getInstance());
-       }
-       /**
-        * @see 
org.apache.ode.bpel.dao.ScopeDAO#setState(org.apache.ode.bpel.dao.ScopeStateEnum)
-        */
-       public void setState(ScopeStateEnum state) {
-               _scope.setState(state.toString());
-    getSession().update(_scope);
-       }
-       /**
-        * @see org.apache.ode.bpel.dao.ScopeDAO#getState()
-        */
-       public ScopeStateEnum getState() {
-               return new ScopeStateEnum(_scope.getState());
-       }
-       /**
-        * @see org.apache.ode.bpel.dao.ScopeDAO#getName()
-        */
-       public String getName() {
-               return _scope.getName();
-       }
-       /**
-        * @see org.apache.ode.bpel.dao.ScopeDAO#getVariable(java.lang.String)
-        */
-       public XmlDataDAO getVariable(String varName) {
-               HXmlData data;
-    Query qry = getSession().createQuery(QRY_VARIABLE);
-    qry.setString(0,varName);
-    qry.setLong(1,_scope.getId());
-    Iterator iter = qry.iterate();
-
-    if(iter.hasNext())
-      data = (HXmlData)iter.next();
-    else{
-      data = new HXmlData();
-      data.setName(varName);
-      data.setScope(_scope);
-      _scope.getVariables().add(data);
-      getSession().save(data);
-    }
-    Hibernate.close(iter);
-    return new XmlDataDaoImpl(_sm, data);
-
-       }
-
-  /**
-   * @see 
org.apache.ode.bpel.dao.ScopeDAO#createPartnerLink(java.lang.String,java.lang.String)
-   */
-  public PartnerLinkDAO createPartnerLink(int modelId, String pLinkName, 
String myRole, String partnerRole) {
-    HPartnerLink epr = new HPartnerLink();
-    epr.setModelId(modelId);
-    epr.setLinkName(pLinkName);
-    epr.setMyRole(myRole);
-    epr.setPartnerRole(partnerRole);
-    epr.setScope(_scope);
-    _scope.getPartnerLinks().add(epr);
-    getSession().save(epr);
-    PartnerLinkDAOImpl eprDao = new PartnerLinkDAOImpl(_sm, epr);
-    return eprDao;
-  }
-
-  /**
-   * @see 
org.apache.ode.bpel.dao.ScopeDAO#getPartnerLink(java.lang.String,java.lang.String)
-   */
-  public PartnerLinkDAO getPartnerLink(int plinkId) {
-    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);
-  }
-
-  /**
-        * @see org.apache.ode.bpel.dao.ScopeDAO#getScopeInstanceId()
-        */
-       public Long getScopeInstanceId() {
-               return _scope.getId();
-       }
-
-  /**
-        * @see org.apache.ode.bpel.dao.ScopeDAO#getModelId()
-        */
-       public int getModelId() {
-               return _scope.getScopeModelId();
-       }
-
-  public Set<CorrelationSetDAO> 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() {
-    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() {
-    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(BpelEventFilter efilter) {
-
-    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.transform(ret,hevents,new 
UnaryFunctionEx<HBpelEvent,BpelEvent>() {
-        public BpelEvent apply(HBpelEvent x) throws Exception{
-          return (BpelEvent) 
SerializableUtils.toObject(x.getData().getBinary(),BpelEvent.class.getClassLoader());
+    private HScope _scope;
+
+
+    public ScopeDaoImpl(SessionManager sm, HScope scope) {
+        super(sm, scope);
+        _scope = scope;
+    }
+
+    /**
+     * @see 
org.apache.ode.bpel.dao.ScopeDAO#getCorrelationSet(java.lang.String)
+     */
+    public CorrelationSetDAO getCorrelationSet(String corrSetName) {
+        Query qry = getSession().createQuery(QRY_CSET);
+        qry.setString(0,corrSetName);
+        qry.setLong(1,_scope.getId());
+        HCorrelationSet cs;
+        Iterator iter = qry.iterate();
+
+        if(!iter.hasNext()){
+            // if it doesn't exist, we make it
+            cs = new HCorrelationSet(_scope, corrSetName);
+            _scope.getCorrelationSets().add(cs);
+            getSession().save(cs);
+        }else{
+            cs = (HCorrelationSet)iter.next();
         }
 
-      });
-    }catch (Exception ex) {
-      throw new RuntimeException(ex);
+        Hibernate.close(iter);
+        return new CorrelationSetDaoImpl(_sm, cs);
+    }
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getParentScope()
+     */
+    public ScopeDAO getParentScope() {
+        return _scope.getParentScope() != null
+                ? new ScopeDaoImpl(_sm, _scope.getParentScope())
+                : null;
+    }
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getProcessInstance()
+     */
+    public ProcessInstanceDAO getProcessInstance() {
+        return new ProcessInstanceDaoImpl(_sm, _scope.getInstance());
+    }
+    /**
+     * @see 
org.apache.ode.bpel.dao.ScopeDAO#setState(org.apache.ode.bpel.dao.ScopeStateEnum)
+     */
+    public void setState(ScopeStateEnum state) {
+        _scope.setState(state.toString());
+        getSession().update(_scope);
+    }
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getState()
+     */
+    public ScopeStateEnum getState() {
+        return new ScopeStateEnum(_scope.getState());
+    }
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getName()
+     */
+    public String getName() {
+        return _scope.getName();
+    }
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getVariable(java.lang.String)
+     */
+    public XmlDataDAO getVariable(String varName) {
+        HXmlData data;
+        Query qry = getSession().createQuery(QRY_VARIABLE);
+        qry.setString(0,varName);
+        qry.setLong(1,_scope.getId());
+        Iterator iter = qry.iterate();
+
+        if(iter.hasNext())
+            data = (HXmlData)iter.next();
+        else{
+            data = new HXmlData();
+            data.setName(varName);
+            data.setScope(_scope);
+            _scope.getVariables().add(data);
+            getSession().save(data);
+        }
+        Hibernate.close(iter);
+        return new XmlDataDaoImpl(_sm, data);
+
+    }
+
+    /**
+     * @see 
org.apache.ode.bpel.dao.ScopeDAO#createPartnerLink(java.lang.String,java.lang.String)
+     */
+    public PartnerLinkDAO createPartnerLink(int modelId, String pLinkName, 
String myRole, String partnerRole) {
+        HPartnerLink epr = new HPartnerLink();
+        epr.setModelId(modelId);
+        epr.setLinkName(pLinkName);
+        epr.setMyRole(myRole);
+        epr.setPartnerRole(partnerRole);
+        epr.setScope(_scope);
+        _scope.getPartnerLinks().add(epr);
+        getSession().save(epr);
+        PartnerLinkDAOImpl eprDao = new PartnerLinkDAOImpl(_sm, epr);
+        return eprDao;
+    }
+
+    /**
+     * @see 
org.apache.ode.bpel.dao.ScopeDAO#getPartnerLink(java.lang.String,java.lang.String)
+     */
+    public PartnerLinkDAO getPartnerLink(int plinkId) {
+        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() {
+        ArrayList<PartnerLinkDAO> plinks = new ArrayList<PartnerLinkDAO>();
+        for (HPartnerLink hPartnerLink : _scope.getPartnerLinks()) {
+            plinks.add(new PartnerLinkDAOImpl(_sm, hPartnerLink));
+        }
+        return plinks;
+    }
+
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getScopeInstanceId()
+     */
+    public Long getScopeInstanceId() {
+        return _scope.getId();
+    }
+
+    /**
+     * @see org.apache.ode.bpel.dao.ScopeDAO#getModelId()
+     */
+    public int getModelId() {
+        return _scope.getScopeModelId();
+    }
+
+    public Set<CorrelationSetDAO> 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() {
+        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() {
+        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(BpelEventFilter efilter) {
+
+        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.transform(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;
     }
-    return ret;
-  }
 
 }


Reply via email to