package org.splat.dal.bo.som;
+
/**
*
* @author Daniel Brunier-Coulin
import org.splat.kernel.ObjectProperties;
import org.splat.som.Step;
-
public abstract class ProjectElement extends Entity {
-// Persistent fields
- protected String title;
- protected User manager;
- protected Date credate; // Object creation date
- protected Date lasdate; // Object Last modification date
- private final List<SimulationContext> contex = new Vector<SimulationContext>(); // Structured by the Step transient class
- private final Set<Publication> docums = new LinkedHashSet<Publication>(); // Structured by the Step transient class
+ // Persistent fields
+ protected String title;
+ protected User manager;
+ protected Date credate; // Object creation date
+ protected Date lasdate; // Object Last modification date
+ private final List<SimulationContext> contex = new Vector<SimulationContext>(); // Structured by the Step transient class
+ private final Set<Publication> docums = new LinkedHashSet<Publication>(); // Structured by the Step transient class
- /**
- * Transient array of steps (folders).
- */
- private Step[] folders;
+ /**
+ * Transient array of steps (folders).
+ */
+ private Step[] folders;
- /**
+ /**
* Set the transient array of steps (folders).
- * @param folders the steps to set
+ *
+ * @param folders
+ * the steps to set
*/
public void setFolders(final Step[] folders) {
this.folders = folders;
}
+
/**
* Get the transient array of steps (folders).
+ *
* @return the array of steps
*/
public Step[] getFolders() {
return folders;
}
-// ==============================================================================================================================
-// Constructors
-// ==============================================================================================================================
-
- /**
- * Database fetch constructor.
- */
- protected ProjectElement () {
- super();
- folders = null;
- }
- /**
- * Initialization constructor.
- * @param oprop
- * @throws MissedPropertyException
- * @throws InvalidPropertyException
- * @throws MultiplyDefinedException
- */
- protected ProjectElement (final ObjectProperties oprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
- super(oprop); // Throws one of the above exception if not valid
- title = null; // Initialized by subclasses
- credate = null; // Initialized by subclasses
- lasdate = null; // Initialized by subclasses
-//RKV docums = new LinkedHashSet<Publication>();
-//RKV contex = new Vector<SimulationContext>();
-
- folders = null;
- }
-
-// ==============================================================================================================================
-// Public member functions
-// ==============================================================================================================================
-
- public User getAuthor () {
- return manager;
- }
+ // ==============================================================================================================================
+ // Constructors
+ // ==============================================================================================================================
-/**
- * Returns the creation date of this Project Element.
- */
- public Date getDate () {
- return credate;
- }
-
- public String getDescription () {
- String summary = null;
- DescriptionAttribute field = (DescriptionAttribute)this.getAttribute(DescriptionAttribute.class);
- if (field != null) {
- summary = field.getValue();
- }
- return summary; // May be null
- }
-
- public Date getLastModificationDate () {
- return lasdate;
- }
-
- public void setLastModificationDate (final Date aDate) {
- lasdate = aDate;
- }
-
- /**
- * Returns the publication into this Project Element of the given document version, if exists.
- * If exists, a document publication id unique in a given ProjectElement.
- *
- * @param doc a document version published into this Project Element
- * @return the publication of the document version, or null if the given document version is not published into this Project Element
- */
- public Publication getPublication (final Document doc) {
- long index = doc.getIndex();
- for (Iterator<Publication> i=docums.iterator(); i.hasNext(); ) {
- Publication found = i.next();
- if (found.value().getIndex() == index) {
- return found; // A document publication is unique in a given ProjectElement
+ /**
+ * Database fetch constructor.
+ */
+ protected ProjectElement() {
+ super();
+ folders = null;
+ }
+
+ /**
+ * Initialization constructor.
+ *
+ * @param oprop
+ * @throws MissedPropertyException
+ * @throws InvalidPropertyException
+ * @throws MultiplyDefinedException
+ */
+ protected ProjectElement(final ObjectProperties oprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException {
+ super(oprop); // Throws one of the above exception if not valid
+ title = null; // Initialized by subclasses
+ credate = null; // Initialized by subclasses
+ lasdate = null; // Initialized by subclasses
+ // RKV docums = new LinkedHashSet<Publication>();
+ // RKV contex = new Vector<SimulationContext>();
+
+ folders = null;
+ }
+
+ // ==============================================================================================================================
+ // Public member functions
+ // ==============================================================================================================================
+
+ public User getAuthor() {
+ return manager;
+ }
+
+ /**
+ * Returns the creation date of this Project Element.
+ */
+ public Date getDate() {
+ return credate;
+ }
+
+ public String getDescription() {
+ String summary = null;
+ DescriptionAttribute field = (DescriptionAttribute) this
+ .getAttribute(DescriptionAttribute.class);
+ if (field != null) {
+ summary = field.getValue();
}
- }
- return null;
- }
-
- public String getTitle () {
- return title;
- }
-
- public void setTitle (final String aTitle) {
- title = aTitle;
- }
-
- public boolean publishes (final Document doc) {
- long index = doc.getIndex();
- for (Iterator<Publication> i=docums.iterator(); i.hasNext(); ) {
- Document found = i.next().value();
- if (found.getIndex() == index) {
- return true;
+ return summary; // May be null
+ }
+
+ public Date getLastModificationDate() {
+ return lasdate;
+ }
+
+ public void setLastModificationDate(final Date aDate) {
+ lasdate = aDate;
+ }
+
+ /**
+ * Returns the publication into this Project Element of the given document version, if exists. If exists, a document publication id
+ * unique in a given ProjectElement.
+ *
+ * @param doc
+ * a document version published into this Project Element
+ * @return the publication of the document version, or null if the given document version is not published into this Project Element
+ */
+ public Publication getPublication(final Document doc) {
+ long index = doc.getIndex();
+ for (Iterator<Publication> i = docums.iterator(); i.hasNext();) {
+ Publication found = i.next();
+ if (found.value().getIndex() == index) {
+ return found; // A document publication is unique in a given ProjectElement
+ }
}
- }
- return false;
- }
+ return null;
+ }
- public Iterator<Publication> PublicationIterator () {
- return Collections.unmodifiableSet(docums).iterator();
- }
+ public String getTitle() {
+ return title;
+ }
- public Iterator<SimulationContext> SimulationContextIterator () {
- return Collections.unmodifiableList(contex).iterator();
- }
+ public void setTitle(final String aTitle) {
+ title = aTitle;
+ }
-// ==============================================================================================================================
-// Protected member functions
-// ==============================================================================================================================
+ /**
+ * Check if the given document is published in the scenario.
+ *
+ * @param doc
+ * the document
+ * @return true if the document is published in the scenario
+ */
+ public boolean publishes(final Document doc) {
+ boolean res = false;
+ long index = doc.getIndex();
+ for (Iterator<Publication> i = docums.iterator(); i.hasNext();) {
+ Document found = i.next().value();
+ res = (found.getIndex() == index);
+ if (res) {
+ break;
+ }
+ }
+ return res;
+ }
+
+ public Iterator<Publication> PublicationIterator() {
+ return Collections.unmodifiableSet(docums).iterator();
+ }
+
+ public Iterator<SimulationContext> SimulationContextIterator() {
+ return Collections.unmodifiableList(contex).iterator();
+ }
- public boolean add (final Publication newdoc) {
- return docums.add(newdoc);
- }
+ // ==============================================================================================================================
+ // Protected member functions
+ // ==============================================================================================================================
- public boolean add (final SimulationContext newdoc) {
- return contex.add(newdoc);
- }
+ public boolean add(final Publication newdoc) {
+ return docums.add(newdoc);
+ }
+
+ public boolean add(final SimulationContext newdoc) {
+ return contex.add(newdoc);
+ }
- public boolean remove (final Publication oldoc) {
- return docums.remove(oldoc); // The removed tag becoming orphan, it is supposed automatically deleted from the data store
- }
+ public boolean remove(final Publication oldoc) {
+ return docums.remove(oldoc); // The removed tag becoming orphan, it is supposed automatically deleted from the data store
+ }
+
+ public boolean remove(final SimulationContext oldoc) {
+ return contex.remove(oldoc);
+ }
- public boolean remove (final SimulationContext oldoc) {
- return contex.remove(oldoc);
- }
/**
* Get the docums.
+ *
* @return the docums
*/
public Set<Publication> getDocums() {