use of com.centurylink.mdw.model.value.process.PackageVO 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.model.value.process.PackageVO in project mdw-designer by CenturyLinkCloud.
the class DesignerProxy method upgradeAssets.
/**
* Replace obsolete implementors, and other assets (see help doc
* upgradeAssetsDuringImport.html).
*/
public void upgradeAssets(WorkflowPackage packageVersion) throws DataAccessException, IOException {
boolean packageUpdated = false;
PackageVO packageVO = packageVersion.getPackageVO();
List<ProcessVO> processVOs = packageVO.getProcesses();
// update activity implementors
List<ProcessVO> newProcs = new ArrayList<>();
for (ProcessVO processVO : processVOs) {
boolean processUpdated = false;
ProcessVO newProc = dataAccess.getDesignerDataAccess().getProcess(processVO.getProcessId(), processVO);
List<ActivityVO> activities = newProc.getActivities();
if (activities != null) {
for (ActivityVO activityVO : activities) {
if (new ActivityUpgrader(activityVO).doUpgrade())
processUpdated = true;
}
if (newProc.getSubProcesses() != null) {
for (ProcessVO subproc : newProc.getSubProcesses()) {
if (subproc.getActivities() != null) {
for (ActivityVO subprocActivity : subproc.getActivities()) {
if (new ActivityUpgrader(subprocActivity).doUpgrade())
processUpdated = true;
}
}
}
}
}
// update variable types
List<VariableVO> variables = newProc.getVariables();
if (variables != null) {
for (VariableVO variableVO : variables) {
String variableType = variableVO.getVariableType();
String updatedVariableType = Compatibility.getVariableType(variableType);
if (!updatedVariableType.equals(variableType)) {
variableVO.setVariableType(updatedVariableType);
processUpdated = true;
}
}
}
if (processUpdated) {
int processVersion = newProc.getVersion();
processVersion++;
newProc.setVersion(processVersion);
packageUpdated = true;
}
newProcs.add(newProc);
}
// Set old activity implementors in the package to hidden
List<ActivityImplementorVO> activityImplementorVOs = packageVO.getImplementors();
for (ActivityImplementorVO activityImplementorVO : activityImplementorVOs) {
String activityImplClassName = activityImplementorVO.getImplementorClassName();
if (Compatibility.isOldImplementor(activityImplClassName)) {
activityImplementorVO.setHidden(true);
packageUpdated = true;
}
}
if (packageUpdated) {
// update with new assets for saving
packageVO.setProcesses(newProcs);
List<RuleSetVO> newRuleSets = new ArrayList<>();
for (RuleSetVO ruleSet : packageVO.getRuleSets()) newRuleSets.add(getDesignerDataAccess().getRuleSet(ruleSet.getId()));
packageVO.setRuleSets(newRuleSets);
int version = packageVersion.getVersion();
version++;
packageVersion.setVersion(version);
// avoid forcing version
packageVersion.setExported(false);
// increment on save
packageVersion.syncProcesses();
getDesignerDataAccess().savePackage(packageVO, ProcessPersister.PersistType.IMPORT);
}
}
use of com.centurylink.mdw.model.value.process.PackageVO in project mdw-designer by CenturyLinkCloud.
the class Importer method importTaskTemplates.
public void importTaskTemplates(final WorkflowPackage pkg, final String xml, final ProgressMonitor progressMonitor) throws XmlException, DataAccessException {
progressMonitor.subTask(PARSING_XML);
PackageDocument pkgDoc = PackageDocument.Factory.parse(xml);
MDWPackage packageDef = pkgDoc.getPackage();
if (!pkg.getName().equals(packageDef.getName()))
throw new DataAccessException("Expected package: " + pkg.getName() + " in tasks XML but found: " + packageDef.getName());
com.centurylink.mdw.task.TaskTemplatesDocument.TaskTemplates templates = packageDef.getTaskTemplates();
PackageVO packageVO = new PackageVO();
if (packageDef.getName() != null)
packageVO.setPackageName(packageDef.getName());
else
packageVO.setPackageName("package");
packageVO.setVersion(PackageVO.parseVersion(packageDef.getVersion()));
List<TaskVO> packageTaskTemplates = new ArrayList<>();
for (com.centurylink.mdw.task.TaskTemplate template : templates.getTaskList()) {
TaskVO taskTemplateVO = new TaskVO(template);
taskTemplateVO.setPackageName(packageVO.getPackageName());
String v = template.getVersion();
if (v != null && !v.equals("0"))
taskTemplateVO.setVersion(RuleSetVO.parseVersion(v));
String assetName = template.getAssetName();
if (assetName != null && !assetName.isEmpty())
taskTemplateVO.setName(assetName);
packageTaskTemplates.add(taskTemplateVO);
}
packageVO.setTaskTemplates(packageTaskTemplates);
if (!packageTaskTemplates.isEmpty())
dataAccess.getDesignerDataAccess().savePackage(packageVO, ProcessPersister.PersistType.IMPORT);
for (TaskVO taskVo : packageVO.getTaskTemplates()) {
TaskTemplate existing = null;
for (TaskTemplate taskTemplate : pkg.getTaskTemplates()) {
if (taskTemplate.getLogicalId().equals(taskVo.getLogicalId())) {
existing = taskTemplate;
break;
}
}
if (existing == null) {
TaskTemplate newTemplate = new TaskTemplate(taskVo, pkg.getPackage());
pkg.addTaskTemplate(newTemplate);
} else {
existing.setTaskVO(taskVo);
}
}
}
use of com.centurylink.mdw.model.value.process.PackageVO in project mdw-designer by CenturyLinkCloud.
the class DesignerDataModel method getPackagesForProcess.
public List<PackageVO> getPackagesForProcess(String procname) {
List<PackageVO> ret = new ArrayList<PackageVO>();
String lastPackageName = "";
for (PackageVO pkg : packages) {
if (pkg.getPackageName().equals(lastPackageName))
continue;
lastPackageName = pkg.getPackageName();
// package is shallow-loaded
if (pkg.getProcesses() == null)
continue;
for (ProcessVO proc : pkg.getProcesses()) {
if (proc.getProcessName().equals(procname)) {
ret.add(pkg);
break;
}
}
}
return ret;
}
use of com.centurylink.mdw.model.value.process.PackageVO in project mdw-designer by CenturyLinkCloud.
the class DesignerDataModel method collectImportItems.
public List<ImportItem> collectImportItems(PackageVO pkg) {
List<ImportItem> importItems = new ArrayList<ImportItem>();
// check for package
ImportItem item;
int status;
if (pkg.getVersion() != 0 && getDatabaseSchemaVersion() >= DataAccess.schemaVersion4) {
status = ImportItem.STATUS_NEW_VERSION;
for (PackageVO one : packages) {
if (one.getPackageName().equals(pkg.getPackageName())) {
if (pkg.getVersion() < one.getVersion()) {
status = ImportItem.STATUS_OLD_VERSION;
} else if (pkg.getVersion() == one.getVersion()) {
if (status == ImportItem.STATUS_NEW_VERSION)
status = ImportItem.STATUS_SAME_VERSION;
}
}
}
} else
status = ImportItem.STATUS_NOT_PACKAGE;
item = new ImportItem(pkg.getPackageName(), ImportItem.TYPE_PACKAGE, status);
importItems.add(item);
// check for implementors
for (ActivityImplementorVO a : pkg.getImplementors()) {
ActivityImplementorVO a1 = findActivityImplementorVO(a.getImplementorClassName());
if (a1 == null)
status = ImportItem.STATUS_NEW;
else if (same_implementor(a, a1))
status = ImportItem.STATUS_SAME;
else
status = ImportItem.STATUS_DIFFERENT;
item = new ImportItem(a.getImplementorClassName(), ImportItem.TYPE_IMPLEMENTOR, status);
importItems.add(item);
}
for (ExternalEventVO e : pkg.getExternalEvents()) {
ExternalEventVO e1 = findExternalEvent(e.getEventName());
if (e1 == null)
status = ImportItem.STATUS_NEW;
else if (same_handler(e, e1))
status = ImportItem.STATUS_SAME;
else
status = ImportItem.STATUS_DIFFERENT;
item = new ImportItem(e.getEventName(), ImportItem.TYPE_HANDLER, status);
importItems.add(item);
}
for (RuleSetVO e : pkg.getRuleSets()) {
RuleSetVO e1 = findRuleSet(e.getName(), null);
if (e1 == null || e.getVersion() > e1.getVersion())
status = ImportItem.STATUS_NEW_VERSION;
else if (e.getVersion() == 0) {
status = ImportItem.STATUS_NEW_VERSION;
e.setVersion(e1.getVersion() + 1);
} else if (e.getVersion() == e1.getVersion())
status = ImportItem.STATUS_SAME_VERSION;
else
status = ImportItem.STATUS_OLD_VERSION;
item = new ImportItem(e.getName(), ImportItem.TYPE_RULESET, status);
importItems.add(item);
}
for (ProcessVO p : pkg.getProcesses()) {
ProcessVO p1 = findProcessDefinition(p.getProcessName(), 0);
if (p1 == null || p.getVersion() > p1.getVersion() || p.getVersion() == 0)
status = ImportItem.STATUS_NEW_VERSION;
else if (p.getVersion() == p1.getVersion())
status = ImportItem.STATUS_SAME_VERSION;
else
status = ImportItem.STATUS_OLD_VERSION;
item = new ImportItem(p.getProcessName(), ImportItem.TYPE_PROCESS, status);
importItems.add(item);
}
return importItems;
}
Aggregations