Search in sources :

Example 11 with File

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

the class ImportPackagePage method removeGitVersionedPackages.

/**
 * Not foolproof since it relies on asset XML naming convention. returns
 * emptyFolders to be pruned.
 */
private List<Folder> removeGitVersionedPackages(Folder folder) {
    List<Folder> emptyFolders = new ArrayList<>();
    Map<File, Folder> toRemove = new HashMap<>();
    for (WorkflowElement child : folder.getChildren()) {
        if (child instanceof Folder) {
            for (Folder emptyFolder : removeGitVersionedPackages((Folder) child)) {
                if (!emptyFolders.contains(emptyFolder))
                    emptyFolders.add(emptyFolder);
            }
        } else if (child instanceof File) {
            File file = (File) child;
            String pkgName = file.getName();
            if (file.getParent() instanceof Folder && pkgName.endsWith(".xml")) {
                pkgName = pkgName.substring(0, pkgName.length() - 3);
                int lastDash = pkgName.lastIndexOf('-');
                if (lastDash > 0) {
                    pkgName = pkgName.substring(0, lastDash);
                    for (WorkflowPackage gitPackage : getProject().getTopLevelPackages()) {
                        if (pkgName.equals(gitPackage.getName())) {
                            PluginMessages.log("Import excludes VCS package: " + pkgName);
                            toRemove.put(file, (Folder) file.getParent());
                        }
                    }
                }
            }
        }
    }
    if (!toRemove.isEmpty()) {
        getImportPackageWizard().getImportPackageSelectPage().setInfo("Some packages are not displayed since they exist in version control.");
        for (Map.Entry<File, Folder> file : toRemove.entrySet()) {
            Folder removeFrom = file.getValue();
            removeFrom.getChildren().remove(file.getKey());
            if (removeFrom.getChildren().isEmpty())
                emptyFolders.add(removeFrom);
        }
    }
    return emptyFolders;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Folder(com.centurylink.mdw.plugin.designer.model.Folder) File(com.centurylink.mdw.plugin.designer.model.File) Map(java.util.Map) HashMap(java.util.HashMap) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Aggregations

File (com.centurylink.mdw.plugin.designer.model.File)11 Folder (com.centurylink.mdw.plugin.designer.model.Folder)6 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)4 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)4 ArrayList (java.util.ArrayList)4 TestFile (com.centurylink.mdw.designer.testing.TestFile)3 JarFile (com.centurylink.mdw.plugin.designer.model.JarFile)3 IOException (java.io.IOException)3 URL (java.net.URL)3 IFile (org.eclipse.core.resources.IFile)3 JSONObject (org.json.JSONObject)3 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)2 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)2 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)2 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)2 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)2 AutomatedTestSuite (com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)2 LegacyExpectedResults (com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults)2 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)2 HashMap (java.util.HashMap)2