Author: tfmorris
Date: 2008-04-29 15:49:07-0700
New Revision: 14521
Modified:
trunk/src/argouml-app/src/org/argouml/kernel/MemberList.java
trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java
trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java
trunk/src/argouml-app/src/org/argouml/persistence/ZargoFilePersister.java
Log:
issue 4946 - Bob's patches to make sure profile info gets written before XMI file
Modified: trunk/src/argouml-app/src/org/argouml/kernel/MemberList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/kernel/MemberList.java?view=diff&rev=14521&p1=trunk/src/argouml-app/src/org/argouml/kernel/MemberList.java&p2=trunk/src/argouml-app/src/org/argouml/kernel/MemberList.java&r1=14520&r2=14521
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/kernel/MemberList.java (original)
+++ trunk/src/argouml-app/src/org/argouml/kernel/MemberList.java 2008-04-29 15:49:07-0700
@@ -39,19 +39,25 @@
/**
* List of ProjectMembers. <p>
*
- * The project members are grouped into 4 categories:
+ * <p>The project members are grouped into 4 categories:
* model, diagrams, the todo item list and the profile configuration. <p>
*
- * The purpose of these categories is to make sure that members are read
- * and written in the correct order. The model must be read before diagrams,
- * diagrams must be read before todo items. (Dixit Bob in issue 2979.)
- * The profile configuration is written last. <p>
+ * <p>The purpose of these categories is to make sure that members are read
+ * and written in the correct order.
+ *
+ * <p>When reading the todo items it will fail if the diagrams elements or model
+ * elements have not yet been read that they refer to. When reading diagrams
+ * that will fail if the model elements don't yet exist that they refer to.
+ * When loading the model that may fail if the correct profile has not been
+ * loaded.
+ *
+ * <p>Hence, the save (and therefore load) order is profile, model, diagrams,
+ * todo items.
*
- * This implementation supports only 1 model member,
- * multiple diagram members, one todo list member,
- * and one profile configuration. <p>
+ * <p>This implementation supports only one profile configuration, one model
+ * member, multiple diagram members, one todo list member.
*
- * Comments by mvw: <p>
+ * <p>Comments by mvw: <p>
* This class should be reworked to be independent
* of the org.argouml.uml package. That can be done by extending the
* ProjectMember interface with functions returning the sorting order,
@@ -131,20 +137,27 @@
}
public synchronized Iterator<ProjectMember> iterator() {
- return buildTempList().iterator();
+ return buildOrderedMemberList().iterator();
}
public synchronized ListIterator<ProjectMember> listIterator() {
- return buildTempList().listIterator();
+ return buildOrderedMemberList().listIterator();
}
public synchronized ListIterator<ProjectMember> listIterator(int arg0) {
- return buildTempList().listIterator(arg0);
+ return buildOrderedMemberList().listIterator(arg0);
}
- private List<ProjectMember> buildTempList() {
+ /**
+ * @return the list of members in the order that they need to be written
+ * out in.
+ */
+ private List<ProjectMember> buildOrderedMemberList() {
List<ProjectMember> temp =
new ArrayList<ProjectMember>(size());
+ if (profileConfiguration != null) {
+ temp.add(profileConfiguration);
+ }
if (model != null) {
temp.add(model);
}
@@ -152,9 +165,6 @@
if (todoList != null) {
temp.add(todoList);
}
- if (profileConfiguration != null) {
- temp.add(profileConfiguration);
- }
return temp;
}
Modified: trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java?view=diff&rev=14521&p1=trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java&p2=trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java&r1=14520&r2=14521
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java 2008-04-29 15:49:07-0700
@@ -51,7 +51,7 @@
private ArgoTokenTable tokens = new ArgoTokenTable();
- private List memberList = new ArrayList();
+ private List<String> memberList = new ArrayList<String>();
/**
* The constructor.
@@ -326,14 +326,7 @@
throw new SAXException("XML element is null");
}
String type = e.getAttribute("type");
- // The members list dictates the order in which the
- // members are loaded. So make sure that XMI is at the top
- // and others below.
- if (type.equals("xmi")) {
- memberList.add(0, type);
- } else {
- memberList.add(type);
- }
+ memberList.add(type);
}
/**
@@ -478,7 +471,7 @@
* Get the number of diagram members read.
* @return the number of diagram members read.
*/
- public List getMemberList() {
+ public List<String> getMemberList() {
return memberList;
}
}
Modified: trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java?view=diff&rev=14521&p1=trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java&p2=trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java&r1=14520&r2=14521
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/UmlFilePersister.java 2008-04-29 15:49:07-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -261,48 +261,23 @@
}
writer.flush();
- // Write out XMI section first
- int size = project.getMembers().size();
- for (int i = 0; i < size; i++) {
- ProjectMember projectMember = project.getMembers().get(i);
- if (projectMember.getType().equalsIgnoreCase("xmi")) {
- if (LOG.isInfoEnabled()) {
- LOG.info("Saving member of type: "
- + project.getMembers().get(i).getType());
- }
- MemberFilePersister persister
- = getMemberFilePersister(projectMember);
- filteredStream.startEntry();
- persister.save(projectMember, filteredStream);
- try {
- filteredStream.flush();
- } catch (IOException e) {
- throw new SaveException(e);
- }
- }
- }
-
if (progressMgr != null) {
progressMgr.nextPhase();
}
- // Write out all non-XMI sections
- for (int i = 0; i < size; i++) {
- ProjectMember projectMember = project.getMembers().get(i);
- if (!projectMember.getType().equalsIgnoreCase("xmi")) {
- if (LOG.isInfoEnabled()) {
- LOG.info("Saving member of type: "
- + project.getMembers().get(i).getType());
- }
- MemberFilePersister persister
- = getMemberFilePersister(projectMember);
- filteredStream.startEntry();
- persister.save(projectMember, filteredStream);
- try {
- filteredStream.flush();
- } catch (IOException e) {
- throw new SaveException(e);
- }
+ // Note we assume members are ordered correctly already
+ for (ProjectMember projectMember : project.getMembers()) {
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Saving member : " + projectMember);
+ }
+ MemberFilePersister persister
+ = getMemberFilePersister(projectMember);
+ filteredStream.startEntry();
+ persister.save(projectMember, filteredStream);
+ try {
+ filteredStream.flush();
+ } catch (IOException e) {
+ throw new SaveException(e);
}
}
Modified: trunk/src/argouml-app/src/org/argouml/persistence/ZargoFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/ZargoFilePersister.java?view=diff&rev=14521&p1=trunk/src/argouml-app/src/org/argouml/persistence/ZargoFilePersister.java&p2=trunk/src/argouml-app/src/org/argouml/persistence/ZargoFilePersister.java&r1=14520&r2=14521
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/ZargoFilePersister.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/ZargoFilePersister.java 2008-04-29 15:49:07-0700
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -326,6 +326,8 @@
progressMgr.nextPhase();
+ copyMember(file, "profile", encoding, writer);
+
copyXmi(file, encoding, writer);
copyDiagrams(file, encoding, writer);
@@ -335,8 +337,6 @@
// will exist before creating critics.
copyMember(file, "todo", encoding, writer);
- copyMember(file, "profile", encoding, writer);
-
progressMgr.nextPhase();
writer.println("</uml>");
@@ -400,7 +400,7 @@
writer.println("<member type='todo' name='.todo' />");
}
if (containsProfile) {
- String type = ProfileConfiguration.EXTENSION;
+ String type = ProfileConfiguration.EXTENSION;
writer.println("<member type='" + type + "' name='."
+ type + "' />");
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.