// Protected services
// ==============================================================================================================================
- protected boolean removeAttribute (Attribute field) {
+ public boolean removeAttribute (Attribute field) {
for (Iterator<Attribute> i=getAttributes().iterator(); i.hasNext(); ) {
if (!i.next().equals(field)) continue;
i.remove();
* @param exception the exception which originated the message
* @param message the message
*/
- public void debug(final String message, final Exception exception) {
+ public void debug(final String message, final Throwable exception) {
_logger.debug(message, exception);
}
/**
* Step service interface.
- *
+ *
* @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
public interface StepService {
/**
* Create a new document published in the given study step.
- *
+ *
* @param aStep
* the target study step
* @param dprop
/**
* Publish an existing document in the given study step.
- *
+ *
* @param aStep
* the target study step
* @param dprop
/**
* Create a new version of a document in the given study step.
- *
+ *
* @param aStep
* the study step
* @param base
/**
* Add simulation context to the study step.
- *
+ *
* @param aStep
* the study step
* @param dprop
/**
* Add simulation context to the study step.
- *
+ *
* @param firstStep
* the study step
* @param context
/**
* Remove a simulation context from the study step.
- *
+ *
* @param aStep
* the study step
* @param context
/**
* Add a document publication to the given step.
- *
+ *
* @param aStep
* the target study step
* @param newdoc
/**
* Remove a document publication from the given step.
- *
+ *
* @param aStep
* the study step
* @param oldoc
/**
* Get document types which are applicable for the given study step (activity).
- *
+ *
* @param aStep
* the study step
* @return the list of document types
* if the owner of the step is not found in the database.
*/
List<StepCommentDTO> getStepComments(final Step step) throws InvalidParameterException;
+
+ /**
+ * Removes the comment with given id from the database.
+ *
+ * @param commentId
+ * the comment id
+ * @throws InvalidParameterException
+ * if the comment is not found in the database.
+ */
+ void removeStepComment(final long commentId) throws InvalidParameterException;
+
+
+ /**
+ * Checks if a given comment was made by a given user.
+ * @param commentId the comment id
+ * @param userId the user id
+ * @return if the comment was made by the user
+ * @throws InvalidParameterException if the comment with such id does not exist.
+ */
+ boolean isCommentMadeByUser(final long commentId, final long userId) throws InvalidParameterException;
+
+
+ /**
+ * Edit value and title of a comment.
+ * If value or title is null - no changes will be applied to this field.
+ * @param commentId the comment id
+ * @param newValue the new comment value
+ * @param newTitle the new comment title
+ * @throws InvalidParameterException if the comment with such id does not exist.
+ */
+ void editStepComment(final long commentId, final String newValue, final String newTitle)
+ throws InvalidParameterException;
}
/**
* Step service implementation.
- *
+ *
* @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
public class StepServiceImpl implements StepService {
* Injected user DAO.
*/
private UserDAO _userDAO;
-
-
+
+
/**
* {@inheritDoc}
- *
+ *
* @see org.splat.service.StepService#addSimulationContext(org.splat.som.Step, org.splat.dal.bo.som.SimulationContext.Properties)
*/
@Override
/**
* {@inheritDoc}
- *
+ *
* @see org.splat.service.StepService#addSimulationContext(org.splat.som.Step, org.splat.dal.bo.som.SimulationContext)
*/
@Override
/**
* Update lucene index of knowledge elements of a scenario or a study which the given step is related to.
- *
+ *
* @param aStep
* the step (activity)
*/
/**
* Update lucene index for knowledge elements of the scenario.
- *
+ *
* @param scene
* the scenario
* @throws IOException
/**
* {@inheritDoc}
- *
+ *
* @see org.splat.service.StepService#removeSimulationContext(org.splat.som.Step, org.splat.dal.bo.som.SimulationContext)
*/
@Override
/**
* {@inheritDoc}
- *
+ *
* @see org.splat.service.StepService#createDocument(org.splat.som.Step, org.splat.dal.bo.som.Document.Properties)
*/
@Override
/**
* {@inheritDoc}
- *
+ *
* @see org.splat.service.StepService#assignDocument(org.splat.som.Step, org.splat.dal.bo.som.Document.Properties)
*/
@Override
/**
* Create a new version of a document in the given study step.
- *
+ *
* @param aStep
* the study step
* @param base
/**
* Create a new version of a document in the given study step.
- *
+ *
* @param aStep
* the study step
* @param base
/**
* Create a new version of a document in the given study step.
- *
+ *
* @param aStep
* the study step
* @param base
/**
* Get document types which are applicable for the given study step (activity).
- *
+ *
* @param aStep
* the study step
* @return the list of document types
/**
* Add a document publication to the given step.
- *
+ *
* @param aStep
* the target study step
* @param newdoc
/**
* Remove a document publication from the given step.
- *
+ *
* @param aStep
* the study step
* @param oldoc
}
}
return res;
+
+
}
-
+
/**
* {@inheritDoc}
*
comment.setId(resultKey);
}
- /**
+ /**
* {@inheritDoc}
* @see org.splat.service.StepService#getStepComments(org.splat.som.Step)
*/
}
return commentDTOs;
}
+
+ /**
+ * {@inheritDoc}
+ * @see org.splat.service.StepService#removeStepComment(long)
+ */
+ @Override
+ @Transactional
+ public void removeStepComment(final long commentId) throws InvalidParameterException {
+ StepCommentAttribute stepComment = _stepCommentAttributeDAO.get(Long.valueOf(commentId));
+ if(stepComment == null) {
+ throw new InvalidParameterException("commentId",String.valueOf(commentId));
+ }
+ _stepCommentAttributeDAO.delete(stepComment);
+ }
+ /**
+ * {@inheritDoc}
+ * @see org.splat.service.StepService#editStepComment(long, java.lang.String, java.lang.String)
+ */
+ @Override
+ @Transactional
+ public void editStepComment(final long commentId, final String newValue, final String newTitle)
+ throws InvalidParameterException {
+ StepCommentAttribute comment = _stepCommentAttributeDAO.get(Long.valueOf(commentId));
+ if(comment == null) {
+ throw new InvalidParameterException("commentId",String.valueOf(commentId));
+ }
+ if(newTitle != null) {
+ comment.setTitle(newTitle);
+ }
+ if(newValue != null) {
+ comment.setValue(newValue);
+ }
+ _stepCommentAttributeDAO.update(comment);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.splat.service.StepService#isCommentMadeByUser(long, long)
+ */
+ @Override
+ @Transactional(readOnly = true)
+ public boolean isCommentMadeByUser(final long commentId, final long userId)
+ throws InvalidParameterException {
+ StepCommentAttribute comment = _stepCommentAttributeDAO.get(Long.valueOf(commentId));
+ if(comment == null) {
+ throw new InvalidParameterException("commentId", String.valueOf(commentId));
+ }
+ return comment.getUser().getIndex() == userId;
+ }
+
/**
* Get the documentService.
- *
+ *
* @return the documentService
*/
public DocumentService getDocumentService() {
/**
* Set the documentService.
- *
+ *
* @param documentService
* the documentService to set
*/
/**
* Get the simulationContextService.
- *
+ *
* @return the simulationContextService
*/
public SimulationContextService getSimulationContextService() {
/**
* Set the simulationContextService.
- *
+ *
* @param simulationContextService
* the simulationContextService to set
*/
/**
* Get the documentDAO.
- *
+ *
* @return the documentDAO
*/
public DocumentDAO getDocumentDAO() {
/**
* Set the documentDAO.
- *
+ *
* @param documentDAO
* the documentDAO to set
*/
/**
* Get the simulationContextDAO.
- *
+ *
* @return the simulationContextDAO
*/
public SimulationContextDAO getSimulationContextDAO() {
/**
* Set the simulationContextDAO.
- *
+ *
* @param simulationContextDAO
* the simulationContextDAO to set
*/
/**
* Get the projectElementDAO.
- *
+ *
* @return the projectElementDAO
*/
public ProjectElementDAO getProjectElementDAO() {
/**
* Set the projectElementDAO.
- *
+ *
* @param projectElementDAO
* the projectElementDAO to set
*/
/**
* Get the indexService.
- *
+ *
* @return the indexService
*/
public IndexService getIndexService() {
/**
* Set the indexService.
- *
+ *
* @param indexService
* the indexService to set
*/
/**
* Get the fileDAO.
- *
+ *
* @return the fileDAO
*/
public FileDAO getFileDAO() {
/**
* Set the fileDAO.
- *
+ *
* @param fileDAO
* the fileDAO to set
*/
/**
* Get the documentTypeService.
- *
+ *
* @return the documentTypeService
*/
public DocumentTypeService getDocumentTypeService() {
/**
* Set the documentTypeService.
- *
+ *
* @param documentTypeService
* the documentTypeService to set
*/
/**
* Get the versionsRelationDAO.
- *
+ *
* @return the versionsRelationDAO
*/
public VersionsRelationDAO getVersionsRelationDAO() {
/**
* Set the versionsRelationDAO.
- *
+ *
* @param versionsRelationDAO
* the versionsRelationDAO to set
*/
/**
* Get project settings.
- *
+ *
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
return _projectSettings;
}
-
+
/**
* Set project settings service.
- *
+ *
* @param projectSettingsService
* project settings service
*/
final ProjectSettingsService projectSettingsService) {
_projectSettings = projectSettingsService;
}
-
+
/**
* Get the stepCommentAttributeDAO.
* @return the stepCommentAttributeDAO
public void setUserDAO(final UserDAO userDAO) {
_userDAO = userDAO;
}
-
+
/**
* Get the publicationDAO.
*
package org.splat.service;
+import java.util.Date;
import java.util.List;
import org.splat.dal.bo.kernel.User;
*/
void setDescription(Long studyId, String descriptionText) throws InvalidParameterException;
+ /**
+ * Remove a description attached to a study.
+ *
+ * @param studyId the study id
+ * @throws InvalidParameterException
+ * if no study with such Id has been found in the database.
+ * @return true if succeeded, false if study doesn't have a description.
+ */
+ boolean removeDescription(final Long studyId) throws InvalidParameterException;
}
import org.splat.som.Revision;
import org.springframework.transaction.annotation.Transactional;
+
/**
* This class defines all methods for creation, modification the study.
*
* Injected user service.
*/
private UserService _userService;
-
+
/**
* Injected publication DAO.
*/
*
* @see org.splat.service.StudyService#selectStudy(long)
*/
+ @Override
@Transactional
public Study selectStudy(final long index) {
Study result = getStudyDAO().get(index);
*
* @see org.splat.service.StudyService#createStudy(org.splat.dal.bo.som.Study.Properties)
*/
+ @Override
@Transactional
public Study createStudy(final Study.Properties sprop)
throws MissedPropertyException, InvalidPropertyException,
*
* @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext.Properties)
*/
+ @Override
@Transactional
public SimulationContext addProjectContext(final Study aStudy,
final SimulationContext.Properties cprop)
*
* @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext)
*/
+ @Override
@Transactional
public SimulationContext addProjectContext(final Study aStudy,
final SimulationContext context) {
*
* @see org.splat.service.StudyService#addContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User)
*/
+ @Override
public boolean addContributor(final Study aStudy, final User user) {
List<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
for (Iterator<User> i = contributor.iterator(); i.hasNext();) {
* @see #isPublic()
* @see Publication#approve(Date)
*/
+ @Override
public boolean moveToReference(final Study aStudy) {
if (aStudy.getProgressState() != ProgressState.APPROVED) {
return false;
*
* @see org.splat.service.StudyService#update(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.Study.Properties)
*/
+ @Override
public boolean update(final Study aStudy, final Properties sprop)
throws InvalidPropertyException {
if (sprop.getTitle() != null) {
*
* @see org.splat.service.StudyService#removeContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User[])
*/
+ @Override
public boolean removeContributor(final Study aStudy, final User... users) {
List<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
Boolean done = false;
*
* @see org.splat.service.StudyService#removeProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext)
*/
+ @Override
public boolean removeProjectContext(final Study aStudy,
final SimulationContext context) {
boolean done = getStepService().removeSimulationContext(
* @see org.splat.service.StudyService#setValidationCycle(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.DocumentType,
* org.splat.dal.bo.som.ValidationCycle.Properties)
*/
+ @Override
@Transactional
public void setValidationCycle(final Study aStudyDTO, final DocumentType type,
final ValidationCycle.Properties vprop) {
* a study to demote
* @return true if the demotion succeeded.
*/
+ @Override
public boolean demote(final Study aStudy) {
if (aStudy.getProgressState() == ProgressState.inCHECK) {
aStudy.setProgressState(ProgressState.inDRAFT);
*
* @see org.splat.service.StudyService#generateLocalIndex(org.splat.dal.bo.som.Study)
*/
+ @Override
@Transactional
public int generateLocalIndex(final Study aStudy) {
aStudy.setLastLocalIndex(aStudy.getLastLocalIndex() + 1);
* a study to promote
* @return true if the demotion succeeded.
*/
+ @Override
@Transactional
public boolean promote(final Study aStudy) {
if (aStudy.getProgressState() == ProgressState.inWORK) {
* @return true if the move succeeded.
* @see #isPublic()
*/
+ @Override
@Transactional
public boolean moveToPublic(final Study aStudy) {
boolean isOk = false;
* a study to move
* @return true if the move succeeded.
*/
+ @Override
@Transactional
public boolean moveToPrivate(final Study aStudy) {
boolean isOk = false;
* the study
* @return the unmodifiable not null transient list of contributors of this study
*/
+ @Override
public List<User> getContributors(final Study aStudy) {
if (aStudy.getContributor() == null) {
setShortCuts(aStudy);
* the document type being subject of validation
* @return the validation cycle of the document, or null if not defined.
*/
+ @Override
public ValidationCycle getValidationCycleOf(final Study aStudy,
final DocumentType type) {
if (aStudy.getValidationCycles() == null || aStudy.getValidationCycles().isEmpty()) {
* @return true if the given user is actor of this study.
* @see #getActors()
*/
+ @Override
public boolean hasActor(final Study aStudy, final User user) {
if (user == null) {
return false;
* @return true if the given user is actor of this study.
* @see #getContributors()
*/
+ @Override
public boolean isStaffedBy(final Study aStudy, final User user) {
if (user == null) {
return false;
* @param aStudy
* the study
*/
+ @Override
public void loadWorkflow(final Study aStudy) {
setShortCuts(aStudy);
}
getStudyDAO().merge(aStudy);
}
+
/**
* {@inheritDoc}
* @see org.splat.service.StudyService#getDescription(java.lang.Long)
}
study.setAttribute(new DescriptionAttribute(study, descriptionText));
}
+
+ /**
+ * {@inheritDoc}
+ * @see org.splat.service.StudyService#removeStudyDescription(java.lang.Long)
+ */
+ @Override
+ @Transactional
+ public boolean removeDescription(final Long studyId) throws InvalidParameterException {
+ if(studyId == null) {
+ throw new InvalidParameterException("studyId", String.valueOf(studyId));
+ }
+ Study study = _studyDAO.get(studyId);
+ if(study == null) {
+ throw new InvalidParameterException("studyId", String.valueOf(studyId));
+ }
+ return study.removeAttribute(study.getAttribute(DescriptionAttribute.class));
+ }
/**
* Get project settings.
public void setUserService(final UserService userService) {
_userService = userService;
}
-
+
/**
* Get the publicationDAO.
* @return the publicationDAO
final DescriptionAttributeDAO descriptionAttributeDAO) {
_descriptionAttributeDAO = descriptionAttributeDAO;
}
-
}
public void setTitle(final String title) {
_title = title;
}
+
+ /**
+ * Get the id. Used with this name in menupopup.jsp.
+ * @return the id
+ */
+ public Long getIndex() {
+ return _id;
+ }
}
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.ConvertsRelation;
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.ProjectElement;
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.kernel.UserDAO;
import org.splat.dal.dao.som.Database;
import org.splat.dal.dao.som.FileDAO;
@Autowired
@Qualifier("projectSettings")
private transient ProjectSettingsService _projectSettings;
-
+
/**
* The injected by Spring StepCommentAttributeDAO.
*/
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
+ //actual query to the base, not cache, in order to check if the user already exists
StepCommentDTO aBadDTO = createStepCommentDTO(badUser, goodStudy);
try{
"some of the needed fields of the retrieved comment doesn't match with original.");
}
+ /**
+ * Test of retrieval of all comments corresponding to a step.
+ *
+ * @throws BusinessException if there is something wrong likely unrelated to the tested method
+ */
+ @Test
+ public void testEditStepComments() throws BusinessException {
+ LOG.debug(">>>>> BEGIN testEditStepComments()");
+ startNestedTransaction();
+
+ User goodUser = TestEntitiesGenerator.getTestUser("goodUser");
+ _userDAO.create(goodUser);
+ Study goodStudy = TestEntitiesGenerator.getTestStudy(goodUser);
+ _studyDAO.create(goodStudy);
+ getHibernateTemplate().flush();
+
+ org.splat.som.Step step = new org.splat.som.Step(_projectSettings.getStep(1), goodStudy);
+
+ StepCommentAttribute comment = new StepCommentAttribute(goodStudy, "commentValue",
+ new Date(), Integer.valueOf(step.getNumber()), goodUser, "commentTitle");
+ _stepCommentAttributeDAO.saveOrUpdate(comment);
+
+ getHibernateTemplate().flush();
+
+ //non-existing id
+ StepCommentAttribute tmpComment = new StepCommentAttribute(goodStudy,"tmpCommentValue",
+ new Date(), Integer.valueOf(step.getNumber()), goodUser, "tmpCommentTitle");
+ _stepCommentAttributeDAO.create(tmpComment);
+ long nonExistingId = tmpComment.getIndex();
+ _stepCommentAttributeDAO.delete(tmpComment);
+ //getHibernateTemplate().evict(goodUser);
+
+
+ try{
+ _stepService.editStepComment(nonExistingId, "newValue", "newTitle");
+ getHibernateTemplate().flush();
+ Assert.fail("Creation with non-existing user must be failed.");
+ }
+ catch(InvalidParameterException e){
+ LOG.debug("Expected exception is thrown: "
+ + e.getClass().getSimpleName() + ": " + e.getMessage());
+ }
+
+ //different configurations with valid comment id
+ testEdit(comment, "newValue", null);
+ testEdit(comment, null, "newTitle");
+ testEdit(comment, "veryNewValue", "veryNewTitle");
+
+ rollbackNestedTransaction();
+ LOG.debug(">>>>> END testEditStepComments()");
+ }
+
+ /**
+ * Test of comment editing.
+ * @param comment the comment
+ * @param value the value
+ * @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)
+ throws InvalidParameterException {
+ String oldValue = comment.getValue();
+ String oldTitle = comment.getTitle();
+
+ _stepService.editStepComment(comment.getIndex(), value, title);
+ _stepCommentAttributeDAO.flush();
+ getHibernateTemplate().evict(comment);
+ _stepCommentAttributeDAO.refresh(comment);
+ if(value == null) {
+ Assert.assertEquals(comment.getValue(), oldValue);
+ } else {
+ Assert.assertEquals(comment.getValue(), value);
+ }
+ if(title == null) {
+ Assert.assertEquals(comment.getTitle(), oldTitle);
+ } else {
+ Assert.assertEquals(comment.getTitle(), title);
+ }
+ }
+
+
/**
* Create a transient StepCommentDTO.
*
rollbackNestedTransaction();
LOG.debug(">>>>> END testSetDescription()");
}
+
+ /**
+ * Test of removal of a study description.
+ *
+ * @throws BusinessException if there is something wrong likely unrelated to the tested method
+ */
+ @Test
+ public void testRemoveDescription() throws BusinessException {
+ LOG.debug(">>>>> BEGIN testRemoveDescription()");
+ 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.assertFalse(_studyService.removeDescription(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.assertTrue(_studyService.removeDescription(studyId), "existing description removal must return true");
+
+
+ Assert.assertNull(_studyService.getDescription(studyId), "description hasn't been successfully removed");
+
+ //null id
+ try {
+ _studyService.removeDescription(null);
+ Assert.fail("removal 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.removeDescription(nonExistingId);
+ Assert.fail("removal 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()");
+ }
}
<definition name="zone.description" template="/jsp/readDescription.jsp"/>
-<definition name="page.description" template="/jsp/descriptionPane.jsp">
- <put-attribute name="display_description_pane" value="zone.description" />
-</definition>
+<definition name="page.description" template="/jsp/descriptionPane.jsp"/>
<definition name="zone.displaystudy" template="/study/displayStudyStep.jsp">
<put-attribute name="step_comments_pane" value="page.stepcomments" />
// alert("Executing " + args[0] + " with " + args[1]);
document.perform.launch(args[0], args[1]);
}
+ } else { //javascript function call
+ eval(action);
}
} else {
// Server side execution via a Struts action
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
<div id="display_comments_div">
- <tiles:insertAttribute name="display_comments_pane" ignore="true" />
+ <s:action name="display-comments" namespace="/study" executeResult="true" />
</div>
+
+<!-- edit comment functionality -->
+<form name="edit_comment_form" id="edit_comment_form" action="edit-comment" method="post"
+ style="display: none; position: absolute; background: white;">
+ <input type="hidden" name="commentId" id="commentToEditId" value="0"/>
+ <table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
+ <tr valign="top">
+ <td width="20" height="20" align="center">
+ <img id="cancel_edit_comment_button" src="<s:url value="/skin/icon.undo.png"/>"
+ title="<s:text name="tooltip.cancel"/>" />
+ </td>
+ <td>
+ <input type="text" name="commentTitle" id="commentToEditTitle">
+ <script language='JavaScript'>
+ displayTextEditor('commentToEditValue', '', 650, 150);
+ </script>
+ </td>
+ </tr>
+ </table>
+</form>
+
+<script>
+ $("#edit_comment_form").ajaxForm({
+ target: '#display_comments_div'
+ });
+
+ var commentToEditId;
+ function redrawEditor() {
+ document.getElementById('edit_comment_form').style.top =
+ $('#comment_'+commentToEditId+'_tbody').offset().top+'px';
+ }
+
+ function editComment(commentId) {
+ var comment = document.getElementById('comment_'+commentId+'_tbody');
+ var editor = document.getElementById('edit_comment_form');
+ editor.style.display = 'block';
+
+ document.getElementById('commentToEditId').value = commentId;
+ document.getElementById('commentToEditTitle').value =
+ trim(document.getElementById('comment_'+commentId+'_title').innerHTML);
+ document.getElementById('commentToEditValue').contentDocument.body.innerHTML =
+ trim(document.getElementById('comment_'+commentId+'_body').innerHTML);
+
+ commentToEditId = commentId;
+ redrawEditor();
+ document.onchange = redrawEditor;
+ }
+
+ function hideEditCommentEditor() {
+ document.getElementById('edit_comment_form').style.display = 'none';
+ }
+
+ // Bind the cancel button
+ $("#cancel_edit_comment_button").click(hideEditCommentEditor);
+
+ // Bind the submit event
+ $('#edit_comment_form').on('submit', hideEditCommentEditor);
+</script>
+
+<!-- remove comment functionality -->
+<form name="remove_comment_form" id="remove_comment_form" action="remove-comment" method="post">
+ <input type="hidden" name="commentId" id="commentId" value="<s:property value="openStudy.index"/>"/>
+</form>
+
+<script>
+ function removeComment(commentId) {
+ document.getElementById("commentId").value=commentId;
+ $("#remove_comment_form").ajaxSubmit({
+ target: '#display_comments_div'
+ });
+ }
+</script>
+
+<!-- add comment functionality -->
<s:if test="%{writeAccess == 'true' && stepEnabled == 'true'}">
<script type="text/javascript">
$(document).ready(function(){
$("#comments_form").ajaxForm({
target: '#display_comments_div'
});
+
+ function showCommentEditor(commentTitle, commentBody) {
+ document.getElementById('commentTitle').value=commentTitle;
+ document.getElementById(currentRTE).contentDocument.body.innerHTML=commentBody;
+ document.getElementById('add_comment_button_div').style.display = 'none';
+ document.getElementById('add_comment_div').style.display = 'block';
+ }
+
// Bind the add button
- $("#add_button").click(function() {
- document.getElementById("add_button_div").style.display = 'none';
- document.getElementById("add_comments_div").style.display = 'block';
- });
+ $("#add_comment_button").click(function() {showCommentEditor('','');});
- function hideEditor() {
- document.getElementById("add_button_div").style.display = 'block';
- document.getElementById("add_comments_div").style.display = 'none';
- document.getElementById(currentRTE).contentDocument.body.innerHTML=''; //clean input area
- document.getElementById("commentTitle").value='';
+ function hideCommentEditor() {
+ document.getElementById("add_comment_button_div").style.display = 'block';
+ document.getElementById("add_comment_div").style.display = 'none';
}
// Bind the cancel button
- $("#cancel_button").click(hideEditor);
+ $("#cancel_add_comment_button").click(hideCommentEditor);
- // Bind the submit button
- $('#comments_form').on('submit', hideEditor);
+ // Bind the submit event
+ $('#comments_form').on('submit', hideCommentEditor);
});
</script>
- <div id="add_button_div">
+ <div id="add_comment_button_div">
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
<tr>
<td width="20" height="20" align="center">
- <img id="add_button" src="<s:url value="/skin/icon.add.png"/>" onMouseOver=this.src="<s:url value="/skin/icon.addhot.png"/>"
+ <img id="add_comment_button" src="<s:url value="/skin/icon.add.png"/>" onMouseOver=this.src="<s:url value="/skin/icon.addhot.png"/>"
onMouseOut=this.src="<s:url value="/skin/icon.add.png"/>" title="<s:text name="tooltip.addcomment"/>"/>
</td>
<td> </td>
</tr>
- </table>
+ </table>
</div>
- <div id="add_comments_div" style="display: none;">
+ <div id="add_comment_div" style="display: none;">
<form name="comments_form" id="comments_form" action="create-stepComment" method="post">
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
<tr valign="top">
<td width="20" height="20" align="center">
- <img id="cancel_button" src="<s:url value="/skin/icon.undo.png"/>"
+ <img id="cancel_add_comment_button" src="<s:url value="/skin/icon.undo.png"/>"
title="<s:text name="tooltip.cancel"/>" />
</td>
<td>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
<div id="display_description_div">
- <tiles:insertAttribute name="display_description_pane" ignore="true" />
+ <s:action name="display-description" namespace="/study" executeResult="true" />
</div>
-<s:if test="%{writeAccess == 'true' && stepEnabled == 'true'}">
- <script type="text/javascript">
- $(document).ready(function(){
- $("#description_form").ajaxForm({
- target: '#display_description_div'
- });
-
- // Bind the add button
- $("#set_description_button").click(function() {
- document.getElementById("display_description_div").style.display = 'none';
- document.getElementById("set_description_button_div").style.display = 'none';
- document.getElementById("description_editor_div").style.display = 'block';
- document.getElementById("descriptionValue").contentDocument.body.innerHTML =
- document.getElementById("display_description_div").innerHTML;
- });
-
- function hideDescriptionEditor() {
- document.getElementById("display_description_div").style.display = 'block';
- document.getElementById("set_description_button_div").style.display = 'block';
- document.getElementById("description_editor_div").style.display = 'none';
- document.getElementById('descriptionValue').contentDocument.body.innerHTML = '';
- }
-
- // Bind the cancel button
- $("#cancel_set_description_button").click(hideDescriptionEditor);
-
- // Bind the submit event
- $('#description_form').on('submit', hideDescriptionEditor);
- });
- </script>
-
- <div id="set_description_button_div">
- <table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
- <tr>
- <td width="20" height="20" align="center">
- <img id="set_description_button" src="<s:url value="/skin/icon.add.png"/>" onMouseOver=this.src="<s:url value="/skin/icon.addhot.png"/>"
- onMouseOut=this.src="<s:url value="/skin/icon.add.png"/>" title="<s:text name="tooltip.adddescription"/>"/>
- </td>
- <td> </td>
- </tr>
- </table>
- </div>
-
- <div id="description_editor_div" style="display: none;">
- <form name="description_form" id="description_form" action="set-description" method="post">
- <table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
- <tr valign="top">
- <td width="20" height="20" align="center">
- <img id="cancel_set_description_button" src="<s:url value="/skin/icon.undo.png"/>"
- title="<s:text name="tooltip.cancel"/>" />
- </td>
- <td>
- <script language='JavaScript'>
- displayTextEditor('descriptionValue', '', 300, 150);
- </script>
- </td>
- </tr>
- </table>
- </form>
- </div>
-</s:if>
\ No newline at end of file
+<div id="description_editor_div" style="display: none;">
+ <form name="description_form" id="description_form" action="set-description" method="post">
+ <input type="hidden" name="studyId" value="<s:property value="openStudy.index"/>"/>
+ <table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
+ <tr valign="top">
+ <td width="20" height="20" align="center">
+ <img id="cancel_set_description_button" src="<s:url value="/skin/icon.undo.png"/>"
+ title="<s:text name="tooltip.cancel"/>" />
+ </td>
+ <td>
+ <script language='JavaScript'>
+ displayTextEditor('descriptionValue', '', 300, 120);
+ </script>
+ </td>
+ </tr>
+ </table>
+ </form>
+</div>
\ No newline at end of file
<s:if test="isEnabled()">
<td onMouseOver="this.style.backgroundImage='url(<s:url value="/skin/image.highlighted.png"/>)'" onMouseOut="this.style.backgroundImage='url(<s:url value="/skin/image.white.png"/>)'">
<s:if test="isClientSide()">
- <s:set var="menu" value="%{action}"/>
+ <s:if test="#entitindex!=null">
+ <s:set var="menu" value="%{action.replaceAll('entity_index', #entitindex.toString())}"/>
+ </s:if><s:else>
+ <s:set var="menu" value="%{action}"/>
+ </s:else>
</s:if><s:else>
<s:url id="menu" namespace="/study" action="%{action}">
<s:param name="index" value="%{#entitindex}" />
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"
%>
+
+<script type="text/javascript"> _mouseOverContext = false; </script>
<s:if test="%{comments != null && !comments.isEmpty()}">
<table width="100%" cellpadding="0" cellspacing="5" border="0" class="attribute">
<s:iterator var="current" value="comments">
- <tr>
- <td width="20" height="20" align="center">
- </td>
- <td>
- <s:date name="#current.date" format="dd.MM.yyyy" />, <s:property value="#current.title"/>
- <br><s:property value="#current.text" escapeHtml="false"/>
- <br><s:property value="#current.user.displayName"/>
- </td>
- </tr>
- <tr height="1" bgcolor="#AAAAAA"><td colspan="2"></td></tr>
+ <tbody id="comment_<s:property value='%{id}' />_tbody" >
+ <tr valign="top">
+
+ <!-- Pop-up menu -->
+ <td width="20" height="20" align="center">
+ <s:if test="%{user.index == connectedUser.index}">
+ <div id="popup<s:property value="%{id}"/>"
+ style="position:absolute; display:none; top:0px; left:0px; z-index:10000;"
+ onmouseover="javascript:_mouseOverContext=true;" onmouseout="javascript:_mouseOverContext=false;">
+ <jsp:include page="/jsp/menupopup.jsp" />
+ </div>
+ <s:a href="popup%{id}">
+ <img src="<s:url value="/skin/icon.ed.png"/>" width=14 height=14 border="none" title=""/>
+ </s:a>
+ </s:if>
+ </td>
+
+ <!-- The comment body -->
+ <td>
+ <s:date name="%{date}" format="dd.MM.yyyy" />,
+ <div id="comment_<s:property value="%{id}"/>_title" style="display: inline">
+ <s:property value="%{title}"/>
+ </div>
+ <br/>
+ <div id="comment_<s:property value="%{id}"/>_body" style="display: inline">
+ <s:property value="%{text}" escapeHtml="false"/>
+ </div>
+ <br/>
+ <s:property value="%{user.displayName}"/>
+ </td>
+ </tr>
+ <tr height="1" bgcolor="#AAAAAA"><td colspan="2"></td></tr>
+ </tbody>
</s:iterator>
</table>
</s:if>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
-<s:property value="descriptionValue" escapeHtml="false"/>
\ No newline at end of file
+
+<div id="description_value_div">
+ <s:property value="descriptionValue" escapeHtml="false"/>
+</div>
+
+
+<s:if test="userCanModufyDescription()">
+
+<!-- Set description functionality -->
+ <script type="text/javascript">
+ function showDescriptionEditor() {
+ document.getElementById("descriptionValue").contentDocument.body.innerHTML =
+ document.getElementById("description_value_div").innerHTML;
+ document.getElementById("display_description_div").style.display = 'none';
+ document.getElementById("description_buttons_div").style.display = 'none';
+ document.getElementById("description_editor_div").style.display = 'block';
+ }
+
+ function hideDescriptionEditor() {
+ document.getElementById("display_description_div").style.display = 'block';
+ document.getElementById("description_buttons_div").style.display = 'block';
+ document.getElementById("description_editor_div").style.display = 'none';
+ }
+
+ $(document).ready(function(){
+ $("#description_form").ajaxForm({
+ target: '#display_description_div'
+ });
+
+ // Bind the cancel button
+ $("#cancel_set_description_button").click(hideDescriptionEditor);
+
+ // Bind the submit event
+ $('#description_form').on('submit', hideDescriptionEditor);
+ });
+ </script>
+
+ <div id="description_buttons_div">
+ <table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
+ <tr>
+ <td width="20" height="20" align="center">
+ <s:if test="%{descriptionValue==null}">
+ <img id="add_description_button" src="<s:url value="/skin/icon.add.png"/>"
+ onMouseOver=this.src="<s:url value="/skin/icon.addhot.png"/>"
+ onMouseOut=this.src="<s:url value="/skin/icon.add.png"/>"
+ title="<s:text name="tooltip.adddescription"/>" onClick="showDescriptionEditor()"/>
+ </s:if>
+ <s:else>
+ <div id="popupDescription" style="position:absolute; display:none; top:0px; left:0px; z-index:10000;"
+ onmouseover="javascript:_mouseOverContext=true;" onmouseout="javascript:_mouseOverContext=false;">
+ <jsp:include page="/jsp/menupopup.jsp" />
+ </div>
+ <s:a href="popupDescription">
+ <img src="<s:url value="/skin/icon.ed.png"/>" width=14 height=14 border="none" title=""/>
+ </s:a>
+ </s:else>
+ </td>
+ <td> </td>
+ </tr>
+ </table>
+ </div>
+
+<!-- Remove description functionality -->
+<form name="remove_description_form" id="remove_description_form" action="remove-description" method="post">
+ <input type="hidden" name="studyId" value="<s:property value="openStudy.index"/>"/>
+</form>
+<script>
+ function removeDescription() {
+ $("#remove_description_form").ajaxSubmit({
+ target: '#display_description_div'
+ });
+ }
+</script>
+
+</s:if>
\ No newline at end of file
tooltip.refresh = Actualiser
tooltip.close = Fermer
tooltip.cancel = Abandonner
+tooltip.compare = Compare
tooltip.shared = Document partagé entre plusieurs scénarios
tooltip.versioned = Document modifié dans cette version de l''étude
message.delete.context = Voulez-vous retirer ce contexte de simulation ?
message.delete.document = Voulez-vous supprimer ce document ?
message.delete.knowledge = Voulez-vous supprimer cette connaissance ?
+message.delete.comment = Do you really want to remove this comment ?
+message.delete.description= Do you really want to remove this description ?
message.purge.study = Voulez-vous supprimer l’historique de l’étude ?
message.purge.document = Voulez-vous supprimer l’historique de ce document ?
message.markasreference.study = Do you really want to mark the study as reference ?
tooltip.refresh = Refresh
tooltip.close = Close
tooltip.cancel = Cancel
+tooltip.compare = Compare
tooltip.shared = Document shared by several scenarios
tooltip.versioned = Document modified in this version of the study
message.delete.context = Do you really want to remove this simulation context ?
message.delete.document = Do you really want to remove this document ?
message.delete.knowledge = Do you really want to remove this knowledge ?
+message.delete.comment = Do you really want to remove this comment ?
+message.delete.description= Do you really want to remove this description ?
message.purge.study = Do you really want to remove the history of the study ?
message.purge.document = Do you really want to remove the history of this document ?
message.markasreference.study = Do you really want to mark the study as reference ?
}
}
}
+
+ /**
+ * Pop-up menu for comments.
+ */
+ private static class CommentPopup extends PopupMenu {
+ /**
+ * Default constructor.
+ */
+ private CommentPopup() {
+ super();
+ addItem(MNU_EDIT, new PopupItem(MNU_NAME_EDIT).icon("icon.ed.png")
+ .action("editComment(entity_index)"));
+ addItem(MNU_REMOVE, new PopupItem("menu.remove").icon(IMG_DELETE)
+ .action("removeComment(entity_index)").confirmation("message.delete.comment"));
+ }
+
+ /**
+ * Is enabled.
+ * @param name the entry name
+ * @return true
+ */
+ @Override
+ public boolean isEnabled(final String name) {
+ return true;
+ }
+ }
+
+ /**
+ * Pop-up menu for comments.
+ */
+ private static class DescritptionPopup extends PopupMenu {
+ /**
+ * Default constructor.
+ */
+ private DescritptionPopup() {
+ super();
+ addItem(MNU_EDIT, new PopupItem(MNU_NAME_EDIT).icon("icon.ed.png")
+ .action("showDescriptionEditor()"));
+ addItem(MNU_REMOVE, new PopupItem("menu.remove").icon(IMG_DELETE)
+ .action("removeDescription()")
+ .confirmation("message.delete.description"));
+ }
+
+ /**
+ * Is enable.
+ * @param name the entry name
+ * @return true
+ */
+ @Override
+ public boolean isEnabled(final String name) {
+ return true;
+ }
+ }
// ==============================================================================================================================
// Construction
_popups.put("extern", new ExternPopup());
_popups.put("scontext", new ScontextPopup());
_popups.put("feedbex", new FeedbexPopup());
+ _popups.put("comment", new CommentPopup());
+ _popups.put("description", new DescritptionPopup());
// Default customizable mandatory settings
Map<String, Object> fprop = new HashMap<String, Object>();
import org.splat.dal.bo.som.ProjectElement;
import org.splat.dal.bo.som.Scenario;
-import org.splat.exception.InvalidParameterException;
-import org.splat.service.StepService;
import org.splat.service.StudyService;
-import org.splat.service.dto.StepCommentDTO;
import org.splat.som.StepRights;
import org.splat.wapp.Constants;
import org.splat.wapp.PopupMenu;
/**
* Presents the current open study information.
- *
+ *
* @author Daniel Brunier-Coulin.
- *
+ *
*/
public class DisplayStudyStepAction extends AbstractDisplayAction {
* Injected study service.
*/
private StudyService _studyService;
-
- /**
- * Step comments.
- */
- private List<StepCommentDTO> _comments = null;
-
- /**
- * Injected Step Service.
- */
- private StepService _stepService;
-
- /**
- * Study description.
- */
- private String _descriptionValue;
// ==============================================================================================================================
// Action methods
/**
* Open the selected study.
- *
+ *
* @return SUCCESS if succeeded or ERROR if can't open
*/
public String doOpen() {
setMenu();
}
- loadComments();
- loadDescription();
return res;
}
/**
* Close the currently open study.
- *
+ *
* @return SUCCESS
*/
public String doClose() {
initializationScreenContext("none");
return SUCCESS;
}
-
- /**
- * Loads step comments (if already loaded - reloads).
- */
- public void loadComments() {
- try {
- _comments = _stepService.getStepComments(_openStudy.getSelectedStep());
- } catch(InvalidParameterException exception) {
- _comments = null;
- LOG.debug("Error while trying to add comment: " + exception.getMessage());
- }
- }
-
- /**
- * 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
/**
* Get the studyService.
- *
+ *
* @return the studyService
*/
public StudyService getStudyService() {
/**
* Set the studyService.
- *
+ *
* @param studyService
* the studyService to set
*/
/**
* {@inheritDoc}
- *
+ *
* @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
*/
@Override
super.setOpenStudy(study);
_openStudy = study;
}
-
- /**
- * Get the comments.
- * @return the comments
- */
- public List<StepCommentDTO> getComments() {
- return _comments;
- }
-
- /**
- * Set the comments.
- * @param comments the comments to set
- */
- public void setComments(final List<StepCommentDTO> comments) {
- _comments = comments;
- }
-
- /**
- * Get the stepService.
- * @return the stepService
- */
- public StepService getStepService() {
- return _stepService;
- }
-
- /**
- * Set the stepService.
- * @param stepService the stepService to set
- */
- 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
package org.splat.simer;
import java.util.Date;
+import java.util.List;
+import java.util.ResourceBundle;
import org.splat.exception.InvalidParameterException;
+import org.splat.service.StepService;
import org.splat.service.dto.StepCommentDTO;
+import org.splat.wapp.PopupMenu;
/**
* Step comment creation/modification action.
*
*/
private static final long serialVersionUID = 6467920934724352021L;
+ /**
+ * Step comments.
+ */
+ private List<StepCommentDTO> _comments = null;
+
/**
* The value of the comment.
*/
private String _commentValue;
+ /**
+ * The value of the comment.
+ */
+ private String _commentToEditValue;
+
/**
* The title of the comment.
*/
private String _commentTitle;
+ /**
+ * Step comment id.
+ */
+ private Long _commentId;
+
+ /**
+ * Comment popup menu.
+ */
+ private transient PopupMenu _commentPopup = null;
+
+ /**
+ * Injected Step Service.
+ */
+ private StepService _stepService;
+
// ==============================================================================================================================
// Action methods
// ==============================================================================================================================
+ /**
+ * Display step comments.
+ * @return SUCCESS
+ */
+ public String doDisplayComments() {
+ try {
+ _comments = getStepService().getStepComments(getOpenStudy().getSelectedStep());
+ _commentPopup = getApplicationSettings().getPopupMenu("comment");
+
+ //necessary for sysadmin user (with label.sysadmin displayName)
+ ResourceBundle label = ResourceBundle.getBundle("labels",
+ getApplicationSettings().getCurrentLocale());
+ for(StepCommentDTO comment : _comments) {
+ comment.getUser().setDisplayName(label.getString(
+ comment.getUser().getDisplayName()));
+ }
+ } catch(InvalidParameterException exception) {
+ _comments = null;
+ LOG.debug("Error while trying to load comments: " + exception.getMessage());
+ }
+ return SUCCESS;
+ }
+
/**
* Creation of a new comment.
- * @return SUCCESS if operation succeeded, ERROR if Runtime exception, otherwise INPUT
+ * @return SUCCESS
*/
public String doCreate() {
- String res = INPUT;
if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()
&& _commentValue!=null && _commentValue.length()>0
&& _commentTitle!=null && _commentTitle.length()>0) {
);
try {
getStepService().addStepComment(stepCommentDTO);
- res = SUCCESS;
} catch (InvalidParameterException error) {
LOG.debug("Error while trying to add comment: " + error.getMessage());
- res = INPUT;
}
}
- loadComments();
- return res;
+ doDisplayComments();
+ return SUCCESS;
+ }
+
+ /**
+ * Edit a comment.
+ * @return SUCCESS
+ */
+ public String doEdit() {
+ try {
+ if(_stepService.isCommentMadeByUser(_commentId, getConnectedUser().getIndex())) {
+ getStepService().editStepComment(_commentId, _commentToEditValue, _commentTitle);
+ }
+ } catch(InvalidParameterException error) {
+ LOG.debug("Error while trying to remove comment: " + error.getMessage());
+ }
+ doDisplayComments();
+ return SUCCESS;
+ }
+
+ /**
+ * Removal of a comment.
+ * @return SUCCESS
+ */
+ public String doRemove() {
+ try {
+ if(_stepService.isCommentMadeByUser(_commentId, getConnectedUser().getIndex())) {
+ getStepService().removeStepComment(_commentId);
+ }
+ } catch(InvalidParameterException error) {
+ LOG.debug("Error while trying to remove comment: " + error.getMessage());
+ }
+ doDisplayComments();
+ return SUCCESS;
}
/**
public void setCommentTitle(final String commentTitle) {
_commentTitle = commentTitle;
}
+
+ /**
+ * Get the comments.
+ * @return the comments
+ */
+ public List<StepCommentDTO> getComments() {
+ return _comments;
+ }
+
+ /**
+ * Set the comments.
+ * @param comments the comments to set
+ */
+ public void setComments(final List<StepCommentDTO> comments) {
+ _comments = comments;
+ }
+
+ /**
+ * Get the stepService.
+ * @return the stepService
+ */
+ public StepService getStepService() {
+ return _stepService;
+ }
+
+ /**
+ * Set the stepService.
+ * @param stepService the stepService to set
+ */
+ public void setStepService(final StepService stepService) {
+ _stepService = stepService;
+ }
+
+ /**
+ * Get the commentPopup. Should have this exact name since it is used in menupopup.jsp.
+ * @return the commentPopup
+ */
+ public PopupMenu getPopup() {
+ return _commentPopup;
+ }
+
+ /**
+ * Get the commentId.
+ * @return the commentId
+ */
+ public Long getCommentId() {
+ return _commentId;
+ }
+
+ /**
+ * Set the commentId.
+ * @param commentId the commentId to set
+ */
+ public void setCommentId(final Long commentId) {
+ _commentId = commentId;
+ }
+
+ /**
+ * Get the commentToEditValue.
+ * @return the commentToEditValue
+ */
+ public String getCommentToEditValue() {
+ return _commentToEditValue;
+ }
+
+ /**
+ * Set the commentToEditValue.
+ * @param commentToEditValue the commentToEditValue to set
+ */
+ public void setCommentToEditValue(final String commentToEditValue) {
+ _commentToEditValue = commentToEditValue;
+ }
}
--- /dev/null
+package org.splat.simer;
+
+import org.splat.exception.InvalidParameterException;
+import org.splat.wapp.PopupMenu;
+
+/**
+ * Description creation/modification action.
+ */
+public class EditStudyDescriptionAction extends DisplayStudyStepAction {
+
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 6467920934724352021L;
+
+ /**
+ * Study description.
+ */
+ private String _descriptionValue;
+
+ /**
+ * Description popup menu.
+ */
+ private transient PopupMenu _descriptionPopup = null;
+
+ /**
+ * Study id.
+ */
+ private Long _studyId;
+
+ /**
+ * Loads description (if already loaded - reloads).
+ * @return SUCCESS
+ */
+ public String doDisplayDescription() {
+ try {
+ _descriptionValue = getStudyService().getDescription(getOpenStudy().getIndex());
+ _descriptionPopup = getApplicationSettings().getPopupMenu("description");
+ } catch(InvalidParameterException exception) {
+ _descriptionValue = null;
+ LOG.debug("Error while trying to add description: " + exception.getMessage());
+ }
+ return SUCCESS;
+ }
+
+ /**
+ * Checks if user can set description.
+ * @return true if user can set description
+ */
+ public boolean userCanModufyDescription() {
+ return "true".equals(getWriteAccess())
+ && _openStudy.getStudyRights().canEditDescription();
+ }
+
+ /**
+ * Sets study description.
+ * @return SUCCESS
+ */
+ public String doSetDescription() {
+ try {
+ if (userCanModufyDescription() && _descriptionValue != null && _descriptionValue.length()>0) {
+ getStudyService().setDescription(_studyId, _descriptionValue);
+ }
+ } catch(InvalidParameterException exception) {
+ LOG.debug("Error while trying to add description: " + exception.getMessage());
+ }
+ doDisplayDescription();
+ return SUCCESS;
+ }
+
+ /**
+ * Removes study description.
+ * @return SUCCESS
+ */
+ public String doRemoveDescription() {
+ try {
+ if(userCanModufyDescription()) {
+ getStudyService().removeDescription(_studyId);
+ }
+ } catch(InvalidParameterException exception) {
+ LOG.debug("Error while trying to add description: " + exception.getMessage());
+ }
+ doDisplayDescription();
+ return SUCCESS;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Get the descriptionPopup. Should have this exact name since it is used in menupopup.jsp.
+ * @return the descriptionPopup
+ */
+ public PopupMenu getPopup() {
+ return _descriptionPopup;
+ }
+
+ /**
+ * Get the studyId.
+ * @return the studyId
+ */
+ public Long getStudyId() {
+ return _studyId;
+ }
+
+ /**
+ * Set the studyId.
+ * @param studyId the studyId to set
+ */
+ public void setStudyId(final Long studyId) {
+ _studyId = studyId;
+ }
+}
*/
else {
- Exception exc = (Exception) obj;
+ Throwable exc = (Throwable) obj;
StringBuffer msg = new StringBuffer();
if (exc.getMessage() != null) {
msg.append(exc.getMessage());
this._message = e.getMessage();
Throwable cause = e.getCause();
if (null != cause) {
- LOG.errorMsg(cause.getMessage(), (Exception) cause);
+ LOG.errorMsg(cause.getMessage(), cause);
this._message = cause.getMessage();
}
}
class="org.splat.simer.DisplayStudyStepAction" parent="baseAction"
scope="prototype">
<property name="studyService" ref="studyService" />
- <property name="stepService" ref="stepService" />
</bean>
<!--========= Inherited from displayStudyStepAction ========= -->
<bean id="editStepCommentAction"
class="org.splat.simer.EditStepCommentAction" scope="prototype"
parent="displayStudyStepAction">
+ <property name="stepService" ref="stepService" />
+ </bean>
+
+ <bean id="editStudyDescriptionAction"
+ class="org.splat.simer.EditStudyDescriptionAction" scope="prototype"
+ parent="displayStudyStepAction">
</bean>
+
<!-- bean id="CompareStudyAction"
class="org.splat.simer.CompareStudyAction" scope="prototype"
parent="displayStudyStepAction">
<bean id="versionDocumentAction"
class="org.splat.simer.VersionDocumentAction" scope="prototype"
parent="baseAction">
- <property name="studyService" ref="studyService" />
<property name="projectSettings" ref="projectSettings" />
<property name="publicationService" ref="publicationService" />
<property name="stepService" ref="stepService" />
page.editscenarioproperties
</result>
</action>
- <action name="set-description"
- class="displayStudyStepAction" method="setDescription">
- <result name="success" type="tiles">
- zone.description
- </result>
- </action>
<!-- Edition of scenario
-->
<!-- Edition of step
-->
+ <action name="display-comments"
+ class="editStepCommentAction" method="displayComments">
+ <result name="success" type="tiles">zone.stepcomments</result>
+ </action>
+
<action name="create-stepComment" class="editStepCommentAction" method="create">
<result name="success" type="tiles">zone.stepcomments</result>
- <result name="input" type="tiles">zone.stepcomments</result>
+ </action>
+
+ <action name="remove-comment" class="editStepCommentAction" method="remove">
+ <result name="success" type="tiles">zone.stepcomments</result>
+ </action>
+ <action name="edit-comment" class="editStepCommentAction" method="edit">
+ <result name="success" type="tiles">zone.stepcomments</result>
+ </action>
+
+ <!-- Edition of study description -->
+ <action name="display-description"
+ class="editStudyDescriptionAction" method="displayDescription">
+ <result name="success" type="tiles">zone.description</result>
+ </action>
+ <action name="set-description"
+ class="editStudyDescriptionAction" method="setDescription">
+ <result name="success" type="tiles">zone.description</result>
+ </action>
+ <action name="remove-description"
+ class="editStudyDescriptionAction" method="removeDescription">
+ <result name="success" type="tiles">zone.description</result>
</action>
<!-- Comparison of studies