Search in sources :

Example 16 with Collection

use of org.wso2.carbon.registry.api.Collection 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 17 with Collection

use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method getPaginatedProcessList.

public PaginatedProcessInfoList getPaginatedProcessList(String processListFilter, String processListOrderByKey, int page) throws ProcessManagementException {
    int tPage = page;
    PaginatedProcessInfoList processList = new PaginatedProcessInfoList();
    TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
    if (tPage < 0 || tPage == Integer.MAX_VALUE) {
        tPage = 0;
    }
    Integer itemsPerPage = 10;
    Integer startIndexForCurrentPage = tPage * itemsPerPage;
    Integer endIndexForCurrentPage = (tPage + 1) * itemsPerPage;
    final ProcessFilter processFilter = new ProcessFilter(processListFilter, processListOrderByKey);
    Collection<ProcessConf> processListForCurrentPage = processQuery(processFilter, tenantProcessStore);
    Integer processListSize = processListForCurrentPage.size();
    Integer pages = (int) Math.ceil((double) processListSize / itemsPerPage);
    processList.setPages(pages);
    ProcessConf[] processConfigurations = processListForCurrentPage.toArray(new ProcessConf[processListSize]);
    for (int i = startIndexForCurrentPage; (i < endIndexForCurrentPage && i < processListSize); i++) {
        processList.addProcessInfo(AdminServiceUtils.createLimitedProcessInfoObject(processConfigurations[i]));
    }
    return processList;
}
Also used : ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) ProcessFilter(org.apache.ode.bpel.common.ProcessFilter) PaginatedProcessInfoList(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PaginatedProcessInfoList) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)

Example 18 with Collection

use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.

the class ProcessImpl method getLinkArrows.

/**
 * Gets the Link arrow coordinates when there is a FLOW activity in the process
 *
 * @param doc SVG document which defines the components including shapes, gradients etc. of the process
 * @return An element which contains the link arrow coordinates of the Process
 */
private Element getLinkArrows(SVGDocument doc) {
    Element group = doc.createElementNS(SVGNamespace.SVG_NAMESPACE, "g");
    // Checks whether the any links exist
    if (links != null && !links.isEmpty()) {
        // Returns a collection-view of the map with the link names, sources(starting activity) and the target
        // (ending activity)
        Set linksSet = links.entrySet();
        Iterator linksIterator = linksSet.iterator();
        // Iterates through the links
        while (linksIterator.hasNext()) {
            Map.Entry<String, Link> link = (Map.Entry<String, Link>) linksIterator.next();
            // Gets the source/start activity of the link
            ActivityInterface startActivity = link.getValue().getSource();
            // Gets the target/end activity of the link
            ActivityInterface endActivity = link.getValue().getTarget();
            // Get the link name
            String linkName = link.getKey();
            // Check if the source and the target of the link contains a value
            if (endActivity != null && startActivity != null) {
                // Define the link flow/path by giving the coordinates of the start and end activity
                group.appendChild(drawLink(doc, startActivity.getExitArrowCoords().getXLeft(), startActivity.getExitArrowCoords().getYTop(), endActivity.getEntryArrowCoords().getXLeft(), endActivity.getEntryArrowCoords().getYTop(), startActivity.getStartIconWidth(), link.getKey(), linkName));
            }
        }
    }
    return group;
}
Also used : Set(java.util.Set) ActivityInterface(org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) Iterator(java.util.Iterator) Map(java.util.Map) Link(org.wso2.carbon.bpel.ui.bpel2svg.Link)

Example 19 with Collection

use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.

the class HumanTaskPackageRepository method addLatestArchiveToRegistryCollection.

/**
 * Add latest human task package zip to the registry
 *
 * @param humanTaskDeploymentUnit
 * @param humanTaskFile
 * @throws HumanTaskStoreException
 * @throws RegistryException
 */
private void addLatestArchiveToRegistryCollection(HumanTaskDeploymentUnit humanTaskDeploymentUnit, File humanTaskFile) throws HumanTaskStoreException, RegistryException {
    FileInputStream fileInputStream = null;
    try {
        Resource latestHumanTaskArchive = configRegistry.newResource();
        fileInputStream = new FileInputStream(humanTaskFile);
        latestHumanTaskArchive.setContent(fileInputStream);
        configRegistry.put(HumanTaskPackageRepositoryUtils.getHumanTaskPackageArchiveResourcePath(humanTaskDeploymentUnit.getPackageName()), latestHumanTaskArchive);
    } catch (FileNotFoundException ex) {
        String errMsg = "HumanTask package zip file couldn't found on given location " + humanTaskFile.getAbsolutePath();
        throw new HumanTaskStoreException(errMsg, ex);
    } catch (RegistryException ex) {
        String errMsg = "Exception occurred while adding latest archive to registry collection";
        throw new RegistryException(errMsg, ex);
    } finally {
        if (fileInputStream != null) {
            try {
                fileInputStream.close();
            } catch (IOException e) {
                log.warn("Cannot close file input stream.", e);
            }
        }
    }
}
Also used : HumanTaskStoreException(org.wso2.carbon.humantask.core.store.HumanTaskStoreException) Resource(org.wso2.carbon.registry.core.Resource) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) FileInputStream(java.io.FileInputStream)

Example 20 with Collection

use of org.wso2.carbon.registry.api.Collection in project carbon-business-process by wso2.

the class HumanTaskPackageRepository method createHumanTaskPackageParentCollectionWithProperties.

/**
 * Create parent collection for human task package using DeploymentUnitDAO
 *
 * @param deploymentUnitDAO
 * @throws RegistryException
 */
private void createHumanTaskPackageParentCollectionWithProperties(DeploymentUnitDAO deploymentUnitDAO) throws RegistryException {
    Collection humanPackage = configRegistry.newCollection();
    humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_CHECKSUM, deploymentUnitDAO.getChecksum());
    if (log.isDebugEnabled()) {
        log.debug(deploymentUnitDAO.getPackageName() + " updating checksum: " + deploymentUnitDAO.getChecksum() + " in registry");
    }
    humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_STATUS, String.valueOf(deploymentUnitDAO.getStatus()));
    humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_VERSION, Long.toString(deploymentUnitDAO.getVersion()));
    configRegistry.put(HumanTaskPackageRepositoryUtils.getResourcePathForHumanTaskPackage(deploymentUnitDAO), humanPackage);
}
Also used : Collection(org.wso2.carbon.registry.core.Collection)

Aggregations

StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)13 Collection (java.util.Collection)9 ArrayList (java.util.ArrayList)8 ComplexEventChunk (org.wso2.siddhi.core.event.ComplexEventChunk)8 IOException (java.io.IOException)7 Collection (org.wso2.carbon.registry.core.Collection)7 Map (java.util.Map)6 HashSet (java.util.HashSet)5 File (java.io.File)4 InstanceFilter (org.apache.ode.bpel.common.InstanceFilter)4 BpelDAOConnection (org.apache.ode.bpel.dao.BpelDAOConnection)4 ProcessInstanceDAO (org.apache.ode.bpel.dao.ProcessInstanceDAO)4 BpelDatabase (org.apache.ode.bpel.engine.BpelDatabase)4 Test (org.testng.annotations.Test)4 TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)4 InstanceManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 HashMap (java.util.HashMap)3 Response (javax.ws.rs.core.Response)3 JAXBContext (javax.xml.bind.JAXBContext)3