]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
"Mark as reference" and "Remove as reference" functionality is implemented.
authormka <mka@opencascade.com>
Wed, 16 Jan 2013 07:50:20 +0000 (07:50 +0000)
committermka <mka@opencascade.com>
Wed, 16 Jan 2013 07:50:20 +0000 (07:50 +0000)
15 files changed:
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/Role.java
Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.hbm.xml
Workspace/Siman-Common/src/org/splat/dal/bo/som/Study.java
Workspace/Siman-Common/src/org/splat/service/StudyService.java
Workspace/Siman-Common/src/org/splat/service/StudyServiceImpl.java
Workspace/Siman-Common/src/org/splat/som/StudyRights.java
Workspace/Siman/WebContent/skin/icon.TEMPLATE.png
Workspace/Siman/WebContent/skin/icon.edTEMPLATE.png [new file with mode: 0644]
Workspace/Siman/src/labels.properties
Workspace/Siman/src/labels_en.properties
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/EditStudyAction.java
Workspace/Siman/src/org/splat/simer/OpenStudy.java
Workspace/Siman/src/spring/applicationContext.xml
Workspace/Siman/src/struts.xml

index 512e59aed2db88483d28558f8c72c6c38a026dec..c796bd2456cda63119c0b287b57755326b674c01 100644 (file)
@@ -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
index 43d7a93c06a11dcf4d31209ac68c1788e6bdb5ec..27f2d9caca2dd1cfc17d255d585568793b1bd7ef 100644 (file)
@@ -42,6 +42,9 @@
     
       <!-- int    history              -->    
       <property name="history" column="history" access="field" not-null="true" />
+      
+      <!-- int    mark as reference flag              -->    
+      <property name="markreference" column="markreference" access="field" not-null="true" />
 
   </union-subclass>
 
index b052879ca1774e7ccd8ffc621ad1aad28cf3ee17..f9d4ec424029bee96bc97902e02b48a758c64f3d 100644 (file)
@@ -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<Scenario>();
                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
index 9ba72257473e60635760ff54dcaf42b82dd78b96..051154e6eee0628618a34c0cc4a901becb623fd3 100644 (file)
@@ -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<User> 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);
 }
index 3b2e9a386750698297deaad771ab37ad7d3f41b9..b8edad5cd88185717412cd37cfcc9d22ed05ff5a 100644 (file)
@@ -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.
index 7a724e1d1c007328a3270985e258ecc20dd5c769..617330f8e897d2950c8aa47fdf05c0a0df143fca 100644 (file)
@@ -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
index 893952784458f8a9e3976fcddeb90975bd737473..de8178d4471f83b85b946693ffca983e2b278cfc 100644 (file)
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 (file)
index 0000000..de8178d
Binary files /dev/null and b/Workspace/Siman/WebContent/skin/icon.edTEMPLATE.png differ
index b826000a0f3baa24a6c1c8e7a0adb4f6f8f4200a..778d10f62384b82a80571925bb9e4cb6797cf014 100644 (file)
@@ -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
index 09111f5a4b28a89a087c0f57601f8cdb540084f1..ebb4c74f2c92b28cbdb693def4839f5da8b6ff11 100644 (file)
@@ -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
index d2bbd28cc1032bfd6bf1ec2f613ba229e5a19c00..8c8a6728d651f9077bb91f632779da47199e2f1a 100644 (file)
@@ -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<String, PopupMenu>();
-               _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());
index bf4804c7446927c01dcf18e8b68389050d04d431..230f042d66d6ed588cb9d77c255bb3af5b91e816 100644 (file)
@@ -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
index 8fc62e9dc2c5f5203982051612bfe82cea114f6f..c70d3b1a37827031fded9b8af6751c899e8ff866 100644 (file)
@@ -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);
index ade8fa1a9f1dbbb9ccca041e2644afcf568ac5f9..fff1dff8469c3c24a6d5b011cb590bedb04ff94b 100644 (file)
@@ -165,6 +165,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
        <bean id="editStudyAction" class="org.splat.simer.EditStudyAction"
                scope="prototype" parent="displayStudyStepAction">
+               <property name="studyService" ref="studyService" />
        </bean>
 
        <bean id="editScenarioPropertiesAction"
index cfa3fdcb0e5b934d8e35d8f1dceb22e42ae8cd68..48047c9d5e39a4fd6fdf12c21aa928b489e5e91e 100644 (file)
                        <interceptor name="file-upload"
                                class="org.apache.struts2.interceptor.FileUploadInterceptor">
                        </interceptor>
+                       
+                       <interceptor-stack name="siman-validation">
+                   <interceptor-ref name="validation">
+                    <param name="excludeMethods">input,back,cancel,browse</param>
+                </interceptor-ref>
+                <interceptor-ref name="workflow"/>
+                </interceptor-stack>
 
                        <interceptor-stack name="simanBasicStack">
                                <interceptor-ref name="exception" />
                </action>
                <action name="valid-new" class="newStudyAction"
                        method="create">
+                       <!--interceptor-ref name="siman-validation" /-->
                        <result name="success" type="redirectAction">
                                open-study?selection=0.1
                        </result>
                                page.displaystudy
                        </result>
                </action>
+               <action name="markasref-study" class="editStudyAction"
+                       method="markAsReference">
+                       <result name="success" type="tiles">
+                               page.displaystudy
+                       </result>
+               </action>
+               <action name="removeasref-study" class="editStudyAction"
+                       method="removeAsReference">
+                       <result name="success" type="tiles">
+                               page.displaystudy
+                       </result>
+               </action>
+               
                <action name="add-scenario" class="newScenarioAction"
                        method="initialize">
                        <result name="success" type="tiles">