use of com.centurylink.mdw.bpm.ApplicationPropertiesDocument.ApplicationProperties 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<>();
}
}
Aggregations