From: rkv Date: Fri, 19 Apr 2013 08:07:45 +0000 (+0000) Subject: Fix for generating a description for version relation during checkin. X-Git-Tag: Root_Delivery2_2013_04_22~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a5ad17dfa926241e6a75e698e7c30ed2041ed026;p=tools%2Fsiman.git Fix for generating a description for version relation during checkin. --- diff --git a/Workspace/Siman-Common/src/conf/log-messages.properties b/Workspace/Siman-Common/src/conf/log-messages.properties index 9c63877..7fec854 100644 --- a/Workspace/Siman-Common/src/conf/log-messages.properties +++ b/Workspace/Siman-Common/src/conf/log-messages.properties @@ -21,5 +21,6 @@ DCT-000001=Document type "{0}" already exists DCT-000002=Can not delete the document "{0}" because it is used by other documents. DCT-000003=Can not save a document in {0} state. Check the validation cycle. DCT-000004=The source file can not be replaced. The document must be external or in In-Work state. +DCT-000005=Document checked in by {0} PRM-000001=Parameter {0} is invalid with value: {1} IDT-000001=Incompatible data: X-units or Y-units are not the same for all comparable studies. \ No newline at end of file diff --git a/Workspace/Siman-Common/src/conf/log-messages_en.properties b/Workspace/Siman-Common/src/conf/log-messages_en.properties index 9c63877..7fec854 100644 --- a/Workspace/Siman-Common/src/conf/log-messages_en.properties +++ b/Workspace/Siman-Common/src/conf/log-messages_en.properties @@ -21,5 +21,6 @@ DCT-000001=Document type "{0}" already exists DCT-000002=Can not delete the document "{0}" because it is used by other documents. DCT-000003=Can not save a document in {0} state. Check the validation cycle. DCT-000004=The source file can not be replaced. The document must be external or in In-Work state. +DCT-000005=Document checked in by {0} PRM-000001=Parameter {0} is invalid with value: {1} IDT-000001=Incompatible data: X-units or Y-units are not the same for all comparable studies. \ No newline at end of file diff --git a/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java b/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java index f8b0840..39483be 100644 --- a/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java +++ b/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java @@ -105,6 +105,10 @@ public enum MessageKeyEnum { * DCT-000004=The source file can not be replaced. The document must be external or in In-Work state. */ DCT_000004("DCT-000004"), + /** + * DCT-000005=Document checked in by {0}. + */ + DCT_000005("DCT-000005"), /** * Parameter {0} is invalid with value: {1}. */ diff --git a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java index 794dd90..d1a7f1b 100644 --- a/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java @@ -930,6 +930,11 @@ public class ScenarioServiceImpl implements ScenarioService { // Attach the file via ConvertsRelation, create a new document or // create a new version of the document dprop.setAuthor(aUser).setDate(aDate).setFormat(fileFormat); + String authorName = I18nUtils.getMessageLocaleDefault(aUser + .getDisplayName()); + String summary = I18nUtils.getMessageLocaleDefault( + MessageKeyEnum.DCT_000005.toString(), authorName); + dprop.setDescription(summary); if (doc.getId() > 0) { checkinExistingDoc(step, doc, dprop, fileFormat, upfile, @@ -954,7 +959,7 @@ public class ScenarioServiceImpl implements ScenarioService { } docname += "_" + i; // The generated new document title - dprop.setDescription("Checked in").setName(docname); + dprop.setName(docname); Publication newPub = getStepService().createDocument(step, dprop); @@ -1049,7 +1054,7 @@ public class ScenarioServiceImpl implements ScenarioService { } else { // If an attachment with this extension already exists then // replace it by the new one - moveFile(upfile,attach.asFile()); + moveFile(upfile, attach.asFile()); // Update attached file modification date attach.setDate(new Date()); } diff --git a/Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java b/Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java index 5cf66d4..baddb01 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java @@ -37,6 +37,7 @@ import org.splat.dal.bo.som.UsesRelation; 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; @@ -457,6 +458,7 @@ public class TestScenarioService extends BaseTest { createDocDTOForModule(stepToCheckin, "SMESH", "med", userId, step, stepsToCheckin); } + // ///////////////////////////////////////////////////////////////// // Do test checkin _scenarioService.checkin(scenarioId, userId, stepsToCheckin); @@ -511,15 +513,15 @@ public class TestScenarioService extends BaseTest { && "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 @@ -563,6 +565,21 @@ public class TestScenarioService extends BaseTest { + ") 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 @@ -769,8 +786,17 @@ public class TestScenarioService extends BaseTest { || (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)); + } } } }