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);
}
}
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);
}
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;
}
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);
}
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;
}
Aggregations