Salome HOME
Modifications to respect PMD rules.
authorrkv <rkv@opencascade.com>
Thu, 8 Nov 2012 13:02:32 +0000 (13:02 +0000)
committerrkv <rkv@opencascade.com>
Thu, 8 Nov 2012 13:02:32 +0000 (13:02 +0000)
39 files changed:
Workspace/Siman-Common/src/org/splat/dal/bo/kernel/User.java
Workspace/Siman-Common/src/org/splat/kernel/RealmLoginModule.java
Workspace/Siman/WebContent/conf/login.conf
Workspace/Siman/WebContent/jsp/editKnowledge.jsp
Workspace/Siman/WebContent/jsp/readDescription.jsp
Workspace/Siman/WebContent/jsp/readKnowledge.jsp
Workspace/Siman/src/org/splat/simer/AbstractDisplayAction.java [new file with mode: 0644]
Workspace/Siman/src/org/splat/simer/AbstractOpenObject.java [new file with mode: 0644]
Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java [new file with mode: 0644]
Workspace/Siman/src/org/splat/simer/Action.java
Workspace/Siman/src/org/splat/simer/ConnectionAction.java
Workspace/Siman/src/org/splat/simer/DisplayBaseAction.java [deleted file]
Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java
Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java
Workspace/Siman/src/org/splat/simer/DocumentFacade.java
Workspace/Siman/src/org/splat/simer/EditDocumentAction.java
Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java
Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java
Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java
Workspace/Siman/src/org/splat/simer/EditStudyAction.java
Workspace/Siman/src/org/splat/simer/LeftMenuSettings.java
Workspace/Siman/src/org/splat/simer/MenuAction.java
Workspace/Siman/src/org/splat/simer/MenuBarSettings.java
Workspace/Siman/src/org/splat/simer/NewStudyAction.java
Workspace/Siman/src/org/splat/simer/OpenKnowledge.java
Workspace/Siman/src/org/splat/simer/OpenObject.java [deleted file]
Workspace/Siman/src/org/splat/simer/OpenStudy.java
Workspace/Siman/src/org/splat/simer/SearchBaseAction.java [deleted file]
Workspace/Siman/src/org/splat/simer/SearchKnowledgeAction.java
Workspace/Siman/src/org/splat/simer/SearchStudyAction.java
Workspace/Siman/src/org/splat/simer/SimulationContextFacade.java
Workspace/Siman/src/org/splat/simer/StampFacade.java
Workspace/Siman/src/org/splat/simer/StartAction.java
Workspace/Siman/src/org/splat/simer/StudyMenu.java
Workspace/Siman/src/org/splat/simer/StudyPropertiesAction.java
Workspace/Siman/src/org/splat/simer/ValidationFacade.java
Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java
Workspace/Siman/src/org/splat/wapp/Constants.java [new file with mode: 0644]
Workspace/Siman/src/spring/applicationContext.xml

index 41dad3bc452dde7583e8994d83755194baa56fa3..a9b24ea28d58480b4baf8d008c167594249206a4 100644 (file)
@@ -7,7 +7,6 @@ package org.splat.dal.bo.kernel;
 
 import java.security.Principal;
 
-import org.splat.dal.bo.kernel.Persistent;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.kernel.MissedPropertyException;
 import org.splat.kernel.MultiplyDefinedException;
@@ -42,10 +41,11 @@ public class User extends Persistent implements Principal, Name {
 
 //  - Public services
 
-      public void clear () {
+      @Override
+       public void clear () {
         super.clear();
         username = null;
-        password = null;;
+        password = null;
         first    = null;
         last     = null;
         display  = null;
@@ -64,62 +64,84 @@ public class User extends Persistent implements Principal, Name {
          }
 //  - Property setters
          
-      public Properties addRole (String role) throws InvalidPropertyException
+      public Properties addRole (final String role) throws InvalidPropertyException
       {
-        if (role.length() == 0) throw new InvalidPropertyException("role");
+        if (role.length() == 0) {
+                       throw new InvalidPropertyException("role");
+               }
         if (this.role == null) {
           this.role = new Role(username, role);
         } else {
           Role[] curole = this.role.toArray();
-          for (int i=0; i<curole.length; i++) if (curole[i].is(role)) return this;             
+          for (int i=0; i<curole.length; i++) {
+                       if (curole[i].is(role)) {
+                               return this;
+                       }
+               }               
           this.role.addRole(role);
         }
         return this;
       }
-      public Properties setDisplayName (String display) throws InvalidPropertyException
+      public Properties setDisplayName (final String display) throws InvalidPropertyException
       {
-        if (display.length() == 0) throw new InvalidPropertyException("displayname");
+        if (display.length() == 0) {
+                       throw new InvalidPropertyException("displayname");
+               }
         this.display = display;
         return this;
       }
-      public Properties setFirstName (String first) throws InvalidPropertyException
+      public Properties setFirstName (final String first) throws InvalidPropertyException
       {
-        if (first.length() == 0) throw new InvalidPropertyException("firstname");
+        if (first.length() == 0) {
+                       throw new InvalidPropertyException("firstname");
+               }
         this.first = first;
         return this;
       }
-      public Properties setMailAddress (String address) throws InvalidPropertyException
+      public Properties setMailAddress (final String address) throws InvalidPropertyException
       {
        String[] term = address.split("@");     // Must be of the form x@y
-       if (term.length != 2) throw new InvalidPropertyException("address");
+       if (term.length != 2) {
+                       throw new InvalidPropertyException("address");
+               }
        term = term[1].split("\\x2E");          // Must be of the form x@y.z
-       if (term.length != 2) throw new InvalidPropertyException("address");
+       if (term.length != 2) {
+                       throw new InvalidPropertyException("address");
+               }
        this.email = address;
        return this;
       }
-      public Properties setName (String last) throws InvalidPropertyException
+      public Properties setName (final String last) throws InvalidPropertyException
       {
-        if (last.length() == 0) throw new InvalidPropertyException("lastname");
+        if (last.length() == 0) {
+                       throw new InvalidPropertyException("lastname");
+               }
         this.last = last;
         return this;
       }
-      public Properties setOrganizationName (String organization) throws InvalidPropertyException
+      public Properties setOrganizationName (final String organization) throws InvalidPropertyException
       {
-        if (organization.length() == 0) throw new InvalidPropertyException("organization");
+        if (organization.length() == 0) {
+                       throw new InvalidPropertyException("organization");
+               }
         this.organid = organization;
         return this;
       }
-      public Properties setPassword (String password) throws InvalidPropertyException
+      public Properties setPassword (final String password) throws InvalidPropertyException
       {
        if (password != null) {
-          if (password.length() < 1) throw new InvalidPropertyException("password");
+          if (password.length() < 1) {
+                       throw new InvalidPropertyException("password");
+               }
           this.password = String.valueOf(password.hashCode());
        }
        return this;
       }
-      public Properties setUsername (String username) throws InvalidPropertyException
+      public Properties setUsername (final String username) throws InvalidPropertyException
       {
-        if (username.length() == 0) throw new InvalidPropertyException("username");
+        if (username.length() == 0) {
+                       throw new InvalidPropertyException("username");
+               }
         this.username = username;
         return this;
       }
@@ -127,12 +149,22 @@ public class User extends Persistent implements Principal, Name {
       
       public void checkValidity () throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException
       {
-        if (username == null) throw new MissedPropertyException("username");
-        if (first == null)    throw new MissedPropertyException("firstname");
-        if (last == null)     throw new MissedPropertyException("lastname");
-        if (role == null)     throw new MissedPropertyException("role");
-        if (email == null)    throw new MissedPropertyException("email");
+        if (username == null) {
+                       throw new MissedPropertyException("username");
+               }
+        if (first == null) {
+                       throw new MissedPropertyException("firstname");
+               }
+        if (last == null) {
+                       throw new MissedPropertyException("lastname");
+               }
+        if (role == null) {
+                       throw new MissedPropertyException("role");
+               }
+        if (email == null) {
+                       throw new MissedPropertyException("email");
 //TODO: Check if username exists        
+               }
       }
     }
 
@@ -145,7 +177,7 @@ public class User extends Persistent implements Principal, Name {
 //  --------------
        }
 //  Anonymous user supposed not to be saved
-       public User (String name) {
+       public User (final String name) {
 //  -------------------------
          username = null;
          password = null;
@@ -157,7 +189,7 @@ public class User extends Persistent implements Principal, Name {
          organid  = null;
        }
 //  New user
-       public User (Properties uprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
+       public User (final Properties uprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
 //  ------------------------------
          super(uprop);   // Throws one of the above exception if not valid
          this.username = uprop.username;
@@ -174,16 +206,22 @@ public class User extends Persistent implements Principal, Name {
 //  Public member functions
 //  ==============================================================================================================================
 
-    public boolean equals (Object item) {
+    @Override
+       public boolean equals (final Object item) {
 //  -----------------------------------
-      if (item == null) return false;
+      if (item == null) {
+               return false;
+       }
       if (item instanceof String) {
-        return  this.username.equals((String)item);                       // Usernames are unique
+        return  this.username.equals(item);                       // Usernames are unique
       }
       else if (item instanceof User) {
        User given = (User)item;
-       if (isSaved()) return (this.getIndex() ==  given.getIndex());
-       else           return (given.username.equals(this.username));     // Usernames are unique
+       if (isSaved()) {
+                       return (this.getIndex() ==  given.getIndex());
+               } else {
+                       return (given.username.equals(this.username));     // Usernames are unique
+               }
       } else {
        return false;
       }
@@ -191,8 +229,11 @@ public class User extends Persistent implements Principal, Name {
 
     public String getDisplayName () {
 //  -------------------------------
-      if (display == null) return last + " " + first;
-      else                 return display;
+      if (display == null) {
+               return last + " " + first;
+       } else {
+               return display;
+       }
     }
 
     public String getFirstName () {
@@ -230,7 +271,8 @@ public class User extends Persistent implements Principal, Name {
       return username;
     }
 
-    public String toString () {
+    @Override
+       public String toString () {
 //  -------------------------
       return last + " " + first;
     }
index 0a8eeb7f1b97787303577eab4e541fa3c5ee8df7..e9b3ed0b19df3df4cb2991bc6a3fa36941776a32 100644 (file)
@@ -24,42 +24,64 @@ import org.apache.log4j.Logger;
 import org.splat.dal.bo.kernel.User;
 import org.splat.service.ServiceLocatorImpl;
 
+/**
+ * Implementation of login module for SIMAN.
+ */
 public class RealmLoginModule implements LoginModule {
 
-       // Initial state
+       /**
+        * The logger.
+        */
+       private static final Logger LOG = Logger.getLogger(RealmLoginModule.class);
+
+       /**
+        * Initial state.
+        */
        private transient Subject _subject;
        private transient CallbackHandler _callbackHandler;
        // private Map sharedState;
        // private Map options;
 
-       // Authentication status
+       /**
+        * Authentication status.
+        */
        private transient boolean _succeeded = false;
        private transient boolean _commit = false;
 
-       // Principal
+       /**
+        * Principal.
+        */
        private transient User _identity = null;
 
-       private static final Logger LOG = Logger.getLogger(RealmLoginModule.class);
-
        // ==============================================================================================================================
        // Constructor
        // ==============================================================================================================================
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see javax.security.auth.spi.LoginModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler,
+        *      java.util.Map, java.util.Map)
+        */
        public void initialize(final Subject user, final CallbackHandler handler,
                        final Map<String, ?> state, final Map<String, ?> opts) {
-               // --------------------------------------------------------------------------------------------------------
                _subject = user;
                _callbackHandler = handler;
                // sharedState = state;
                // options = opts;
                // debug = "true".equalsIgnoreCase((String)options.get("debug"));
-               //_logger = Logger.getLogger(RealmLoginModule.class);
+               // _logger = Logger.getLogger(RealmLoginModule.class);
        }
 
        // ==============================================================================================================================
        // Public services
        // ==============================================================================================================================
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see javax.security.auth.spi.LoginModule#login()
+        */
        public boolean login() throws LoginException {
                boolean res = false;
                try {
@@ -102,13 +124,19 @@ public class RealmLoginModule implements LoginModule {
                } catch (java.io.IOException ioe) {
                        throw new LoginException(ioe.getMessage()); // RKV: NOPMD: The message is sent into the constructor
                } catch (UnsupportedCallbackException uce) {
-                       throw new LoginException("Error: " + uce.getCallback().toString() // RKV: NOPMD: Stacktrace is printed
+                       throw new LoginException("Error: " // RKV: NOPMD: Stacktrace is printed
+                                       + uce.getCallback().toString()
                                        + " not available to garner authentication information"
                                        + " from the user");
                }
                return res;
        }
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see javax.security.auth.spi.LoginModule#commit()
+        */
        public boolean commit() throws LoginException {
                boolean res = _succeeded;
                if (res) {
@@ -121,19 +149,29 @@ public class RealmLoginModule implements LoginModule {
                return res;
        }
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see javax.security.auth.spi.LoginModule#abort()
+        */
        public boolean abort() throws LoginException {
                boolean res = _succeeded;
                if (res) {
-                       if (_succeeded && !_commit) {
+                       if (_commit) {
+                               logout();
+                       } else {
                                _identity = null;
                                _succeeded = false;
-                       } else {
-                               logout();
                        }
                }
                return res;
        }
 
+       /**
+        * {@inheritDoc}
+        * 
+        * @see javax.security.auth.spi.LoginModule#logout()
+        */
        public boolean logout() throws LoginException {
                _subject.getPrincipals().remove(_identity);
                _identity = null;
index e11cfc50513a33fcf7c51b6fd857800af51fa043..d1bfcd5f46828ee0c87d47e7737227fc653344b0 100644 (file)
@@ -1,3 +1,3 @@
-Simer {
+Siman {
   org.splat.kernel.RealmLoginModule required debug=true;
 };
\ No newline at end of file
index 7e613b883e73ff2d3fcd4a7a1023d36b0fc77f48..2ae4fd4b6da89ebea8c4bdb159f3470b914546b4 100644 (file)
@@ -6,7 +6,7 @@
 <%@ page import="java.util.List"%>
 <%@ page import="java.util.Iterator"%>
 <%@ page import="java.util.ResourceBundle"%>
-<%@ page import="org.splat.simer.OpenObject"%>
+<%@ page import="org.splat.simer.AbstractOpenObject"%>
 <%@ page import="org.splat.simer.OpenStudy"%>
 <%@ page import="org.splat.simer.KnowledgeElementFacade"%>
 <%!
@@ -16,7 +16,7 @@
          Action                             todo       = Action.valueOf(request.getParameter("action"));
     String                             typenumber = request.getParameter("index");
     OpenStudy                          study      = (OpenStudy)session.getAttribute("study.open");
-    List<OpenObject.KnowledgeIterator> knowlist   = study.getDisplayedKnowledges();
+    List<AbstractOpenObject.KnowledgeIterator> knowlist   = study.getDisplayedKnowledges();
     ResourceBundle                     locale     = ResourceBundle.getBundle("som");
 %>
 <s:url id="undo" namespace="/study" action="step-study"></s:url>
@@ -24,8 +24,8 @@
 <table width=100% cellpadding=0 cellspacing=0 border=0 class=text>
   <input type=hidden name=knowledgeType value="<%=typenumber%>"/>
 <%
-    for (Iterator<OpenObject.KnowledgeIterator> knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) {
-      OpenObject.KnowledgeIterator type = knowtypes.next();
+    for (Iterator<AbstractOpenObject.KnowledgeIterator> knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) {
+       AbstractOpenObject.KnowledgeIterator type = knowtypes.next();
 %>
   <tr height=20>
     <td width=38%><%=locale.getString("type.knowledge." + type.getType())%></td>
index a3d98e41679da020d40e0a63aaedea365d68dd0f..48f3d984d01f22b6974b09388bbb65bbcd53aeda 100644 (file)
@@ -3,11 +3,11 @@
 %>
 <%@ taglib prefix="s" uri="/struts-tags"
 %>
-<%@ page import="org.splat.simer.OpenObject"%>
+<%@ page import="org.splat.simer.AbstractOpenObject"%>
 <%
 //  On the contrary of Struts tags, the Java implementation allows the HTML contents of knowledge values to be displayed
     String      entitype    = request.getParameter("entity");   // Study or Knowledge element
-    OpenObject  object      = (OpenObject)session.getAttribute(entitype + ".open");
+    AbstractOpenObject  object      = (AbstractOpenObject)session.getAttribute(entitype + ".open");
     String      description = object.getDisplayedDescription();
 %>
 <table cellpadding=0 cellspacing=0 border=0 class=text>
index d888b8892c449bf606f66e758d1590c6efe61caf..0a74809928d1a3d673fd6c86cdfda462de37045d 100644 (file)
@@ -6,21 +6,21 @@
 <%@ page import="java.util.List"%>
 <%@ page import="java.util.Iterator"%>
 <%@ page import="java.util.ResourceBundle"%>
-<%@ page import="org.splat.simer.OpenObject"%>
+<%@ page import="org.splat.simer.AbstractOpenObject"%>
 <%@ page import="org.splat.simer.OpenKnowledge"%>
 <%@ page import="org.splat.simer.KnowledgeElementFacade"%>
-<%@ page import="org.splat.simer.DisplayBaseAction"%>
+<%@ page import="org.splat.simer.AbstractDisplayAction"%>
 <%@ page import="com.opensymphony.xwork2.ActionContext"%>
 <%@ page import="com.opensymphony.xwork2.util.ValueStack"%>
 <%
 //  Scriptlet implementation is required for displaying HTML contents of knowledge values which does not work with Struts tags
     ValueStack                         stack    = ActionContext.getContext().getValueStack();
     Object                             stacktop = stack.peek();
-    DisplayBaseAction                  action   = (DisplayBaseAction)stacktop;
+    AbstractDisplayAction                  action   = (AbstractDisplayAction)stacktop;
 
     String                             entitype = request.getParameter("entity");             // Study or Knowledge element
-    OpenObject                         object   = (OpenObject)session.getAttribute(entitype + ".open");
-    List<OpenObject.KnowledgeIterator> knowlist = object.getDisplayedKnowledges();
+    AbstractOpenObject                         object   = (AbstractOpenObject)session.getAttribute(entitype + ".open");
+    List<AbstractOpenObject.KnowledgeIterator> knowlist = object.getDisplayedKnowledges();
     ResourceBundle                     locale   = ResourceBundle.getBundle("som");
 %>
 <s:set var="entitype"><%=entitype%></s:set>
@@ -35,8 +35,8 @@
 <table width=100% cellpadding=0 cellspacing=0 border=0 class=text>
 <%
     String  curindex = object.getIndex().toString();
-    for (Iterator<OpenObject.KnowledgeIterator> knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) {
-       OpenObject.KnowledgeIterator type = knowtypes.next();
+    for (Iterator<AbstractOpenObject.KnowledgeIterator> knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) {
+       AbstractOpenObject.KnowledgeIterator type = knowtypes.next();
 %>
   <tr height=20>
     <td width=38%><%=locale.getString("type.knowledge." + type.getType())%></td>
diff --git a/Workspace/Siman/src/org/splat/simer/AbstractDisplayAction.java b/Workspace/Siman/src/org/splat/simer/AbstractDisplayAction.java
new file mode 100644 (file)
index 0000000..15e7559
--- /dev/null
@@ -0,0 +1,50 @@
+package org.splat.simer;
+
+
+public abstract class AbstractDisplayAction extends Action {
+
+    /**
+     * Index of the open object.
+     */
+    protected  transient String _myindex   = null;
+    /**
+     * User activity selection.
+     */
+    protected  String           _selection = null;
+    protected  transient String _action    = null;
+
+       /**
+        * Serial version ID.
+        */
+    private static final long serialVersionUID = 3003902258668626946L;
+
+       protected enum Execute { popup, develop, reduce, reduceall }
+
+//  ==============================================================================================================================
+//  Getters and setters
+//  ==============================================================================================================================
+
+    public String getSelection () {
+//  -----------------------------
+      return _selection;   // Equals to myobject.getSelection()
+    }
+
+    public void setAction (final String action) {
+//  -------------------------------------
+      this._action = action;
+    }
+    public void setIndex (final String index) {
+//  -----------------------------------
+      this._myindex = index;
+    }
+    public void setSelection (final String step) {
+//  --------------------------------------
+      this._selection = step;
+    }    
+
+//  ==============================================================================================================================
+//  Abstract services
+//  ==============================================================================================================================
+
+    public abstract String getWriteAccess ();
+}
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/AbstractOpenObject.java b/Workspace/Siman/src/org/splat/simer/AbstractOpenObject.java
new file mode 100644 (file)
index 0000000..a83ba4c
--- /dev/null
@@ -0,0 +1,441 @@
+package org.splat.simer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.KnowledgeElement;
+import org.splat.dal.bo.som.KnowledgeElementType;
+import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.Publication;
+import org.splat.dal.bo.som.Scenario;
+import org.splat.service.KnowledgeElementTypeService;
+import org.splat.service.ProjectElementService;
+import org.splat.service.PublicationService;
+import org.splat.service.dto.KnowledgeElementDTO;
+import org.splat.service.dto.Proxy;
+import org.splat.service.technical.ProjectSettingsService;
+import org.splat.som.Step;
+import org.splat.util.BeanHelper;
+import org.splat.wapp.Menu;
+import org.splat.wapp.PopupMenu;
+
+/**
+ * Open study or knowledge.
+ */
+public abstract class AbstractOpenObject implements Proxy {
+
+       protected static Map<Long, DocumentFacade> docpres = null;
+       protected static Map<Long, KnowledgeElementFacade> knowpres = null;
+
+       /**
+        * Connected user.
+        */
+       protected transient User _cuser = null;
+       /**
+        * Menu selected by the user.
+        */
+       protected transient String _selection = null;
+       /**
+        * Corresponding selected step.
+        */
+       protected transient Step _ustep = null;
+       /**
+        * Object description (rich text).
+        */
+       protected transient String _description = null;
+       protected transient List<Step> _involving = new ArrayList<Step>();
+       /**
+        * Simulation Context display representations.
+        */
+       protected transient List<SimulationContextFacade> _context = new ArrayList<SimulationContextFacade>();
+       /**
+        * Document display representations.
+        */
+       protected transient List<DocumentFacade> _contents = null;
+       /**
+        * Knowledge Element display representations structured by knowledge types.
+        */
+       protected transient List<KnowledgeIterator> _knowledge = null;
+
+       /**
+        * Left pane menu of this object.
+        */
+       protected Menu _menu = null;
+       /**
+        * Pop-up menu of this object, if the user has write access.
+        */
+       protected transient PopupMenu _popup = null;
+       /**
+        * Injected project settings service.
+        */
+       private ProjectSettingsService _projectSettings;
+       /**
+        * Injected application settings bean.
+        */
+       private ApplicationSettings _applicationSettings;
+       /**
+        * Injected publication service.
+        */
+       private PublicationService _publicationService;
+       /**
+        * Injected knowledge element service.
+        */
+       private KnowledgeElementTypeService _knowledgeElementTypeService;
+       /**
+        * Injected project element service.
+        */
+       private ProjectElementService _projectElementService;
+
+       public class KnowledgeIterator {
+               protected transient KnowledgeElementType _type;
+               protected transient List<KnowledgeElementFacade> _list;
+
+               public KnowledgeIterator(final KnowledgeElementType type,
+                               final List<KnowledgeElementFacade> list) {
+                       this._type = type;
+                       this._list = list;
+               }
+
+               public String getIndex() {
+                       return String.valueOf(_type.getIndex());
+               }
+
+               public String getType() {
+                       return _type.getName();
+               }
+
+               public List<KnowledgeElementFacade> getKnowledgeElements() {
+                       return _list;
+               }
+       }
+
+       // ==============================================================================================================================
+       // Constructor
+       // ==============================================================================================================================
+
+       protected AbstractOpenObject() {
+               // All member fields are supposed initialized by subclasses
+               if (docpres == null) {
+                       docpres = new HashMap<Long, DocumentFacade>();
+               }
+               if (knowpres == null) {
+                       knowpres = new HashMap<Long, KnowledgeElementFacade>();
+               }
+       }
+
+       // ==============================================================================================================================
+       // Public member functions
+       // ==============================================================================================================================
+
+       public void developDocument(final String index) {
+               for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
+                       DocumentFacade doc = i.next();
+                       if (!doc.getIndex().equals(index)) {
+                               continue;
+                       }
+                       doc.develop();
+                       return;
+               }
+       }
+
+       public void developKnowledge(final String index) {
+               for (Iterator<KnowledgeIterator> i = _knowledge.iterator(); i.hasNext();) {
+                       List<KnowledgeElementFacade> knowelms = i.next()
+                                       .getKnowledgeElements();
+                       for (Iterator<KnowledgeElementFacade> j = knowelms.iterator(); j
+                                       .hasNext();) {
+                               KnowledgeElementFacade kelm = j.next();
+                               if (!kelm.getIndex().equals(index)) {
+                                       continue;
+                               }
+                               kelm.develop();
+                               return;
+                       }
+               }
+       }
+
+       public void clearFacades() {
+               docpres.clear(); // For eventually reopening the knowledge from a fresh context
+               knowpres.clear(); // For eventually reopening the knowledge from a fresh context
+       }
+
+       public List<Document> collectInvolvedDocuments(final DocumentType type) {
+               List<Document> found = new ArrayList<Document>();
+               for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
+                       Step step = i.next();
+                       List<Publication> exist = step.getAllDocuments();
+                       for (Iterator<Publication> j = exist.iterator(); j.hasNext();) {
+                               Document doc = j.next().value();
+                               if (doc.getType().equals(type)) {
+                                       found.add(doc);
+                               }
+                       }
+               }
+               return found;
+       }
+
+       public String getDisplayedDescription() {
+               return _description;
+       }
+
+       public List<DocumentFacade> getDisplayedDocuments() {
+               return _contents;
+       }
+
+       public List<SimulationContextFacade> getDisplayedSimulationContexts() {
+               return _context;
+       }
+
+       public List<KnowledgeIterator> getDisplayedKnowledges() {
+               return _knowledge;
+       }
+
+       public List<Step> getInvolvedSteps() {
+               return _involving;
+       }
+
+       public Menu getMenu() {
+               return _menu;
+       }
+
+       public PopupMenu getPopup() {
+               return _popup;
+       }
+
+       public Step getSelectedStep() {
+               return _ustep;
+       }
+
+       public String getSelection() {
+               return _selection;
+       }
+
+       public User getUser() {
+               return _cuser;
+       }
+
+       public boolean isOpenForWriting() {
+               return (_popup != null); // The pop-up is supposed existed when the user is staffed on the study
+       }
+
+       public void reduceDocument(final String index) {
+               for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
+                       DocumentFacade doc = i.next();
+                       if (!doc.getIndex().equals(index)) {
+                               continue;
+                       }
+                       doc.reduceAll();
+                       return;
+               }
+       }
+
+       public void reduceHistory(final String index) {
+               for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
+                       DocumentFacade doc = i.next();
+                       if (!doc.getIndex().equals(index)) {
+                               continue;
+                       }
+                       doc.reduce();
+                       return;
+               }
+       }
+
+       public void reduceKnowledge(final String index) {
+               for (Iterator<KnowledgeIterator> i = _knowledge.iterator(); i.hasNext();) {
+                       List<KnowledgeElementFacade> knowelms = i.next()
+                                       .getKnowledgeElements();
+                       for (Iterator<KnowledgeElementFacade> j = knowelms.iterator(); j
+                                       .hasNext();) {
+                               KnowledgeElementFacade kelm = j.next();
+                               if (!kelm.getIndex().equals(index)) {
+                                       continue;
+                               }
+                               kelm.reduce();
+                               return;
+                       }
+               }
+       }
+
+       // ==============================================================================================================================
+       // Protected services
+       // ==============================================================================================================================
+
+       protected void setupContents() {
+               // Description
+               // Initialized in subclasses
+
+               // Knowledge elements supposed ordered by type
+               if (_ustep.mayContain(KnowledgeElement.class)) {
+                       Scenario scene = (Scenario) _ustep.getOwner();
+                       List<KnowledgeElementType> types = getKnowledgeElementTypeService()
+                                       .selectTypesWhere(ProgressState.APPROVED);
+                       List<KnowledgeElement> kelms = scene.getAllKnowledgeElements();
+                       Iterator<KnowledgeElement> more = kelms.iterator();
+                       KnowledgeElement current = null;
+                       if (more.hasNext()) {
+                               current = more.next();
+                       }
+
+                       _knowledge = new ArrayList<KnowledgeIterator>(types.size());
+                       for (Iterator<KnowledgeElementType> i = types.iterator(); i
+                                       .hasNext();) {
+                               KnowledgeElementType type = i.next();
+                               List<KnowledgeElementFacade> display = new ArrayList<KnowledgeElementFacade>(
+                                               kelms.size());
+                               while (current != null && current.getType().equals(type)) {
+                                       KnowledgeElementFacade facade = knowpres.get(current
+                                                       .getIndex());
+                                       if (facade == null) {
+                                               facade = new KnowledgeElementFacade(BeanHelper
+                                                               .copyBean(current, KnowledgeElementDTO.class));
+                                               knowpres.put(current.getIndex(), facade);
+                                       }
+                                       display.add(facade);
+                                       if (more.hasNext()) {
+                                               current = more.next();
+                                       } else {
+                                               current = null;
+                                       }
+                               }
+                               _knowledge.add(new KnowledgeIterator(type, display));
+                       }
+               } else {
+                       _knowledge = null;
+               }
+               // Documents
+               if (_ustep.mayContain(Document.class)) {
+                       List<Publication> list = _ustep.getAllDocuments();
+
+                       _contents = new ArrayList<DocumentFacade>(list.size());
+                       for (Iterator<Publication> i = list.iterator(); i.hasNext();) {
+                               Publication present = i.next();
+                               Long index = present.getIndex();
+                               DocumentFacade facade = docpres.get(index);
+                               if (facade == null) {
+                                       facade = new DocumentFacade(this, present,
+                                                       getProjectSettings(), getPublicationService());
+                                       docpres.put(index, facade);
+                               }
+                               _contents.add(facade);
+                       }
+               } else {
+                       _contents = null;
+               }
+       }
+
+       /**
+        * Get project settings.
+        * 
+        * @return Project settings service
+        */
+       public ProjectSettingsService getProjectSettings() {
+               return _projectSettings;
+       }
+
+       /**
+        * Get the publicationService.
+        * 
+        * @return the publicationService
+        */
+       public PublicationService getPublicationService() {
+               return _publicationService;
+       }
+
+       /**
+        * Set project settings service.
+        * 
+        * @param projectSettingsService
+        *            project settings service
+        */
+       public void setProjectSettings(
+                       final ProjectSettingsService projectSettingsService) {
+               _projectSettings = projectSettingsService;
+       }
+
+       /**
+        * Set the publicationService.
+        * 
+        * @param publicationService
+        *            the publicationService to set
+        */
+       public void setPublicationService(
+                       final PublicationService publicationService) {
+               _publicationService = publicationService;
+       }
+
+       /**
+        * Set the menu.
+        * 
+        * @param menu
+        *            the menu to set
+        */
+       public void setMenu(final Menu menu) {
+               this._menu = menu;
+       }
+
+       /**
+        * Get the projectElementService.
+        * 
+        * @return the projectElementService
+        */
+       public ProjectElementService getProjectElementService() {
+               return _projectElementService;
+       }
+
+       /**
+        * Set the projectElementService.
+        * 
+        * @param projectElementService
+        *            the projectElementService to set
+        */
+       public void setProjectElementService(
+                       final ProjectElementService projectElementService) {
+               _projectElementService = projectElementService;
+       }
+
+       /**
+        * Get the knowledgeElementTypeService.
+        * 
+        * @return the knowledgeElementTypeService
+        */
+       public KnowledgeElementTypeService getKnowledgeElementTypeService() {
+               return _knowledgeElementTypeService;
+       }
+
+       /**
+        * Set the knowledgeElementTypeService.
+        * 
+        * @param knowledgeElementTypeService
+        *            the knowledgeElementTypeService to set
+        */
+       public void setKnowledgeElementTypeService(
+                       final KnowledgeElementTypeService knowledgeElementTypeService) {
+               _knowledgeElementTypeService = knowledgeElementTypeService;
+       }
+
+       /**
+        * Get the applicationSettings.
+        * 
+        * @return the applicationSettings
+        */
+       public ApplicationSettings getApplicationSettings() {
+               return _applicationSettings;
+       }
+
+       /**
+        * Set the applicationSettings.
+        * 
+        * @param applicationSettings
+        *            the applicationSettings to set
+        */
+       public void setApplicationSettings(
+                       final ApplicationSettings applicationSettings) {
+               _applicationSettings = applicationSettings;
+       }
+}
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java b/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java
new file mode 100644 (file)
index 0000000..f62ade4
--- /dev/null
@@ -0,0 +1,314 @@
+package org.splat.simer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.SimulationContext;
+import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.Name;
+import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
+import org.splat.service.dto.Proxy;
+import org.splat.service.technical.ProjectSettingsService;
+import org.splat.som.ApplicationRights;
+
+public abstract class AbstractSearchBaseAction extends Action {
+
+       /**
+        * Serial version ID.
+        */
+       private static final long serialVersionUID = 7863055790228544510L;
+       
+       /**
+        * Search result key in the session.
+        */
+       public static final String RESULT_KEY = "search.result";
+
+       /**
+        * Context type index, when selected.
+        */
+       protected transient String _ctype = null;
+       /**
+        * Context value index, when selected.
+        */
+       protected transient String _cvalue = null;
+       /**
+        * Context index, when removed.
+        */
+       protected transient String _cindex = "";
+       protected String _author = null;
+       protected List<Name> _candidates = null;
+       /**
+        * Context type to be valued.
+        */
+       protected transient SimulationContextType _newtype;
+       /**
+        * Context value to be selected.
+        */
+       protected transient List<SimulationContext> _newvalue;
+       /**
+        * Addable context types.
+        */
+       protected transient List<SimulationContextType> _critext;
+       /**
+        * Current contexts search criteria.
+        */
+       protected transient List<SimulationContext> _context;
+       protected transient List<Proxy> _result;
+       /**
+        * Injected simulation context service.
+        */
+       private SimulationContextService _simulationContextService;
+
+       /**
+        * Injected user service.
+        */
+       private UserService _userService;
+
+       enum UserAction {
+               refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
+       }
+
+       // ==============================================================================================================================
+       // Action methods
+       // ==============================================================================================================================
+
+       public String doSubmitForm() {
+               // Identification of the user action
+               UserAction action = UserAction.refreshResult;
+               if (_ctype != null && Integer.valueOf(_ctype) > 0) {
+                       action = UserAction.selectContextType;
+               } else if (_cvalue != null && Integer.valueOf(_cvalue) > 0) {
+                       action = UserAction.selectContextValue;
+               } else if (_cindex.length() > 0) {
+                       int index = Integer.valueOf(_cindex);
+                       if (index > 0) {
+                               action = UserAction.removeContext;
+                       } else if (index < 0) {
+                               action = UserAction.cancelSelect;
+                       }
+               }
+               // Execution of the user action
+               String done;
+               try {
+                       saveFilter(); // Also reinitializes the form, if needed
+
+                       if (action == UserAction.selectContextType) {
+                               done = doSelectContextType();
+                       } else if (action == UserAction.selectContextValue) {
+                               done = doAddContext();
+                       } else if (action == UserAction.removeContext) {
+                               done = doRemoveContext();
+                       } else if (action == UserAction.cancelSelect) {
+                               done = doCancel();
+                       } else { // UserAction.refreshResult
+                               done = doSearch();
+                               setContextTypeOptions(getInvolvedContexts()); // Done in other do functions, when required
+                       }
+                       setCandidates();
+               } catch (Exception error) {
+                       // No need to roll back the transaction as it is read only
+                       LOG.error("Reason: ", error);
+                       done = ERROR;
+               }
+               return done;
+       }
+
+       @SuppressWarnings("unchecked")
+       protected String doSelectContextType() {
+               SimulationContext.Properties sprop = new SimulationContext.Properties();
+
+               _newtype = getSimulationContextService().selectType(
+                               Integer.valueOf(_ctype));
+               _newvalue = getSimulationContextService().selectSimulationContextsWhere(
+                               sprop.setType(_newtype));
+               if (_cindex.length() > 0 && Integer.valueOf(_cindex) == 0) {
+                       getSession().remove(RESULT_KEY);
+               } else {
+                       _result = (List<Proxy>) getSession().get(RESULT_KEY); // We keep the previous result search, if valid
+               }
+               return "selectype";
+       }
+
+       protected String doAddContext() {
+               SimulationContext selected = getSimulationContextService()
+                               .selectSimulationContext(Integer.valueOf(_cvalue));
+
+               _context.add(selected);
+               setContextTypeOptions(getInvolvedContexts()); // Sets critext
+               getSession().remove(RESULT_KEY); // The current result is obsolete
+               return "refresh";
+       }
+
+       protected String doRemoveContext() {
+               int index = Integer.valueOf(_cindex);
+               for (Iterator<SimulationContext> selected = _context.iterator(); selected
+                               .hasNext();) {
+                       if (selected.next().getIndex() == index) {
+                               selected.remove();
+                               break;
+                       }
+               }
+               setContextTypeOptions(getInvolvedContexts()); // Sets critext
+               getSession().remove(RESULT_KEY); // The current result is obsolete
+               return "refresh";
+       }
+
+       @SuppressWarnings("unchecked")
+       protected String doCancel() {
+               _result = (List<Proxy>) getSession().get(RESULT_KEY); // Current result search
+               setContextTypeOptions(getInvolvedContexts()); // Sets critext
+               return "refresh";
+       }
+
+       // ==============================================================================================================================
+       // Getters
+       // ==============================================================================================================================
+
+       public String getAuthor() {
+               return _author;
+       }
+
+       public List<Name> getCandidates() {
+               return _candidates;
+       }
+
+       public List<SimulationContextType> getContextTypeOptions() {
+               return _critext;
+       }
+
+       public List<SimulationContext> getContextValueOptions() {
+               return _newvalue;
+       }
+
+       public SimulationContextType getSelectedContextType() {
+               return _newtype;
+       }
+
+       public List<SimulationContext> getSimulationContexts() {
+               return _context;
+       }
+
+       public List<Proxy> getResult() {
+               return _result;
+       }
+
+       // ==============================================================================================================================
+       // Setters
+       // ==============================================================================================================================
+
+       public void setAuthor(final String index) {
+               this._author = index;
+       }
+
+       public void setContextType(final String type) {
+               this._ctype = type;
+       }
+
+       public void setContextValue(final String value) {
+               this._cvalue = value;
+       }
+
+       public void setContextIndex(final String value) {
+               this._cindex = value;
+       }
+
+       protected void setCandidates() {
+               _candidates = new ArrayList<Name>();
+               List<User> users = getUserService().selectAllUsers();
+               User me = getConnectedUser(); // May be null
+               for (Iterator<User> i = users.iterator(); i.hasNext();) {
+                       User next = i.next();
+                       ApplicationRights he = new ApplicationRights(next);
+                       if (he.canCreateStudy()) {
+                               if (next.equals(me)) {
+                                       _candidates.add(0, new ValidationFacade.ByManager(me));
+                               } else {
+                                       _candidates.add(next);
+                               }
+                       }
+               }
+       }
+
+       protected void setContextTypeOptions(final List<SimulationContextType> critext) {
+               for (Iterator<SimulationContext> i = _context.iterator(); i.hasNext();) {
+                       critext.remove(i.next().getType()); // Already used context type
+               }
+               // Ordering by alphabetical order of localized context types
+               SimulationContextType[] types = critext
+                               .toArray(new SimulationContextType[critext.size()]);
+               ContextTypeComparator compare = new ContextTypeComparator();
+               ProjectSettingsService.Step step = getSimulationContextService()
+                               .getAttachedStep(types[0]);
+               int from = 0;
+               int to = 0;
+               while (to < types.length - 1) {
+                       to += 1;
+                       if (types[to].isAttachedTo(step)) {
+                               continue;
+                       }
+
+                       if (to > from + 1) {
+                               Arrays.sort(types, from, to, compare);
+                       }
+                       from = to;
+                       step = getSimulationContextService().getAttachedStep(types[to]);
+               }
+               if (to > from) {
+                       Arrays.sort(types, from, to + 1, compare);
+               }
+               this._critext = Arrays.asList(types);
+       }
+
+       // ==============================================================================================================================
+       // Abstract services
+       // ==============================================================================================================================
+
+       protected abstract String doSearch() throws InvalidPropertyException;
+
+       protected abstract List<SimulationContextType> getInvolvedContexts();
+
+       protected abstract void loadFilter();
+
+       protected abstract void saveFilter();
+
+       /**
+        * Get the simulationContextService.
+        * 
+        * @return the simulationContextService
+        */
+       public SimulationContextService getSimulationContextService() {
+               return _simulationContextService;
+       }
+
+       /**
+        * Set the simulationContextService.
+        * 
+        * @param simulationContextService
+        *            the simulationContextService to set
+        */
+       public void setSimulationContextService(
+                       final SimulationContextService simulationContextService) {
+               _simulationContextService = simulationContextService;
+       }
+
+       /**
+        * Get the userService.
+        * @return the userService
+        */
+       public UserService getUserService() {
+               return _userService;
+       }
+
+       /**
+        * Set the userService.
+        * @param userService the userService to set
+        */
+       public void setUserService(final UserService userService) {
+               _userService = userService;
+       }
+}
\ No newline at end of file
index 47e928dba330fd80edd8b424f1b4949accd9266e..e2446fe69488ac4caa3aa403324e6b4cd81c7d34 100644 (file)
@@ -167,7 +167,7 @@ public class Action extends ActionSupport implements ServletRequestAware,
         * Remove the currently open knowledge from the session.
         */
        protected void closeKnowledge() {
-               OpenObject open = (OpenObject) _session.remove(KNOWLEDGE_OPEN);
+               AbstractOpenObject open = (AbstractOpenObject) _session.remove(KNOWLEDGE_OPEN);
                if ((open != null) && (_session.get(STUDY_OPEN) == null)) {
                        open.clearFacades(); // For eventually reopening the knowledge from a fresh context
                }
@@ -177,7 +177,7 @@ public class Action extends ActionSupport implements ServletRequestAware,
         * Remove the currently open study from the session.
         */
        protected void closeStudy() {
-               OpenObject open = (OpenObject) _session.remove(STUDY_OPEN);
+               AbstractOpenObject open = (AbstractOpenObject) _session.remove(STUDY_OPEN);
                if ((open != null) && (_session.get(KNOWLEDGE_OPEN) == null)) {
                        open.clearFacades(); // For eventually reopening the study from a fresh context
                }
@@ -393,7 +393,7 @@ public class Action extends ActionSupport implements ServletRequestAware,
 
                initializationContext();
 
-               OpenObject entity = (OpenObject) _session.get(titleProperty + ".open");
+               AbstractOpenObject entity = (AbstractOpenObject) _session.get(titleProperty + ".open");
 
                getTitleBarSettings().setProgressState(
                                entity.getProgressState().toString());
index 6f7eab962e6ce2eed6499ec17fd0c02a3cbcabaf..2838c977a68e9bf9b3e289d818c7a83480836c6d 100644 (file)
@@ -1,49 +1,69 @@
 package org.splat.simer;
 
+import java.io.IOException;
 import java.util.Map;
 import java.util.Set;
 
-import javax.security.auth.login.LoginContext;
 import javax.security.auth.Subject;
-import javax.security.auth.callback.*;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.LoginContext;
 
 import org.splat.dal.bo.kernel.User;
 import org.splat.som.ApplicationRights;
 
-import java.io.IOException;
-import javax.security.auth.login.FailedLoginException;
-
+/**
+ * User login action.
+ */
 public class ConnectionAction extends Action {
 
-       private String username = null;
-       private String password = null;
-       private String backmenu = null;
-    
-    private String _menuProperty;
+       /**
+        * User name.
+        */
+       private String _username = null;
+       /**
+        * User password.
+        */
+       private String _password = null;
+       private transient String _backmenu = null;
+
+       private String _menuProperty;
 
        /**
         * Serial version ID.
         */
        private static final long serialVersionUID = 6095471616361606231L;
 
+       /**
+        * Handler for login into SIMAN.
+        */
        private class Handler implements CallbackHandler {
-               // ------------------------------------------------
-               public void handle(Callback[] callbacks) throws IOException,
+               /**
+                * {@inheritDoc}
+                * 
+                * @see javax.security.auth.callback.CallbackHandler#handle(javax.security.auth.callback.Callback[])
+                */
+               public void handle(final Callback[] callbacks) throws IOException,
                                UnsupportedCallbackException {
                        for (int i = 0; i < callbacks.length; i++) {
                                if (callbacks[i] instanceof TextOutputCallback) {
                                        // Display a message according to a specified type
-
+                                       LOG.info(((TextOutputCallback) callbacks[i]).getMessage());
                                } else if (callbacks[i] instanceof NameCallback) {
                                        // Get the username
                                        NameCallback call = (NameCallback) callbacks[i];
-                                       call.setName(username);
+                                       call.setName(_username);
 
                                } else if (callbacks[i] instanceof PasswordCallback) {
                                        // Get the password
-                                       if (password != null) {
+                                       if (_password != null) {
                                                PasswordCallback call = (PasswordCallback) callbacks[i];
-                                               call.setPassword(password.toCharArray());
+                                               call.setPassword(_password.toCharArray());
                                        }
                                } else {
                                        throw new UnsupportedCallbackException(callbacks[i],
@@ -57,55 +77,71 @@ public class ConnectionAction extends Action {
        // Action execution
        // ==============================================================================================================================
 
+       /**
+        * Login the user with the given name and password into SIMAN.
+        * 
+        * @return SUCCESS if succeeded, INPUT - if some mandatory parameter is absent or FailedLoginException is caught during login, ERROR -
+        *         if other exception is caught
+        * 
+        * @see org.splat.kernel.RealmLoginModule
+        */
        @SuppressWarnings("unchecked")
-       public String doLogin() throws Exception {
-               // ------------------------
-               if (username == null || username.length() == 0)
-                       return INPUT;
-               if (password != null && password.length() == 0)
-                       password = null; // User having no password
-               try {
-                       LoginContext context = new LoginContext("Simer", new Handler());
-                       context.login();
-
-                       Subject identity = context.getSubject();
-                       Set<User> table = identity.getPrincipals(User.class);
-                       if (table.isEmpty())
-                               throw new Exception();
-
-                       User user = table.iterator().next(); // The user is (apparently...) the 1st principal
-                       ApplicationRights logged = new ApplicationRights(user);
-                       if (logged.canContributeToStudy() || logged.canValidate()) {
-                               // TODO: Set the search filter according to user preferences
-                               Map<String, Object> session = getSession();
-                               // Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
-                               Map<String, Object> sfilter = (Map<String, Object>) session
-                                               .get("study.filter");
+       public String doLogin() {
+               String res = INPUT;
+               if (_username != null && _username.length() > 0) {
+                       if (_password != null && _password.length() == 0) {
+                               _password = null; // User having no password
+                       }
+                       try {
+                               LoginContext context = new LoginContext("Siman", new Handler());
+                               context.login();
+
+                               Subject identity = context.getSubject();
+                               Set<User> table = identity.getPrincipals(User.class);
+                               if (table.isEmpty()) {
+                                       throw new Exception();
+                               }
 
-                               sfilter.put("state", "ANY");
-                               sfilter.put("visibility", "PRIVATE");
-                               if (logged.canCreateStudy())
-                                       sfilter.put("author", String.valueOf(user.getIndex()));
+                               User user = table.iterator().next(); // The user is (apparently...) the 1st principal
+                               ApplicationRights logged = new ApplicationRights(user);
+                               if (logged.canContributeToStudy() || logged.canValidate()) {
+                                       // TODO: Set the search filter according to user preferences
+                                       Map<String, Object> session = getSession();
+                                       // Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
+                                       Map<String, Object> sfilter = (Map<String, Object>) session
+                                                       .get("study.filter");
+
+                                       sfilter.put("state", "ANY");
+                                       sfilter.put("visibility", "PRIVATE");
+                                       if (logged.canCreateStudy()) {
+                                               sfilter.put("author", String.valueOf(user.getIndex()));
+                                       }
+                               }
+                               this.connect(context, user); // Updates the session context
+
+                               setMenuProperty("none");
+                               initializationScreenContext(_menuProperty);
+
+                               res = _backmenu;
+                       } catch (FailedLoginException error) {
+                               setErrorCode("message.error.login." + error.getMessage());
+                               res = INPUT;
+                       } catch (Exception error) {
+                               LOG.error("Reason:", error);
+                               res = ERROR;
                        }
-                       this.connect(context, user); // Updates the session context
-                       
-                       setMenuProperty("none");
-                       initializationScreenContext(_menuProperty);
-                       
-                       return backmenu;
-               } catch (FailedLoginException error) {
-                       setErrorCode("message.error.login." + error.getMessage());
-                       return INPUT;
-               } catch (Exception error) {
-                       LOG.error("Reason:", error);
-                       return ERROR;
                }
+               return res;
        }
 
-
+       /**
+        * Disconnect the current user from SIMAN application.
+        * 
+        * @return SUCCESS if disconnected, ERROR - if exception is caught
+        */
        @SuppressWarnings("unchecked")
        public String doLogout() {
-               // -------------------------
+               String res;
                try {
                        Map<String, Object> session = getSession();
                        // Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
@@ -117,10 +153,9 @@ public class ConnectionAction extends Action {
                        if (getConnectedUser() != null) {
                                connectedUsr = getConnectedUser().toString();
                        }
-                       
-                       LOG.info("Deconnection of " + connectedUsr
-                                       + ".");
-                       
+
+                       LOG.info("Deconnection of " + connectedUsr + ".");
+
                        if (context != null) {
                                context.logout();
                        }
@@ -132,45 +167,73 @@ public class ConnectionAction extends Action {
                        }
 
                        this.disconnect(); // Updates the session context
-                       
+
                        setMenuProperty("none");
                        initializationScreenContext(_menuProperty);
-                       
-                       return backmenu;
+
+                       res = _backmenu;
                } catch (Exception error) {
                        LOG.error("Reason:", error);
-                       return ERROR;
+                       res = ERROR;
                }
+               return res;
        }
 
-//  ==============================================================================================================================
-//  Getters and setters
-//  ==============================================================================================================================
-       
-    public String getUsername () {
-//  ----------------------------       
-      return username;
-    }
-    public String getPassword () {
-//  ----------------------------
-      return password;
-    }
-
-    public void setUsername (String value) {
-//  --------------------------------------
-      this.username = value;
-    }
-    public void setPassword (String value) {
-//  --------------------------------------
-      this.password = value;
-    }
-    public void setBackMenu (String menu) {
-//  -------------------------------------
-      this.backmenu = menu;
-    }
-    
-    /**
+       // ==============================================================================================================================
+       // Getters and setters
+       // ==============================================================================================================================
+
+       /**
+        * Get user name.
+        * 
+        * @return user name
+        */
+       public String getUsername() {
+               return _username;
+       }
+
+       /**
+        * Get user password.
+        * 
+        * @return user password
+        */
+       public String getPassword() {
+               return _password;
+       }
+
+       /**
+        * Set user name.
+        * 
+        * @param value
+        *            user name
+        */
+       public void setUsername(final String value) {
+               this._username = value;
+       }
+
+       /**
+        * Set user password.
+        * 
+        * @param value
+        *            the password
+        */
+       public void setPassword(final String value) {
+               this._password = value;
+       }
+
+       /**
+        * Set menu for the user.
+        * 
+        * @param menu
+        *            menu key string
+        */
+       public void setBackMenu(final String menu) {
+               this._backmenu = menu;
+       }
+
+       /**
         * Get the menuProperty.
+        * 
         * @return the menuProperty
         */
        public String getMenuProperty() {
@@ -179,9 +242,11 @@ public class ConnectionAction extends Action {
 
        /**
         * Set the menuProperty.
-        * @param menuProperty the menuProperty to set
+        * 
+        * @param menuProperty
+        *            the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
 }
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/DisplayBaseAction.java b/Workspace/Siman/src/org/splat/simer/DisplayBaseAction.java
deleted file mode 100644 (file)
index 58b66ab..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.splat.simer;
-
-
-public abstract class DisplayBaseAction extends Action {
-
-    protected  String          myindex   = null;    // Index of the open object
-    protected  String          selection = null;    // User activity selection
-    protected  String          action    = null;
-
-       /**
-        * Serial version ID.
-        */
-    private static final long serialVersionUID = 3003902258668626946L;
-
-       protected enum Execute { popup, develop, reduce, reduceall }
-
-//  ==============================================================================================================================
-//  Getters and setters
-//  ==============================================================================================================================
-
-    public String getSelection () {
-//  -----------------------------
-      return selection;   // Equals to myobject.getSelection()
-    }
-
-    public void setAction (String action) {
-//  -------------------------------------
-      this.action = action;
-    }
-    public void setIndex (String index) {
-//  -----------------------------------
-      this.myindex = index;
-    }
-    public void setSelection (String step) {
-//  --------------------------------------
-      this.selection = step;
-    }    
-
-//  ==============================================================================================================================
-//  Abstract services
-//  ==============================================================================================================================
-
-    public abstract String getWriteAccess ();
-}
\ No newline at end of file
index 4fbcd3eed2c85c3246ce06442a24516c3afc0ffc..6e7d0324b2c1d70930110fd64d90db14844428ae 100644 (file)
@@ -2,12 +2,12 @@ package org.splat.simer;
 
 import java.util.List;
 
-import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.service.KnowledgeElementService;
 import org.splat.service.dto.KnowledgeElementDTO;
 import org.splat.som.Step;
+import org.splat.wapp.Constants;
 
-public class DisplayKnowledgeAction extends DisplayBaseAction {
+public class DisplayKnowledgeAction extends AbstractDisplayAction {
 
        /**
         * Serial version ID.
@@ -17,7 +17,7 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
        /**
         * Current knowledge element details.
         */
-       protected OpenKnowledge myknelm = null;
+       protected transient OpenKnowledge _myknelm = null;
 
        /**
         * Injected knowledge element service.
@@ -60,88 +60,92 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
        // ==============================================================================================================================
 
        public String doOpen() {
-               myknelm = getOpenKnowledge();
-               if (myindex != null) {
+               _myknelm = getOpenKnowledge();
+               if (_myindex == null) {
+                       if (_selection != null) { // Re-opening (refreshing) the currently open knowledge
+                               KnowledgeElementDTO kelm = getKnowledgeElementService()
+                                               .getKnowledgeElement(_myknelm.getIndex());
+                               _myknelm = open(kelm); // Closes the previously open knowledge
+                               _myknelm.setSelection(_selection);
+                       }
+               } else {
                        try { // Opening a knowledge from the search result
-                               int index = Integer.valueOf(myindex);
-                               if (myknelm != null && myknelm.getIndex() == index) { // - The selected knowledge is currently open
-                                       selection = myknelm.getSelection(); // Current selection
+                               int index = Integer.valueOf(_myindex);
+                               if (_myknelm != null && _myknelm.getIndex() == index) { // - The selected knowledge is currently open
+                                       _selection = _myknelm.getSelection(); // Current selection
                                } else { // - The selected knowledge is new
                                        KnowledgeElementDTO kelm = getKnowledgeElementService()
                                                        .getKnowledgeElement(index);
-                                       myknelm = open(kelm);
-                                       selection = myknelm.getSelection(); // Default selection
+                                       _myknelm = open(kelm);
+                                       _selection = _myknelm.getSelection(); // Default selection
                                }
                        } catch (Exception error) {
                                LOG.error("Reason:", error);
                                return ERROR;
                        }
-               } else if (selection != null) { // Re-opening (refreshing) the currently open knowledge
-                       KnowledgeElementDTO kelm = getKnowledgeElementService()
-                                       .getKnowledgeElement(myknelm.getIndex());
-                       myknelm = open(kelm); // Closes the previously open knowledge
-                       myknelm.setSelection(selection);
                }
-               getSession().put("menu.knowledge", myknelm.getMenu());
+               getSession().put("menu.knowledge", _myknelm.getMenu());
                
-               setMenuProperty("knowledge");
-               setTitleProperty("knowledge");
-               setToolProperty("none");
-               setLeftMenuProperty("knowledge");
+               setMenuProperty(Constants.KNOWLEDGE_MENU);
+               setTitleProperty(Constants.KNOWLEDGE_MENU);
+               setToolProperty(Constants.NONE);
+               setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
 
                return SUCCESS;
        }
 
        public String doSelectStep() {
-               myknelm = getOpenKnowledge();
+               _myknelm = getOpenKnowledge();
 
-               if (selection == null) { // Switch back to the current study
-                       selection = myknelm.getSelection();
+               if (_selection == null) { // Switch back to the current study
+                       _selection = _myknelm.getSelection();
                } else { // Selection of a step of current study
-                       myknelm.setSelection(selection);
+                       _myknelm.setSelection(_selection);
                }
                
-               setMenuProperty("knowledge");
-               setTitleProperty("knowledge");
-               setToolProperty("none");
-               setLeftMenuProperty("knowledge");
+               setMenuProperty(Constants.KNOWLEDGE_MENU);
+               setTitleProperty(Constants.KNOWLEDGE_MENU);
+               setToolProperty(Constants.NONE);
+               setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                
                return SUCCESS;
        }
 
        public String doSelectDocument() {
-               Execute todo = Execute.valueOf(action);
-               myknelm = getOpenKnowledge();
-               if (todo == Execute.develop)
-                       myknelm.developDocument(myindex);
-               else if (todo == Execute.reduce)
-                       myknelm.reduceHistory(myindex);
-               else if (todo == Execute.reduceall)
-                       myknelm.reduceDocument(myindex);
+               Execute todo = Execute.valueOf(_action);
+               _myknelm = getOpenKnowledge();
+               if (todo == Execute.develop) {
+                       _myknelm.developDocument(_myindex);
+               } else if (todo == Execute.reduce) {
+                       _myknelm.reduceHistory(_myindex);
+               } else if (todo == Execute.reduceall) {
+                       _myknelm.reduceDocument(_myindex);
+               }
                
-               setMenuProperty("knowledge");
-               setTitleProperty("knowledge");
-               setToolProperty("none");
-               setLeftMenuProperty("knowledge");
+               setMenuProperty(Constants.KNOWLEDGE_MENU);
+               setTitleProperty(Constants.KNOWLEDGE_MENU);
+               setToolProperty(Constants.NONE);
+               setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                
                return SUCCESS;
        }
 
        public String doSelectKnowledge() {
-               Execute todo = Execute.valueOf(action);
-               myknelm = getOpenKnowledge();
-               if (todo == Execute.develop)
-                       myknelm.developKnowledge(myindex);
-               else if (todo == Execute.reduce)
-                       myknelm.reduceKnowledge(myindex);
+               Execute todo = Execute.valueOf(_action);
+               _myknelm = getOpenKnowledge();
+               if (todo == Execute.develop) {
+                       _myknelm.developKnowledge(_myindex);
+               } else if (todo == Execute.reduce) {
+                       _myknelm.reduceKnowledge(_myindex);
+               }
                
-               setMenuProperty("knowledge");
-               setTitleProperty("knowledge");
-               setToolProperty("none");
-               setLeftMenuProperty("knowledge");
+               setMenuProperty(Constants.KNOWLEDGE_MENU);
+               setTitleProperty(Constants.KNOWLEDGE_MENU);
+               setToolProperty(Constants.NONE);
+               setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                
                return SUCCESS;
@@ -150,7 +154,7 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
        public String doClose() {
                closeKnowledge();
                
-               setMenuProperty("none");
+               setMenuProperty(Constants.NONE);
                initializationScreenContext(_menuProperty);
                
                return SUCCESS;
@@ -161,21 +165,22 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
        // ==============================================================================================================================
 
        public List<DocumentFacade> getDocuments() {
-               return myknelm.getDisplayedDocuments();
+               return _myknelm.getDisplayedDocuments();
        }
 
-       public List<OpenObject.KnowledgeIterator> getKnowledges() {
-               return myknelm.getDisplayedKnowledges();
+       public List<AbstractOpenObject.KnowledgeIterator> getKnowledges() {
+               return _myknelm.getDisplayedKnowledges();
        }
 
        public List<SimulationContextFacade> getSimulationContexts() {
-               return myknelm.getDisplayedSimulationContexts();
+               return _myknelm.getDisplayedSimulationContexts();
        }
 
        public Step getSelectedStep() {
-               return myknelm.getSelectedStep();
+               return _myknelm.getSelectedStep();
        }
 
+       @Override
        public String getWriteAccess() {
                return "false";
        }
@@ -196,7 +201,7 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
         *            the knowledgeElementService to set
         */
        public void setKnowledgeElementService(
-                       KnowledgeElementService knowledgeElementService) {
+                       final KnowledgeElementService knowledgeElementService) {
                _knowledgeElementService = knowledgeElementService;
        }
        
@@ -212,7 +217,7 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
         * Set the menuProperty.
         * @param menuProperty the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
        
@@ -228,7 +233,7 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
         * Set the _titleProperty.
         * @param _titleProperty the titleProperty to set
         */
-       public void setTitleProperty(String titleProperty) {
+       public void setTitleProperty(final String titleProperty) {
                _titleProperty = titleProperty;
        }
 
@@ -241,11 +246,11 @@ public class DisplayKnowledgeAction extends DisplayBaseAction {
        }
 
        /**
-        * Set the _editDisabledProperty.
-        * @param _editDisabledProperty the _editDisabledProperty to set
+        * Set the editDisabledProperty.
+        * @param editDisabledProperty the editDisabledProperty to set
         */
-       public final void setEditDisabledProperty(String _editDisabledProperty) {
-               this._editDisabledProperty = _editDisabledProperty;
+       public final void setEditDisabledProperty(final String editDisabledProperty) {
+               this._editDisabledProperty = editDisabledProperty;
        }
 
        /**
index 6a9536c254525278f14789636383ad96980a3e6e..b0852f0d6ca3989a5d7fe1c6a72a80fd34212d34 100644 (file)
@@ -4,9 +4,10 @@ import java.util.List;
 
 import org.splat.dal.bo.som.ProjectElement;
 import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.Study;
 import org.splat.service.StudyService;
 import org.splat.som.StepRights;
-import org.splat.dal.bo.som.Study;
+import org.splat.wapp.Constants;
 import org.splat.wapp.PopupMenu;
 import org.splat.wapp.SimpleMenu;
 
@@ -15,7 +16,7 @@ import org.splat.wapp.SimpleMenu;
  * @author Daniel Brunier-Coulin.
  *
  */
-public class DisplayStudyStepAction extends DisplayBaseAction {
+public class DisplayStudyStepAction extends AbstractDisplayAction {
 
        /**
         * Serial version ID.
@@ -25,7 +26,7 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
        /**
         * Presented study.
         */
-       protected OpenStudy mystudy = null;
+       protected transient OpenStudy _openStudy = null;
 
        /**
         * Injected study service.
@@ -69,14 +70,24 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
 
        public String doOpen() {
                Study study;
-               mystudy = getOpenStudy();
-               if (myindex != null)
+               String res = SUCCESS;
+               _openStudy = getOpenStudy();
+               if (_myindex == null) {
+                       if (_selection == null) { // Opening a study just newed
+                               _selection = _openStudy.getSelection(); // Default selection
+                               study = _openStudy.getStudyObject();
+                       } else { // Re-opening (refreshing) the currently open study
+                               study = getStudyService().selectStudy(_openStudy.getIndex());
+                               _openStudy = open(study); // Closes the previously open study
+                               _openStudy.setSelection(_selection);
+                       }
+               } else {
                        try { // Opening a study from the search result
-                               int index = Integer.valueOf(myindex);
-                               if (mystudy != null && mystudy.getStudyObject() != null
-                                               && mystudy.getIndex() == index) { // - The selected study is currently open
-                                       selection = mystudy.getSelection(); // Current selection
-                                       study = mystudy.getStudyObject(); // Current Study object
+                               int index = Integer.valueOf(_myindex);
+                               if (_openStudy != null && _openStudy.getStudyObject() != null
+                                               && _openStudy.getIndex() == index) { // - The selected study is currently open
+                                       _selection = _openStudy.getSelection(); // Current selection
+                                       study = _openStudy.getStudyObject(); // Current Study object
                                        // RKV:BEGIN: put in session if necessary
                                        if (!getSession().containsKey("study.open")) {
                                                open(study);
@@ -84,120 +95,116 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
                                        // RKV:END
                                } else { // - The selected study is new
                                        study = getStudyService().selectStudy(index);
-                                       mystudy = open(study);
-                                       selection = mystudy.getSelection(); // Default selection
+                                       _openStudy = open(study);
+                                       _selection = _openStudy.getSelection(); // Default selection
                                }
                        } catch (Exception error) {
                                LOG.error("Reason:", error);
-                               return ERROR;
+                               res = ERROR;
                        }
-               else if (selection == null) { // Opening a study just newed
-                       selection = mystudy.getSelection(); // Default selection
-                       study = mystudy.getStudyObject();
-               } else { // Re-opening (refreshing) the currently open study
-                       study = getStudyService().selectStudy(mystudy.getIndex());
-                       mystudy = open(study); // Closes the previously open study
-                       mystudy.setSelection(selection);
                }
-               // Initialization of menus
-               ProjectElement owner = mystudy.getSelectedStep().getOwner();
-               SimpleMenu menu = ApplicationSettings.getMenu("configuration");
-               if (owner instanceof Scenario) {
-                       menu.enables("prop-scenario");
-                       menu.selects("prop-scenario");
-               } else {
-                       menu.disables("prop-scenario");
-                       menu.selects("prop-general");
-               }
-               getSession().put("menu.study", mystudy.getMenu());
-               
-               setMenuProperty("study");
-               setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
-               } else {
-                       setToolProperty("standard");
+               if (!ERROR.equals(res)){
+                       // Initialization of menus
+                       ProjectElement owner = _openStudy.getSelectedStep().getOwner();
+                       SimpleMenu menu = ApplicationSettings.getMenu("configuration");
+                       if (owner instanceof Scenario) {
+                               menu.enables(Constants.PROP_SCENARIO);
+                               menu.selects(Constants.PROP_SCENARIO);
+                       } else {
+                               menu.disables(Constants.PROP_SCENARIO);
+                               menu.selects("prop-general");
+                       }
+                       getSession().put("menu.study", _openStudy.getMenu());
+                       
+                       setMenuProperty(Constants.STUDY_MENU);
+                       setTitleProperty(Constants.STUDY_MENU);
+                       if (Constants.TRUE.equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+                               setToolProperty(Constants.STUDY_MENU);
+                       } else {
+                               setToolProperty(Constants.STANDARD_MENU);
+                       }
+                       
+                       setLeftMenuProperty(Constants.STUDY_MENU);
+       
+                       initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                }
-               
-               setLeftMenuProperty("study");
-
-               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-
-               return SUCCESS;
+               return res;
        }
 
        public String doSelectStep() {
 
-               mystudy = getOpenStudy();
-               if (selection == null) { // Switch back to the current study
-                       selection = mystudy.getSelection();
+               _openStudy = getOpenStudy();
+               if (_selection == null) { // Switch back to the current study
+                       _selection = _openStudy.getSelection();
                } else { // Selection of a step of current study
-                       mystudy.setSelection(selection);
+                       _openStudy.setSelection(_selection);
                }
                // Re-initialization of the properties menu according to the selected step
-               ProjectElement owner = mystudy.getSelectedStep().getOwner();
+               ProjectElement owner = _openStudy.getSelectedStep().getOwner();
                SimpleMenu menu = ApplicationSettings.getMenu("configuration");
                if (owner instanceof Scenario) {
-                       menu.enables("prop-scenario");
-                       menu.selects("prop-scenario");
+                       menu.enables(Constants.PROP_SCENARIO);
+                       menu.selects(Constants.PROP_SCENARIO);
                } else {
-                       menu.disables("prop-scenario");
+                       menu.disables(Constants.PROP_SCENARIO);
                        menu.selects("prop-general");
                }
                
-               setMenuProperty("study");
-               setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
+               if (Constants.TRUE.equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
-                       setToolProperty("standard");
+                       setToolProperty(Constants.STANDARD_MENU);
                }
                
-               setLeftMenuProperty("study");
+               setLeftMenuProperty(Constants.STUDY_MENU);
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                
                return SUCCESS;
        }
 
        public String doSelectDocument() {
-               mystudy = getOpenStudy();
-               Execute todo = Execute.valueOf(action);
-               if (todo == Execute.develop)
-                       mystudy.developDocument(myindex);
-               else if (todo == Execute.reduce)
-                       mystudy.reduceHistory(myindex);
-               else if (todo == Execute.reduceall)
-                       mystudy.reduceDocument(myindex);
+               _openStudy = getOpenStudy();
+               Execute todo = Execute.valueOf(_action);
+               if (todo == Execute.develop) {
+                       _openStudy.developDocument(_myindex);
+               } else if (todo == Execute.reduce) {
+                       _openStudy.reduceHistory(_myindex);
+               } else if (todo == Execute.reduceall) {
+                       _openStudy.reduceDocument(_myindex);
+               }
                
-               setMenuProperty("study");
-               setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
+               if (Constants.TRUE.equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
-                       setToolProperty("standard");
+                       setToolProperty(Constants.STANDARD_MENU);
                }
-               setLeftMenuProperty("study");
+               setLeftMenuProperty(Constants.STUDY_MENU);
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                
                return SUCCESS;
        }
 
        public String doSelectKnowledge() {
-               mystudy = getOpenStudy();
-               Execute todo = Execute.valueOf(action);
-               if (todo == Execute.develop)
-                       mystudy.developKnowledge(myindex);
-               else if (todo == Execute.reduce)
-                       mystudy.reduceKnowledge(myindex);
+               _openStudy = getOpenStudy();
+               Execute todo = Execute.valueOf(_action);
+               if (todo == Execute.develop) {
+                       _openStudy.developKnowledge(_myindex);
+               } else if (todo == Execute.reduce) {
+                       _openStudy.reduceKnowledge(_myindex);
+               }
                
-               setMenuProperty("study");
-               setTitleProperty("study");
-               if ("true".equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
-                       setToolProperty("study");
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
+               if (Constants.TRUE.equals(getWriteAccess()) &&  getUserRights().canCreateDocument()) {
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
-                       setToolProperty("standard");
+                       setToolProperty(Constants.STANDARD_MENU);
                }
-               setLeftMenuProperty("study");
+               setLeftMenuProperty(Constants.STUDY_MENU);
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                
                return SUCCESS;
@@ -217,39 +224,40 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
        // ==============================================================================================================================
 
        public String getAction() {
-               return action;
+               return _action;
        }
 
        public List<DocumentFacade> getDocuments() {
-               return mystudy.getDisplayedDocuments();
+               return _openStudy.getDisplayedDocuments();
        }
 
-       public List<OpenObject.KnowledgeIterator> getKnowledges() {
-               return mystudy.getDisplayedKnowledges();
+       public List<AbstractOpenObject.KnowledgeIterator> getKnowledges() {
+               return _openStudy.getDisplayedKnowledges();
        }
 
        public List<SimulationContextFacade> getSimulationContexts() {
-               return mystudy.getDisplayedSimulationContexts();
+               return _openStudy.getDisplayedSimulationContexts();
        }
 
        public PopupMenu getPopup() {
-               return mystudy.getPopup();
+               return _openStudy.getPopup();
        }
 
        public int getStepNumber() {
-               return mystudy.getSelectedStep().getNumber();
+               return _openStudy.getSelectedStep().getNumber();
        }
 
        public String getStepEnabled() {
-               return String.valueOf(mystudy.isStepEnabled());
+               return String.valueOf(_openStudy.isStepEnabled());
        }
 
        public StepRights getUserRights() {
-               return mystudy.getSelectedStepRights();
+               return _openStudy.getSelectedStepRights();
        }
 
+       @Override
        public String getWriteAccess() {
-               return String.valueOf(mystudy.isOpenForWriting());
+               return String.valueOf(_openStudy.isOpenForWriting());
        }
 
        /**
@@ -267,7 +275,7 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
         * @param studyService
         *            the studyService to set
         */
-       public void setStudyService(StudyService studyService) {
+       public void setStudyService(final StudyService studyService) {
                _studyService = studyService;
        }
 
@@ -277,9 +285,9 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
         * @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
         */
        @Override
-       public void setOpenStudy(OpenStudy study) {
+       public void setOpenStudy(final OpenStudy study) {
                super.setOpenStudy(study);
-               mystudy = study;
+               _openStudy = study;
        }
        
        /**
@@ -294,7 +302,7 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
         * Set the menuProperty.
         * @param menuProperty the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
        
@@ -310,7 +318,7 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
         * Set the _titleProperty.
         * @param _titleProperty the titleProperty to set
         */
-       public void setTitleProperty(String titleProperty) {
+       public void setTitleProperty(final String titleProperty) {
                _titleProperty = titleProperty;
        }
 
@@ -326,7 +334,7 @@ public class DisplayStudyStepAction extends DisplayBaseAction {
         * Set the editDisabledProperty.
         * @param editDisabledProperty the editDisabledProperty to set
         */
-       public void setEditDisabledProperty(String editDisabledProperty) {
+       public void setEditDisabledProperty(final String editDisabledProperty) {
                _editDisabledProperty = editDisabledProperty;
        }
        
index 074b9e439e4dddb0ff01e8d15016b3c2fe11a93e..f94b37cb7fd3953403899001bee9700b0ad6d90f 100644 (file)
@@ -33,7 +33,7 @@ import org.splat.wapp.PopupMenu;
 
 public class DocumentFacade implements HistoryFacade {
 
-       private OpenObject owner;
+       private AbstractOpenObject owner;
        private Publication me;
        private Document my; // Published document
        private ProgressState state; // Document state
@@ -62,7 +62,7 @@ public class DocumentFacade implements HistoryFacade {
        // Constructors
        // ==============================================================================================================================
 
-       public DocumentFacade(OpenObject opened, Publication represented,
+       public DocumentFacade(AbstractOpenObject opened, Publication represented,
                        ProjectSettingsService projectSettings,
                        PublicationService publicationService) {
                // ------------------------------------------------------------------
@@ -88,7 +88,7 @@ public class DocumentFacade implements HistoryFacade {
         * @param represented
         *            the represented history document
         */
-       private DocumentFacade(OpenObject opened, Document represented,
+       private DocumentFacade(AbstractOpenObject opened, Document represented,
                        ProjectSettingsService projectSettings,
                        PublicationService publicationService) {
                // ----------------------------------------------------------------
@@ -125,10 +125,10 @@ public class DocumentFacade implements HistoryFacade {
                                for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
                                        Publication used = i.next();
                                        long index = used.getIndex();
-                                       DocumentFacade facade = OpenObject.docpres.get(index);
+                                       DocumentFacade facade = AbstractOpenObject.docpres.get(index);
                                        if (facade == null) {
                                                facade = new DocumentFacade(owner, used, getProjectSettings(), getPublicationService());
-                                               OpenObject.docpres.put(index, facade);
+                                               AbstractOpenObject.docpres.put(index, facade);
                                        }
                                        uses.add(facade);
                                }
index 955e65b9734cd3e88ea9779ab20f3b08c06c2535..1cac34a80b9289b57fc7a7c5eefcd77887fe48ab 100644 (file)
@@ -86,7 +86,7 @@ public class EditDocumentAction extends DisplayStudyStepAction {
         * @return SUCCESS
         */
        public String doInitialize() {
-               mystudy = getOpenStudy();
+               _openStudy = getOpenStudy();
                
                setMenuProperty("study");
                setTitleProperty("study");
@@ -114,10 +114,10 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
 
                try {
-                       mystudy = getOpenStudy();
+                       _openStudy = getOpenStudy();
 
-                       Execute todo = Execute.valueOf(action);
-                       Step step = mystudy.getSelectedStep();
+                       Execute todo = Execute.valueOf(_action);
+                       Step step = _openStudy.getSelectedStep();
                        Publication doc = step.getDocument(Integer.valueOf(index));
 
                        if (todo == Execute.renameDocument) {
@@ -125,26 +125,26 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                                // Useless to update the document presentation
                        } else if (todo == Execute.accept) {
                                getPublicationService().actualize(doc);
-                               mystudy.update(doc);
+                               _openStudy.update(doc);
                        } else if (todo == Execute.promote) {
                                getPublicationService().promote(doc,
                                                Calendar.getInstance().getTime());
-                               mystudy.update(doc);
+                               _openStudy.update(doc);
                        } else if (todo == Execute.demote) {
                                getPublicationService().demote(doc);
-                               mystudy.update(doc);
+                               _openStudy.update(doc);
                        } else if (todo == Execute.review) {
                                getPublicationService().review(doc,
                                                Calendar.getInstance().getTime());
-                               mystudy.update(doc);
+                               _openStudy.update(doc);
                        } else if (todo == Execute.invalidate) {
                                getPublicationService().invalidate(doc);
-                               mystudy.update(doc);
+                               _openStudy.update(doc);
                        } else if (todo == Execute.approve) {
                                getPublicationService().approve(doc,
                                                Calendar.getInstance().getTime());
-                               mystudy.update(doc);
-                               mystudy.getMenu().refreshSelectedItem(); // Updates the menu icon, in case of other documents in approved state
+                               _openStudy.update(doc);
+                               _openStudy.getMenu().refreshSelectedItem(); // Updates the menu icon, in case of other documents in approved state
                        }
                        return SUCCESS;
                } catch (RuntimeException saverror) {
@@ -169,9 +169,9 @@ public class EditDocumentAction extends DisplayStudyStepAction {
 
                try {
                        // Getting user inputs
-                       mystudy = getOpenStudy();
+                       _openStudy = getOpenStudy();
                        User user = getConnectedUser();
-                       Step step = mystudy.getSelectedStep();
+                       Step step = _openStudy.getSelectedStep();
                        File updir = getRepositoryService().getDownloadDirectory(user);
                        File upfile = new File(updir.getPath() + "/" + filename);
                        String[] parse = filename.split("\\x2E");
@@ -184,7 +184,7 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                                                + updir.getPath() + "\".");
                        upfile.renameTo(export.getTo().asFile());
 
-                       mystudy.update(edited);
+                       _openStudy.update(edited);
                        return SUCCESS;
                } catch (Exception error) {
                        LOG.error("Reason:", error);
@@ -205,14 +205,14 @@ public class EditDocumentAction extends DisplayStudyStepAction {
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
 
                try {
-                       mystudy = getOpenStudy();
+                       _openStudy = getOpenStudy();
 
-                       Step step = mystudy.getSelectedStep();
+                       Step step = _openStudy.getSelectedStep();
                        Publication doctag = step.getDocument(Integer.valueOf(index));
 
                        getStepService().removeDocument(step, doctag); // Updates the data structure
 
-                       mystudy.remove(doctag); // Updates the presentation
+                       _openStudy.remove(doctag); // Updates the presentation
                        return SUCCESS;
                } catch (RuntimeException saverror) {
                        LOG.error("Reason:", saverror);
index 7f9afa14976ea718473f00a21f15b2b50ff56a6a..76a15f5af42e5fcaddcb28c04b9a194da69e477e 100644 (file)
@@ -81,7 +81,7 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         * @return SUCCESS if no exceptions
         */
        public String doInitialize() {
-               mystudy = getOpenStudy();
+               _openStudy = getOpenStudy();
 
                setMenuProperty("study");
                setTitleProperty("study");
@@ -119,9 +119,9 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
 
                try {
                        User user = getConnectedUser();
-                       mystudy = getOpenStudy();
+                       _openStudy = getOpenStudy();
 
-                       Step step = mystudy.getSelectedStep();
+                       Step step = _openStudy.getSelectedStep();
                        Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
 
                        if ((title == null) || (value == null)) { 
@@ -132,16 +132,16 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
                                } else { // Edition of a knowledge
                                        getKnowledgeElementService().update(kelm, value);
                                }
-                               mystudy.update(kelm); // For updating the truncated value
+                               _openStudy.update(kelm); // For updating the truncated value
                        } else { // Addition of a new Knowledge Element
                                KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
                                KnowledgeElementType ktype = getKnowledgeElementTypeService()
                                                .selectType(Integer.valueOf(type));
                                kprop.setType(ktype).setTitle(title).setValue(value).setAuthor(
                                                user);
-                               mystudy.add(getScenarioService().addKnowledgeElement(scene,
+                               _openStudy.add(getScenarioService().addKnowledgeElement(scene,
                                                kprop));
-                               getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of first added document
+                               getMenu("study").selects(_openStudy.getSelection()); // Updates the menu icon, in case of first added document
                        }
                        return SUCCESS;
                } catch (RuntimeException saverror) {
@@ -159,15 +159,15 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         * @return SUCCESS if no exceptions
         */
        public String doDeleteKnowledge() {
-               mystudy = getOpenStudy();
-               Step step = mystudy.getSelectedStep();
+               _openStudy = getOpenStudy();
+               Step step = _openStudy.getSelectedStep();
                Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
 
                KnowledgeElement kelm = scene.getKnowledgeElement(Integer
-                               .valueOf(myindex));
+                               .valueOf(_myindex));
                getScenarioService().removeKnowledgeElement(scene, kelm); // The knowledge element necessarily exists
 
-               mystudy.remove(kelm);
+               _openStudy.remove(kelm);
                updateMenu();
 
                return SUCCESS;
@@ -201,17 +201,17 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         * @return the selected knowledge element
         */
        private KnowledgeElement getKnowledgeElement() {
-               mystudy = getOpenStudy();
-               Step step = mystudy.getSelectedStep();
+               _openStudy = getOpenStudy();
+               Step step = _openStudy.getSelectedStep();
                Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
-               return scene.getKnowledgeElement(Integer.valueOf(myindex));
+               return scene.getKnowledgeElement(Integer.valueOf(_myindex));
        }
 
        /**
         * Update current menu.
         */
        private void updateMenu() {
-               getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of last removed document
+               getMenu("study").selects(_openStudy.getSelection()); // Updates the menu icon, in case of last removed document
 
                setMenuProperty("study");
                setTitleProperty("study");
@@ -248,7 +248,7 @@ public class EditKnowledgeElementAction extends DisplayStudyStepAction {
         */
        public String getSelectedKnowledge() {
                // -------------------------------------
-               return myindex;
+               return _myindex;
        }
 
        /**
index 782798f4ca6c56c5addc1c44d878fc14f94c3058..501a3c539ff44269757dee336d129bd5a3721e25 100644 (file)
@@ -76,11 +76,11 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
                                custom.getString("date.format")); // Locale date display format
                Step step;
 
-               mystudy = getOpenStudy();
-               step = mystudy.getSelectedStep();
+               _openStudy = getOpenStudy();
+               step = _openStudy.getSelectedStep();
                myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
                lasdate = datstring.format(myscenario.getLastModificationDate());
-               subject = label.getString("label.study") + " " + mystudy.getTitle();
+               subject = label.getString("label.study") + " " + _openStudy.getTitle();
                
                setMenuProperty("study");
                setTitleProperty("study");
@@ -95,14 +95,14 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
        public String doCheckin() {
                Step step;
 
-               mystudy = getOpenStudy();
-               selection = mystudy.getSelection();
-               step = mystudy.getSelectedStep();
+               _openStudy = getOpenStudy();
+               _selection = _openStudy.getSelection();
+               step = _openStudy.getSelectedStep();
                myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
 
                getScenarioService().checkin(myscenario);
 
-               mystudy.getMenu().refreshGivenStepItem(
+               _openStudy.getMenu().refreshGivenStepItem(
                                getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
                
                setMenuProperty("study");
@@ -137,7 +137,7 @@ public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
 
        public StepRights getSelectedStep() {
                // ------------------------------------
-               return mystudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
+               return _openStudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
        }
 
        public String getSubject() {
index 31ec5a3ffff3a2764411cec9bf9fcb7e71c05d05..5ed1a7d23ead99480ab7fdc23d8175de37063f0a 100644 (file)
@@ -77,7 +77,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
 
        public String doInitialize() {
 
-               mystudy = getOpenStudy();
+               _openStudy = getOpenStudy();
                contype = getInvolvedContexts();
                
                setMenuProperty("study");
@@ -98,7 +98,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        }
 
        public String doSelectContext() {
-               mystudy = getOpenStudy();
+               _openStudy = getOpenStudy();
                
                setMenuProperty("study");
                setTitleProperty("study");
@@ -127,7 +127,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        public String doCreateContext() {
                // --------------------------------
                try {
-                       mystudy = getOpenStudy();
+                       _openStudy = getOpenStudy();
                        
                        setMenuProperty("study");
                        setTitleProperty("study");
@@ -142,7 +142,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                        if (newtype.length() == 0 || value.length() == 0)
                                return INPUT;
 
-                       Step step = mystudy.getSelectedStep();
+                       Step step = _openStudy.getSelectedStep();
                        ProjectElement owner = step.getOwner();
 
                        SimulationContext.Properties cprop = new SimulationContext.Properties();
@@ -156,7 +156,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                        else
                                contex = getStepService().addSimulationContext(step, cprop); // Re-indexes knowledges only
 
-                       mystudy.add(contex);
+                       _openStudy.add(contex);
                        return SUCCESS;
                } catch (RuntimeException saverror) {
                        LOG.error("Reason:", saverror);
@@ -179,19 +179,19 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                
                try {
-                       mystudy = getOpenStudy();
+                       _openStudy = getOpenStudy();
 
-                       Step step = mystudy.getSelectedStep();
+                       Step step = _openStudy.getSelectedStep();
                        ProjectElement owner = step.getOwner();
                        SimulationContext context = step.getSimulationContext(Integer
-                                       .valueOf(myindex));
+                                       .valueOf(_myindex));
                        if (owner instanceof Study)
                                getStudyService()
                                                .removeProjectContext(((Study) owner), context); // Re-indexes knowledges and the study
                        else
                                getStepService().removeSimulationContext(step, context); // Re-indexes knowledges only
 
-                       mystudy.remove(context);
+                       _openStudy.remove(context);
                        return SUCCESS;
                } catch (RuntimeException saverror) {
                        LOG.error("Reason:", saverror);
@@ -216,9 +216,9 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                
                try {
-                       mystudy = getOpenStudy();
+                       _openStudy = getOpenStudy();
 
-                       Step step = mystudy.getSelectedStep();
+                       Step step = _openStudy.getSelectedStep();
                        ProjectElement owner = step.getOwner();
                        SimulationContext contex = null;
 
@@ -245,7 +245,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
                                else
                                        contex = getStepService().addSimulationContext(step, cprop); // Re-indexes knowledges only
                        }
-                       mystudy.add(contex);
+                       _openStudy.add(contex);
                        contype = getInvolvedContexts();
 
 //                     transax.commit();
@@ -309,7 +309,7 @@ public class EditSimulationContextAction extends DisplayStudyStepAction {
        private List<SimulationContextType> getInvolvedContexts() {
                // ----------------------------------------------------------
                SimulationContextType.Properties sprop = new SimulationContextType.Properties()
-                               .setStep(mystudy.getSelectedStep().getStep());
+                               .setStep(_openStudy.getSelectedStep().getStep());
                List<SimulationContextType> contype = getSimulationContextService()
                                .selectTypesWhere(sprop);
 
index 2cef5d01db2c01fdfff7790cd70b7efe0c26fb0e..755ba3faef571bf7a0600e27b80d1413479d5915 100644 (file)
@@ -52,14 +52,14 @@ public class EditStudyAction extends DisplayStudyStepAction {
 
     public String doEdition () {
          try {
-        mystudy = getOpenStudy();
+        _openStudy = getOpenStudy();
 
-        Execute  todo   = Execute.valueOf(action);
-        Study    study  = mystudy.getStudyObject();
+        Execute  todo   = Execute.valueOf(_action);
+        Study    study  = _openStudy.getStudyObject();
         
         if      (todo == Execute.publish) getStudyService().moveToPublic(study);
         else if (todo == Execute.promote) getStudyService().moveToReference(study);
-        mystudy.getPopup().setContext("study", mystudy.getStudyRights());   // The context has changed
+        _openStudy.getPopup().setContext("study", _openStudy.getStudyRights());   // The context has changed
         
         setMenuProperty("study");
         setTitleProperty("study");
index 1c3942bacaf3df9b74e83789fc2a2e746e4abe19..86206fb07cb0ed03c53ff4858888c571df5b6694 100644 (file)
@@ -21,24 +21,24 @@ public class LeftMenuSettings {
        /**
         * The name of the left menu.
         */
-       private String menuName;
+       private String _menuName;
        
        /**
         * The name space of the left menu.
         */
-       private String menuNamespace;
+       private String _menuNamespace;
        
        /**
         * The left menu.
         */
-       private Menu menu;
+       private Menu _menu;
 
        /**
         * Get the menuName.
         * @return the menuName
         */
        public String getMenuName() {
-               return menuName;
+               return _menuName;
        }
 
        /**
@@ -46,7 +46,7 @@ public class LeftMenuSettings {
         * @param menuName the menuName to set
         */
        public void setMenuName(final String menuName) {
-               this.menuName = menuName;
+               this._menuName = menuName;
        }
 
        /**
@@ -54,7 +54,7 @@ public class LeftMenuSettings {
         * @return the menuNamespace
         */
        public String getMenuNamespace() {
-               return menuNamespace;
+               return _menuNamespace;
        }
 
        /**
@@ -62,7 +62,7 @@ public class LeftMenuSettings {
         * @param menuNamespace the menuNamespace to set
         */
        public void setMenuNamespace(final String menuNamespace) {
-               this.menuNamespace = menuNamespace;
+               this._menuNamespace = menuNamespace;
        }
 
        /**
@@ -70,7 +70,7 @@ public class LeftMenuSettings {
         * @return the menu
         */
        public Menu getMenu() {
-               return menu;
+               return _menu;
        }
 
        /**
@@ -78,7 +78,7 @@ public class LeftMenuSettings {
         * @param menu the menu to set
         */
        public void setMenu(final Menu menu) {
-               this.menu = menu;
+               this._menu = menu;
        }
        
        
index 1c026e32d0d4622031e670e3bc42f176e543d2bd..3764e28160183124764026538f42b4c5ec3b2697 100644 (file)
@@ -2,54 +2,81 @@ package org.splat.simer;
 
 import org.splat.wapp.SimpleMenu;
 
-
+/**
+ * Menu selection action.
+ */
 public class MenuAction extends Action {
-
-    private String menuname;
-       private String selection;
-
        /**
         * Serial version ID.
         */
        private static final long serialVersionUID = 5904292225286579036L;
 
-//  ==============================================================================================================================
-//  Action methods
-//  ==============================================================================================================================
-
-    public String doSelectItem () {
-//  -----------------------------
-      SimpleMenu  menu = ApplicationSettings.getMenu(menuname);
-        
-      if (selection == null) {                 // Switch back to the menu, keeping the last selection
-               getSession().put("menu.open", menu);   // Activates the menu
-        selection = menu.getSelection();
-        if (selection == null) selection = "none";
-      } else {                                    // Selection of another menu item
-        menu.selects(selection);
-      }
-      return selection;
-    }
-
-//  ==============================================================================================================================
-//  Getters and setters
-//  ==============================================================================================================================
-
-    public String getItem () {
-//  ------------------------
-      return selection;
-    }
-    public String getMenu () {
-//  ------------------------
-      return menuname;
-    }
-
-    public void setMenu (String name) {
-//  ---------------------------------
-      this.menuname = name;
-    }
-    public void setItem (String item) {
-//  ---------------------------------
-      this.selection = item;
-    }
+       /**
+        * Current menu.
+        */
+       private String _menu;
+       /**
+        * Selected item.
+        */
+       private String _item;
+
+       // ==============================================================================================================================
+       // Action methods
+       // ==============================================================================================================================
+
+       /**
+        * Activate the menu and select the menu item.
+        * 
+        * @return the selected menu item
+        */
+       public String doSelectItem() {
+               SimpleMenu menu = ApplicationSettings.getMenu(_menu);
+
+               if (_item == null) { // Switch back to the menu, keeping the last selection
+                       getSession().put("menu.open", menu); // Activates the menu
+                       _item = menu.getSelection();
+                       if (_item == null) {
+                               _item = "none";
+                       }
+               } else { // Selection of another menu item
+                       menu.selects(_item);
+               }
+               return _item;
+       }
+
+       // ==============================================================================================================================
+       // Getters and setters
+       // ==============================================================================================================================
+
+       /**
+        * Get selected menu item.
+        * @return the selected menu item
+        */
+       public String getItem() {
+               return _item;
+       }
+
+       /**
+        * Get current menu name. 
+        * @return the menu name
+        */
+       public String getMenu() {
+               return _menu;
+       }
+
+       /**
+        * Set current menu name.
+        * @param name the menu name
+        */
+       public void setMenu(final String name) {
+               this._menu = name;
+       }
+
+       /**
+        * Set the selected menu item.
+        * @param item the selected item
+        */
+       public void setItem(final String item) {
+               this._item = item;
+       }
 }
\ No newline at end of file
index 57c89b2979703485b0df15542995807f4e76522b..4956e008d10d45d81e8329a78c639b652c321cee 100644 (file)
@@ -9,6 +9,8 @@
 
 package org.splat.simer; 
 
+import org.splat.wapp.Constants;
+
 /**
  * Settings for menu bar.
  * @author Maria KRUCHININA
@@ -19,73 +21,73 @@ public class MenuBarSettings {
        /**
         * The SALOME WEB-site URL.
         */
-       private  String webSiteURL;
+       private  String _webSiteURL;
 
        /**
         * Help URL.
         */
-       private  String helpURL;
+       private  String _helpURL;
 
        //=== MENUS==========================================
        /**
         * Property, is this menu the "Create the Study" one.
         */
-       private  Boolean isMenuCreate;
+       private  Boolean _isMenuCreate;
        
        /**
         * Property, is this menu the "Open the Study" one.
         */
-       private  Boolean isMenuOpen;
+       private  Boolean _isMenuOpen;
        
        /**
         * Property, is this menu the "Display the Open Study" one.
         */
-       private  Boolean isMenuStudy;
+       private  Boolean _isMenuStudy;
        
        /**
         * Property, is this menu the "Display the Open Knowledge" one.
         */
-       private  Boolean isMenuKnowledge;
+       private  Boolean _isMenuKnowledge;
        
        /**
         * Property, is this menu the "Managing the database" one.
         */
-       private  Boolean isMenuSysAdmin;
+       private  Boolean _isMenuSysAdmin;
        
        /**
         * Property, is this menu the "Help" one.
         */
-       private  Boolean isMenuHelp;
+       private  Boolean _isMenuHelp;
        
        //=== OTHER OPERATIONS ============================
        
        /**
         * Can the given User create the given Study. 
         */
-       private  Boolean canUserCreateStudy;
+       private  Boolean _canUserCreateStudy;
        
        /**
         * Is the given Study NULL. 
         */
-       private  Boolean isStudyNull;
+       private  Boolean _isStudyNull;
        
        /**
         * Is the given Knowledge NULL. 
         */
-       private  Boolean isKnowledgeNull;
+       private  Boolean _isKnowledgeNull;
        
        /**
         * Can the given User manage the Database. 
         */
-       private  Boolean canUserManageDatabase;
+       private  Boolean _canUserManageDatabase;
        
        /**
      * Initialize the initial properties for menus.
      */  
     public void initializeInitialMenuProperties() {
        
-       webSiteURL = ApplicationSettings.getWebSiteURL();
-       helpURL =  ApplicationSettings.getHelpURL();
+       _webSiteURL = ApplicationSettings.getWebSiteURL();
+       _helpURL =  ApplicationSettings.getHelpURL();
        
     }
     
@@ -106,9 +108,9 @@ public class MenuBarSettings {
                setIsMenuCreate(true);
        } else if ("open".equals(menuProperty)) {
                setIsMenuOpen(true);
-       } else if ("study".equals(menuProperty)) {
+       } else if (Constants.STUDY_MENU.equals(menuProperty)) {
                setIsMenuStudy(true);
-       } else if ("knowledge".equals(menuProperty)) {
+       } else if (Constants.KNOWLEDGE_MENU.equals(menuProperty)) {
                setIsMenuKnowledge(true);
        } else if ("sysadmin".equals(menuProperty)) {
                setIsMenuSysAdmin(true);
@@ -124,7 +126,7 @@ public class MenuBarSettings {
         * @return the webSiteURL
         */
     public String getWebSiteURL() {
-               return webSiteURL;
+               return _webSiteURL;
        }
 
     /**
@@ -132,7 +134,7 @@ public class MenuBarSettings {
         * @param webSiteURL the webSiteURL to set
         */
        public void setWebSiteURL(final String webSiteURL) {
-               this.webSiteURL = webSiteURL;
+               this._webSiteURL = webSiteURL;
        }
 
        /**
@@ -140,7 +142,7 @@ public class MenuBarSettings {
         * @return the helpURL
         */
        public String getHelpURL() {
-               return helpURL;
+               return _helpURL;
        }
 
        /**
@@ -148,7 +150,7 @@ public class MenuBarSettings {
         * @param helpURL the helpURL to set
         */
        public void setHelpURL(final String helpURL) {
-               this.helpURL = helpURL;
+               this._helpURL = helpURL;
        }
 
        /**
@@ -156,7 +158,7 @@ public class MenuBarSettings {
         * @return the isMenuCreate
         */
        public Boolean getIsMenuCreate() {
-               return isMenuCreate;
+               return _isMenuCreate;
        }
 
        /**
@@ -164,7 +166,7 @@ public class MenuBarSettings {
         * @param isMenuCreate the isMenuCreate to set
         */
        public void setIsMenuCreate(final Boolean isMenuCreate) {
-               this.isMenuCreate = isMenuCreate;
+               this._isMenuCreate = isMenuCreate;
        }
 
        /**
@@ -172,7 +174,7 @@ public class MenuBarSettings {
         * @return the isMenuOpen
         */
        public Boolean getIsMenuOpen() {
-               return isMenuOpen;
+               return _isMenuOpen;
        }
 
        /**
@@ -180,7 +182,7 @@ public class MenuBarSettings {
         * @param isMenuOpen the isMenuOpen to set
         */
        public void setIsMenuOpen(final Boolean isMenuOpen) {
-               this.isMenuOpen = isMenuOpen;
+               this._isMenuOpen = isMenuOpen;
        }
 
        /**
@@ -188,7 +190,7 @@ public class MenuBarSettings {
         * @return the isMenuStudy
         */
        public Boolean getIsMenuStudy() {
-               return isMenuStudy;
+               return _isMenuStudy;
        }
 
        /**
@@ -196,7 +198,7 @@ public class MenuBarSettings {
         * @param isMenuStudy the isMenuStudy to set
         */
        public void setIsMenuStudy(final Boolean isMenuStudy) {
-               this.isMenuStudy = isMenuStudy;
+               this._isMenuStudy = isMenuStudy;
        }
 
        /**
@@ -204,7 +206,7 @@ public class MenuBarSettings {
         * @return the isMenuKnowledge
         */
        public Boolean getIsMenuKnowledge() {
-               return isMenuKnowledge;
+               return _isMenuKnowledge;
        }
 
        /**
@@ -212,7 +214,7 @@ public class MenuBarSettings {
         * @param isMenuKnowledge the isMenuKnowledge to set
         */
        public void setIsMenuKnowledge(final Boolean isMenuKnowledge) {
-               this.isMenuKnowledge = isMenuKnowledge;
+               this._isMenuKnowledge = isMenuKnowledge;
        }
 
        /**
@@ -220,7 +222,7 @@ public class MenuBarSettings {
         * @return the isMenuSysAdmin
         */
        public Boolean getIsMenuSysAdmin() {
-               return isMenuSysAdmin;
+               return _isMenuSysAdmin;
        }
 
        /**
@@ -228,7 +230,7 @@ public class MenuBarSettings {
         * @param isMenuSysAdmin the isMenuSysAdmin to set
         */
        public void setIsMenuSysAdmin(final Boolean isMenuSysAdmin) {
-               this.isMenuSysAdmin = isMenuSysAdmin;
+               this._isMenuSysAdmin = isMenuSysAdmin;
        }
 
        /**
@@ -236,7 +238,7 @@ public class MenuBarSettings {
         * @return the isMenuHelp
         */
        public Boolean getIsMenuHelp() {
-               return isMenuHelp;
+               return _isMenuHelp;
        }
 
        /**
@@ -244,7 +246,7 @@ public class MenuBarSettings {
         * @param isMenuHelp the isMenuHelp to set
         */
        public void setIsMenuHelp(final Boolean isMenuHelp) {
-               this.isMenuHelp = isMenuHelp;
+               this._isMenuHelp = isMenuHelp;
        }
 
        /**
@@ -252,7 +254,7 @@ public class MenuBarSettings {
         * @return the canUserCreateStudy
         */
        public Boolean getCanUserCreateStudy() {
-               return canUserCreateStudy;
+               return _canUserCreateStudy;
        }
 
        /**
@@ -260,7 +262,7 @@ public class MenuBarSettings {
         * @param canUserCreateStudy the canUserCreateStudy to set
         */
        public void setCanUserCreateStudy(final Boolean canUserCreateStudy) {
-               this.canUserCreateStudy = canUserCreateStudy;
+               this._canUserCreateStudy = canUserCreateStudy;
        }
 
        /**
@@ -268,7 +270,7 @@ public class MenuBarSettings {
         * @return the isStudyNull
         */
        public Boolean getIsStudyNull() {
-               return isStudyNull;
+               return _isStudyNull;
        }
 
        /**
@@ -276,7 +278,7 @@ public class MenuBarSettings {
         * @param isStudyNull the isStudyNull to set
         */
        public void setIsStudyNull(final Boolean isStudyNull) {
-               this.isStudyNull = isStudyNull;
+               this._isStudyNull = isStudyNull;
        }
 
        /**
@@ -284,7 +286,7 @@ public class MenuBarSettings {
         * @return the isKnowledgeNull
         */
        public Boolean getIsKnowledgeNull() {
-               return isKnowledgeNull;
+               return _isKnowledgeNull;
        }
 
        /**
@@ -292,7 +294,7 @@ public class MenuBarSettings {
         * @param isKnowledgeNull the isKnowledgeNull to set
         */
        public void setIsKnowledgeNull(final Boolean isKnowledgeNull) {
-               this.isKnowledgeNull = isKnowledgeNull;
+               this._isKnowledgeNull = isKnowledgeNull;
        }
 
        /**
@@ -300,7 +302,7 @@ public class MenuBarSettings {
         * @return the canUserManageDatabase
         */
        public Boolean getCanUserManageDatabase() {
-               return canUserManageDatabase;
+               return _canUserManageDatabase;
        }
 
        /**
@@ -308,7 +310,7 @@ public class MenuBarSettings {
         * @param canUserManageDatabase the canUserManageDatabase to set
         */
        public void setCanUserManageDatabase(final Boolean canUserManageDatabase) {
-               this.canUserManageDatabase = canUserManageDatabase;
+               this._canUserManageDatabase = canUserManageDatabase;
        }
        
 }
index 94b40177ff329d6b4072841705b0b00ef0367943..40ae3ff3ab8847a85346a025b6a79770e4a520b7 100644 (file)
@@ -7,6 +7,9 @@ import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.dal.bo.som.Study;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
 import org.splat.service.ScenarioService;
 import org.splat.service.SimulationContextService;
 
@@ -27,15 +30,15 @@ public class NewStudyAction extends Action {
        /**
         * Title of the new study.
         */
-       private String title = null;
+       private String _title = null;
        /**
         * List of available project contexts for selection for the new study.
         */
-       private List<SimulationContext> contelm = null;
+       private transient List<SimulationContext> _contelm = null;
        /**
         * Project context.
         */
-       private String context = null;
+       private String _projectContext = null;
 
        /**
         * Injected simulation context service.
@@ -50,16 +53,14 @@ public class NewStudyAction extends Action {
         * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
         */
        private String _menuProperty;
-       
+
        /**
-        * Value of the tool bar property. 
-        * It can be: none, standard, study, back.
+        * Value of the tool bar property. It can be: none, standard, study, back.
         */
        private String _toolProperty;
-       
+
        /**
-        * Value of the left menu property. 
-        * It can be: open, study, knowledge, scenario.
+        * Value of the left menu property. It can be: open, study, knowledge, scenario.
         */
        private String _leftMenuProperty;
 
@@ -75,18 +76,19 @@ public class NewStudyAction extends Action {
        public String doInitialize() {
 
                // get the list of the simulation contexts of the study
-               contelm = getSimulationContextService().getSimulationContextList();
+               _contelm = getSimulationContextService().getSimulationContextList();
 
                // set the default name of the new study
                ResourceBundle locale = ResourceBundle.getBundle("labels",
                                getApplicationSettings().getCurrentLocale());
-               title = locale.getString("label.study") + " "
+               _title = locale.getString("label.study") + " "
                                + String.valueOf(number + 1);
 
                setMenuProperty("create");
                setToolProperty("none");
                setLeftMenuProperty("open");
-               initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
+               initializationFullScreenContext(_menuProperty, _toolProperty,
+                               _leftMenuProperty);
 
                return SUCCESS;
        }
@@ -95,11 +97,16 @@ public class NewStudyAction extends Action {
         * Create a new study.
         * 
         * @return SUCCESS if the new study is created, INPUT if project context is not defined, ERROR if failed
-        * @throws Exception
+        * @throws InvalidPropertyException
+        *             if some property has invalid value
+        * @throws MultiplyDefinedException
+        *             if some property is defined several times
+        * @throws MissedPropertyException
         *             if properties of the new study are invalid
         */
-       public String doCreate() throws Exception {
-               String[] input = context.split(",");
+       public String doCreate() throws InvalidPropertyException,
+                       MissedPropertyException, MultiplyDefinedException {
+               String[] input = _projectContext.split(",");
                int valid = Integer.valueOf(input[0]);
                String value = ""; // input[1] if exists
 
@@ -110,7 +117,7 @@ public class NewStudyAction extends Action {
                        SimulationContext.Properties cprop = new SimulationContext.Properties();
                        SimulationContextType product = getSimulationContextService()
                                        .selectType("product");
-                       contelm = getSimulationContextService()
+                       _contelm = getSimulationContextService()
                                        .selectSimulationContextsWhere(cprop.setType(product));
                        return INPUT; // Title empty, simply wait for input without error message
                }
@@ -122,7 +129,7 @@ public class NewStudyAction extends Action {
                                return INPUT; // No need to reinitialize the list of existing products
                        }
                }
-               sprop.setTitle(title).setManager(getConnectedUser());
+               sprop.setTitle(_title).setManager(getConnectedUser());
                sprop.checkValidity();
                sprop.disableCheck();
                try {
@@ -149,7 +156,8 @@ public class NewStudyAction extends Action {
                        setMenuProperty("study");
                        setToolProperty("none");
                        setLeftMenuProperty("open");
-                       initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
+                       initializationFullScreenContext(_menuProperty, _toolProperty,
+                                       _leftMenuProperty);
 
                        return SUCCESS;
                } catch (Exception error) {
@@ -166,42 +174,49 @@ public class NewStudyAction extends Action {
 
        /**
         * Get the selected project context for the new study.
+        * 
         * @return the selected project context
         */
        public String getProjectContext() {
-               return context;
+               return _projectContext;
        }
 
        /**
         * Get the list of available project contexts.
+        * 
         * @return the list of context values
         */
        public List<SimulationContext> getProjectContextValues() {
-               return contelm;
+               return _contelm;
        }
 
        /**
         * Get the title of the new study.
+        * 
         * @return the title
         */
        public String getTitle() {
-               return title;
+               return _title;
        }
 
        /**
         * Set the project context for the new study.
-        * @param value the project context value.
+        * 
+        * @param value
+        *            the project context value.
         */
-       public void setProjectContext(String value) {
-               this.context = value;
+       public void setProjectContext(final String value) {
+               this._projectContext = value;
        }
 
        /**
         * Set the title of the new study.
-        * @param value the title to set
+        * 
+        * @param value
+        *            the title to set
         */
-       public void setTitle(String value) {
-               this.title = value;
+       public void setTitle(final String value) {
+               this._title = value;
        }
 
        /**
@@ -220,7 +235,7 @@ public class NewStudyAction extends Action {
         *            the simulationContextService to set
         */
        public void setSimulationContextService(
-                       SimulationContextService simulationContextService) {
+                       final SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
 
@@ -239,7 +254,7 @@ public class NewStudyAction extends Action {
         * @param scenarioService
         *            the scenarioService to set
         */
-       public void setScenarioService(ScenarioService scenarioService) {
+       public void setScenarioService(final ScenarioService scenarioService) {
                _scenarioService = scenarioService;
        }
 
@@ -258,12 +273,13 @@ public class NewStudyAction extends Action {
         * @param menuProperty
         *            the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
-       
+
        /**
         * Get the toolProperty.
+        * 
         * @return the toolProperty
         */
        public String getToolProperty() {
@@ -272,14 +288,17 @@ public class NewStudyAction extends Action {
 
        /**
         * Set the toolProperty.
-        * @param toolProperty the toolProperty to set
+        * 
+        * @param toolProperty
+        *            the toolProperty to set
         */
        public void setToolProperty(final String toolProperty) {
                _toolProperty = toolProperty;
        }
-       
+
        /**
         * Get the leftMenuProperty.
+        * 
         * @return the leftMenuProperty
         */
        public String getLeftMenuProperty() {
@@ -288,7 +307,9 @@ public class NewStudyAction extends Action {
 
        /**
         * Set the leftMenuProperty.
-        * @param leftMenuProperty the leftMenuProperty to set
+        * 
+        * @param leftMenuProperty
+        *            the leftMenuProperty to set
         */
        public void setLeftMenuProperty(final String leftMenuProperty) {
                _leftMenuProperty = leftMenuProperty;
index 7795dbe0508dac8a174723d15ee04eaa3dcf9195..cca5b9f9531aafe810ebe3b79272af2c6e748866 100644 (file)
@@ -16,7 +16,7 @@ import org.splat.wapp.SimpleMenu;
 /**
  * Open knowledge details for presentation.
  */
-public class OpenKnowledge extends OpenObject {
+public class OpenKnowledge extends AbstractOpenObject {
 
        /**
         * The open knowledge element DTO.
@@ -87,19 +87,19 @@ public class OpenKnowledge extends OpenObject {
                // Preparation of the display
                _credate = convert.format(_myknelm.getDate());
                // involving = getAllSteps(knelm.getOwnerScenario());
-               involving = knelm.getInvolving();
-               context = new ArrayList<SimulationContextFacade>();
-               menu = new Menu(getInvolvedSteps());
-               selection = menu.getSelection(); // The default selection is set in the menu definition
-               int index = Integer.valueOf(selection);
-               for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
+               _involving = knelm.getInvolving();
+               _context = new ArrayList<SimulationContextFacade>();
+               _menu = new Menu(getInvolvedSteps());
+               _selection = _menu.getSelection(); // The default selection is set in the menu definition
+               int index = Integer.valueOf(_selection);
+               for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
                        Step next = i.next();
                        if (next.getNumber() == index) {
-                               ustep = next;
+                               _ustep = next;
                        }
                        for (Iterator<SimulationContext> j = next
                                        .getAllSimulationContexts().iterator(); j.hasNext();) {
-                               context.add(new SimulationContextFacade(j.next(),
+                               _context.add(new SimulationContextFacade(j.next(),
                                                getProjectSettings().getAllSteps()));
                        }
                }
@@ -110,7 +110,7 @@ public class OpenKnowledge extends OpenObject {
                                .append("\",").append("<br>")
                                .append(sceneTitle/* scene.getTitle() */).append(".").append(
                                                "</p>");
-               description = value.toString();
+               _description = value.toString();
                setupContents(); // Initializes documents and knowledge at ustep
                return this;
        }
@@ -133,7 +133,7 @@ public class OpenKnowledge extends OpenObject {
 
        @Override
        public Menu getMenu() {
-               return (Menu) menu;
+               return (Menu) _menu;
        }
 
        public ProgressState getProgressState() {
@@ -159,15 +159,15 @@ public class OpenKnowledge extends OpenObject {
        }
 
        public void setSelection(final String step) {
-               selection = step;
-               int index = Integer.valueOf(selection);
-               for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
-                       ustep = i.next();
-                       if (ustep.getNumber() == index) {
+               _selection = step;
+               int index = Integer.valueOf(_selection);
+               for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
+                       _ustep = i.next();
+                       if (_ustep.getNumber() == index) {
                                break;
                        }
                }
-               menu.selects(selection);
+               _menu.selects(_selection);
                setupContents(); // The contents may have changed even if the selection is the same
        }
 }
\ No newline at end of file
diff --git a/Workspace/Siman/src/org/splat/simer/OpenObject.java b/Workspace/Siman/src/org/splat/simer/OpenObject.java
deleted file mode 100644 (file)
index 2efe1b0..0000000
+++ /dev/null
@@ -1,448 +0,0 @@
-package org.splat.simer;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.splat.dal.bo.kernel.User;
-import org.splat.dal.bo.som.Document;
-import org.splat.dal.bo.som.DocumentType;
-import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.bo.som.KnowledgeElementType;
-import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.bo.som.Publication;
-import org.splat.dal.bo.som.Scenario;
-import org.splat.service.KnowledgeElementTypeService;
-import org.splat.service.ProjectElementService;
-import org.splat.service.PublicationService;
-import org.splat.service.dto.KnowledgeElementDTO;
-import org.splat.service.dto.Proxy;
-import org.splat.service.technical.ProjectSettingsService;
-import org.splat.som.Step;
-import org.splat.util.BeanHelper;
-import org.splat.wapp.Menu;
-import org.splat.wapp.PopupMenu;
-
-public abstract class OpenObject implements Proxy {
-
-       protected static Map<Long, DocumentFacade> docpres = null;
-       protected static Map<Long, KnowledgeElementFacade> knowpres = null;
-
-       /**
-        * Connected user.
-        */
-       protected User cuser = null;
-       /**
-        * Menu selected by the user.
-        */
-       protected String selection = null;
-       /**
-        * Corresponding selected step.
-        */
-       protected Step ustep = null;
-       /**
-        * Object description (rich text).
-        */
-       protected String description = null;
-       protected List<Step> involving = new ArrayList<Step>();
-       /**
-        * Simulation Context display representations.
-        */
-       protected List<SimulationContextFacade> context = new ArrayList<SimulationContextFacade>(); // Simulation Context display representations
-       /**
-        * Document display representations.
-        */
-       protected List<DocumentFacade> contents = null;
-       /**
-        * Knowledge Element display representations structured by knowledge types.
-        */
-       protected List<KnowledgeIterator> knowledge = null;
-
-       /**
-        * Left pane menu of this object.
-        */
-       protected Menu menu = null;
-       /**
-        * Pop-up menu of this object, if the user has write access.
-        */
-       protected PopupMenu popup = null;
-       /**
-        * Injected project settings service.
-        */
-       private ProjectSettingsService _projectSettingsService;
-       /**
-        * Injected application settings bean.
-        */
-       private ApplicationSettings _applicationSettings;
-       /**
-        * Injected publication service.
-        */
-       private PublicationService _publicationService;
-       /**
-        * Injected knowledge element service.
-        */
-       private KnowledgeElementTypeService _knowledgeElementTypeService;
-       /**
-        * Injected project element service.
-        */
-       private ProjectElementService _projectElementService;
-
-       public class KnowledgeIterator {
-               protected KnowledgeElementType type;
-               protected List<KnowledgeElementFacade> list;
-
-               public KnowledgeIterator(final KnowledgeElementType type,
-                               final List<KnowledgeElementFacade> list) {
-                       this.type = type;
-                       this.list = list;
-               }
-
-               public String getIndex() {
-                       return String.valueOf(type.getIndex());
-               }
-
-               public String getType() {
-                       return type.getName();
-               }
-
-               public List<KnowledgeElementFacade> getKnowledgeElements() {
-                       return list;
-               }
-       }
-
-       // ==============================================================================================================================
-       // Constructor
-       // ==============================================================================================================================
-
-       protected OpenObject() {
-               // -----------------------
-               // All member fields are supposed initialized by subclasses
-               if (docpres == null) {
-                       docpres = new HashMap<Long, DocumentFacade>();
-               }
-               if (knowpres == null) {
-                       knowpres = new HashMap<Long, KnowledgeElementFacade>();
-               }
-       }
-
-       // ==============================================================================================================================
-       // Public member functions
-       // ==============================================================================================================================
-
-       public void developDocument(final String index) {
-               // ------------------------------------------
-               for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
-                       DocumentFacade doc = i.next();
-                       if (!doc.getIndex().equals(index)) {
-                               continue;
-                       }
-                       doc.develop();
-                       return;
-               }
-       }
-
-       public void developKnowledge(final String index) {
-               // -------------------------------------------
-               for (Iterator<KnowledgeIterator> i = knowledge.iterator(); i.hasNext();) {
-                       List<KnowledgeElementFacade> knowelms = i.next()
-                                       .getKnowledgeElements();
-                       for (Iterator<KnowledgeElementFacade> j = knowelms.iterator(); j
-                                       .hasNext();) {
-                               KnowledgeElementFacade kelm = j.next();
-                               if (!kelm.getIndex().equals(index)) {
-                                       continue;
-                               }
-                               kelm.develop();
-                               return;
-                       }
-               }
-       }
-
-       public void clearFacades() {
-               // ---------------------------
-               docpres.clear(); // For eventually reopening the knowledge from a fresh context
-               knowpres.clear(); // For eventually reopening the knowledge from a fresh context
-       }
-
-       public List<Document> collectInvolvedDocuments(final DocumentType type) {
-               // ------------------------------------------------------------------
-               List<Document> found = new ArrayList<Document>();
-               for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
-                       Step step = i.next();
-                       List<Publication> exist = step.getAllDocuments();
-                       for (Iterator<Publication> j = exist.iterator(); j.hasNext();) {
-                               Document doc = j.next().value();
-                               if (doc.getType().equals(type)) {
-                                       found.add(doc);
-                               }
-                       }
-               }
-               return found;
-       }
-
-       public String getDisplayedDescription() {
-               // ----------------------------------------
-               return description;
-       }
-
-       public List<DocumentFacade> getDisplayedDocuments() {
-               // -----------------------------------------------------
-               return contents;
-       }
-
-       public List<SimulationContextFacade> getDisplayedSimulationContexts() {
-               // ----------------------------------------------------------------------
-               return context;
-       }
-
-       public List<KnowledgeIterator> getDisplayedKnowledges() {
-               // --------------------------------------------------------
-               return knowledge;
-       }
-
-       public List<Step> getInvolvedSteps() {
-               // -------------------------------------
-               return involving;
-       }
-
-       public Menu getMenu() {
-               // ----------------------
-               return menu;
-       }
-
-       public PopupMenu getPopup() {
-               // ----------------------------
-               return popup;
-       }
-
-       public Step getSelectedStep() {
-               // ------------------------------
-               return ustep;
-       }
-
-       public String getSelection() {
-               // -----------------------------
-               return selection;
-       }
-
-       public User getUser() {
-               // ----------------------
-               return cuser;
-       }
-
-       public boolean isOpenForWriting() {
-               // ----------------------------------
-               return (popup != null); // The pop-up is supposed existed when the user is staffed on the study
-       }
-
-       public void reduceDocument(final String index) {
-               // -----------------------------------------
-               for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
-                       DocumentFacade doc = i.next();
-                       if (!doc.getIndex().equals(index)) {
-                               continue;
-                       }
-                       doc.reduceAll();
-                       return;
-               }
-       }
-
-       public void reduceHistory(final String index) {
-               // ----------------------------------------
-               for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
-                       DocumentFacade doc = i.next();
-                       if (!doc.getIndex().equals(index)) {
-                               continue;
-                       }
-                       doc.reduce();
-                       return;
-               }
-       }
-
-       public void reduceKnowledge(final String index) {
-               // ------------------------------------------
-               for (Iterator<KnowledgeIterator> i = knowledge.iterator(); i.hasNext();) {
-                       List<KnowledgeElementFacade> knowelms = i.next()
-                                       .getKnowledgeElements();
-                       for (Iterator<KnowledgeElementFacade> j = knowelms.iterator(); j
-                                       .hasNext();) {
-                               KnowledgeElementFacade kelm = j.next();
-                               if (!kelm.getIndex().equals(index)) {
-                                       continue;
-                               }
-                               kelm.reduce();
-                               return;
-                       }
-               }
-       }
-
-       // ==============================================================================================================================
-       // Protected services
-       // ==============================================================================================================================
-
-       protected void setupContents() {
-               // -------------------------------
-               // Description
-               // Initialized in subclasses
-
-               // Knowledge elements supposed ordered by type
-               if (ustep.mayContain(KnowledgeElement.class)) {
-                       Scenario scene = (Scenario) ustep.getOwner();
-                       List<KnowledgeElementType> types = getKnowledgeElementTypeService()
-                                       .selectTypesWhere(ProgressState.APPROVED);
-                       List<KnowledgeElement> kelms = scene.getAllKnowledgeElements();
-                       Iterator<KnowledgeElement> more = kelms.iterator();
-                       KnowledgeElement current = null;
-                       if (more.hasNext()) {
-                               current = more.next();
-                       }
-
-                       knowledge = new ArrayList<KnowledgeIterator>(types.size());
-                       for (Iterator<KnowledgeElementType> i = types.iterator(); i
-                                       .hasNext();) {
-                               KnowledgeElementType type = i.next();
-                               List<KnowledgeElementFacade> display = new ArrayList<KnowledgeElementFacade>(
-                                               kelms.size());
-                               while (current != null && current.getType().equals(type)) {
-                                       KnowledgeElementFacade facade = knowpres.get(current
-                                                       .getIndex());
-                                       if (facade == null) {
-                                               facade = new KnowledgeElementFacade(BeanHelper.copyBean(current, KnowledgeElementDTO.class));
-                                               knowpres.put(current.getIndex(), facade);
-                                       }
-                                       display.add(facade);
-                                       if (more.hasNext()) {
-                                               current = more.next();
-                                       } else {
-                                               current = null;
-                                       }
-                               }
-                               knowledge.add(new KnowledgeIterator(type, display));
-                       }
-               } else {
-                       knowledge = null;
-               }
-               // Documents
-               if (ustep.mayContain(Document.class)) {
-                       List<Publication> list = ustep.getAllDocuments();
-
-                       contents = new ArrayList<DocumentFacade>(list.size());
-                       for (Iterator<Publication> i = list.iterator(); i.hasNext();) {
-                               Publication present = i.next();
-                               Long index = present.getIndex();
-                               DocumentFacade facade = docpres.get(index);
-                               if (facade == null) {
-                                       facade = new DocumentFacade(this, present,
-                                                       getProjectSettings(), getPublicationService());
-                                       docpres.put(index, facade);
-                               }
-                               contents.add(facade);
-                       }
-               } else {
-                       contents = null;
-               }
-       }
-
-       /**
-        * Get project settings.
-        * 
-        * @return Project settings service
-        */
-       public ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
-       }
-
-       /**
-        * Get the publicationService.
-        * 
-        * @return the publicationService
-        */
-       public PublicationService getPublicationService() {
-               return _publicationService;
-       }
-
-       /**
-        * Set project settings service.
-        * 
-        * @param projectSettingsService
-        *            project settings service
-        */
-       public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
-       }
-
-       /**
-        * Set the publicationService.
-        * 
-        * @param publicationService
-        *            the publicationService to set
-        */
-       public void setPublicationService(final PublicationService publicationService) {
-               _publicationService = publicationService;
-       }
-
-       /**
-        * Set the menu.
-        * 
-        * @param menu
-        *            the menu to set
-        */
-       public void setMenu(final Menu menu) {
-               this.menu = menu;
-       }
-
-       /**
-        * Get the projectElementService.
-        * 
-        * @return the projectElementService
-        */
-       public ProjectElementService getProjectElementService() {
-               return _projectElementService;
-       }
-
-       /**
-        * Set the projectElementService.
-        * 
-        * @param projectElementService
-        *            the projectElementService to set
-        */
-       public void setProjectElementService(
-                       final ProjectElementService projectElementService) {
-               _projectElementService = projectElementService;
-       }
-
-       /**
-        * Get the knowledgeElementTypeService.
-        * @return the knowledgeElementTypeService
-        */
-       public KnowledgeElementTypeService getKnowledgeElementTypeService() {
-               return _knowledgeElementTypeService;
-       }
-
-       /**
-        * Set the knowledgeElementTypeService.
-        * @param knowledgeElementTypeService the knowledgeElementTypeService to set
-        */
-       public void setKnowledgeElementTypeService(
-                       final KnowledgeElementTypeService knowledgeElementTypeService) {
-               _knowledgeElementTypeService = knowledgeElementTypeService;
-       }
-
-       /**
-        * Get the applicationSettings.
-        * @return the applicationSettings
-        */
-       public ApplicationSettings getApplicationSettings() {
-               return _applicationSettings;
-       }
-
-       /**
-        * Set the applicationSettings.
-        * @param applicationSettings the applicationSettings to set
-        */
-       public void setApplicationSettings(final ApplicationSettings applicationSettings) {
-               _applicationSettings = applicationSettings;
-       }
-}
\ No newline at end of file
index 0769013e3bbae45424fd58d3ac7e04e2e8de4fd9..47f1a00900a425218927e537c48a2e4f7cb37646 100644 (file)
@@ -40,7 +40,7 @@ import org.splat.som.StudyRights;
 import org.splat.util.BeanHelper;
 import org.splat.wapp.ToolBar;
 
-public class OpenStudy extends OpenObject implements OpenStudyServices {
+public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
 
        /**
         * Serial version ID.
@@ -48,8 +48,14 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        protected final static Logger LOGGER = org.splat.simer.Action.LOG;
 
        private transient Study _mystudy;
-       private transient StudyRights _urightstudy; // User rights on the open study
-       private transient StepRights _urightstep; // User rights on the selected step
+       /**
+        * User rights on the open study.
+        */
+       private transient StudyRights _urightstudy;
+       /**
+        * User rights on the selected step.
+        */
+       private transient StepRights _urightstep;
        private transient String _version;
        private transient String _credate;
        private transient String _lasdate;
@@ -96,41 +102,41 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                Revision.Format verstring = new Revision.Format(getProjectSettings()
                                .getRevisionPattern());
 
-               cuser = user; // May be null if nobody connected
+               _cuser = user; // May be null if nobody connected
                _mystudy = study;
-               selection = "0.1"; // Default selection
+               _selection = "0.1"; // Default selection
                _selecdoc = null;
 
                // Preparation of the display
                _version = verstring.format(_mystudy.getVersion());
                _credate = datstring.format(_mystudy.getDate());
                _lasdate = ""; // Not yet supported
-               description = _mystudy.getDescription();
-               involving = new ArrayList<Step>(1);
-               context = new ArrayList<SimulationContextFacade>();
-               ustep = getProjectElementService().getFirstStep(_mystudy);
-               ustep.setActor(cuser);
-               involving.add(ustep);
-               for (Iterator<SimulationContext> i = ustep.getAllSimulationContexts()
+               _description = _mystudy.getDescription();
+               _involving = new ArrayList<Step>(1);
+               _context = new ArrayList<SimulationContextFacade>();
+               _ustep = getProjectElementService().getFirstStep(_mystudy);
+               _ustep.setActor(_cuser);
+               _involving.add(_ustep);
+               for (Iterator<SimulationContext> i = _ustep.getAllSimulationContexts()
                                .iterator(); i.hasNext();) {
-                       context.add(new SimulationContextFacade(i.next(),
+                       _context.add(new SimulationContextFacade(i.next(),
                                        getProjectSettings().getAllSteps()));
                }
-               if (getStudyService().isStaffedBy(_mystudy, cuser)
-                               || getStudyService().hasActor(_mystudy, cuser)) {
+               if (getStudyService().isStaffedBy(_mystudy, _cuser)
+                               || getStudyService().hasActor(_mystudy, _cuser)) {
                        // 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(
+                       /* else */_popup = getApplicationSettings().getPopupMenu(
                                        "steditable");
-                       popup.setContext("study", new StudyRights(cuser, _mystudy));
+                       _popup.setContext("study", new StudyRights(_cuser, _mystudy));
                }
-               _urightstudy = new StudyRights(cuser, _mystudy);
-               _urightstep = new StepRights(cuser, ustep);
+               _urightstudy = new StudyRights(_cuser, _mystudy);
+               _urightstep = new StepRights(_cuser, _ustep);
 
                // RKV menu = new StudyMenu(mystudy);
-               menu = (getMenu()).init(_mystudy); // RKV
-               menu.selects(selection); // Initializes menu items to be displayed
+               _menu = (getMenu()).init(_mystudy); // RKV
+               _menu.selects(_selection); // Initializes menu items to be displayed
                setupContents(); // Initializes documents and knowledge at ustep
                return this;
        }
@@ -153,11 +159,11 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
 
        @Override
        public StudyMenu getMenu() {
-               return (StudyMenu) menu;
+               return (StudyMenu) _menu;
        }
 
        public void setMenu(final StudyMenu aMenu) {
-               menu = aMenu;
+               _menu = aMenu;
        }
 
        public ProgressState getProgressState() {
@@ -289,7 +295,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                                String path = docurl.substring(prefix.length());
                                Document value = getDocumentService().getDocumentByPath(path);
 
-                               _selecdoc = ustep.getDocument(value.getIndex());
+                               _selecdoc = _ustep.getDocument(value.getIndex());
                        } catch (Exception error) {
                                LOGGER.error("Reason:", error);
                        }
@@ -297,16 +303,16 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        }
 
        public void setSelection(final String step) {
-               if (!step.equals(selection)) {
-                       selection = step;
+               if (!step.equals(_selection)) {
+                       _selection = step;
                        _selecdoc = null;
                        setupPreviousToSelectedSteps();
                        updateSimulationContexts(); // Initializes contexts according to the selected steps
                }
-               ustep = involving.get(involving.size() - 1);
-               _urightstep = new StepRights(cuser, ustep);
-               ustep.setActor(cuser);
-               menu.selects(selection); // Updates menu items to be displayed
+               _ustep = _involving.get(_involving.size() - 1);
+               _urightstep = new StepRights(_cuser, _ustep);
+               _ustep.setActor(_cuser);
+               _menu.selects(_selection); // Updates menu items to be displayed
                setupContents(); // The contents may have changed even if the selection is the same
        }
 
@@ -317,10 +323,10 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        protected void add(final Publication doc) {
                DocumentFacade facade = new DocumentFacade(this, doc,
                                getProjectSettings(), getPublicationService());
-               boolean first = (contents.size() == 0);
+               boolean first = (_contents.size() == 0);
 
                docpres.put(doc.getIndex(), facade);
-               contents.add(0, facade); // Prepend the new publication
+               _contents.add(0, facade); // Prepend the new publication
                if (first) {
                        this.getMenu().refreshSelectedItem();
                }
@@ -331,7 +337,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                SimulationContextFacade facade = new SimulationContextFacade(contex,
                                getProjectSettings().getAllSteps());
 
-               context.add(facade);
+               _context.add(facade);
        }
 
        protected void add(final KnowledgeElement kelm) {
@@ -341,7 +347,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                // Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
                // RKV:Begin: Find a knowledge iterator for appropriate knowledge type
                KnowledgeIterator known = null;
-               for (KnowledgeIterator aKnowledgeSection : knowledge) {
+               for (KnowledgeIterator aKnowledgeSection : _knowledge) {
                        if (aKnowledgeSection.getIndex().equals(
                                        String.valueOf(kelm.getType().getIndex()))) {
                                known = aKnowledgeSection;
@@ -350,12 +356,12 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                }
                if (known != null) { // RKV:End
                        knowpres.put(kelm.getIndex(), facade);
-                       known.list.add(facade); // Insert the new knowledge at the end of the corresponding knowledge type
+                       known._list.add(facade); // Insert the new knowledge at the end of the corresponding knowledge type
                }
        }
 
        protected void remove(final Publication doctag) {
-               for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
+               for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
                        DocumentFacade facade = i.next();
                        if (!facade.isFacadeOf(doctag)) {
                                continue;
@@ -363,28 +369,28 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                        i.remove();
                        break;
                }
-               if (contents.size() == 0) {
+               if (_contents.size() == 0) {
                        this.getMenu().refreshSelectedItem();
                }
        }
 
        protected void changeUser(final User user) {
-               cuser = user;
-               popup = null;
-               if (getStudyService().isStaffedBy(_mystudy, cuser)) {
-                       popup = getApplicationSettings().getPopupMenu("steditable");
-                       popup.setContext("study", new StudyRights(cuser, _mystudy));
+               _cuser = user;
+               _popup = null;
+               if (getStudyService().isStaffedBy(_mystudy, _cuser)) {
+                       _popup = getApplicationSettings().getPopupMenu("steditable");
+                       _popup.setContext("study", new StudyRights(_cuser, _mystudy));
                }
                // ustep = getProjectElementService().getFirstStep(mystudy);
-               if (ustep != null) {
-                       ustep.setActor(cuser);
+               if (_ustep != null) {
+                       _ustep.setActor(_cuser);
                }
-               _urightstudy = new StudyRights(cuser, _mystudy);
-               _urightstep = new StepRights(cuser, ustep);
+               _urightstudy = new StudyRights(_cuser, _mystudy);
+               _urightstep = new StepRights(_cuser, _ustep);
        }
 
        protected void remove(final SimulationContext contex) {
-               for (Iterator<SimulationContextFacade> i = context.iterator(); i
+               for (Iterator<SimulationContextFacade> i = _context.iterator(); i
                                .hasNext();) {
                        SimulationContextFacade facade = i.next();
                        if (!facade.isFacadeOf(contex)) {
@@ -396,11 +402,11 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        }
 
        protected void remove(final KnowledgeElement kelm) {
-               KnowledgeIterator known = knowledge.get((int) (kelm.getType()
+               KnowledgeIterator known = _knowledge.get((int) (kelm.getType()
                                .getIndex() - 2));
                // Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
                knowpres.remove(kelm.getIndex());
-               for (Iterator<KnowledgeElementFacade> i = known.list.iterator(); i
+               for (Iterator<KnowledgeElementFacade> i = known._list.iterator(); i
                                .hasNext();) {
                        KnowledgeElementFacade facade = i.next();
                        if (!facade.isFacadeOf(BeanHelper.copyBean(kelm,
@@ -427,11 +433,11 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        }
 
        protected void updateSimulationContexts() {
-               context.clear();
-               for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
+               _context.clear();
+               for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
                        for (Iterator<SimulationContext> j = i.next()
                                        .getAllSimulationContexts().iterator(); j.hasNext();) {
-                               context.add(new SimulationContextFacade(j.next(),
+                               _context.add(new SimulationContextFacade(j.next(),
                                                getProjectSettings().getAllSteps()));
                        }
                }
@@ -442,13 +448,13 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        // ==============================================================================================================================
 
        private void setupPreviousToSelectedSteps() {
-               String[] item = selection.split("\\x2E");
+               String[] item = _selection.split("\\x2E");
                int major = Integer.valueOf(item[0]);
                int minor = Integer.valueOf(item[1]);
                int base = minor;
                Step[] step;
 
-               involving.clear();
+               _involving.clear();
                if (major > 0) {
                        Scenario[] branch = _mystudy.getScenarii();
                        Scenario scenar = branch[0];
@@ -461,7 +467,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                        step = getProjectElementService().getSteps(scenar);
                        base = step[0].getNumber() - 1;
                        for (int i = 0; i + base < minor; i++) {
-                               involving.add(step[i]);
+                               _involving.add(step[i]);
                        }
                }
                step = getProjectElementService().getSteps(_mystudy);
@@ -470,7 +476,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                        if (firstep.getNumber() > base) {
                                continue;
                        }
-                       involving.add(0, firstep);
+                       _involving.add(0, firstep);
                }
        }
 
diff --git a/Workspace/Siman/src/org/splat/simer/SearchBaseAction.java b/Workspace/Siman/src/org/splat/simer/SearchBaseAction.java
deleted file mode 100644 (file)
index 7db86ad..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-package org.splat.simer;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.splat.kernel.InvalidPropertyException;
-import org.splat.kernel.Name;
-import org.splat.dal.bo.kernel.User;
-import org.splat.som.ApplicationRights;
-import org.splat.service.SimulationContextService;
-import org.splat.service.UserService;
-import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.dto.Proxy;
-import org.splat.dal.bo.som.SimulationContext;
-import org.splat.dal.bo.som.SimulationContextType;
-
-public abstract class SearchBaseAction extends Action {
-
-       /**
-        * Serial version ID.
-        */
-       private static final long serialVersionUID = 7863055790228544510L;
-
-       protected String ctype = null; // Context type index, when selected
-       protected String cvalue = null; // Context value index, when selected
-       protected String cindex = ""; // Context index, when removed
-       protected String author = null;
-       protected List<Name> manager = null;
-       protected SimulationContextType newtype; // Context type to be valued
-       protected List<SimulationContext> newvalue; // Context value to be selected
-       protected List<SimulationContextType> critext; // Addable context types
-       protected List<SimulationContext> context; // Current contexts search criteria
-       protected List<Proxy> result;
-       /**
-        * Injected simulation context service.
-        */
-       private SimulationContextService _simulationContextService;
-
-       /**
-        * Injected user service.
-        */
-       private UserService _userService;
-
-       enum UserAction {
-               refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
-       }
-
-       // ==============================================================================================================================
-       // Action methods
-       // ==============================================================================================================================
-
-       public String doSubmitForm() {
-               // Identification of the user action
-               UserAction action = UserAction.refreshResult;
-               if (ctype != null && Integer.valueOf(ctype) > 0)
-                       action = UserAction.selectContextType;
-               else if (cvalue != null && Integer.valueOf(cvalue) > 0)
-                       action = UserAction.selectContextValue;
-               else if (cindex.length() > 0) {
-                       int index = Integer.valueOf(cindex);
-                       if (index > 0)
-                               action = UserAction.removeContext;
-                       else if (index < 0)
-                               action = UserAction.cancelSelect;
-               }
-               // Execution of the user action
-               String done;
-               try {
-                       saveFilter(); // Also reinitializes the form, if needed
-
-                       if (action == UserAction.selectContextType) {
-                               done = doSelectContextType();
-                       } else if (action == UserAction.selectContextValue) {
-                               done = doAddContext();
-                       } else if (action == UserAction.removeContext) {
-                               done = doRemoveContext();
-                       } else if (action == UserAction.cancelSelect) {
-                               done = doCancel();
-                       } else { // UserAction.refreshResult
-                               done = doSearch();
-                               setContextTypeOptions(getInvolvedContexts()); // Done in other do functions, when required
-                       }
-                       setCandidates();
-                       return done;
-               } catch (Exception error) {
-                       // No need to roll back the transaction as it is read only
-                       LOG.error("Reason: ", error);
-                       return ERROR;
-               }
-       }
-
-       @SuppressWarnings("unchecked")
-       protected String doSelectContextType() {
-               SimulationContext.Properties sprop = new SimulationContext.Properties();
-
-               newtype = getSimulationContextService().selectType(
-                               Integer.valueOf(ctype));
-               newvalue = getSimulationContextService().selectSimulationContextsWhere(
-                               sprop.setType(newtype));
-               if (cindex.length() > 0 && Integer.valueOf(cindex) == 0)
-                       getSession().remove("search.result");
-               else
-                       result = (List<Proxy>) getSession().get("search.result"); // We keep the previous result search, if valid
-               return "selectype";
-       }
-
-       protected String doAddContext() {
-               SimulationContext selected = getSimulationContextService()
-                               .selectSimulationContext(Integer.valueOf(cvalue));
-
-               context.add(selected);
-               setContextTypeOptions(getInvolvedContexts()); // Sets critext
-               getSession().remove("search.result"); // The current result is obsolete
-               return "refresh";
-       }
-
-       protected String doRemoveContext() {
-               int index = Integer.valueOf(cindex);
-               for (Iterator<SimulationContext> selected = context.iterator(); selected
-                               .hasNext();) {
-                       if (selected.next().getIndex() == index) {
-                               selected.remove();
-                               break;
-                       }
-               }
-               setContextTypeOptions(getInvolvedContexts()); // Sets critext
-               getSession().remove("search.result"); // The current result is obsolete
-               return "refresh";
-       }
-
-       @SuppressWarnings("unchecked")
-       protected String doCancel() {
-               result = (List<Proxy>) getSession().get("search.result"); // Current result search
-               setContextTypeOptions(getInvolvedContexts()); // Sets critext
-               return "refresh";
-       }
-
-       // ==============================================================================================================================
-       // Getters
-       // ==============================================================================================================================
-
-       public String getAuthor() {
-               return author;
-       }
-
-       public List<Name> getCandidates() {
-               return manager;
-       }
-
-       public List<SimulationContextType> getContextTypeOptions() {
-               return critext;
-       }
-
-       public List<SimulationContext> getContextValueOptions() {
-               return newvalue;
-       }
-
-       public SimulationContextType getSelectedContextType() {
-               return newtype;
-       }
-
-       public List<SimulationContext> getSimulationContexts() {
-               return context;
-       }
-
-       public List<Proxy> getResult() {
-               return result;
-       }
-
-       // ==============================================================================================================================
-       // Setters
-       // ==============================================================================================================================
-
-       public void setAuthor(String index) {
-               this.author = index;
-       }
-
-       public void setContextType(String type) {
-               this.ctype = type;
-       }
-
-       public void setContextValue(String value) {
-               this.cvalue = value;
-       }
-
-       public void setContextIndex(String value) {
-               this.cindex = value;
-       }
-
-       protected void setCandidates() {
-               manager = new Vector<Name>();
-               List<User> users = getUserService().selectAllUsers();
-               User me = getConnectedUser(); // May be null
-               for (Iterator<User> i = users.iterator(); i.hasNext();) {
-                       User next = i.next();
-                       ApplicationRights he = new ApplicationRights(next);
-                       if (he.canCreateStudy()) {
-                               if (next.equals(me))
-                                       manager.add(0, new ValidationFacade.ByManager(me));
-                               else
-                                       manager.add(next);
-                       }
-               }
-       }
-
-       protected void setContextTypeOptions(List<SimulationContextType> critext) {
-               for (Iterator<SimulationContext> i = context.iterator(); i.hasNext();) {
-                       critext.remove(i.next().getType()); // Already used context type
-               }
-               // Ordering by alphabetical order of localized context types
-               SimulationContextType[] types = critext
-                               .toArray(new SimulationContextType[critext.size()]);
-               ContextTypeComparator compare = new ContextTypeComparator();
-               ProjectSettingsService.Step step = getSimulationContextService()
-                               .getAttachedStep(types[0]);
-               int from = 0;
-               int to = 0;
-               while (to < types.length - 1) {
-                       to += 1;
-                       if (types[to].isAttachedTo(step))
-                               continue;
-
-                       if (to > from + 1)
-                               Arrays.sort(types, from, to, compare);
-                       from = to;
-                       step = getSimulationContextService().getAttachedStep(types[to]);
-               }
-               if (to > from)
-                       Arrays.sort(types, from, to + 1, compare);
-               this.critext = Arrays.asList(types);
-       }
-
-       // ==============================================================================================================================
-       // Abstract services
-       // ==============================================================================================================================
-
-       protected abstract String doSearch() throws InvalidPropertyException;
-
-       protected abstract List<SimulationContextType> getInvolvedContexts();
-
-       protected abstract void loadFilter();
-
-       protected abstract void saveFilter();
-
-       /**
-        * Get the simulationContextService.
-        * 
-        * @return the simulationContextService
-        */
-       public SimulationContextService getSimulationContextService() {
-               return _simulationContextService;
-       }
-
-       /**
-        * Set the simulationContextService.
-        * 
-        * @param simulationContextService
-        *            the simulationContextService to set
-        */
-       public void setSimulationContextService(
-                       SimulationContextService simulationContextService) {
-               _simulationContextService = simulationContextService;
-       }
-
-       /**
-        * Get the userService.
-        * @return the userService
-        */
-       public UserService getUserService() {
-               return _userService;
-       }
-
-       /**
-        * Set the userService.
-        * @param userService the userService to set
-        */
-       public void setUserService(UserService userService) {
-               _userService = userService;
-       }
-}
\ No newline at end of file
index 0720eae6b0dc76286fc8bb67d50175ee02c16c56..0ef7fc9bbe7f8a2a47951054b79b7f88c2be5f86 100644 (file)
@@ -3,36 +3,60 @@ package org.splat.simer;
 import java.util.List;
 import java.util.Map;
 
-import org.splat.kernel.InvalidPropertyException;
 import org.splat.dal.bo.kernel.User;
-import org.splat.service.KnowledgeElementTypeService;
-import org.splat.service.SearchService;
-import org.splat.service.SimulationContextService;
-import org.splat.service.UserService;
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.KnowledgeElementType;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.dal.bo.som.Visibility;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.KnowledgeElementTypeService;
+import org.splat.service.SearchService;
+import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
 
 /**
  * Action for searching a knowledge in the database.
  */
-public class SearchKnowledgeAction extends SearchBaseAction {
+public class SearchKnowledgeAction extends AbstractSearchBaseAction {
 
        /**
         * Serial version ID.
         */
        private static final long serialVersionUID = -3104321907432838476L;
 
-       private String visibility = null; // "Private", "Public", "All"
-       private String typid = null; // Knowledge type index when among all
-       private String matchamong = null; // "all" or "any"
-       private String matcontext = null; // "all" or "any"
-       private String refid = null; // Knowledge reference when among ref
-       private String words = null; // Full text search words
-       private List<KnowledgeElementType> types; // Available knowledge types filter (initialized below)
+       /**
+        * "Private", "Public", "All".
+        */
+       private String _visibility = null;
+       /**
+        * Knowledge type index when among all.
+        */
+       private String _state = null;
+       /**
+        * Criteria match: "all" or "any".
+        */
+       private String _criteriaMatch = null;
+       /**
+        * Simulation context match: "all" or "any".
+        */
+       private String _contextMatch = null;
+       /**
+        * Knowledge reference when among ref.
+        */
+       private String _reference = null;
+       /**
+        * Full text search words.
+        */
+       private String _words = null;
+       /**
+        * Available knowledge types filter (initialized below).
+        */
+       private transient List<KnowledgeElementType> _knowledgeTypes;
+       /**
+        * Injected search service.
+        */
        private SearchService _searchService;
        /**
         * Injected simulation context service.
@@ -82,71 +106,76 @@ public class SearchKnowledgeAction extends SearchBaseAction {
                setLeftMenuProperty("open");
                initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
                
+               String res = SUCCESS;
                try {
                        loadFilter();
                        doSearch();
 
                        // Final initialization of the form
-                       types = getKnowledgeElementTypeService().selectTypesWhere(
+                       _knowledgeTypes = getKnowledgeElementTypeService().selectTypesWhere(
                                        ProgressState.APPROVED);
                        setCandidates();
                        setContextTypeOptions(getInvolvedContexts());
-
-                       return SUCCESS;
                } catch (Exception error) {
                        // No need to roll back the transaction as it is read only
                        LOG.error("Reason: ", error);
-                       return ERROR;
+                       res = ERROR;
                }
+               return res;
        }
 
+       @Override
        protected String doSearch() throws InvalidPropertyException {
                // ----------------------------
                setMenuProperty("open");
                initializationScreenContext(_menuProperty);
                
                Map<String, Object> session = getSession();
-               User user = getConnectedUser();
 
                KnowledgeElement.Properties sprop = new KnowledgeElement.Properties();
 
                // Search matching all criteria
                sprop.setType(getKnowledgeElementTypeService().selectType(
-                               Integer.valueOf(typid)));
-               if (words.length() > 0)
-                       sprop.setTitle(words);
-               if (refid.length() > 0)
-                       sprop.setReference(refid);
-               if (context.size() > 0)
-                       sprop.setSimulationContexts(context);
-               int index = Integer.valueOf(author);
+                               Integer.valueOf(_state)));
+               if (_words.length() > 0) {
+                       sprop.setTitle(_words);
+               }
+               if (_reference.length() > 0) {
+                       sprop.setReference(_reference);
+               }
+               if (_context.size() > 0) {
+                       sprop.setSimulationContexts(_context);
+               }
+               int index = Integer.valueOf(_author);
                if (index > 0) {
                        User him = getUserService().selectUser(index);
                        sprop.setAuthor(him);
                }
                // Set of the visibility
-               if (visibility.equals("all")) {
+               if ("all".equals(_visibility)) {
                        KnowledgeElement.Properties other = sprop.copy();
 
                        other.setVisibility(Visibility.PUBLIC);
                        sprop.setVisibility(Visibility.PRIVATE);
-                       sprop.setActor(user);
+                       sprop.setActor(getConnectedUser());
 
-                       result = getSearchService().selectKnowledgeElementsWhere(sprop,
+                       _result = getSearchService().selectKnowledgeElementsWhere(sprop,
                                        other);
                } else {
-                       Visibility reparea = null;
-                       if (visibility.equals("onlypublic"))
+                       Visibility reparea;
+                       if ("onlypublic".equals(_visibility)) {
                                reparea = Visibility.PUBLIC;
-                       else
-                               reparea = Visibility.valueOf(visibility);
+                       } else {
+                               reparea = Visibility.valueOf(_visibility);
+                       }
                        sprop.setVisibility(reparea);
-                       if (reparea == Visibility.PRIVATE)
-                               sprop.setActor(user);
+                       if (reparea == Visibility.PRIVATE) {
+                               sprop.setActor(getConnectedUser());
+                       }
 
-                       result = getSearchService().selectKnowledgeElementsWhere(sprop);
+                       _result = getSearchService().selectKnowledgeElementsWhere(sprop);
                }
-               session.put("search.result", result); // For redisplaying the page without re-executing the search
+               session.put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
                return "refresh";
        }
 
@@ -156,82 +185,84 @@ public class SearchKnowledgeAction extends SearchBaseAction {
 
        public String getContextMatch() {
                // --------------------------------
-               return matcontext;
+               return _contextMatch;
        }
 
        public String getCriteriaMatch() {
                // ---------------------------------
-               return matchamong;
+               return _criteriaMatch;
        }
 
        public List<KnowledgeElementType> getKnowledgeTypes() {
                // ------------------------------------------------------
-               return types;
+               return _knowledgeTypes;
        }
 
        public String getReference() {
                // -----------------------------
-               return refid;
+               return _reference;
        }
 
        public String getState() {
                // ------------------------
-               return typid;
+               return _state;
        }
 
        public String getVisibility() {
                // ------------------------------
-               return visibility;
+               return _visibility;
        }
 
        public String getWords() {
                // -------------------------
-               return words;
+               return _words;
        }
 
        // ==============================================================================================================================
        // Setters
        // ==============================================================================================================================
 
-       public void setContextMatch(String value) {
+       public void setContextMatch(final String value) {
                // ------------------------------------------
-               this.matcontext = value;
+               this._contextMatch = value;
        }
 
-       public void setCriteriaMatch(String value) {
+       public void setCriteriaMatch(final String value) {
                // -------------------------------------------
-               this.matchamong = value;
+               this._criteriaMatch = value;
        }
 
-       public void setReference(String value) {
+       public void setReference(final String value) {
                // ---------------------------------------
-               this.refid = value;
+               this._reference = value;
        }
 
-       public void setState(String value) {
+       public void setState(final String value) {
                // ----------------------------------
-               this.typid = value;
+               this._state = value;
        }
 
-       public void setVisibility(String value) {
+       public void setVisibility(final String value) {
                // ----------------------------------------
-               this.visibility = value;
+               this._visibility = value;
        }
 
-       public void setWords(String value) {
+       public void setWords(final String value) {
                // -----------------------------------
-               this.words = value;
+               this._words = value;
        }
 
        // ==============================================================================================================================
        // Implementation of abstract services
        // ==============================================================================================================================
 
+       @Override
        protected List<SimulationContextType> getInvolvedContexts() {
                // ------------------------------------------------------------
                return getSimulationContextService().selectAllTypes();
        }
 
+       @Override
        @SuppressWarnings("unchecked")
        protected void loadFilter() {
                // ----------------------------
@@ -240,20 +271,21 @@ public class SearchKnowledgeAction extends SearchBaseAction {
                Map<String, Object> filter = (Map<String, Object>) session
                                .get("knowledge.filter"); // A default filter is supposed being set at start
 
-               visibility = (String) filter.get("visibility");
-               matchamong = (String) filter.get("matchamong");
-               matcontext = (String) filter.get("matcontext");
-               typid = (String) filter.get("type");
-               author = (String) filter.get("author");
-               refid = (String) filter.get("reference");
-               words = (String) filter.get("title");
-               context = (List<SimulationContext>) filter.get("context");
+               _visibility = (String) filter.get("visibility");
+               _criteriaMatch = (String) filter.get("matchamong");
+               _contextMatch = (String) filter.get("matcontext");
+               _state = (String) filter.get("type");
+               _author = (String) filter.get("author");
+               _reference = (String) filter.get("reference");
+               _words = (String) filter.get("title");
+               _context = (List<SimulationContext>) filter.get("context");
 
                if (user == null) {
-                       visibility = "onlypublic";
+                       _visibility = "onlypublic";
                }
        }
 
+       @Override
        @SuppressWarnings("unchecked")
        protected void saveFilter() {
                // ----------------------------
@@ -261,18 +293,18 @@ public class SearchKnowledgeAction extends SearchBaseAction {
                Map<String, Object> filter = (Map<String, Object>) session
                                .get("knowledge.filter"); // A default filter is supposed being set at start
 
-               filter.put("visibility", this.visibility);
-               filter.put("matchamong", this.matchamong);
-               filter.put("matcontext", this.matcontext);
-               filter.put("type", this.typid);
-               filter.put("author", this.author);
+               filter.put("visibility", this._visibility);
+               filter.put("matchamong", this._criteriaMatch);
+               filter.put("matcontext", this._contextMatch);
+               filter.put("type", this._state);
+               filter.put("author", this._author);
                filter.put("reference", "");
-               filter.put("title", this.words);
+               filter.put("title", this._words);
 
-               context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
+               _context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
 
                // Initialization required by all do functions
-               types = getKnowledgeElementTypeService().selectTypesWhere(ProgressState.APPROVED);
+               _knowledgeTypes = getKnowledgeElementTypeService().selectTypesWhere(ProgressState.APPROVED);
        }
 
        /**
@@ -290,7 +322,7 @@ public class SearchKnowledgeAction extends SearchBaseAction {
         * @param searchService
         *            the searchService to set
         */
-       public void setSearchService(SearchService searchService) {
+       public void setSearchService(final SearchService searchService) {
                _searchService = searchService;
        }
 
@@ -299,6 +331,7 @@ public class SearchKnowledgeAction extends SearchBaseAction {
         * 
         * @return the simulationContextService
         */
+       @Override
        public SimulationContextService getSimulationContextService() {
                return _simulationContextService;
        }
@@ -309,8 +342,9 @@ public class SearchKnowledgeAction extends SearchBaseAction {
         * @param simulationContextService
         *            the simulationContextService to set
         */
+       @Override
        public void setSimulationContextService(
-                       SimulationContextService simulationContextService) {
+                       final SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
 
@@ -330,7 +364,7 @@ public class SearchKnowledgeAction extends SearchBaseAction {
         *            the knowledgeElementTypeService to set
         */
        public void setKnowledgeElementTypeService(
-                       KnowledgeElementTypeService knowledgeElementTypeService) {
+                       final KnowledgeElementTypeService knowledgeElementTypeService) {
                _knowledgeElementTypeService = knowledgeElementTypeService;
        }
 
@@ -338,6 +372,7 @@ public class SearchKnowledgeAction extends SearchBaseAction {
         * Get the userService.
         * @return the userService
         */
+       @Override
        public UserService getUserService() {
                return _userService;
        }
@@ -346,7 +381,8 @@ public class SearchKnowledgeAction extends SearchBaseAction {
         * Set the userService.
         * @param userService the userService to set
         */
-       public void setUserService(UserService userService) {
+       @Override
+       public void setUserService(final UserService userService) {
                _userService = userService;
        }
        
@@ -362,7 +398,7 @@ public class SearchKnowledgeAction extends SearchBaseAction {
         * Set the menuProperty.
         * @param menuProperty the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
        
index f752eb3a70a837dbdedaf514e05eff79a6dc9a11..766971abfa3fded3a78e7fbca56e3e9a08a8bbcf 100644 (file)
@@ -3,35 +3,51 @@ package org.splat.simer;
 import java.util.List;
 import java.util.Map;
 
-import org.splat.kernel.InvalidPropertyException;
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.ProgressState;
-import org.splat.service.SearchService;
-import org.splat.service.SimulationContextService;
-import org.splat.service.UserService;
-import org.splat.service.technical.ProjectSettingsService;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.Visibility;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.SearchService;
+import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
+import org.splat.service.technical.ProjectSettingsService;
 
 /**
  * Search studies form action.
- *
- * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
-public class SearchStudyAction extends SearchBaseAction {
-
-       private String visibility = null; // "Private", "Public", "All"
-       private String state = null; // "In-Work", "In-Draft", "In-Check"...
-       private String matchamong = null; // "all" or "any"
-       private String matcontext = null; // "all" or "any"
-       private String refid = null; // Study reference
-       private String words = null; // Full text search words
+public class SearchStudyAction extends AbstractSearchBaseAction {
+
+       /**
+        * "Private", "Public", "All".
+        */
+       private String _visibility = null;
+       /**
+        * "In-Work", "In-Draft", "In-Check"...
+        */
+       private String _state = null;
+       /**
+        * Criteria match: "all" or "any".
+        */
+       private String _criteriaMatch = null;
+       /**
+        * Simulation context match: "all" or "any".
+        */
+       private String _contextMatch = null;
+       /**
+        * Study reference.
+        */
+       private String _reference = null;
+       /**
+        * Full text search words.
+        */
+       private String _words = null;
        /**
         * Injected project settings service.
         */
-       private ProjectSettingsService _projectSettingsService;
+       private ProjectSettingsService _projectSettings;
        /**
         * Injected search service.
         */
@@ -81,6 +97,7 @@ public class SearchStudyAction extends SearchBaseAction {
         * @return SUCCESS if no exception, otherwise return ERROR
         */
        public String doInitialize() {
+               String res = SUCCESS;
                try {
                        loadFilter();
                        doSearch();
@@ -93,8 +110,6 @@ public class SearchStudyAction extends SearchBaseAction {
                        setToolProperty("none");
                        setLeftMenuProperty("open");
                        initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
-
-                       return SUCCESS;
                } catch (Exception error) {
                        // No need to roll back the transaction as it is read only
                        LOG.error("Reason: ", error);
@@ -102,53 +117,62 @@ public class SearchStudyAction extends SearchBaseAction {
                        setMenuProperty("none");
                        initializationScreenContext(_menuProperty);
                        
-                       return ERROR;
+                       res = ERROR;
                }
+               return res;
        }
 
+       /** 
+        * {@inheritDoc}
+        * @see org.splat.simer.AbstractSearchBaseAction#doSearch()
+        */
+       @Override
        protected String doSearch() throws InvalidPropertyException {
-               // ----------------------------
                Map<String, Object> session = getSession();
-               User user = getConnectedUser();
-
                Study.Properties sprop = new Study.Properties();
 
                // Search matching all criteria
-               if (!this.state.equals("ANY"))
-                       sprop.setState(ProgressState.valueOf(this.state));
-               if (words.length() > 0)
-                       sprop.setTitle(words);
-               if (refid.length() > 0)
-                       sprop.setReference(refid);
-               if (context.size() > 0)
-                       sprop.setSimulationContexts(context);
-               int index = Integer.valueOf(author);
+               if (!this._state.equals("ANY")) {
+                       sprop.setState(ProgressState.valueOf(this._state));
+               }
+               if (_words.length() > 0) {
+                       sprop.setTitle(_words);
+               }
+               if (_reference.length() > 0) {
+                       sprop.setReference(_reference);
+               }
+               if (_context.size() > 0) {
+                       sprop.setSimulationContexts(_context);
+               }
+               int index = Integer.valueOf(_author);
                if (index > 0) {
                        User him = getUserService().selectUser(index);
                        sprop.setManager(him);
                }
                // Set of the visibility
-               if (visibility.equals("all")) {
+               if ("all".equals(_visibility)) {
                        Study.Properties other = sprop.copy();
 
                        other.setVisibility(Visibility.PUBLIC);
                        sprop.setVisibility(Visibility.PRIVATE);
-                       sprop.setActor(user);
+                       sprop.setActor(getConnectedUser());
 
-                       result = getSearchService().selectStudiesWhere(sprop, other);
+                       _result = getSearchService().selectStudiesWhere(sprop, other);
                } else {
                        Visibility reparea = null;
-                       if (visibility.equals("onlypublic"))
+                       if ("onlypublic".equals(_visibility)) {
                                reparea = Visibility.PUBLIC;
-                       else
-                               reparea = Visibility.valueOf(visibility);
+                       } else {
+                               reparea = Visibility.valueOf(_visibility);
+                       }
                        sprop.setVisibility(reparea);
-                       if (reparea == Visibility.PRIVATE)
-                               sprop.setActor(user);
+                       if (reparea == Visibility.PRIVATE) {
+                               sprop.setActor(getConnectedUser());
+                       }
 
-                       result = getSearchService().selectStudiesWhere(sprop);
+                       _result = getSearchService().selectStudiesWhere(sprop);
                }
-               session.put("search.result", result); // For redisplaying the page without re-executing the search
+               session.put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
                return "refresh";
        }
 
@@ -157,75 +181,63 @@ public class SearchStudyAction extends SearchBaseAction {
        // ==============================================================================================================================
 
        public String getContextMatch() {
-               // --------------------------------
-               return matcontext;
+               return _contextMatch;
        }
 
        public String getCriteriaMatch() {
-               // ---------------------------------
-               return matchamong;
+               return _criteriaMatch;
        }
 
        public String getReference() {
-               // -----------------------------
-               return refid;
+               return _reference;
        }
 
        public String getState() {
-               // -------------------------
-               return state;
+               return _state;
        }
 
        public String getVisibility() {
-               // ------------------------------
-               return visibility;
+               return _visibility;
        }
 
        public String getWords() {
-               // -------------------------
-               return words;
+               return _words;
        }
 
        // ==============================================================================================================================
        // Setters
        // ==============================================================================================================================
 
-       public void setContextMatch(String value) {
-               // ------------------------------------------
-               this.matcontext = value;
+       public void setContextMatch(final String value) {
+               this._contextMatch = value;
        }
 
-       public void setCriteriaMatch(String value) {
-               // -------------------------------------------
-               this.matchamong = value;
+       public void setCriteriaMatch(final String value) {
+               this._criteriaMatch = value;
        }
 
-       public void setReference(String value) {
-               // ---------------------------------------
-               this.refid = value;
+       public void setReference(final String value) {
+               this._reference = value;
        }
 
-       public void setState(String value) {
-               // -----------------------------------
-               this.state = value;
+       public void setState(final String value) {
+               this._state = value;
        }
 
-       public void setVisibility(String value) {
-               // ----------------------------------------
-               this.visibility = value;
+       public void setVisibility(final String value) {
+               this._visibility = value;
        }
 
-       public void setWords(String value) {
-               // -----------------------------------
-               this.words = value;
+       public void setWords(final String value) {
+               this._words = value;
        }
 
        // ==============================================================================================================================
        // Implementation of abstract services
        // ==============================================================================================================================
 
+       @Override
        protected List<SimulationContextType> getInvolvedContexts() {
-               // ------------------------------------------------------------
                List<ProjectSettingsService.Step> steps = getProjectSettings()
                                .getStepsOf(Study.class);
                ProjectSettingsService.Step[] number = steps
@@ -234,44 +246,44 @@ public class SearchStudyAction extends SearchBaseAction {
                return getSimulationContextService().selectTypesOf(number);
        }
 
+       @Override
        @SuppressWarnings("unchecked")
        protected void loadFilter() {
-               // ----------------------------
                Map<String, Object> session = getSession();
                User user = getConnectedUser();
                Map<String, Object> filter = (Map<String, Object>) session
                                .get("study.filter"); // A default filter is supposed being set at start
 
-               visibility = (String) filter.get("visibility");
-               matchamong = (String) filter.get("matchamong");
-               matcontext = (String) filter.get("matcontext");
-               state = (String) filter.get("state");
-               author = (String) filter.get("author");
-               refid = (String) filter.get("reference");
-               words = (String) filter.get("title");
-               context = (List<SimulationContext>) filter.get("context");
+               _visibility = (String) filter.get("visibility");
+               _criteriaMatch = (String) filter.get("matchamong");
+               _contextMatch = (String) filter.get("matcontext");
+               _state = (String) filter.get("state");
+               _author = (String) filter.get("author");
+               _reference = (String) filter.get("reference");
+               _words = (String) filter.get("title");
+               _context = (List<SimulationContext>) filter.get("context");
 
                if (user == null) {
-                       visibility = "onlypublic";
+                       _visibility = "onlypublic";
                }
        }
 
+       @Override
        @SuppressWarnings("unchecked")
        protected void saveFilter() {
-               // ----------------------------
                Map<String, Object> session = getSession();
                Map<String, Object> filter = (Map<String, Object>) session
                                .get("study.filter"); // A default filter is supposed being set at start
 
-               filter.put("visibility", this.visibility);
-               filter.put("matchamong", this.matchamong);
-               filter.put("matcontext", this.matcontext);
-               filter.put("state", this.state);
-               filter.put("author", this.author);
-               filter.put("reference", this.refid);
-               filter.put("title", this.words);
+               filter.put("visibility", this._visibility);
+               filter.put("matchamong", this._criteriaMatch);
+               filter.put("matcontext", this._contextMatch);
+               filter.put("state", this._state);
+               filter.put("author", this._author);
+               filter.put("reference", this._reference);
+               filter.put("title", this._words);
 
-               context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
+               _context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
 
        }
 
@@ -290,7 +302,7 @@ public class SearchStudyAction extends SearchBaseAction {
         * @param searchService
         *            the searchService to set
         */
-       public void setSearchService(SearchService searchService) {
+       public void setSearchService(final SearchService searchService) {
                _searchService = searchService;
        }
 
@@ -300,7 +312,7 @@ public class SearchStudyAction extends SearchBaseAction {
         * @return Project settings service
         */
        private ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
+               return _projectSettings;
        }
 
        /**
@@ -309,8 +321,8 @@ public class SearchStudyAction extends SearchBaseAction {
         * @param projectSettingsService
         *            project settings service
         */
-       public void setProjectSettings(ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
+       public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
+               _projectSettings = projectSettingsService;
        }
 
        /**
@@ -318,6 +330,7 @@ public class SearchStudyAction extends SearchBaseAction {
         * 
         * @return the simulationContextService
         */
+       @Override
        public SimulationContextService getSimulationContextService() {
                return _simulationContextService;
        }
@@ -328,8 +341,9 @@ public class SearchStudyAction extends SearchBaseAction {
         * @param simulationContextService
         *            the simulationContextService to set
         */
+       @Override
        public void setSimulationContextService(
-                       SimulationContextService simulationContextService) {
+                       final SimulationContextService simulationContextService) {
                _simulationContextService = simulationContextService;
        }
 
@@ -338,6 +352,7 @@ public class SearchStudyAction extends SearchBaseAction {
         * 
         * @return the userService
         */
+       @Override
        public UserService getUserService() {
                return _userService;
        }
@@ -348,7 +363,8 @@ public class SearchStudyAction extends SearchBaseAction {
         * @param userService
         *            the userService to set
         */
-       public void setUserService(UserService userService) {
+       @Override
+       public void setUserService(final UserService userService) {
                _userService = userService;
        }
        
@@ -364,7 +380,7 @@ public class SearchStudyAction extends SearchBaseAction {
         * Set the menuProperty.
         * @param menuProperty the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
        
index 3cd145fe02185072094c5762a13375cc485dc662..1124d3df397f8b3626339643a7d954ae9e0ae980 100644 (file)
@@ -5,89 +5,93 @@ import java.util.List;
 import java.util.ResourceBundle;
 
 import org.splat.dal.bo.som.ProgressState;
-import org.splat.service.technical.ProjectSettingsService;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.service.technical.ProjectSettingsService;
 import org.splat.wapp.PopupMenu;
 
-
 public class SimulationContextFacade {
 
-    private SimulationContext  my;
-    private String             name;
-    private int                step;
-    private ProgressState      state;
-    private PopupMenu          popup;
-
-//  ==============================================================================================================================
-//  Constructor
-//  ==============================================================================================================================
-
-    public SimulationContextFacade (SimulationContext represented, List<ProjectSettingsService.Step> allSteps) {
-//  --------------------------------------------------------------
-      my    = represented;
-      popup = ApplicationSettings.getPopupMenu("scontext");
-
-      SimulationContextType type = my.getType();
-      for (Iterator<ProjectSettingsService.Step> i=allSteps.iterator(); i.hasNext(); ) {
-        ProjectSettingsService.Step   next = i.next();
-       if (!type.isAttachedTo(next)) continue;
-        step = next.getNumber();
-       break;
-      }
-      state = my.getProgressState();                     // inCHECK or APPROVED
-      name  = type.getName();
-      if (type.isApproved()) {
-        name = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale()).getString("type.context." + name);
-      } else {
-        state  = ProgressState.inDRAFT;
-      }
-    }
-
-//  ==============================================================================================================================
-//  Getters
-//  ==============================================================================================================================
-
-    public String getEditIcon () {
-//  ----------------------------
-      return "icon.ed" + state + ".png";
-    }
-    public String getIndex () {
-//  -------------------------
-      return String.valueOf(my.getIndex());
-    }
-    public PopupMenu getPopup () {
-//  ----------------------------
-      popup.setContext("scontext", this);     // Cannot be done at construction because pop-ups are shared
-      return popup;
-    }
-    public String getStateIcon () {
-//  -----------------------------
-      return "icon." + state + ".png";
-    }
-    public String getStepNumber () {
-//  ------------------------------
-      return String.valueOf(step);
-    }
-    public String getTypeName () {
-//  ----------------------------
-      return  name;
-    }
-    public String getValue () {
-//  -------------------------
-      return  my.getValue();
-    }
-
-    public boolean isApproved () {
-//  ----------------------------
-      return (state == ProgressState.APPROVED);
-    }
-    public boolean isEditable () {
-//  ----------------------------
-      return !my.isShared();
-    }
-    public boolean isFacadeOf (SimulationContext represented) {
-//  ---------------------------------------------------------
-      return  my.equals(represented);
-    }
+       private final SimulationContext _my;
+       private String _name;
+       private int _step;
+       private ProgressState _state;
+       private final PopupMenu _popup;
+
+       // ==============================================================================================================================
+       // Constructor
+       // ==============================================================================================================================
+
+       public SimulationContextFacade(final SimulationContext represented,
+                       final List<ProjectSettingsService.Step> allSteps) {
+               _my = represented;
+               _popup = ApplicationSettings.getPopupMenu("scontext");
+
+               SimulationContextType type = _my.getType();
+               for (Iterator<ProjectSettingsService.Step> i = allSteps.iterator(); i
+                               .hasNext();) {
+                       ProjectSettingsService.Step next = i.next();
+                       if (!type.isAttachedTo(next)) {
+                               continue;
+                       }
+                       _step = next.getNumber();
+                       break;
+               }
+               _state = _my.getProgressState(); // inCHECK or APPROVED
+               _name = type.getName();
+               if (type.isApproved()) {
+                       _name = ResourceBundle.getBundle("som",
+                                       ApplicationSettings.getCurrentLocale()).getString(
+                                       "type.context." + _name);
+               } else {
+                       _state = ProgressState.inDRAFT;
+               }
+       }
+
+       // ==============================================================================================================================
+       // Getters
+       // ==============================================================================================================================
+
+       public String getEditIcon() {
+
+               return "icon.ed" + _state + ".png";
+       }
+
+       public String getIndex() {
+               return String.valueOf(_my.getIndex());
+       }
+
+       public PopupMenu getPopup() {
+
+               _popup.setContext("scontext", this); // Cannot be done at construction because pop-ups are shared
+               return _popup;
+       }
+
+       public String getStateIcon() {
+               return "icon." + _state + ".png";
+       }
+
+       public String getStepNumber() {
+               return String.valueOf(_step);
+       }
+
+       public String getTypeName() {
+               return _name;
+       }
+
+       public String getValue() {
+               return _my.getValue();
+       }
+
+       public boolean isApproved() {
+               return (_state == ProgressState.APPROVED);
+       }
+
+       public boolean isEditable() {
+               return !_my.isShared();
+       }
+
+       public boolean isFacadeOf(final SimulationContext represented) {
+               return _my.equals(represented);
+       }
 }
\ No newline at end of file
index 481133fe6aeb3415f18846bbf777c85413e2f6e8..368f1daa20b3ea619c39c643f2f4f5496c169bd3 100644 (file)
@@ -1,4 +1,5 @@
 package org.splat.simer;
+
 /**
  * 
  * @author    Daniel Brunier-Coulin
@@ -11,66 +12,72 @@ import java.util.ResourceBundle;
 import org.splat.dal.bo.som.Timestamp;
 import org.splat.dal.bo.som.ValidationStep;
 
-
 public class StampFacade implements HistoryFacade {
 
-    private String  icon;
-    private String  comment;
-    private String  date;
-    private String  empty;
-    private String  nonicon;
-
-//  ==============================================================================================================================
-//  Constructor
-//  ==============================================================================================================================
-
-    public StampFacade (Timestamp stamp) {
-//  ------------------------------------
-      ResourceBundle    labels  = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale());
-      ResourceBundle    custom  = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
-         SimpleDateFormat  convert = new SimpleDateFormat(custom.getString("date.format"));  // Date display format
-         ValidationStep    type    = stamp.getType();
-
-      nonicon = "image.hold.gif";
-      empty   = "";
-      date    = convert.format(stamp.getDate());
-      comment = labels.getString("label." + type.toString()) + " " + stamp.getAuthor().toString();
-      if      (type == ValidationStep.APPROVAL)  icon = "icon.APPROVED.png";
-      else if (type == ValidationStep.REVIEW)    icon = "icon.inCHECK.png";
-      else if (type == ValidationStep.PROMOTION) icon = "icon.inDRAFT.png";
-      else                                       icon = "icon.inWORK.png";
-    }
-
-//  ==============================================================================================================================
-//  Getters
-//  ==============================================================================================================================
-
-    public String getDate () {
-//  ------------------------
-      return date;
-    }
-    public String getDescription () {
-//  -------------------------------
-      return comment;
-    }
-    public String getFileIcon () {
-//  ----------------------------
-      return icon;
-    }
-    public String getSharingIcon () {
-//  -------------------------------
-      return nonicon;
-    }
-    public String getSize () {
-//  ------------------------
-      return empty;
-    }
-    public String getVersion () {
-//  ---------------------------
-      return empty;
-    }
-    public String getVersioningIcon () {
-//  ----------------------------------
-      return nonicon;
-    }
+       private transient String _icon;
+       private transient final String _comment;
+       private transient final String _date;
+       private transient final String _empty;
+       private transient final String _nonicon;
+
+       // ==============================================================================================================================
+       // Constructor
+       // ==============================================================================================================================
+
+       public StampFacade(final Timestamp stamp) {
+               ResourceBundle labels = ResourceBundle.getBundle("labels",
+                               ApplicationSettings.getCurrentLocale());
+               ResourceBundle custom = ResourceBundle.getBundle("som",
+                               ApplicationSettings.getCurrentLocale());
+               SimpleDateFormat convert = new SimpleDateFormat(custom
+                               .getString("date.format")); // Date display format
+               ValidationStep type = stamp.getType();
+
+               _nonicon = "image.hold.gif";
+               _empty = "";
+               _date = convert.format(stamp.getDate());
+               _comment = labels.getString("label." + type.toString()) + " "
+                               + stamp.getAuthor().toString();
+               if (type == ValidationStep.APPROVAL) {
+                       _icon = "icon.APPROVED.png";
+               } else if (type == ValidationStep.REVIEW) {
+                       _icon = "icon.inCHECK.png";
+               } else if (type == ValidationStep.PROMOTION) {
+                       _icon = "icon.inDRAFT.png";
+               } else {
+                       _icon = "icon.inWORK.png";
+               }
+       }
+
+       // ==============================================================================================================================
+       // Getters
+       // ==============================================================================================================================
+
+       public String getDate() {
+               return _date;
+       }
+
+       public String getDescription() {
+               return _comment;
+       }
+
+       public String getFileIcon() {
+               return _icon;
+       }
+
+       public String getSharingIcon() {
+               return _nonicon;
+       }
+
+       public String getSize() {
+               return _empty;
+       }
+
+       public String getVersion() {
+               return _empty;
+       }
+
+       public String getVersioningIcon() {
+               return _nonicon;
+       }
 }
\ No newline at end of file
index 8eaab0a79053091aaf651cf7b5acb146e044a527..1299731c974d36e7a22d704b853c1dec13047004 100644 (file)
@@ -2,158 +2,178 @@ package org.splat.simer;
 
 import java.util.Map;
 
-import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.struts2.interceptor.ServletRequestAware;
-import org.apache.struts2.util.ServletContextAware;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.splat.som.ApplicationRights;
-import org.splat.dal.dao.som.Database;
 import org.splat.service.technical.ProjectSettingsService;
+import org.splat.som.ApplicationRights;
+import org.splat.wapp.Constants;
 
-
-
+/**
+ * Start application action.
+ */
 public class StartAction extends Action implements ServletRequestAware {
+       /**
+        * Serial version ID.
+        */
+       private static final long serialVersionUID = 5875058140682652964L;
 
-    private HttpServletRequest  request = null;
+       /**
+        * HTTP request.
+        */
+       private transient HttpServletRequest _request = null;
 
-       private ProjectSettingsService _projectSettingsService;
-       private ApplicationSettings _ApplicationSettings;
-       
        /**
-        * Value of the menu property. 
-        * It can be: none, create, open, study, knowledge, sysadmin, help.
+        * Injected project settings service.
+        */
+       private ProjectSettingsService _projectSettings;
+       /**
+        * Injected application settings service.
+        */
+       private ApplicationSettings _applicationSettings;
+
+       /**
+        * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
         */
        private String _menuProperty;
-       
+
        /**
-        * Value of the title bar property. 
-        * It can be: study, knowledge.
+        * Value of the title bar property. It can be: study, knowledge.
         */
        private String _titleProperty;
-       
+
        /**
-        * Property that indicates whether the current open study is editable or not.
-        * On the screen it looks like pen on the status icon, pop-up menu also can be called.
-        * It is necessary for correct building the title bar.
+        * Property that indicates whether the current open study is editable or not. On the screen it looks like pen on the status icon, pop-up
+        * menu also can be called. It is necessary for correct building the title bar.
         */
        private String _editDisabledProperty = "false";
-       
+
        /**
-        * Value of the tool bar property. 
-        * It can be: none, standard, study, back.
+        * Value of the tool bar property. It can be: none, standard, study, back.
         */
        private String _toolProperty;
-       
+
        /**
-        * Value of the left menu property. 
-        * It can be: open, study, knowledge, scenario.
+        * Value of the left menu property. It can be: open, study, knowledge, scenario.
         */
        private String _leftMenuProperty;
 
+       // ==============================================================================================================================
+       // Action execution
+       // ==============================================================================================================================
+
        /**
-        * Serial version ID.
+        * Initialize application.
+        * @return SUCCESS if succeeded, ERROR - if exception is caught
+        */
+       public String doInitialize() {
+               StringBuffer wappurl = _request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
+               String res = SUCCESS;
+               
+               LOG.info(new StringBuffer("Initializing ").append(wappurl)
+                               .append("...").toString());
+               try {
+                       ProjectSettingsService project = getProjectSettings();
+                       ApplicationSettings wapp = getApplicationSettings().init(
+                                       wappurl.toString(), this.getLocale());
+                       String root = wapp.getApplicationRootPath();
+                       LOG.debug("Application root: " + root);
+
+                       // Database configuration
+                       project.configure(root
+                                       + wapp.getApplicationProperty("wapp.configuration"));
+
+                       // Application configuration
+                       System.setProperty("java.security.auth.login.config", root
+                                       + wapp.getApplicationProperty("wapp.login"));
+                       wapp.configure(root
+                                       + wapp.getApplicationProperty("wapp.customization"));
+
+                       // Initialization of the user session
+                       Map<String, Object> session = getSession();
+
+                       session.put("user.rights", new ApplicationRights(null)); // No user connected yet
+                       session.put("study.filter", wapp.getFilter(Constants.STUDY_MENU));
+                       session.put("knowledge.filter", wapp
+                                       .getFilter(Constants.KNOWLEDGE_MENU));
+
+                       setMenuProperty(Constants.NONE);
+                       initializationScreenContext(_menuProperty);
+                       
+               } catch (Exception error) {
+                       LOG.fatal("Reason:", error);
+
+                       setMenuProperty(Constants.STUDY_MENU);
+                       setTitleProperty(Constants.STUDY_MENU);
+                       setEditDisabledProperty("true");
+                       setToolProperty(Constants.NONE);
+                       setLeftMenuProperty(Constants.STUDY_MENU);
+                       initializationFullScreenContext(_menuProperty, _titleProperty,
+                                       _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
+                       res = ERROR;
+               }
+               return res;
+       }
+
+       // ==============================================================================================================================
+       // Setter
+       // ==============================================================================================================================
+
+       /** 
+        * {@inheritDoc}
+        * @see org.splat.simer.Action#setServletRequest(javax.servlet.http.HttpServletRequest)
         */
-       private static final long   serialVersionUID = 5875058140682652964L;
-
-//  ==============================================================================================================================
-//  Action execution
-//  ==============================================================================================================================
-
-       public String doInitialize () throws Exception {
-//  -----------------------------
-//      Session      connex  = Database.getSession();
-//      Transaction  transax = connex.beginTransaction();                
-         StringBuffer wappurl = request.getRequestURL();     // "http://{server}:{port}/{webapp}/", including the leading '/'
-
-      LOG.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
-         try {
-               ProjectSettingsService project = getProjectSettings();
-        ApplicationSettings wapp    = getApplicationSettings().init(wappurl.toString(), this.getLocale());
-        String              root    = wapp.getApplicationRootPath();
-        LOG.debug("Application root: " + root);
-
-//      Database configuration
-               project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
-
-//      Application configuration
-           System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));        
-           wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
-
-//      Initialization of the user session
-               Map<String, Object> session = getSession();
-
-        session.put("user.rights", new ApplicationRights(null) );      // No user connected yet
-               session.put("study.filter",     wapp.getFilter("study"));
-               session.put("knowledge.filter", wapp.getFilter("knowledge"));
-
-//         transax.commit();
-           
-               setMenuProperty("none");
-               initializationScreenContext(_menuProperty);
-           
-           return SUCCESS;
-      }
-      catch (Exception error) {
-        LOG.fatal("Reason:", error);
-        
-        setMenuProperty("study");
-        setTitleProperty("study");
-        setEditDisabledProperty("true");
-        setToolProperty("none");
-        setLeftMenuProperty("study");
-        initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-        
-        return ERROR;
-      }
-       }
-
-//  ==============================================================================================================================
-//  Setter
-//  ==============================================================================================================================
-
-       public void setServletRequest (HttpServletRequest request) {
-//  ----------------------------------------------------------
-      this.request = request;
-       }
-    /**
-     * Get project settings.
+       @Override
+       public void setServletRequest(final HttpServletRequest request) {
+               this._request = request;
+       }
+
+       /**
+        * Get project settings.
+        * 
         * @return Project settings service
         */
        private ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
+               return _projectSettings;
        }
 
        /**
         * Set project settings service.
-        * @param projectSettingsService project settings service
+        * 
+        * @param projectSettingsService
+        *            project settings service
         */
        public void setProjectSettings(
-                       ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
+                       final ProjectSettingsService projectSettingsService) {
+               _projectSettings = projectSettingsService;
        }
 
        /**
         * Get the applicationSettings.
+        * 
         * @return the applicationSettings
         */
+       @Override
        public ApplicationSettings getApplicationSettings() {
-               return _ApplicationSettings;
+               return _applicationSettings;
        }
 
        /**
         * Set the applicationSettings.
-        * @param applicationSettings the applicationSettings to set
+        * 
+        * @param applicationSettings
+        *            the applicationSettings to set
         */
-       public void setApplicationSettings(ApplicationSettings applicationSettings) {
-               _ApplicationSettings = applicationSettings;
+       @Override
+       public void setApplicationSettings(
+                       final ApplicationSettings applicationSettings) {
+               _applicationSettings = applicationSettings;
        }
-       
+
        /**
         * Get the menuProperty.
+        * 
         * @return the menuProperty
         */
        public String getMenuProperty() {
@@ -162,14 +182,17 @@ public class StartAction extends Action implements ServletRequestAware {
 
        /**
         * Set the menuProperty.
-        * @param menuProperty the menuProperty to set
+        * 
+        * @param menuProperty
+        *            the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
-       
+
        /**
         * Get the _titleProperty.
+        * 
         * @return the _titleProperty
         */
        public String getTitleProperty() {
@@ -177,15 +200,18 @@ public class StartAction extends Action implements ServletRequestAware {
        }
 
        /**
-        * Set the _titleProperty.
-        * @param _titleProperty the titleProperty to set
+        * Set the titleProperty.
+        * 
+        * @param titleProperty
+        *            the titleProperty to set
         */
-       public void setTitleProperty(String titleProperty) {
+       public void setTitleProperty(final String titleProperty) {
                _titleProperty = titleProperty;
        }
 
        /**
         * Get the editDisabledProperty.
+        * 
         * @return the editDisabledProperty
         */
        public final String getEditDisabledProperty() {
@@ -194,14 +220,17 @@ public class StartAction extends Action implements ServletRequestAware {
 
        /**
         * Set the editDisabledProperty.
-        * @param editDisabledProperty the editDisabledProperty to set
+        * 
+        * @param editDisabledProperty
+        *            the editDisabledProperty to set
         */
-       public final void setEditDisabledProperty(String editDisabledProperty) {
+       public final void setEditDisabledProperty(final String editDisabledProperty) {
                _editDisabledProperty = editDisabledProperty;
        }
 
        /**
         * Get the toolProperty.
+        * 
         * @return the toolProperty
         */
        public String getToolProperty() {
@@ -210,14 +239,17 @@ public class StartAction extends Action implements ServletRequestAware {
 
        /**
         * Set the toolProperty.
-        * @param toolProperty the toolProperty to set
+        * 
+        * @param toolProperty
+        *            the toolProperty to set
         */
        public void setToolProperty(final String toolProperty) {
                _toolProperty = toolProperty;
        }
-       
+
        /**
         * Get the leftMenuProperty.
+        * 
         * @return the leftMenuProperty
         */
        public String getLeftMenuProperty() {
@@ -226,7 +258,9 @@ public class StartAction extends Action implements ServletRequestAware {
 
        /**
         * Set the leftMenuProperty.
-        * @param leftMenuProperty the leftMenuProperty to set
+        * 
+        * @param leftMenuProperty
+        *            the leftMenuProperty to set
         */
        public void setLeftMenuProperty(final String leftMenuProperty) {
                _leftMenuProperty = leftMenuProperty;
index a3af29809af749b6f722308cb883bd5a12708ea2..be1930da28f744f4ff9dc20238542010390184d9 100644 (file)
@@ -11,6 +11,7 @@ import org.splat.dal.bo.som.Study;
 import org.splat.service.ProjectElementService;
 import org.splat.service.ScenarioService;
 import org.splat.som.Step;
+import org.splat.wapp.Constants;
 import org.splat.wapp.MenuItem;
 import org.splat.wapp.SlidMenu;
 
@@ -70,7 +71,7 @@ public class StudyMenu extends SlidMenu {
         * Default constructor.
         */
        public StudyMenu() {
-               super("activities", "study");
+               super("activities", Constants.STUDY_MENU);
        }
 
        /**
@@ -78,7 +79,7 @@ public class StudyMenu extends SlidMenu {
         * @param context the study
         */
        public StudyMenu(final Study context) {
-               super("activities", "study");
+               super("activities", Constants.STUDY_MENU);
                _study = context;
        }
 
index e38497d8e61d2fb78a28d2b2a597d09defa85f6f..452ee07302469de3ce62ae61ffd16bb128eb1e37 100644 (file)
@@ -120,13 +120,13 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
         */
        public String doInitialize() {
 
-               mystudy = getOpenStudy();
+               _openStudy = getOpenStudy();
                validation = new Vector<ValidationFacade>();
                validefault = null;
                other = getDocumentTypeService().selectResultTypes();
 
-               Study study = mystudy.getStudyObject();
-               StudyRights user = mystudy.getStudyRights();
+               Study study = _openStudy.getStudyObject();
+               StudyRights user = _openStudy.getStudyRights();
                for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
                        DocumentType type = i.next();
                        ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
@@ -150,7 +150,7 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
                setLeftMenuProperty("open");
                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
 
-               if (mystudy.isOpenForWriting() && user.canEditProperties()) {                   
+               if (_openStudy.isOpenForWriting() && user.canEditProperties()) {                        
                        return "edit";
                }
                else {
@@ -162,12 +162,12 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
 //             Session connex = Database.getCurSession();
 //             Transaction transax = connex.beginTransaction();
 
-               mystudy = getOpenStudy();
+               _openStudy = getOpenStudy();
                validation = new Vector<ValidationFacade>();
                validefault = null;
                other = getDocumentTypeService().selectResultTypes();
 
-               Study study = mystudy.getStudyObject();
+               Study study = _openStudy.getStudyObject();
                for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
                        DocumentType type = i.next();
                        ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
@@ -200,12 +200,12 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
 //             Session connex = Database.getCurSession();
 //             Transaction transax = connex.beginTransaction();
 
-               mystudy = getOpenStudy();
+               _openStudy = getOpenStudy();
                validation = new Vector<ValidationFacade>();
                validefault = null;
                other = getDocumentTypeService().selectAllTypes();
 
-               Study study = mystudy.getStudyObject();
+               Study study = _openStudy.getStudyObject();
                for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
                        DocumentType type = i.next();
                        ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
@@ -245,12 +245,12 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
 //             Session connex = Database.getCurSession();
 //             Transaction transax = connex.beginTransaction();
 
-               mystudy = getOpenStudy();
+               _openStudy = getOpenStudy();
                validation = new Vector<ValidationFacade>();
                validefault = null;
                other = getDocumentTypeService().selectResultTypes();
 
-               Study study = mystudy.getStudyObject();
+               Study study = _openStudy.getStudyObject();
                for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
                        DocumentType type = i.next();
                        ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
@@ -383,7 +383,7 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
 
        public User getAuthor() {
                // ------------------------
-               return mystudy.getStudyObject().getAuthor();
+               return _openStudy.getStudyObject().getAuthor();
        }
 
        public List<User> getCandidates() {
@@ -418,7 +418,7 @@ public class StudyPropertiesAction extends DisplayStudyStepAction {
 
        public String getStudyTitle() {
                // ------------------------------
-               return mystudy.getTitle();
+               return _openStudy.getTitle();
        }
 
        public List<ValidationFacade> getValidations() {
index 34c665dc0fa5bd15c22a3bcd30b3dfb0379045c6..ba40df6460c2a8fd7c5bce49772b6014b001a8ab 100644 (file)
@@ -2,114 +2,127 @@ package org.splat.simer;
 
 import java.util.ResourceBundle;
 
-import org.splat.kernel.Name;
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.ValidationCycle;
 import org.splat.dal.bo.som.ValidationStep;
-
+import org.splat.kernel.Name;
 
 public class ValidationFacade {
 
-       String  myicon;
-       String  myname;
-       Name    mypublisher;
-    Name    myreviewer;
-    Name    myapprover;
-
-    protected static abstract class UserOption implements Name {
-//  ----------------------------------------------------------
-      protected String name;
-      protected long    index;
-
-      public long getIndex() {
-       return index;
-      }
-      public String toString () {
-        return name;
-      }
-    }
-    protected static class NotRequired extends UserOption {
-//  -----------------------------------------------------
-      protected NotRequired () {
-       name  = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale()).getString("label.skipped");
-       index = 0;
-      }
-    }
-    protected static class ByAuthor extends UserOption {
-//  --------------------------------------------------
-      protected ByAuthor () {
-       name  = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale()).getString("label.bytheauthor");
-       index = 0;
-      }
-    }
-    protected static class ByManager extends UserOption {
-//  ---------------------------------------------------
-      protected ByManager (User manager) {
-       name  = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale()).getString("label.me");
-       index = manager.getIndex();
-      }
-    }
-
-//  ==============================================================================================================================
-//  Constructors
-//  ==============================================================================================================================
-
-       public ValidationFacade (ValidationCycle cycle) {
-//  -----------------------------------------------
-      myicon  = "icon.empty.png";
-         if (cycle.isDefault()) {
-           myname    = "default";
-         } else {
-        if (cycle.isAssigned()) myicon = "icon.done.png";
-        myname    = cycle.getDocumentType().getName();
-         }
-      mypublisher = cycle.getActor(ValidationStep.PROMOTION);
-      myreviewer  = cycle.getActor(ValidationStep.REVIEW);
-      myapprover  = cycle.getActor(ValidationStep.APPROVAL);
-      if (mypublisher == null) {
-       mypublisher = new ByAuthor();
-      }
-      if (myreviewer == null || myapprover == null) {
-        Name  skipped = new NotRequired();
-        if (myreviewer == null) myreviewer = skipped;
-        if (myapprover == null) myapprover = skipped;
-      }
+       private transient String _myicon;
+       private transient String _myname;
+       private transient Name _mypublisher;
+       private transient Name _myreviewer;
+       private transient Name _myapprover;
+
+       protected static class UserOption implements Name {
+               protected transient String _name;
+               protected transient long _index;
+
+               public long getIndex() {
+                       return _index;
+               }
+
+               @Override
+               public String toString() {
+                       return _name;
+               }
+       }
+
+       protected static class NotRequired extends UserOption {
+               protected NotRequired() {
+                       super();
+                       _name = ResourceBundle.getBundle("labels",
+                                       ApplicationSettings.getCurrentLocale()).getString(
+                                       "label.skipped");
+                       _index = 0;
+               }
        }
 
-//  ==============================================================================================================================
-//  Getters
-//  ==============================================================================================================================
-
-    public String getDocumentType () {
-//  --------------------------------
-      return myname;
-    }
-    public long getApproverIndex () {
-//  ------------------------------
-      return myapprover.getIndex();
-    }
-    public String getApproverName () {
-//  --------------------------------
-      return myapprover.toString();
-    }
-    public String getIcon () {
-//  ------------------------
-      return myicon;
-    }
-    public long getPublisherIndex () {
-//  -------------------------------
-      return mypublisher.getIndex();
-    }
-    public String getPublisherName () {
-//  ---------------------------------
-      return mypublisher.toString();
-    }
-    public long getReviewerIndex () {
-//  ------------------------------
-      return myreviewer.getIndex();
-    }
-    public String getReviewerName () {
-//  --------------------------------
-      return myreviewer.toString();
-    }
+       protected static class ByAuthor extends UserOption {
+               protected ByAuthor() {
+                       super();
+                       _name = ResourceBundle.getBundle("labels",
+                                       ApplicationSettings.getCurrentLocale()).getString(
+                                       "label.bytheauthor");
+                       _index = 0;
+               }
+       }
+
+       protected static class ByManager extends UserOption {
+               protected ByManager(final User manager) {
+                       super();
+                       _name = ResourceBundle.getBundle("labels",
+                                       ApplicationSettings.getCurrentLocale()).getString(
+                                       "label.me");
+                       _index = manager.getIndex();
+               }
+       }
+
+       // ==============================================================================================================================
+       // Constructors
+       // ==============================================================================================================================
+
+       public ValidationFacade(final ValidationCycle cycle) {
+               _myicon = "icon.empty.png";
+               if (cycle.isDefault()) {
+                       _myname = "default";
+               } else {
+                       if (cycle.isAssigned()) {
+                               _myicon = "icon.done.png";
+                       }
+                       _myname = cycle.getDocumentType().getName();
+               }
+               _mypublisher = cycle.getActor(ValidationStep.PROMOTION);
+               _myreviewer = cycle.getActor(ValidationStep.REVIEW);
+               _myapprover = cycle.getActor(ValidationStep.APPROVAL);
+               if (_mypublisher == null) {
+                       _mypublisher = new ByAuthor();
+               }
+               if (_myreviewer == null || _myapprover == null) {
+                       Name skipped = new NotRequired();
+                       if (_myreviewer == null) {
+                               _myreviewer = skipped;
+                       }
+                       if (_myapprover == null) {
+                               _myapprover = skipped;
+                       }
+               }
+       }
+
+       // ==============================================================================================================================
+       // Getters
+       // ==============================================================================================================================
+
+       public String getDocumentType() {
+               return _myname;
+       }
+
+       public long getApproverIndex() {
+               return _myapprover.getIndex();
+       }
+
+       public String getApproverName() {
+               return _myapprover.toString();
+       }
+
+       public String getIcon() {
+               return _myicon;
+       }
+
+       public long getPublisherIndex() {
+               return _mypublisher.getIndex();
+       }
+
+       public String getPublisherName() {
+               return _mypublisher.toString();
+       }
+
+       public long getReviewerIndex() {
+               return _myreviewer.getIndex();
+       }
+
+       public String getReviewerName() {
+               return _myreviewer.toString();
+       }
 }
\ No newline at end of file
index d171ce1b65da1bba2cde1156795beaf2d35cfcd1..f962e769b894c3e55b4949997d4371fa5e888b7b 100644 (file)
@@ -4,28 +4,29 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ResourceBundle;
-import java.util.Vector;
 
-import org.splat.kernel.InvalidPropertyException;
 import org.splat.dal.bo.kernel.Relation;
 import org.splat.dal.bo.kernel.User;
-import org.splat.manox.Reader;
-import org.splat.manox.Toolbox;
 import org.splat.dal.bo.som.Document;
 import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.Publication;
+import org.splat.dal.bo.som.UsedByRelation;
+import org.splat.dal.bo.som.UsesRelation;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.manox.Reader;
+import org.splat.manox.Toolbox;
 import org.splat.service.PublicationService;
 import org.splat.service.StepService;
 import org.splat.service.technical.ProjectSettingsService;
 import org.splat.service.technical.RepositoryService;
-import org.splat.dal.bo.som.Publication;
 import org.splat.som.Revision;
 import org.splat.som.Step;
-import org.splat.dal.bo.som.UsedByRelation;
-import org.splat.dal.bo.som.UsesRelation;
+import org.splat.wapp.Constants;
 
 /**
  * Action for creating a new version of a document.
@@ -40,31 +41,31 @@ public class VersionDocumentAction extends UploadBaseNextAction {
        /**
         * Versioned document index.
         */
-       private String index = null;
+       private String _index = null;
        /**
         * List of publications which use the selected document.
         */
-       private List<Publication> usedby = null;
+       private transient List<Publication> _usedby = null;
        /**
         * List of selected impacted documents ids.
         */
-       private long[] docusedby = null;
+       private transient long[] _docusedby = null;
        /**
         * Summary of changes in the new version.
         */
-       private String summary = null;
+       private String _description = null;
        /**
         * Version number extracted from the imported file, if exist.
         */
-       private String docver = "";
+       private String _version = "";
        /**
         * Date extracted from the imported file, if exist.
         */
-       private String date = "";
+       private String _date = "";
        /**
         * Injected project settings service.
         */
-       private ProjectSettingsService _projectSettingsService;
+       private ProjectSettingsService _projectSettings;
        /**
         * Injected publication service.
         */
@@ -119,15 +120,15 @@ public class VersionDocumentAction extends UploadBaseNextAction {
         */
        public String doInitialize() {
 
-               setMenuProperty("study");
-               setTitleProperty("study");
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
                setEditDisabledProperty("true");
                if ("true".equals(getWriteAccess())) {
-                       setToolProperty("study");
+                       setToolProperty(Constants.STUDY_MENU);
                } else {
-                       setToolProperty("none");
+                       setToolProperty(Constants.NONE);
                }
-               setLeftMenuProperty("study");
+               setLeftMenuProperty(Constants.STUDY_MENU);
         initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
            
                User user = getConnectedUser();
@@ -137,35 +138,35 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                mystudy = getOpenStudy();
 
                Publication tag = mystudy.getSelectedStep().getDocument(
-                               Integer.valueOf(index));
+                               Integer.valueOf(_index));
                Document doc = tag.value();
                deftype = doc.getType();
                docname = doc.getTitle();
-               defuses = new Vector<Document>();
-               usedby = new Vector<Publication>();
-
-               if (!extractProperties(upfile, doc)) {
-                       if (!("none".equals(_toolProperty))) {
-                               setToolProperty("none");
-                               setLeftMenuProperty("study");
+               defuses = new ArrayList<Document>();
+               _usedby = new ArrayList<Publication>();
+
+               String res = SUCCESS;
+               if (extractProperties(upfile, doc)) {
+                       setupDefaultUses(deftype);
+                       // Add additional documents used by the current version
+                       List<Relation> uses = doc.getRelations(UsesRelation.class);
+                       for (Iterator<Relation> i = uses.iterator(); i.hasNext();) {
+                               Document used = (Document) i.next().getTo();
+                               if (!defuses.contains(used)) {
+                                       defuses.add(used);
+                               }
+                       }
+                       // Setup dependencies
+                       _usedby.addAll(tag.getRelations(UsedByRelation.class));
+               } else {
+                       if (!(Constants.NONE.equals(_toolProperty))) {
+                               setToolProperty(Constants.NONE);
+                               setLeftMenuProperty(Constants.STUDY_MENU);
                                initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                        }
-                       return ERROR;
-               }
-               setupDefaultUses(deftype);
-               // Add additional documents used by the current version
-               List<Relation> uses = doc.getRelations(UsesRelation.class);
-               for (Iterator<Relation> i = uses.iterator(); i.hasNext();) {
-                       Document used = (Document) i.next().getTo();
-                       if (!defuses.contains(used))
-                               defuses.add(used);
-               }
-               // Setup dependencies
-               List<Publication> relist = tag.getRelations(UsedByRelation.class);
-               for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
-                       usedby.add(i.next());
+                       res = ERROR;
                }
-               return SUCCESS;
+               return res;
        }
 
        /**
@@ -177,16 +178,13 @@ public class VersionDocumentAction extends UploadBaseNextAction {
         *            the document to version
         * @return true if succeeded or if the file is not XML, otherwise return false
         */
-       private boolean extractProperties(File upfile, Document doc) {
+       private boolean extractProperties(final File upfile, final Document doc) {
                boolean res = true;
                Reader tool = Toolbox.getReader(upfile);
                if (tool != null) {
                        String fileref = tool.extractProperty("reference");
                        String filever = tool.extractProperty("version");
-                       if (fileref != null && !doc.getReference().equals(fileref)) {
-                               setErrorCode("reference.mismatch");
-                               res = false;
-                       } else {
+                       if (fileref == null || doc.getReference().equals(fileref)) {
                                if (filever != null) {
                                        try {
                                                Revision.Format get = new Revision.Format(
@@ -201,30 +199,33 @@ public class VersionDocumentAction extends UploadBaseNextAction {
                                                } else {
                                                        state = ProgressState.inDRAFT;
                                                }
-                                               docver = newver.toString();
+                                               _version = newver.toString();
                                        } catch (Exception e) {
                                                setErrorCode("version.mismatch");
                                                res = false;
                                        }
                                }
                                if (res) {
-                                       summary = tool.extractProperty("history");
-                                       date = tool.extractProperty("date");
-                                       if (date != null) {
+                                       _description = tool.extractProperty("history");
+                                       _date = tool.extractProperty("date");
+                                       if (_date == null) {
+                                               _date = "";
+                                       } else {
                                                ResourceBundle locale = ResourceBundle.getBundle("som",
                                                                getApplicationSettings().getCurrentLocale());
                                                SimpleDateFormat check = new SimpleDateFormat(locale
                                                                .getString("date.format"));
                                                try {
-                                                       check.parse(date);
+                                                       check.parse(_date);
                                                } catch (ParseException e) {
                                                        setErrorCode("format.date");
                                                        res = false;
                                                }
-                                       } else {
-                                               date = "";
                                        }
                                }
+                       } else {
+                               setErrorCode("reference.mismatch");
+                               res = false;
                        }
                }
                return res;
@@ -236,55 +237,58 @@ public class VersionDocumentAction extends UploadBaseNextAction {
         * @return SUCCESS - if succeeded, "cancel" - if canceled, ERROR - if failed
         */
        public String doVersion() {
-               setMenuProperty("study");
-               setTitleProperty("study");
+               String res = ERROR;
+               setMenuProperty(Constants.STUDY_MENU);
+               setTitleProperty(Constants.STUDY_MENU);
                setEditDisabledProperty("true");
         initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
            
-               if (action == ToDo.cancel)
-                       return "cancel";
-
-               try {
-                       // Getting user inputs
-                       mystudy = getOpenStudy();
-                       User user = getConnectedUser();
-                       Step step = mystudy.getSelectedStep();
-                       Date aDate = null;
-                       if (date.length() > 0) {
-                               ResourceBundle locale = ResourceBundle.getBundle("som",
-                                               getApplicationSettings().getCurrentLocale());
-                               SimpleDateFormat get = new SimpleDateFormat(locale
-                                               .getString("date.format"));
-                               aDate = get.parse(date);
+               if (action == ToDo.cancel) {
+                       res = "cancel";
+               } else {
+       
+                       try {
+                               // Getting user inputs
+                               mystudy = getOpenStudy();
+                               User user = getConnectedUser();
+                               Step step = mystudy.getSelectedStep();
+                               Date aDate = null;
+                               if (_date.length() > 0) {
+                                       ResourceBundle locale = ResourceBundle.getBundle("som",
+                                                       getApplicationSettings().getCurrentLocale());
+                                       SimpleDateFormat get = new SimpleDateFormat(locale
+                                                       .getString("date.format"));
+                                       aDate = get.parse(_date);
+                               }
+       
+                               String[] listDocuses = null;
+                               if (docuses != null) {
+                                       listDocuses = docuses.split(",");
+                               }
+                               getPublicationService().versionDocument(step, user, filename,
+                                               Integer.valueOf(_index), _version, _description, state, aDate,
+                                               listDocuses, _docusedby);
+       
+                               // Update of the open study
+                               mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
+                               // TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
+       
+                               res = SUCCESS;
+                       } catch (FileNotFoundException error) {
+                               LOG.error("Reason:", error);
+                               setErrorCode("import.file");
+                       } catch (Exception error) {
+                               LOG.error("Reason:", error);
+                               setErrorCode("internal");
                        }
-
-                       String[] listDocuses = null;
-                       if (docuses != null) {
-                               listDocuses = docuses.split(",");
+                       if (!SUCCESS.equals(res)) {
+                               setToolProperty(Constants.NONE);
+                               
+                               setLeftMenuProperty(Constants.STUDY_MENU);
+                               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
                        }
-                       getPublicationService().versionDocument(step, user, filename,
-                                       Integer.valueOf(index), docver, summary, state, aDate,
-                                       listDocuses, docusedby);
-
-                       // Update of the open study
-                       mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
-                       // TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
-
-                       return SUCCESS;
-               } catch (FileNotFoundException error) {
-                       LOG.error("Reason:", error);
-                       setErrorCode("import.file");
-               } catch (Exception error) {
-                       LOG.error("Reason:", error);
-                       setErrorCode("internal");
-               }
-               
-               setToolProperty("none");
-               
-               setLeftMenuProperty("study");
-               initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-               
-               return ERROR;
+               }               
+               return res;
        }
 
        // ==============================================================================================================================
@@ -292,48 +296,49 @@ public class VersionDocumentAction extends UploadBaseNextAction {
        // ==============================================================================================================================
 
        public String getDate() {
-               return date;
+               return _date;
        }
 
        public List<Publication> getDependencies() {
-               return usedby;
+               return _usedby;
        }
 
        public String getDescription() {
-               return summary;
+               return _description;
        }
 
        public String getIndex() {
-               return index;
+               return _index;
        }
 
        public String getVersion() {
-               return docver;
+               return _version;
        }
 
-       public void setDate(String date) {
-               this.date = date;
+       public void setDate(final String date) {
+               this._date = date;
        }
 
-       public void setDefaultDescription(String summary) {
-               if (this.summary == null)
-                       this.summary = summary;
+       public void setDefaultDescription(final String summary) {
+               if (this._description == null) {
+                       this._description = summary;
+               }
        }
 
-       public void setDescription(String summary) {
-               this.summary = summary;
+       public void setDescription(final String summary) {
+               this._description = summary;
        }
 
-       public void setIndex(String index) {
-               this.index = index;
+       public void setIndex(final String index) {
+               this._index = index;
        }
 
-       public void setUsedBy(long[] list) {
-               this.docusedby = list;
+       public void setUsedBy(final long[] list) {
+               this._docusedby = list;
        }
 
-       public void setVersion(String value) {
-               this.docver = value;
+       public void setVersion(final String value) {
+               this._version = value;
        }
 
        /**
@@ -342,7 +347,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
         * @return Project settings service
         */
        private ProjectSettingsService getProjectSettings() {
-               return _projectSettingsService;
+               return _projectSettings;
        }
 
        /**
@@ -351,8 +356,8 @@ public class VersionDocumentAction extends UploadBaseNextAction {
         * @param projectSettingsService
         *            project settings service
         */
-       public void setProjectSettings(ProjectSettingsService projectSettingsService) {
-               _projectSettingsService = projectSettingsService;
+       public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
+               _projectSettings = projectSettingsService;
        }
 
        /**
@@ -370,7 +375,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
         * @param publicationService
         *            the publicationService to set
         */
-       public void setPublicationService(PublicationService publicationService) {
+       public void setPublicationService(final PublicationService publicationService) {
                _publicationService = publicationService;
        }
 
@@ -389,7 +394,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
         * @param stepService
         *            the stepService to set
         */
-       public void setStepService(StepService stepService) {
+       public void setStepService(final StepService stepService) {
                _stepService = stepService;
        }
 
@@ -408,7 +413,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
         * @param repositoryService
         *            the repositoryService to set
         */
-       public void setRepositoryService(RepositoryService repositoryService) {
+       public void setRepositoryService(final RepositoryService repositoryService) {
                _repositoryService = repositoryService;
        }
 
@@ -427,7 +432,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
         * @param menuProperty
         *            the menuProperty to set
         */
-       public void setMenuProperty(String menuProperty) {
+       public void setMenuProperty(final String menuProperty) {
                this._menuProperty = menuProperty;
        }
 
@@ -446,7 +451,7 @@ public class VersionDocumentAction extends UploadBaseNextAction {
         * @param titleProperty
         *            the titleProperty to set
         */
-       public void setTitleProperty(String titleProperty) {
+       public void setTitleProperty(final String titleProperty) {
                _titleProperty = titleProperty;
        }
 
@@ -460,13 +465,13 @@ public class VersionDocumentAction extends UploadBaseNextAction {
        }
 
        /**
-        * Set the _editDisabledProperty.
+        * Set the editDisabledProperty.
         * 
-        * @param _editDisabledProperty
-        *            the _editDisabledProperty to set
+        * @param editDisabledProperty
+        *            the editDisabledProperty to set
         */
-       public void setEditDisabledProperty(String _editDisabledProperty) {
-               this._editDisabledProperty = _editDisabledProperty;
+       public void setEditDisabledProperty(final String editDisabledProperty) {
+               this._editDisabledProperty = editDisabledProperty;
        }
        
        /**
diff --git a/Workspace/Siman/src/org/splat/wapp/Constants.java b/Workspace/Siman/src/org/splat/wapp/Constants.java
new file mode 100644 (file)
index 0000000..54fc75f
--- /dev/null
@@ -0,0 +1,23 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   08.11.2012
+ * @author         $Author$
+ * @version        $Revision$
+ * @copyright      OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.wapp; 
+
+/**
+ * SIMAN constants.
+ */
+public class Constants {
+       public final static String STANDARD_MENU = "standard";
+       public final static String STUDY_MENU = "study";
+       public final static String KNOWLEDGE_MENU = "knowledge";
+       public final static String NONE = "none";
+       public final static String TRUE = "true";
+       public final static String PROP_SCENARIO = "prop-scenario";
+}
index cdcfa55e60bd8a9d99feb7782e1322bf8cd45cad..d51647dc16ab9ba02c8e3a57f7097c284a9db63b 100644 (file)
@@ -68,7 +68,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                scope="session" parent="slidMenu" />
 
        <bean id="openObject" abstract="true"
-               class="org.splat.simer.OpenObject" scope="session">
+               class="org.splat.simer.AbstractOpenObject" scope="session">
                <property name="applicationSettings" ref="applicationSettings" />
                <property name="projectElementService"
                        ref="projectElementService" />