Search in sources :

Example 6 with TenantProcessStoreImpl

use of org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl in project carbon-business-process by wso2.

the class BPELPackageManagementServiceSkeleton method getTenantProcessStore.

private TenantProcessStoreImpl getTenantProcessStore() {
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    BPELServerImpl bpelServer = BPELServerImpl.getInstance();
    return (TenantProcessStoreImpl) bpelServer.getMultiTenantProcessStore().getTenantsProcessStore(tenantId);
}
Also used : BPELServerImpl(org.wso2.carbon.bpel.core.ode.integration.BPELServerImpl) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)

Example 7 with TenantProcessStoreImpl

use of org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method getProcessDeploymentInfo.

/* The methods gets data from ProcessConfigurationImpl and display the details
    *  @param  pid
    *  @return processDeployDetailsList
    *
    */
public ProcessDeployDetailsList_type0 getProcessDeploymentInfo(QName pid) {
    /* Configuring process basic information*/
    ProcessDeployDetailsList processDeployDetailsList = new ProcessDeployDetailsList();
    ProcessDeployDetailsList_type0 processDeployDetailsListType = new ProcessDeployDetailsList_type0();
    TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
    ProcessConf processConf = tenantProcessStore.getProcessConfiguration(pid);
    ProcessConfigurationImpl processConfiguration = (ProcessConfigurationImpl) processConf;
    QName processId = processConfiguration.getProcessId();
    processDeployDetailsListType.setProcessName(processId);
    ProcessStatus processStatus = ProcessStatus.Factory.fromValue(processConfiguration.getState().name());
    processDeployDetailsListType.setProcessState(processStatus);
    processDeployDetailsListType.setIsInMemory(processConfiguration.isTransient());
    /* Configuring invoked services by the process*/
    List<TInvoke> invokeList = processConfiguration.getInvokedServices();
    if (invokeList != null) {
        InvokeServiceListType ist = new InvokeServiceListType();
        for (TInvoke invoke : invokeList) {
            InvokedServiceType invokedServiceType = new InvokedServiceType();
            Service_type1 service = new Service_type1();
            service.setName(invoke.getService().getName());
            service.setPort(invoke.getService().getPort());
            invokedServiceType.setService(service);
            invokedServiceType.setPartnerLink(invoke.getPartnerLink());
            ist.addInvokedService(invokedServiceType);
            processDeployDetailsListType.setInvokeServiceList(ist);
        }
    }
    /* Configuring providing services by the process*/
    List<TProvide> provideList = processConfiguration.getProvidedServices();
    if (provideList != null) {
        ProvideServiceListType pst = new ProvideServiceListType();
        for (TProvide provide : provideList) {
            ProvidedServiceType providedServiceType = new ProvidedServiceType();
            Service_type0 service = new Service_type0();
            service.setName(provide.getService().getName());
            service.setPort(provide.getService().getPort());
            providedServiceType.setService(service);
            providedServiceType.setPartnerLink(provide.getPartnerLink());
            pst.addProvidedService(providedServiceType);
        }
        processDeployDetailsListType.setProvideServiceList(pst);
    }
    /* Configuring message exchange interceptors of the process*/
    MexInterpreterListType mxt = new MexInterpreterListType();
    List<String> mexInterceptor = processConfiguration.getMexInterceptors();
    if (mexInterceptor != null) {
        for (String mexInt : mexInterceptor) {
            mxt.addMexinterpreter(mexInt);
        }
    }
    processDeployDetailsListType.setMexInterperterList(mxt);
    /* Configuring process level and scope level enabled events of process*/
    Map<String, Set<BpelEvent.TYPE>> eventsMap = processConfiguration.getEvents();
    ProcessEventsListType processEventsListType = new ProcessEventsListType();
    EnableEventListType enableEventListType = new EnableEventListType();
    ScopeEventListType scopeEventListType = new ScopeEventListType();
    for (Map.Entry<String, Set<BpelEvent.TYPE>> eventEntry : eventsMap.entrySet()) {
        if (eventEntry.getKey() != null) {
            ScopeEventType scopeEvent = new ScopeEventType();
            String scopeName = eventEntry.getKey();
            EnableEventListType enableEventList = new EnableEventListType();
            Set<BpelEvent.TYPE> typeSetforScope = eventEntry.getValue();
            for (BpelEvent.TYPE type : typeSetforScope) {
                enableEventList.addEnableEvent(type.toString());
            }
            scopeEvent.setScope(scopeName);
            scopeEvent.setEnabledEventList(enableEventList);
            scopeEventListType.addScopeEvent(scopeEvent);
        } else {
            Set<BpelEvent.TYPE> typeSet = eventEntry.getValue();
            for (BpelEvent.TYPE aTypeSet : typeSet) {
                enableEventListType.addEnableEvent(aTypeSet.toString());
            }
        }
    }
    TProcessEvents.Generate.Enum genEnum = processConfiguration.getGenerateType();
    if (genEnum != null) {
        Generate_type1 generate = Generate_type1.Factory.fromValue(genEnum.toString());
        processEventsListType.setGenerate(generate);
    }
    processEventsListType.setEnableEventsList(enableEventListType);
    processEventsListType.setScopeEventsList(scopeEventListType);
    processDeployDetailsListType.setProcessEventsList(processEventsListType);
    // end of process events
    /* configuring properties defined in the process */
    PropertyListType propertyListType = new PropertyListType();
    Map<QName, Node> propertiesMap = processConfiguration.getProcessProperties();
    Set<Map.Entry<QName, Node>> entries = propertiesMap.entrySet();
    for (Map.Entry entry : entries) {
        ProcessProperty_type0 property = new ProcessProperty_type0();
        property.setName((QName) entry.getKey());
        Node node = (Node) entry.getValue();
        property.setValue(DOMUtils.domToStringLevel2(node));
        propertyListType.addProcessProperty(property);
    }
    processDeployDetailsListType.setPropertyList(propertyListType);
    CleanUpListType cleanUpList = new CleanUpListType();
    Set<ProcessConf.CLEANUP_CATEGORY> sucessTypeCleanups = processConfiguration.getCleanupCategories(true);
    Set<ProcessConf.CLEANUP_CATEGORY> failureTypeCleanups = processConfiguration.getCleanupCategories(false);
    if (sucessTypeCleanups != null) {
        CleanUpType cleanUp = new CleanUpType();
        On_type1 onType = On_type1.success;
        cleanUp.setOn(onType);
        CategoryListType categoryListType = new CategoryListType();
        for (ProcessConf.CLEANUP_CATEGORY sCategory : sucessTypeCleanups) {
            Category_type1 categoryType1 = Category_type1.Factory.fromValue(sCategory.name().toLowerCase());
            categoryListType.addCategory(categoryType1);
        }
        cleanUp.setCategoryList(categoryListType);
        cleanUpList.addCleanUp(cleanUp);
    }
    if (failureTypeCleanups != null) {
        CleanUpType cleanUp = new CleanUpType();
        On_type1 onType = On_type1.failure;
        cleanUp.setOn(onType);
        CategoryListType categoryListType = new CategoryListType();
        for (ProcessConf.CLEANUP_CATEGORY fCategory : failureTypeCleanups) {
            Category_type1 categoryType1 = Category_type1.Factory.fromValue(fCategory.name().toLowerCase());
            categoryListType.addCategory(categoryType1);
        }
        cleanUp.setCategoryList(categoryListType);
        cleanUpList.addCleanUp(cleanUp);
    }
    processDeployDetailsListType.setCleanUpList(cleanUpList);
    processDeployDetailsList.setProcessDeployDetailsList(processDeployDetailsListType);
    return processDeployDetailsListType;
}
Also used : ProcessEventsListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessEventsListType) Node(org.w3c.dom.Node) CleanUpType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CleanUpType) TInvoke(org.apache.ode.bpel.dd.TInvoke) ScopeEventListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ScopeEventListType) CleanUpListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CleanUpListType) InvokedServiceType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InvokedServiceType) TProvide(org.apache.ode.bpel.dd.TProvide) EnableEventListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EnableEventListType) Category_type1(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Category_type1) InvokeServiceListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InvokeServiceListType) MexInterpreterListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.MexInterpreterListType) Map(java.util.Map) Set(java.util.Set) ProcessStatus(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessStatus) ProvidedServiceType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProvidedServiceType) BpelEvent(org.apache.ode.bpel.evt.BpelEvent) ProcessConfigurationImpl(org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl) ScopeEventType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ScopeEventType) On_type1(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.On_type1) QName(javax.xml.namespace.QName) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) PropertyListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PropertyListType) ProcessDeployDetailsList(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessDeployDetailsList) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) ProvideServiceListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProvideServiceListType) Generate_type1(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Generate_type1) CategoryListType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CategoryListType) ProcessDeployDetailsList_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessDeployDetailsList_type0) Service_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Service_type0) Service_type1(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Service_type1) ProcessProperty_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperty_type0)

Example 8 with TenantProcessStoreImpl

use of org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method processQuery.

/**
 * Query processes based on a {@link org.apache.ode.bpel.common.ProcessFilter} criteria. This is
 * implemented in memory rather than via database calls since the processes
 * are managed by the {@link org.apache.ode.bpel.iapi.ProcessStore} object and we don't want to make
 * this needlessly complicated.
 *
 * @param filter              process filter
 * @param tenantsProcessStore Current Tenant's process store
 * @return ProcessConf collection
 * @throws ProcessManagementException if an error occurred while processing query
 */
private Collection<ProcessConf> processQuery(ProcessFilter filter, TenantProcessStoreImpl tenantsProcessStore) throws ProcessManagementException {
    Map<QName, ProcessConfigurationImpl> processes = tenantsProcessStore.getProcessConfigMap();
    if (log.isDebugEnabled()) {
        for (Map.Entry<QName, ProcessConfigurationImpl> process : processes.entrySet()) {
            log.debug("Process " + process.getKey() + " in state " + process.getValue());
        }
    }
    Set<QName> pids = processes.keySet();
    // Name filter can be implemented using only the PIDs.
    if (filter != null && filter.getNameFilter() != null) {
        // adding escape sequences to [\^$.|?*+(){} characters
        String nameFilter = filter.getNameFilter().replace("\\", "\\\\").replace("]", "\\]").replace("[", "\\[").replace("^", "\\^").replace("$", "\\$").replace("|", "\\|").replace("?", "\\?").replace(".", "\\.").replace("+", "\\+").replace("(", "\\(").replace(")", "\\)").replace("{", "\\{").replace("}", "\\}").replace("*", ".*");
        final Pattern pattern = Pattern.compile(nameFilter + "(-\\d*)?");
        CollectionsX.remove_if(pids, new MemberOfFunction<QName>() {

            @Override
            public boolean isMember(QName o) {
                return !pattern.matcher(o.getLocalPart()).matches();
            }
        });
    }
    if (filter != null && filter.getNamespaceFilter() != null) {
        // adding escape sequences to [\^$.|?*+(){} characters
        String namespaceFilter = filter.getNamespaceFilter().replace("\\", "\\\\").replace("]", "\\]").replace("[", "\\[").replace("^", "\\^").replace("$", "\\$").replace("|", "\\|").replace("?", "\\?").replace(".", "\\.").replace("+", "\\+").replace("(", "\\(").replace(")", "\\)").replace("{", "\\{").replace("}", "\\}").replace("*", ".*");
        final Pattern pattern = Pattern.compile(namespaceFilter);
        CollectionsX.remove_if(pids, new MemberOfFunction<QName>() {

            @Override
            public boolean isMember(QName o) {
                String ns = o.getNamespaceURI() == null ? "" : o.getNamespaceURI();
                return !pattern.matcher(ns).matches();
            }
        });
    }
    // Now we need the process conf objects, we need to be
    // careful since someone could have deleted them by now
    List<ProcessConf> confs = new LinkedList<ProcessConf>();
    for (QName pid : pids) {
        ProcessConf pConf = tenantsProcessStore.getProcessConfiguration(pid);
        if (pConf != null) {
            confs.add(pConf);
        }
    }
    if (filter != null) {
        // Specific filter for deployment date.
        if (filter.getDeployedDateFilter() != null) {
            for (final String ddf : filter.getDeployedDateFilter()) {
                final Date dd;
                try {
                    dd = ISO8601DateParser.parse(Filter.getDateWithoutOp(ddf));
                } catch (ParseException e) {
                    // Should never happen.
                    String errMsg = "Exception while parsing date";
                    log.error(errMsg, e);
                    throw new ProcessManagementException(errMsg, e);
                }
                CollectionsX.remove_if(confs, new MemberOfFunction<ProcessConf>() {

                    @Override
                    public boolean isMember(ProcessConf o) {
                        if (ddf.startsWith("=")) {
                            return !o.getDeployDate().equals(dd);
                        }
                        if (ddf.startsWith("<=")) {
                            return o.getDeployDate().getTime() > dd.getTime();
                        }
                        if (ddf.startsWith(">=")) {
                            return o.getDeployDate().getTime() < dd.getTime();
                        }
                        if (ddf.startsWith("<")) {
                            return o.getDeployDate().getTime() >= dd.getTime();
                        }
                        return ddf.startsWith(">") && (o.getDeployDate().getTime() <= dd.getTime());
                    }
                });
            }
        }
        // Ordering
        if (filter.getOrders() != null) {
            ComparatorChain cChain = new ComparatorChain();
            for (String key : filter.getOrders()) {
                boolean ascending = true;
                String orderKey = key;
                if (key.startsWith("+") || key.startsWith("-")) {
                    orderKey = key.substring(1, key.length());
                    if (key.startsWith("-")) {
                        ascending = false;
                    }
                }
                Comparator c;
                if ("name".equals(orderKey)) {
                    c = new Comparator<ProcessConf>() {

                        public int compare(ProcessConf o1, ProcessConf o2) {
                            return o1.getProcessId().getLocalPart().compareTo(o2.getProcessId().getLocalPart());
                        }
                    };
                } else if ("namespace".equals(orderKey)) {
                    c = new Comparator<ProcessConf>() {

                        public int compare(ProcessConf o1, ProcessConf o2) {
                            String ns1 = o1.getProcessId().getNamespaceURI() == null ? "" : o1.getProcessId().getNamespaceURI();
                            String ns2 = o2.getProcessId().getNamespaceURI() == null ? "" : o2.getProcessId().getNamespaceURI();
                            return ns1.compareTo(ns2);
                        }
                    };
                } else if ("version".equals(orderKey)) {
                    c = new Comparator<ProcessConf>() {

                        public int compare(ProcessConf o1, ProcessConf o2) {
                            return (int) (o1.getVersion() - o2.getVersion());
                        }
                    };
                } else if ("deployed".equals(orderKey)) {
                    c = new Comparator<ProcessConf>() {

                        public int compare(ProcessConf o1, ProcessConf o2) {
                            return o1.getDeployDate().compareTo(o2.getDeployDate());
                        }
                    };
                } else if ("status".equals(orderKey)) {
                    c = new Comparator<ProcessConf>() {

                        public int compare(ProcessConf o1, ProcessConf o2) {
                            return o1.getState().compareTo(o2.getState());
                        }
                    };
                } else {
                    // unrecognized
                    if (log.isDebugEnabled()) {
                        log.debug("unrecognized order key" + orderKey);
                    }
                    continue;
                }
                cChain.addComparator(c, !ascending);
            }
            Collections.sort(confs, cChain);
        }
    }
    return confs;
}
Also used : Pattern(java.util.regex.Pattern) ComparatorChain(org.apache.commons.collections.comparators.ComparatorChain) QName(javax.xml.namespace.QName) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) ProcessConfigurationImpl(org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl) LinkedList(java.util.LinkedList) Date(java.util.Date) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) Comparator(java.util.Comparator) ParseException(java.text.ParseException) Map(java.util.Map)

Example 9 with TenantProcessStoreImpl

use of org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method getProcessInfo.

public ProcessInfoType getProcessInfo(QName pid) throws ProcessManagementException {
    ProcessInfoType processInfoType = new ProcessInfoType();
    TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
    ProcessConf processConf = tenantProcessStore.getProcessConfiguration(pid);
    fillProcessInfo(processInfoType, processConf, ProcessInfoCustomizer.ALL, tenantProcessStore);
    return processInfoType;
}
Also used : ProcessInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessInfoType) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)

Example 10 with TenantProcessStoreImpl

use of org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl in project carbon-business-process by wso2.

the class BPELPackageManagementServiceSkeleton method listDeployedPackagesPaginated.

public DeployedPackagesPaginated listDeployedPackagesPaginated(int page, String packageSearchString) throws PackageManagementException {
    int tPage = page;
    List<BPELPackageInfo> packages;
    DeployedPackagesPaginated paginatedPackages = new DeployedPackagesPaginated();
    TenantProcessStoreImpl tenantProcessStore = getTenantProcessStore();
    BPELPackageRepository packageRepo = tenantProcessStore.getBPELPackageRepository();
    try {
        // Can return null and we should handle that
        packages = packageRepo.getBPELPackages();
    } catch (Exception e) {
        String errorMessage = "Cannot get the BPEL Package list from repository.";
        log.error(errorMessage, e);
        throw new PackageManagementException(errorMessage, e);
    }
    if (packages != null) {
        // Calculating pagination information
        if (tPage < 0 || tPage == Integer.MAX_VALUE) {
            tPage = 0;
        }
        int startIndex = tPage * BPELConstants.ITEMS_PER_PAGE;
        int endIndex = (tPage + 1) * BPELConstants.ITEMS_PER_PAGE;
        int numberOfPackages = packages.size();
        int totalPackages = 0;
        BPELPackageInfo[] packagesArray = packages.toArray(new BPELPackageInfo[numberOfPackages]);
        for (int i = 0; i < numberOfPackages; i++) {
            if (!packagesArray[i].getName().toLowerCase().contains(packageSearchString.toLowerCase())) {
                continue;
            }
            int count = getPackageVersionCount(packagesArray[i]);
            if (totalPackages + count > startIndex && totalPackages < endIndex) {
                // In-order to get the total number of packages count
                // if (totalPackages >= endIndex) {
                // break;
                // }
                int maxRemainingPackages = totalPackages < startIndex && (totalPackages + count) > startIndex ? startIndex - (totalPackages + count) : endIndex - totalPackages;
                PackageType packageType = getPackageInfo(packagesArray[i], maxRemainingPackages);
                paginatedPackages.add_package(packageType);
            }
            totalPackages += count;
        }
        int pages = (int) Math.ceil((double) totalPackages / BPELConstants.ITEMS_PER_PAGE);
        paginatedPackages.setPages(pages);
    } else {
        // Returning empty result set with pages equal to zero for cases where null is returned from
        // BPEL repo.
        paginatedPackages.setPages(0);
    }
    return paginatedPackages;
}
Also used : PackageType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PackageType) DeployedPackagesPaginated(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeployedPackagesPaginated) BPELPackageRepository(org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository) PackageManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) PackageManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException) BPELUIException(org.wso2.carbon.bpel.core.ode.integration.store.BPELUIException) BPELPackageInfo(org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageInfo)

Aggregations

TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)16 QName (javax.xml.namespace.QName)6 ProcessConf (org.apache.ode.bpel.iapi.ProcessConf)5 InstanceManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException)5 Collection (java.util.Collection)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 BPELUIException (org.wso2.carbon.bpel.core.ode.integration.store.BPELUIException)4 BPELPackageRepository (org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository)4 PackageManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.PackageManagementException)4 Map (java.util.Map)3 ProcessNotFoundException (org.apache.ode.bpel.pmapi.ProcessNotFoundException)3 ProcessingException (org.apache.ode.bpel.pmapi.ProcessingException)3 ProcessConfigurationImpl (org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl)3 ProcessManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException)3 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2