From 3d099281ea994f738da1b3622a3199b1122dc58e Mon Sep 17 00:00:00 2001 From: mka Date: Wed, 16 Jan 2013 07:50:20 +0000 Subject: [PATCH] "Mark as reference" and "Remove as reference" functionality is implemented. --- .../src/org/splat/dal/bo/kernel/Role.java | 9 +- .../src/org/splat/dal/bo/som/Study.hbm.xml | 3 + .../src/org/splat/dal/bo/som/Study.java | 24 ++++ .../src/org/splat/service/StudyService.java | 19 ++- .../org/splat/service/StudyServiceImpl.java | 28 ++++ .../src/org/splat/som/StudyRights.java | 24 ++++ .../Siman/WebContent/skin/icon.TEMPLATE.png | Bin 660 -> 672 bytes .../Siman/WebContent/skin/icon.edTEMPLATE.png | Bin 0 -> 672 bytes Workspace/Siman/src/labels.properties | 5 +- Workspace/Siman/src/labels_en.properties | 5 +- .../org/splat/simer/ApplicationSettings.java | 121 +++++++++++++++++- .../src/org/splat/simer/EditStudyAction.java | 56 ++++++++ .../Siman/src/org/splat/simer/OpenStudy.java | 12 +- .../Siman/src/spring/applicationContext.xml | 1 + Workspace/Siman/src/struts.xml | 21 +++ 15 files changed, 312 insertions(+), 16 deletions(-) create mode 100644 Workspace/Siman/WebContent/skin/icon.edTEMPLATE.png diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Role.java b/Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Role.java index 512e59a..c796bd2 100644 --- a/Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Role.java +++ b/Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Role.java @@ -25,7 +25,7 @@ public class Role { protected Role () { } // Initialization constructor - protected Role (String username, String role) { + protected Role (final String username, final String role) { // --------------------------------------------- this.username = username; this.role = role; @@ -35,7 +35,7 @@ public class Role { // Protected member functions // ============================================================================================================================== - protected void addRole (String role) { + protected void addRole (final String role) { // ------------------------------------ this.role = this.role + "," + role; } @@ -59,13 +59,14 @@ public class Role { return role; } - public boolean is (String name) { + public boolean is (final String name) { // ------------------------------- return this.role.equals(name); } - public boolean isSame (Role other) { + public boolean isSame (final Role other) { // ---------------------------------- return this.role.equals(other.role); } + } \ No newline at end of file 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 43d7a93..27f2d9c 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 @@ -42,6 +42,9 @@ + + + diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.java b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.java index b052879..f9d4ec4 100644 --- a/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.java +++ b/Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.java @@ -58,6 +58,11 @@ public class Study extends ProjectElement { * Persistent history property. It is a number of studies versioning this one, if any. */ private int history; + + /** + * Persistent property. Flag: marked the given study as reference or not. + */ + private int markreference; // Transient fields /** @@ -220,6 +225,7 @@ public class Study extends ProjectElement { // - Global validity check + @Override public void checkValidity() throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException { if (title == null) { @@ -264,6 +270,7 @@ public class Study extends ProjectElement { // RKV scenarii = new LinkedList(); visibility = Visibility.PRIVATE; state = ProgressState.inWORK; + markreference = 0; credate = sprop.date; // Inherited attribute if (credate == null) { @@ -449,4 +456,21 @@ public class Study extends ProjectElement { public Study getOwnerStudy() { return this; } + + /** + * Get the markreference. + * @return the markreference + */ + public int getMarkreference() { + return markreference; + } + + /** + * Set the markreference. + * @param markreference the markreference to set + */ + public void setMarkreference(final int markreference) { + this.markreference = markreference; + } + } \ No newline at end of file diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyService.java b/Workspace/Siman-Common/src/org/splat/service/StudyService.java index 9ba7225..051154e 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyService.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyService.java @@ -16,8 +16,8 @@ import org.splat.dal.bo.som.DocumentType; import org.splat.dal.bo.som.Publication; import org.splat.dal.bo.som.SimulationContext; import org.splat.dal.bo.som.Study; -import org.splat.dal.bo.som.ValidationCycle; import org.splat.dal.bo.som.Study.Properties; +import org.splat.dal.bo.som.ValidationCycle; import org.splat.kernel.InvalidPropertyException; import org.splat.kernel.MissedPropertyException; import org.splat.kernel.MultiplyDefinedException; @@ -250,4 +250,21 @@ public interface StudyService { * @return the unmodifiable not null transient list of contributors of this study */ List getContributors(Study aStudy); + + /** + * Mark study as reference. + * + * @param aStudy - the Study + * @return true if operation is success + */ + void markStudyAsReference(Study aStudy); + + /** + * Remove study as reference. + * This operation is inverse one to Mark as reference. + * + * @param aStudy - the Study + * @return true if operation is success + */ + void removeStudyAsReference(Study aStudy); } diff --git a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java index 3b2e9a3..b8edad5 100644 --- a/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java @@ -978,6 +978,34 @@ public class StudyServiceImpl implements StudyService { aStudy.getActor().add(((ActorRelation) link).getTo()); } } + + /** + * + * {@inheritDoc} + * @see org.splat.service.StudyService#markStudyAsReference(org.splat.dal.bo.som.Study) + */ + @Override + @Transactional + public void markStudyAsReference (final Study aStudy) { + + aStudy.setMarkreference(1); + aStudy.setProgressState(ProgressState.TEMPLATE); + getStudyDAO().update(aStudy); + } + + /** + * + * {@inheritDoc} + * @see org.splat.service.StudyService#removeStudyAsReference(org.splat.dal.bo.som.Study) + */ + @Override + @Transactional + public void removeStudyAsReference(final Study aStudy) { + + aStudy.setMarkreference(0); + aStudy.setProgressState(ProgressState.APPROVED); + getStudyDAO().update(aStudy); + } /** * Get project settings. diff --git a/Workspace/Siman-Common/src/org/splat/som/StudyRights.java b/Workspace/Siman-Common/src/org/splat/som/StudyRights.java index 7a724e1..617330f 100644 --- a/Workspace/Siman-Common/src/org/splat/som/StudyRights.java +++ b/Workspace/Siman-Common/src/org/splat/som/StudyRights.java @@ -100,6 +100,30 @@ public class StudyRights { } return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user); } + + /** + * Can the given study be marked as reference or not. + * @return true/false. + */ + public boolean canMarkStudyAsReference() { + + if (_operand.getProgressState() == ProgressState.APPROVED /*&& "knowledgineer".equals(_user.getRole().getName())*/) { + return true; + } + return false; + } + + /** + * Can the given study be unmarked as reference or not. + * @return true/false. + */ + public boolean canRemoveStudyAsReference() { + + if (_operand.getProgressState() == ProgressState.TEMPLATE /*&& "knowledgineer".equals(_user.getRole().getName())*/) { + return true; + } + return false; + } // ============================================================================================================================== // Getter diff --git a/Workspace/Siman/WebContent/skin/icon.TEMPLATE.png b/Workspace/Siman/WebContent/skin/icon.TEMPLATE.png index 893952784458f8a9e3976fcddeb90975bd737473..de8178d4471f83b85b946693ffca983e2b278cfc 100644 GIT binary patch delta 649 zcmV;40(SkB1)v3xBYyw{XF*Lt00000izQ%900074Nkl7_d4ey z5PnX&sIi5~5)lc4@IqKuUi6}75QElD7hQ*51YutG7j$J4Bq*p0DfPmEp}mJUqJ&Es zMz!{<$r#Rj+3$35=Ge>wU(R!$=llI0&ck^G|F0Gx0Zt63DSrfjo6mro0+K+smMjj% zLxg+ohcCwc=g)Ot~|JVV{m|`<2IYSWj1%c%3fx3r_AQgK9Bm_NK1z$FWAYK zxozN$4zzH#=YK`VwL50um_?y1Yv57XS4duN1z=+3H&*j0er=>L;AX}QAVGKBZwD;0 zdmiWlvvRmr)lXX?aa zG7V;>=Td^DVvS-hgKemUr6XQ_<;dkTz*ZbgU7d@$jE3u`$fi}%XF!92Sol_d`}^^{xg3{3c>4r^G8RG@9Ty>kX#INVlvy@H{BZ zPQks~m?^BG%0+?CPchU1OkMIPWuDFmfvXgV}S!@`Go zSO@;F$Pw0P^M>pfY{?l|*K+ZHB;GwaMz)n*z(y&GW6hmhK4S&dLNGBBF!DR|??~Woe+YE;Q z&H&g7kTQU(7tOg0{ijvndSJ%9L=3$c#-SsCB(NxKmMDy`a5^=kVE+0U=snlNp7CUB z455e&Nd$3Fvt7vFg#}>bo>8HvDIi6|4+oQYH{~l95(Y-X;^`JRoFa?FmVZ*C7_`Fa zDpFetly&GdaJ#!$NUUh>(ijFGb=J0>K}{8n#JmfR0ch?z1+3GHTYLQq=({?OOuD3$ z|2I=>d%yEqP~Lm20aX%jPH)kie|%g(;$b9-smY4Xw7s2cJpuT9tes=A6|BW8w(~#5 Wj`%;UF8bd900007_d4ey5PnX&sIi5~5)lc4@IqKuUi6}75QElD z7hQ*51YutG7j$J4Bq*p0DfPmEp}mJUqJ&EsMz!{<$r#Rj+3$35=Ge>wU(R!$=llI0 z&ck^G|F0Gx0Zt63DFlF<&w!f(l0deWEDps(gnRCXFUI}n&vkL4$p^rX{9itNUSxfC zqQv^#DDV)FwFUxs%%zc=iNSulP9Cqfmug$wD3E;i941G`fm?voE0kfbJh*#faDb-c zHk-R;Hg~` zt~f;@z&0S<95Mi~bX;A4sa46jt7q!OVloY8rRP$DrDBa@E`x2Tgry^1edWmIGr(3H zOkJIexr~PErpTsM(Puz|fmrxffBXCI;8(S((a$uvZb}1^OpleYb@i?W1NVlvy@H{BZPQks~(); - _popups.put("steditable", new EditableStudyPopup()); + _popups.put("steditablemark", new EditableMarkedStudyPopup()); + _popups.put("steditableunmark", new EditableUnmarkedStudyPopup()); _popups.put("editable", new EditableDocumentPopup()); _popups.put("notresult", new NotResultDocumentPopup()); _popups.put("reviewable", new ReviewableDocumentPopup()); diff --git a/Workspace/Siman/src/org/splat/simer/EditStudyAction.java b/Workspace/Siman/src/org/splat/simer/EditStudyAction.java index bf4804c..230f042 100644 --- a/Workspace/Siman/src/org/splat/simer/EditStudyAction.java +++ b/Workspace/Siman/src/org/splat/simer/EditStudyAction.java @@ -1,6 +1,7 @@ package org.splat.simer; import org.splat.dal.bo.som.Study; +import org.splat.service.StudyService; public class EditStudyAction extends DisplayStudyStepAction { @@ -8,6 +9,11 @@ public class EditStudyAction extends DisplayStudyStepAction { * Serial version ID. */ private static final long serialVersionUID = -4865668290514118396L; + + /** + * Injected study service. + */ + private StudyService _studyService; private enum Execute { publish, promote @@ -34,4 +40,54 @@ public class EditStudyAction extends DisplayStudyStepAction { return SUCCESS; } + + /** + * Mark study as reference functionality. + * @return SUCCESS + */ + public String doMarkAsReference() { + + _openStudy = getOpenStudy(); + Study study = _openStudy.getStudyObject(); + + _studyService.markStudyAsReference(study); + + return SUCCESS; + } + + /** + * Remove study as reference functionality. + * @return SUCCESS + */ + public String doRemoveAsReference() { + + _openStudy = getOpenStudy(); + Study study = _openStudy.getStudyObject(); + + _studyService.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/OpenStudy.java b/Workspace/Siman/src/org/splat/simer/OpenStudy.java index 8fc62e9..c70d3b1 100644 --- a/Workspace/Siman/src/org/splat/simer/OpenStudy.java +++ b/Workspace/Siman/src/org/splat/simer/OpenStudy.java @@ -134,8 +134,14 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { // ProgressState state = mystudy.getProgressState(); // if (state == ProgressState.inCHECK) popup = getApplicationSettings().getPopupMenu("stapprovable"); // else if (state == ProgressState.APPROVED) popup = getApplicationSettings().getPopupMenu("stapproved"); - /* else */_popup = getApplicationSettings().getPopupMenu( - "steditable"); + /* else */ + if (_mystudy.getProgressState() == ProgressState.TEMPLATE) { + _popup = getApplicationSettings().getPopupMenu( + "steditableunmark"); + } else { + _popup = getApplicationSettings().getPopupMenu( + "steditablemark"); + } _popup.setContext("study", new StudyRights(_cuser, _mystudy)); } _urightstudy = new StudyRights(_cuser, _mystudy); @@ -387,7 +393,7 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { _cuser = user; _popup = null; if (getStudyService().isStaffedBy(_mystudy, _cuser)) { - _popup = getApplicationSettings().getPopupMenu("steditable"); + _popup = getApplicationSettings().getPopupMenu("steditablemark"); _popup.setContext("study", new StudyRights(_cuser, _mystudy)); } // ustep = getProjectElementService().getFirstStep(mystudy); diff --git a/Workspace/Siman/src/spring/applicationContext.xml b/Workspace/Siman/src/spring/applicationContext.xml index ade8fa1..fff1dff 100644 --- a/Workspace/Siman/src/spring/applicationContext.xml +++ b/Workspace/Siman/src/spring/applicationContext.xml @@ -165,6 +165,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + + + + + input,back,cancel,browse + + + @@ -183,6 +190,7 @@ + open-study?selection=0.1 @@ -319,6 +327,19 @@ page.displaystudy + + + page.displaystudy + + + + + page.displaystudy + + + -- 2.39.2