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;
}
Aggregations