Search in sources :

Example 41 with WorkflowPackage

use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.

the class WorkflowProject method newPackageVersion.

public void newPackageVersion(WorkflowPackage newPkg, WorkflowPackage prevPkg) {
    if (isFilePersist()) {
        // refresh prevPkg since it's fast
        try {
            PackageVO pkg = getDesignerDataAccess().loadPackage(prevPkg.getId(), false);
            if (// when incrementing by saving non-process
            pkg == null)
                // pkgs
                return;
            prevPkg.setPackageVO(pkg);
            prevPkg.setProcesses(findProcesses(prevPkg));
            prevPkg.setExternalEvents(findExternalEvents(prevPkg));
            prevPkg.setActivityImpls(findActivityImplementors(prevPkg));
            prevPkg.setAssets(findWorkflowAssets(prevPkg));
            prevPkg.setTaskTemplates(findTaskTemplates(prevPkg));
            // may have been called in response to vcs save new process
            // version
            prevPkg.syncProcesses();
        } catch (Exception ex) {
            PluginMessages.log(ex);
        }
    }
    // contents
    for (WorkflowElement we : getArchivedUserVisiblePackagesFolder().getChildren()) {
        WorkflowPackage pv = (WorkflowPackage) we;
        if (pv.getName().equals(prevPkg.getName())) {
            List<WorkflowPackage> descendants = pv.getDescendantPackageVersions();
            if (descendants == null) {
                descendants = new ArrayList<>();
                pv.setDescendantPackageVersions(descendants);
            }
            descendants.add(prevPkg);
            prevPkg.setTopLevelVersion(pv);
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) 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) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 42 with WorkflowPackage

use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.

the class WorkflowProject method getAllExternalEvents.

/**
 * Returns all external events regardless of packaging and archive status.
 */
/**
 * Returns all event handlers, regardless of packaging.
 */
public List<ExternalEvent> getAllExternalEvents() {
    List<ExternalEvent> allHandlers = new ArrayList<>();
    for (WorkflowPackage pkg : getTopLevelPackages()) {
        for (ExternalEvent handler : pkg.getExternalEvents()) {
            if (!allHandlers.contains(handler))
                allHandlers.add(handler);
        }
    }
    for (WorkflowElement topLevelArchived : getArchivedPackageFolder().getChildren()) {
        if (topLevelArchived instanceof WorkflowPackage) {
            WorkflowPackage topLevelPkg = (WorkflowPackage) topLevelArchived;
            if (topLevelPkg.hasDescendantPackageVersions()) {
                for (WorkflowPackage pkg : topLevelPkg.getDescendantPackageVersions()) {
                    for (ExternalEvent handler : pkg.getExternalEvents()) {
                        if (!allHandlers.contains(handler))
                            allHandlers.add(handler);
                    }
                }
            }
        }
    }
    Collections.sort(allHandlers);
    return allHandlers;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ArrayList(java.util.ArrayList) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 43 with WorkflowPackage

use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.

the class GherkinTestCaseLaunch method getLaunchConfiguration.

/**
 * Actually returns a working copy since we don't save this launch config.
 */
public ILaunchConfiguration getLaunchConfiguration() throws CoreException {
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(CUCUMBER_LAUNCH_TYPE);
    ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, "mdwCucumberLaunch_" + getTestCase().getCaseName());
    List<String> resPaths = new ArrayList<>();
    resPaths.add("/" + workflowProject.getName());
    workingCopy.setAttribute(CucumberLaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS, resPaths);
    List<String> resTypes = new ArrayList<>();
    resTypes.add(CucumberLaunchConfiguration.RESOURCE_TYPE_PROJECT);
    workingCopy.setAttribute(CucumberLaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, resTypes);
    workingCopy.setAttribute(CucumberLaunchConfiguration.ATTR_USE_START_ON_FIRST_THREAD, true);
    workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, workflowProject.getName());
    // TODO user-specified arguments (especially glue)
    StringBuilder args = new StringBuilder(CucumberLaunchConfiguration.DEFAULT_ARGS);
    // glue
    if (workflowProject.isFilePersist()) {
        for (WorkflowPackage gluePackage : getGluePackages()) args.append(" --glue \"").append(gluePackage.getFolder().getProjectRelativePath()).append("\"");
    }
    // legacy glue
    File oldGlueFile = new File(workflowProject.getOldTestCasesDir() + "/steps.groovy");
    if (oldGlueFile.exists())
        args.append(" --glue \"").append(oldGlueFile.toString().replace('\\', '/')).append("\"");
    // feature
    if (getTestCase().isLegacy()) {
        String oldTestSuiteLoc = workflowProject.getOldTestCasesDir().toString().replace('\\', '/');
        args.append(" \"").append(oldTestSuiteLoc).append("/").append(getTestCase().getCaseName()).append("\"");
    } else {
        args.append(" \"").append(workflowProject.getAssetFolder().getProjectRelativePath()).append("/").append(getTestCase().getPrefix().replace('.', '/')).append("/").append(getTestCase().getName()).append(RuleSetVO.getFileExtension(RuleSetVO.FEATURE)).append("\"");
    }
    workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args.toString());
    String vmArgs = "-Dmdw.test.case=" + getTestCase().getCaseName();
    if (getTestCase().isLegacy())
        vmArgs += " -Dmdw.test.cases.dir=\"" + workflowProject.getOldTestCasesDir().toString().replace('\\', '/') + "\"";
    else
        vmArgs += " -Dmdw.test.case.file=\"" + getTestCase().getCaseFile().toString().replace('\\', '/') + "\"";
    vmArgs += " -Dmdw.test.case.user=" + workflowProject.getUser().getUsername();
    vmArgs += " -Dmdw.test.server.url=" + workflowProject.getServiceUrl();
    if (stubbing) {
        vmArgs += " -Dmdw.test.server.stub=true";
        vmArgs += " -Dmdw.test.server.stubPort=" + workflowProject.getServerSettings().getStubServerPort();
    }
    if (workflowProject.isOldNamespaces())
        vmArgs += " -Dmdw.test.old.namespaces=true";
    if (singleServer)
        vmArgs += " -Dmdw.test.pin.to.server=true";
    if (createReplace)
        vmArgs += " -Dmdw.test.create.replace=true";
    vmArgs += " -Dmdw.test.results.dir=\"" + getTestCase().getResultDirectory().toString().replace('\\', '/') + "\"";
    if (workflowProject.isFilePersist())
        vmArgs += " -Dmdw.test.workflow.dir=\"" + workflowProject.getAssetDir().toString().replace('\\', '/') + "\"";
    else
        vmArgs += " -Dmdw.test.jdbc.url=" + workflowProject.getMdwDataSource().getJdbcUrlWithCredentials();
    if (verbose)
        vmArgs += " -Dmdw.test.verbose=true";
    if (this.getMasterRequestId() != null)
        vmArgs += " -Dmdw.test.masterRequestId=" + this.getMasterRequestId();
    workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs);
    return workingCopy;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) File(java.io.File)

Example 44 with WorkflowPackage

use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.

the class ImportExportPage method createPackageControls.

@Override
protected void createPackageControls(Composite parent, int ncol) {
    List<WorkflowPackage> packages = getPackages();
    String label = packages.get(0).getLabel();
    if (packages.size() > 1)
        label += ", " + packages.get(1).getLabel() + "...";
    new Label(parent, SWT.NONE).setText(packages.size() == 1 ? "Package:" : "Packages:");
    Label packageLabel = new Label(parent, SWT.NONE);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.horizontalSpan = ncol - 1;
    packageLabel.setLayoutData(gd);
    FontData font = packageLabel.getFont().getFontData()[0];
    font.setStyle(font.getStyle() | SWT.BOLD);
    packageLabel.setFont(new Font(this.getShell().getDisplay(), font));
    packageLabel.setText(label);
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Font(org.eclipse.swt.graphics.Font)

Example 45 with WorkflowPackage

use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.

the class ImportPackagePage method populateTopFolder.

public Folder populateTopFolder(String discoveryUrl, String groupId, boolean latestVersionsOnly, IProgressMonitor progressMonitor) throws Exception {
    Folder folder = null;
    getImportPackageWizard().getImportPackageSelectPage().clear();
    if (discoveryUrl != null || groupId != null) {
        if (discoveryUrl != null) {
            if (getProject().checkRequiredVersion(6, 0, 13))
                folder = new Discoverer(new URL(discoveryUrl), getProject().getHttpHelper(discoveryUrl)).getAssetTopFolder(latestVersionsOnly, progressMonitor);
            else
                folder = new Discoverer(new URL(discoveryUrl)).getAssetTopFolder(latestVersionsOnly, progressMonitor);
        }
        if (groupId != null)
            folder = new Discoverer(groupId).getAssetTopFolder(latestVersionsOnly, progressMonitor);
        if (getProject().isRemote() && getProject().isGitVcs()) {
            List<Folder> emptyFolders = removeGitVersionedPackages(folder);
            List<Folder> emptyParents = new ArrayList<>();
            for (Folder emptyFolder : emptyFolders) {
                if (emptyFolder.getParent() instanceof Folder) {
                    Folder parent = emptyFolder.getParent();
                    parent.getChildren().remove(emptyFolder);
                    // go one more level up
                    if (parent.getChildren().isEmpty() && !emptyParents.contains(parent))
                        emptyParents.add(parent);
                }
            }
            for (Folder emptyParent : emptyParents) {
                if (emptyParent.getParent() instanceof Folder)
                    (emptyParent.getParent()).getChildren().remove(emptyParent);
            }
        }
    } else {
        String filepath = filePathText.getText().trim();
        String contents = FileHelper.getFileContents(filepath);
        folder = new Folder(filepath);
        boolean hasOldImpls = false;
        if (contents.trim().startsWith("{")) {
            ImporterExporterJson importer = new ImporterExporterJson();
            List<PackageVO> packages = importer.importPackages(contents);
            for (PackageVO pkg : packages) {
                if (getProject().isRemote() && getProject().isGitVcs()) {
                    for (WorkflowPackage existingVcs : getProject().getTopLevelPackages()) {
                        if (existingVcs.getName().equals(pkg.getName()))
                            getImportPackageWizard().getImportPackageSelectPage().setError(PKG_EXISTS + pkg.getName());
                    }
                }
                File aFile = new File(folder, pkg.getName() + " v" + pkg.getVersionString());
                ImporterExporterJson jsonExporter = new ImporterExporterJson();
                List<PackageVO> pkgs = new ArrayList<>();
                pkgs.add(pkg);
                JSONObject pkgJson = new JSONObject(jsonExporter.exportPackages(pkgs));
                pkgJson.put("name", pkg.getName());
                aFile.setContent(pkgJson.toString(2));
                folder.addChild(aFile);
            }
            preselected = folder;
        } else {
            try {
                // try and parse as multiple packages
                PackageDocument pkgDoc = PackageDocument.Factory.parse(contents);
                QName docElement = new QName("http://mdw.centurylink.com/bpm", "processDefinition");
                for (MDWProcessDefinition pkgDef : pkgDoc.getPackage().getProcessDefinitionList()) {
                    if (getProject().isRemote() && getProject().isGitVcs()) {
                        for (WorkflowPackage existingVcs : getProject().getTopLevelPackages()) {
                            if (existingVcs.getName().equals(pkgDef.getPackageName()))
                                getImportPackageWizard().getImportPackageSelectPage().setError(PKG_EXISTS + pkgDef.getPackageName());
                        }
                    }
                    if (!hasOldImpls && getProject().isFilePersist() && !getProject().isRemote())
                        hasOldImpls = checkForOldImplementors(pkgDef);
                    File aFile = new File(folder, pkgDef.getPackageName() + " v" + pkgDef.getPackageVersion());
                    aFile.setContent(pkgDef.xmlText(new XmlOptions().setSaveOuter().setSaveSyntheticDocumentElement(docElement)));
                    folder.addChild(aFile);
                }
                preselected = folder;
            } catch (XmlException ex) {
                // unparseable -- assume single package
                if (getProject().isRemote() && getProject().isGitVcs()) {
                    MDWProcessDefinition procDef = ProcessDefinitionDocument.Factory.parse(contents, Compatibility.namespaceOptions()).getProcessDefinition();
                    for (WorkflowPackage existingVcs : getProject().getTopLevelPackages()) {
                        if (existingVcs.getName().equals(procDef.getPackageName()))
                            getImportPackageWizard().getImportPackageSelectPage().setError(PKG_EXISTS + procDef.getPackageName());
                    }
                }
                if (getProject().isFilePersist() && !getProject().isRemote())
                    hasOldImpls = checkForOldImplementors(ProcessDefinitionDocument.Factory.parse(contents, Compatibility.namespaceOptions()).getProcessDefinition());
                File file = new File(folder, filepath);
                file.setContent(contents);
                folder.addChild(file);
                preselected = file;
            }
        }
        getImportPackageWizard().setHasOldImplementors(hasOldImpls);
    }
    return folder;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) PackageVO(com.centurylink.mdw.model.value.process.PackageVO) QName(javax.xml.namespace.QName) XmlOptions(org.apache.xmlbeans.XmlOptions) ArrayList(java.util.ArrayList) MDWProcessDefinition(com.centurylink.mdw.bpm.MDWProcessDefinition) Discoverer(com.centurylink.mdw.plugin.designer.Discoverer) Folder(com.centurylink.mdw.plugin.designer.model.Folder) URL(java.net.URL) PackageDocument(com.centurylink.mdw.bpm.PackageDocument) JSONObject(org.json.JSONObject) XmlException(org.apache.xmlbeans.XmlException) File(com.centurylink.mdw.plugin.designer.model.File) ImporterExporterJson(com.centurylink.mdw.dataaccess.file.ImporterExporterJson)

Aggregations

WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)85 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)31 ArrayList (java.util.ArrayList)27 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)25 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)21 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)17 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)11 GridData (org.eclipse.swt.layout.GridData)11 CoreException (org.eclipse.core.runtime.CoreException)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)8 List (java.util.List)8 Label (org.eclipse.swt.widgets.Label)8 JSONException (org.json.JSONException)8 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)7 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)7 Folder (com.centurylink.mdw.plugin.designer.model.Folder)7 IOException (java.io.IOException)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)7