1 package org.splat.dal.bo.som;
4 * @author Daniel Brunier-Coulin
5 * @copyright OPEN CASCADE 2012
8 import java.util.Collections;
10 import java.util.Iterator;
11 import java.util.LinkedHashSet;
12 import java.util.List;
14 import java.util.Vector;
16 import org.apache.log4j.Logger;
18 import org.splat.dal.bo.kernel.User;
19 import org.splat.kernel.ObjectProperties;
20 import org.splat.kernel.InvalidPropertyException;
21 import org.splat.kernel.MissedPropertyException;
22 import org.splat.kernel.MultiplyDefinedException;
23 import org.splat.som.Step;
26 public abstract class ProjectElement extends Entity {
29 protected String title;
30 protected User manager;
31 protected Date credate; // Object creation date
32 protected Date lasdate; // Object Last modification date
33 private List<SimulationContext> contex; // Structured by the Step transient class
34 private Set<Publication> docums; // Structured by the Step transient class
37 private Step[] folders;
41 * @param folders the folders to set
43 public void setFolders(Step[] folders) {
44 this.folders = folders;
50 public Step[] getFolders() {
54 protected final static Logger logger = Logger.getLogger(ProjectElement.class);
56 // ==============================================================================================================================
58 // ==============================================================================================================================
60 // Database fetch constructor
61 protected ProjectElement () {
62 // ---------------------------
65 // Initialization constructor
66 protected ProjectElement (ObjectProperties oprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
67 // -------------------------------------------------
68 super(oprop); // Throws one of the above exception if not valid
69 title = null; // Initialized by subclasses
70 credate = null; // Initialized by subclasses
71 lasdate = null; // Initialized by subclasses
72 docums = new LinkedHashSet<Publication>();
73 contex = new Vector<SimulationContext>();
78 // ==============================================================================================================================
79 // Public member functions
80 // ==============================================================================================================================
82 public User getAuthor () {
83 // ------------------------
88 * Returns the creation date of this Project Element.
90 public Date getDate () {
91 // ----------------------
95 public String getDescription () {
96 // -------------------------------
97 String summary = null;
98 DescriptionAttribute field = (DescriptionAttribute)this.getAttribute(DescriptionAttribute.class);
99 if (field != null) summary = field.getValue();
100 return summary; // May be null
103 public Date getLastModificationDate () {
107 public void setLastModificationDate (Date aDate) {
112 * Returns the publication into this Project Element of the given document version, if exists.
113 * If exists, a document publication id unique in a given ProjectElement.
115 * @param doc a document version published into this Project Element
116 * @return the publication of the document version, or null if the given document version is not published into this Project Element
118 public Publication getPublication (Document doc) {
119 // ------------------------------------------------
120 long index = doc.getIndex();
121 for (Iterator<Publication> i=docums.iterator(); i.hasNext(); ) {
122 Publication found = i.next();
123 if (found.value().getIndex() == index) return found; // A document publication is unique in a given ProjectElement
128 public String getTitle () {
129 // -------------------------
133 public void setTitle (String aTitle) {
137 public boolean publishes (Document doc) {
138 // ---------------------------------------
139 long index = doc.getIndex();
140 for (Iterator<Publication> i=docums.iterator(); i.hasNext(); ) {
141 Document found = i.next().value();
142 if (found.getIndex() == index) return true;
147 public Iterator<Publication> PublicationIterator () {
148 // ---------------------------------------------------
149 return Collections.unmodifiableSet(docums).iterator();
152 public Iterator<SimulationContext> SimulationContextIterator () {
153 // ---------------------------------------------------------------
154 return Collections.unmodifiableList(contex).iterator();
157 // ==============================================================================================================================
158 // Protected member functions
159 // ==============================================================================================================================
161 public boolean add (Publication newdoc) {
162 // ------------------------------------------
163 return docums.add(newdoc);
166 public boolean add (SimulationContext newdoc) {
167 // ------------------------------------------------
168 return contex.add(newdoc);
171 public boolean remove (Publication oldoc) {
172 // --------------------------------------------
173 return docums.remove(oldoc); // The removed tag becoming orphan, it is supposed automatically deleted from the data store
176 public boolean remove (SimulationContext oldoc) {
177 // --------------------------------------------------
178 return contex.remove(oldoc);
184 public Set<Publication> getDocums() {