import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.KnowledgeElementType;
-import org.splat.dal.bo.som.ProjectElement;
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.ValidationCycle;
import org.splat.dal.bo.som.ValidationCycleRelation;
import org.splat.dal.bo.som.ValidationStep;
+import org.splat.dal.bo.som.VersionsRelation;
import org.splat.dal.bo.som.Document.Properties;
import org.splat.dal.dao.kernel.UserDAO;
import org.splat.dal.dao.som.Database;
createDocDTOForModule(stepToCheckin, "SMESH", "med", userId, step,
stepsToCheckin);
}
+ // /////////////////////////////////////////////////////////////////
// Do test checkin
_scenarioService.checkin(scenarioId, userId, stepsToCheckin);
&& "geometry".equals(prevDoc.getType()
.getName())) {
Assert.assertEquals(newPub.value().getFormat(),
- "brep");
+ newFormat);
Assert.assertEquals(newPub.getSourceFile()
- .getFormat(), "brep");
+ .getFormat(), newFormat);
Assert.assertEquals(newPub.getSourceFile()
.getRelativePath().substring(
newPub.getSourceFile()
.getRelativePath()
.lastIndexOf('.') + 1),
- "brep");
+ newFormat);
}
// Check that uses relations are copied correctly
+ ") must become outdated.");
}
}
+
+ // Check that a correct comment is generated for VersionsRelation
+ VersionsRelation versRel = (VersionsRelation) newPub
+ .value().getFirstRelation(
+ VersionsRelation.class);
+ Assert.assertNotNull(versRel,
+ "VersionsRelation must be created.");
+ Assert
+ .assertNotNull(versRel.getDescription(),
+ "VersionsRelation description was not generated.");
+ int descrLen = versRel.getDescription().length();
+ Assert.assertTrue(descrLen > 0,
+ "VersionsRelation description is empty.");
+ LOG.debug("Version description: "
+ + versRel.getDescription());
} else {
// Otherwise the new file format must differ from the previous one
// and the new file must be attached to the same document
|| (file.getPath().endsWith("py") && (format
.equals("brep") || format.equals("med")))) {
// Create a file in the download directory
- docToCheckin.addFile(createDownloadedFile(userId,
- doc.getTitle() + "_result", format));
+ if ("GEOM".equals(module)) {
+ // New version case
+ docToCheckin.addFile(createDownloadedFile(
+ userId, doc.getTitle() + "_newvers",
+ "py"));
+ } else {
+ // Attached generated result case
+ docToCheckin.addFile(createDownloadedFile(
+ userId, doc.getTitle() + "_result",
+ format));
+ }
}
}
}
return new FileDTO(filePath);
}
- /**
- * Create a file.
- *
- * @param fname
- * file name
- * @throws IOException
- * if file creation failed
- */
- private void createFile(final String fname) throws IOException {
- // Create a file in the download directory
- LOG.debug("Create file: " + fname);
- String filePath = fname;
- FileWriter fw = new FileWriter(filePath);
- fw.write("Simulation of " + fname + " data file at " + new Date());
- fw.close();
- }
-
- /**
- * Get path to the user's downloads directory. The directory is created if it is not exist yet.
- *
- * @param userId
- * user id
- * @return absolute path to downloads directory followed by slash
- */
- private String getDownloadPath(final long userId) {
- // Prepare download directory
- File tmpDir = _repositoryService.getDownloadDirectory(userId);
- if (!tmpDir.exists()) {
- Assert.assertTrue(tmpDir.mkdir(),
- "Can't create temporary directory: "
- + tmpDir.getAbsolutePath());
- }
-
- return tmpDir.getAbsolutePath() + "/";
- }
-
/**
* Create a persistent scenario for tests.
*
LOG.debug(">>>>> END testCopyStudyContent()");
}
- /**
- * Create a document and publish it in the project element.
- *
- * @param aProjElem
- * the project element
- * @param aStep
- * the project element step
- * @param docname
- * document name
- * @param dtype
- * document type
- * @return publication of the created document
- * @throws BusinessException
- * if document creation is failed
- * @throws IOException
- * if file creation is failed
- */
- private Publication addDoc(final ProjectElement aProjElem,
- final org.splat.som.Step aStep, final String docname,
- final DocumentType dtype) throws BusinessException, IOException {
- HibernateTemplate ht = getHibernateTemplate();
- // Add documents to the study activity
- Document.Properties dprop = new Document.Properties().setAuthor(
- aProjElem.getAuthor()).setDate(new Date()).setName(docname)
- .setType(dtype).setFormat("py");
- dprop.setLocalPath(dprop.getName() + "." + dprop.getFormat());
- dprop.setStep(aStep.getStep());
- Publication pub = _stepService.createDocument(aStep, dprop);
- pub.setStep(aStep);
- aProjElem.add(pub);
- aStep.getDocuments().add(pub);
- ht.saveOrUpdate(pub);
- ht.save(pub.value());
- // Add a converts relation
- // Attach a med file
- ht.saveOrUpdate(_publicationService.attach(pub, "med"));
- String filepath = pub.getSourceFile().asFile().getAbsolutePath();
- createFile(filepath);
- createFile(filepath.substring(0, filepath.lastIndexOf(".")) + ".med");
- return pub;
- }
-
- /**
- * Create a new version of the document.
- *
- * @param pub
- * the current document publication
- * @return the new document version publication
- * @throws IOException
- * if versioning is failed
- * @throws BusinessException
- * if versioning is failed
- */
- private Publication version(final Publication pub)
- throws BusinessException, IOException {
- Document.Properties dprop = new Document.Properties();
- dprop.setDocument(pub.value(), pub.getStep().getStep());
- dprop.setLocalPath(pub.value().getTitle() + "_v1");
- Publication newpub = _stepService.versionDocument(pub.getStep(), pub,
- dprop);
- pub.getOwner().getDocums().remove(pub);
- pub.getStep().getDocuments().remove(pub);
- pub.getOwner().add(newpub);
- pub.getStep().getDocuments().add(newpub);
- String filepath = newpub.getSourceFile().asFile().getAbsolutePath();
- createFile(filepath);
- return newpub;
- }
-
/**
* Test assigning a simulation context to a study.<BR>
* <B>Description :</B> <BR>