1 package org.splat.dal.bo.som;
5 * @author Daniel Brunier-Coulin
6 * @copyright OPEN CASCADE 2012
9 import java.util.Collections;
10 import java.util.Date;
11 import java.util.Iterator;
12 import java.util.LinkedHashSet;
13 import java.util.List;
15 import java.util.Vector;
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;
25 public abstract class ProjectElement extends Entity {
28 protected String title;
29 protected User manager;
30 protected Date credate; // Object creation date
31 protected Date lasdate; // Object Last modification date
32 private final List<SimulationContext> contex = new Vector<SimulationContext>(); // Structured by the Step transient class
33 private final Set<Publication> docums = new LinkedHashSet<Publication>(); // Structured by the Step transient class
36 * Transient array of steps (folders).
38 private Step[] folders;
41 * Set the transient array of steps (folders).
46 public void setFolders(final Step[] folders) {
47 this.folders = folders;
51 * Get the transient array of steps (folders).
53 * @return the array of steps
55 public Step[] getFolders() {
59 // ==============================================================================================================================
61 // ==============================================================================================================================
64 * Database fetch constructor.
66 protected ProjectElement() {
72 * Initialization constructor.
75 * @throws MissedPropertyException
76 * @throws InvalidPropertyException
77 * @throws MultiplyDefinedException
79 protected ProjectElement(final ObjectProperties oprop)
80 throws MissedPropertyException, InvalidPropertyException,
81 MultiplyDefinedException {
82 super(oprop); // Throws one of the above exception if not valid
83 title = null; // Initialized by subclasses
84 credate = null; // Initialized by subclasses
85 lasdate = null; // Initialized by subclasses
86 // RKV docums = new LinkedHashSet<Publication>();
87 // RKV contex = new Vector<SimulationContext>();
92 // ==============================================================================================================================
93 // Public member functions
94 // ==============================================================================================================================
96 public User getAuthor() {
101 * Returns the creation date of this Project Element.
103 public Date getDate() {
107 public String getDescription() {
108 String summary = null;
109 DescriptionAttribute field = (DescriptionAttribute) this
110 .getAttribute(DescriptionAttribute.class);
112 summary = field.getValue();
114 return summary; // May be null
117 public Date getLastModificationDate() {
121 public void setLastModificationDate(final Date aDate) {
126 * Returns the publication into this Project Element of the given document version, if exists. If exists, a document publication id
127 * unique in a given ProjectElement.
130 * a document version published into this Project Element
131 * @return the publication of the document version, or null if the given document version is not published into this Project Element
133 public Publication getPublication(final Document doc) {
134 long index = doc.getIndex();
135 for (Iterator<Publication> i = docums.iterator(); i.hasNext();) {
136 Publication found = i.next();
137 if (found.value().getIndex() == index) {
138 return found; // A document publication is unique in a given ProjectElement
144 public String getTitle() {
148 public void setTitle(final String aTitle) {
153 * Check if the given document is published in the scenario.
157 * @return true if the document is published in the scenario
159 public boolean publishes(final Document doc) {
161 long index = doc.getIndex();
162 for (Iterator<Publication> i = docums.iterator(); i.hasNext();) {
163 Document found = i.next().value();
164 res = (found.getIndex() == index);
172 public Iterator<Publication> PublicationIterator() {
173 return Collections.unmodifiableSet(docums).iterator();
176 public Iterator<SimulationContext> SimulationContextIterator() {
177 return Collections.unmodifiableList(contex).iterator();
180 // ==============================================================================================================================
181 // Protected member functions
182 // ==============================================================================================================================
184 public boolean add(final Publication newdoc) {
185 return docums.add(newdoc);
188 public boolean add(final SimulationContext newdoc) {
189 return contex.add(newdoc);
192 public boolean remove(final Publication oldoc) {
193 return docums.remove(oldoc); // The removed tag becoming orphan, it is supposed automatically deleted from the data store
196 public boolean remove(final SimulationContext oldoc) {
197 return contex.remove(oldoc);
205 public Set<Publication> getDocums() {
210 * Return the study of the project element.
212 * @return the project element study
214 public abstract Study getOwnerStudy();