]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman-Common/src/org/splat/service/PublicationServiceImpl.java
Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / PublicationServiceImpl.java
index 1516ba4305010b555607115c84c8c5c4006cf76c..e5a6634855878a2646d3aa8bf72b22320dab9763 100644 (file)
@@ -26,14 +26,17 @@ import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.Timestamp;
+import org.splat.dal.bo.som.UsedByRelation;
 import org.splat.dal.bo.som.ValidationCycle;
 import org.splat.dal.bo.som.ValidationStep;
+import org.splat.dal.dao.som.Database;
 import org.splat.dal.dao.som.ProjectElementDAO;
 import org.splat.dal.dao.som.PublicationDAO;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.NotApplicableException;
 import org.splat.manox.Reader;
 import org.splat.manox.Toolbox;
+import org.splat.som.DocumentRights;
 import org.splat.som.Revision;
 import org.splat.som.Step;
 import org.springframework.transaction.annotation.Transactional;
@@ -107,8 +110,8 @@ public class PublicationServiceImpl implements PublicationService {
                ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
                                type);
                User approver = cycle.getActor(ValidationStep.APPROVAL);
-               Timestamp stamp = new Timestamp(ValidationStep.APPROVAL, aPublication
-                               .value(), approver, adate);
+               Timestamp stamp = new Timestamp(ValidationStep.APPROVAL,
+                               aPublication.value(), approver, adate);
                if (!getDocumentService().promote(aPublication.value(), stamp))
                        return null;
                if (getDocumentService().isStudyResult(type)
@@ -218,8 +221,8 @@ public class PublicationServiceImpl implements PublicationService {
                ValidationCycle cycle = getStudyService().getValidationCycleOf(owner,
                                type);
                User reviewer = cycle.getActor(ValidationStep.REVIEW);
-               Timestamp stamp = new Timestamp(ValidationStep.REVIEW, aPublication
-                               .value(), reviewer, rdate);
+               Timestamp stamp = new Timestamp(ValidationStep.REVIEW,
+                               aPublication.value(), reviewer, rdate);
                if (!getDocumentService().promote(aPublication.value(), stamp))
                        return null;
                if (getDocumentService().isStudyResult(type)
@@ -332,7 +335,7 @@ public class PublicationServiceImpl implements PublicationService {
                        return; // No properties extractor available for this type of document
 
                SimulationContextType.Properties sprop = new SimulationContextType.Properties()
-                               .setStep(to.getStep()).setState(ProgressState.APPROVED);
+                               .setStep(to.getStep()).setProgressState(ProgressState.APPROVED);
                List<SimulationContextType> contype = getSimulationContextService()
                                .selectTypesWhere(sprop);
                if (contype.isEmpty())
@@ -393,6 +396,46 @@ public class PublicationServiceImpl implements PublicationService {
                return aPublication.getStep();
        }
 
+       /**
+        * Undo the out-date operation.
+        * 
+        * @param aPublication
+        *            the publication
+        * @return true if the acceptance succeeds
+        * @see #outdate()
+        * @see DocumentRights#canAccept()
+        */
+       public boolean actualize(Publication aPublication) {
+               if (!aPublication.isOutdated())
+                       return false;
+               aPublication.setIsnew('Y');
+               getPublicationDAO().update(aPublication);
+               return true;
+       }
+
+       /**
+        * Out-dates this publication and recursively all publications using this one. Typically, a publication is out-dated when modifying a
+        * document to which it depends.
+        * 
+        * @param aPublication
+        *            the publication
+        * @see #isOutdated()
+        * @see #getProgressState()
+        * @see #actualize()
+        */
+       public void outdate(Publication aPublication) {
+               if (aPublication.isOutdated())
+                       return;
+
+               List<Publication> relist = aPublication
+                               .getRelations(UsedByRelation.class);
+               for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
+                       outdate(i.next());
+               }
+               aPublication.setIsnew('O');
+               getPublicationDAO().update(aPublication);
+       }
+
        /**
         * Create "Converts" relation for the given document publication and format.
         *