/** Fixes the imported library's system package guids with those base's. */ public static void fixImportLibrarySystemPackageGUIDs( MethodLibrary baseLibrary, MethodLibrary importLibraty) { HashMap pluginsMap = new HashMap(); List plugins = baseLibrary.getMethodPlugins(); for (int i = 0; i < plugins.size(); i++) { MethodPlugin plugin = (MethodPlugin) plugins.get(i); pluginsMap.put(plugin.getGuid(), plugin); } if (pluginsMap.isEmpty()) { return; } List importPluginsToFix = new ArrayList(); List importPlugins = importLibraty.getMethodPlugins(); for (int i = 0; i < importPlugins.size(); i++) { MethodPlugin plugin = (MethodPlugin) importPlugins.get(i); if (pluginsMap.containsKey(plugin.getGuid())) { importPluginsToFix.add(plugin); } } for (int i = 0; i < importPluginsToFix.size(); i++) { MethodPlugin importPlugin = (MethodPlugin) importPluginsToFix.get(i); MethodPlugin basePlugin = (MethodPlugin) pluginsMap.get(importPlugin.getGuid()); if (basePlugin == null) { continue; } List importPackages = TngUtil.getAllSystemPackages(importPlugin); HashMap importPackageMap = new HashMap(); for (int j = 0; j < importPackages.size(); j++) { MethodElement importPackage = (MethodElement) importPackages.get(j); importPackageMap.put(importPackage.getName(), importPackage); } List basePackages = TngUtil.getAllSystemPackages(basePlugin); for (int j = 0; j < basePackages.size(); j++) { MethodElement basePackage = (MethodElement) basePackages.get(j); MethodElement importPackage = (MethodElement) importPackageMap.get(basePackage.getName()); if (importPackage == null) { continue; } String guid = basePackage.getGuid(); if (!importPackage.getGuid().equals(guid)) { importPackage.setGuid(guid); } } } }
/** Collects elements in lib that may have type changes */ public static void collectPotentialTypeChanged(MethodLibrary lib, HashMap map) { for (Iterator it = lib.eAllContents(); it.hasNext(); ) { Object obj = it.next(); if (obj instanceof Guidance || obj instanceof Activity) { MethodElement elem = (MethodElement) obj; map.put(elem.getGuid(), elem); } } }
public int compare(Object o1, Object o2) { if (o1 == o2) return 0; o1 = getMethodElement(o1); if (o1 == null) { return 0; } o2 = getMethodElement(o2); if (o2 == null) { return 0; } MethodElement e1 = (MethodElement) o1; MethodElement e2 = (MethodElement) o2; Collator collator = Collator.getInstance(); ; return collator.compare(e1.getName() + e1.getGuid(), e2.getName() + e2.getGuid()); }