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;
/**
* 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.
*/
// - Public services
+ @Override
public void clear() {
super.clear();
owner = null;
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;
}
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");
+ }
}
}
}
// 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;
}
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;
}
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()) {
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;
}
* 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);
}
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);
}
* @param kelm
* the scenario transient "use case" knowledge element
*/
- public void setUcase(KnowledgeElement kelm) {
+ public void setUcase(final KnowledgeElement kelm) {
ucase = kelm;
}
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