From: rkv Date: Wed, 13 Mar 2013 06:31:25 +0000 (+0000) Subject: ProjectSettings are now configured when the bean is created (without call to a struts... X-Git-Tag: Root_Delivery2_2013_04_22~107 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c46cc52d33ba94d0b6776ff8c1e1f744b0ed2cab;p=tools%2Fsiman.git ProjectSettings are now configured when the bean is created (without call to a struts action). It is fixed for SimanWS. --- diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Relations.hbm.xml b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Relations.hbm.xml index 5dd0fb7..9a42aa9 100644 --- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Relations.hbm.xml +++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Relations.hbm.xml @@ -10,48 +10,48 @@ - - - - - + - - - - + + - - - + + \ No newline at end of file diff --git a/Workspace/Siman-Common/src/org/splat/service/ProjectElementServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/ProjectElementServiceImpl.java index f5ec91e..fda1d9d 100644 --- a/Workspace/Siman-Common/src/org/splat/service/ProjectElementServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/ProjectElementServiceImpl.java @@ -16,6 +16,7 @@ import org.splat.dal.bo.som.ProjectElement; import org.splat.dal.bo.som.Publication; import org.splat.dal.dao.som.ProjectElementDAO; import org.splat.service.technical.ProjectSettingsService; +import org.splat.service.technical.StepsConfigService; import org.splat.som.Step; import org.springframework.transaction.annotation.Transactional; @@ -30,7 +31,7 @@ public class ProjectElementServiceImpl implements ProjectElementService { /** * Injected project settings service. */ - private ProjectSettingsService _projectSettings; + private StepsConfigService _stepsConfigService; /** * Injected project element DAO. */ @@ -57,7 +58,7 @@ public class ProjectElementServiceImpl implements ProjectElementService { */ public Step[] getSteps(final ProjectElement elem) { if (elem.getFolders() == null) { - List steps = getProjectSettings() + List steps = getStepsConfigService() .getStepsOf(elem.getClass()); Iterator nstep = steps.iterator(); @@ -91,22 +92,22 @@ public class ProjectElementServiceImpl implements ProjectElementService { } /** - * Get project settings. + * Get steps config. * - * @return Project settings service + * @return steps config service */ - private ProjectSettingsService getProjectSettings() { - return _projectSettings; + private StepsConfigService getStepsConfigService() { + return _stepsConfigService; } /** - * Set project settings service. + * Set steps config service. * - * @param projectSettingsService - * project settings service + * @param stepsConfigService + * steps config service */ - public void setProjectSettings(final ProjectSettingsService projectSettingsService) { - _projectSettings = projectSettingsService; + public void setStepsConfigService(final StepsConfigService stepsConfigService) { + _stepsConfigService = stepsConfigService; } /** diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsService.java b/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsService.java index 16a446c..da1f48a 100644 --- a/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsService.java +++ b/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsService.java @@ -245,16 +245,6 @@ public interface ProjectSettingsService { */ void configure(String filename) throws IOException, SQLException; - /** - * Get steps of the given project element (study or scenario). - * - * @param level - * the project element (study or scenario) - * @return the list of steps - */ - List getStepsOf( - Class level); - /** * Check if a file of the given format should be imported during check-in of a document of the given type. * diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java index 88a779e..f079a5a 100644 --- a/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/technical/ProjectSettingsServiceImpl.java @@ -37,6 +37,9 @@ import org.splat.manox.XDOM; import org.splat.service.DocumentTypeService; import org.splat.service.KnowledgeElementTypeService; import org.splat.service.SimulationContextTypeService; +import org.springframework.context.ResourceLoaderAware; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; import org.springframework.transaction.annotation.Transactional; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -46,7 +49,8 @@ import org.w3c.dom.NodeList; /** * SIMAN workflow configuration data service. */ -public class ProjectSettingsServiceImpl implements ProjectSettingsService { +public class ProjectSettingsServiceImpl implements ProjectSettingsService, + ResourceLoaderAware { /** * The logger for the service. @@ -59,6 +63,20 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { */ private final static String TYPE_ATTR = "type"; + /** + * Steps configuration storage. + */ + private StepsConfigService _stepsConfigService; + /** + * Resource loader injected by Spring. + */ + private ResourceLoader _resourceLoader; + + /** + * Configuration resource injected by Spring. + */ + private Resource _config; + // Non persistent configuration information /** * Repository settings. @@ -76,10 +94,6 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { * Pattern of the presentation of version numbers. */ private transient String _versioning; - /** - * Ordered list of (transient) study steps. - */ - private transient final List _steps = new ArrayList(); /** * Configuration document validation cycles. */ @@ -217,7 +231,24 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { // ============================================================================================================================== /** - * Load workflow configuration from the given file.
Create necessary default staff in the database if it is not initialized yet. + * Load workflow configuration from the file defined by config property.
+ * Create necessary default staff in the database if it is not initialized yet. + * + * @throws IOException + * if there is a file reading or index creation problem + * @throws SQLException + * if there is a database population problem + */ + @Transactional + public void configure() throws IOException, SQLException { + if (getConfig() != null) { + configure("file:" + getConfig().getFile().getAbsolutePath()); + } + } + + /** + * Load workflow configuration from the given file.
+ * Create necessary default staff in the database if it is not initialized yet. * * @param filename * the workflow configuration file @@ -229,12 +260,17 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { @Transactional public void configure(final String filename) throws IOException, SQLException { - if (!_steps.isEmpty()) { + if (!getStepsConfigService().getSteps().isEmpty()) { return; // Project already configured } Database base = getDatabase().getCheckedDB(); - File config = new File(filename); + if (LOG.isInfoEnabled()) { + LOG.info("Loading configuration from: " + + getResource(filename).getFile().getAbsolutePath()); + LOG.info("Root: " + getResource("/").getURI()); + } + File config = getResource(filename).getFile(); if (config.exists()) { loadCustomization(config); } else { @@ -255,7 +291,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { * @return the list of steps from project settings */ public List getAllSteps() { - return _steps; + return getStepsConfigService().getSteps(); } /** @@ -305,8 +341,9 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { */ public ProjectSettingsService.Step getStep(final int number) { ProjectSettingsService.Step res = null; - for (int i = 0; i < _steps.size(); i++) { - ProjectSettingsService.Step step = _steps.get(i); + for (int i = 0; i < getStepsConfigService().getSteps().size(); i++) { + ProjectSettingsService.Step step = getStepsConfigService() + .getSteps().get(i); if (step.getNumber() == number) { res = step; break; @@ -315,26 +352,6 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { return res; } - /** - * Get steps of the given project element (study or scenario). - * - * @param level - * the project element (study or scenario) - * @return the list of steps - */ - public List getStepsOf( - final Class level) { - List result = new ArrayList(); - - for (int i = 0; i < _steps.size(); i++) { - ProjectSettingsService.Step step = _steps.get(i); - if (step.appliesTo(level)) { - result.add(step); - } - } - return result; - } - /** * Check if a file of the given format should be imported during check-out of a document of the given type. * @@ -679,7 +696,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { step.setModule(module.getAttribute("name")); } - _steps.add(step); + getStepsConfigService().getSteps().add(step); res += 1; } return res; @@ -764,7 +781,8 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { String uses = null; for (Iterator i = _flows.iterator(); i.hasNext(); snum++) { NamedNodeMap flow = i.next(); - ProjectSettingsService.Step step = _steps.get(snum); + ProjectSettingsService.Step step = getStepsConfigService() + .getSteps().get(snum); String[] contents = flow.getNamedItem("contents").getNodeValue() .split(","); for (int j = 0; j < contents.length; j++) { @@ -804,7 +822,7 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { // Parse uses attribute String[] usesArr = uses.split(","); List usesTypesList = new ArrayList(); - for (String usesType: usesArr) { + for (String usesType : usesArr) { tdoc = maptype.get(usesType.trim()); if (tdoc == null) { LOG.warn("Undefined \"" + usesType.trim() @@ -815,7 +833,8 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { } } } - tprop.setUses(usesTypesList.toArray(new DocumentType[]{})); + tprop.setUses(usesTypesList + .toArray(new DocumentType[] {})); } if (step != null) { tprop.setResult(step); @@ -876,7 +895,8 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { String[] clist = clatr.getNamedItem("context").getNodeValue() .split(","); for (int j = 0; j < clist.length; j++) { - mapstep.put(clist[j], _steps.get(snum)); + mapstep.put(clist[j], getStepsConfigService().getSteps() + .get(snum)); } } } @@ -978,4 +998,64 @@ public class ProjectSettingsServiceImpl implements ProjectSettingsService { final DocumentTypeService documentTypeService) { _documentTypeService = documentTypeService; } + + /** + * {@inheritDoc} + * + * @see org.springframework.context.ResourceLoaderAware#setResourceLoader(org.springframework.core.io.ResourceLoader) + */ + @Override + public void setResourceLoader(final ResourceLoader resourceLoader) { + this._resourceLoader = resourceLoader; + } + + /** + * Get resource by means of Spring resource loader. + * + * @param location + * the resource location + * @return the resource + */ + public Resource getResource(final String location) { + return _resourceLoader.getResource(location); + } + + /** + * Get the config. + * + * @return the config + */ + public Resource getConfig() { + return _config; + } + + /** + * Set the config. + * + * @param config + * the config to set + */ + public void setConfig(final Resource config) { + _config = config; + } + + /** + * Get the stepsConfigService. + * + * @return the stepsConfigService + */ + public StepsConfigService getStepsConfigService() { + return _stepsConfigService; + } + + /** + * Set the stepsConfigService. + * + * @param stepsConfigService + * the stepsConfigService to set + */ + public void setStepsConfigService( + final StepsConfigService stepsConfigService) { + _stepsConfigService = stepsConfigService; + } } \ No newline at end of file diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/StepsConfigService.java b/Workspace/Siman-Common/src/org/splat/service/technical/StepsConfigService.java new file mode 100644 index 0000000..b688c5e --- /dev/null +++ b/Workspace/Siman-Common/src/org/splat/service/technical/StepsConfigService.java @@ -0,0 +1,41 @@ +/***************************************************************************** + * Company OPEN CASCADE + * Application SIMAN + * File $Id$ + * Creation date 12.03.2013 + * @author $Author$ + * @version $Revision$ + * @copyright OPEN CASCADE 2012 + *****************************************************************************/ + +package org.splat.service.technical; + +import java.util.List; + +import org.splat.dal.bo.som.ProjectElement; + +/** + * Study steps configuration service. + * + * @author Roman Kozlov (RKV) + */ +public interface StepsConfigService { + + /** + * Get steps of the given project element (study or scenario). + * + * @param level + * the project element (study or scenario) + * @return the list of steps + */ + List getStepsOf( + Class level); + + /** + * Get the steps. + * + * @return the steps + */ + public List getSteps(); + +} diff --git a/Workspace/Siman-Common/src/org/splat/service/technical/StepsConfigServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/technical/StepsConfigServiceImpl.java new file mode 100644 index 0000000..0776d94 --- /dev/null +++ b/Workspace/Siman-Common/src/org/splat/service/technical/StepsConfigServiceImpl.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Company OPEN CASCADE + * Application SIMAN + * File $Id$ + * Creation date 12.03.2013 + * @author $Author$ + * @version $Revision$ + * @copyright OPEN CASCADE 2012 + *****************************************************************************/ + +package org.splat.service.technical; + +import java.util.ArrayList; +import java.util.List; + +import org.splat.dal.bo.som.ProjectElement; + +/** + * Study steps configuration service. + * + * @author Roman Kozlov (RKV) + */ +public class StepsConfigServiceImpl implements StepsConfigService { + + /** + * Ordered list of (transient) study steps. + */ + private transient final List _steps = new ArrayList(); + + /** + * Get steps of the given project element (study or scenario). + * + * @param level + * the project element (study or scenario) + * @return the list of steps + */ + public List getStepsOf( + final Class level) { + List result = new ArrayList(); + + for (int i = 0; i < _steps.size(); i++) { + ProjectSettingsService.Step step = _steps.get(i); + if (step.appliesTo(level)) { + result.add(step); + } + } + return result; + } + + /** + * Get the steps. + * + * @return the steps + */ + public List getSteps() { + return _steps; + } + +} diff --git a/Workspace/Siman-Common/src/spring/businessServiceContext.xml b/Workspace/Siman-Common/src/spring/businessServiceContext.xml index bb1b461..a08ebfa 100644 --- a/Workspace/Siman-Common/src/spring/businessServiceContext.xml +++ b/Workspace/Siman-Common/src/spring/businessServiceContext.xml @@ -23,7 +23,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> - + diff --git a/Workspace/Siman-Common/src/spring/technicalServiceContext.xml b/Workspace/Siman-Common/src/spring/technicalServiceContext.xml index 25da86b..6def9c8 100644 --- a/Workspace/Siman-Common/src/spring/technicalServiceContext.xml +++ b/Workspace/Siman-Common/src/spring/technicalServiceContext.xml @@ -14,8 +14,14 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> + + + class="org.splat.service.technical.ProjectSettingsServiceImpl" + init-method="configure"> + + diff --git a/Workspace/Siman-Common/src/test/siman.properties b/Workspace/Siman-Common/src/test/siman.properties index 057b3b5..535882f 100644 --- a/Workspace/Siman-Common/src/test/siman.properties +++ b/Workspace/Siman-Common/src/test/siman.properties @@ -2,7 +2,7 @@ schema.version = D-0.3 wapp.version = D-0.5 wapp.login = conf/login.conf -wapp.configuration = som.xml +wapp.configuration = classpath:test/som.xml wapp.customization = conf/my.xml wapp.website = http://www.salome-platform.org wapp.onlinehelp = http://docs.salome-platform.org/salome_6_3_1/gui/GUI_index.html diff --git a/Workspace/Siman-Common/src/test/splat/dao/TestStudyDAO.java b/Workspace/Siman-Common/src/test/splat/dao/TestStudyDAO.java index 60c48d0..9f887af 100644 --- a/Workspace/Siman-Common/src/test/splat/dao/TestStudyDAO.java +++ b/Workspace/Siman-Common/src/test/splat/dao/TestStudyDAO.java @@ -540,8 +540,7 @@ public class TestStudyDAO extends BaseTest { _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again // Load workflow customization try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find som.xml: ", e); } diff --git a/Workspace/Siman-Common/src/test/splat/service/TestProjectSettingsService.java b/Workspace/Siman-Common/src/test/splat/service/TestProjectSettingsService.java index 78d376b..5d9e769 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestProjectSettingsService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestProjectSettingsService.java @@ -22,6 +22,7 @@ import org.splat.service.DocumentTypeService; import org.splat.service.KnowledgeElementTypeService; import org.splat.service.SimulationContextService; import org.splat.service.technical.ProjectSettingsService; +import org.splat.service.technical.StepsConfigService; import org.splat.service.technical.ProjectSettingsService.Step; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -52,6 +53,13 @@ public class TestProjectSettingsService extends BaseTest { @Qualifier("projectSettings") private transient ProjectSettingsService _projectSettings; + /** + * The StepsConfigService. Later injected by Spring. + */ + @Autowired + @Qualifier("stepsConfigService") + private transient StepsConfigService _stepsConfigService; + /** * The DocumentTypeService. Later injected by Spring. */ @@ -113,12 +121,11 @@ public class TestProjectSettingsService extends BaseTest { */ _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find configuration file: ", e); } - List steps = _projectSettings.getStepsOf(Scenario.class); + List steps = _stepsConfigService.getStepsOf(Scenario.class); Assert.assertTrue(steps.size() > 0, "No steps are created."); Assert.assertTrue(_projectSettings.doImport("geometry", "brep")); Assert.assertTrue(_projectSettings.doImport("model", "med")); @@ -128,12 +135,11 @@ public class TestProjectSettingsService extends BaseTest { // ////// Load workflow customization with empty mappings _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som-without-mappings.xml").getPath()); + _projectSettings.configure("classpath:test/som-without-mappings.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find configuration file: ", e); } - steps = _projectSettings.getStepsOf(Scenario.class); + steps = _stepsConfigService.getStepsOf(Scenario.class); Assert.assertTrue(steps.size() > 0, "No steps are created."); Assert.assertFalse(_projectSettings.doImport("geometry", "brep")); Assert.assertFalse(_projectSettings.doImport("model", "med")); @@ -143,9 +149,7 @@ public class TestProjectSettingsService extends BaseTest { // ////// Load workflow customization from not existing file _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again try { - _projectSettings.configure(ClassLoader.getSystemResource("/") - .getPath() - + "test/xxx.xml"); + _projectSettings.configure("classpath:test/xxx.xml"); Assert .fail("Customization loading must fail for not existing configuration file."); } catch (FileNotFoundException e) { @@ -242,14 +246,13 @@ public class TestProjectSettingsService extends BaseTest { Database.getInstance().reset(); _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find configuration file: ", e); } Assert.assertTrue(_documentTypeService.selectAllTypes().size() > 0, "No document types are created."); - List steps = _projectSettings.getStepsOf(Scenario.class); + List steps = _stepsConfigService.getStepsOf(Scenario.class); Assert.assertTrue(steps.size() > 0, "No steps are created."); for (Step step : steps) { @@ -401,12 +404,11 @@ public class TestProjectSettingsService extends BaseTest { // ////// Load workflow customization with empty mappings _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som-without-mappings.xml").getPath()); + _projectSettings.configure("classpath:test/som-without-mappings.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find configuration file: ", e); } - steps = _projectSettings.getStepsOf(Scenario.class); + steps = _stepsConfigService.getStepsOf(Scenario.class); Assert.assertTrue(steps.size() > 0, "No steps are created."); for (Step step : steps) { List defTypes = _projectSettings.getDefaultFormats(step); @@ -436,9 +438,7 @@ public class TestProjectSettingsService extends BaseTest { // ////// Load workflow customization from not existing file _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again try { - _projectSettings.configure(ClassLoader.getSystemResource("/") - .getPath() - + "test/xxx.xml"); + _projectSettings.configure("classpath:test/xxx.xml"); Assert .fail("Customization loading must fail for not existing configuration file."); } catch (FileNotFoundException e) { @@ -481,14 +481,13 @@ public class TestProjectSettingsService extends BaseTest { _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again Database.getInstance().reset(); try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find configuration file: ", e); } getHibernateTemplate().flush(); - List steps = _projectSettings.getStepsOf(Scenario.class); + List steps = _stepsConfigService.getStepsOf(Scenario.class); Assert.assertTrue(steps.size() > 0, "No steps are created."); KnowledgeElementType ucase = _knowledgeElementTypeService.selectType("usecase"); Assert.assertNotNull(ucase, "Knowledge type 'usecase' must be created in the database."); @@ -500,12 +499,11 @@ public class TestProjectSettingsService extends BaseTest { Database.getInstance().reset(); _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find configuration file: ", e); } - steps = _projectSettings.getStepsOf(Scenario.class); + steps = _stepsConfigService.getStepsOf(Scenario.class); Assert.assertTrue(steps.size() > 0, "No steps are created."); ucase = _knowledgeElementTypeService.selectType("usecase"); Assert.assertNotNull(ucase, "Knowledge type 'usecase' must be created in the database."); @@ -563,13 +561,13 @@ public class TestProjectSettingsService extends BaseTest { startNestedTransaction(); // /////////////////////////////////////////////////// // ////// Load good workflow customization + getHibernateTemplate().bulkUpdate("delete from User"); getHibernateTemplate().bulkUpdate("delete from Role"); getHibernateTemplate().flush(); Database.getInstance().reset(); _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find configuration file: ", e); } diff --git a/Workspace/Siman-Common/src/test/splat/service/TestPublicationService.java b/Workspace/Siman-Common/src/test/splat/service/TestPublicationService.java index 47f9810..6fb04e4 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestPublicationService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestPublicationService.java @@ -150,8 +150,7 @@ public class TestPublicationService extends BaseTest { _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again // Load workflow customization try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find som.xml: ", e); } diff --git a/Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java b/Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java index 7661d62..e70d404 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestScenarioService.java @@ -56,6 +56,7 @@ 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.StepsConfigService; import org.splat.service.technical.ProjectSettingsService.Step; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -130,6 +131,13 @@ public class TestScenarioService extends BaseTest { @Qualifier("projectSettings") private transient ProjectSettingsService _projectSettings; + /** + * The StepsConfigService. Later injected by Spring. + */ + @Autowired + @Qualifier("stepsConfigService") + private transient StepsConfigService _stepsConfigService; + /** * The DocumentTypeService. Later injected by Spring. */ @@ -203,7 +211,7 @@ public class TestScenarioService extends BaseTest { Assert.assertNotNull(steps, "List of steps must not be null."); Assert.assertTrue(steps.size() > 0, "No steps are read."); - List projSteps = _projectSettings.getStepsOf(Scenario.class); + List projSteps = _stepsConfigService.getStepsOf(Scenario.class); Assert.assertEquals(steps.size(), projSteps.size(), "Not all steps are listed."); int docIndex = 0; @@ -361,8 +369,7 @@ public class TestScenarioService extends BaseTest { startNestedTransaction(); _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again - _projectSettings.configure(ClassLoader - .getSystemResource("test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); getHibernateTemplate().flush(); long scenarioId = createScenario(); Scenario aScen = _scenarioDAO.get(scenarioId); @@ -830,12 +837,11 @@ public class TestScenarioService extends BaseTest { _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again // Load workflow customization try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find som.xml: ", e); } - List steps = _projectSettings.getStepsOf(Scenario.class); + List steps = _stepsConfigService.getStepsOf(Scenario.class); Assert.assertTrue(steps.size() > 0, "No steps are created."); // Create a test user @@ -1060,8 +1066,7 @@ public class TestScenarioService extends BaseTest { Database.getInstance().reset(); _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again - _projectSettings.configure(ClassLoader - .getSystemResource("test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); // Create a test user User.Properties uprop = new User.Properties(); @@ -1148,8 +1153,7 @@ public class TestScenarioService extends BaseTest { Database.getInstance().reset(); _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again - _projectSettings.configure(ClassLoader - .getSystemResource("test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); // Create a test user User goodUser = TestEntitiesGenerator.getTestUser("goodUser"); diff --git a/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java b/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java index f9dc920..458a176 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java @@ -204,8 +204,7 @@ public class TestSearchService extends BaseTest { _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again // Load workflow customization try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (Exception e) { Assert.fail("Can't load som.xml: ", e); } @@ -418,8 +417,7 @@ public class TestSearchService extends BaseTest { _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again // Load workflow customization try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (Exception e) { Assert.fail("Can't load som.xml: ", e); } diff --git a/Workspace/Siman-Common/src/test/splat/service/TestStepService.java b/Workspace/Siman-Common/src/test/splat/service/TestStepService.java index 9ead134..0003b00 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestStepService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestStepService.java @@ -180,8 +180,7 @@ public class TestStepService extends BaseTest { startNestedTransaction(); _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again - _projectSettings.configure(ClassLoader - .getSystemResource("test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); HibernateTemplate ht = getHibernateTemplate(); ht.flush(); long scenarioId = createScenario(); @@ -460,8 +459,7 @@ public class TestStepService extends BaseTest { _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again // Load workflow customization try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find som.xml: ", e); } @@ -845,7 +843,7 @@ public class TestStepService extends BaseTest { * @param title the title * @throws InvalidParameterException if there is something wrong likely unrelated to the tested method */ - private void testEdit(StepCommentAttribute comment, String value, String title) + private void testEdit(final StepCommentAttribute comment, final String value, final String title) throws InvalidParameterException { String oldValue = comment.getValue(); String oldTitle = comment.getTitle(); diff --git a/Workspace/Siman-Common/src/test/splat/service/TestStudyService.java b/Workspace/Siman-Common/src/test/splat/service/TestStudyService.java index d3a704b..b54b62c 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestStudyService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestStudyService.java @@ -19,12 +19,12 @@ import java.util.Map; import org.splat.dal.bo.kernel.User; import org.splat.dal.bo.som.DescriptionAttribute; 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.ProjectElement; import org.splat.dal.bo.som.Publication; import org.splat.dal.bo.som.Scenario; import org.splat.dal.bo.som.Study; +import org.splat.dal.bo.som.Document.Properties; import org.splat.dal.dao.kernel.UserDAO; import org.splat.dal.dao.som.Database; import org.splat.dal.dao.som.StudyDAO; @@ -137,8 +137,7 @@ public class TestStudyService extends BaseTest { _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again // Load workflow customization try { - _projectSettings.configure(ClassLoader.getSystemResource( - "test/som.xml").getPath()); + _projectSettings.configure("classpath:test/som.xml"); } catch (FileNotFoundException e) { Assert.fail("Can't find som.xml: ", e); } diff --git a/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java b/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java index 61cbe0b..333fb73 100644 --- a/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java +++ b/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java @@ -11,6 +11,7 @@ import org.splat.kernel.InvalidPropertyException; import org.splat.service.SearchService; import org.splat.service.dto.StudySearchFilterDTO; import org.splat.service.technical.ProjectSettingsService; +import org.splat.service.technical.StepsConfigService; import org.splat.wapp.Constants; /** @@ -27,7 +28,7 @@ public class SearchStudyAction extends /** * Injected project settings service. */ - private ProjectSettingsService _projectSettings; + private StepsConfigService _stepsConfigService; /** * Injected search service. */ @@ -91,7 +92,7 @@ public class SearchStudyAction extends */ @Override protected List getInvolvedContexts() { - List steps = getProjectSettings() + List steps = getStepsConfigService() .getStepsOf(Study.class); ProjectSettingsService.Step[] number = steps .toArray(new ProjectSettingsService.Step[steps.size()]); @@ -150,23 +151,23 @@ public class SearchStudyAction extends } /** - * Get project settings. + * Get StepsConfigService. * - * @return Project settings service + * @return StepsConfigService */ - private ProjectSettingsService getProjectSettings() { - return _projectSettings; + private StepsConfigService getStepsConfigService() { + return _stepsConfigService; } /** - * Set project settings service. + * Set StepsConfigService. * - * @param projectSettingsService - * project settings service + * @param stepsConfigService + * StepsConfigService */ - public void setProjectSettings( - final ProjectSettingsService projectSettingsService) { - _projectSettings = projectSettingsService; + public void setStepsConfigService( + final StepsConfigService stepsConfigService) { + _stepsConfigService = stepsConfigService; } /** diff --git a/Workspace/Siman/src/org/splat/simer/StartAction.java b/Workspace/Siman/src/org/splat/simer/StartAction.java index 64a6ed5..be27e29 100644 --- a/Workspace/Siman/src/org/splat/simer/StartAction.java +++ b/Workspace/Siman/src/org/splat/simer/StartAction.java @@ -2,12 +2,11 @@ package org.splat.simer; import java.util.Map; -import org.splat.service.technical.ProjectSettingsService; import org.splat.som.ApplicationRights; import org.splat.wapp.Constants; /** - * Start application action. + * Start application action. Initializes application settings. */ public class StartAction extends Action { /** @@ -15,11 +14,6 @@ public class StartAction extends Action { */ private static final long serialVersionUID = 5875058140682652964L; - /** - * Injected project settings service. - */ - private ProjectSettingsService _projectSettings; - // ============================================================================================================================== // Action execution // ============================================================================================================================== @@ -36,17 +30,11 @@ public class StartAction extends Action { LOG.info(new StringBuffer("Initializing ").append(wappurl) .append("...").toString()); try { - ProjectSettingsService project = getProjectSettings(); ApplicationSettings wapp = getApplicationSettings(); wapp.setLocale(this.getLocale()); String root = ApplicationSettings.getApplicationRootPath(); LOG.debug("Application root: " + root); - // Database configuration - project.configure(root - + ApplicationSettings - .getApplicationProperty("wapp.configuration")); - // Configure menus for the current user wapp.configure(); @@ -71,28 +59,4 @@ public class StartAction extends Action { } return res; } - - // ============================================================================================================================== - // Setter - // ============================================================================================================================== - - /** - * Get project settings. - * - * @return Project settings service - */ - private ProjectSettingsService getProjectSettings() { - return _projectSettings; - } - - /** - * Set project settings service. - * - * @param projectSettingsService - * project settings service - */ - public void setProjectSettings( - final ProjectSettingsService projectSettingsService) { - _projectSettings = projectSettingsService; - } } \ No newline at end of file diff --git a/Workspace/Siman/src/spring/applicationContext.xml b/Workspace/Siman/src/spring/applicationContext.xml index a7ce2df..13d385d 100644 --- a/Workspace/Siman/src/spring/applicationContext.xml +++ b/Workspace/Siman/src/spring/applicationContext.xml @@ -25,8 +25,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> class="org.springframework.context.support.ResourceBundleMessageSource"> - conf/log-messages - som + conf/log-messages + som @@ -48,20 +48,16 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + scope="session" /> - + scope="session" /> - + scope="session" /> - + scope="session" /> - + - + parent="openObject" scope="session" /> + + - - - @@ -141,7 +137,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + @@ -156,10 +152,11 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - - - + + + @@ -170,10 +167,9 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - - - + + @@ -209,49 +205,43 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> ref="knowledgeElementTypeService" /> - + - - - - - - - - + class="org.splat.simer.EditStepCommentAction" scope="prototype" + parent="displayStudyStepAction"> + + + + + + + - - - + scope="prototype" parent="baseAction" /> + - + scope="prototype" parent="baseAction" /> - + scope="prototype" parent="baseAction" /> - + parent="baseAction" /> - + @@ -270,8 +260,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + class="org.splat.simer.SearchDocumentAction" scope="prototype" /> - + parent="baseAction" /> - + @@ -326,7 +314,6 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + scope="prototype" />