]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Fix: document format always has been taken from the previous version of the document...
authorrkv <rkv@opencascade.com>
Tue, 11 Dec 2012 10:42:44 +0000 (10:42 +0000)
committerrkv <rkv@opencascade.com>
Tue, 11 Dec 2012 10:42:44 +0000 (10:42 +0000)
Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java
Workspace/Siman-Common/src/test/som-without-mappings.xml
Workspace/Siman-Common/src/test/som.xml
Workspace/Siman-Common/src/test/splat/service/TestProjectSettingsService.java
Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java
Workspace/Siman/WebContent/conf/som.xml

index fa1f31e41249a8e8145737f1a681db57d9de656d..55f75248b302d0b55e2ab19f165559a8a08cfcec 100644 (file)
@@ -585,7 +585,16 @@ public class ScenarioServiceImpl implements ScenarioService {
                                        throw new MismatchException(MessageKeyEnum.SCN_000002
                                                        .toString(), doc.getId());
                                }
+                               if (LOG.isDebugEnabled()) {
+                                       LOG.debug("Old format: " + pub.value().getFormat()
+                                                       + " => New format: " + fileFormat);
+                               }
                                newPub = getStepService().versionDocument(step, pub, dprop);
+                               if (LOG.isDebugEnabled()) {
+                                       LOG.debug("Created document type: "
+                                                       + newPub.value().getType().getName() + ", format: "
+                                                       + newPub.value().getFormat());
+                               }
                                // Remeber the link from the old document to the new document version
                                newVersion.put(pub.value(), newPub.value());
                                // Remember the new version publication
@@ -892,7 +901,7 @@ public class ScenarioServiceImpl implements ScenarioService {
                KnowledgeElement torem = scenario.getKnowledgeElement(kelm.getIndex());
                boolean isOk = (torem != null);
                if (isOk) {
-                       isOk =  scenario.getKnowledgeElements().remove(torem);
+                       isOk = scenario.getKnowledgeElements().remove(torem);
                        if (isOk) {
                                getScenarioDAO().merge(scenario);
                                // Update of my transient data
index 9c2458daec7d4ffadb38381a4d2c202c74166c9d..4aae91f4cee24acfae520f79c0d1e411820784c6 100644 (file)
@@ -364,7 +364,7 @@ public class StepServiceImpl implements StepService {
                }
 
                if (newFormat != null
-                               && previous.getTitle().equals(
+                               && previous.getType().equals(
                                                getProjectSettings().getDefaultDocumentType(
                                                                aStep.getStep(), newFormat))) {
                        dprop.setFormat(newFormat);
index 0aeae571eac42fa78b356436926a13f0d5ae69ac..c3db0a43c3577eed1fb26cd227c303ec1422b1c8 100644 (file)
@@ -6,7 +6,7 @@
 <!-- 1. Database physical location
      -->
     <database>
-        <repository disk="D:/users/rkv/SALOME_SIMER/rep" />
+        <repository disk="D:/users/rkv/SALOME_SIMER/testrep" />
     </database>
 
 
index 64bcd7c8fa779cdb155f99fffc1aca8c58c99fc9..d6a34ef1cf01e8941139a527e5ed1da9a32e04f5 100644 (file)
@@ -6,7 +6,7 @@
 <!-- 1. Database physical location
      -->
     <database>
-        <repository disk="D:/users/rkv/SALOME_SIMER/rep" />
+        <repository disk="D:/users/rkv/SALOME_SIMER/testrep" />
     </database>
 
 
             <mapping extension="sldasm" type="geometry"/>          <!-- SolidWorks Assembly             -->
             <mapping extension="part"   type="geometry"/>          <!-- GEOM Part                       -->
             <mapping extension="py"     type="geometry"/>          <!-- GEOM Python script              -->
+            <mapping extension="brep"   type="geometry"/>          <!-- GEOM Part                       -->
         </step>
         <step number="4">
             <mapping extension="doc"    type="memorandum"/>
index c1fc9a59d4151e19584dd8195e85d5b813e0c97e..a8aab568bb470878e5774f5b3d4aedcbab4a2878 100644 (file)
@@ -301,7 +301,7 @@ public class TestProjectSettingsService extends BaseTest {
                                                        "design");
                                        break;
                                case 3:
-                                       Assert.assertEquals(defTypes.size(), 7);
+                                       Assert.assertEquals(defTypes.size(), 8);
                                        Assert.assertNull(_projectSettings.getDefaultDocumentType(
                                                        step, "pdf"));
                                        Assert.assertNotNull(_projectSettings
@@ -324,6 +324,11 @@ public class TestProjectSettingsService extends BaseTest {
                                        Assert.assertEquals(_projectSettings
                                                        .getDefaultDocumentType(step, "py").getName(),
                                                        "geometry");
+                                       Assert.assertNotNull(_projectSettings
+                                                       .getDefaultDocumentType(step, "brep"));
+                                       Assert.assertEquals(_projectSettings
+                                                       .getDefaultDocumentType(step, "brep").getName(),
+                                                       "geometry");
                                        Assert.assertNotNull(_projectSettings
                                                        .getDefaultDocumentType(step, "doc"));
                                        Assert.assertEquals(_projectSettings
index ef5fce11787e722d04a9bd41a92b11e248d00d9b..d5e5b43ae04cf5d18e1db031f28f0f112aaade85 100644 (file)
@@ -220,8 +220,9 @@ public class TestScenarioService extends BaseTest {
                                                Assert.assertEquals(doc.getTitle(), docName);
                                                Assert.assertNotNull(doc.getFiles(),
                                                                "Document files list must not be null.");
-                                               Assert.assertTrue(doc.getFiles().size() > 1,
-                                                               "Document must have more then 1 attached file.");
+                                               Assert
+                                                               .assertTrue(doc.getFiles().size() > 1,
+                                                                               "Document must have more then 1 attached file.");
 
                                                for (FileDTO file : doc.getFiles()) {
                                                        Assert.assertNotNull(file.getPath(),
@@ -256,9 +257,10 @@ public class TestScenarioService extends BaseTest {
                                                        } else { // Outdated
                                                                Assert.assertEquals(file.getState(), 'O',
                                                                                "File state must be outdated ('O').");
-                                                               Assert.assertEquals(file.getProcessing(),
-                                                                               "file-download",
-                                                                               "Outdated document should not be imported but downloaded.");
+                                                               Assert
+                                                                               .assertEquals(file.getProcessing(),
+                                                                                               "file-download",
+                                                                                               "Outdated document should not be imported but downloaded.");
                                                        }
                                                }
                                        }
@@ -271,7 +273,8 @@ public class TestScenarioService extends BaseTest {
                try {
                        steps = _scenarioService.getScenarioInfo(-1L);
                        // getHibernateTemplate().flush();
-                       Assert.fail("Getting an object with not existing id must be failed.");
+                       Assert
+                                       .fail("Getting an object with not existing id must be failed.");
                } catch (Exception e) {
                        LOG.debug("Expected exception is thrown: "
                                        + e.getClass().getSimpleName() + ": " + e.getMessage());
@@ -291,6 +294,7 @@ public class TestScenarioService extends BaseTest {
         * <li>presentation of the previous version is removed</li>
         * <li>uses relations are copied correctly</li>
         * <li>files are moved correctly</li>
+        * <li>formats of files are new if they are according to the document's type on the study step</li>
         * <li>new documents are created for new data</li>
         * <li>new documents have correctly generated names</li>
         * <li>uses relations are created correctly</li>
@@ -388,8 +392,7 @@ public class TestScenarioService extends BaseTest {
                                                        }
                                                }
                                        }
-                                       Assert.assertTrue(
-                                                       found,
+                                       Assert.assertTrue(found,
                                                        "New version of the existing checked in document \""
                                                                        + docDTO.getTitle() + "\" (id="
                                                                        + docDTO.getId()
@@ -397,6 +400,20 @@ public class TestScenarioService extends BaseTest {
                                        // Check that presentation of the previous version is removed
                                        Assert.assertFalse(aScen.publishes(prevDoc));
                                        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(),
+                                                               "brep");
+                                               Assert.assertEquals(newPub.getSourceFile()
+                                                               .getRelativePath().substring(
+                                                                               newPub.getSourceFile()
+                                                                                               .getRelativePath().lastIndexOf(
+                                                                                                               '.') + 1), "brep");
+                                       }
+
                                        // Check that uses relations are copied correctly
 
                                        // 1. Get all uses relations of the previous document version
@@ -452,8 +469,9 @@ public class TestScenarioService extends BaseTest {
                                                                                .getSourceFile().asFile());
                                                                found = fcontent.contains(docDTO.getTitle());
                                                                if (found) {
-                                                                       LOG.debug("Found new document with generated title: "
-                                                                                       + pub.value().getTitle());
+                                                                       LOG
+                                                                                       .debug("Found new document with generated title: "
+                                                                                                       + pub.value().getTitle());
                                                                        newPub = pub;
                                                                        break;
                                                                }
@@ -463,13 +481,10 @@ public class TestScenarioService extends BaseTest {
                                        Assert.assertTrue(found,
                                                        "New document is not created for checked in document \""
                                                                        + docDTO.getTitle() + "\".");
+
                                        // Check that uses relations are created correctly
-                                       Assert.assertTrue(
-                                                       newPub.value()
-                                                                       .getTitle()
-                                                                       .startsWith(
-                                                                                       newPub.value().getType().getName()
-                                                                                                       + "_"),
+                                       Assert.assertTrue(newPub.value().getTitle().startsWith(
+                                                       newPub.value().getType().getName() + "_"),
                                                        "Document title newPub.value().getTitle() must start with "
                                                                        + newPub.value().getType().getName() + "_");
 
@@ -499,7 +514,8 @@ public class TestScenarioService extends BaseTest {
                // Call checkin method for a not existing id.
                try {
                        _scenarioService.checkin(-1, userId, stepsToCheckin);
-                       Assert.fail("Check in for scenario with not existing id must be failed.");
+                       Assert
+                                       .fail("Check in for scenario with not existing id must be failed.");
                } catch (Exception e) {
                        LOG.debug("Expected exception is thrown: "
                                        + e.getClass().getSimpleName() + ": " + e.getMessage());
@@ -558,7 +574,7 @@ public class TestScenarioService extends BaseTest {
                        String format = fileDTO.getPath().substring(
                                        fileDTO.getPath().lastIndexOf('.') + 1);
                }
-               // TODO:Check file by its internal content
+               // TODO: Check file by its internal content
                Assert.assertTrue(newPub.getSourceFile().exists(), "File "
                                + newPub.getSourceFile().asFile().getAbsolutePath()
                                + " for the document " + docDTO.getTitle()
@@ -600,7 +616,9 @@ public class TestScenarioService extends BaseTest {
                                        DocumentDTO docToCheckin = stepToCheckin.addDoc(
                                                        doc.getId(), doc.getTitle());
                                        for (FileDTO file : doc.getFiles()) {
-                                               if (file.getPath().endsWith(format)) {
+                                               if (file.getPath().endsWith(format)
+                                                               || (file.getPath().endsWith("py") && format
+                                                                               .equals("brep"))) {
                                                        // Create a file in the download directory
                                                        docToCheckin.addFile(createDownloadedFile(userId,
                                                                        doc.getTitle() + "_result", format));
@@ -610,8 +628,8 @@ public class TestScenarioService extends BaseTest {
                        }
                        // Prepare new data
                        stepToCheckin.addDoc(0, "newdoc" + stepFrom.getNumber()).addFile(
-                                       createDownloadedFile(userId,
-                                                       "newdoc" + stepFrom.getNumber(), "brep"));
+                                       createDownloadedFile(userId, "newdoc"
+                                                       + stepFrom.getNumber(), "brep"));
                }
                return stepToCheckin;
        }
@@ -651,8 +669,7 @@ public class TestScenarioService extends BaseTest {
                // Prepare download directory
                File tmpDir = _repositoryService.getDownloadDirectory(userId);
                if (!tmpDir.exists()) {
-                       Assert.assertTrue(
-                                       tmpDir.mkdir(),
+                       Assert.assertTrue(tmpDir.mkdir(),
                                        "Can't create temporary directory: "
                                                        + tmpDir.getAbsolutePath());
                }
@@ -697,23 +714,21 @@ public class TestScenarioService extends BaseTest {
                User.Properties uprop = new User.Properties();
                uprop.setUsername("TST_Username").setName("TST_SimanUnitTestsUser")
                                .setFirstName("TST_FirstName").setDisplayName("TST_test.user")
-                               .addRole("TST_user")
-                               .setMailAddress("noreply@salome-platform.org");
+                               .addRole("TST_user").setMailAddress(
+                                               "noreply@salome-platform.org");
                uprop.disableCheck();
                User anAuthor = new User(uprop);
                ht.saveOrUpdate(anAuthor);
 
                // Create a test study
-               Study.Properties stprops = new Study.Properties()
-                               .setReference("TST_SID_01").setTitle("TST_Study")
-                               .setManager(anAuthor);
+               Study.Properties stprops = new Study.Properties().setReference(
+                               "TST_SID_01").setTitle("TST_Study").setManager(anAuthor);
                Study aStudy = new Study(stprops);
                ht.saveOrUpdate(aStudy);
 
                // Create a test scenario
-               Scenario.Properties sprops = new Scenario.Properties()
-                               .setTitle("TST_Scenario").setManager(anAuthor)
-                               .setOwnerStudy(aStudy);
+               Scenario.Properties sprops = new Scenario.Properties().setTitle(
+                               "TST_Scenario").setManager(anAuthor).setOwnerStudy(aStudy);
                Scenario aScenario = new Scenario(sprops);
                aStudy.getScenariiList().add(aScenario);
                ht.saveOrUpdate(anAuthor);
@@ -741,7 +756,7 @@ public class TestScenarioService extends BaseTest {
                                if (step.getNumber() > 3) {
                                        dprop.setFormat("med");
                                } else {
-                                       dprop.setFormat("brep");
+                                       dprop.setFormat("py");
                                }
                                Publication pub = createDoc(aScenario, aScStep, dprop, "med",
                                                false);
@@ -754,8 +769,7 @@ public class TestScenarioService extends BaseTest {
                                usedPub = pub;
 
                                // Create another document with outdated publication
-                               dprop.setName("document" + i++).setType(dtype)
-                                               .setFormat("brep");
+                               dprop.setName("document" + i++).setType(dtype).setFormat("py");
                                createDoc(aScenario, aScStep, dprop, "med", true);
 
                        }
@@ -771,9 +785,8 @@ public class TestScenarioService extends BaseTest {
                Assert.assertTrue(ht.find("from Document").size() > 0,
                                "No documents in the database.");
 
-               Assert.assertNotNull(
-                               ht.find("from Publication where owner=" + aScenario.getIndex()),
-                               "No publications in the database.");
+               Assert.assertNotNull(ht.find("from Publication where owner="
+                               + aScenario.getIndex()), "No publications in the database.");
                Assert.assertTrue(
                                ht.find("from Publication where owner=" + aScenario.getIndex())
                                                .size() > 0, "No publications in the database.");
@@ -799,7 +812,9 @@ public class TestScenarioService extends BaseTest {
                                "More then one document must be in the database");
 
                // Check created uses relations
-               Assert.assertTrue(usedMap.size() > 0, "Uses relations must be created.");
+               Assert
+                               .assertTrue(usedMap.size() > 0,
+                                               "Uses relations must be created.");
                boolean foundAny = false;
                for (Long usingId : usedMap.keySet()) {
                        for (Publication pub : aScen.getDocums()) {
@@ -940,8 +955,8 @@ public class TestScenarioService extends BaseTest {
                User.Properties uprop = new User.Properties();
                uprop.setUsername("TST_Username").setName("TST_SimanUnitTestsUser")
                                .setFirstName("TST_FirstName").setDisplayName("TST_test.user")
-                               .addRole("TST_user")
-                               .setMailAddress("noreply@salome-platform.org");
+                               .addRole("TST_user").setMailAddress(
+                                               "noreply@salome-platform.org");
                uprop.disableCheck();
                User anAuthor = new User(uprop);
 
@@ -952,14 +967,15 @@ public class TestScenarioService extends BaseTest {
                                "Knowledge type 'usecase' must be created in the database.");
                SimulationContextType prodtype = _simulationContextService
                                .selectType("product");
-               Assert.assertNotNull(prodtype,
-                               "Simulation context type 'product' must be created in the database.");
+               Assert
+                               .assertNotNull(prodtype,
+                                               "Simulation context type 'product' must be created in the database.");
 
                // Create admin
                uprop.clear();
                uprop.setUsername("TST_Admin").setName("TST_SimanUnitTestsAdmin")
-                               .setFirstName("TST_AdminFirstName")
-                               .setDisplayName("TST_test.admin").addRole("TST_user,sysadmin")
+                               .setFirstName("TST_AdminFirstName").setDisplayName(
+                                               "TST_test.admin").addRole("TST_user,sysadmin")
                                .setMailAddress("noreply@salome-platform.org");
                uprop.disableCheck();
 
index af7c4a66361d7ddeb5cced6337455bf9992fad3d..fb349b79bfa91f34d90b642038cf2af57ffaa867 100644 (file)
             <mapping extension="sldasm" type="geometry"/>          <!-- SolidWorks Assembly             -->
             <mapping extension="part"   type="geometry"/>          <!-- GEOM Part                       -->
             <mapping extension="py"     type="geometry"/>          <!-- GEOM Python script              -->
+            <mapping extension="brep"   type="geometry"/>          <!-- GEOM Part                       -->
         </step>
         <step number="4">
             <mapping extension="doc"    type="memorandum"/>