Search in sources :

Example 1 with ProcessList

use of com.centurylink.mdw.model.value.process.ProcessList in project mdw-designer by CenturyLinkCloud.

the class RuntimeDataAccessRest method getProcessInstanceList.

public ProcessList getProcessInstanceList(Map<String, String> criteria, Map<String, String> variables, int pageIndex, int pageSize, String orderBy) throws DataAccessException {
    try {
        String pathWithArgs = "Processes?mdw-app=designer";
        if (!getServer().isSchemaVersion61())
            pathWithArgs = "ProcessInstances?format=json";
        String criteriaParams = queryParams(criteria);
        if (criteriaParams.length() > 0)
            pathWithArgs += "&" + criteriaParams;
        String varParams = queryParams(variables);
        if (varParams.length() > 0)
            pathWithArgs += "&" + varParams;
        if (pageIndex > 0)
            pathWithArgs += "&pageIndex=" + pageIndex;
        if (pageSize != 0)
            pathWithArgs += "&pageSize=" + pageSize;
        if (orderBy != null) {
            pathWithArgs += "&orderBy=" + URLEncoder.encode(orderBy.trim(), "UTF-8");
        }
        String response = invokeResourceService(pathWithArgs);
        return new ProcessList(ProcessList.PROCESS_INSTANCES, response);
    } catch (IOException ex) {
        throw new DataAccessOfflineException(ex.getMessage(), ex);
    } catch (Exception ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) IOException(java.io.IOException) JSONException(org.json.JSONException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 2 with ProcessList

use of com.centurylink.mdw.model.value.process.ProcessList in project mdw-designer by CenturyLinkCloud.

the class ProcessInstanceContentProvider method getElements.

public Object[] getElements(Object inputElement) {
    WorkflowProcess processVersion = (WorkflowProcess) inputElement;
    if (instanceInfo == null) {
        DesignerProxy designerProxy = processVersion.getProject().getDesignerProxy();
        ProcessList instanceList = designerProxy.getProcessInstanceList(processVersion, filter.getProcessCriteria(), filter.getVariableCriteria(processVersion), pageIndex, filter.getPageSize(), sort.getOrderBy());
        instanceCount = instanceList.getTotal();
        instanceInfo = instanceList.getItems();
    }
    return instanceInfo.toArray(new ProcessInstanceVO[0]);
}
Also used : ProcessList(com.centurylink.mdw.model.value.process.ProcessList) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 3 with ProcessList

use of com.centurylink.mdw.model.value.process.ProcessList in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getProcessInstanceList.

public ProcessList getProcessInstanceList(Map<String, String> pMap, int pageIndex, int pageSize, ProcessVO procdef, String orderBy) throws DataAccessException {
    if (procdef != null && procdef.isRemote()) {
        RuntimeDataAccess runTimeInfo = remoteAccess.get(procdef.getRemoteServer()).getRuntimeDataAccess();
        ProcessList ret = runTimeInfo.getProcessInstanceList(pMap, pageIndex, pageSize, orderBy);
        for (ProcessInstanceVO one : ret.getProcesses()) {
            one.setRemoteServer(procdef.getRemoteServer());
        }
        return ret;
    } else {
        return rtinfo.getProcessInstanceList(pMap, pageIndex, pageSize, orderBy);
    }
}
Also used : RuntimeDataAccess(com.centurylink.mdw.dataaccess.RuntimeDataAccess) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 4 with ProcessList

use of com.centurylink.mdw.model.value.process.ProcessList in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getChildProcessInstance.

/**
 * Does not work for embedded subprocs in asset processes.
 */
public List<ProcessInstanceVO> getChildProcessInstance(Long processInstanceId, ProcessVO childProcess, ProcessVO parentProcess) throws DataAccessException {
    Map<String, String> pMap = new HashMap<>();
    if (childProcess.isRemote()) {
        RuntimeDataAccess runTimeInfo = remoteAccess.get(childProcess.getRemoteServer()).getRuntimeDataAccess();
        List<ProcessInstanceVO> ret;
        String ownerType = OwnerType.PROCESS_INSTANCE;
        if (parentProcess.isRemote()) {
            if (!parentProcess.getRemoteServer().equals(childProcess.getRemoteServer()))
                ownerType = parentProcess.getRemoteServer();
        } else {
            ownerType = currentServer.getApplicationName();
        }
        pMap.put("owner", ownerType);
        pMap.put("ownerId", processInstanceId.toString());
        pMap.put(PROCESSID, childProcess.getProcessId().toString());
        ProcessList procList = runTimeInfo.getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, null);
        ret = procList.getProcesses();
        for (ProcessInstanceVO one : ret) {
            one.setRemoteServer(childProcess.getRemoteServer());
        }
        return ret;
    } else {
        pMap.put("owner", OwnerType.PROCESS_INSTANCE);
        pMap.put("ownerId", processInstanceId.toString());
        pMap.put(PROCESSID, childProcess.getProcessId().toString());
        return getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, childProcess, null).getProcesses();
    }
}
Also used : RuntimeDataAccess(com.centurylink.mdw.dataaccess.RuntimeDataAccess) HashMap(java.util.HashMap) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 5 with ProcessList

use of com.centurylink.mdw.model.value.process.ProcessList in project mdw-designer by CenturyLinkCloud.

the class RuntimeDataAccessRest method deleteProcessInstances.

public int deleteProcessInstances(List<Long> processInstanceIds) throws DataAccessException {
    try {
        List<ProcessInstanceVO> instances = new ArrayList<ProcessInstanceVO>();
        for (Long id : processInstanceIds) instances.add(new ProcessInstanceVO(id));
        ProcessList processList = new ProcessList(ProcessList.PROCESS_INSTANCES, instances);
        if (getServer().getSchemaVersion() >= 6000) {
            try {
                getServer().delete("Processes", processList.getJson().toString(2));
            } catch (IOException ex) {
                throw new DataAccessOfflineException("Unable to connect to " + getServer().getServiceUrl(), ex);
            }
        } else {
            ActionRequestMessage actionRequest = new ActionRequestMessage();
            actionRequest.setAction("DeleteProcessInstances");
            actionRequest.addParameter("appName", "MDW Designer");
            JSONObject msgJson = actionRequest.getJson();
            msgJson.put(processList.getJsonName(), processList.getJson());
            invokeActionService(msgJson.toString(2));
        }
        return processList.getCount();
    } catch (XmlException ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    } catch (JSONException ex) {
        throw new DataAccessException(ex.getMessage(), ex);
    }
}
Also used : DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) JSONObject(org.json.JSONObject) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) XmlException(org.apache.xmlbeans.XmlException) ArrayList(java.util.ArrayList) ActionRequestMessage(com.centurylink.mdw.common.service.types.ActionRequestMessage) JSONException(org.json.JSONException) IOException(java.io.IOException) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Aggregations

ProcessList (com.centurylink.mdw.model.value.process.ProcessList)6 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)3 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)3 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)3 IOException (java.io.IOException)3 XmlException (org.apache.xmlbeans.XmlException)3 JSONException (org.json.JSONException)3 RuntimeDataAccess (com.centurylink.mdw.dataaccess.RuntimeDataAccess)2 ActionRequestMessage (com.centurylink.mdw.common.service.types.ActionRequestMessage)1 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)1 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 JSONObject (org.json.JSONObject)1