Search in sources :

Example 16 with PackageVO

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();
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) JSONException(org.json.JSONException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) MdwSecurityException(com.centurylink.mdw.auth.MdwSecurityException) MalformedURLException(java.net.MalformedURLException) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) TestCase(com.centurylink.mdw.designer.testing.TestCase) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) TestResultsParser(com.centurylink.mdw.designer.testing.TestResultsParser) CodeTimer(com.centurylink.mdw.plugin.CodeTimer) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 17 with PackageVO

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);
    }
}
Also used : PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ActivityVO(com.centurylink.mdw.model.value.activity.ActivityVO) ArrayList(java.util.ArrayList) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO) ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO)

Example 18 with PackageVO

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);
        }
    }
}
Also used : TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ArrayList(java.util.ArrayList) MDWPackage(com.centurylink.mdw.bpm.MDWPackage) PackageDocument(com.centurylink.mdw.bpm.PackageDocument) TaskVO(com.centurylink.mdw.model.value.task.TaskVO) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Example 19 with PackageVO

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;
}
Also used : PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO)

Example 20 with PackageVO

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;
}
Also used : ImportItem(com.centurylink.mdw.designer.utils.ImportItem) ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) ExternalEventVO(com.centurylink.mdw.model.value.event.ExternalEventVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO)

Aggregations

PackageVO (com.centurylink.mdw.model.value.process.PackageVO)27 ArrayList (java.util.ArrayList)18 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)11 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)8 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)7 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)6 IOException (java.io.IOException)6 JSONObject (org.json.JSONObject)6 PackageDocument (com.centurylink.mdw.bpm.PackageDocument)5 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)5 ProcessExporter (com.centurylink.mdw.dataaccess.ProcessExporter)5 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)5 AttributeVO (com.centurylink.mdw.model.value.attribute.AttributeVO)5 JSONException (org.json.JSONException)5 TaskVO (com.centurylink.mdw.model.value.task.TaskVO)4 CodeTimer (com.centurylink.mdw.plugin.CodeTimer)4 HashMap (java.util.HashMap)4 ProcessImporter (com.centurylink.mdw.dataaccess.ProcessImporter)3 ImporterExporterJson (com.centurylink.mdw.dataaccess.file.ImporterExporterJson)3 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)3