From d9ff6416d0b257189f05c7c2f1f7f3ad50b5544b Mon Sep 17 00:00:00 2001 From: rkv Date: Mon, 11 Mar 2013 13:09:33 +0000 Subject: [PATCH] Preliminary version of the "Remove study" action is implemented. --- .../src/org/splat/service/StudyService.java | 8 +++ .../org/splat/service/StudyServiceImpl.java | 12 ++++ .../org/splat/simer/ApplicationSettings.java | 2 +- .../src/org/splat/simer/EditStudyAction.java | 32 +--------- .../org/splat/simer/RemoveStudyAction.java | 64 +++++++++++++++++++ .../Siman/src/spring/applicationContext.xml | 15 +++-- Workspace/Siman/src/struts.xml | 12 ++-- 7 files changed, 105 insertions(+), 40 deletions(-) create mode 100644 Workspace/Siman/src/org/splat/simer/RemoveStudyAction.java diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyService.java b/Workspace/Siman-Common/src/org/splat/service/StudyService.java index ddc4c0f..277ea77 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyService.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyService.java @@ -52,6 +52,14 @@ public interface StudyService { */ Study selectStudy(long index); + /** + * Delete the study. + * + * @param index + * the study id + */ + public void removeStudy(final long index); + /** * Create a new study. * diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java index 7a48fb6..2e3fc45 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java @@ -177,6 +177,18 @@ public class StudyServiceImpl implements StudyService { return result; } + /** + * {@inheritDoc} + * @see org.splat.service.StudyService#removeStudy(long) + */ + @Transactional + public void removeStudy(final long index) { + Study study = getStudyDAO().get(index); + if (study != null) { + getStudyDAO().delete(study); + } + } + /** * Get study by its reference. * diff --git a/Workspace/Siman/src/org/splat/simer/ApplicationSettings.java b/Workspace/Siman/src/org/splat/simer/ApplicationSettings.java index e39cf3d..99fdb59 100644 --- a/Workspace/Siman/src/org/splat/simer/ApplicationSettings.java +++ b/Workspace/Siman/src/org/splat/simer/ApplicationSettings.java @@ -512,7 +512,7 @@ public class ApplicationSettings { * addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE) .confirmation("message.purge.study")); addItem("export", new * PopupItem("menu.export") .icon("image.export.png")); // For future needs */addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE).icon( - IMG_DELETE).action(ACT_NOT_YET_IMPLEMENTED).confirmation( + IMG_DELETE).action("remove-study").confirmation( "message.delete.study")); } diff --git a/Workspace/Siman/src/org/splat/simer/EditStudyAction.java b/Workspace/Siman/src/org/splat/simer/EditStudyAction.java index afff22e..928ba6e 100644 --- a/Workspace/Siman/src/org/splat/simer/EditStudyAction.java +++ b/Workspace/Siman/src/org/splat/simer/EditStudyAction.java @@ -1,7 +1,6 @@ package org.splat.simer; import org.splat.dal.bo.som.Study; -import org.splat.service.StudyService; public class EditStudyAction extends DisplayStudyStepAction { @@ -9,11 +8,6 @@ public class EditStudyAction extends DisplayStudyStepAction { * Serial version ID. */ private static final long serialVersionUID = -4865668290514118396L; - - /** - * Injected study service. - */ - private StudyService _studyService; private enum Execute { publish, protect, promote @@ -52,7 +46,7 @@ public class EditStudyAction extends DisplayStudyStepAction { _openStudy = getOpenStudy(); Study study = _openStudy.getStudyObject(); - _studyService.markStudyAsReference(study); + getStudyService().markStudyAsReference(study); return SUCCESS; } @@ -66,30 +60,8 @@ public class EditStudyAction extends DisplayStudyStepAction { _openStudy = getOpenStudy(); Study study = _openStudy.getStudyObject(); - _studyService.removeStudyAsReference(study); + getStudyService().removeStudyAsReference(study); return SUCCESS; } - - /** - * Get the studyService. - * - * @return the studyService - */ - @Override - public StudyService getStudyService() { - return _studyService; - } - - /** - * Set the studyService. - * - * @param studyService - * the studyService to set - */ - @Override - public void setStudyService(final StudyService studyService) { - _studyService = studyService; - } - } \ No newline at end of file diff --git a/Workspace/Siman/src/org/splat/simer/RemoveStudyAction.java b/Workspace/Siman/src/org/splat/simer/RemoveStudyAction.java new file mode 100644 index 0000000..85cf487 --- /dev/null +++ b/Workspace/Siman/src/org/splat/simer/RemoveStudyAction.java @@ -0,0 +1,64 @@ +/***************************************************************************** + * Company OPEN CASCADE + * Application SIMAN + * File $Id$ + * Creation date 11.03.2013 + * @author $Author$ + * @version $Revision$ + * @copyright OPEN CASCADE 2012 + *****************************************************************************/ + +package org.splat.simer; + +import org.splat.service.StudyService; + +/** + * The action for removing a study. + * + * @author Roman Kozlov (RKV) + */ +public class RemoveStudyAction extends Action { + /** + * Serialization version UID. + */ + private static final long serialVersionUID = -6914581042309013794L; + /** + * Injected study service. + */ + private StudyService _studyService; + + /** + * Remove the selected study. + * + * @return SUCCESS + */ + public String doRemove() { + OpenStudy openStudy = getOpenStudy(); + if (openStudy != null && openStudy.isOpenForWriting()) { + long id = openStudy.getIndex(); + getStudyService().removeStudy(id); + } + closeStudy(); + initializationScreenContext("none"); + return SUCCESS; + } + + /** + * Get the studyService. + * + * @return the studyService + */ + public StudyService getStudyService() { + return _studyService; + } + + /** + * Set the studyService. + * + * @param studyService + * the studyService to set + */ + public void setStudyService(final StudyService studyService) { + _studyService = studyService; + } +} diff --git a/Workspace/Siman/src/spring/applicationContext.xml b/Workspace/Siman/src/spring/applicationContext.xml index 643374c..a7ce2df 100644 --- a/Workspace/Siman/src/spring/applicationContext.xml +++ b/Workspace/Siman/src/spring/applicationContext.xml @@ -156,6 +156,11 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + + + + - - - - + + + @@ -292,6 +296,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + diff --git a/Workspace/Siman/src/struts.xml b/Workspace/Siman/src/struts.xml index 00271a7..ffebe53 100644 --- a/Workspace/Siman/src/struts.xml +++ b/Workspace/Siman/src/struts.xml @@ -275,10 +275,14 @@ page.displaystudy - - page.home - + + page.home + + + page.home + -- 2.39.2