Search in sources :

Example 1 with AssetVersionSpec

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

the class WorkflowAssetEditor method render.

@Override
public void render(Composite parent) {
    label = new Label(parent, SWT.NONE);
    label.setText(attributeLabel + ":");
    treeCombo = new CTreeCombo(parent, SWT.BORDER | SWT.FULL_SELECTION);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.widthHint = comboWidth;
    gd.heightHint = 16;
    treeCombo.setLayoutData(gd);
    fillTreeCombo();
    treeCombo.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            CTreeComboItem[] selItems = treeCombo.getSelection();
            if (selItems.length == 1) {
                CTreeComboItem selItem = selItems[0];
                if (selItem.getParentItem() == null) {
                    // ignore package selection
                    treeCombo.setSelection(new CTreeComboItem[0]);
                } else {
                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException ex) {
                    }
                    // ** set asset
                    WorkflowPackage pkg = getProject().getPackage(selItem.getParentItem().getText());
                    if (pkg == null) {
                        workflowAsset = null;
                    } else {
                        AssetLocator assetLocator = new AssetLocator(getElement(), getLocatorType());
                        workflowAsset = assetLocator.getAssetVersion(selItem.getText(), pkg);
                    }
                    link.setText(getLinkLabel());
                    fireValueChanged(new AssetLocator(getElement(), getLocatorType()).attrFromAsset(workflowAsset));
                    // selecting the asset also selects the version
                    updateVersionAttribute(workflowAsset);
                    treeCombo.dropDown(false);
                }
            }
        }
    });
    treeCombo.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event event) {
            if (treeCombo.getSelection().length == 0 && !suppressFire) {
                // triggered when something was typed in the combo
                // instead of selecting -- use it verbatim
                // note: also triggered on selection, but immediately
                // followed by SWT.Selection event, so no harm done
                // ** set asset
                workflowAsset = null;
                link.setText("");
                AssetVersionSpec versionSpec = AssetVersionSpec.parse(treeCombo.getText().trim());
                String oldName = getElement().getAttribute(attributeName);
                String newName = versionSpec.getName();
                boolean nameChanged = oldName == null ? newName != null && newName.length() > 0 : !oldName.equals(newName);
                if (nameChanged)
                    fireValueChanged(newName);
                String oldVer = readVersionAttribute();
                String newVer = "".equals(newName) ? "" : versionSpec.getVersion();
                boolean verChanged = oldVer == null ? newVer != null && newVer.length() > 0 : !oldVer.equals(newVer);
                if (verChanged)
                    updateVersionAttribute(newVer);
            }
        }
    });
    link = new Link(parent, SWT.SINGLE);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 75;
    link.setLayoutData(gd);
    link.setText(getLinkLabel());
    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (workflowAsset == null) {
                workflowAsset = createWorkflowAsset();
                fillTreeCombo();
                if (workflowAsset != null) {
                    treeCombo.setText(workflowAsset.getName());
                    fireValueChanged(new AssetLocator(getElement(), getLocatorType()).attrFromAsset(workflowAsset));
                    updateVersionAttribute(workflowAsset);
                }
            } else {
                openWorkflowAsset();
            }
        }
    });
    spacer = new Label(parent, SWT.NONE);
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) Listener(org.eclipse.swt.widgets.Listener) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) CTreeCombo(com.centurylink.swt.widgets.CTreeCombo) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Link(org.eclipse.swt.widgets.Link)

Example 2 with AssetVersionSpec

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

the class WorkflowAssetEditor method updateVersionAttribute.

private void updateVersionAttribute(WorkflowElement workflowAsset) {
    AssetVersionSpec versionSpec = AssetVersionSpec.parse(workflowAsset.getLabel());
    String versionAttr = null;
    if (isProcess()) {
        if (getProject().checkRequiredVersion(5, 5) && !(getElement() instanceof Activity && ((Activity) getElement()).isOldMultipleSubProcInvoke())) {
            if (MdwPlugin.getSettings().isInferSmartSubprocVersionSpec())
                versionAttr = AssetVersionSpec.getDefaultSmartVersionSpec(versionSpec.getVersion());
            else
                versionAttr = versionSpec.getVersion();
        } else {
            // pre-5.5
            versionAttr = String.valueOf(((WorkflowProcess) workflowAsset).getVersion());
        // compatibility
        }
        getElement().setAttribute(WorkAttributeConstant.PROCESS_VERSION, versionAttr);
    } else if (// assets only save
    getProject().checkRequiredVersion(5, 5)) // version for 5.5
    {
        if (MdwPlugin.getSettings().isInferSmartSubprocVersionSpec())
            versionAttr = AssetVersionSpec.getDefaultSmartVersionSpec(versionSpec.getVersion());
        else
            versionAttr = versionSpec.getVersion();
        getElement().setAttribute(getAssetVersionAttributeName(), versionAttr);
    }
}
Also used : Activity(com.centurylink.mdw.plugin.designer.model.Activity) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 3 with AssetVersionSpec

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

the class AssetLocator method getWorkflowAssetVersion.

private WorkflowAsset getWorkflowAssetVersion(String versionSpec, List<WorkflowAsset> assets) {
    AssetVersionSpec spec = AssetVersionSpec.parse(versionSpec);
    boolean isDefaultSmart = isDefaultSmartFormat(spec.getVersion());
    WorkflowAsset match = null;
    for (WorkflowAsset asset : assets) {
        if (asset.getName().matches(spec.getName())) {
            if (asset.getVersionString().equals(spec.getVersion())) {
                match = asset;
                break;
            } else if ((AssetVersionSpec.VERSION_LATEST.equals(spec.getVersion()) || (isDefaultSmart && asset.meetsVersionSpec(spec.getVersion()))) && (match == null || asset.getVersion() > match.getVersion())) {
                match = asset;
            }
        }
    }
    return match;
}
Also used : WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec)

Example 4 with AssetVersionSpec

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

the class AssetLocator method getTaskTemplateVersion.

private TaskTemplate getTaskTemplateVersion(String versionSpec, List<TaskTemplate> taskTemplates) {
    AssetVersionSpec spec = AssetVersionSpec.parse(versionSpec);
    boolean isDefaultSmart = isDefaultSmartFormat(spec.getVersion());
    TaskTemplate match = null;
    for (TaskTemplate taskTemplate : taskTemplates) {
        if (taskTemplate.getName().matches(spec.getName())) {
            if (taskTemplate.getVersionString().equals(spec.getVersion())) {
                match = taskTemplate;
                break;
            } else if ((AssetVersionSpec.VERSION_LATEST.equals(spec.getVersion()) || (isDefaultSmart && taskTemplate.meetsVersionSpec(spec.getVersion()))) && (match == null || taskTemplate.getVersion() > match.getVersion())) {
                match = taskTemplate;
            }
        }
    }
    return match;
}
Also used : TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec)

Example 5 with AssetVersionSpec

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

the class AssetLocator method getProcessVersion.

private WorkflowProcess getProcessVersion(String versionSpec, List<WorkflowProcess> processes) {
    AssetVersionSpec spec = AssetVersionSpec.parse(versionSpec);
    boolean isDefaultSmart = isDefaultSmartFormat(spec.getVersion());
    WorkflowProcess match = null;
    for (WorkflowProcess process : processes) {
        if (process.getName().equals(spec.getName())) {
            if (process.getVersionString().equals(spec.getVersion())) {
                match = process;
                break;
            } else if ((AssetVersionSpec.VERSION_LATEST.equals(spec.getVersion()) || (isDefaultSmart && process.meetsVersionSpec(spec.getVersion()))) && (match == null || process.getVersion() > match.getVersion())) {
                match = process;
            }
        }
    }
    return match;
}
Also used : AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

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