Search in sources :

Example 1 with AssetLocator

use of com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator in project mdw-designer by CenturyLinkCloud.

the class AssetDrivenActivityCustomSection method determineCustomAttr.

private CustomAttributeVO determineCustomAttr(Activity activity) {
    PropertyEditorList propEditorList = new PropertyEditorList(activity);
    for (PropertyEditor propertyEditor : propEditorList) {
        if (propertyEditor instanceof WorkflowAssetEditor) {
            WorkflowAssetEditor assetEditor = (WorkflowAssetEditor) propertyEditor;
            propertyEditor.setValue(activity);
            AssetLocator locator = new AssetLocator(assetEditor.getElement(), assetEditor.getLocatorType());
            WorkflowAsset asset = (WorkflowAsset) locator.assetFromAttr(activity.getAttribute(assetEditor.getAttributeName()));
            if (asset != null) {
                // language definitively determined by selected asset
                return activity.getProject().getDataAccess().getAssetCustomAttribute(asset.getLanguage());
            } else {
                // guess language based on presence of custom attributes
                for (String language : assetEditor.getAssetTypes()) {
                    CustomAttributeVO customAttr = activity.getProject().getDataAccess().getAssetCustomAttribute(language);
                    if (customAttr != null && !StringHelper.isEmpty(customAttr.getDefinition()))
                        return customAttr;
                }
            }
        }
    }
    return null;
}
Also used : PropertyEditorList(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList) WorkflowAssetEditor(com.centurylink.mdw.plugin.designer.properties.editor.WorkflowAssetEditor) AssetLocator(com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator) CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 2 with AssetLocator

use of com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method getSubProcessInstances.

public List<ProcessInstanceVO> getSubProcessInstances(ProcessInstanceVO parentEmbeddedProcessInstance, Activity activity) {
    try {
        Long parentProcessInstanceId = parentEmbeddedProcessInstance.getId();
        ProcessVO subProcessVO = new ProcessVO();
        String subProcName = activity.getAttribute(WorkAttributeConstant.PROCESS_NAME);
        String subProcVer = activity.getAttribute(WorkAttributeConstant.PROCESS_VERSION);
        WorkflowProcess subProc = new AssetLocator(activity, AssetLocator.Type.PROCESS).getProcessVersion(new AssetVersionSpec(subProcName, subProcVer));
        subProcessVO.setProcessId(subProc == null ? 0L : subProc.getId());
        subProcessVO.setProcessName(subProcName);
        return dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, new ProcessVO());
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Load SubProcess Instances", project);
        return Collections.emptyList();
    }
}
Also used : AssetLocator(com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException)

Example 3 with AssetLocator

use of com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator in project mdw-designer by CenturyLinkCloud.

the class DesignerProxy method getSubProcessInstances.

public List<ProcessInstanceVO> getSubProcessInstances(WorkflowProcess parentProcess, Activity activity) {
    try {
        Long parentProcessInstanceId = parentProcess.getProcessInstance().getId();
        if (activity.isHeterogeneousSubProcInvoke()) {
            List<ProcessInstanceVO> insts = new ArrayList<>();
            String procMapStr = activity.getAttribute(WorkAttributeConstant.PROCESS_MAP);
            if (procMapStr != null && !procMapStr.isEmpty()) {
                List<String[]> procMap = StringHelper.parseTable(procMapStr, ',', ';', 3);
                for (String[] row : procMap) {
                    ProcessVO subProcessVO = new ProcessVO();
                    AssetVersionSpec spec = new AssetVersionSpec(row[1], row[2] == null ? "0" : row[2]);
                    AssetLocator locator = new AssetLocator(activity, AssetLocator.Type.PROCESS);
                    WorkflowProcess found = locator.getProcessVersion(spec);
                    if (found != null) {
                        subProcessVO.setProcessId(found.getId());
                        subProcessVO.setProcessName(found.getName());
                        insts.addAll(dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, parentProcess.getProcessVO()));
                    } else {
                        PluginMessages.log(new Exception("SubProcess not found: " + row[1] + " v" + row[2]));
                    }
                }
            }
            return insts;
        } else if (activity.isManualTask()) {
            List<ProcessInstanceVO> insts = new ArrayList<>();
            String procMapStr = activity.getAttribute(TaskAttributeConstant.SERVICE_PROCESSES);
            if (procMapStr != null && !procMapStr.isEmpty()) {
                Map<String, String> pMap = new HashMap<>();
                pMap.put("owner", OwnerType.TASK_INSTANCE);
                StringBuilder sb = new StringBuilder();
                sb.append("(");
                if (activity.getTaskInstances() != null) {
                    for (TaskInstanceVO taskInst : activity.getTaskInstances()) {
                        if (sb.length() > 1)
                            sb.append(",");
                        sb.append(taskInst.getTaskInstanceId().toString());
                    }
                }
                sb.append(")");
                pMap.put("ownerIdList", sb.toString());
                insts = dataAccess.getDesignerDataAccess().getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, parentProcess.getProcessVO(), null).getItems();
            }
            return insts;
        } else {
            ProcessVO subProcessVO = new ProcessVO();
            String subProcName = activity.getAttribute(WorkAttributeConstant.PROCESS_NAME);
            String subProcVer = activity.getAttribute(WorkAttributeConstant.PROCESS_VERSION);
            AssetVersionSpec spec = new AssetVersionSpec(subProcName, subProcVer == null ? "0" : subProcVer);
            AssetLocator locator = new AssetLocator(activity, AssetLocator.Type.PROCESS);
            WorkflowProcess subProc = locator.getProcessVersion(spec);
            subProcessVO.setProcessId((subProc == null || subProc.getId() == null) ? 0L : subProc.getId());
            subProcessVO.setProcessName(activity.getAttribute(WorkAttributeConstant.PROCESS_NAME));
            // handle alias subprocs
            String subprocAliasProcessId = activity.getAttribute(WorkAttributeConstant.ALIAS_PROCESS_ID);
            if (subprocAliasProcessId != null)
                subProcessVO = this.getProcessVO(new Long(subprocAliasProcessId));
            return dataAccess.getDesignerDataAccess().getChildProcessInstance(parentProcessInstanceId, subProcessVO, parentProcess.getProcessVO());
        }
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Load SubProcess Instances (P=" + parentProcess.getId() + ",A=" + activity.getId() + ")", project);
        return Collections.emptyList();
    }
}
Also used : AssetLocator(com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator) ArrayList(java.util.ArrayList) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) JSONException(org.json.JSONException) TranslationException(com.centurylink.mdw.common.exception.TranslationException) AuthenticationException(com.centurylink.mdw.auth.AuthenticationException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) DataAccessOfflineException(com.centurylink.mdw.dataaccess.DataAccessOfflineException) ZipException(java.util.zip.ZipException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) TaskInstanceVO(com.centurylink.mdw.model.value.task.TaskInstanceVO) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) ArrayList(java.util.ArrayList) List(java.util.List) ProcessList(com.centurylink.mdw.model.value.process.ProcessList) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Map(java.util.Map) HashMap(java.util.HashMap) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Aggregations

AssetLocator (com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator)3 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)2 TranslationException (com.centurylink.mdw.common.exception.TranslationException)2 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)2 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)2 AssetVersionSpec (com.centurylink.mdw.model.value.attribute.AssetVersionSpec)2 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)2 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 RemoteException (java.rmi.RemoteException)2 ZipException (java.util.zip.ZipException)2 XmlException (org.apache.xmlbeans.XmlException)2 JSONException (org.json.JSONException)2 CustomAttributeVO (com.centurylink.mdw.model.value.attribute.CustomAttributeVO)1 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)1 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)1 TaskInstanceVO (com.centurylink.mdw.model.value.task.TaskInstanceVO)1 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)1