Search in sources :

Example 1 with CustomAttributeVO

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

the class DesignerDataModel method reloadRuleSets.

public void reloadRuleSets(DesignerDataAccess dao) throws DataAccessException, RemoteException {
    rulesets = new HashMap<String, RuleSetVO>();
    rulesetsById = new HashMap<Long, RuleSetVO>();
    if (dao == null)
        return;
    List<RuleSetVO> flatList = dao.getRuleSets();
    rulesetCustomAttributes = new HashMap<String, CustomAttributeVO>();
    for (RuleSetVO one : flatList) {
        String key = getResourceKey(one);
        RuleSetVO last = rulesets.get(key);
        if (last != null) {
            last.setPrevVersion(one);
            one.setNextVersion(last);
        } else {
            one.setNextVersion(null);
            if (one.getLanguage() != null && !rulesetCustomAttributes.containsKey(one.getLanguage())) {
                CustomAttributeVO custAttrVO = dao.getCustomAttribute("RULE_SET", one.getLanguage());
                rulesetCustomAttributes.put(one.getLanguage(), custAttrVO);
            }
            rulesets.put(key, one);
        }
        rulesetsById.put(one.getId(), one);
        one.setPrevVersion(null);
    }
}
Also used : CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO)

Example 2 with CustomAttributeVO

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

the class WorkflowAssetCustomSection method drawWidgets.

public void drawWidgets(Composite composite, WorkflowElement selection) {
    workflowAsset = (WorkflowAsset) selection;
    // attr definition text area
    customAttrsPropEditor = new PropertyEditor(workflowAsset, PropertyEditor.TYPE_TEXT);
    customAttrsPropEditor.setLabel("Custom Attr Definition\n(Pagelet Syntax)");
    customAttrsPropEditor.setMultiLine(true);
    customAttrsPropEditor.setWidth(475);
    customAttrsPropEditor.setHeight(80);
    customAttrsPropEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            String def = newValue == null || ((String) newValue).length() == 0 ? null : (String) newValue;
            if (customAttribute == null)
                customAttribute = new CustomAttributeVO("RULE_SET", workflowAsset.getLanguage());
            customAttribute.setDefinition(def);
        }
    });
    customAttrsPropEditor.render(composite);
    // roles picklist
    rolesPropertyEditor = new PropertyEditor(workflowAsset, PropertyEditor.TYPE_PICKLIST);
    rolesPropertyEditor.setValueConverter(new ListConverter());
    rolesPropertyEditor.setLabel("Custom Attr Edit Roles:Unselected~Permitted");
    PluginDataAccess dataAccess = workflowAsset.getProject().getDataAccess();
    rolesPropertyEditor.setValueOptions(dataAccess.getRoleNames(false));
    rolesPropertyEditor.addValueChangeListener(new ValueChangeListener() {

        @SuppressWarnings("unchecked")
        public void propertyValueChanged(Object newValue) {
            if (customAttribute == null)
                customAttribute = new CustomAttributeVO("RULE_SET", workflowAsset.getLanguage());
            if (newValue == null)
                customAttribute.setRoles(null);
            else
                customAttribute.setRoles((List<String>) newValue);
        }
    });
    rolesPropertyEditor.render(composite);
    rolesPropertyEditor.setValue("");
    // save button
    savePropertyEditor = new PropertyEditor(workflowAsset, PropertyEditor.TYPE_BUTTON);
    savePropertyEditor.setLabel("Save");
    savePropertyEditor.setComment("Save Custom Attrs:");
    savePropertyEditor.setWidth(65);
    savePropertyEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            saveCustomAttribute();
        }
    });
    savePropertyEditor.render(composite);
    // help link
    helpLinkPropertyEditor = new PropertyEditor(workflowAsset, PropertyEditor.TYPE_LINK);
    helpLinkPropertyEditor.setLabel("Custom Attributes Help");
    helpLinkPropertyEditor.render(composite);
}
Also used : ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) ListConverter(com.centurylink.mdw.plugin.designer.properties.convert.ListConverter) PluginDataAccess(com.centurylink.mdw.plugin.designer.PluginDataAccess)

Example 3 with CustomAttributeVO

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

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

the class AssetDrivenActivityCustomSection method setSelection.

@Override
public void setSelection(WorkflowElement selection) {
    activity = (Activity) selection;
    CustomAttributeVO customAttrVO = determineCustomAttr(activity);
    if (propertyEditors != null) {
        for (PropertyEditor propertyEditor : propertyEditors) propertyEditor.dispose();
    }
    if (warningLabel != null)
        warningLabel.dispose();
    if (commentLabel != null)
        commentLabel.dispose();
    if (clearBtnPropertyEditor != null)
        clearBtnPropertyEditor.dispose();
    if (customAttrVO == null || StringHelper.isEmpty(customAttrVO.getDefinition())) {
        warningLabel = new Label(composite, SWT.NONE);
        warningLabel.setText("No custom attributes defined for workflow asset type" + (customAttrVO == null ? "." : ": " + customAttrVO.getCategorizer()));
    } else {
        commentLabel = new Label(composite, SWT.NONE);
        GridData gd = new GridData(SWT.LEFT);
        gd.horizontalSpan = PropertyEditor.COLUMNS;
        commentLabel.setLayoutData(gd);
        commentLabel.setText("Enter the custom attribute values that must be matched at runtime for the asset to be in effect.");
        valueMap = new HashMap<>();
        String attr = activity.getAttribute("CustomAttributes");
        if (attr != null)
            valueMap = StringHelper.parseMap(attr);
        // TODO: update is broken
        // setAttribute() must be called on property update (must not update
        // activity directly)
        propertyEditors = new PropertyEditorList(activity, customAttrVO.getDefinition());
        for (PropertyEditor propertyEditor : propertyEditors) {
            propertyEditor.setReadOnly(true);
            propertyEditor.render(composite);
            propertyEditor.setValue(valueMap.get(propertyEditor.getName()));
        }
        // clear button
        clearBtnPropertyEditor = new PropertyEditor(activity, PropertyEditor.TYPE_BUTTON);
        clearBtnPropertyEditor.setLabel("Clear");
        clearBtnPropertyEditor.setComment("Remove Criteria:");
        clearBtnPropertyEditor.setWidth(65);
        clearBtnPropertyEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                clear();
            }
        });
        clearBtnPropertyEditor.render(composite);
    }
    composite.layout(true);
}
Also used : PropertyEditorList(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 5 with CustomAttributeVO

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

the class WorkflowAssetAttributesSection method select.

public boolean select(Object toTest) {
    // currently only definition docs supported
    if (!(toTest instanceof WorkflowAsset))
        return false;
    WorkflowAsset asset = (WorkflowAsset) toTest;
    if (!asset.getProject().isMdw5())
        return false;
    CustomAttributeVO customAttribute = asset.getCustomAttribute();
    if (customAttribute == null || !customAttribute.hasDefinition())
        return false;
    if (customAttribute.hasRoles()) {
        // check authorization
        for (String role : customAttribute.getRoles()) {
            if (asset.isUserAuthorized(role))
                return true;
        }
        return false;
    }
    return true;
}
Also used : CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset)

Aggregations

CustomAttributeVO (com.centurylink.mdw.model.value.attribute.CustomAttributeVO)7 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)3 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)3 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)2 ProcessExporter (com.centurylink.mdw.dataaccess.ProcessExporter)2 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)2 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)2 PropertyEditorList (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList)2 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ImporterExporterJson (com.centurylink.mdw.dataaccess.file.ImporterExporterJson)1 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)1 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)1 PluginDataAccess (com.centurylink.mdw.plugin.designer.PluginDataAccess)1 ListConverter (com.centurylink.mdw.plugin.designer.properties.convert.ListConverter)1 AssetLocator (com.centurylink.mdw.plugin.designer.properties.editor.AssetLocator)1 WorkflowAssetEditor (com.centurylink.mdw.plugin.designer.properties.editor.WorkflowAssetEditor)1 GridData (org.eclipse.swt.layout.GridData)1 Label (org.eclipse.swt.widgets.Label)1