Author: assaf
Date: Thu Sep  7 00:03:04 2006
New Revision: 440998

URL: http://svn.apache.org/viewvc?view=rev&rev=440998
Log:
Added activity recovery information in database

Added:
    
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ActivityRecoveryDAO.java
   (with props)
    
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java
   (with props)
    
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java
   (with props)
Modified:
    
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ProcessInstanceDAO.java
    
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
    
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java
    
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessInstanceDaoImpl.java
    
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcessInstance.java

Added: 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ActivityRecoveryDAO.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ActivityRecoveryDAO.java?view=auto&rev=440998
==============================================================================
--- 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ActivityRecoveryDAO.java
 (added)
+++ 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ActivityRecoveryDAO.java
 Thu Sep  7 00:03:04 2006
@@ -0,0 +1,42 @@
+/*
+ * 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.bpel.dao;
+
+import java.util.Date;
+import org.w3c.dom.Element;
+
+/**
+ * Activity recovery object. Registered when activity enters recovery state.
+ */
+public interface ActivityRecoveryDAO {
+
+  int getActivityId();
+
+  String getChannel();
+
+  String getReason();
+
+  Element getData();
+
+  Date getDateTime();
+
+  String[] getActions();
+
+}

Propchange: 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ActivityRecoveryDAO.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ActivityRecoveryDAO.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ActivityRecoveryDAO.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ProcessInstanceDAO.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ProcessInstanceDAO.java?view=diff&rev=440998&r1=440997&r2=440998
==============================================================================
--- 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ProcessInstanceDAO.java
 (original)
+++ 
incubator/ode/trunk/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ProcessInstanceDAO.java
 Thu Sep  7 00:03:04 2006
@@ -206,28 +206,52 @@
    * Get a triple containing the first
    * @return
    */
- EventsFirstLastCountTuple getEventsFirstLastCount();
+  EventsFirstLastCountTuple getEventsFirstLastCount();
 
- /** 
-  * Get the next number from a monotonically increasing sequence.
-  * @return next number in seqeunce
-  */
- public long genMonotonic();
+  /** 
+   * Get the next number from a monotonically increasing sequence.
+   * @return next number in seqeunce
+   */
+  public long genMonotonic();
 
- public BpelDAOConnection getConnection();
+  public BpelDAOConnection getConnection();
+
+  /**
+   * Get number of activities in the failure state.
+   */
+  int getActivityFailureCount();
+
+  /**
+   * Get date/time of last activity failure.
+   */
+  Date getActivityFailureDateTime();
+
+  /**
+   * Returns all activity recovery objects for this process instance.
+   */
+  Collection<ActivityRecoveryDAO> getActivityRecoveries();
+
+  /**
+   * Create an activity recovery object for a given activity instance.
+   * Specify the reason and optional data associated with the failure.
+   * Date/time failure occurred, and the recovery channel and available
+   * recovery actions.
+   */
+  void createActivityRecovery(String channel, int activityId, String reason, 
Date dateTime, Element data, String[] actions);
+
+  /**
+   * Delete previously registered activity recovery.
+   */
+  void deleteActivityRecovery(String channel);
  
- /**
-  * Transport object holding the date of the first and last instance event
-  * along with the number events.
-  */
+  /**
+   * Transport object holding the date of the first and last instance event
+   * along with the number events.
+   */
   public class EventsFirstLastCountTuple {
-    public Date first;
+  public Date first;
     public Date last;
     public int count;
   }
-
-
-
-  
 
 }

Modified: 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java?view=diff&rev=440998&r1=440997&r2=440998
==============================================================================
--- 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
 (original)
+++ 
incubator/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessInstanceDaoImpl.java
 Thu Sep  7 00:03:04 2006
@@ -6,6 +6,7 @@
 package org.apache.ode.bpel.memdao;
 
 import org.apache.ode.bpel.common.ProcessState;
+import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
 import org.apache.ode.bpel.dao.BpelDAOConnection;
 import org.apache.ode.bpel.dao.CorrelationSetDAO;
 import org.apache.ode.bpel.dao.CorrelatorDAO;
@@ -278,6 +279,13 @@
     ret.last = last;
     return ret;
   }
+
+  
+  public int getActivityFailureCount() { return 0; }
+  public Date getActivityFailureDateTime() { return null; }
+  public Collection<ActivityRecoveryDAO> getActivityRecoveries() { return 
null; }
+  public void createActivityRecovery(String channel, int activityId, String 
reason, Date dateTime, Element data, String[] actions) { }
+  public void deleteActivityRecovery(String channel) { }
 
   public long genMonotonic() {
     return ++_seq;

Modified: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java?view=diff&rev=440998&r1=440997&r2=440998
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java
 (original)
+++ 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/SessionManager.java
 Thu Sep  7 00:03:04 2006
@@ -105,6 +105,7 @@
             .addClass(HVariableProperty.class)
             .addClass(HBpelEvent.class)
            .addClass(HFaultData.class)
+           .addClass(HActivityRecovery.class)
             .addClass(HLargeData.class);
   }
 

Added: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java?view=auto&rev=440998
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java
 (added)
+++ 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java
 Thu Sep  7 00:03:04 2006
@@ -0,0 +1,75 @@
+/*
+ * 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.daohib.bpel;
+
+import org.apache.ode.bpel.dao.ActivityRecoveryDAO;
+import org.apache.ode.daohib.SessionManager;
+import org.apache.ode.daohib.bpel.hobj.HActivityRecovery;
+import org.apache.ode.utils.DOMUtils;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Hibernate based [EMAIL PROTECTED] ActivityRecoveryDao} implementation
+ */
+public class ActivityRecoveryDaoImpl extends HibernateDao implements 
ActivityRecoveryDAO {
+
+  HActivityRecovery _self;
+
+  public ActivityRecoveryDaoImpl(SessionManager sm, HActivityRecovery 
recovery) {
+    super(sm, recovery);
+    _self = recovery;
+  }
+
+  public int getActivityId() {
+    return _self.getActivityId();
+  }
+
+  public String getChannel() {
+    return _self.getChannel();
+  }
+
+  public String getReason() {
+    return _self.getReason();
+  }
+
+  public Date getDateTime() {
+    return _self.getDateTime();
+  }
+
+  public Element getData() {
+    if (_self.getData() == null) return null;
+    try {
+      return DOMUtils.stringToDOM(_self.getData().getText());
+    } catch (SAXException e) {
+      throw new RuntimeException(e);
+    } catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  public String[] getActions() {
+    return _self.getActions().split(" ");
+  }
+
+}

Propchange: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ActivityRecoveryDaoImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessInstanceDaoImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessInstanceDaoImpl.java?view=diff&rev=440998&r1=440997&r2=440998
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessInstanceDaoImpl.java
 (original)
+++ 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessInstanceDaoImpl.java
 Thu Sep  7 00:03:04 2006
@@ -333,9 +333,60 @@
     q.executeUpdate();    
   }
 
+  public int getActivityFailureCount() {
+    return _instance.getActivityFailureCount();
+  }
+
+  public Date getActivityFailureDateTime() {
+    return _instance.getActivityFailureDateTime();
+  }
+
+  public Collection<ActivityRecoveryDAO> getActivityRecoveries() {
+    List<ActivityRecoveryDAO> results = new ArrayList<ActivityRecoveryDAO>();
+    for (HActivityRecovery recovery : _instance.getActivityRecoveries())
+      results.add(new ActivityRecoveryDaoImpl(_sm, recovery));
+    return results;
+  }
+
+  public void createActivityRecovery(String channel, int activityId, String 
reason,
+                                     Date dateTime, Element data, String[] 
actions) {
+    HActivityRecovery recovery = new HActivityRecovery();
+    recovery.setChannel(channel);
+    recovery.setActivityId(activityId);
+    recovery.setReason(reason);
+    recovery.setDateTime(dateTime);
+    if (data != null) {
+      HLargeData ld = new HLargeData(DOMUtils.domToString(data));
+      recovery.setData(ld);
+      getSession().save(ld);
+    }
+    String list = actions[0];
+    for (int i = 1; i < actions.length; ++i)
+      list += " " + actions[i];
+    recovery.setActions(list);
+    _instance.getActivityRecoveries().add(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) {
+    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() {
     return new BpelDAOConnectionImpl(_sm);
   }
-
 
 }

Added: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java?view=auto&rev=440998
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java
 (added)
+++ 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java
 Thu Sep  7 00:03:04 2006
@@ -0,0 +1,121 @@
+/*
+ * 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.daohib.bpel.hobj;
+
+import org.apache.ode.daohib.hobj.HLargeData;
+import org.apache.ode.daohib.hobj.HObject;
+import java.util.Date;
+
+/**
+ * Persistent representation of activity recovery information.
+ * @hibernate.class table="BPEL_ACTIVITY_RECOVERY"
+ */
+public class HActivityRecovery extends HObject {
+
+  /** Process instance to which this scope belongs. */
+  private HProcessInstance _instance;
+  private int         _activityId;
+  private String      _channel;
+  private String      _reason;
+  private Date        _dateTime;
+  private HLargeData  _data;
+  private String      _actions;
+
+  /**
+   * Get the [EMAIL PROTECTED] HProcessInstance} to which this scope object 
belongs.
+   * @hibernate.many-to-one
+   *  column="PIID"
+   */
+       public HProcessInstance getInstance() {
+               return _instance;
+       }
+
+  /** @see #getInstance() */
+  public void setInstance(HProcessInstance instance) {
+               _instance = instance;
+       }
+
+  /**
+   * @hibernate.property column="AID"
+   */
+  public int getActivityId() {
+    return _activityId;
+  }
+
+  public void setActivityId(int 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"
+   */
+  public HLargeData getData() {
+    return _data;
+  }
+
+  public void setData(HLargeData data) {
+    _data = data;
+  }
+
+  /**
+   * @hibernate.property column="ACTIONS"
+   */
+       public String getActions() {
+               return _actions;
+       }
+
+  public void setActions(String actions) {
+               _actions = actions;
+       }
+
+}

Propchange: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HActivityRecovery.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcessInstance.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcessInstance.java?view=diff&rev=440998&r1=440997&r2=440998
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcessInstance.java
 (original)
+++ 
incubator/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcessInstance.java
 Thu Sep  7 00:03:04 2006
@@ -51,6 +51,10 @@
   private short _previousState;
   private short _state;
   private Date _lastActiveTime;
+  private Date _activityFailureDateTime;
+  private int  _activityFailureCount;
+
+  private Collection<HActivityRecovery> _activityRecoveries = new 
HashSet<HActivityRecovery>();
 
   private long _seq;
   
@@ -231,6 +235,44 @@
     return _seq;
   }
   
+  /**
+   * @hibernate.bag
+   *  lazy="true"
+   *  inverse="true"
+   *  cascade="delete"
+   * @hibernate.collection-key
+   *  column="PIID"
+   * @hibernate.collection-one-to-many
+   *  class="org.apache.ode.daohib.bpel.hobj.HActivityRecovery"
+   */
+       public Collection<HActivityRecovery> getActivityRecoveries() {
+               return _activityRecoveries;
+       }
+
+       public void setActivityRecoveries(Collection<HActivityRecovery> 
activityRecoveries) {
+               _activityRecoveries = activityRecoveries;
+       }
+
+  /**
+   * @hibernate.property column="FAILURE_COUNT"
+   */
+  public int getActivityFailureCount() {
+    return _activityFailureCount;
+  }
+
+  public void setActivityFailureCount(int count) {
+    _activityFailureCount = count;
+  }
   
+  /**
+   * @hibernate.property column="FAILURE_DT"
+   */
+  public Date getActivityFailureDateTime() {
+    return _activityFailureDateTime;
+  }
+
+  public void setActivityFailureDateTime(Date dateTime) {
+    _activityFailureDateTime = dateTime;
+  }
 
 }


Reply via email to