From: mka Date: Wed, 16 Jan 2013 07:50:20 +0000 (+0000) Subject: "Mark as reference" and "Remove as reference" functionality is implemented. X-Git-Tag: Root_Delivery2_2013_04_22~184 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3d099281ea994f738da1b3622a3199b1122dc58e;p=tools%2Fsiman.git "Mark as reference" and "Remove as reference" functionality is implemented. --- 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 8939527..de8178d 100644 Binary files a/Workspace/Siman/WebContent/skin/icon.TEMPLATE.png and b/Workspace/Siman/WebContent/skin/icon.TEMPLATE.png differ diff --git a/Workspace/Siman/WebContent/skin/icon.edTEMPLATE.png b/Workspace/Siman/WebContent/skin/icon.edTEMPLATE.png new file mode 100644 index 0000000..de8178d Binary files /dev/null and b/Workspace/Siman/WebContent/skin/icon.edTEMPLATE.png differ diff --git a/Workspace/Siman/src/labels.properties b/Workspace/Siman/src/labels.properties index b826000..778d10f 100644 --- a/Workspace/Siman/src/labels.properties +++ b/Workspace/Siman/src/labels.properties @@ -315,4 +315,7 @@ message.error.reference.duplicate = Ce document porte une r message.error.reference.mismatch = Ce document porte une référence différente du document versionné. message.error.format.version = Ce document porte un numéro de version illicite. message.error.format.date = Ce document porte une date illicite ou définie dans un format non supporté. -message.error.version.mismatch = Ce document porte un numéro de version illicite ou incorrect. \ No newline at end of file +message.error.version.mismatch = Ce document porte un numéro de version illicite ou incorrect. + +#Validation errors +message.error.noenteredvalue=The field ''{0}'' must be filled \ No newline at end of file diff --git a/Workspace/Siman/src/labels_en.properties b/Workspace/Siman/src/labels_en.properties index 09111f5..ebb4c74 100644 --- a/Workspace/Siman/src/labels_en.properties +++ b/Workspace/Siman/src/labels_en.properties @@ -316,4 +316,7 @@ message.error.reference.duplicate = The reference of this document is already us message.error.reference.mismatch = The reference of this document does not match the one of the versioned document. message.error.format.version = The revision number of this document is illicit. message.error.format.date = The date of this document is illicit or is defined in an unsupported format. -message.error.version.mismatch = The revision number of this document is illicit or incorrect. \ No newline at end of file +message.error.version.mismatch = The revision number of this document is illicit or incorrect. + +#Validation errors +message.error.noenteredvalue=The field ''{0}'' must be filled \ No newline at end of file diff --git a/Workspace/Siman/src/org/splat/simer/ApplicationSettings.java b/Workspace/Siman/src/org/splat/simer/ApplicationSettings.java index d2bbd28..8c8a672 100644 --- a/Workspace/Siman/src/org/splat/simer/ApplicationSettings.java +++ b/Workspace/Siman/src/org/splat/simer/ApplicationSettings.java @@ -233,10 +233,18 @@ public class ApplicationSettings { * Mark as reference menu item name. */ private static final String MNU_MARK_AS_REFERENCE = "markasreference"; + /** + * Remove as reference menu item name. + */ + private static final String MNU_REMOVE_AS_REFERENCE = "removeasreference"; /** * Mark as reference menu item label key. */ private static final String MNU_NAME_MARK_AS_REFERENCE = "menu.markasreference"; + /** + * Remove as reference menu item label key. + */ + private static final String MNU_NAME_REMOVE_AS_REFERENCE = "menu.removeasreference"; /** * Not yet implemented action name. */ @@ -249,6 +257,14 @@ public class ApplicationSettings { * Version action name. */ private static final String ACT_VERSION = "select-file?nextAction=version"; + /** + * Mark as reference action name. + */ + private static final String ACT_MARK_AS_REFERENCE = "markasref-study"; + /** + * Remove as reference action name. + */ + private static final String ACT_REMOVE_AS_REFERENCE = "removeasref-study"; /** * Siman application server name. @@ -454,14 +470,14 @@ public class ApplicationSettings { }; // Resources relative to studies - private static class EditableStudyPopup extends PopupMenu { + private static class EditableMarkedStudyPopup extends PopupMenu { private transient StudyRights _user = null; - private EditableStudyPopup() { + private EditableMarkedStudyPopup() { super(); - addItem(MNU_MARK_AS_REFERENCE, new PopupItem( - MNU_NAME_MARK_AS_REFERENCE).action(ACT_NOT_YET_IMPLEMENTED) - .confirmation("message.markasreference.study")); + addItem(MNU_MARK_AS_REFERENCE, new PopupItem(MNU_NAME_MARK_AS_REFERENCE) + .action(ACT_MARK_AS_REFERENCE).confirmation( + "message.markasreference.study")); addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PUBLISH).icon( "image.publish.png").action("edit-study?action=publish") .confirmation("message.publish.study")); @@ -513,6 +529,98 @@ public class ApplicationSettings { case purge: res = _user.canPurge(); break; + case markasreference: + res = _user.canMarkStudyAsReference(); + break; + default: + res = false; + } + } + return res; + } + + @Override + public void setContext(final String name, final Object context) { + if (context instanceof StudyRights) { + _user = (StudyRights) context; // Just for optimizing + boolean history = _user.getOperand().isVersioned(); + PopupItem item = this.item(MNU_REMOVE); + if (history) { + item.rename(MNU_NAME_REMOVE); + } else { + item.rename("menu.remove.study"); + } + } + } + } + + // Resources relative to studies + private static class EditableUnmarkedStudyPopup extends PopupMenu { + private transient StudyRights _user = null; + + private EditableUnmarkedStudyPopup() { + super(); + addItem(MNU_MARK_AS_REFERENCE, new PopupItem( + MNU_NAME_REMOVE_AS_REFERENCE).action(ACT_REMOVE_AS_REFERENCE) + .confirmation("message.removeasreference.study")); + addItem(MNU_PUBLISH, + new PopupItem(MNU_NAME_PUBLISH).icon("image.publish.png") + .action("edit-study?action=publish") + .confirmation("message.publish.study")); + /* addItem(MNU_PROMOTE, new PopupItem("menu.archive")); */ + addSeparator(); + addItem(MNU_EDIT, + new PopupItem("menu.properties").icon("icon.ed.png") + .action("../select?menu=properties")); + addSeparator(); + addItem(MNU_SCRIPT, + new PopupItem(MNU_NAME_SCRIPT).action("add-scenario")); + /* + * addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon( IMG_VERSION).action(ACT_NOT_YET_IMPLEMENTED)); + */ + addSeparator(); + /* + * 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("message.delete.study")); + } + + /** + * {@inheritDoc} + * + * @see org.splat.wapp.ContextualMenu#isEnabled(java.lang.String) + */ + @Override + public boolean isEnabled(final String name) { + boolean res = (_user != null); + if (res) { + Item item = Item.valueOf(name); + switch (item) { + case publish: + res = _user.canPublish(); + break; + case edit: + res = _user.canEditProperties(); + break; + case script: + res = _user.canAddScenario(); + break; + case version: + res = _user.canVersion(); + break; + case remove: + res = _user.canRemove(); + break; + case purge: + res = _user.canPurge(); + break; + case markasreference: + res = _user.canRemoveStudyAsReference(); + break; default: res = false; } @@ -940,7 +1048,8 @@ public class ApplicationSettings { _menus.put(menu.getName(), menu); _popups = new HashMap(); - _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 + + +