import org.splat.dal.bo.kernel.Relation;
import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.KnowledgeElementType;
User user = aScen.getAuthor();
long userId = user.getIndex();
-
// ////////////////////////////////////////////////////////
// Call checkin method for empty list of modules.
aScen = _scenarioDAO.get(scenarioId);
Assert.assertFalse(aScen.isCheckedout(),
"Scenario is still marked as checked out after checkin.");
-
-
-
+
// ////////////////////////////////////////////////////////
// Call checkin method for good prepared transient data.
steps = _scenarioService.getScenarioInfo(scenarioId);
_scenarioService.checkout(aScen, user);
+ // Remember modification dates of all attached files
+ Map<Long, Date> dates = new HashMap<Long, Date>();
+ for (Publication p : aScen.getDocums()) {
+ for (Relation r : p.value().getRelations(ConvertsRelation.class)) {
+ org.splat.dal.bo.som.File attach = ((ConvertsRelation) r)
+ .getTo();
+ dates.put(attach.getIndex(), attach.getDate());
+ }
+ }
+
// Prepare test data for checkin
// Checkin only two first steps (geom and mesh)
for (StepDTO step : steps) {
aScen = _scenarioDAO.get(scenarioId);
Assert.assertFalse(aScen.isCheckedout(),
"Scenario is still marked as checked out after checkin.");
+ boolean modifDatesChecked = false;
// Check that new document versions are created for checked in documents
for (StepDTO step : stepsToCheckin) {
for (DocumentDTO docDTO : step.getDocs()) {
Assert.assertFalse(aScen.publishes(prevDoc));
// Check that presentation of the previous version is removed
checkFiles(docDTO, newPub);
-
+
// Formats of files are new if they are according to the document's type on the study step
if ("py".equals(prevDoc.getFormat())
- && "geometry".equals(prevDoc.getType().getName())) {
- Assert.assertEquals(newPub.value().getFormat(), "brep");
- Assert.assertEquals(newPub.getSourceFile().getFormat(),
+ && "geometry".equals(prevDoc.getType()
+ .getName())) {
+ Assert.assertEquals(newPub.value().getFormat(),
"brep");
+ Assert.assertEquals(newPub.getSourceFile()
+ .getFormat(), "brep");
Assert.assertEquals(newPub.getSourceFile()
.getRelativePath().substring(
newPub.getSourceFile()
- .getRelativePath().lastIndexOf(
- '.') + 1), "brep");
+ .getRelativePath()
+ .lastIndexOf('.') + 1),
+ "brep");
}
// Check that uses relations are copied correctly
if ((lastPub.value().getPreviousVersion() != null)
&& (lastPub.value()
.getPreviousVersion()
- .getIndex() == used.getIndex())) {
+ .getIndex() == used
+ .getIndex())) {
toBeUsed = lastPub;
break;
}
Assert.assertTrue(attFile.asFile().exists(), "File "
+ docDTO.getFiles().get(0).getPath()
+ " attached to the document "
- + docDTO.getTitle() + "#" + docDTO.getId() + " doesn't exist");
- LOG.debug("Source format: " + curDoc.getFormat() + ", new format: " + newFormat);
+ + docDTO.getTitle() + "#" + docDTO.getId()
+ + " doesn't exist");
+ LOG.debug("Source format: " + curDoc.getFormat()
+ + ", new format: " + newFormat);
+ // Check that attachment with the same format is not duplicated.
+ int attachNb = 0;
+ for (Relation conv : curDoc
+ .getRelations(ConvertsRelation.class)) {
+ if (newFormat.equals(((ConvertsRelation) conv)
+ .getTo().getFormat())) {
+ attachNb++;
+ }
+ }
+ Assert
+ .assertEquals(attachNb, 1,
+ "Attachment with the same format must be only one.");
+
+ // Check that the attached file date is updated
+ if (dates.containsKey(attFile.getIndex())) {
+ Assert
+ .assertTrue(attFile.getDate().compareTo(
+ dates.get(attFile.getIndex())) > 0,
+ "Attachment modification date is not updated.");
+ modifDatesChecked = true;
+ }
}
-
} else {
// Check that new documents are created for new data
boolean found = false;
}
}
+ Assert
+ .assertTrue(
+ modifDatesChecked,
+ "No modification date is checked because no files were attached when attachment with same extension already exists.");
+
// ///////////////////////////////////////////////////////////
// Call checkin method for a not existing id.
try {
for (FileDTO file : doc.getFiles()) {
if (file.getPath().endsWith(format)
|| (file.getPath().endsWith("py") && (format
- .equals("brep") || format
- .equals("med")))) {
+ .equals("brep") || format.equals("med")))) {
// Create a file in the download directory
docToCheckin.addFile(createDownloadedFile(userId,
doc.getTitle() + "_result", format));
// <source-file>.brep
// <attached-file>.med
dprop.setName("document" + i++).setType(dtype);
-/* if (step.getNumber() > 3) {
- dprop.setFormat("med");
- } else {
-*/ dprop.setFormat("py");
-// }
+ /*
+ * if (step.getNumber() > 3) { dprop.setFormat("med"); } else {
+ */dprop.setFormat("py");
+ // }
dprop.setLocalPath(dprop.getName() + "." + dprop.getFormat());
Publication pub = createDoc(aScenario, aScStep, dprop, "med",
false);