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);
}
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());
}
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;
}
});
}
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;
}
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;
}
Aggregations