use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method findUnpackagedAssetFolders.
/**
* Returns the folders for unpackaged archived workflow assets. Side-effect:
* If an unpackaged version is later than any package, add to default
* package.
*/
private List<Folder> findUnpackagedAssetFolders() {
CodeTimer timer = new CodeTimer("findUnpackagedAssetFolders()");
Map<String, Folder> upAssetFolders = new HashMap<>();
Map<String, List<RuleSetVO>> nonLatestUnpackaged = new HashMap<>();
for (RuleSetVO ruleSetVO : getDataAccess().getRuleSets(false)) {
if (!isPackaged(ruleSetVO)) {
// if version is later than that in any non-archived package,
// it belongs in the top-level default package
boolean laterThanPackaged = true;
for (WorkflowPackage pkg : getTopLevelPackages()) {
WorkflowAsset packaged = pkg.getAsset(ruleSetVO.getName());
if (packaged != null && packaged.getVersion() >= ruleSetVO.getVersion()) {
laterThanPackaged = false;
break;
}
}
boolean latestUnpackaged = true;
if (laterThanPackaged) {
WorkflowAsset defPkgAsset = getDefaultPackage().getAsset(ruleSetVO.getName());
if (defPkgAsset != null) {
if (defPkgAsset.getVersion() > ruleSetVO.getVersion()) {
latestUnpackaged = false;
} else if (defPkgAsset.getVersion() < ruleSetVO.getVersion()) {
defPkgAsset.removeElementChangeListener(this);
getDefaultPackage().removeAsset(defPkgAsset);
WorkflowAssetFactory.deRegisterAsset(defPkgAsset);
List<RuleSetVO> list = nonLatestUnpackaged.get(ruleSetVO.getName());
if (list == null) {
list = new ArrayList<>();
nonLatestUnpackaged.put(ruleSetVO.getName(), list);
}
list.add(defPkgAsset.getRuleSetVO());
}
}
}
if (laterThanPackaged && latestUnpackaged) {
WorkflowAsset asset = WorkflowAssetFactory.createAsset(ruleSetVO, getDefaultPackage());
if (asset != null) {
asset.addElementChangeListener(this);
getDefaultPackage().addAsset(asset);
WorkflowAssetFactory.registerAsset(asset);
}
} else {
List<RuleSetVO> list = nonLatestUnpackaged.get(ruleSetVO.getName());
if (list == null) {
list = new ArrayList<>();
nonLatestUnpackaged.put(ruleSetVO.getName(), list);
}
list.add(ruleSetVO);
}
}
}
for (String rsName : nonLatestUnpackaged.keySet()) {
List<RuleSetVO> list = nonLatestUnpackaged.get(rsName);
Collections.sort(list, new Comparator<RuleSetVO>() {
public int compare(RuleSetVO rs1, RuleSetVO rs2) {
return rs2.getVersion() - rs1.getVersion();
}
});
for (RuleSetVO rs : list) {
WorkflowAsset asset = WorkflowAssetFactory.createAsset(rs, archivedDefaultPackage);
if (asset != null) {
Folder folder = upAssetFolders.get(asset.getName());
if (folder == null) {
folder = WorkflowAssetFactory.createAssetFolder(asset);
upAssetFolders.put(asset.getName(), folder);
} else {
folder.getChildren().add(asset);
}
}
}
}
List<Folder> folders = new ArrayList<>();
folders.addAll(upAssetFolders.values());
Collections.sort(folders);
timer.stopAndLog();
return folders;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method getSuppressedActivityImplementors.
public List<String> getSuppressedActivityImplementors() throws IOException {
if (suppressedActivityImplementors == null) {
suppressedActivityImplementors = new ArrayList<>();
String compressed = getPersistentProperty(MDW_SUPPRESSED_ACTIVITY_IMPLEMENTORS);
String suppressedImplsProp = compressed == null ? null : StringHelper.uncompress(compressed);
if (suppressedImplsProp == null) {
if (checkRequiredVersion(5, 5)) {
// suppress the old baseline package impls by default
WorkflowPackage baseline52 = getPackage("MDW Baseline");
if (baseline52 != null) {
for (ActivityImpl impl : baseline52.getActivityImpls()) suppressedActivityImplementors.add(impl.getImplClassName());
}
}
} else {
for (String impl : suppressedImplsProp.split(",")) suppressedActivityImplementors.add(impl);
}
}
return suppressedActivityImplementors;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method findTopLevelPackages.
/**
* Finds the list of top level packages (including the default if
* supported), populated with the appropriate processes, etc.
*/
private void findTopLevelPackages(ProgressMonitor progressMonitor) {
CodeTimer timer = new CodeTimer("findTopLevelPackages()");
topLevelPackages = new ArrayList<>();
topLevelUserVisiblePackages = new ArrayList<>();
activityImpls.clear();
for (PackageVO packageVO : getTopLevelPackageVOs(progressMonitor)) {
WorkflowPackage topLevelPackage = new WorkflowPackage(this, packageVO);
topLevelPackage.setProcesses(findProcesses(topLevelPackage));
topLevelPackage.setExternalEvents(findExternalEvents(topLevelPackage));
topLevelPackage.setActivityImpls(findActivityImplementors(topLevelPackage));
topLevelPackage.setAssets(findWorkflowAssets(topLevelPackage));
topLevelPackage.setTaskTemplates(findTaskTemplates(topLevelPackage));
topLevelPackages.add(topLevelPackage);
if (topLevelPackage.isVisible())
topLevelUserVisiblePackages.add(topLevelPackage);
// register as a listener so that i can pass on element change
// events
topLevelPackage.addElementChangeListener(this);
for (WorkflowProcess process : topLevelPackage.getProcesses()) process.addElementChangeListener(this);
}
Collections.sort(topLevelPackages);
Collections.sort(topLevelUserVisiblePackages);
File resultsFile = getFunctionTestResultsFile();
if (resultsFile.exists()) {
// update test case statuses
List<TestCase> testCases = new ArrayList<>();
for (WorkflowPackage pkg : topLevelPackages) {
for (WorkflowAsset asset : pkg.getAssets()) {
if (asset instanceof AutomatedTestCase)
testCases.add(((AutomatedTestCase) asset).getTestCase());
}
}
if (!testCases.isEmpty()) {
try {
TestResultsParser parser = new TestResultsParser(resultsFile, testCases);
if (resultsFile.getName().endsWith(".xml"))
parser.parseXml();
else
parser.parseJson(getAssetDir());
} catch (Exception ex) {
PluginMessages.uiError(ex, "Parse Test Results", this);
}
}
}
timer.stopAndLog();
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class Importer method importAttributes.
public void importAttributes(final WorkflowElement element, final String xml, final ProgressMonitor progressMonitor, String attrPrefix) throws DataAccessException, XmlException {
progressMonitor.subTask(PARSING_XML);
int schemaVersion = dataAccess.getSchemaVersion();
ProcessImporter importer = DataAccess.getProcessImporter(schemaVersion);
progressMonitor.progress(40);
progressMonitor.subTask("Saving attributes");
ProcessDefinitionDocument procdef = ProcessDefinitionDocument.Factory.parse(xml, Compatibility.namespaceOptions());
if (element instanceof WorkflowPackage && !((WorkflowPackage) element).getName().equals(procdef.getProcessDefinition().getPackageName()))
throw new DataAccessException("Expected package: " + ((WorkflowPackage) element).getName() + " in attributes XML but found: " + procdef.getProcessDefinition().getPackageName());
for (MDWProcess process : procdef.getProcessDefinition().getProcessList()) {
ProcessDefinitionDocument oneProcDef = ProcessDefinitionDocument.Factory.newInstance();
MDWProcessDefinition oneProc = oneProcDef.addNewProcessDefinition();
oneProc.getProcessList().add(process);
ProcessVO importedProc = importer.importProcess(oneProcDef.xmlText());
if (element instanceof WorkflowProcess && !((WorkflowProcess) element).getName().equals(importedProc.getProcessName()))
throw new DataAccessException("Expected process: " + ((WorkflowProcess) element).getName() + " in attributes XML but found: " + importedProc.getName());
ProcessVO proc = dataAccess.getLatestProcess(importedProc.getName());
if (proc == null)
throw new DataAccessException("Process not found: " + importedProc.getName());
Map<String, String> existAttrs = dataAccess.getDesignerDataAccess().getAttributes(OwnerType.PROCESS, proc.getId());
Map<String, String> importedAttrs = importedProc.getOverrideAttributes();
Map<String, String> setAttrs = new HashMap<>();
if (existAttrs != null) {
// retain existing attrs not related to this prefix
for (Map.Entry<String, String> attrs : existAttrs.entrySet()) {
if (!WorkAttributeConstant.isAttrNameFor(attrs.getKey(), attrPrefix))
setAttrs.put(attrs.getKey(), attrs.getValue());
}
}
if (importedAttrs != null) {
for (Map.Entry<String, String> attrs : importedAttrs.entrySet()) {
if (!WorkAttributeConstant.isAttrNameFor(attrs.getKey(), attrPrefix))
throw new DataAccessException("Expected attribute prefix: " + attrPrefix + " in attributes XML but found attribute: " + attrs.getKey());
else
setAttrs.put(attrs.getKey(), attrs.getValue());
}
}
dataAccess.getDesignerDataAccess().setOverrideAttributes(attrPrefix, OwnerType.PROCESS, proc.getId(), setAttrs);
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class TableEditor method createTableViewer.
private TableViewer createTableViewer(Table table) {
TableViewer lTableViewer = new TableViewer(table);
lTableViewer.setUseHashlookup(true);
lTableViewer.setColumnProperties(columnProps);
if (!isReadOnly()) {
CellEditor[] cellEditors = new CellEditor[columnSpecs.size()];
for (int i = 0; i < columnSpecs.size(); i++) {
ColumnSpec colSpec = columnSpecs.get(i);
CellEditor cellEditor = null;
if (!colSpec.hidden) {
if (colSpec.type.equals(TYPE_TEXT)) {
if (colSpec.style != 0)
cellEditor = new TextCellEditor(table, colSpec.style);
else
cellEditor = new TextCellEditor(table);
} else if (colSpec.type.equals(TYPE_CHECKBOX)) {
cellEditor = new CheckboxCellEditor(table);
} else if (colSpec.type.equals(TYPE_COMBO)) {
int style = SWT.None;
if (colSpec.readOnly)
style = style | SWT.READ_ONLY;
cellEditor = new ComboBoxCellEditor(table, colSpec.options, style);
if (!colSpec.readOnly)
cellEditor.addListener(new EditableComboCellEditorListener((ComboBoxCellEditor) cellEditor, i));
} else if (colSpec.type.equals(WorkflowAssetEditor.TYPE_ASSET)) {
int style = SWT.None;
if (colSpec.readOnly)
style = style | SWT.READ_ONLY;
cellEditor = new TreeComboCellEditor(table, style) {
@Override
protected void doSetValue(Object value) {
Object val = getValue();
if (val instanceof CTreeComboItem) {
CTreeComboItem selItem = (CTreeComboItem) getValue();
if (selItem != null) {
super.doSetValue(selItem.getText());
return;
}
}
if (value instanceof String) {
String strVal = (String) value;
if (strVal.indexOf('/') > -1) {
super.doSetValue(strVal.substring(strVal.indexOf('/') + 1));
return;
}
}
super.doSetValue(value);
}
};
((TreeComboCellEditor) cellEditor).setSelectionModifier(new SelectionModifier() {
public String modify(CTreeComboItem selection) {
if (selection.getParentItem() != null) {
WorkflowPackage pkg = getProject().getPackage(selection.getParentItem().getText());
if (pkg == null || pkg.isDefaultPackage())
return selection.getText();
else
return pkg.getName() + "/" + selection.getText();
} else {
// ignore packages
return null;
}
}
});
// populate the treecombo
if (colSpec.source.equals(PROCESS)) {
List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
for (WorkflowPackage pkg : packages) {
CTreeComboItem packageItem = ((TreeComboCellEditor) cellEditor).addItem(pkg.getName());
packageItem.setText(pkg.getName());
packageItem.setImage(pkg.getIconImage());
for (WorkflowProcess process : pkg.getProcesses()) {
CTreeComboItem processItem = new CTreeComboItem(packageItem, SWT.NONE);
processItem.setText(process.getLabel());
processItem.setImage(process.getIconImage());
}
}
} else {
List<WorkflowAsset> assets = getProject().getAssetList(Arrays.asList(colSpec.assetTypes));
Map<String, CTreeComboItem> packageItems = new HashMap<>();
for (WorkflowAsset asset : assets) {
String pkgName = asset.getPackage().getName();
CTreeComboItem packageItem = packageItems.get(pkgName);
if (packageItem == null) {
packageItem = ((TreeComboCellEditor) cellEditor).addItem(pkgName);
packageItem.setImage(asset.getPackage().getIconImage());
packageItems.put(pkgName, packageItem);
}
CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
assetItem.setText(asset.getLabel());
assetItem.setImage(asset.getIconImage());
}
}
}
if (colSpec.listener != null && cellEditor != null)
cellEditor.addListener(colSpec.listener);
cellEditors[i] = cellEditor;
}
}
lTableViewer.setCellEditors(cellEditors);
lTableViewer.setCellModifier(cellModifier);
}
return lTableViewer;
}
Aggregations