Search in sources :

Example 16 with WorkflowAsset

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

the class ParameterizedCombo method assetFromAttr.

public WorkflowAsset assetFromAttr(String attrValue) {
    if (attrValue == null || attrValue.isEmpty() || attrValue.startsWith("$")) {
        return null;
    }
    int slashIdx = attrValue.indexOf('/');
    if (slashIdx <= 0) {
        // prefer asset in same package
        WorkflowAsset pkgDoc = workflowElement.getPackage().getAsset(attrValue);
        if (pkgDoc != null)
            return pkgDoc;
        else
            return workflowProject.getAsset(attrValue);
    } else {
        String pkgName = attrValue.substring(0, slashIdx);
        WorkflowPackage pkg = workflowProject.getPackage(pkgName);
        if (pkg == null)
            return null;
        else
            return pkg.getAsset(attrValue.substring(slashIdx + 1));
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset)

Example 17 with WorkflowAsset

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

the class WorkflowProject method clear.

/**
 * Forces refresh from the database or file system.
 */
public void clear() {
    if (isLoaded()) {
        List<WorkflowAsset> assets = archivedPackageFolder == null ? getTopLevelWorkflowAssets() : getAllWorkflowAssets();
        for (WorkflowAsset asset : assets) WorkflowAssetFactory.deRegisterAsset(asset);
        List<IFile> listenersToRemove = new ArrayList<>();
        if (artifactResourceListeners != null) {
            for (IFile file : artifactResourceListeners.keySet()) listenersToRemove.add(file);
            for (IFile file : listenersToRemove) removeArtifactResourceListener(artifactResourceListeners.get(file));
        }
    }
    if (designerProxy != null && designerProxy.isStubServerRunning())
        designerProxy.toggleStubServer();
    designerProxy = null;
    topLevelPackages = null;
    topLevelUserVisiblePackages = null;
    archivedPackageFolder = null;
    archivedUserVisiblePackagesFolder = null;
    legacyTestSuite = null;
    artifactResourceListeners = null;
    assetsNotForCurrentUser = null;
    shutdownNoticeChecks();
    scriptLibrariesSaved = false;
    pageletTabs = null;
    warn = false;
}
Also used : IFile(org.eclipse.core.resources.IFile) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ArrayList(java.util.ArrayList)

Example 18 with WorkflowAsset

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

the class WorkflowProject method findWorkflowAssets.

/**
 * Returns the workflow assets belonging to a package version.
 */
private List<WorkflowAsset> findWorkflowAssets(WorkflowPackage aPackage) {
    List<WorkflowAsset> assets = new ArrayList<>();
    if (!aPackage.isDefaultPackage()) {
        for (RuleSetVO ruleSetVO : getDataAccess().getRuleSets(false)) {
            if (aPackage.getPackageVO().containsRuleSet(ruleSetVO.getId())) {
                WorkflowAsset asset = WorkflowAssetFactory.createAsset(ruleSetVO, aPackage);
                if (asset != null) {
                    asset.addElementChangeListener(this);
                    if (!asset.isArchived())
                        WorkflowAssetFactory.registerAsset(asset);
                    assets.add(asset);
                    if (RuleSetVO.PAGELET.equals(asset.getLanguage()) && // BAM's
                    !BAM_PAGELET.equals(asset.getName())) // special
                    {
                        if (pageletTabs == null)
                            pageletTabs = new ArrayList<>();
                        String name = asset.getName();
                        if (name.indexOf('.') >= 0)
                            name = name.substring(0, name.lastIndexOf('.'));
                        PageletTab pageletTab = new PageletTab(name, designerProxy.loadWorkflowAsset(asset).getContent());
                        // check if already added from a later package
                        // version
                        boolean already = false;
                        for (PageletTab existing : pageletTabs) {
                            if (existing.getId().equals(pageletTab.getId())) {
                                already = true;
                                break;
                            }
                        }
                        if (!already)
                            pageletTabs.add(pageletTab);
                    }
                }
            }
        }
        Collections.sort(assets);
    }
    return assets;
}
Also used : WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ArrayList(java.util.ArrayList) PageletTab(com.centurylink.mdw.plugin.designer.properties.PageletTab) RuleSetVO(com.centurylink.mdw.model.value.attribute.RuleSetVO)

Example 19 with WorkflowAsset

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

the class WorkflowProject method getAsset.

public WorkflowAsset getAsset(String name) {
    int slash = name.indexOf('/');
    if (slash > 0)
        return getAsset(name.substring(0, slash), name.substring(slash + 1));
    WorkflowAsset latest = null;
    for (WorkflowAsset asset : getAllWorkflowAssets()) {
        if (asset.getName().equals(name) && (latest == null || latest.getVersion() < asset.getVersion()))
            latest = asset;
    }
    return latest;
}
Also used : WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset)

Example 20 with WorkflowAsset

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

the class WorkflowProject method viewSource.

public void viewSource(String className) {
    if (setJava()) {
        // dynamic java is preferred
        int lastDot = className.lastIndexOf('.');
        WorkflowAsset dynamicJava = null;
        if (lastDot == -1) {
            dynamicJava = getAsset(className);
            if (dynamicJava == null)
                dynamicJava = getAsset(className + ".java");
        } else {
            String pkg = className.substring(0, lastDot);
            String cls = className.substring(lastDot + 1);
            dynamicJava = getAsset(pkg, cls);
            if (dynamicJava == null)
                dynamicJava = getAsset(pkg, cls + ".java");
        }
        if (dynamicJava != null) {
            dynamicJava.openFile(new NullProgressMonitor());
            return;
        }
        IJavaProject wfSourceJavaProject = getSourceJavaProject();
        try {
            Path sourcePath = new Path(className.replace('.', '/') + ".java");
            IJavaElement javaElement = wfSourceJavaProject.findElement(sourcePath);
            if (javaElement == null) {
                PluginMessages.uiMessage("Unable to find source code for '" + className + "'.", "View Source", this, PluginMessages.INFO_MESSAGE);
                return;
            }
            JavaUI.openInEditor(javaElement);
        } catch (Exception ex) {
            PluginMessages.uiError(ex, "Open Java Source", this);
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IJavaElement(org.eclipse.jdt.core.IJavaElement) IJavaProject(org.eclipse.jdt.core.IJavaProject) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) 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)

Aggregations

WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)46 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)17 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)15 ArrayList (java.util.ArrayList)13 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)8 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)8 IFile (org.eclipse.core.resources.IFile)8 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)7 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)6 File (java.io.File)6 IOException (java.io.IOException)6 CoreException (org.eclipse.core.runtime.CoreException)6 IEditorPart (org.eclipse.ui.IEditorPart)5 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)4 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)4 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)4 List (java.util.List)4 IFolder (org.eclipse.core.resources.IFolder)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 CodeTimer (com.centurylink.mdw.plugin.CodeTimer)3