Search in sources :

Example 1 with ActivityRecoveryInfoType

use of org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivityRecoveryInfoType in project carbon-business-process by wso2.

the class InstanceManagementServiceSkeleton method getFailedActivitiesForInstance.

/**
 * Get Failed Activities for give instance id.
 *
 * @param instanceID
 * @return
 * @throws InstanceManagementException
 */
@Override
public ActivityRecoveryInfoType[] getFailedActivitiesForInstance(final long instanceID) throws InstanceManagementException {
    try {
        isOperationIsValidForTheCurrentTenant(instanceID);
    } catch (IllegalAccessException ex) {
        handleError(ex);
    }
    ActivityRecoveryInfoType[] activityRecoveryInfoTypes = null;
    try {
        BpelDatabase bpelDb = bpelServer.getODEBPELServer().getBpelDb();
        Object result = bpelDb.exec(new BpelDatabase.Callable<Object>() {

            public Object run(BpelDAOConnection conn) throws InstanceManagementException {
                ProcessInstanceDAO instance = conn.getInstance(instanceID);
                Collection<ActivityRecoveryDAO> activityRecoveries = instance.getActivityRecoveries();
                return activityRecoveries;
            }
        });
        ArrayList<ActivityRecoveryDAO> activityRecoveryDAOs = (ArrayList<ActivityRecoveryDAO>) result;
        if (activityRecoveryDAOs != null) {
            activityRecoveryInfoTypes = new ActivityRecoveryInfoType[activityRecoveryDAOs.size()];
            for (int i = 0; i < activityRecoveryDAOs.size(); i++) {
                ActivityRecoveryDAO activityRecovery = activityRecoveryDAOs.get(i);
                ActivityRecoveryInfoType info = new ActivityRecoveryInfoType();
                info.setActions(activityRecovery.getActions());
                info.setActivityID(activityRecovery.getActivityId());
                info.setDateTime(String.valueOf(activityRecovery.getDateTime()));
                info.setInstanceID(instanceID);
                info.setReason(activityRecovery.getReason());
                info.setRetires(activityRecovery.getRetries());
                activityRecoveryInfoTypes[i] = info;
            }
        }
    } catch (Exception e) {
        String errMsg = "Error occurred while retrieving failed activity information for instance id " + instanceID;
        log.error(errMsg, e);
        throw new InstanceManagementException(errMsg, e);
    }
    return activityRecoveryInfoTypes;
}
Also used : BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) ArrayList(java.util.ArrayList) ActivityRecoveryInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivityRecoveryInfoType) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) ProcessNotFoundException(org.apache.ode.bpel.pmapi.ProcessNotFoundException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessingException(org.apache.ode.bpel.pmapi.ProcessingException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessInstanceDAO(org.apache.ode.bpel.dao.ProcessInstanceDAO) ActivityRecoveryDAO(org.apache.ode.bpel.dao.ActivityRecoveryDAO) Collection(java.util.Collection)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 ActivityRecoveryDAO (org.apache.ode.bpel.dao.ActivityRecoveryDAO)1 BpelDAOConnection (org.apache.ode.bpel.dao.BpelDAOConnection)1 ProcessInstanceDAO (org.apache.ode.bpel.dao.ProcessInstanceDAO)1 BpelDatabase (org.apache.ode.bpel.engine.BpelDatabase)1 ProcessNotFoundException (org.apache.ode.bpel.pmapi.ProcessNotFoundException)1 ProcessingException (org.apache.ode.bpel.pmapi.ProcessingException)1 InstanceManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException)1 ActivityRecoveryInfoType (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivityRecoveryInfoType)1