]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman-Common/src/org/splat/dal/bo/som/Scenario.java
Salome HOME
Document id generation is fixed. Document index is updated in the database now.
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / som / Scenario.java
index b2e154b9bc9188fddc5bd3ac1de09c3b6f8d0715..42b1e9799e0f42a1050438f0ffddeef423032822 100644 (file)
@@ -10,10 +10,10 @@ import java.util.Calendar;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
-import java.util.HashSet;
 import java.util.Vector;
 
 import org.splat.dal.bo.kernel.Persistent;
@@ -44,13 +44,13 @@ public class Scenario extends ProjectElement {
        /**
         * The persistent set of scenario knowledge elements.
         */
-       private Set<KnowledgeElement> kelms = new HashSet<KnowledgeElement>();
+       private final Set<KnowledgeElement> kelms = new HashSet<KnowledgeElement>();
 
        // Transient fields
        /**
         * The transient map of knowledge elements grouped by types.
         */
-       transient private HashMap<Long, List<KnowledgeElement>> known;
+       transient private final HashMap<Long, List<KnowledgeElement>> known;
        /**
         * The scenario transient list of knowledge elements.
         */
@@ -78,6 +78,7 @@ public class Scenario extends ProjectElement {
 
                // - Public services
 
+               @Override
                public void clear() {
                        super.clear();
                        owner = null;
@@ -103,46 +104,49 @@ public class Scenario extends ProjectElement {
                        return manager;
                }
 
-               public Properties setOwnerStudy(Study owner) {
+               public Properties setOwnerStudy(final Study owner) {
                        this.owner = owner;
                        return this;
                }
 
                // - Setters of Scenario properties
 
-               public Properties setBaseStep(Step base)
+               public Properties setBaseStep(final Step base)
                                throws InvalidPropertyException {
-                       if (!(base.getOwner() instanceof Scenario))
+                       if (!(base.getOwner() instanceof Scenario)) {
                                throw new InvalidPropertyException("step");
+                       }
                        this.base = base;
                        return this;
                }
 
-               public Properties setDate(Date date) {
+               public Properties setDate(final Date date) {
                        this.date = date;
                        return this;
                }
 
-               public Properties setDescription(String summary) {
-                       if (summary.length() > 0)
+               public Properties setDescription(final String summary) {
+                       if (summary.length() > 0) {
                                this.summary = summary;
+                       }
                        return this;
                }
 
-               public Properties setInsertAfter(Scenario previous) {
+               public Properties setInsertAfter(final Scenario previous) {
                        this.previous = previous;
                        return this;
                }
 
-               public Properties setManager(User user) {
+               public Properties setManager(final User user) {
                        this.manager = user;
                        return this;
                }
 
-               public Properties setTitle(String title)
+               public Properties setTitle(final String title)
                                throws InvalidPropertyException {
-                       if (title.length() == 0)
+                       if (title.length() == 0) {
                                throw new InvalidPropertyException("title");
+                       }
                        this.title = title;
                        return this;
                }
@@ -151,12 +155,15 @@ public class Scenario extends ProjectElement {
 
                public void checkValidity() throws MissedPropertyException,
                                InvalidPropertyException, MultiplyDefinedException {
-                       if (owner == null)
+                       if (owner == null) {
                                throw new MissedPropertyException("owner");
-                       if (title == null)
+                       }
+                       if (title == null) {
                                throw new MissedPropertyException("title");
-                       if (manager == null)
+                       }
+                       if (manager == null) {
                                throw new MissedPropertyException("manager");
+                       }
                }
        }
 
@@ -168,7 +175,7 @@ public class Scenario extends ProjectElement {
        }
 
        // Internal constructor
-       public Scenario(Properties sprop) throws MissedPropertyException,
+       public Scenario(final Properties sprop) throws MissedPropertyException,
                        InvalidPropertyException, MultiplyDefinedException {
                super(sprop); // Throws one of the above exception if not valid
                owner = sprop.owner;
@@ -190,13 +197,16 @@ public class Scenario extends ProjectElement {
                }
                lasdate = credate; // Inherited attribute
 
-               if (sprop.summary != null)
+               if (sprop.summary != null) {
                        this.setAttribute(new DescriptionAttribute(this, sprop.summary));
+               }
 
                Scenario[] scene = owner.getScenarii();
-               for (int i = 0; i < scene.length; i++)
-                       if (scene[i].sid > this.sid)
+               for (int i = 0; i < scene.length; i++) {
+                       if (scene[i].sid > this.sid) {
                                this.sid = scene[i].sid;
+                       }
+               }
                sid += 1;
        }
 
@@ -209,16 +219,17 @@ public class Scenario extends ProjectElement {
                        knowl = new Vector<KnowledgeElement>(kelms.size());
                        for (Iterator<KnowledgeElement> i = kelms.iterator(); i.hasNext();) {
                                KnowledgeElement kelm = i.next();
-                               if (kelm.getType().equals("usecase"))
+                               if (kelm.getType().equals("usecase")) {
                                        ucase = kelm;
-                               else
+                               } else {
                                        knowl.add(kelm);
+                               }
                        }
                }
                return Collections.unmodifiableList(knowl);
        }
 
-       public KnowledgeElement getKnowledgeElement(long l) {
+       public KnowledgeElement getKnowledgeElement(final long l) {
                for (Iterator<KnowledgeElement> i = kelms.iterator(); i.hasNext();) {
                        KnowledgeElement mykelm = i.next();
                        if (l == mykelm.getIndex()) {
@@ -228,28 +239,13 @@ public class Scenario extends ProjectElement {
                return null;
        }
 
-/* RKV: Not used
- *     public List<KnowledgeElement> getKnowledgeElementsOf(
-                       KnowledgeElementType type) {
-               if (known == null)
-                       known = new HashMap<Long, List<KnowledgeElement>>();
-
-               long numtype = type.getIndex();
-               List<KnowledgeElement> listype = known.get(numtype);
-               if (listype == null) {
-                       listype = new Vector<KnowledgeElement>();
-                       for (Iterator<KnowledgeElement> i = kelms.iterator(); i.hasNext();) {
-                               KnowledgeElement kelm = i.next();
-                               if (kelm.getType().getIndex() == numtype)
-                                       listype.add(kelm);
-                       }
-                       known.put(numtype, listype);
-               }
-               return listype; // No protection against this object corruption as it would not corrupt the database
-       }
-*/
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.dal.bo.som.ProjectElement#getOwnerStudy()
+        */
+       @Override
        public Study getOwnerStudy() {
-               // -----------------------------
                return owner;
        }
 
@@ -257,7 +253,6 @@ public class Scenario extends ProjectElement {
         * Returns the local reference of this scenario. This reference is unique in the scope of the owner study.
         */
        public String getReference() {
-               // -----------------------------
                return String.valueOf(sid);
        }
 
@@ -265,12 +260,11 @@ public class Scenario extends ProjectElement {
                return cuser; // Null if the scenario has not been checked-out
        }
 
-       public void setUser(User aUser) {
+       public void setUser(final User aUser) {
                cuser = aUser; // Null if the scenario has not been checked-out
        }
 
        public boolean isCheckedout() {
-               // ------------------------------
                return (cuser != null);
        }
 
@@ -301,7 +295,7 @@ public class Scenario extends ProjectElement {
         * @param kelm
         *            the scenario transient "use case" knowledge element
         */
-       public void setUcase(KnowledgeElement kelm) {
+       public void setUcase(final KnowledgeElement kelm) {
                ucase = kelm;
        }
 
@@ -313,14 +307,4 @@ public class Scenario extends ProjectElement {
        public KnowledgeElement getUcase() {
                return ucase;
        }
-
-       /**
-        * Get the known.
-        * 
-        * @return the known
-        */
-/* RKV: Not used
- *     public HashMap<Long, List<KnowledgeElement>> getKnowledgeByType() {
-               return known;
-       }
-*/}
\ No newline at end of file
+}
\ No newline at end of file