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;
// 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
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;
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)) {
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;
}
}
}
+ Assert.assertTrue(caseFound,
+ "Not checked in dependent documents must become outdated.");
// ///////////////////////////////////////////////////////////
// Call checkin method for a not existing id.