From 3df7975ae4b432bd34ce5fe6d24bee1f807c6b99 Mon Sep 17 00:00:00 2001 From: mka Date: Fri, 15 Feb 2013 13:11:01 +0000 Subject: [PATCH] Show and Edit description functionalities are implemented --- .../src/conf/log-messages.properties | 2 +- .../src/conf/log-messages_en.properties | 2 +- .../common/properties/MessageKeyEnum.java | 4 +- .../org/splat/dal/bo/som/Attributes.hbm.xml | 2 +- .../src/org/splat/dal/bo/som/Study.hbm.xml | 2 +- .../org/splat/service/StepServiceImpl.java | 2 + .../src/org/splat/service/StudyService.java | 21 ++- .../org/splat/service/StudyServiceImpl.java | 131 +++++++++++++++++- .../src/spring/businessServiceContext.xml | 1 + .../test/splat/service/TestStepService.java | 60 ++------ .../test/splat/service/TestStudyService.java | 117 +++++++++++++++- .../splat/util/TestEntitiesGenerator.java | 69 +++++++++ .../WebContent/WEB-INF/tiles/tiles-defs.xml | 7 + .../Siman/WebContent/jsp/descriptionPane.jsp | 70 ++++++++++ .../Siman/WebContent/jsp/readDescription.jsp | 29 +--- .../WebContent/study/displayStudyStep.jsp | 4 +- .../splat/simer/DisplayStudyStepAction.java | 50 +++++++ Workspace/Siman/src/struts.xml | 6 + 18 files changed, 487 insertions(+), 92 deletions(-) create mode 100644 Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java create mode 100644 Workspace/Siman/WebContent/jsp/descriptionPane.jsp diff --git a/Workspace/Siman-Common/src/conf/log-messages.properties b/Workspace/Siman-Common/src/conf/log-messages.properties index fed0f42..f947e08 100644 --- a/Workspace/Siman-Common/src/conf/log-messages.properties +++ b/Workspace/Siman-Common/src/conf/log-messages.properties @@ -18,4 +18,4 @@ SCT-000001=Simulation context type "{0}" already exists DCT-000001=Document type "{0}" already exists DCT-000002=Can not delete the document "{0}" because it is used by other documents. DCT-000003=Can not save a document in {0} state. Check the validation cycle. -PARAM-000001=Parameter {0} is invalid with value: {1} +PRM-000001=Parameter {0} is invalid with value: {1} diff --git a/Workspace/Siman-Common/src/conf/log-messages_en.properties b/Workspace/Siman-Common/src/conf/log-messages_en.properties index fed0f42..f1b20c6 100644 --- a/Workspace/Siman-Common/src/conf/log-messages_en.properties +++ b/Workspace/Siman-Common/src/conf/log-messages_en.properties @@ -18,4 +18,4 @@ SCT-000001=Simulation context type "{0}" already exists DCT-000001=Document type "{0}" already exists DCT-000002=Can not delete the document "{0}" because it is used by other documents. DCT-000003=Can not save a document in {0} state. Check the validation cycle. -PARAM-000001=Parameter {0} is invalid with value: {1} +PRM-000001=Parameter {0} is invalid with value: {1} \ No newline at end of file diff --git a/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java b/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java index 27be5b2..eaea30f 100644 --- a/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java +++ b/Workspace/Siman-Common/src/org/splat/common/properties/MessageKeyEnum.java @@ -94,9 +94,9 @@ public enum MessageKeyEnum { */ DCT_000003("DCT-000003"), /** - * Parameter {1} is invalid with value: {2}. + * Parameter {0} is invalid with value: {1}. */ - PARAM_000001("PARAM-000001"); + PRM_000001("PRM-000001"); /** * Value. */ diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Attributes.hbm.xml b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Attributes.hbm.xml index 2072446..6c21eaf 100644 --- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Attributes.hbm.xml +++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Attributes.hbm.xml @@ -26,7 +26,7 @@ - + diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.hbm.xml b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.hbm.xml index 27f2d9c..be38e6a 100644 --- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.hbm.xml +++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.hbm.xml @@ -19,7 +19,7 @@ - + diff --git a/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java index 47d0962..af8ffcb 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/StepServiceImpl.java @@ -604,9 +604,11 @@ public class StepServiceImpl implements StepService { } /** + * {@inheritDoc} * @see org.splat.service.StepService#getStepComments(org.splat.som.Step) */ @Override + @Transactional(readOnly = true) public List getStepComments(final Step step) throws InvalidParameterException { ProjectElement owner = _projectElementDAO.get(step.getOwner().getRid()); if(owner == null) { diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyService.java b/Workspace/Siman-Common/src/org/splat/service/StudyService.java index 13dc7df..19fa71f 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyService.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyService.java @@ -18,6 +18,7 @@ import org.splat.dal.bo.som.SimulationContext; import org.splat.dal.bo.som.Study; import org.splat.dal.bo.som.Study.Properties; import org.splat.dal.bo.som.ValidationCycle; +import org.splat.exception.InvalidParameterException; import org.splat.kernel.InvalidPropertyException; import org.splat.kernel.MissedPropertyException; import org.splat.kernel.MultiplyDefinedException; @@ -264,7 +265,6 @@ public interface StudyService { * Mark study as reference. * * @param aStudy - the Study - * @return true if operation is success */ void markStudyAsReference(Study aStudy); @@ -273,7 +273,24 @@ public interface StudyService { * This operation is inverse one to Mark as reference. * * @param aStudy - the Study - * @return true if operation is success */ void removeStudyAsReference(Study aStudy); + + /** + * Get the description attribute related to the study + * (there supposed to be the only one such attribute in the database). + * @param studyId the study id + * @return the description attribute value (null if does not exist) + * @throws InvalidParameterException if a study with such id does not exist in the database. + */ + String getDescription(Long studyId) throws InvalidParameterException; + + /** + * Set the description attribute related to the study. + * @param studyId the study id + * @param descriptionText the description text + * @throws InvalidParameterException if some parameters are invalid. + */ + void setDescription(Long studyId, String descriptionText) throws InvalidParameterException; + } diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java index 1228925..b1f0305 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java @@ -34,16 +34,20 @@ import org.splat.dal.bo.som.Publication; import org.splat.dal.bo.som.Scenario; import org.splat.dal.bo.som.SimulationContext; import org.splat.dal.bo.som.Study; +import org.splat.dal.bo.som.Study.Properties; import org.splat.dal.bo.som.ValidationCycle; +import org.splat.dal.bo.som.ValidationCycle.Actor; import org.splat.dal.bo.som.ValidationCycleRelation; import org.splat.dal.bo.som.ValidationStep; import org.splat.dal.bo.som.Visibility; -import org.splat.dal.bo.som.Study.Properties; -import org.splat.dal.bo.som.ValidationCycle.Actor; +import org.splat.dal.dao.som.DescriptionAttributeDAO; +import org.splat.dal.dao.som.DocumentDAO; import org.splat.dal.dao.som.IDBuilderDAO; +import org.splat.dal.dao.som.PublicationDAO; import org.splat.dal.dao.som.ScenarioDAO; import org.splat.dal.dao.som.StudyDAO; import org.splat.dal.dao.som.ValidationCycleDAO; +import org.splat.exception.InvalidParameterException; import org.splat.kernel.InvalidPropertyException; import org.splat.kernel.MissedPropertyException; import org.splat.kernel.MultiplyDefinedException; @@ -51,6 +55,7 @@ import org.splat.log.AppLogger; import org.splat.service.technical.IndexService; import org.splat.service.technical.ProjectSettingsService; import org.splat.service.technical.ProjectSettingsServiceImpl; +import org.splat.service.technical.RepositoryService; import org.splat.som.Revision; import org.springframework.transaction.annotation.Transactional; @@ -117,6 +122,26 @@ public class StudyServiceImpl implements StudyService { * Injected user service. */ private UserService _userService; + + /** + * Injected publication DAO. + */ + private PublicationDAO _publicationDAO; + + /** + * Injected repository service. + */ + private RepositoryService _repositoryService; + + /** + * Injected document DAO. + */ + private DocumentDAO _documentDAO; + + /** + * Injected description attribute DAO. + */ + private DescriptionAttributeDAO _descriptionAttributeDAO; /** * {@inheritDoc} @@ -1027,6 +1052,42 @@ public class StudyServiceImpl implements StudyService { aStudy.setProgressState(ProgressState.APPROVED); getStudyDAO().merge(aStudy); } + + /** + * {@inheritDoc} + * @see org.splat.service.StudyService#getDescription(java.lang.Long) + */ + @Override + @Transactional(readOnly = true) + public String getDescription(final Long studyId) throws InvalidParameterException { + if(studyId == null) { + throw new InvalidParameterException("studyId", "null"); + } + Study study = _studyDAO.get(studyId); + if(study == null) { + throw new InvalidParameterException("studyId", studyId.toString()); + } + return study.getDescription(); + } + + + /** + * {@inheritDoc} + * @see org.splat.service.StudyService#setDescription(java.lang.Long, java.lang.String) + */ + @Override + @Transactional + public void setDescription(final Long studyId, final String descriptionText) + throws InvalidParameterException { + if(studyId == null) { + throw new InvalidParameterException("studyId", "null"); + } + Study study = _studyDAO.get(studyId); + if(study == null) { + throw new InvalidParameterException("studyId", studyId.toString()); + } + study.setAttribute(new DescriptionAttribute(study, descriptionText)); + } /** * Get project settings. @@ -1221,4 +1282,70 @@ public class StudyServiceImpl implements StudyService { public void setUserService(final UserService userService) { _userService = userService; } + + /** + * Get the publicationDAO. + * @return the publicationDAO + */ + public PublicationDAO getPublicationDAO() { + return _publicationDAO; + } + + /** + * Set the publicationDAO. + * @param publicationDAO the publicationDAO to set + */ + public void setPublicationDAO(final PublicationDAO publicationDAO) { + _publicationDAO = publicationDAO; + } + + /** + * Get the repositoryService. + * @return the repositoryService + */ + public RepositoryService getRepositoryService() { + return _repositoryService; + } + + /** + * Set the repositoryService. + * @param repositoryService the repositoryService to set + */ + public void setRepositoryService(final RepositoryService repositoryService) { + _repositoryService = repositoryService; + } + + /** + * Get the documentDAO. + * @return the documentDAO + */ + public DocumentDAO getDocumentDAO() { + return _documentDAO; + } + + /** + * Set the documentDAO. + * @param documentDAO the documentDAO to set + */ + public void setDocumentDAO(final DocumentDAO documentDAO) { + _documentDAO = documentDAO; + } + + /** + * Get the descriptionAttributeDAO. + * @return the descriptionAttributeDAO + */ + public DescriptionAttributeDAO getDescriptionAttributeDAO() { + return _descriptionAttributeDAO; + } + + /** + * Set the descriptionAttributeDAO. + * @param descriptionAttributeDAO the descriptionAttributeDAO to set + */ + public void setDescriptionAttributeDAO( + final DescriptionAttributeDAO descriptionAttributeDAO) { + _descriptionAttributeDAO = descriptionAttributeDAO; + } + } diff --git a/Workspace/Siman-Common/src/spring/businessServiceContext.xml b/Workspace/Siman-Common/src/spring/businessServiceContext.xml index 1999046..2a1874f 100644 --- a/Workspace/Siman-Common/src/spring/businessServiceContext.xml +++ b/Workspace/Siman-Common/src/spring/businessServiceContext.xml @@ -153,6 +153,7 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> + diff --git a/Workspace/Siman-Common/src/test/splat/service/TestStepService.java b/Workspace/Siman-Common/src/test/splat/service/TestStepService.java index 92329d5..f0e0bf8 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestStepService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestStepService.java @@ -23,16 +23,13 @@ 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.File; -import org.splat.dal.bo.som.ProgressState; 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.SimulationContext; import org.splat.dal.bo.som.StepCommentAttribute; 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.Visibility; import org.splat.dal.dao.kernel.UserDAO; import org.splat.dal.dao.som.Database; import org.splat.dal.dao.som.FileDAO; @@ -60,6 +57,7 @@ import org.testng.Assert; import org.testng.annotations.Test; import test.splat.common.BaseTest; +import test.splat.util.TestEntitiesGenerator; /** * Test class for StepService. @@ -665,6 +663,7 @@ public class TestStepService extends BaseTest { return pub; } + /** * Test of addition of a new step comment. * @@ -673,9 +672,9 @@ public class TestStepService extends BaseTest { @Test public void testAddStepComment() throws BusinessException{ - User goodUser = getTestUser("goodUser"); + User goodUser = TestEntitiesGenerator.getTestUser("goodUser"); _userDAO.create(goodUser); - Study goodStudy = getTestStudy(goodUser); + Study goodStudy = TestEntitiesGenerator.getTestStudy(goodUser); _studyDAO.create(goodStudy); getHibernateTemplate().flush(); StepCommentDTO goodStepCommentDTO = createStepCommentDTO(goodUser, goodStudy); @@ -693,7 +692,7 @@ public class TestStepService extends BaseTest { //valid DTO, non-existing user { //get a non-existing id - User badUser = getTestUser("badUser"); + User badUser = TestEntitiesGenerator.getTestUser("badUser"); _userDAO.create(badUser); getHibernateTemplate().evict(badUser);//so createStepCommentDTO will invoke an //actual query to the base, not cache in order to check if the user already exists @@ -712,7 +711,7 @@ public class TestStepService extends BaseTest { //valid DTO, non-existing project element { - Study badStudy = getTestStudy(goodUser); + Study badStudy = TestEntitiesGenerator.getTestStudy(goodUser); _studyDAO.create(badStudy); getHibernateTemplate().evict(badStudy);//so createStepCommentDTO will invoke an //actual query to the base, not cache in order to check if the study already exists @@ -751,9 +750,9 @@ public class TestStepService extends BaseTest { @Test public void testGetStepComments() throws BusinessException { - User user = getTestUser("goodUser"); + User user = TestEntitiesGenerator.getTestUser("goodUser"); _userDAO.create(user); - Study study = getTestStudy(user); + Study study = TestEntitiesGenerator.getTestStudy(user); //Before we create the study in the database: org.splat.som.Step step = new org.splat.som.Step(_projectSettings.getStep(1), study); @@ -801,49 +800,6 @@ public class TestStepService extends BaseTest { new Integer(0), new Date(), user.getRid(), user.getName(), "Good comment title"); } - /** - * Create a transient user. - * - * @param userName the userName - * @return a transient StepCommentDTO - * @throws BusinessException if something's wrong - */ - private User getTestUser(final String userName) throws BusinessException { - - User.Properties uprop = new User.Properties(); - uprop.setUsername(userName) - .setName("TST_Username") - .setFirstName("TST_FirstName") - .setDisplayName("TST_test.user") - .setMailAddress("noreply@salome-platform.org") - .addRole("TST-User"); - uprop.disableCheck(); - User user = new User(uprop); - return user; - } - - /** - * Create a transient study. - * - * @param user the user that will be placed in 'manager' and 'actor' properties - * @return the test study - * @throws BusinessException if something's wrong - */ - private Study getTestStudy(final User user) throws BusinessException{ - Study.Properties studyProps = new Study.Properties(); - studyProps.setActor(user) - .setManager(user) - .setTitle("a test study") - .setDescription("description") - .setDate(new Date()) - .setReference("test reference") - .setSimulationContexts(new ArrayList()) - .setState(ProgressState.inWORK) - .setVisibility(Visibility.PUBLIC); - Study study = new Study(studyProps); - return study; - } - /** * Create StepCommentDTO with all the fields filled in from StepCommentAttribute. * @param comment the comment diff --git a/Workspace/Siman-Common/src/test/splat/service/TestStudyService.java b/Workspace/Siman-Common/src/test/splat/service/TestStudyService.java index 915f54b..565cfea 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestStudyService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestStudyService.java @@ -17,15 +17,19 @@ import java.util.List; 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; +import org.splat.exception.BusinessException; +import org.splat.exception.InvalidParameterException; import org.splat.kernel.InvalidPropertyException; import org.splat.kernel.MissedPropertyException; import org.splat.kernel.MultiplyDefinedException; @@ -43,6 +47,7 @@ import org.testng.Assert; import org.testng.annotations.Test; import test.splat.common.BaseTest; +import test.splat.util.TestEntitiesGenerator; /** * Test class for StudyService. @@ -99,6 +104,13 @@ public class TestStudyService extends BaseTest { @Autowired @Qualifier("studyService") private transient StudyService _studyService; + + /** + * The UserDAO. Later injected by Spring. + */ + @Autowired + @Qualifier("userDAO") + private transient UserDAO _userDAO; /** * Create a persistent scenario for tests. @@ -397,4 +409,107 @@ public class TestStudyService extends BaseTest { rollbackNestedTransaction(); LOG.debug(">>>>> END testGenerateLocalIndex()"); } + + /** + * Test of retrieval of a study description. + * + * @throws BusinessException if there is something wrong likely unrelated to the tested method + */ + @Test + public void testGetDescription() throws BusinessException { + LOG.debug(">>>>> BEGIN testGetDescription()"); + startNestedTransaction(); + + User user = TestEntitiesGenerator.getTestUser("GoodUser"); + _userDAO.create(user); + Study study = TestEntitiesGenerator.getTestStudy(user); + _studyDAO.create(study); + _studyDAO.flush(); + Long studyId = Long.valueOf(study.getIndex()); + + //Empty description: + Assert.assertNull(_studyService.getDescription(studyId), + "returned value for study without description must be null"); + + //Not empty description: + study.setAttribute(new DescriptionAttribute(study, "description")); + _studyDAO.update(study); + _studyDAO.flush(); + Assert.assertEquals("description", _studyService.getDescription(studyId)); + + //null id + try { + _studyService.getDescription(null); + Assert.fail("retrieval with null study id must fail"); + } catch(InvalidParameterException e){ + LOG.debug("Expected exception is thrown: " + + e.getClass().getSimpleName() + ": " + e.getMessage()); + } + + //Non-existing id + Study tmpStudy = TestEntitiesGenerator.getTestStudy(user); + _studyDAO.create(tmpStudy); + Long nonExistingId = tmpStudy.getIndex(); + _studyDAO.delete(tmpStudy); + try { + _studyService.getDescription(nonExistingId); + Assert.fail("retrieval with non-existing study id must fail"); + } catch(InvalidParameterException e){ + LOG.debug("Expected exception is thrown: " + + e.getClass().getSimpleName() + ": " + e.getMessage()); + } + + rollbackNestedTransaction(); + LOG.debug(">>>>> END testGetDescription()"); + } + + /** + * Test of setting of a study description. + * + * @throws BusinessException if there is something wrong likely unrelated to the tested method + */ + @Test + public void testSetDescription() throws BusinessException { + LOG.debug(">>>>> BEGIN testSetDescription()"); + startNestedTransaction(); + + User user = TestEntitiesGenerator.getTestUser("GoodUser"); + _userDAO.create(user); + Study study = TestEntitiesGenerator.getTestStudy(user); + _studyDAO.create(study); + _studyDAO.flush(); + Long studyId = Long.valueOf(study.getIndex()); + + //Setting description for study without any + _studyService.setDescription(studyId, "description"); + + //Resetting description + _studyService.setDescription(studyId, "replaced description"); + + //null id + try { + _studyService.setDescription(null, "description"); + Assert.fail("setting with null study id must fail"); + } catch(InvalidParameterException e){ + LOG.debug("Expected exception is thrown: " + + e.getClass().getSimpleName() + ": " + e.getMessage()); + } + + //Non-existing id + Study tmpStudy = TestEntitiesGenerator.getTestStudy(user); + _studyDAO.create(tmpStudy); + Long nonExistingId = tmpStudy.getIndex(); + _studyDAO.delete(tmpStudy); + + try { + _studyService.setDescription(nonExistingId, "description"); + Assert.fail("retrieval with non-existing study id must fail"); + } catch(InvalidParameterException e){ + LOG.debug("Expected exception is thrown: " + + e.getClass().getSimpleName() + ": " + e.getMessage()); + } + + rollbackNestedTransaction(); + LOG.debug(">>>>> END testSetDescription()"); + } } diff --git a/Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java b/Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java new file mode 100644 index 0000000..d43b932 --- /dev/null +++ b/Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java @@ -0,0 +1,69 @@ +/***************************************************************************** + * Company EURIWARE + * Application SIMAN + * File $Id$ + * Creation date Feb 12, 2013 + * @author $Author$ + * @version $Revision$ + *****************************************************************************/ + +package test.splat.util; + +import java.util.ArrayList; +import java.util.Date; + +import org.splat.dal.bo.kernel.User; +import org.splat.dal.bo.som.ProgressState; +import org.splat.dal.bo.som.SimulationContext; +import org.splat.dal.bo.som.Study; +import org.splat.dal.bo.som.Visibility; +import org.splat.exception.BusinessException; + +/** + * Utility class for creating test entities. + */ +public class TestEntitiesGenerator { + + /** + * Create a transient user. + * + * @param userName the userName + * @return a transient StepCommentDTO + * @throws BusinessException if something's wrong + */ + public static User getTestUser(final String userName) throws BusinessException { + + User.Properties uprop = new User.Properties(); + uprop.setUsername(userName) + .setName("TST_Username") + .setFirstName("TST_FirstName") + .setDisplayName("TST_test.user") + .setMailAddress("noreply@salome-platform.org") + .addRole("TST-User"); + uprop.disableCheck(); + User user = new User(uprop); + return user; + } + + /** + * Create a transient study. + * + * @param user the user that will be placed in 'manager' and 'actor' properties + * @return the test study + * @throws BusinessException if something's wrong + */ + public static Study getTestStudy(final User user) throws BusinessException{ + Study.Properties studyProps = new Study.Properties(); + studyProps.setActor(user) + .setManager(user) + .setTitle("a test study") + //.setDescription("description") + .setDate(new Date()) + .setReference("test reference") + .setSimulationContexts(new ArrayList()) + .setState(ProgressState.inWORK) + .setVisibility(Visibility.PUBLIC); + Study study = new Study(studyProps); + return study; + } +} diff --git a/Workspace/Siman/WebContent/WEB-INF/tiles/tiles-defs.xml b/Workspace/Siman/WebContent/WEB-INF/tiles/tiles-defs.xml index 319ce10..435051c 100644 --- a/Workspace/Siman/WebContent/WEB-INF/tiles/tiles-defs.xml +++ b/Workspace/Siman/WebContent/WEB-INF/tiles/tiles-defs.xml @@ -69,8 +69,15 @@ + + + + + + + diff --git a/Workspace/Siman/WebContent/jsp/descriptionPane.jsp b/Workspace/Siman/WebContent/jsp/descriptionPane.jsp new file mode 100644 index 0000000..a14d1f0 --- /dev/null +++ b/Workspace/Siman/WebContent/jsp/descriptionPane.jsp @@ -0,0 +1,70 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> +<%@ taglib prefix="s" uri="/struts-tags"%> +<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%> + +
+ +
+ + + + +
+ + + + + +
+ " onMouseOver=this.src="" + onMouseOut=this.src="" title=""/> +  
+
+ + +
\ No newline at end of file diff --git a/Workspace/Siman/WebContent/jsp/readDescription.jsp b/Workspace/Siman/WebContent/jsp/readDescription.jsp index 48f3d98..14c32db 100644 --- a/Workspace/Siman/WebContent/jsp/readDescription.jsp +++ b/Workspace/Siman/WebContent/jsp/readDescription.jsp @@ -1,27 +1,4 @@ <%@ page language="java" contentType="text/html; charset=ISO-8859-1" - pageEncoding="ISO-8859-1" -%> -<%@ taglib prefix="s" uri="/struts-tags" -%> -<%@ page import="org.splat.simer.AbstractOpenObject"%> -<% -// On the contrary of Struts tags, the Java implementation allows the HTML contents of knowledge values to be displayed - String entitype = request.getParameter("entity"); // Study or Knowledge element - AbstractOpenObject object = (AbstractOpenObject)session.getAttribute(entitype + ".open"); - String description = object.getDisplayedDescription(); -%> - -<% if (description != null) { -%> - - -<% } -%> - - - - - -
<%=description%>
- " border="none" title="" /> -
\ No newline at end of file + pageEncoding="ISO-8859-1"%> +<%@ taglib prefix="s" uri="/struts-tags"%> + \ No newline at end of file diff --git a/Workspace/Siman/WebContent/study/displayStudyStep.jsp b/Workspace/Siman/WebContent/study/displayStudyStep.jsp index 7803b46..6cc1f8f 100644 --- a/Workspace/Siman/WebContent/study/displayStudyStep.jsp +++ b/Workspace/Siman/WebContent/study/displayStudyStep.jsp @@ -118,9 +118,7 @@
- - - +
diff --git a/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java b/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java index f8523e1..4474f20 100644 --- a/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java +++ b/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java @@ -45,6 +45,11 @@ public class DisplayStudyStepAction extends AbstractDisplayAction { * Injected Step Service. */ private StepService _stepService; + + /** + * Study description. + */ + private String _descriptionValue; // ============================================================================================================================== // Action methods @@ -102,6 +107,7 @@ public class DisplayStudyStepAction extends AbstractDisplayAction { setMenu(); } loadComments(); + loadDescription(); return res; } @@ -198,6 +204,34 @@ public class DisplayStudyStepAction extends AbstractDisplayAction { } } + /** + * Loads description (if already loaded - reloads). + */ + public void loadDescription() { + try { + _descriptionValue = _studyService.getDescription(_openStudy.getIndex()); + } catch(InvalidParameterException exception) { + _descriptionValue = null; + LOG.debug("Error while trying to add description: " + exception.getMessage()); + } + } + + /** + * Sets study description. + * @return SUCCESS if succeeded, INPUT otherwise. + */ + public String doSetDescription() { + String res = INPUT; + try { + _studyService.setDescription(_openStudy.getIndex(), _descriptionValue); + res = SUCCESS; + } catch(InvalidParameterException exception) { + LOG.debug("Error while trying to add description: " + exception.getMessage()); + } + loadDescription(); + return res; + } + // ============================================================================================================================== // Getters // ============================================================================================================================== @@ -300,4 +334,20 @@ public class DisplayStudyStepAction extends AbstractDisplayAction { public void setStepService(final StepService stepService) { _stepService = stepService; } + + /** + * Get the descriptionValue. + * @return the descriptionValue + */ + public String getDescriptionValue() { + return _descriptionValue; + } + + /** + * Set the descriptionValue. + * @param descriptionValue the descriptionValue to set + */ + public void setDescriptionValue(final String descriptionValue) { + _descriptionValue = descriptionValue; + } } \ No newline at end of file diff --git a/Workspace/Siman/src/struts.xml b/Workspace/Siman/src/struts.xml index 4dadb4c..b822679 100644 --- a/Workspace/Siman/src/struts.xml +++ b/Workspace/Siman/src/struts.xml @@ -403,6 +403,12 @@ page.editscenarioproperties + + + zone.description + + -- 2.39.2