Search in sources :

Example 1 with LimitedInstanceInfoType

use of org.wso2.carbon.bpel.stub.mgt.types.LimitedInstanceInfoType in project carbon-business-process by wso2.

the class InstanceManagementServiceSkeleton method createLimitedInstanceInfoObject.

private LimitedInstanceInfoType createLimitedInstanceInfoObject(ProcessInstanceDAO instanceDAO) throws InstanceManagementException {
    LimitedInstanceInfoType instanceInfo = new LimitedInstanceInfoType();
    instanceInfo.setIid(Long.toString(instanceDAO.getInstanceId()));
    instanceInfo.setPid(instanceDAO.getProcess().getProcessId().toString());
    instanceInfo.setStatus(odeInstanceStatusToManagementAPIStatus(instanceDAO.getState()));
    instanceInfo.setDateLastActive(toCalendar(instanceDAO.getLastActiveTime()));
    instanceInfo.setDateStarted(toCalendar(instanceDAO.getCreateTime()));
    return instanceInfo;
}
Also used : LimitedInstanceInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.LimitedInstanceInfoType)

Example 2 with LimitedInstanceInfoType

use of org.wso2.carbon.bpel.stub.mgt.types.LimitedInstanceInfoType in project carbon-business-process by wso2.

the class Instance method getInstanceInfoFromInstanceId.

@Override
public String[] getInstanceInfoFromInstanceId() {
    StringBuffer buffer = new StringBuffer();
    PaginatedInstanceList paginatedInstanceList;
    String[] instanceInfoArray = null;
    int arrayCount = 0;
    try {
        paginatedInstanceList = getPaginatedInstanceList(" ", "-last-active", 200, 0);
        LimitedInstanceInfoType[] instanceArray = paginatedInstanceList.getInstance();
        instanceInfoArray = new String[instanceArray.length];
        for (LimitedInstanceInfoType instance : instanceArray) {
            buffer.append("Instance id=" + instance.getIid());
            buffer.append("  ");
            buffer.append("Process id=" + instance.getPid());
            buffer.append(" ");
            buffer.append("Status =" + instance.getStatus());
            buffer.append(" ");
            buffer.append("Started Date=" + instance.getDateStarted().get(5));
            buffer.append("-" + instance.getDateStarted().get(2));
            buffer.append("-" + instance.getDateStarted().get(1));
            buffer.append("  ");
            buffer.append(instance.getDateStarted().get(11));
            buffer.append(":" + instance.getDateStarted().get(12));
            buffer.append(":" + instance.getDateStarted().get(13));
            buffer.append("  ");
            buffer.append("Date Last Activate=" + instance.getDateLastActive().get(5));
            buffer.append("-" + instance.getDateLastActive().get(2));
            buffer.append("-" + instance.getDateLastActive().get(1));
            buffer.append("  ");
            buffer.append(instance.getDateLastActive().get(11));
            buffer.append(":" + instance.getDateLastActive().get(12));
            buffer.append(":" + instance.getDateLastActive().get(13));
            buffer.append("  ");
            instanceInfoArray[arrayCount] = buffer.toString();
            arrayCount++;
            buffer.delete(0, buffer.length());
        }
    } catch (InstanceManagementException e) {
        String errMsg = "failed to get instance information from instance id";
        log.error(errMsg, e);
    }
    return instanceInfoArray;
}
Also used : InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) LimitedInstanceInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.LimitedInstanceInfoType) PaginatedInstanceList(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PaginatedInstanceList)

Example 3 with LimitedInstanceInfoType

use of org.wso2.carbon.bpel.stub.mgt.types.LimitedInstanceInfoType in project carbon-business-process by wso2.

the class BpelUIUtil method createLongRunningInstanceJSONString.

public static String createLongRunningInstanceJSONString(PaginatedInstanceList longRunningInstances) {
    // LinkedHashMap is introduced instead of JSONObject, in-order to keep the order of the instances
    LinkedHashMap<String, JSONObject> longRunning = new LinkedHashMap<String, JSONObject>();
    if (longRunningInstances.isInstanceSpecified()) {
        for (LimitedInstanceInfoType instance : longRunningInstances.getInstance()) {
            JSONObject instanceJson = new JSONObject();
            long instanceLifetimeTillLastActive = (instance.getDateLastActive().getTime().getTime() - instance.getDateStarted().getTime().getTime());
            long instanceLifetimeFromLastActiveToNow = (new Date().getTime() - instance.getDateLastActive().getTime().getTime());
            instanceJson.put(BPELUIConstant.INSTANCE_LIFETIME_TILL_LASTACTIVE, instanceLifetimeTillLastActive);
            instanceJson.put(BPELUIConstant.INSTANCE_LIFETIME_FROM_LASTACTIVE_TO_NOW, instanceLifetimeFromLastActiveToNow);
            longRunning.put(instance.getIid(), instanceJson);
        }
    }
    return JSONObject.toJSONString(longRunning);
}
Also used : JSONObject(org.json.simple.JSONObject) LimitedInstanceInfoType(org.wso2.carbon.bpel.stub.mgt.types.LimitedInstanceInfoType) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with LimitedInstanceInfoType

use of org.wso2.carbon.bpel.stub.mgt.types.LimitedInstanceInfoType in project carbon-business-process by wso2.

the class InstanceManagementServiceSkeleton method getLongRunningInstances.

/**
 * Get long running instances with duration
 *
 * @param limit The maximum number of instances to be fetched
 * @return Long running instances
 * @throws InstanceManagementException When an error occurs
 */
public LimitedInstanceInfoType[] getLongRunningInstances(int limit) throws InstanceManagementException {
    final List<LimitedInstanceInfoType> longRunningInstances = new ArrayList<LimitedInstanceInfoType>();
    Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    TenantProcessStoreImpl tenantProcessStore = (TenantProcessStoreImpl) bpelServer.getMultiTenantProcessStore().getTenantsProcessStore(tenantId);
    if (tenantProcessStore.getProcessConfigMap().size() <= 0) {
        return longRunningInstances.toArray(new LimitedInstanceInfoType[longRunningInstances.size()]);
    }
    String filter = "status=ACTIVE";
    if (!filter.contains(" pid=")) {
        filter = filter + getTenantsProcessList(tenantProcessStore.getProcessConfigMap().keySet());
    }
    if (log.isDebugEnabled()) {
        log.debug("Instance Filter:" + filter);
    }
    String orderBy = "started";
    final InstanceFilter instanceFilter = new InstanceFilter(filter, orderBy, limit);
    try {
        BpelDatabase bpelDb = bpelServer.getODEBPELServer().getBpelDb();
        bpelDb.exec(new BpelDatabase.Callable<Object>() {

            public Object run(BpelDAOConnection conn) throws InstanceManagementException {
                Collection<ProcessInstanceDAO> instances = conn.instanceQuery(instanceFilter);
                for (ProcessInstanceDAO piDAO : instances) {
                    longRunningInstances.add(createLimitedInstanceInfoObject(piDAO));
                }
                return null;
            }
        });
    } catch (Exception e) {
        String errMsg = "Error querying instances from database. Instance Filter:" + instanceFilter.toString();
        log.error(errMsg, e);
        throw new InstanceManagementException(errMsg, e);
    }
    return longRunningInstances.toArray(new LimitedInstanceInfoType[longRunningInstances.size()]);
}
Also used : InstanceFilter(org.apache.ode.bpel.common.InstanceFilter) BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) ArrayList(java.util.ArrayList) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) ProcessNotFoundException(org.apache.ode.bpel.pmapi.ProcessNotFoundException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessingException(org.apache.ode.bpel.pmapi.ProcessingException) InstanceManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException) ProcessInstanceDAO(org.apache.ode.bpel.dao.ProcessInstanceDAO) LimitedInstanceInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.LimitedInstanceInfoType) Collection(java.util.Collection)

Example 5 with LimitedInstanceInfoType

use of org.wso2.carbon.bpel.stub.mgt.types.LimitedInstanceInfoType in project carbon-business-process by wso2.

the class Instance method createLimitedInstanceInfoObject.

private LimitedInstanceInfoType createLimitedInstanceInfoObject(ProcessInstanceDAO instanceDAO) throws InstanceManagementException {
    LimitedInstanceInfoType instanceInfo = new LimitedInstanceInfoType();
    instanceInfo.setIid(Long.toString(instanceDAO.getInstanceId()));
    instanceInfo.setPid(instanceDAO.getProcess().getProcessId().toString());
    instanceInfo.setStatus(odeInstanceStatusToManagementAPIStatus(instanceDAO.getState()));
    instanceInfo.setDateLastActive(toCalendar(instanceDAO.getLastActiveTime()));
    instanceInfo.setDateStarted(toCalendar(instanceDAO.getCreateTime()));
    return instanceInfo;
}
Also used : LimitedInstanceInfoType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.LimitedInstanceInfoType)

Aggregations

LimitedInstanceInfoType (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.LimitedInstanceInfoType)4 InstanceManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.InstanceManagementException)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 InstanceFilter (org.apache.ode.bpel.common.InstanceFilter)1 BpelDAOConnection (org.apache.ode.bpel.dao.BpelDAOConnection)1 ProcessInstanceDAO (org.apache.ode.bpel.dao.ProcessInstanceDAO)1 BpelDatabase (org.apache.ode.bpel.engine.BpelDatabase)1 ProcessNotFoundException (org.apache.ode.bpel.pmapi.ProcessNotFoundException)1 ProcessingException (org.apache.ode.bpel.pmapi.ProcessingException)1 JSONObject (org.json.simple.JSONObject)1 TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)1 PaginatedInstanceList (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PaginatedInstanceList)1 LimitedInstanceInfoType (org.wso2.carbon.bpel.stub.mgt.types.LimitedInstanceInfoType)1