* @see org.splat.service.StepService#addSimulationContext(org.splat.som.Step, org.splat.dal.bo.som.SimulationContext.Properties)
*/
public SimulationContext addSimulationContext(final Step aStep,
- final SimulationContext.Properties dprop) throws MissedPropertyException,
- InvalidPropertyException, MultiplyDefinedException {
+ final SimulationContext.Properties dprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException {
SimulationContext context = new SimulationContext(dprop.setStep(aStep
.getStep()));
return addSimulationContext(aStep, context);
updateScenarioIndex(scene);
}
} catch (Exception error) {
- LOG.error("Unable to re-index Knowledge Elements, reason:",
- error);
+ LOG.error("Unable to re-index Knowledge Elements, reason:", error);
}
}
* @see org.splat.service.StepService#removeSimulationContext(org.splat.som.Step, org.splat.dal.bo.som.SimulationContext)
*/
@Transactional
- public boolean removeSimulationContext(final Step aStep, final SimulationContext context) {
+ public boolean removeSimulationContext(final Step aStep,
+ final SimulationContext context) {
SimulationContext torem = aStep
.getSimulationContext(context.getIndex());
* @see org.splat.service.StepService#createDocument(org.splat.som.Step, org.splat.dal.bo.som.Document.Properties)
*/
@Transactional
- public Publication createDocument(final Step aStep, final Document.Properties dprop)
- throws MissedPropertyException, InvalidPropertyException,
- MultiplyDefinedException, IOException {
+ public Publication createDocument(final Step aStep,
+ final Document.Properties dprop) throws MissedPropertyException,
+ InvalidPropertyException, MultiplyDefinedException, IOException {
Document newdoc = new Document(dprop.setOwner(aStep.getOwner())
.setStep(aStep.getStep()));
getDocumentService().generateDocumentId(newdoc, dprop);
* @throws MismatchException
* if the document is not applicable to the given study step
*/
- public Publication versionDocument(final Step aStep, final Publication base,
- final String reason) throws MissedPropertyException,
- InvalidPropertyException, MultiplyDefinedException, IOException,
- MismatchException {
+ public Publication versionDocument(final Step aStep,
+ final Publication base, final String reason)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException, IOException, MismatchException {
return versionDocument(aStep, base, new Document.Properties()
.setDescription(reason));
}
* if the document is not applicable to the given study step
*/
@Transactional
- public Publication versionDocument(final Step aStep, final Publication base,
- final Document.Properties dprop) throws MissedPropertyException,
- InvalidPropertyException, MultiplyDefinedException, IOException,
- MismatchException {
+ public Publication versionDocument(final Step aStep,
+ final Publication base, final Document.Properties dprop)
+ throws MissedPropertyException, InvalidPropertyException,
+ MultiplyDefinedException, IOException, MismatchException {
Document previous = base.value();
- dprop.setDocument(previous, getProjectSettings().getStep(base.getStep().getNumber())); // Initializes the Step property
+ // RKV: Keep the new file format if it is related to the same document type on this step.
+ String newFormat = dprop.getFormat();
+
+ dprop.setDocument(previous, getProjectSettings().getStep(
+ base.getStep().getNumber())); // Initializes the Step property
if (dprop.getStep().getNumber() != aStep.getNumber()) {
throw new MismatchException();
}
+ if (newFormat != null
+ && previous.getTitle().equals(
+ getProjectSettings().getDefaultDocumentType(
+ aStep.getStep(), newFormat))) {
+ dprop.setFormat(newFormat);
+ }
+
if (dprop.getAuthor() == null) {
dprop.setAuthor(previous.getAuthor());
}
// Versioning
VersionsRelation aRel;
aRel = new VersionsRelation(newdoc, previous, summary);
-// getVersionsRelationDAO().create(aRel);
+ // getVersionsRelationDAO().create(aRel);
newdoc.addRelation(aRel);
-
+
// Update of usedby relations, if exist
-/* RKV: Consider the new version as not used by old dependent documents.
- * So these documents must be marked as outdated then.
- List<Relation> relist = previous.getRelations(UsedByRelation.class);
- Study scope = aStep.getOwnerStudy();
- for (Iterator<Relation> i = relist.iterator(); i.hasNext();) {
- UsedByRelation relation = (UsedByRelation) i.next();
- Document relatedoc = relation.getTo();
- if (scope.shares(relatedoc)) {
- relatedoc.addRelation(new UsesRelation(relatedoc, newdoc));
- } else {
- relation.moveTo(newdoc);
- }
- }
-*/
+ /*
+ * RKV: Consider the new version as not used by old dependent documents. So these documents must be marked as outdated then. List<Relation>
+ * relist = previous.getRelations(UsedByRelation.class); Study scope = aStep.getOwnerStudy(); for (Iterator<Relation> i =
+ * relist.iterator(); i.hasNext();) { UsedByRelation relation = (UsedByRelation) i.next(); Document relatedoc = relation.getTo(); if
+ * (scope.shares(relatedoc)) { relatedoc.addRelation(new UsesRelation(relatedoc, newdoc)); } else { relation.moveTo(newdoc); } }
+ */
return new Publication(newdoc, aStep.getOwner());
}
* @param documentTypeService
* the documentTypeService to set
*/
- public void setDocumentTypeService(final DocumentTypeService documentTypeService) {
+ public void setDocumentTypeService(
+ final DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
/**
* Get the versionsRelationDAO.
+ *
* @return the versionsRelationDAO
*/
public VersionsRelationDAO getVersionsRelationDAO() {
/**
* Set the versionsRelationDAO.
- * @param versionsRelationDAO the versionsRelationDAO to set
+ *
+ * @param versionsRelationDAO
+ * the versionsRelationDAO to set
*/
- public void setVersionsRelationDAO(final VersionsRelationDAO versionsRelationDAO) {
+ public void setVersionsRelationDAO(
+ final VersionsRelationDAO versionsRelationDAO) {
_versionsRelationDAO = versionsRelationDAO;
}