Search in sources :

Example 11 with Collection

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

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

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

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

use of org.wso2.carbon.registry.core.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

Collection (org.wso2.carbon.registry.core.Collection)45 Resource (org.wso2.carbon.registry.core.Resource)39 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 Test (org.junit.Test)24 UserRegistry (org.wso2.carbon.registry.core.session.UserRegistry)23 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)22 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)20 IOException (java.io.IOException)19 InputStream (java.io.InputStream)19 ArrayList (java.util.ArrayList)17 RegistryService (org.wso2.carbon.registry.core.service.RegistryService)17 ServiceReferenceHolder (org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder)16 FileInputStream (java.io.FileInputStream)14 OMElement (org.apache.axiom.om.OMElement)13 StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)13 Collection (java.util.Collection)11 CollectionImpl (org.wso2.carbon.registry.core.CollectionImpl)11 ResourceImpl (org.wso2.carbon.registry.core.ResourceImpl)11 File (java.io.File)10