use of com.centurylink.mdw.bpm.PropertyGroupDocument.PropertyGroup in project mdw-designer by CenturyLinkCloud.
the class PackageConfigurationSection method updatePackageMetaContent.
private void updatePackageMetaContent() throws XmlException, JSONException, IOException {
if (!workflowPackage.getProject().isOldNamespaces()) {
if (workflowPackage.getMetaContent() != null && workflowPackage.getMetaContent().trim().startsWith("{")) {
PackageVO metaPkg = new PackageVO(new JSONObject(workflowPackage.getMetaContent()));
List<AttributeVO> attributes = null;
if (propertyGroups != null) {
attributes = new ArrayList<>();
for (PropertyGroup propGroup : propertyGroups) {
String group = propGroup.getName();
for (Property prop : propGroup.getPropertyList()) {
AttributeVO attribute = new AttributeVO(prop.getName(), prop.getStringValue());
if (group != null)
attribute.setAttributeGroup(group);
attributes.add(attribute);
}
}
}
metaPkg.setAttributes(attributes);
workflowPackage.setMetaContent(metaPkg.getJson(false).toString(2));
} else if (workflowPackage.getSchemaVersion() >= DataAccess.schemaVersion61) {
List<AttributeVO> attributes = null;
Yaml yaml = new Yaml();
Map<String, Object> map = (Map<String, Object>) yaml.load(workflowPackage.getMetaContent());
PackageVO metaPkg = new PackageVO(map);
if (propertyGroups != null) {
attributes = new ArrayList<>();
for (PropertyGroup propGroup : propertyGroups) {
String group = propGroup.getName();
for (Property prop : propGroup.getPropertyList()) {
AttributeVO attribute = new AttributeVO(prop.getName(), prop.getStringValue());
if (group != null)
attribute.setAttributeGroup(group);
attributes.add(attribute);
}
}
}
metaPkg.setAttributes(attributes);
workflowPackage.setMetaContent(metaPkg.getJson(false).toString(2));
} else {
PackageDocument pkgDefDoc = null;
if (workflowPackage.getMetaContent() == null || workflowPackage.getMetaContent().isEmpty()) {
pkgDefDoc = PackageDocument.Factory.newInstance();
} else {
if (workflowPackage.getMetaContent().startsWith("<bpm:package") || workflowPackage.getMetaContent().startsWith("<package")) {
pkgDefDoc = PackageDocument.Factory.parse(workflowPackage.getMetaContent());
} else {
pkgDefDoc = PackageDocument.Factory.newInstance();
}
}
if (pkgDefDoc.getPackage() == null)
pkgDefDoc.addNewPackage();
if (pkgDefDoc.getPackage().getApplicationProperties() == null)
pkgDefDoc.getPackage().addNewApplicationProperties();
pkgDefDoc.getPackage().getApplicationProperties().setPropertyGroupArray(propertyGroups.toArray(new PropertyGroup[0]));
String procDefStr = pkgDefDoc.xmlText(new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(2));
workflowPackage.setMetaContent(procDefStr);
}
} else {
ProcessDefinitionDocument procDefDoc;
if (workflowPackage.getMetaContent() == null || workflowPackage.getMetaContent().isEmpty())
procDefDoc = ProcessDefinitionDocument.Factory.newInstance();
else
procDefDoc = ProcessDefinitionDocument.Factory.parse(workflowPackage.getMetaContent(), Compatibility.namespaceOptions());
if (procDefDoc.getProcessDefinition() == null)
procDefDoc.addNewProcessDefinition();
if (procDefDoc.getProcessDefinition().getApplicationProperties() == null)
procDefDoc.getProcessDefinition().addNewApplicationProperties();
procDefDoc.getProcessDefinition().getApplicationProperties().setPropertyGroupArray(propertyGroups.toArray(new PropertyGroup[0]));
String procDefStr = DesignerCompatibility.getInstance().getOldProcessDefinition(procDefDoc);
workflowPackage.setMetaContent(procDefStr);
}
}
use of com.centurylink.mdw.bpm.PropertyGroupDocument.PropertyGroup in project mdw-designer by CenturyLinkCloud.
the class PackageConfigurationSection method getPropertyGroups.
private List<PropertyGroup> getPropertyGroups() {
if (// empty
workflowPackage.getMetaContent() == null && !workflowPackage.isDefaultPackage()) // string
// signifies
// already
// loaded
{
try {
PackageVO packageVO = workflowPackage.getProject().getDesignerProxy().getDesignerDataAccess().loadPackage(workflowPackage.getId(), false);
workflowPackage.setMetaContent(packageVO.getMetaContent() == null ? "" : packageVO.getMetaContent());
} catch (Exception ex) {
PluginMessages.uiError(getShell(), ex, "Package Config", workflowPackage.getProject());
}
}
if (workflowPackage.getMetaContent() == null || workflowPackage.getMetaContent().trim().length() == 0) {
return new ArrayList<>();
} else {
ApplicationProperties appProps = null;
try {
if (workflowPackage.getMetaContent().trim().startsWith("{")) {
List<PropertyGroup> propGroups = new ArrayList<>();
PackageVO metaPkg = new PackageVO(new JSONObject(workflowPackage.getMetaContent()));
if (metaPkg.getAttributes() != null) {
Map<String, List<AttributeVO>> groupedAttrs = metaPkg.getAttributesByGroup();
for (Map.Entry<String, List<AttributeVO>> group : groupedAttrs.entrySet()) {
PropertyGroup propGroup = PropertyGroup.Factory.newInstance();
if (group.getKey() != null)
propGroup.setName(group.getKey());
for (AttributeVO groupAttr : group.getValue()) {
Property prop = propGroup.addNewProperty();
prop.setName(groupAttr.getAttributeName());
prop.setStringValue(groupAttr.getAttributeValue());
}
propGroups.add(propGroup);
}
}
return propGroups;
} else if (workflowPackage.getSchemaVersion() >= DataAccess.schemaVersion61) {
List<PropertyGroup> propGroups = new ArrayList<>();
Yaml yaml = new Yaml();
Map<String, Object> map = (Map<String, Object>) yaml.load(workflowPackage.getMetaContent());
PackageVO metaPkg = new PackageVO(map);
if (metaPkg.getAttributes() != null) {
Map<String, List<AttributeVO>> groupedAttrs = metaPkg.getAttributesByGroup();
for (Map.Entry<String, List<AttributeVO>> group : groupedAttrs.entrySet()) {
PropertyGroup propGroup = PropertyGroup.Factory.newInstance();
if (group.getKey() != null)
propGroup.setName(group.getKey());
for (AttributeVO groupAttr : group.getValue()) {
Property prop = propGroup.addNewProperty();
prop.setName(groupAttr.getAttributeName());
prop.setStringValue(groupAttr.getAttributeValue());
}
propGroups.add(propGroup);
}
}
return propGroups;
} else if (workflowPackage.getMetaContent().startsWith("<bpm:package") || workflowPackage.getMetaContent().startsWith("<package")) {
PackageDocument pkgDoc = PackageDocument.Factory.parse(workflowPackage.getMetaContent());
appProps = pkgDoc.getPackage().getApplicationProperties();
} else {
ProcessDefinitionDocument procDefDoc = ProcessDefinitionDocument.Factory.parse(workflowPackage.getMetaContent(), Compatibility.namespaceOptions());
appProps = procDefDoc.getProcessDefinition().getApplicationProperties();
}
} catch (Exception ex) {
PluginMessages.uiError(getShell(), ex, "Package Config", workflowPackage.getProject());
}
if (appProps != null && appProps.getPropertyGroupList() != null)
return appProps.getPropertyGroupList();
// not found or can't parse
return new ArrayList<>();
}
}
use of com.centurylink.mdw.bpm.PropertyGroupDocument.PropertyGroup in project mdw-designer by CenturyLinkCloud.
the class PackageConfigurationSection method getPropertyRows.
private List<PropertyRow> getPropertyRows(List<PropertyGroup> propGroups) {
List<PropertyRow> rows = new ArrayList<>();
for (PropertyGroup propGroup : propGroups) {
for (Property prop : propGroup.getPropertyList()) {
PropertyRow propRow = null;
for (PropertyRow row : rows) {
if (row.propName.equals(prop.getName())) {
propRow = row;
break;
}
}
if (propRow == null) {
propRow = new PropertyRow(prop.getName());
rows.add(propRow);
}
if (propGroup.getName() != null)
propRow.envValues.put(propGroup.getName().trim(), prop.getStringValue().trim());
else
propRow.envValues.put(null, prop.getStringValue().trim());
}
}
return rows;
}
use of com.centurylink.mdw.bpm.PropertyGroupDocument.PropertyGroup in project mdw-designer by CenturyLinkCloud.
the class PackageConfigurationSection method updatePropertyGroups.
private void updatePropertyGroups() {
List<PropertyGroup> updatedGroups = new ArrayList<>();
for (PropertyRow propRow : propertyRows) {
for (String env : propRow.envValues.keySet()) {
// get the group
PropertyGroup propGroup = null;
for (PropertyGroup group : updatedGroups) {
if (group != null && group.getName() != null && group.getName().equals(env)) {
propGroup = group;
break;
}
}
if (propGroup == null) {
propGroup = PropertyGroup.Factory.newInstance();
propGroup.setName(env);
updatedGroups.add(propGroup);
}
// set the prop value
Property property = propGroup.addNewProperty();
property.setName(propRow.propName.trim());
property.setStringValue(propRow.envValues.get(env).trim());
}
}
propertyGroups = updatedGroups;
}
use of com.centurylink.mdw.bpm.PropertyGroupDocument.PropertyGroup in project mdw-designer by CenturyLinkCloud.
the class PackageConfigurationSection method setSelection.
@Override
public void setSelection(WorkflowElement selection) {
workflowPackage = (WorkflowPackage) selection;
if (table != null)
table.dispose();
if (buttonComposite != null)
buttonComposite.dispose();
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {
propertyGroups = getPropertyGroups();
propertyRows = getPropertyRows(propertyGroups);
columnSpecs = new ArrayList<>();
ColumnSpec propNameColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, PROPERTY, PROPERTY_NAME);
propNameColSpec.width = 200;
columnSpecs.add(propNameColSpec);
for (PropertyGroup propGroup : propertyGroups) {
ColumnSpec colSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, propGroup.getName(), propGroup.getName());
colSpec.width = 200;
columnSpecs.add(colSpec);
}
Collections.sort(columnSpecs, new Comparator<ColumnSpec>() {
public int compare(ColumnSpec cs1, ColumnSpec cs2) {
if (cs1.label != null && cs1.label.equals(PROPERTY))
return -1;
if (cs2.label != null && cs2.label.equals(PROPERTY))
return 1;
// dev always comes first; prod always comes last
if (cs1.label != null && (cs1.label.equalsIgnoreCase("dev") || cs2.label.equalsIgnoreCase("prod")))
return -1;
if (cs2.label != null && (cs2.label.equalsIgnoreCase("dev") || cs1.label.equalsIgnoreCase("prod")))
return 1;
return cs1.label.compareToIgnoreCase(cs2.label);
}
});
Collections.sort(propertyRows);
}
});
table = createTable(composite);
tableViewer = createTableViewer(table);
tableViewer.setContentProvider(new PackageConfigContentProvider());
tableViewer.setLabelProvider(new PackageConfigLabelProvider());
tableViewer.setInput(propertyRows);
if ((!workflowPackage.isArchived() || DesignerProxy.isArchiveEditAllowed()) && workflowPackage.getProject().isUserAuthorizedForSystemAdmin())
createButtons(composite);
composite.layout(true);
}
Aggregations