From 2c8dd55c08e69e1dde655dbd1bf5899bb4876ec7 Mon Sep 17 00:00:00 2001 From: rkv Date: Thu, 7 Nov 2013 05:39:16 +0000 Subject: [PATCH] VPV fix for the following case: Import the specification document : ex: Cahier des charges Import the 1st geometry script : e0_donnees.py uses Cahier des charges Import the 2nd geometry script : e1_geometrie.py uses Cahier des charges and e0_donnees Version the specification document. ==> There is no Information message like "Warning: The documents below will ...." --- .../src/org/splat/dal/bo/som/Publication.java | 452 +++++++++--------- 1 file changed, 236 insertions(+), 216 deletions(-) diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Publication.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Publication.java index cc0160f..41c72d4 100644 --- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Publication.java +++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Publication.java @@ -27,224 +27,244 @@ import org.splat.dal.bo.kernel.Relation; import org.splat.som.Step; /** - * Persistent class representing a tag of a document published in a study/scenario activity. + * Persistent class representing a tag of a document published in a + * study/scenario activity. */ public class Publication extends Persistent { - // Persistent fields - /** - * Persistent field. The published document. - */ - private Document mydoc; - /** - * Persistent field. Either Study or Scenario, depending on the step involved by the publication. - */ - private ProjectElement owner; - /** - * Persistent field. True if this references a document version new for the owner project element. - */ - private char isnew; - - // Transient fields - /** - * Transient field. The step where the document is published. - */ - private Step mystep; - - // ============================================================================================================================== - // Construction - // ============================================================================================================================== - - /** - * Get the mystep. - * - * @return the mystep - */ - public Step getStep() { - return mystep; - } - - /** - * Set the mystep. - * - * @param aStep - * the mystep to set - */ - public void setStep(final Step aStep) { - this.mystep = aStep; - } - - /** - * Database fetch constructor. - */ - public Publication() { - super(); - mystep = null; - } - - /** - * Internal constructors. - * - * @param doc - * the published document - * @param publisher - * the project element where the document is published - */ - public Publication(final Document doc, final ProjectElement publisher) { - super(); - mydoc = doc; - mystep = null; - owner = publisher; - isnew = 'Y'; - } - - // ============================================================================================================================== - // Member functions - // ============================================================================================================================== - - public Relation addDependency(final Publication to) { - return this.addDependency(to.value()); - } - - public Relation addDependency(final Document to) { - Relation res = null; - if (to != null) { - res = mydoc.addRelation(new UsesRelation(mydoc, to)); - } - return res; - } - - /** - * Returns either the Study Scenario or the Study itself to which this publication belongs, depending on the Study Step into which the - * referenced document has been published.
If this publication belongs to a Study, the Project Element returned is the Study - * returned by getOwnerStudy(). - * - * @return the Study Scenario or the Study to which this publication belongs to - * @see #getOwnerStudy() - */ - public ProjectElement getOwner() { - return owner; - } - - /** - * Set the owner. - * - * @param owner - * the owner to set - */ - public void setOwner(final ProjectElement owner) { - this.owner = owner; - } - - /** - * Returns the study where the document is published. - * - * @return the owner study - */ - public Study getOwnerStudy() { - return owner.getOwnerStudy(); - } - - /** - * Returns the state of this published document. It is the same than the state of the referenced document, unless this publication is - * out-of-date, in which case it is In-Work state. - * - * @see #outdate() - * @see #isOutdated() - * @return the document progress state - */ - public ProgressState getProgressState() { - ProgressState res; - if (this.isOutdated()) { - res = ProgressState.inWORK; // Overrides the document state - } else { - res = mydoc.getProgressState(); - } - return res; - } - - public List getRelations(final Class type) { - if (type == null) { - return null; - } - - List result = new ArrayList(); - List relist = mydoc.getRelations(type); - for (Iterator i = relist.iterator(); i.hasNext();) { - Relation relation = i.next(); - Document relatedoc = (Document) relation.getTo(); - Publication related = owner.getPublication(relatedoc); - if (related != null) { - result.add(related); - } else if (owner instanceof Scenario) { // The relation may cross steps belonging to a scenario and its owner study - related = owner.getOwnerStudy().getPublication(relatedoc); - if (related != null) { + // Persistent fields + /** + * Persistent field. The published document. + */ + private Document mydoc; + /** + * Persistent field. Either Study or Scenario, depending on the step + * involved by the publication. + */ + private ProjectElement owner; + /** + * Persistent field. True if this references a document version new for the + * owner project element. + */ + private char isnew; + + // Transient fields + /** + * Transient field. The step where the document is published. + */ + private Step mystep; + + // ============================================================================================================================== + // Construction + // ============================================================================================================================== + + /** + * Get the mystep. + * + * @return the mystep + */ + public Step getStep() { + return mystep; + } + + /** + * Set the mystep. + * + * @param aStep + * the mystep to set + */ + public void setStep(final Step aStep) { + this.mystep = aStep; + } + + /** + * Database fetch constructor. + */ + public Publication() { + super(); + mystep = null; + } + + /** + * Internal constructors. + * + * @param doc + * the published document + * @param publisher + * the project element where the document is published + */ + public Publication(final Document doc, final ProjectElement publisher) { + super(); + mydoc = doc; + mystep = null; + owner = publisher; + isnew = 'Y'; + } + + // ============================================================================================================================== + // Member functions + // ============================================================================================================================== + + public Relation addDependency(final Publication to) { + return this.addDependency(to.value()); + } + + public Relation addDependency(final Document to) { + Relation res = null; + if (to != null) { + res = mydoc.addRelation(new UsesRelation(mydoc, to)); + } + return res; + } + + /** + * Returns either the Study Scenario or the Study itself to which this + * publication belongs, depending on the Study Step into which the + * referenced document has been published.
+ * If this publication belongs to a Study, the Project Element returned is + * the Study returned by getOwnerStudy(). + * + * @return the Study Scenario or the Study to which this publication belongs + * to + * @see #getOwnerStudy() + */ + public ProjectElement getOwner() { + return owner; + } + + /** + * Set the owner. + * + * @param owner + * the owner to set + */ + public void setOwner(final ProjectElement owner) { + this.owner = owner; + } + + /** + * Returns the study where the document is published. + * + * @return the owner study + */ + public Study getOwnerStudy() { + return owner.getOwnerStudy(); + } + + /** + * Returns the state of this published document. It is the same than the + * state of the referenced document, unless this publication is out-of-date, + * in which case it is In-Work state. + * + * @see #outdate() + * @see #isOutdated() + * @return the document progress state + */ + public ProgressState getProgressState() { + ProgressState res; + if (this.isOutdated()) { + res = ProgressState.inWORK; // Overrides the document state + } else { + res = mydoc.getProgressState(); + } + return res; + } + + public List getRelations(final Class type) { + List result = null; + if (type != null) { + result = new ArrayList(); + List relist = mydoc.getRelations(type); + for (Iterator i = relist.iterator(); i.hasNext();) { + Relation relation = i.next(); + Document relatedoc = (Document) relation.getTo(); + Publication related = owner.getPublication(relatedoc); + + // Try to find the publication in scenarios + List list = owner.getOwnerStudy().getScenariiList(); + if (related == null) { + for (Scenario scen : list) { + related = scen.getPublication(relatedoc); + break; + } + } + + if (related == null) { + // If not found try to find the publication in the study + if (owner instanceof Scenario) { + related = owner.getOwnerStudy().getPublication( + relatedoc); + } + } + + if (related != null) { result.add(related); } - } - } - return result; - } - - public File getSourceFile() { - return mydoc.getSourceFile(); - } - - public boolean isNewForOwner() { - return (isnew == 'Y'); - } - - public boolean isOutdated() { - return (isnew == 'O'); - } - - /** - * Get the isnew. - * - * @return the isnew - */ - public char getIsnew() { - return isnew; - } - - /** - * Set the isnew. - * - * @param isnew - * the isnew to set - */ - public void setIsnew(final char isnew) { - this.isnew = isnew; - } - - /** - * Returns the document version referenced by this Publication. - */ - public Document value() { - return mydoc; - } - - /** - * Set the mydoc. - * - * @param mydoc - * the mydoc to set - */ - public void setValue(final Document aDoc) { - this.mydoc = aDoc; - } - - /** - * {@inheritDoc} - * - * @see org.splat.dal.bo.kernel.Persistent#evict() - */ - @Override - public void evict() { - super.evict(); - // Evict the document - if (value() != null) { - value().evict(); - } - } -} \ No newline at end of file + } + } + return result; + + } + + public File getSourceFile() { + return mydoc.getSourceFile(); + } + + public boolean isNewForOwner() { + return (isnew == 'Y'); + } + + public boolean isOutdated() { + return (isnew == 'O'); + } + + /** + * Get the isnew. + * + * @return the isnew + */ + public char getIsnew() { + return isnew; + } + + /** + * Set the isnew. + * + * @param isnew + * the isnew to set + */ + public void setIsnew(final char isnew) { + this.isnew = isnew; + } + + /** + * Returns the document version referenced by this Publication. + */ + public Document value() { + return mydoc; + } + + /** + * Set the mydoc. + * + * @param mydoc + * the mydoc to set + */ + public void setValue(final Document aDoc) { + this.mydoc = aDoc; + } + + /** + * {@inheritDoc} + * + * @see org.splat.dal.bo.kernel.Persistent#evict() + */ + @Override + public void evict() { + super.evict(); + // Evict the document + if (value() != null) { + value().evict(); + } + } +} -- 2.39.2