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;
17 import org.splat.dal.bo.kernel.Entity;
18 import org.splat.dal.bo.kernel.User;
19 import org.splat.kernel.InvalidPropertyException;
20 import org.splat.kernel.MissedPropertyException;
21 import org.splat.kernel.MultiplyDefinedException;
22 import org.splat.kernel.ObjectProperties;
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 final List<SimulationContext> contex = new Vector<SimulationContext>(); // Structured by the Step transient class
34 private final Set<Publication> docums = new LinkedHashSet<Publication>(); // Structured by the Step transient class
37 private Step[] folders;
41 * @param folders the folders to set
43 public void setFolders(final 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 (final 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 //RKV docums = new LinkedHashSet<Publication>();
73 //RKV 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);
100 summary = field.getValue();
102 return summary; // May be null
105 public Date getLastModificationDate () {
109 public void setLastModificationDate (final Date aDate) {
114 * Returns the publication into this Project Element of the given document version, if exists.
115 * If exists, a document publication id unique in a given ProjectElement.
117 * @param doc a document version published into this Project Element
118 * @return the publication of the document version, or null if the given document version is not published into this Project Element
120 public Publication getPublication (final Document doc) {
121 // ------------------------------------------------
122 long index = doc.getIndex();
123 for (Iterator<Publication> i=docums.iterator(); i.hasNext(); ) {
124 Publication found = i.next();
125 if (found.value().getIndex() == index) {
126 return found; // A document publication is unique in a given ProjectElement
132 public String getTitle () {
133 // -------------------------
137 public void setTitle (final String aTitle) {
141 public boolean publishes (final Document doc) {
142 // ---------------------------------------
143 long index = doc.getIndex();
144 for (Iterator<Publication> i=docums.iterator(); i.hasNext(); ) {
145 Document found = i.next().value();
146 if (found.getIndex() == index) {
153 public Iterator<Publication> PublicationIterator () {
154 // ---------------------------------------------------
155 return Collections.unmodifiableSet(docums).iterator();
158 public Iterator<SimulationContext> SimulationContextIterator () {
159 // ---------------------------------------------------------------
160 return Collections.unmodifiableList(contex).iterator();
163 // ==============================================================================================================================
164 // Protected member functions
165 // ==============================================================================================================================
167 public boolean add (final Publication newdoc) {
168 // ------------------------------------------
169 return docums.add(newdoc);
172 public boolean add (final SimulationContext newdoc) {
173 // ------------------------------------------------
174 return contex.add(newdoc);
177 public boolean remove (final Publication oldoc) {
178 // --------------------------------------------
179 return docums.remove(oldoc); // The removed tag becoming orphan, it is supposed automatically deleted from the data store
182 public boolean remove (final SimulationContext oldoc) {
183 // --------------------------------------------------
184 return contex.remove(oldoc);
190 public Set<Publication> getDocums() {