diff options
author | njames <nkskjames@gmail.com> | 2016-09-02 13:32:22 -0500 |
---|---|---|
committer | njames <nkskjames@gmail.com> | 2016-09-02 13:32:22 -0500 |
commit | aee0da8f1941a9cf90e52e08c659d4c40c6968a3 (patch) | |
tree | b2278d3198fb317d4ce8d1dbc9c182ada9f76f80 /src/com/ibm/ServerWizard2/model/SystemModel.java | |
parent | 5d05a5f56d9ecdf1aa93278e0f274a7ac44e1bc8 (diff) | |
download | serverwiz-aee0da8f1941a9cf90e52e08c659d4c40c6968a3.tar.gz serverwiz-aee0da8f1941a9cf90e52e08c659d4c40c6968a3.zip |
Keep track of already loaded libraries
Reloading a library can cause duplicates in library model
Signed-off-by: Norman James <nkskjames@gmail.com>
Diffstat (limited to 'src/com/ibm/ServerWizard2/model/SystemModel.java')
-rw-r--r-- | src/com/ibm/ServerWizard2/model/SystemModel.java | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/src/com/ibm/ServerWizard2/model/SystemModel.java b/src/com/ibm/ServerWizard2/model/SystemModel.java index 64c349a..07cc600 100644 --- a/src/com/ibm/ServerWizard2/model/SystemModel.java +++ b/src/com/ibm/ServerWizard2/model/SystemModel.java @@ -29,7 +29,6 @@ import com.ibm.ServerWizard2.ServerWizard2; import com.ibm.ServerWizard2.view.ErrataViewer; public class SystemModel { - // public Target rootTarget; public Vector<Target> rootTargets = new Vector<Target>(); private DocumentBuilder builder; @@ -58,11 +57,12 @@ public class SystemModel { private TreeMap<String, TreeMap<String, Field>> globalSettings = new TreeMap<String, TreeMap<String, Field>>(); + private HashMap<String,Boolean> loadedLibraries = new HashMap<String,Boolean>(); + public Boolean partsMode = false; public Boolean cleanupMode = false; public Boolean errataUpdated = false; - public Vector<Target> getBusTypes() { return busTypes; } @@ -200,6 +200,11 @@ public class SystemModel { return null; } public void loadLibrary(String path) throws Exception { + if (this.loadedLibraries.containsKey(path)) { + ServerWizard2.LOGGER.info("Library already loaded: "+path); + return; + } + this.loadedLibraries.put(path, true); File xmlDir = new File(path); //Loads files in alphabetical order String[] filesStr = xmlDir.list(); @@ -344,6 +349,9 @@ public class SystemModel { checkErrata(); } + /* + * Compare attributes in errata*.xml against currently loaded XML + */ public void checkErrata() { Vector<Errata> errataNew = new Vector<Errata>(); @@ -396,8 +404,9 @@ public class SystemModel { } } - /////////////////////////////////////////////// - // global settings + /* + * Global settings get/sets + */ public Field setGlobalSetting(String path, String attribute, String value) { TreeMap<String, Field> s = globalSettings.get(path); @@ -471,6 +480,9 @@ public class SystemModel { this.setGlobalSetting(targetId, property, value); } } + /* + * Read errata file + */ private void readErrata(Element setting) { String errata_id = SystemModel.getElement(setting, "id"); if (this.errata.containsKey(errata_id)) { @@ -479,8 +491,40 @@ public class SystemModel { } } - ///////////////////////////////////////////////// - // Writes MRW to file + /* + * Returns a vector of attributes located in the target and global settings + * associated with a particular target instance + */ + public Vector<Field> getAttributesAndGlobals(Target targetInstance, String path, Boolean showGlobalSettings) { + Vector<Field> attributes = new Vector<Field>(); + for (Map.Entry<String, Attribute> entry : targetInstance.getAttributes().entrySet()) { + Attribute attribute = entry.getValue(); + if (!attribute.isHidden()) { + if (attribute.isGlobal() && showGlobalSettings) { + if (!path.isEmpty()) { + Field field = getGlobalSetting(path, attribute.name); + if (field==null) { + setGlobalSetting(path, attribute.name, ""); + field = getGlobalSetting(path, attribute.name); + } + field.type = attribute.getValue().getType(); + if (field.type.equals("enumeration")) { + field.enumerator = attribute.getValue().getFields().get(0).enumerator; + } + attributes.add(field); + } + } else { + for (Field field : attribute.getValue().getFields()) + attributes.add(field); + } + } + } + return attributes; + } + + /* + * Write XML to a file + */ public void writeXML(String filename, Boolean partsMode) throws Exception { Writer out = new BufferedWriter(new FileWriter(filename)); String topTag = "systemInstance"; @@ -508,6 +552,9 @@ public class SystemModel { out.close(); } + /* + * Add a target instance to the model + */ public void addTarget(Target parentTarget, Target newTarget,Boolean pathMode) throws Exception { if (parentTarget == null) { this.rootTargets.add(newTarget); |