]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Document name is generated now for new documents during checkin. Unit test is updated...
authorrkv <rkv@opencascade.com>
Mon, 3 Dec 2012 06:07:26 +0000 (06:07 +0000)
committerrkv <rkv@opencascade.com>
Mon, 3 Dec 2012 06:07:26 +0000 (06:07 +0000)
18 files changed:
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/i18n/I18nUtils.java
Workspace/Siman-Common/src/org/splat/kernel/NotApplicableException.java
Workspace/Siman-Common/src/org/splat/service/ScenarioService.java
Workspace/Siman-Common/src/org/splat/service/ScenarioServiceImpl.java
Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java
Workspace/Siman-Common/src/test/spring/ut-applicationContext.xml
Workspace/Siman/WebContent/jap/splat-launcher.jar
Workspace/Siman/WebContent/jap/splat-signedlauncher.jar
Workspace/Siman/WebContent/study/jsonCheckoutRes.jsp [new file with mode: 0644]
Workspace/Siman/src/org/splat/launcher/ConfigurationException.java [new file with mode: 0644]
Workspace/Siman/src/org/splat/launcher/ToolbarApplet.java
Workspace/Siman/src/org/splat/simer/CheckoutAction.java [new file with mode: 0644]
Workspace/Siman/src/org/splat/simer/OpenStudy.java
Workspace/Siman/src/spring/applicationContext.xml
Workspace/Siman/src/struts.xml

index 3f69b0feea780ecd2182d3c777b83423b0453581..8669c7ba3cfab79fd3efc136540ea867a8d369a6 100644 (file)
@@ -1,14 +1,18 @@
 #Lock service exception values
-LCK-000001=Lock reference already exists for user {2}.
+LCK-000001=Lock reference already exists for user {0}.
 LCK-000002=Lock reference does not exists.
-LCK-000003=Lock reference protected and can be only deleted or updated by user {2}.
-LCK-000004=Lock reference is timeout and could have been modified by user {2}.
-STD-000001=Unable to re-index the study #{1}, reason: {2}
-SCN-000001=Scenario doesn't contain the step number #{1}
-SCN-000002=Scenario doesn't contain the document #{1}
-SCN-000003=The existing file {1} has been deleted when check-in the scenario #{2}
-SCN-000004=Can not delete the existing destination file to move file from {1} to {2} when check-in the scenario #{3}
-SCN-000005=Can not move file from {1} to {2} when check-in the scenario #{3}
-KNT-000001=Knowledge element type "{1}" already exists
-SCT-000001=Simulation context type "{1}" already exists
-DCT-000001=Document type "{1}" already exists
+LCK-000003=Lock reference protected and can be only deleted or updated by user {0}.
+LCK-000004=Lock reference is timeout and could have been modified by user {0}.
+STD-000001=Unable to re-index the study #{0}, reason: {1}
+SCN-000001=Scenario doesn't contain the step number #{0}
+SCN-000002=Scenario doesn't contain the document #{0}
+SCN-000003=The existing file {0} has been deleted when check-in the scenario #{0}
+SCN-000004=Can not delete the existing destination file to move file from {0} to {1} when check-in the scenario #{2}
+SCN-000005=Can not move file from {0} to {1} when check-in the scenario #{2}
+SCN-000006=Scenario #{0} is not found
+SCN-000007=The user {0} does not participate in the scenario #{1}
+SCN-000008=The scenario #{0} is already checked out by the user {1}
+USR-000001=User {0} is not found in the database
+KNT-000001=Knowledge element type "{0}" already exists
+SCT-000001=Simulation context type "{0}" already exists
+DCT-000001=Document type "{0}" already exists
index 3f69b0feea780ecd2182d3c777b83423b0453581..8669c7ba3cfab79fd3efc136540ea867a8d369a6 100644 (file)
@@ -1,14 +1,18 @@
 #Lock service exception values
-LCK-000001=Lock reference already exists for user {2}.
+LCK-000001=Lock reference already exists for user {0}.
 LCK-000002=Lock reference does not exists.
-LCK-000003=Lock reference protected and can be only deleted or updated by user {2}.
-LCK-000004=Lock reference is timeout and could have been modified by user {2}.
-STD-000001=Unable to re-index the study #{1}, reason: {2}
-SCN-000001=Scenario doesn't contain the step number #{1}
-SCN-000002=Scenario doesn't contain the document #{1}
-SCN-000003=The existing file {1} has been deleted when check-in the scenario #{2}
-SCN-000004=Can not delete the existing destination file to move file from {1} to {2} when check-in the scenario #{3}
-SCN-000005=Can not move file from {1} to {2} when check-in the scenario #{3}
-KNT-000001=Knowledge element type "{1}" already exists
-SCT-000001=Simulation context type "{1}" already exists
-DCT-000001=Document type "{1}" already exists
+LCK-000003=Lock reference protected and can be only deleted or updated by user {0}.
+LCK-000004=Lock reference is timeout and could have been modified by user {0}.
+STD-000001=Unable to re-index the study #{0}, reason: {1}
+SCN-000001=Scenario doesn't contain the step number #{0}
+SCN-000002=Scenario doesn't contain the document #{0}
+SCN-000003=The existing file {0} has been deleted when check-in the scenario #{0}
+SCN-000004=Can not delete the existing destination file to move file from {0} to {1} when check-in the scenario #{2}
+SCN-000005=Can not move file from {0} to {1} when check-in the scenario #{2}
+SCN-000006=Scenario #{0} is not found
+SCN-000007=The user {0} does not participate in the scenario #{1}
+SCN-000008=The scenario #{0} is already checked out by the user {1}
+USR-000001=User {0} is not found in the database
+KNT-000001=Knowledge element type "{0}" already exists
+SCT-000001=Simulation context type "{0}" already exists
+DCT-000001=Document type "{0}" already exists
index e7b4366c0d2ad0fce110bce36c2002bc0fd97a8a..ce03ca850e0edeeed0704e13531f2616eee9cbfb 100644 (file)
@@ -18,7 +18,7 @@ package org.splat.common.properties;
 public enum MessageKeyEnum {
        
        /**
-        * Lock reference already exists for user {2}.
+        * Lock reference already exists for user {0}.
         */
        LCK_000001("LCK-000001"),
        /**
@@ -26,47 +26,63 @@ public enum MessageKeyEnum {
         */
        LCK_000002("LCK-000002"),
        /**
-        * Lock reference protected and can be only deleted or updated by user {2}.
+        * Lock reference protected and can be only deleted or updated by user {0}.
         */
        LCK_000003("LCK-000003"),
        /**
-        * Lock reference is timeout and could have been modified by user {2}.
+        * Lock reference is timeout and could have been modified by user {0}.
         */
        LCK_000004("LCK-000004"),
        /**
-        * Unable to re-index the study #{1}, reason: {2}.
+        * Unable to re-index the study #{0}, reason: {1}.
         */
        STD_000001("STD-000001"),
        /**
-        * Scenario doesn't contain the step number #{1}.
+        * Scenario doesn't contain the step number #{0}.
         */
        SCN_000001("SCN-000001"),
        /**
-        * Scenario doesn't contain the document #{1}.
+        * Scenario doesn't contain the document #{0}.
         */
        SCN_000002("SCN-000002"),
        /**
-        * The existing file {1} has been deleted when check-in the scenario #{2}.
+        * The existing file {0} has been deleted when check-in the scenario #{1}.
         */
        SCN_000003("SCN-000003"),
        /**
-        * Can not delete the existing destination file to move file from {1} to {2} when check-in the scenario #{3}.
+        * Can not delete the existing destination file to move file from {0} to {1} when check-in the scenario #{2}.
         */
        SCN_000004("SCN-000004"),
        /**
-        * Can not move file from {1} to {2} when check-in the scenario #{3}.
+        * Can not move file from {0} to {1} when check-in the scenario #{2}.
         */
        SCN_000005("SCN-000005"),
        /**
-        * Simulation context type "{1}" already exists.
+        * SCN-000006=Scenario #{0} is not found.
+        */
+       SCN_000006("SCN-000006"),
+       /**
+        * SCN-000007=The user {0} does not participate in the scenario #{1}.
+        */
+       SCN_000007("SCN-000007"),
+       /**
+        * SCN-000008=The scenario #{0} is already checked out by the user {1}.
+        */
+       SCN_000008("SCN-000008"),
+       /**
+        * USR-000001=User {0} is not found in the database.
+        */
+       USR_000001("USR-000001"),
+       /**
+        * Simulation context type "{0}" already exists.
         */
        KNT_000001("KNT-000001"),
        /**
-        * Knowledge element type "{1}" already exists.
+        * Knowledge element type "{0}" already exists.
         */
        SCT_000001("SCT-000001"),
        /**
-        * Document type "{1}" already exists.
+        * Document type "{0}" already exists.
         */
        DCT_000001("DCT-000001");
        
index 690574e5e5234ce99145eb930464061a7a9237cc..5ba5f37de29781f33649653e6f69ce01e7b162e9 100644 (file)
@@ -11,6 +11,7 @@ package org.splat.i18n;
 
 import java.util.Locale;
 
+import org.springframework.context.NoSuchMessageException;
 import org.springframework.context.support.ResourceBundleMessageSource;
 
 /**
@@ -68,7 +69,13 @@ public final class I18nUtils {
         * @return Translated message
         */
        public static String getMessageLocaleDefault(final String code, final Object... context) {
-               return getMessage(Locale.getDefault(), code, context);
+               String res = "";
+               try {
+                       res = getMessage(Locale.getDefault(), code, context);
+               } catch (NoSuchMessageException nsme) {
+                       res = getMessage(new Locale(""), code, context);
+               }
+               return res;
        }       
        
        
index 26b81167e8e65aa8176f31188de22fea7b1c48af..6848e36577ef6bb63f9014b4e8e6fe9f53ec7e1c 100644 (file)
@@ -22,4 +22,12 @@ public class NotApplicableException extends BusinessException {
        public NotApplicableException (final String message) {
         super(message);
     }
+
+       /**
+        * @param messageKey
+        * @param context
+        */
+       public NotApplicableException(final String messageKey, final Object... context) {
+               super(messageKey, context);
+       }
 }
\ No newline at end of file
index de0ed295f66c71d36c6464c724df39e04d56e30c..9087b190ebbc57ce4489185f81ed603023f3dada 100644 (file)
@@ -154,6 +154,21 @@ public interface ScenarioService {
         */
        boolean checkout(Scenario aScenario, User user);
 
+       /**
+        * Mark the given scenario as checked out by the given user.
+        * 
+        * @param scenarioId
+        *            the scenario id
+        * @param username
+        *            the username of the user performing the check out
+        * @throws InvalidPropertyException
+        *             if the user or the scenario is not found in the database
+        * @throws NotApplicableException
+        *             if the given user can not check out the scenario
+        */
+       public void checkout(final long scenarioId, final String username)
+                       throws InvalidPropertyException, NotApplicableException;
+       
        /**
         * Copy contents from other scenario up to its given step into the given scenario.
         * 
index 0303a5f4efa5ee2399c161f2374290d5d49c73f6..98949f13770e2d751b7ec81c53ef0a2023fa0752 100644 (file)
@@ -357,8 +357,9 @@ public class ScenarioServiceImpl implements ScenarioService {
                                                + " is added to the scenario #" + aScenario.getIndex());
                        }
                } catch (IOException error) {
-                       LOG.error("Unable to index the knowedge element '"
-                                       + kelm.getIndex() + "', reason:", error);
+                       LOG.error(
+                                       "Unable to index the knowedge element '" + kelm.getIndex()
+                                                       + "', reason:", error);
                        kelm = null;
                }
 
@@ -379,8 +380,9 @@ public class ScenarioServiceImpl implements ScenarioService {
                        getScenarioDAO().update(aScenario); // Update of relational base
                        isOk = true;
                } catch (Exception error) {
-                       LOG.error("Unable to re-index the knowledge element '"
-                                       + aScenario.getIndex() + "', reason:", error);
+                       LOG.error(
+                                       "Unable to re-index the knowledge element '"
+                                                       + aScenario.getIndex() + "', reason:", error);
                }
                return isOk;
        }
@@ -568,8 +570,6 @@ public class ScenarioServiceImpl implements ScenarioService {
                        java.io.File upfile = new java.io.File(file.getPath());
                        String fileFormat = upfile.getName().substring(
                                        upfile.getName().lastIndexOf('.') + 1);
-                       String docname = upfile.getName().substring(0,
-                                       upfile.getName().lastIndexOf('.'));
 
                        // Create a new document or a new version of the document
                        dprop.setAuthor(aUser).setDate(aDate);
@@ -584,8 +584,8 @@ public class ScenarioServiceImpl implements ScenarioService {
                                                        MessageKeyEnum.SCN_000002.toString(), doc.getId());
                                }
                                if (pub.value() == null) {
-                                       throw new MismatchException(MessageKeyEnum.SCN_000002
-                                                       .toString(), doc.getId());
+                                       throw new MismatchException(
+                                                       MessageKeyEnum.SCN_000002.toString(), doc.getId());
                                }
                                newPub = getStepService().versionDocument(step, pub, dprop);
                                // Remeber the link from the old document to the new document version
@@ -602,8 +602,18 @@ public class ScenarioServiceImpl implements ScenarioService {
                                } else {
                                        dprop.setType(resType);
                                }
-                               dprop.setDescription("Checked in").setName(docname).setFormat(
-                                               fileFormat);
+                               // New document title generation as <document type name>_N
+                               String docname = dprop.getType().getName();
+                               int i = 1;
+                               for (Publication scenPub : step.getOwner().getDocums()) {
+                                       if (scenPub.value().getTitle().startsWith(docname)) {
+                                               i++;
+                                       }
+                               }
+                               docname += "_" + i; // The generated new document title
+
+                               dprop.setDescription("Checked in").setName(docname)
+                                               .setFormat(fileFormat);
                                newPub = getStepService().createDocument(step, dprop);
 
                                // Remeber the new document
@@ -618,8 +628,8 @@ public class ScenarioServiceImpl implements ScenarioService {
                        }
                        if (updir.exists()) {
                                if (updir.delete()) {
-                                       LOG.info(MessageKeyEnum.SCN_000003.toString(), updir
-                                                       .getAbsoluteFile(), step.getOwner().getIndex());
+                                       LOG.info(MessageKeyEnum.SCN_000003.toString(),
+                                                       updir.getAbsoluteFile(), step.getOwner().getIndex());
                                } else {
                                        throw new IOException(
                                                        "Can't delete the existing destination file to move file from "
@@ -661,8 +671,8 @@ public class ScenarioServiceImpl implements ScenarioService {
                } while ((step == null) && (i < steps.length));
 
                if (step == null) {
-                       throw new InvalidPropertyException(MessageKeyEnum.SCN_000001
-                                       .toString(), stepDTO.getNumber());
+                       throw new InvalidPropertyException(
+                                       MessageKeyEnum.SCN_000001.toString(), stepDTO.getNumber());
                }
                return step;
        }
@@ -689,11 +699,56 @@ public class ScenarioServiceImpl implements ScenarioService {
                if (res) {
                        aScenario.setUser(user);
                        aScenario.setLastModificationDate(Calendar.getInstance().getTime());
-                       getScenarioDAO().update(aScenario);
+                       // RKV: getScenarioDAO().update(aScenario);
                }
                return res;
        }
 
+       /**
+        * Mark the given scenario as checked out by the given user.
+        * 
+        * @param scenarioId
+        *            the scenario id
+        * @param username
+        *            the username of the user performing the check out
+        * @throws InvalidPropertyException
+        *             if the user or the scenario is not found in the database
+        * @throws NotApplicableException
+        *             if the given user can not check out the scenario
+        */
+       @Transactional
+       public void checkout(final long scenarioId, final String username)
+                       throws InvalidPropertyException, NotApplicableException {
+               User aUser = getUserService().selectUser(username);
+               if (aUser == null) {
+                       // User not found
+                       throw new InvalidPropertyException(
+                                       MessageKeyEnum.USR_000001.toString(), username);
+               }
+               Scenario aScenario = getScenarioDAO().get(scenarioId);
+               if (aScenario == null) {
+                       // Scenario not found
+                       throw new InvalidPropertyException(
+                                       MessageKeyEnum.SCN_000006.toString(), scenarioId);
+               }
+               boolean res = getStudyService().isStaffedBy(aScenario.getOwnerStudy(),
+                               aUser);
+               if (res) {
+                       if (aScenario.isCheckedout()
+                                       && (!aScenario.getUser().getUsername().equals(username))) {
+                               throw new NotApplicableException(
+                                               MessageKeyEnum.SCN_000008.toString(), scenarioId,
+                                               aScenario.getUser().getUsername());
+                       }
+                       aScenario.setUser(aUser);
+                       aScenario.setLastModificationDate(Calendar.getInstance().getTime());
+               } else {
+                       // User doesn't participate in the scenario
+                       throw new NotApplicableException(
+                                       MessageKeyEnum.SCN_000007.toString(), username, scenarioId);
+               }
+       }
+
        /**
         * {@inheritDoc}
         * 
@@ -799,9 +854,9 @@ public class ScenarioServiceImpl implements ScenarioService {
                                Restrictions.like("role", "%sysadmin%")).get(0);
                User admin = getUserDAO().getFilteredList(
                                Restrictions.eq("role", adminRole), Order.asc("rid")).get(0); // First sysadmin in the database
-               
-               kprop.setType(ucase).setTitle(aStudy.getTitle()).setValue(
-                               scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
+
+               kprop.setType(ucase).setTitle(aStudy.getTitle())
+                               .setValue(scenario.getTitle()).setAuthor(admin); // Internal Knowledge Element required by the validation process of
                // knowledges
                addKnowledgeElement(scenario, kprop);
                return scenario;
index b858a2905160e0176cc51f163e902b97110015d3..5a391b75cf2e3dbed2164066c1eeb1e2ab451fb6 100644 (file)
@@ -23,6 +23,7 @@ import java.util.Set;
 import org.splat.dal.bo.kernel.Relation;
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.Document.Properties;
 import org.splat.dal.bo.som.DocumentType;
 import org.splat.dal.bo.som.KnowledgeElementType;
 import org.splat.dal.bo.som.Publication;
@@ -32,7 +33,6 @@ import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.UsedByRelation;
 import org.splat.dal.bo.som.UsesRelation;
-import org.splat.dal.bo.som.Document.Properties;
 import org.splat.dal.dao.som.Database;
 import org.splat.dal.dao.som.ScenarioDAO;
 import org.splat.kernel.InvalidPropertyException;
@@ -51,13 +51,14 @@ import org.splat.service.dto.DocumentDTO;
 import org.splat.service.dto.FileDTO;
 import org.splat.service.dto.StepDTO;
 import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.technical.RepositoryService;
 import org.splat.service.technical.ProjectSettingsService.Step;
+import org.splat.service.technical.RepositoryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.orm.hibernate3.HibernateTemplate;
 import org.testng.Assert;
 import org.testng.annotations.Test;
+import org.testng.reporters.Files;
 
 import test.splat.common.BaseTest;
 
@@ -116,7 +117,7 @@ public class TestScenarioService extends BaseTest {
        @Autowired
        @Qualifier("simulationContextService")
        private transient SimulationContextService _simulationContextService;
-       
+
        /**
         * The ProjectSettingsService. Later injected by Spring.
         */
@@ -176,7 +177,7 @@ public class TestScenarioService extends BaseTest {
                        SQLException {
                LOG.debug(">>>>> BEGIN testGetScenarioInfo()");
                startNestedTransaction();
-               
+
                long scenarioId = createScenario();
                // Call DAO's create method for a good transient knowledge element.
                List<StepDTO> steps = _scenarioService.getScenarioInfo(scenarioId);
@@ -219,9 +220,8 @@ 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,10 +256,9 @@ 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.");
                                                        }
                                                }
                                        }
@@ -272,8 +271,7 @@ 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());
@@ -294,6 +292,7 @@ public class TestScenarioService extends BaseTest {
         * <li>uses relations are copied correctly</li>
         * <li>files are moved correctly</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>
         * <li>files are moved correctly</li>
         * </ul>
@@ -337,7 +336,7 @@ public class TestScenarioService extends BaseTest {
                        SQLException, MismatchException, NotApplicableException {
                LOG.debug(">>>>> BEGIN testCheckin()");
                startNestedTransaction();
-               
+
                _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again
                _projectSettings.configure(ClassLoader
                                .getSystemResource("test/som.xml").getPath());
@@ -389,7 +388,8 @@ public class TestScenarioService extends BaseTest {
                                                        }
                                                }
                                        }
-                                       Assert.assertTrue(found,
+                                       Assert.assertTrue(
+                                                       found,
                                                        "New version of the existing checked in document \""
                                                                        + docDTO.getTitle() + "\" (id="
                                                                        + docDTO.getId()
@@ -445,11 +445,18 @@ public class TestScenarioService extends BaseTest {
                                        Publication newPub = null;
                                        for (Publication pub : aScen.getDocums()) {
                                                if (pub.value().getPreviousVersion() == null) {
-                                                       found = (docDTO.getTitle().equals(pub.value()
-                                                                       .getTitle()));
+                                                       found = (pub.value().getTitle().startsWith(pub
+                                                                       .value().getType().getName()));
                                                        if (found) { // Found next published version of the checked in document
-                                                               newPub = pub;
-                                                               break;
+                                                               String fcontent = Files.readFile(pub
+                                                                               .getSourceFile().asFile());
+                                                               found = fcontent.contains(docDTO.getTitle());
+                                                               if (found) {
+                                                                       LOG.debug("Found new document with generated title: "
+                                                                                       + pub.value().getTitle());
+                                                                       newPub = pub;
+                                                                       break;
+                                                               }
                                                        }
                                                }
                                        }
@@ -457,6 +464,14 @@ public class TestScenarioService extends BaseTest {
                                                        "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()
+                                                                                                       + "_"),
+                                                       "Document title newPub.value().getTitle() must start with "
+                                                                       + newPub.value().getType().getName() + "_");
 
                                        // 1. Find the document type used by this document type
                                        Set<DocumentType> usedTypes = newPub.value().getType()
@@ -484,13 +499,12 @@ 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());
                }
-               
+
                rollbackNestedTransaction();
                LOG.debug(">>>>> END testCheckin()");
        }
@@ -592,8 +606,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;
        }
@@ -633,7 +647,8 @@ 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());
                }
@@ -678,21 +693,23 @@ 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);
@@ -750,8 +767,9 @@ 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.");
@@ -777,9 +795,7 @@ 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()) {
@@ -855,7 +871,6 @@ public class TestScenarioService extends BaseTest {
                return pub;
        }
 
-
        /**
         * Test check-in scenario operation to be performed after SALOME session.<BR>
         * <B>Description :</B> <BR>
@@ -911,38 +926,42 @@ public class TestScenarioService extends BaseTest {
                        SQLException, MismatchException, NotApplicableException {
                LOG.debug(">>>>> BEGIN testCreateStudy()");
                startNestedTransaction();
-               
+
                Database.getInstance().reset();
                _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again
                _projectSettings.configure(ClassLoader
                                .getSystemResource("test/som.xml").getPath());
-               
+
                // Create a test user
                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);
-               
+
                getHibernateTemplate().saveOrUpdate(anAuthor);
-               KnowledgeElementType ucase = _knowledgeElementTypeService.selectType("usecase");
-               Assert.assertNotNull(ucase, "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.");
-               
+               KnowledgeElementType ucase = _knowledgeElementTypeService
+                               .selectType("usecase");
+               Assert.assertNotNull(ucase,
+                               "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.");
+
                // Create admin
                uprop.clear();
                uprop.setUsername("TST_Admin").setName("TST_SimanUnitTestsAdmin")
-                               .setFirstName("TST_AdminFirstName").setDisplayName("TST_test.admin")
-                               .addRole("TST_user,sysadmin").setMailAddress(
-                                               "noreply@salome-platform.org");
+                               .setFirstName("TST_AdminFirstName")
+                               .setDisplayName("TST_test.admin").addRole("TST_user,sysadmin")
+                               .setMailAddress("noreply@salome-platform.org");
                uprop.disableCheck();
-               
+
                getHibernateTemplate().saveOrUpdate(new User(uprop));
                getHibernateTemplate().flush();
-               
+
                Study.Properties sprop = new Study.Properties();
                sprop.setTitle("Test study creation").setManager(anAuthor);
                Scenario.Properties oprop = new Scenario.Properties();
@@ -952,9 +971,9 @@ public class TestScenarioService extends BaseTest {
                SimulationContext.Properties cprop = new SimulationContext.Properties();
                // Input of new project context
                cprop.setType(_simulationContextService.selectType("product"))
-                                       .setValue("Test Simulation Context: Product");
+                               .setValue("Test Simulation Context: Product");
                Study study = _scenarioService.createStudy(sprop, oprop, cprop);
-               
+
                rollbackNestedTransaction();
                LOG.debug(">>>>> END testCreateStudy()");
        }
index 221c1339e4a74a49c2c79eb6215c1fd8f697be73..1a59c7029e595e3596938d38fcff2569aabcaa38 100644 (file)
@@ -27,8 +27,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
         class="org.springframework.context.support.ResourceBundleMessageSource">
         <property name="basenames">
             <list>
-                <value>application</value>
-                <value>log-messages</value>
+                <value>som</value>
+                <value>conf/log-messages</value>
             </list>
         </property>
     </bean>
index a95e95ccbf969132a787c8444fa1f5f2aae34d73..afb3cbf4013dbc4e5f1dea8ff6d86a1f9110d05d 100644 (file)
Binary files a/Workspace/Siman/WebContent/jap/splat-launcher.jar and b/Workspace/Siman/WebContent/jap/splat-launcher.jar differ
index d0b487386b69bf1e48b794469f9e3e22ece94a27..bfb539491a9dd52b8d646f820bde9fdb9b418d65 100644 (file)
Binary files a/Workspace/Siman/WebContent/jap/splat-signedlauncher.jar and b/Workspace/Siman/WebContent/jap/splat-signedlauncher.jar differ
diff --git a/Workspace/Siman/WebContent/study/jsonCheckoutRes.jsp b/Workspace/Siman/WebContent/study/jsonCheckoutRes.jsp
new file mode 100644 (file)
index 0000000..b266101
--- /dev/null
@@ -0,0 +1,5 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+    pageEncoding="ISO-8859-1"%>
+<%@ taglib prefix="s" uri="/struts-tags"%>
+<%@ page import="org.splat.launcher.ToolbarApplet"%>
+{<%=ToolbarApplet.CHECKOUT_RES%> "<s:property value="result"/>"}
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/launcher/ConfigurationException.java b/Workspace/Siman/src/org/splat/launcher/ConfigurationException.java
new file mode 100644 (file)
index 0000000..b9623fc
--- /dev/null
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   02.12.2012
+ * @author         $Author$
+ * @version        $Revision$
+ * @copyright      OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.launcher;
+
+/**
+ * Exception thrown when configuration problem appears during an executable module launching.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class ConfigurationException extends Exception {
+
+       /**
+        * Constructs a configuration exception with its reason description.
+        * 
+        * @param message
+        *            error message
+        */
+       public ConfigurationException(final String message) {
+               super(message);
+       }
+
+       /**
+        * Serialization version id.
+        */
+       private static final long serialVersionUID = -8886811002435115163L;
+
+}
index 3a7c5903d7c89e5240fefc851c52b99a9c67b680..0de07566c800377e69b2364856fa72c74ed9e75c 100644 (file)
@@ -5,11 +5,16 @@ import java.awt.ComponentOrientation;
 import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.io.ObjectInputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.net.URLEncoder;
 
 /**
  * Applet providing a set of buttons. Each button is defined by three parameters:<BR>
@@ -27,6 +32,11 @@ public class ToolbarApplet extends java.applet.Applet implements ActionListener
         */
        private static final long serialVersionUID = 3243053622061086715L;
 
+       /**
+        * The response key string: '<i>"canCheckout"</i> :'.
+        */
+       public static final String CHECKOUT_RES = "\"canCheckout\" :";
+
        // ==============================================================================================================================
        // Overridden functions
        // ==============================================================================================================================
@@ -106,50 +116,8 @@ public class ToolbarApplet extends java.applet.Applet implements ActionListener
 
                        // Opening an application on the local machine
 
-                       if (module.equals("runSalome")) {
-                               // Run SALOME
-                               // To get the SALOME_HOME environment variable
-                               String SALOME_HOME = System.getenv("SALOME_ROOT_DIR");
-                               // If SALOME_ROOT_DIR does not exist the SALOME_HOME equals to null.
-                               if (SALOME_HOME == null) {
-                                       // TODO: Use logger to be more user friendly
-                                       getAppletContext()
-                                                       .showDocument(
-                                                                       new URL(
-                                                                                       getCodeBase().toString()
-                                                                                                       + "error.jsp?message=launch&value="
-                                                                                                       + "SALOME_ROOT_DIR environment variable is not defined."),
-                                                                       "_blank");
-                                       throw new Exception(
-                                                       "SALOME_ROOT_DIR nevironment variable is not defined.");
-                               } else if (!SALOME_HOME.endsWith(File.separator)) {
-                                       SALOME_HOME += File.separator;
-                               }
-                               String pathToScript = SALOME_HOME + "runSalome";
-
-                               File script = new File(pathToScript);
-                               if (!script.exists()) {
-                                       script = new File(pathToScript + ".bat");
-                                       if (!script.exists()) {
-                                               script = new File(pathToScript + ".cmd");
-                                       }
-                               }
-                               
-                               if (script.exists()) {
-                                       // Execute the runSalome script.
-                                       // filename here indeed a string containing parameters for runSalome.
-                                       Runtime.getRuntime().exec(
-                                                       new String[] { script.getAbsolutePath(), filename });
-                               } else {
-                                       // TODO: Use logger to be more user friendly
-                                       getAppletContext().showDocument(
-                                                       new URL(getCodeBase().toString()
-                                                                       + "error.jsp?message=launch&value="
-                                                                       + "SALOME module is not found: "
-                                                                       + script.getAbsolutePath()), "_blank");
-                                       throw new FileNotFoundException(
-                                                       "SALOME module is not found: " + script.getAbsolutePath());
-                               }
+                       if ("runSalome".equals(module)) {
+                               salomeCheckout(filename);
                        } else
 
                        if (module.endsWith(".exe") || module.endsWith(".EXE")) {
@@ -205,4 +173,100 @@ public class ToolbarApplet extends java.applet.Applet implements ActionListener
                        error.printStackTrace(); // RKV: NOPMD: TODO: try to use logger
                }
        }
+
+       /**
+        * Checkout a scenario and start Salome with it.
+        * 
+        * @param params
+        *            Salome parameters
+        * @throws IOException
+        *             if URL connection opening/reading is failed
+        * @throws ConfigurationException
+        *             if SALOME_ROOT_DIR environment variable is not defined or Salome launcher script is not found
+        */
+       private void salomeCheckout(final String params)
+                       throws ConfigurationException, IOException {
+               // Run SALOME
+               // To get the SALOME_HOME environment variable
+               String SALOME_HOME = System.getenv("SALOME_ROOT_DIR");
+               // If SALOME_ROOT_DIR does not exist the SALOME_HOME equals to null.
+               if (SALOME_HOME == null) {
+                       // TODO: Use logger to be more user friendly
+                       showError("SALOME_ROOT_DIR environment variable is not defined.");
+                       throw new ConfigurationException(
+                                       "SALOME_ROOT_DIR nevironment variable is not defined.");
+               } else if (!SALOME_HOME.endsWith(File.separator)) {
+                       SALOME_HOME += File.separator;
+               }
+               String pathToScript = SALOME_HOME + "runSalome";
+
+               File script = new File(pathToScript);
+               if (!script.exists()) {
+                       script = new File(pathToScript + ".bat");
+                       if (!script.exists()) {
+                               script = new File(pathToScript + ".cmd");
+                       }
+               }
+
+               if (script.exists()) {
+
+                       // Checkout the scenario
+                       URL checkoutUrl = new URL(getCodeBase().toString()
+                                       + "checkout.action?"
+                                       + params.replaceAll("siman-", "").replaceAll("--", "-")
+                                                       .replaceAll("-", "&").replaceAll("\\s", ""));
+
+                       BufferedReader buffer = new BufferedReader(new InputStreamReader(
+                                       checkoutUrl.openStream()));
+                       boolean isOk = false;
+                       String response = buffer.readLine();
+                       while ((response != null)) {
+                               if (response.contains(CHECKOUT_RES)) {
+                                       isOk = response.contains(CHECKOUT_RES + " \"true\"");
+                                       break;
+                               }
+                               response = buffer.readLine();
+                       }
+                       buffer.close();
+
+                       if (isOk) {
+                               // Execute the runSalome script.
+                               // filename here indeed a string containing parameters for runSalome.
+                               Runtime.getRuntime().exec(
+                                               new String[] { script.getAbsolutePath(), params });
+                       } else {
+                               // Checkout of the scenario is failed at the beginning.
+                               if (response != null) {
+                                       response = response
+                                                       .substring(
+                                                                       response.indexOf(CHECKOUT_RES)
+                                                                                       + CHECKOUT_RES.length())
+                                                       .replace('}', ' ').replace('"', ' ');
+                               }
+                               showError(response);
+                       }
+               } else {
+                       // TODO: Use logger to be more user friendly
+                       showError("SALOME module is not found: " + script.getAbsolutePath());
+                       throw new ConfigurationException("SALOME module is not found: "
+                                       + script.getAbsolutePath());
+               }
+       }
+
+       /**
+        * Show error message in the new window.
+        * 
+        * @param message
+        *            the error message
+        * @throws MalformedURLException
+        *             if built URL is incorrect
+        * @throws UnsupportedEncodingException
+        *             if UTF-8 encoding is not supported
+        */
+       private void showError(final String message) throws MalformedURLException,
+                       UnsupportedEncodingException {
+               getAppletContext().showDocument(
+                               new URL(getCodeBase().toString() + "../error.jsp?error="
+                                               + URLEncoder.encode(message, "UTF-8")), "_blank");
+       }
 }
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/CheckoutAction.java b/Workspace/Siman/src/org/splat/simer/CheckoutAction.java
new file mode 100644 (file)
index 0000000..ed95b20
--- /dev/null
@@ -0,0 +1,149 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   02.12.2012
+ * @author         $Author$
+ * @version        $Revision$
+ * @copyright      OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.simer;
+
+import org.splat.exception.BusinessException;
+import org.splat.log.AppLogger;
+import org.splat.service.ScenarioService;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ * Action to checkout a scenario.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class CheckoutAction extends ActionSupport {
+
+       /**
+        * Serialization version id.
+        */
+       private static final long serialVersionUID = 6140789360802711199L;
+
+       /**
+        * Action logger.
+        */
+       protected static final AppLogger LOG = AppLogger
+                       .getLogger(CheckoutAction.class);
+
+       /**
+        * Result message. If the scenario is successfully checked out then result is "true", otherwise it contains the error message.
+        */
+       private String _result;
+       /**
+        * Scenario id action parameter. Defines the scenario to check out.
+        */
+       private long _scenario;
+       /**
+        * User login name action parameter. Defines the user who performs check out.
+        */
+       private String _user;
+       /**
+        * Injected scenario service.
+        */
+       private ScenarioService _scenarioService;
+
+       /**
+        * Mark the currently selected scenario as checked out. If the scenario is successfully checked out then result is "true", otherwise it
+        * contains the error message.
+        * 
+        * @return SUCCESS
+        */
+       public String doCheckout() {
+               try {
+                       getScenarioService().checkout(getScenario(), getUser());
+                       setResult("true");
+               } catch (BusinessException e) {
+                       setResult(e.getMessage());
+               }
+               if (LOG.isDebugEnabled()) {
+                       LOG.debug("Can checkout scenario #" + getScenario()
+                                       + " by the user " + getUser() + ": " + getResult());
+               }
+               return SUCCESS;
+       }
+
+       /**
+        * Get the scenarioService.
+        * 
+        * @return the scenarioService
+        */
+       public ScenarioService getScenarioService() {
+               return _scenarioService;
+       }
+
+       /**
+        * Set the scenarioService.
+        * 
+        * @param scenarioService
+        *            the scenarioService to set
+        */
+       public void setScenarioService(final ScenarioService scenarioService) {
+               _scenarioService = scenarioService;
+       }
+
+       /**
+        * Result message. If the scenario is successfully checked out then result is "true", otherwise it contains the error message.
+        * 
+        * @return the result
+        */
+       public String getResult() {
+               return _result;
+       }
+
+       /**
+        * Set the result.
+        * 
+        * @param result
+        *            the result to set
+        */
+       public void setResult(final String result) {
+               _result = result;
+       }
+
+       /**
+        * Get the scenario.
+        * 
+        * @return the scenario
+        */
+       public long getScenario() {
+               return _scenario;
+       }
+
+       /**
+        * Set the scenario.
+        * 
+        * @param scenario
+        *            the scenario to set
+        */
+       public void setScenario(final long scenario) {
+               _scenario = scenario;
+       }
+
+       /**
+        * Get the user.
+        * 
+        * @return the user
+        */
+       public String getUser() {
+               return _user;
+       }
+
+       /**
+        * Set the user.
+        * 
+        * @param user
+        *            the user to set
+        */
+       public void setUser(final String user) {
+               _user = user;
+       }
+}
index 256f84cf4ceb5501d5fd727a8dc1dbece1eaacb5..82dcc0efa6daa9bed44b5889b71acaa29405bfdf 100644 (file)
@@ -97,8 +97,8 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
        public OpenStudy open(final User user, final Study study) {
                ResourceBundle custom = ResourceBundle.getBundle("som",
                                getApplicationSettings().getCurrentLocale());
-               SimpleDateFormat datstring = new SimpleDateFormat(custom
-                               .getString("date.format"));
+               SimpleDateFormat datstring = new SimpleDateFormat(
+                               custom.getString("date.format"));
                Revision.Format verstring = new Revision.Format(getProjectSettings()
                                .getRevisionPattern());
 
@@ -204,9 +204,10 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
        }
 
        public String getType() {
-               return ResourceBundle.getBundle("labels",
-                               getApplicationSettings().getCurrentLocale()).getString(
-                               "label.study");
+               /*
+                * RKV: return ResourceBundle.getBundle("labels", getApplicationSettings().getCurrentLocale()).getString( "label.study");
+                */
+               return "study";
        }
 
        public String getVersion() {
@@ -256,8 +257,8 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
                        // Transfer to the document of all known properties
                        ResourceBundle locale = ResourceBundle.getBundle("som",
                                        getApplicationSettings().getCurrentLocale());
-                       SimpleDateFormat get = new SimpleDateFormat(locale
-                                       .getString("date.format"));
+                       SimpleDateFormat get = new SimpleDateFormat(
+                                       locale.getString("date.format"));
                        Writer tool = Toolbox.getWriter(credoc);
                        List<Step> slist = getInvolvedSteps();
                        for (Iterator<Step> i = slist.iterator(); i.hasNext();) {
@@ -266,14 +267,15 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
                                for (Iterator<SimulationContext> j = clist.iterator(); j
                                                .hasNext();) {
                                        SimulationContext context = j.next();
-                                       tool.updateProperty(context.getType().getName(), context
-                                                       .getValue());
+                                       tool.updateProperty(context.getType().getName(),
+                                                       context.getValue());
                                }
                        }
                        tool.updateProperty("reference", medoc.getReference());
                        tool.updateProperty("study", _mystudy.getTitle());
-                       tool.updateProperty("step", locale.getString(
-                                       "folder.step." + step.getNumber()).replaceAll("''", "'"));
+                       tool.updateProperty("step",
+                                       locale.getString("folder.step." + step.getNumber())
+                                                       .replaceAll("''", "'"));
                        tool.updateProperty("author", author.getUsername().toUpperCase());
                        tool.updateProperty("date", get.format(medoc.getCreationDate()));
                        tool.updateProperty("history", locale.getString("label.creation")
@@ -343,8 +345,8 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
        }
 
        protected void add(final KnowledgeElement kelm) {
-               KnowledgeElementFacade facade = new KnowledgeElementFacade(BeanHelper
-                               .copyBean(kelm, KnowledgeElementDTO.class),
+               KnowledgeElementFacade facade = new KnowledgeElementFacade(
+                               BeanHelper.copyBean(kelm, KnowledgeElementDTO.class),
                                getApplicationSettings());
                // RKV KnowledgeIterator known = knowledge.get(kelm.getType().getIndex() - 2);
                // Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
index 70c4bb4bb33179a9a4f3fce879d63551fe6889e4..68674115cbcb2bb46db2d6db44613ed456d43db2 100644 (file)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:aop="http://www.springframework.org/schema/aop"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans  
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
@@ -17,24 +16,22 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
        <!-- configuration i18n -->
        <bean id="i18nUtils" class="org.splat.i18n.I18nUtils">
-               <property name="resourceBundleMessageSource"
-                       ref="messageSource" />
+               <property name="resourceBundleMessageSource" ref="messageSource" />
        </bean>
 
        <bean id="messageSource"
                class="org.springframework.context.support.ResourceBundleMessageSource">
                <property name="basenames">
                        <list>
-                               <value>application</value>
-                               <value>log-messages</value>
+                <value>conf/log-messages</value>
                        </list>
                </property>
        </bean>
        <!-- ref 'baseMessageSource' into Siman-common\src\spring\globalContext.xml -->
        <!-- property name="parentMessageSource" ref="baseMessageSource"/ -->
 
-       <bean id="applicationSettings"
-               class="org.splat.simer.ApplicationSettings" scope="session">
+       <bean id="applicationSettings" class="org.splat.simer.ApplicationSettings"
+               scope="session">
                <property name="projectSettings" ref="projectSettings" />
                <property name="documentTypeService" ref="documentTypeService" />
        </bean>
@@ -56,13 +53,12 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        </bean>
 
        <bean id="slidMenu" scope="session" abstract="true">
-               <property name="projectElementService"
-                       ref="projectElementService" />
+               <property name="projectElementService" ref="projectElementService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
-       <bean id="studyMenu" class="org.splat.simer.StudyMenu"
-               scope="session" parent="slidMenu" />
+       <bean id="studyMenu" class="org.splat.simer.StudyMenu" scope="session"
+               parent="slidMenu" />
 
        <bean id="newScenarioMenu" class="org.splat.simer.NewScenarioMenu"
                scope="session" parent="slidMenu" />
@@ -70,17 +66,14 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <bean id="openObject" abstract="true"
                class="org.splat.simer.AbstractOpenObject" scope="session">
                <property name="applicationSettings" ref="applicationSettings" />
-               <property name="projectElementService"
-                       ref="projectElementService" />
+               <property name="projectElementService" ref="projectElementService" />
                <property name="projectSettings" ref="projectSettings" />
-               <property name="knowledgeElementTypeService"
-                       ref="knowledgeElementTypeService" />
+               <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
        </bean>
 
-       <bean id="openStudy" class="org.splat.simer.OpenStudy"
-               parent="openObject" scope="session">
-               <property name="projectElementService"
-                       ref="projectElementService" />
+       <bean id="openStudy" class="org.splat.simer.OpenStudy" parent="openObject"
+               scope="session">
+               <property name="projectElementService" ref="projectElementService" />
                <property name="publicationService" ref="publicationService" />
                <property name="studyService" ref="studyService" />
                <property name="stepService" ref="stepService" />
@@ -94,8 +87,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                parent="openObject" scope="session">
        </bean>
 
-       <bean id="baseAction" class="org.splat.simer.Action"
-               scope="prototype" abstract="true">
+       <bean id="baseAction" class="org.splat.simer.Action" scope="prototype"
+               abstract="true">
                <property name="applicationSettings" ref="applicationSettings" />
                <property name="openStudy" ref="openStudy" />
                <property name="openKnowledge" ref="openKnowledge" />
@@ -109,23 +102,24 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
        <bean id="newStudyAction" class="org.splat.simer.NewStudyAction"
                parent="baseAction" scope="prototype">
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
+               <property name="simulationContextService" ref="simulationContextService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
-       <bean id="newScenarioAction"
-               class="org.splat.simer.NewScenarioAction" parent="baseAction"
-               scope="prototype">
-               <property name="projectElementService"
-                       ref="projectElementService" />
+       <bean id="newScenarioAction" class="org.splat.simer.NewScenarioAction"
+               parent="baseAction" scope="prototype">
+               <property name="projectElementService" ref="projectElementService" />
                <property name="scenarioService" ref="scenarioService" />
                <property name="menu" ref="newScenarioMenu" />
        </bean>
 
-       <bean id="importDocumentAction"
-               class="org.splat.simer.ImportDocumentAction" scope="prototype"
-               parent="baseAction">
+       <bean id="checkoutAction" class="org.splat.simer.CheckoutAction"
+               scope="prototype">
+               <property name="scenarioService" ref="scenarioService" />
+       </bean>
+
+       <bean id="importDocumentAction" class="org.splat.simer.ImportDocumentAction"
+               scope="prototype" parent="baseAction">
                <property name="stepService" ref="stepService" />
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
@@ -134,17 +128,15 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="documentTypeService" ref="documentTypeService" />
        </bean>
 
-       <bean id="displayStudyStepAction"
-               class="org.splat.simer.DisplayStudyStepAction" parent="baseAction"
-               scope="prototype">
+       <bean id="displayStudyStepAction" class="org.splat.simer.DisplayStudyStepAction"
+               parent="baseAction" scope="prototype">
                <property name="studyService" ref="studyService" />
        </bean>
 
        <!--========= Inherited from displayStudyStepAction ========= -->
 
-       <bean id="studyPropertiesAction"
-               class="org.splat.simer.StudyPropertiesAction" scope="prototype"
-               parent="displayStudyStepAction">
+       <bean id="studyPropertiesAction" class="org.splat.simer.StudyPropertiesAction"
+               scope="prototype" parent="displayStudyStepAction">
                <property name="documentTypeService" ref="documentTypeService" />
                <property name="userService" ref="userService" />
        </bean>
@@ -153,46 +145,37 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                scope="prototype" parent="displayStudyStepAction">
        </bean>
 
-       <bean id="editScenarioPropertiesAction"
-               class="org.splat.simer.EditScenarioPropertiesAction" scope="prototype"
-               parent="displayStudyStepAction">
-               <property name="projectElementService"
-                       ref="projectElementService" />
+       <bean id="editScenarioPropertiesAction" class="org.splat.simer.EditScenarioPropertiesAction"
+               scope="prototype" parent="displayStudyStepAction">
+               <property name="projectElementService" ref="projectElementService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
-       <bean id="editSimulationContextAction"
-               class="org.splat.simer.EditSimulationContextAction" scope="prototype"
-               parent="displayStudyStepAction">
+       <bean id="editSimulationContextAction" class="org.splat.simer.EditSimulationContextAction"
+               scope="prototype" parent="displayStudyStepAction">
                <property name="stepService" ref="stepService" />
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
-               <property name="simulationContextTypeService"
-                       ref="simulationContextTypeService" />
+               <property name="simulationContextService" ref="simulationContextService" />
+               <property name="simulationContextTypeService" ref="simulationContextTypeService" />
        </bean>
 
-       <bean id="editDocumentAction"
-               class="org.splat.simer.EditDocumentAction" scope="prototype"
-               parent="displayStudyStepAction">
+       <bean id="editDocumentAction" class="org.splat.simer.EditDocumentAction"
+               scope="prototype" parent="displayStudyStepAction">
                <property name="stepService" ref="stepService" />
                <property name="publicationService" ref="publicationService" />
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
-       <bean id="editKnowledgeElementAction"
-               class="org.splat.simer.EditKnowledgeElementAction" scope="prototype"
-               parent="displayStudyStepAction">
-               <property name="knowledgeElementService"
-                       ref="knowledgeElementService" />
-               <property name="knowledgeElementTypeService"
-                       ref="knowledgeElementTypeService" />
+       <bean id="editKnowledgeElementAction" class="org.splat.simer.EditKnowledgeElementAction"
+               scope="prototype" parent="displayStudyStepAction">
+               <property name="knowledgeElementService" ref="knowledgeElementService" />
+               <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
        <!-- End of Inherited from displayStudyStepAction -->
 
-       <bean id="startAction" class="org.splat.simer.StartAction"
-               scope="prototype" parent="baseAction">
+       <bean id="startAction" class="org.splat.simer.StartAction" scope="prototype"
+               parent="baseAction">
                <property name="applicationSettings" ref="applicationSettings" />
                <property name="projectSettings" ref="projectSettings" />
        </bean>
@@ -200,45 +183,37 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                scope="prototype" parent="baseAction">
        </bean>
 
-       <bean id="menuAction" class="org.splat.simer.MenuAction"
-               scope="prototype" parent="baseAction">
+       <bean id="menuAction" class="org.splat.simer.MenuAction" scope="prototype"
+               parent="baseAction">
        </bean>
 
-       <bean id="notYetImplementedAction"
-               class="org.splat.simer.NotYetImplementedAction" scope="prototype"
-               parent="baseAction">
+       <bean id="notYetImplementedAction" class="org.splat.simer.NotYetImplementedAction"
+               scope="prototype" parent="baseAction">
        </bean>
 
-       <bean id="searchStudyAction"
-               class="org.splat.simer.SearchStudyAction" scope="prototype"
-               parent="baseAction">
+       <bean id="searchStudyAction" class="org.splat.simer.SearchStudyAction"
+               scope="prototype" parent="baseAction">
                <property name="projectSettings" ref="projectSettings" />
                <property name="searchService" ref="searchService" />
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
+               <property name="simulationContextService" ref="simulationContextService" />
                <property name="userService" ref="userService" />
        </bean>
 
-       <bean id="searchKnowledgeAction"
-               class="org.splat.simer.SearchKnowledgeAction" scope="prototype"
-               parent="baseAction">
+       <bean id="searchKnowledgeAction" class="org.splat.simer.SearchKnowledgeAction"
+               scope="prototype" parent="baseAction">
                <property name="searchService" ref="searchService" />
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
-               <property name="knowledgeElementTypeService"
-                       ref="knowledgeElementTypeService" />
+               <property name="simulationContextService" ref="simulationContextService" />
+               <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
                <property name="userService" ref="userService" />
        </bean>
 
-       <bean id="searchDocumentAction"
-               class="org.splat.simer.SearchDocumentAction" scope="prototype">
+       <bean id="searchDocumentAction" class="org.splat.simer.SearchDocumentAction"
+               scope="prototype">
        </bean>
 
-       <bean id="displayKnowledgeAction"
-               class="org.splat.simer.DisplayKnowledgeAction" scope="prototype"
-               parent="baseAction">
-               <property name="knowledgeElementService"
-                       ref="knowledgeElementService" />
+       <bean id="displayKnowledgeAction" class="org.splat.simer.DisplayKnowledgeAction"
+               scope="prototype" parent="baseAction">
+               <property name="knowledgeElementService" ref="knowledgeElementService" />
        </bean>
 
        <bean id="uploadAction" class="org.splat.simer.UploadAction"
@@ -246,58 +221,49 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
-       <bean id="uploadStudyAction"
-               class="org.splat.simer.UploadStudyAction" scope="prototype"
-               parent="baseAction">
+       <bean id="uploadStudyAction" class="org.splat.simer.UploadStudyAction"
+               scope="prototype" parent="baseAction">
        </bean>
 
-       <bean id="versionDocumentAction"
-               class="org.splat.simer.VersionDocumentAction" scope="prototype"
-               parent="baseAction">
+       <bean id="versionDocumentAction" class="org.splat.simer.VersionDocumentAction"
+               scope="prototype" parent="baseAction">
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
                <property name="stepService" ref="stepService" />
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
-       <bean id="databaseIndexingAction"
-               class="org.splat.simer.admin.DatabaseIndexingAction" scope="prototype"
-               parent="baseAction">
+       <bean id="databaseIndexingAction" class="org.splat.simer.admin.DatabaseIndexingAction"
+               scope="prototype" parent="baseAction">
                <property name="searchService" ref="searchService" />
        </bean>
 
-       <bean id="importUserAction"
-               class="org.splat.simer.admin.ImportUserAction" scope="prototype"
-               parent="baseAction">
+       <bean id="importUserAction" class="org.splat.simer.admin.ImportUserAction"
+               scope="prototype" parent="baseAction">
                <property name="repositoryService" ref="repositoryService" />
                <property name="userService" ref="userService" />
        </bean>
 
-       <bean id="simulationContextAction"
-               class="org.splat.simer.admin.SimulationContextAction"
+       <bean id="simulationContextAction" class="org.splat.simer.admin.SimulationContextAction"
                scope="prototype" parent="baseAction">
-               <property name="knowledgeElementService"
-                       ref="knowledgeElementService" />
+               <property name="knowledgeElementService" ref="knowledgeElementService" />
                <property name="searchService" ref="searchService" />
                <property name="projectSettings" ref="projectSettings" />
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
+               <property name="simulationContextService" ref="simulationContextService" />
        </bean>
 
-       <bean id="knowledgeElementAction"
-               class="org.splat.simer.admin.KnowledgeElementAction"
+       <bean id="knowledgeElementAction" class="org.splat.simer.admin.KnowledgeElementAction"
                scope="prototype">
        </bean>
 
-       <bean id="saveDocumentAction"
-               class="org.splat.module.SaveDocumentAction" scope="prototype">
+       <bean id="saveDocumentAction" class="org.splat.module.SaveDocumentAction"
+               scope="prototype">
                <property name="documentTypeService" ref="documentTypeService" />
                <property name="publicationService" ref="publicationService" />
                <property name="repositoryService" ref="repositoryService" />
                <property name="scenarioService" ref="scenarioService" />
                <property name="stepService" ref="stepService" />
-               <property name="simulationContextService"
-                       ref="simulationContextService" />
+               <property name="simulationContextService" ref="simulationContextService" />
        </bean>
 
 </beans>
index 9a2da596a5262c50b1504ba910770770c0dd9b82..ea10f3fa89d7942ca14a82c4e74213d77c54e0a0 100644 (file)
             <result name="success" type="tiles">page.error.study</result>
         </action>
 
+        <action name="checkout" class="checkoutAction" method="checkout">
+            <result name="success">/study/jsonCheckoutRes.jsp</result>
+        </action>
+
         <!-- Creation of a study
           -->        
         <action name="new-empty" class="newStudyAction" method="initialize">