Search in sources :

Example 1 with EventInfoList

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

the class InstanceManagementServiceSkeleton method getActivitiesWithEvents.

private ActivitiesWithEvents_type0 getActivitiesWithEvents(ScopeDAO scope) {
    ActivitiesWithEvents_type0 activitiesWithEvents = new ActivitiesWithEvents_type0();
    Collection<ActivityRecoveryDAO> recoveries = scope.getProcessInstance().getActivityRecoveries();
    // List<BpelEvent> events = scope.listEvents();
    Set<EventDAOImpl> eventsEntities = ((ScopeDAOImpl) scope).getEvents();
    List<BpelEvent> events = new ArrayList<BpelEvent>();
    for (EventDAOImpl event : eventsEntities) {
        events.add(event.getEvent());
    }
    ActivityStateAndEventDocumentBuilder docBuilder = new ActivityStateAndEventDocumentBuilder();
    for (BpelEvent e : events) {
        docBuilder.onEvent(e);
    }
    for (ActivityInfoWithEventsDocument aweDoc : docBuilder.getActivitiesWithEvents()) {
        for (ActivityRecoveryDAO recovery : recoveries) {
            if (String.valueOf(recovery.getActivityId()).equals(aweDoc.getActivityInfoDoc().getActivityInfo().getAiid())) {
                TFailureInfo failure = aweDoc.getActivityInfoDoc().getActivityInfo().addNewFailure();
                failure.setReason(recovery.getReason());
                failure.setDtFailure(toCalendar(recovery.getDateTime()));
                failure.setActions(recovery.getActions());
                failure.setRetries(recovery.getRetries());
                aweDoc.getActivityInfoDoc().getActivityInfo().setStatus(TActivityStatus.FAILURE);
            }
        }
        ActivityInfoWithEventsType activityWE = new ActivityInfoWithEventsType();
        TActivityInfo actInfoDoc = aweDoc.getActivityInfoDoc().getActivityInfo();
        TEventInfoList evtInfoList = aweDoc.getEventInfoList().getEventInfoList();
        // add activityInfo
        // add event info
        ActivityInfoType activity = fillActivityInfo(new ActivityInfoType(), actInfoDoc);
        /*XmlOptions opt = new XmlOptions();
            opt = opt.setSaveOuter();*/
        EventInfoList eventList = fillEventInfo(new EventInfoList(), evtInfoList);
        activityWE.setActivityInfo(activity);
        activityWE.setActivityEventsList(eventList);
        activitiesWithEvents.addActivityInfoWithEvents(activityWE);
    }
    return activitiesWithEvents;
}
Also used : ActivitiesWithEvents_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivitiesWithEvents_type0) TEventInfoList(org.apache.ode.bpel.pmapi.TEventInfoList) ArrayList(java.util.ArrayList) ScopeDAOImpl(org.apache.ode.dao.jpa.ScopeDAOImpl) BpelEvent(org.apache.ode.bpel.evt.BpelEvent) TActivityInfo(org.apache.ode.bpel.pmapi.TActivityInfo) TFailureInfo(org.apache.ode.bpel.pmapi.TFailureInfo) ActivityInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivityInfoType) EventInfoList(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EventInfoList) TEventInfoList(org.apache.ode.bpel.pmapi.TEventInfoList) ActivityRecoveryDAO(org.apache.ode.bpel.dao.ActivityRecoveryDAO) ActivityStateAndEventDocumentBuilder(org.wso2.carbon.bpel.core.ode.integration.utils.ActivityStateAndEventDocumentBuilder) ActivityInfoWithEventsDocument(org.wso2.carbon.bpel.core.ode.integration.utils.ActivityInfoWithEventsDocument) ActivityInfoWithEventsType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivityInfoWithEventsType) EventDAOImpl(org.apache.ode.dao.jpa.EventDAOImpl)

Example 2 with EventInfoList

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

the class InstanceManagementServiceSkeleton method fillEventInfo.

private EventInfoList fillEventInfo(EventInfoList eventInfoList, TEventInfoList infoList) {
    EventInfo[] infoArray = new EventInfo[infoList.sizeOfEventInfoArray()];
    List<TEventInfo> list = infoList.getEventInfoList();
    for (int i = 0; i < list.size(); i++) {
        infoArray[i] = new EventInfo();
        EventInfo eventInfo = infoArray[i];
        TEventInfo listElem = list.get(i);
        eventInfo.setName(listElem.getName());
        eventInfo.setType(listElem.getType());
        eventInfo.setLineNumber(listElem.getLineNumber());
        eventInfo.setTimestamp(listElem.getTimestamp());
    // TODO: need to change schema and validate the methods
    }
    /*
        for (int i = 0; i < list.size(); i++) {
            infoArray[i] = new TEventInfo
            TEventInfoListSequence tEventInfo = infoArray[i];
            //tEventInfo = new TEventInfo();
            org.apache.ode.bpel.pmapi.TEventInfo listElem = list.get(i);
            tEventInfo.setActivityDefinitionId(listElem.getActivityDefinitionId());
            //tEventInfo.setActivityFailureReason(listElem.getActivityFailureReason());
            tEventInfo.setActivityId(listElem.getActivityId());
            tEventInfo.setActivityName(listElem.getActivityName());
            //tEventInfo.setActivityRecoveryAction(listElem.getActivityRecoveryAction());
            tEventInfo.setActivityType(listElem.getActivityType());
            //tEventInfo.setCorrelationKey(listElem.getCorrelationKey());
            //tEventInfo.setCorrelationSet(listElem.getCorrelationSet());
            //tEventInfo.setExplanation(listElem.getExplanation());
            //tEventInfo.setExpression(listElem.getExpression());
            //tEventInfo.setFault(listElem.getFault());
            tEventInfo.setProcessId(listElem.getProcessId());
            tEventInfo.setScopeId(listElem.getScopeId());
            tEventInfo.setScopeName(listElem.getScopeName());

        }*/
    eventInfoList.setEventInfo(infoArray);
    return eventInfoList;
}
Also used : TEventInfo(org.apache.ode.bpel.pmapi.TEventInfo) EventInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EventInfo) TEventInfo(org.apache.ode.bpel.pmapi.TEventInfo)

Example 3 with EventInfoList

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

the class InstanceManagementServiceSkeleton method fillActivityLifeCycleEventsList.

private void fillActivityLifeCycleEventsList(ActivityLifeCycleEventsListType activityLifeCycleEventsList, EventInfoListDocument infoList) {
    List<TEventInfo> list;
    if (infoList.getEventInfoList() == null) {
        list = infoList.addNewEventInfoList().getEventInfoList();
    } else {
        list = infoList.getEventInfoList().getEventInfoList();
    }
    List<EventInfo> eventInfoList = new ArrayList<EventInfo>();
    Map<Long, Boolean> isFaultMap = new HashMap<Long, Boolean>();
    for (TEventInfo tInfo : list) {
        EventInfo info = new EventInfo();
        info.setType(tInfo.getType());
        info.setName(tInfo.getName());
        info.setLineNumber(tInfo.getLineNumber());
        info.setTimestamp(tInfo.getTimestamp());
        info.setActivityId(tInfo.getActivityId());
        info.setActivityName(tInfo.getActivityName());
        if (tInfo.getName().equals("ActivityFailureEvent")) {
            if (isFaultMap.get(tInfo.getActivityId()) == null) {
                isFaultMap.put(tInfo.getActivityId(), true);
            }
        } else if (tInfo.getName().equals("ActivityExecEndEvent")) {
            if (isFaultMap.get(tInfo.getActivityId()) != null) {
                isFaultMap.remove(tInfo.getActivityId());
            }
            isFaultMap.put(tInfo.getActivityId(), false);
        }
        info.setActivityType(tInfo.getActivityType());
        info.setScopeId(tInfo.getScopeId());
        info.setScopeName(tInfo.getScopeName());
        eventInfoList.add(info);
    }
    for (EventInfo info : eventInfoList) {
        boolean isFault = isFaultMap.get(info.getActivityId()) == null ? false : isFaultMap.get(info.getActivityId());
        info.setIsRecoveryRequired(isFault);
        activityLifeCycleEventsList.addEventInfo(info);
    }
}
Also used : TEventInfo(org.apache.ode.bpel.pmapi.TEventInfo) EventInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EventInfo) TEventInfo(org.apache.ode.bpel.pmapi.TEventInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 TEventInfo (org.apache.ode.bpel.pmapi.TEventInfo)2 EventInfo (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EventInfo)2 HashMap (java.util.HashMap)1 ActivityRecoveryDAO (org.apache.ode.bpel.dao.ActivityRecoveryDAO)1 BpelEvent (org.apache.ode.bpel.evt.BpelEvent)1 TActivityInfo (org.apache.ode.bpel.pmapi.TActivityInfo)1 TEventInfoList (org.apache.ode.bpel.pmapi.TEventInfoList)1 TFailureInfo (org.apache.ode.bpel.pmapi.TFailureInfo)1 EventDAOImpl (org.apache.ode.dao.jpa.EventDAOImpl)1 ScopeDAOImpl (org.apache.ode.dao.jpa.ScopeDAOImpl)1 ActivityInfoWithEventsDocument (org.wso2.carbon.bpel.core.ode.integration.utils.ActivityInfoWithEventsDocument)1 ActivityStateAndEventDocumentBuilder (org.wso2.carbon.bpel.core.ode.integration.utils.ActivityStateAndEventDocumentBuilder)1 ActivitiesWithEvents_type0 (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivitiesWithEvents_type0)1 ActivityInfoType (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivityInfoType)1 ActivityInfoWithEventsType (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ActivityInfoWithEventsType)1 EventInfoList (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EventInfoList)1