svn commit: r14079 - trunk/src_new/org/argouml: kernel persistence

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2008-02-04 14:18:59-0800
New Revision: 14079

Modified:
   trunk/src_new/org/argouml/kernel/MemberList.java
   trunk/src_new/org/argouml/kernel/Project.java
   trunk/src_new/org/argouml/kernel/ProjectImpl.java
   trunk/src_new/org/argouml/persistence/XmiFilePersister.java
   trunk/src_new/org/argouml/persistence/ZipFilePersister.java

Log:
Make the usage of the MemberList restricted to one location only. 

This in preparation of improving it, 

which is needed to solve a package dependency cycle between the kernel and the org.argouml.uml package.

Modified: trunk/src_new/org/argouml/kernel/MemberList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/MemberList.java?view=diff&rev=14079&p1=trunk/src_new/org/argouml/kernel/MemberList.java&p2=trunk/src_new/org/argouml/kernel/MemberList.java&r1=14078&r2=14079
==============================================================================
--- trunk/src_new/org/argouml/kernel/MemberList.java	(original)
+++ trunk/src_new/org/argouml/kernel/MemberList.java	2008-02-04 14:18:59-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2004-2007 The Regents of the University of California. All
+// Copyright (c) 2004-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
@@ -39,19 +39,30 @@
 /**
  * List of ProjectMembers. <p>
  * 
- * The project members are grouped into 3 categories: 
- * model, diagrams and the todo item list. <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. <p>
+ * diagrams must be read before todo items. (Dixit Bob in issue 2979.)
+ * The profile configuration is written last. <p>
  *
  * This implementation supports only 1 model member, 
- * multiple diagram members, and one todo list member.
+ * multiple diagram members, one todo list member, 
+ * and one profile configuration. <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, 
+ * and if multiple entries of the same type are allowed. <p>
+ * 
+ * In preparation, this class is made simpler by deprecating 
+ * all operations that are not part of the List interface.
  * 
  * @author Bob Tarling
  */
-public class MemberList implements List<ProjectMember> {
+class MemberList implements List<ProjectMember> {
 
     /**
      * Logger.
@@ -84,7 +95,7 @@
             setTodoList((AbstractProjectMember) member);
             return true;
         } else if (member instanceof ProfileConfiguration) {
-            setProfileConfiguration((AbstractProjectMember) member);
+            profileConfiguration = (AbstractProjectMember) member;
             return true;
         } else if (member instanceof ProjectMemberDiagram) {
             // otherwise add the diagram at the start
@@ -108,7 +119,7 @@
             return true;
         } else if (profileConfiguration == member) {
             LOG.info("Removing profile configuration");
-            setProfileConfiguration(null);
+            profileConfiguration = null;
             return true;
         } else {
             final boolean removed = diagramMembers.remove(member);
@@ -207,7 +218,10 @@
     /**
      * @param type the type of the member
      * @return the member of the project
+     * @deprecated by MVW in V0.25.2: no replacement needed since not used. 
+     * Rationale: this class should ONLY implement List, nothing more.
      */
+    @Deprecated
     public synchronized ProjectMember getMember(Class type) {
         if (type == ProjectMemberModel.class) {
             return model;
@@ -225,7 +239,10 @@
     /**
      * @param type the type of the member
      * @return the member of the project
+     * @deprecated by MVW in V0.25.2: no replacement needed since not used. 
+     * Rationale: this class should ONLY implement List, nothing more.
      */
+    @Deprecated
     public synchronized List getMembers(Class type) {
         if (type == ProjectMemberModel.class) {
             List<ProjectMember> temp = new ArrayList<ProjectMember>(1);
@@ -303,23 +320,23 @@
         throw new UnsupportedOperationException();
     }
 
-    public boolean containsAll(Collection<?> arg0) {
+    public boolean containsAll(Collection< ? > arg0) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean addAll(Collection<? extends ProjectMember> arg0) {
+    public boolean addAll(Collection< ? extends ProjectMember> arg0) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean addAll(int arg0, Collection<? extends ProjectMember> arg1) {
+    public boolean addAll(int arg0, Collection< ? extends ProjectMember> arg1) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean removeAll(Collection<?> arg0) {
+    public boolean removeAll(Collection< ? > arg0) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean retainAll(Collection<?> arg0) {
+    public boolean retainAll(Collection< ? > arg0) {
         throw new UnsupportedOperationException();
     }
 
@@ -347,10 +364,22 @@
         throw new UnsupportedOperationException();
     }
 
+    /**
+     * @return the project member
+     * @deprecated by MVW in V0.25.2: no replacement needed since not used. 
+     * Rationale: this class should ONLY implement List, nothing more.
+     */
+    @Deprecated
     public AbstractProjectMember getProfileConfiguration() {
         return profileConfiguration;
     }
 
+    /**
+     * @param profileConfig the new profile configuration
+     * @deprecated by MVW in V0.25.2: no replacement needed since not used. 
+     * Rationale: this class should ONLY implement List, nothing more.
+     */
+    @Deprecated
     public void setProfileConfiguration(AbstractProjectMember profileConfig) {
         profileConfiguration = profileConfig;
     }

Modified: trunk/src_new/org/argouml/kernel/Project.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/Project.java?view=diff&rev=14079&p1=trunk/src_new/org/argouml/kernel/Project.java&p2=trunk/src_new/org/argouml/kernel/Project.java&r1=14078&r2=14079
==============================================================================
--- trunk/src_new/org/argouml/kernel/Project.java	(original)
+++ trunk/src_new/org/argouml/kernel/Project.java	2008-02-04 14:18:59-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2007 The Regents of the University of California. All
+// Copyright (c) 2007-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
@@ -59,9 +59,11 @@
      *
      * @return The name (a String).
      * @deprecated by MVW in V0.25.4 - replaced by 
-     *     {@link org.argouml.persistence.PersistenceManager#getProjectBaseName(Project)}
+     *     {@link org.argouml.persistence.PersistenceManager
+     *     #getProjectBaseName(Project)}
      *     Rationale: Remove dependency on persistence subsystem.
      */
+    @Deprecated
     public String getBaseName();
 
     /**
@@ -77,9 +79,11 @@
      * @throws URISyntaxException if the argument cannot be converted to
      *         an URI.
      * @deprecated by MVW in V0.25.4 - replaced by 
-     *     {@link org.argouml.persistence.PersistenceManager#setProjectName(String, Project)}
+     *     {@link org.argouml.persistence.PersistenceManager
+     *     #setProjectName(String, Project)}
      *     Rationale: Remove dependency on persistence subsystem.
      */
+    @Deprecated
     public void setName(final String n) throws URISyntaxException;
 
     /**
@@ -94,16 +98,19 @@
      *
      * @param theUri The URI to set.
      * @deprecated by MVW in V0.25.4 - replaced by 
-     *     {@link org.argouml.persistence.PersistenceManager#setProjectURI(URI, Project)}
+     *     {@link org.argouml.persistence.PersistenceManager
+     *     #setProjectURI(URI, Project)}
      *     Rationale: Remove dependency on persistence subsystem.
      */
+    @Deprecated
     public void setURI(final URI theUri);
 
     /**
      * Set the URI for this project. <p>
      * 
      * Don't use this directly! Use instead:
-     * {@link org.argouml.persistence.PersistenceManager#setProjectURI(URI, Project)}
+     * {@link org.argouml.persistence.PersistenceManager
+     * #setProjectURI(URI, Project)}
      *
      * @param theUri The URI to set.
      */
@@ -151,7 +158,7 @@
      *
      * @return all members.
      */
-    public MemberList getMembers();
+    public List<ProjectMember> getMembers();
 
     /**
      * Add a member: ArgoDiagram, a UML Model, or a ProjectMemberTodoList.

Modified: trunk/src_new/org/argouml/kernel/ProjectImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/kernel/ProjectImpl.java?view=diff&rev=14079&p1=trunk/src_new/org/argouml/kernel/ProjectImpl.java&p2=trunk/src_new/org/argouml/kernel/ProjectImpl.java&r1=14078&r2=14079
==============================================================================
--- trunk/src_new/org/argouml/kernel/ProjectImpl.java	(original)
+++ trunk/src_new/org/argouml/kernel/ProjectImpl.java	2008-02-04 14:18:59-0800
@@ -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
@@ -50,13 +50,13 @@
 import org.argouml.i18n.Translator;
 import org.argouml.model.Model;
 import org.argouml.persistence.PersistenceManager;
+import org.argouml.profile.Profile;
 import org.argouml.uml.CommentEdge;
 import org.argouml.uml.ProjectMemberModel;
 import org.argouml.uml.cognitive.ProjectMemberTodoList;
 import org.argouml.uml.diagram.ArgoDiagram;
 import org.argouml.uml.diagram.DiagramFactory;
 import org.argouml.uml.diagram.ProjectMemberDiagram;
-import org.argouml.profile.Profile;
 import org.tigris.gef.presentation.Fig;
 
 /**
@@ -102,7 +102,7 @@
 
     // TODO: break into 3 main member types
     // model, diagram and other
-    private final MemberList members = new MemberList();
+    private final List<ProjectMember> members = new MemberList();
 
     private String historyFile;
 
@@ -274,7 +274,7 @@
     }
 
 
-    public MemberList getMembers() {
+    public List<ProjectMember> getMembers() {
         LOG.info("Getting the members there are " + members.size());
         return members;
     }
@@ -328,8 +328,8 @@
 
         boolean memberFound = false;
         Object currentMember =
-            members.getMember(ProjectMemberModel.class);
-        if (currentMember != null) {
+            members.get(0);
+        if (currentMember instanceof ProjectMemberModel) {
             Object currentModel =
                 ((ProjectMemberModel) currentMember).getModel();
             if (currentModel == m) {
@@ -819,8 +819,6 @@
 
     /**
      * Empty the trash can and permanently delete all objects that it contains.
-     * 
-     * @see org.argouml.kernel.Project#emptyTrashCan()
      */
     public void emptyTrashCan() {
         trashcan.clear();

Modified: trunk/src_new/org/argouml/persistence/XmiFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/persistence/XmiFilePersister.java?view=diff&rev=14079&p1=trunk/src_new/org/argouml/persistence/XmiFilePersister.java&p2=trunk/src_new/org/argouml/persistence/XmiFilePersister.java&r1=14078&r2=14079
==============================================================================
--- trunk/src_new/org/argouml/persistence/XmiFilePersister.java	(original)
+++ trunk/src_new/org/argouml/persistence/XmiFilePersister.java	2008-02-04 14:18:59-0800
@@ -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
@@ -178,11 +178,11 @@
         int size = project.getMembers().size();
         for (int i = 0; i < size; i++) {
             ProjectMember projectMember =
-                (ProjectMember) project.getMembers().get(i);
+                project.getMembers().get(i);
             if (projectMember.getType().equalsIgnoreCase(getExtension())) {
                 if (LOG.isInfoEnabled()) {
                     LOG.info("Saving member of type: "
-                            + ((ProjectMember) project.getMembers()
+                            + (project.getMembers()
                                     .get(i)).getType());
                 }
                 MemberFilePersister persister = new ModelMemberFilePersister();

Modified: trunk/src_new/org/argouml/persistence/ZipFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/persistence/ZipFilePersister.java?view=diff&rev=14079&p1=trunk/src_new/org/argouml/persistence/ZipFilePersister.java&p2=trunk/src_new/org/argouml/persistence/ZipFilePersister.java&r1=14078&r2=14079
==============================================================================
--- trunk/src_new/org/argouml/persistence/ZipFilePersister.java	(original)
+++ trunk/src_new/org/argouml/persistence/ZipFilePersister.java	2008-02-04 14:18:59-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2006 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
@@ -135,11 +135,11 @@
             int size = project.getMembers().size();
             for (int i = 0; i < size; i++) {
                 ProjectMember projectMember =
-                    (ProjectMember) project.getMembers().get(i);
+                    project.getMembers().get(i);
                 if (projectMember.getType().equalsIgnoreCase("xmi")) {
                     if (LOG.isInfoEnabled()) {
                         LOG.info("Saving member of type: "
-                              + ((ProjectMember) project.getMembers()
+                              + (project.getMembers()
                                     .get(i)).getType());
                     }
                     MemberFilePersister persister
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.