Salome HOME
Fix for generating a description for version relation during checkin.
authorrkv <rkv@opencascade.com>
Fri, 19 Apr 2013 08:07:45 +0000 (08:07 +0000)
committerrkv <rkv@opencascade.com>
Fri, 19 Apr 2013 08:07:45 +0000 (08:07 +0000)
Workspace/Siman-Common/src/conf/log-messages.properties
Workspace/Siman-Common/src/conf/log-messages_en.properties
Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java
Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java

index 9c638775a8bebb1e84a31717555e4f990cea4d64..7fec85490bf5431e421483f98dec31dd5e960f93 100644 (file)
@@ -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
index 9c638775a8bebb1e84a31717555e4f990cea4d64..7fec85490bf5431e421483f98dec31dd5e960f93 100644 (file)
@@ -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
index f8b08405a45ff14cb742bc0841850ff7721be9f3..39483be5a3cfc6e94e9dbc9f31313598e7027024 100644 (file)
@@ -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}.
         */
index 794dd9029d8a799238c577c7524ad9a97a886a60..d1a7f1b555ebdeadbb3ffbd50dd4adfd5d7391f7 100644 (file)
@@ -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());
                        }
index 5cf66d462b10e284686f611aa3590759aac6e6d8..baddb0191ebade1c24ed126f47637be8797899b6 100644 (file)
@@ -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));
+                                                       }
                                                }
                                        }
                                }