Search in sources :

Example 6 with AssetVersionSpec

use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec 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 7 with AssetVersionSpec

use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec 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)

Example 8 with AssetVersionSpec

use of com.centurylink.mdw.model.value.attribute.AssetVersionSpec in project mdw-designer by CenturyLinkCloud.

the class TableEditor method createTable.

private Table createTable(Composite parent) {
    int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
    final Table table = new Table(parent, style);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    if (horizontalSpan == 0)
        gridData.horizontalSpan = getLabel() == null ? 3 : 2;
    else
        gridData.horizontalSpan = horizontalSpan;
    if (getType().equals(TYPE_TABLE))
        gridData.heightHint = 100;
    if (getHeight() != SWT.DEFAULT)
        gridData.heightHint = getHeight();
    if (getWidth() != DEFAULT_VALUE_WIDTH)
        gridData.widthHint = getWidth();
    table.setLayoutData(gridData);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    for (int i = 0; i < columnSpecs.size(); i++) {
        ColumnSpec colSpec = columnSpecs.get(i);
        int colStyle = SWT.LEFT | colSpec.style;
        if (colSpec.readOnly)
            colStyle = colStyle | SWT.READ_ONLY;
        TableColumn column = new TableColumn(table, colStyle, i);
        column.setText(colSpec.label);
        if (colSpec.hidden) {
            column.setWidth(0);
            column.setResizable(false);
        } else {
            column.setWidth(colSpec.width);
            column.setResizable(colSpec.resizable);
        }
        if (colSpec.height != ColumnSpec.DEFAULT_ROW_HEIGHT) {
            table.addListener(SWT.MeasureItem, new RowHeightListener(colSpec.height));
        }
    }
    if (isFillWidth()) {
        table.addControlListener(new ControlAdapter() {

            @Override
            public void controlResized(ControlEvent e) {
                int tableWidth = table.getBounds().width;
                int cumulative = 0;
                TableColumn[] tableColumns = table.getColumns();
                for (int i = 0; i < tableColumns.length; i++) {
                    if (i == tableColumns.length - 1)
                        tableColumns[i].setWidth(tableWidth - cumulative - 5);
                    cumulative += tableColumns[i].getWidth();
                }
            }
        });
    }
    table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            fireValueChanged(e.item.getData(), false);
        }
    });
    // double-click handler for asset rows
    int assetColIdx = -1;
    for (int i = 0; i < columnSpecs.size(); i++) {
        if (WorkflowAssetEditor.TYPE_ASSET.equals(columnSpecs.get(i).type))
            assetColIdx = i;
    }
    if (assetColIdx != -1) {
        final int colIdx = assetColIdx;
        addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                if (newValue instanceof DefaultRowImpl) {
                    // is the case for double-click
                    DefaultRowImpl row = (DefaultRowImpl) newValue;
                    String name = row.getColumnValues()[colIdx];
                    String ver = "0";
                    if (columnSpecs.size() > colIdx + 1 && (PROCESS_VERSION.equals(columnSpecs.get(colIdx + 1).source) || "AssetVersion".equals(columnSpecs.get(colIdx + 1).source)))
                        ver = row.getColumnValues()[colIdx + 1];
                    if (name != null && ver != null) {
                        AssetVersionSpec spec = new AssetVersionSpec(name, ver);
                        AssetLocator.Type type = AssetLocator.Type.ASSET;
                        if (PROCESS.equals(columnSpecs.get(colIdx).source))
                            type = AssetLocator.Type.PROCESS;
                        else if (RuleSetVO.TASK.equals(columnSpecs.get(colIdx).source))
                            type = AssetLocator.Type.TASKTEMPLATE;
                        AssetLocator locator = new AssetLocator(getElement(), type);
                        locator.openAsset(spec);
                    }
                }
            }
        });
    }
    return table;
}
Also used : Table(org.eclipse.swt.widgets.Table) ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) TableColumn(org.eclipse.swt.widgets.TableColumn) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

AssetVersionSpec (com.centurylink.mdw.model.value.attribute.AssetVersionSpec)8 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)4 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 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)2 AssetLocator (com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator)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 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 JSONException (org.json.JSONException)2 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)1 ProcessList (com.centurylink.mdw.model.value.process.ProcessList)1