Search in sources :

Example 1 with InstanceSummary

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

the class ProcessManagementServiceSkeleton method addInstanceSummaryEntry.

private void addInstanceSummaryEntry(InstanceSummary instSum, ProcessConf pconf, InstanceStatus state) throws ProcessManagementException {
    Instances_type0 instances = new Instances_type0();
    instances.setState(state);
    String queryStatus = InstanceFilter.StatusKeys.valueOf(state.toString()).toString().toLowerCase();
    final InstanceFilter instanceFilter = new InstanceFilter("status=" + queryStatus + " pid=" + pconf.getProcessId());
    int count = dbexec(new BpelDatabase.Callable<Integer>() {

        public Integer run(BpelDAOConnection conn) throws Exception {
            return conn.instanceCount(instanceFilter).intValue();
        }
    });
    instances.setCount(count);
    instSum.addInstances(instances);
}
Also used : InstanceFilter(org.apache.ode.bpel.common.InstanceFilter) Instances_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Instances_type0) BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) XMLStreamException(javax.xml.stream.XMLStreamException) ParseException(java.text.ParseException) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 2 with InstanceSummary

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

the class ProcessManagementServiceSkeleton method fillProcessInfo.

/**
 * Fill in the <code>ProcessInfo</code> element of the transfer object.
 *
 * @param info               destination XMLBean
 * @param pconf              process configuration object (from store)
 * @param custom             used to customize the quantity of information produced in the
 *                           info
 * @param tenantProcessStore Tenant's Process store
 * @throws ProcessManagementException If an error occurred while filling process information
 */
private void fillProcessInfo(ProcessInfoType info, ProcessConf pconf, ProcessInfoCustomizer custom, TenantProcessStoreImpl tenantProcessStore) throws ProcessManagementException {
    if (pconf == null) {
        String errMsg = "Process configuration cannot be null.";
        log.error(errMsg);
        throw new ProcessManagementException(errMsg);
    }
    info.setPid(pconf.getProcessId().toString());
    // Active process may be retired at the same time
    if (pconf.getState() == ProcessState.RETIRED) {
        info.setStatus(ProcessStatus.RETIRED);
        info.setOlderVersion(AdminServiceUtils.isOlderVersion(pconf, tenantProcessStore));
    } else if (pconf.getState() == ProcessState.DISABLED) {
        info.setStatus(ProcessStatus.DISABLED);
        info.setOlderVersion(0);
    } else {
        info.setStatus(ProcessStatus.ACTIVE);
        info.setOlderVersion(0);
    }
    info.setVersion(pconf.getVersion());
    DefinitionInfo defInfo = new DefinitionInfo();
    defInfo.setProcessName(pconf.getType());
    BpelDefinition bpelDefinition = new BpelDefinition();
    bpelDefinition.setExtraElement(getProcessDefinition(pconf));
    defInfo.setDefinition(bpelDefinition);
    info.setDefinitionInfo(defInfo);
    DeploymentInfo depInfo = new DeploymentInfo();
    depInfo.setPackageName(pconf.getPackage());
    depInfo.setDocument(pconf.getBpelDocument());
    depInfo.setDeployDate(AdminServiceUtils.toCalendar(pconf.getDeployDate()));
    // TODO: Need to fix this by adding info to process conf.
    depInfo.setDeployer(org.wso2.carbon.bpel.core.BPELConstants.BPEL_DEPLOYER_NAME);
    info.setDeploymentInfo(depInfo);
    if (custom.includeInstanceSummary()) {
        InstanceSummary instanceSummary = new InstanceSummary();
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.ACTIVE);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.COMPLETED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.FAILED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.SUSPENDED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.TERMINATED);
        addFailuresToInstanceSummary(instanceSummary, pconf);
        info.setInstanceSummary(instanceSummary);
    }
    if (custom.includeProcessProperties()) {
        ProcessProperties processProps = new ProcessProperties();
        for (Map.Entry<QName, Node> propEntry : pconf.getProcessProperties().entrySet()) {
            QName key = propEntry.getKey();
            if (key != null) {
                Property_type0 prop = new Property_type0();
                prop.setName(new QName(key.getNamespaceURI(), key.getLocalPart()));
                OMFactory omFac = OMAbstractFactory.getOMFactory();
                OMElement propEle = omFac.createOMElement("PropertyValue", null);
                propEle.setText(propEntry.getValue().getNodeValue());
                prop.addExtraElement(propEle);
                processProps.addProperty(prop);
            }
        }
        info.setProperties(processProps);
    }
    fillPartnerLinks(info, ((ProcessConfigurationImpl) pconf).getProcessDeploymentInfo());
}
Also used : DefinitionInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DefinitionInfo) BpelDefinition(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.BpelDefinition) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) OMElement(org.apache.axiom.om.OMElement) InstanceSummary(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InstanceSummary) Property_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Property_type0) ProcessProperty_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperty_type0) ProcessProperties(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperties) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) OMFactory(org.apache.axiom.om.OMFactory) DeploymentInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeploymentInfo) Map(java.util.Map)

Example 3 with InstanceSummary

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

the class ProcessManagementServiceSkeleton method addFailuresToInstanceSummary.

private void addFailuresToInstanceSummary(final InstanceSummary instSum, ProcessConf pconf) throws ProcessManagementException {
    final FailuresInfo failureInfo = new FailuresInfo();
    String queryStatus = InstanceFilter.StatusKeys.valueOf(TInstanceStatus.ACTIVE.toString()).toString().toLowerCase();
    final InstanceFilter instanceFilter = new InstanceFilter("status=" + queryStatus + " pid=" + pconf.getProcessId());
    dbexec(new BpelDatabase.Callable<Void>() {

        public Void run(BpelDAOConnection conn) throws Exception {
            Date lastFailureDt = null;
            int failureInstances = 0;
            for (ProcessInstanceDAO instance : conn.instanceQuery(instanceFilter)) {
                int count = instance.getActivityFailureCount();
                if (count > 0) {
                    ++failureInstances;
                    Date failureDt = instance.getActivityFailureDateTime();
                    if (lastFailureDt == null || lastFailureDt.before(failureDt)) {
                        lastFailureDt = failureDt;
                    }
                }
            }
            if (failureInstances > 0) {
                failureInfo.setCount(failureInstances);
                failureInfo.setFailureDate(AdminServiceUtils.toCalendar(lastFailureDt));
                instSum.setFailures(failureInfo);
            }
            return null;
        }
    });
}
Also used : InstanceFilter(org.apache.ode.bpel.common.InstanceFilter) ProcessInstanceDAO(org.apache.ode.bpel.dao.ProcessInstanceDAO) BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) FailuresInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.FailuresInfo) XMLStreamException(javax.xml.stream.XMLStreamException) ParseException(java.text.ParseException) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Date(java.util.Date)

Example 4 with InstanceSummary

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

the class InstanceSummary method createInstanceSummary.

/**
 * Create instance summary object from process instances array.
 *
 * @param processInstances process instance array
 * @return instance summary object
 */
public static InstanceSummary createInstanceSummary(Instances_type0[] processInstances) {
    InstanceSummary summary = new InstanceSummary();
    for (Instances_type0 processInstance : processInstances) {
        String state = processInstance.getState().getValue();
        if (state.equals("ACTIVE")) {
            summary.activeInstances = processInstance.getCount();
        } else if (state.equals("COMPLETED")) {
            summary.completedInstances = processInstance.getCount();
        } else if (state.equals("TERMINATED")) {
            summary.terminatedInstances = processInstance.getCount();
        } else if (state.equals("FAILED")) {
            summary.failedInstances = processInstance.getCount();
        } else if (state.equals("SUSPENDED")) {
            summary.suspendedInstances = processInstance.getCount();
        } else {
            log.error("Invalid State " + state);
        }
        summary.totalInstances += processInstance.getCount();
    }
    return summary;
}
Also used : Instances_type0(org.wso2.carbon.bpel.stub.mgt.types.Instances_type0)

Example 5 with InstanceSummary

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

the class InstanceManagementServiceSkeleton method getInstanceSummary.

public InstanceSummaryE getInstanceSummary() throws InstanceManagementException {
    InstanceSummaryE instanceSummary = new InstanceSummaryE();
    Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    TenantProcessStoreImpl tenantProcessStore = (TenantProcessStoreImpl) bpelServer.getMultiTenantProcessStore().getTenantsProcessStore(tenantId);
    instanceSummary.setActive(getInstanceCountByState(getTenantsProcessList(tenantProcessStore.getProcessConfigMap().keySet()), INSTANCE_STATUS_ACTIVE).intValue());
    instanceSummary.setCompleted(getInstanceCountByState(getTenantsProcessList(tenantProcessStore.getProcessConfigMap().keySet()), INSTANCE_STATUS_COMPLETED).intValue());
    instanceSummary.setFailed(getInstanceCountByState(getTenantsProcessList(tenantProcessStore.getProcessConfigMap().keySet()), INSTANCE_STATUS_FAILED).intValue());
    instanceSummary.setSuspended(getInstanceCountByState(getTenantsProcessList(tenantProcessStore.getProcessConfigMap().keySet()), INSTANCE_STATUS_SUSPENDED).intValue());
    instanceSummary.setTerminated(getInstanceCountByState(getTenantsProcessList(tenantProcessStore.getProcessConfigMap().keySet()), INSTANCE_STATUS_TERMINATED).intValue());
    return instanceSummary;
}
Also used : InstanceSummaryE(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InstanceSummaryE) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)

Aggregations

ProcessManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ParseException (java.text.ParseException)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 InstanceFilter (org.apache.ode.bpel.common.InstanceFilter)2 BpelDAOConnection (org.apache.ode.bpel.dao.BpelDAOConnection)2 BpelDatabase (org.apache.ode.bpel.engine.BpelDatabase)2 Date (java.util.Date)1 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1 OMElement (org.apache.axiom.om.OMElement)1 OMFactory (org.apache.axiom.om.OMFactory)1 ProcessInstanceDAO (org.apache.ode.bpel.dao.ProcessInstanceDAO)1 Node (org.w3c.dom.Node)1 TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)1 BpelDefinition (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.BpelDefinition)1 DefinitionInfo (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DefinitionInfo)1 DeploymentInfo (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeploymentInfo)1 FailuresInfo (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.FailuresInfo)1