]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Dependent not checked in documents are marked as outdated during checkin. Unit test...
authorrkv <rkv@opencascade.com>
Tue, 27 Nov 2012 13:03:07 +0000 (13:03 +0000)
committerrkv <rkv@opencascade.com>
Tue, 27 Nov 2012 13:03:07 +0000 (13:03 +0000)
Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java

index 659d5bd6d7f3b9d2aa57bdf205c25b8c0598ef2c..f32c3b40bb9b2deeaecbab54792fe73ab2b1a2cb 100644 (file)
@@ -33,6 +33,7 @@ import org.splat.dal.bo.som.Publication;
 import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.Study;
+import org.splat.dal.bo.som.UsedByRelation;
 import org.splat.dal.bo.som.UsesRelation;
 import org.splat.dal.dao.kernel.UserDAO;
 import org.splat.dal.dao.som.KnowledgeElementDAO;
@@ -531,8 +532,17 @@ public class ScenarioServiceImpl implements ScenarioService {
                                // Build the appropriate relation for the new version.
                                newVer.addDependency(usedDoc);
                        }
-                       // TODO: Outdate documents which depend from the previous version and were not checked in during this operation.
-
+                       // Outdate documents which depend from the previous version and
+                       // were not checked in during this operation.
+                       // 1. Get all usedBy relations of the previous document version
+                       for (Relation rel : prevDoc.getRelations(UsedByRelation.class)) {
+                               Document using = ((UsedByRelation) rel).getTo();
+                               // Check that not checked in dependent documents became outdated
+                               Publication usingPub = aScenario.getPublication(using);
+                               if (usingPub != null) { // if the document using the old version is still published
+                                       usingPub.setIsnew('O');
+                               }
+                       }
                }
 
                // For each new document create uses relation to the last versions of
index f455c4e49bf93501dee5a7d85e4ea877869cbfd4..005ddfb5033494c5e8203c87d5a7cfc0f8431727 100644 (file)
@@ -27,6 +27,7 @@ import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.Publication;
 import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.Study;
+import org.splat.dal.bo.som.UsedByRelation;
 import org.splat.dal.bo.som.UsesRelation;
 import org.splat.dal.bo.som.Document.Properties;
 import org.splat.dal.dao.som.Database;
@@ -346,6 +347,7 @@ public class TestScenarioService extends BaseTest {
                Assert.assertFalse(aScen.isCheckedout(),
                                "Scenario is still marked as checked out after checkin.");
                // Check that new document versions are created for checked in documents
+               boolean caseFound = false;
                for (StepDTO step : stepsToCheckin) {
                        for (DocumentDTO docDTO : step.getDocs()) {
                                if ((docDTO.getId() != 0) && (docDTO.getId() != null)) {
@@ -396,6 +398,22 @@ public class TestScenarioService extends BaseTest {
                                                        checkUsesRelation(newPub, toBeUsed);
                                                }
                                        }
+                                       // 1. Get all usedBy relations of the previous document version
+                                       for (Relation rel : prevDoc
+                                                       .getRelations(UsedByRelation.class)) {
+                                               Document using = ((UsedByRelation) rel).getTo();
+                                               // Check that not checked in dependent documents became outdated
+                                               Publication usingPub = aScen.getPublication(using);
+                                               if (usingPub != null) { // if the document using the old version is still published
+                                                       Assert.assertTrue(usingPub.isOutdated(),
+                                                                       "Not checked in dependent document "
+                                                                                       + using.getTitle() + " ("
+                                                                                       + using.getType().getName()
+                                                                                       + ") must become outdated.");
+                                                       caseFound = true;
+                                               }
+                                       }
+
                                } else {
                                        // Check that new documents are created for new data
                                        boolean found = false;
@@ -434,6 +452,8 @@ public class TestScenarioService extends BaseTest {
                                }
                        }
                }
+               Assert.assertTrue(caseFound,
+                               "Not checked in dependent documents must become outdated.");
 
                // ///////////////////////////////////////////////////////////
                // Call checkin method for a not existing id.