Search in sources :

Example 21 with WorkflowPackage

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

the class ExportPackageWizard method performImportExport.

void performImportExport(ProgressMonitor progressMonitor) throws IOException, JSONException, XmlException, DataAccessException, ActionCancelledException {
    Exporter exporter = new Exporter(getProject().getDesignerDataAccess());
    boolean exportJson = false;
    boolean includeTaskTemplates = false;
    boolean inferReferencedImpls = false;
    boolean exportZip = false;
    IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
    if (getProject().isFilePersist()) {
        exportJson = prefsStore.getBoolean(PreferenceConstants.PREFS_EXPORT_JSON_FORMAT);
        includeTaskTemplates = !prefsStore.getBoolean(PreferenceConstants.PREFS_SUPPRESS_TASK_TEMPLATES_IN_PKG_EXPORT);
        exportZip = prefsStore.getBoolean(PreferenceConstants.PREFS_EXPORT_ZIP_FORMAT);
    } else {
        inferReferencedImpls = !prefsStore.getBoolean(PreferenceConstants.PREFS_SUPPRESS_INFER_REFERENCED_IMPLS_DURING_EXPORT);
    }
    List<WorkflowPackage> packages = getPackages();
    String export = null;
    if (exportZip) {
        File assetDir = getProject().getAssetDir();
        List<File> includes = new ArrayList<>();
        for (WorkflowPackage pkg : packages) includes.add(new File(assetDir + "/" + pkg.getName().replace('.', '/')));
        ZipHelper.zipWith(assetDir, new File(getPage().getFilePath()), includes);
    } else if (packages.size() == 1 && !exportJson)
        export = exporter.exportPackage(packages.get(0), includeTaskTemplates, inferReferencedImpls, progressMonitor);
    else
        export = exporter.exportPackages(packages, exportJson, includeTaskTemplates, progressMonitor);
    progressMonitor.progress(10);
    progressMonitor.subTask("Writing " + (exportJson ? "JSON" : "XML") + " file");
    if (export != null)
        writeFile(getPage().getFilePath(), export.getBytes());
    progressMonitor.progress(5);
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ArrayList(java.util.ArrayList) Exporter(com.centurylink.mdw.plugin.designer.Exporter) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) File(java.io.File)

Example 22 with WorkflowPackage

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

the class TestResultsFormatter method getXslFile.

private File getXslFile(String filename) throws IOException {
    File stylesheet = null;
    if (project.isFilePersist()) {
        // prefer override (non-MDW testing package); fall back to MDW
        // testing package
        WorkflowPackage mdwTestingPackage = null;
        WorkflowPackage otherTestingPackage = null;
        for (WorkflowPackage pkg : project.getTopLevelPackages()) {
            if (pkg.getName().equals("com.centurylink.mdw.testing"))
                mdwTestingPackage = pkg;
            else if (pkg.getName().endsWith(".testing"))
                otherTestingPackage = pkg;
        }
        if (otherTestingPackage != null) {
            WorkflowAsset asset = otherTestingPackage.getAsset(filename);
            if (asset != null)
                stylesheet = asset.getRawFile();
        }
        if (stylesheet == null && mdwTestingPackage != null) {
            WorkflowAsset asset = mdwTestingPackage.getAsset(filename);
            if (asset != null)
                stylesheet = asset.getRawFile();
        }
    }
    if (stylesheet == null) {
        // fall back to template version in designer
        URL localUrl = PluginUtil.getLocalResourceUrl("templates/xsl/" + filename);
        try {
            stylesheet = new File(new URI(localUrl.toString()));
        } catch (URISyntaxException ex) {
            throw new IOException(ex.getMessage(), ex);
        }
    }
    return stylesheet;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) File(java.io.File) URI(java.net.URI) URL(java.net.URL)

Example 23 with WorkflowPackage

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

the class CodeGenWizardPage method createWorkflowPackageControls.

@Override
protected void createWorkflowPackageControls(Composite parent, int ncol) {
    new Label(parent, SWT.NONE).setText("Workflow Package:");
    workflowPackageCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.horizontalSpan = ncol - 1;
    gd.widthHint = 250;
    workflowPackageCombo.setLayoutData(gd);
    workflowPackageCombo.removeAll();
    if (getCodeElement().getProject() != null) {
        for (WorkflowPackage packageVersion : getCodeElement().getProject().getTopLevelUserVisiblePackages()) workflowPackageCombo.add(packageVersion.getName());
    }
    workflowPackageCombo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            String packageName = workflowPackageCombo.getText().trim();
            getCodeElement().setPackage(getCodeElement().getProject().getPackage(packageName));
            handleFieldChanged();
        }
    });
    if (getCodeElement().getPackage() != null)
        workflowPackageCombo.setText(getCodeElement().getPackage().getName());
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Combo(org.eclipse.swt.widgets.Combo)

Example 24 with WorkflowPackage

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

the class ImportTaskTemplatesWizard method postRunUpdates.

@Override
protected void postRunUpdates() {
    WorkflowPackage pkg = getPackage();
    if (pkg != null) {
        pkg.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, pkg);
        pkg.refreshFolder();
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage)

Example 25 with WorkflowPackage

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

the class ImportTaskTemplatesWizard method performImportExport.

void performImportExport(ProgressMonitor progressMonitor) throws IOException, XmlException, DataAccessException, ValidationException, ActionCancelledException {
    Importer importer = new Importer(getProject().getDataAccess(), getShell());
    progressMonitor.progress(10);
    progressMonitor.subTask("Reading XML file");
    byte[] bytes = readFile(getPage().getFilePath());
    if (progressMonitor.isCanceled())
        throw new ActionCancelledException();
    progressMonitor.subTask("Performing Import");
    WorkflowPackage pkg = getPackage();
    if (pkg == null)
        throw new ValidationException("No package found.");
    importer.importTaskTemplates(pkg, new String(bytes), progressMonitor);
    progressMonitor.progress(30);
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) Importer(com.centurylink.mdw.plugin.designer.Importer)

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