From f831c6187d0a041d3811a14bb5740fd5cdc956fa Mon Sep 17 00:00:00 2001 From: rkv Date: Thu, 8 Nov 2012 13:02:32 +0000 Subject: [PATCH] Modifications to respect PMD rules. --- .../src/org/splat/dal/bo/kernel/User.java | 114 +++++--- .../org/splat/kernel/RealmLoginModule.java | 60 +++- Workspace/Siman/WebContent/conf/login.conf | 2 +- .../Siman/WebContent/jsp/editKnowledge.jsp | 8 +- .../Siman/WebContent/jsp/readDescription.jsp | 4 +- .../Siman/WebContent/jsp/readKnowledge.jsp | 14 +- ...Action.java => AbstractDisplayAction.java} | 30 +- ...penObject.java => AbstractOpenObject.java} | 145 +++++----- ...ion.java => AbstractSearchBaseAction.java} | 168 ++++++----- .../Siman/src/org/splat/simer/Action.java | 6 +- .../src/org/splat/simer/ConnectionAction.java | 253 ++++++++++------- .../splat/simer/DisplayKnowledgeAction.java | 131 ++++----- .../splat/simer/DisplayStudyStepAction.java | 208 +++++++------- .../src/org/splat/simer/DocumentFacade.java | 10 +- .../org/splat/simer/EditDocumentAction.java | 34 +-- .../simer/EditKnowledgeElementAction.java | 30 +- .../simer/EditScenarioPropertiesAction.java | 16 +- .../simer/EditSimulationContextAction.java | 26 +- .../src/org/splat/simer/EditStudyAction.java | 8 +- .../src/org/splat/simer/LeftMenuSettings.java | 18 +- .../Siman/src/org/splat/simer/MenuAction.java | 115 +++++--- .../src/org/splat/simer/MenuBarSettings.java | 82 +++--- .../src/org/splat/simer/NewStudyAction.java | 89 +++--- .../src/org/splat/simer/OpenKnowledge.java | 34 +-- .../Siman/src/org/splat/simer/OpenStudy.java | 118 ++++---- .../splat/simer/SearchKnowledgeAction.java | 192 +++++++------ .../org/splat/simer/SearchStudyAction.java | 212 +++++++------- .../splat/simer/SimulationContextFacade.java | 162 +++++------ .../src/org/splat/simer/StampFacade.java | 127 +++++---- .../src/org/splat/simer/StartAction.java | 260 +++++++++-------- .../Siman/src/org/splat/simer/StudyMenu.java | 5 +- .../splat/simer/StudyPropertiesAction.java | 24 +- .../src/org/splat/simer/ValidationFacade.java | 217 ++++++++------- .../splat/simer/VersionDocumentAction.java | 263 +++++++++--------- .../Siman/src/org/splat/wapp/Constants.java | 23 ++ .../Siman/src/spring/applicationContext.xml | 2 +- 36 files changed, 1797 insertions(+), 1413 deletions(-) rename Workspace/Siman/src/org/splat/simer/{DisplayBaseAction.java => AbstractDisplayAction.java} (62%) rename Workspace/Siman/src/org/splat/simer/{OpenObject.java => AbstractOpenObject.java} (72%) rename Workspace/Siman/src/org/splat/simer/{SearchBaseAction.java => AbstractSearchBaseAction.java} (66%) create mode 100644 Workspace/Siman/src/org/splat/wapp/Constants.java diff --git a/Workspace/Siman-Common/src/org/splat/dal/bo/kernel/User.java b/Workspace/Siman-Common/src/org/splat/dal/bo/kernel/User.java index 41dad3b..a9b24ea 100644 --- a/Workspace/Siman-Common/src/org/splat/dal/bo/kernel/User.java +++ b/Workspace/Siman-Common/src/org/splat/dal/bo/kernel/User.java @@ -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 state, final Map 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; diff --git a/Workspace/Siman/WebContent/conf/login.conf b/Workspace/Siman/WebContent/conf/login.conf index e11cfc5..d1bfcd5 100644 --- a/Workspace/Siman/WebContent/conf/login.conf +++ b/Workspace/Siman/WebContent/conf/login.conf @@ -1,3 +1,3 @@ -Simer { +Siman { org.splat.kernel.RealmLoginModule required debug=true; }; \ No newline at end of file diff --git a/Workspace/Siman/WebContent/jsp/editKnowledge.jsp b/Workspace/Siman/WebContent/jsp/editKnowledge.jsp index 7e613b8..2ae4fd4 100644 --- a/Workspace/Siman/WebContent/jsp/editKnowledge.jsp +++ b/Workspace/Siman/WebContent/jsp/editKnowledge.jsp @@ -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 knowlist = study.getDisplayedKnowledges(); + List knowlist = study.getDisplayedKnowledges(); ResourceBundle locale = ResourceBundle.getBundle("som"); %> @@ -24,8 +24,8 @@ <% - for (Iterator knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) { - OpenObject.KnowledgeIterator type = knowtypes.next(); + for (Iterator knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) { + AbstractOpenObject.KnowledgeIterator type = knowtypes.next(); %> diff --git a/Workspace/Siman/WebContent/jsp/readDescription.jsp b/Workspace/Siman/WebContent/jsp/readDescription.jsp index a3d98e4..48f3d98 100644 --- a/Workspace/Siman/WebContent/jsp/readDescription.jsp +++ b/Workspace/Siman/WebContent/jsp/readDescription.jsp @@ -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(); %>
<%=locale.getString("type.knowledge." + type.getType())%>
diff --git a/Workspace/Siman/WebContent/jsp/readKnowledge.jsp b/Workspace/Siman/WebContent/jsp/readKnowledge.jsp index d888b88..0a74809 100644 --- a/Workspace/Siman/WebContent/jsp/readKnowledge.jsp +++ b/Workspace/Siman/WebContent/jsp/readKnowledge.jsp @@ -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 knowlist = object.getDisplayedKnowledges(); + AbstractOpenObject object = (AbstractOpenObject)session.getAttribute(entitype + ".open"); + List knowlist = object.getDisplayedKnowledges(); ResourceBundle locale = ResourceBundle.getBundle("som"); %> <%=entitype%> @@ -35,8 +35,8 @@
<% String curindex = object.getIndex().toString(); - for (Iterator knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) { - OpenObject.KnowledgeIterator type = knowtypes.next(); + for (Iterator knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) { + AbstractOpenObject.KnowledgeIterator type = knowtypes.next(); %> diff --git a/Workspace/Siman/src/org/splat/simer/DisplayBaseAction.java b/Workspace/Siman/src/org/splat/simer/AbstractDisplayAction.java similarity index 62% rename from Workspace/Siman/src/org/splat/simer/DisplayBaseAction.java rename to Workspace/Siman/src/org/splat/simer/AbstractDisplayAction.java index 58b66ab..15e7559 100644 --- a/Workspace/Siman/src/org/splat/simer/DisplayBaseAction.java +++ b/Workspace/Siman/src/org/splat/simer/AbstractDisplayAction.java @@ -1,11 +1,17 @@ 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; +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. @@ -20,20 +26,20 @@ public abstract class DisplayBaseAction extends Action { public String getSelection () { // ----------------------------- - return selection; // Equals to myobject.getSelection() + return _selection; // Equals to myobject.getSelection() } - public void setAction (String action) { + public void setAction (final String action) { // ------------------------------------- - this.action = action; + this._action = action; } - public void setIndex (String index) { + public void setIndex (final String index) { // ----------------------------------- - this.myindex = index; + this._myindex = index; } - public void setSelection (String step) { + public void setSelection (final String step) { // -------------------------------------- - this.selection = step; + this._selection = step; } // ============================================================================================================================== diff --git a/Workspace/Siman/src/org/splat/simer/OpenObject.java b/Workspace/Siman/src/org/splat/simer/AbstractOpenObject.java similarity index 72% rename from Workspace/Siman/src/org/splat/simer/OpenObject.java rename to Workspace/Siman/src/org/splat/simer/AbstractOpenObject.java index 2efe1b0..a83ba4c 100644 --- a/Workspace/Siman/src/org/splat/simer/OpenObject.java +++ b/Workspace/Siman/src/org/splat/simer/AbstractOpenObject.java @@ -25,7 +25,10 @@ import org.splat.util.BeanHelper; import org.splat.wapp.Menu; import org.splat.wapp.PopupMenu; -public abstract class OpenObject implements Proxy { +/** + * Open study or knowledge. + */ +public abstract class AbstractOpenObject implements Proxy { protected static Map docpres = null; protected static Map knowpres = null; @@ -33,45 +36,45 @@ public abstract class OpenObject implements Proxy { /** * Connected user. */ - protected User cuser = null; + protected transient User _cuser = null; /** * Menu selected by the user. */ - protected String selection = null; + protected transient String _selection = null; /** * Corresponding selected step. */ - protected Step ustep = null; + protected transient Step _ustep = null; /** * Object description (rich text). */ - protected String description = null; - protected List involving = new ArrayList(); + protected transient String _description = null; + protected transient List _involving = new ArrayList(); /** * Simulation Context display representations. */ - protected List context = new ArrayList(); // Simulation Context display representations + protected transient List _context = new ArrayList(); /** * Document display representations. */ - protected List contents = null; + protected transient List _contents = null; /** * Knowledge Element display representations structured by knowledge types. */ - protected List knowledge = null; + protected transient List _knowledge = null; /** * Left pane menu of this object. */ - protected Menu menu = null; + protected Menu _menu = null; /** * Pop-up menu of this object, if the user has write access. */ - protected PopupMenu popup = null; + protected transient PopupMenu _popup = null; /** * Injected project settings service. */ - private ProjectSettingsService _projectSettingsService; + private ProjectSettingsService _projectSettings; /** * Injected application settings bean. */ @@ -90,25 +93,25 @@ public abstract class OpenObject implements Proxy { private ProjectElementService _projectElementService; public class KnowledgeIterator { - protected KnowledgeElementType type; - protected List list; + protected transient KnowledgeElementType _type; + protected transient List _list; public KnowledgeIterator(final KnowledgeElementType type, final List list) { - this.type = type; - this.list = list; + this._type = type; + this._list = list; } public String getIndex() { - return String.valueOf(type.getIndex()); + return String.valueOf(_type.getIndex()); } public String getType() { - return type.getName(); + return _type.getName(); } public List getKnowledgeElements() { - return list; + return _list; } } @@ -116,8 +119,7 @@ public abstract class OpenObject implements Proxy { // Constructor // ============================================================================================================================== - protected OpenObject() { - // ----------------------- + protected AbstractOpenObject() { // All member fields are supposed initialized by subclasses if (docpres == null) { docpres = new HashMap(); @@ -132,8 +134,7 @@ public abstract class OpenObject implements Proxy { // ============================================================================================================================== public void developDocument(final String index) { - // ------------------------------------------ - for (Iterator i = contents.iterator(); i.hasNext();) { + for (Iterator i = _contents.iterator(); i.hasNext();) { DocumentFacade doc = i.next(); if (!doc.getIndex().equals(index)) { continue; @@ -144,8 +145,7 @@ public abstract class OpenObject implements Proxy { } public void developKnowledge(final String index) { - // ------------------------------------------- - for (Iterator i = knowledge.iterator(); i.hasNext();) { + for (Iterator i = _knowledge.iterator(); i.hasNext();) { List knowelms = i.next() .getKnowledgeElements(); for (Iterator j = knowelms.iterator(); j @@ -161,15 +161,13 @@ public abstract class OpenObject implements Proxy { } 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 collectInvolvedDocuments(final DocumentType type) { - // ------------------------------------------------------------------ List found = new ArrayList(); - for (Iterator i = involving.iterator(); i.hasNext();) { + for (Iterator i = _involving.iterator(); i.hasNext();) { Step step = i.next(); List exist = step.getAllDocuments(); for (Iterator j = exist.iterator(); j.hasNext();) { @@ -183,63 +181,51 @@ public abstract class OpenObject implements Proxy { } public String getDisplayedDescription() { - // ---------------------------------------- - return description; + return _description; } public List getDisplayedDocuments() { - // ----------------------------------------------------- - return contents; + return _contents; } public List getDisplayedSimulationContexts() { - // ---------------------------------------------------------------------- - return context; + return _context; } public List getDisplayedKnowledges() { - // -------------------------------------------------------- - return knowledge; + return _knowledge; } public List getInvolvedSteps() { - // ------------------------------------- - return involving; + return _involving; } public Menu getMenu() { - // ---------------------- - return menu; + return _menu; } public PopupMenu getPopup() { - // ---------------------------- - return popup; + return _popup; } public Step getSelectedStep() { - // ------------------------------ - return ustep; + return _ustep; } public String getSelection() { - // ----------------------------- - return selection; + return _selection; } public User getUser() { - // ---------------------- - return cuser; + return _cuser; } public boolean isOpenForWriting() { - // ---------------------------------- - return (popup != null); // The pop-up is supposed existed when the user is staffed on the study + 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 i = contents.iterator(); i.hasNext();) { + for (Iterator i = _contents.iterator(); i.hasNext();) { DocumentFacade doc = i.next(); if (!doc.getIndex().equals(index)) { continue; @@ -250,8 +236,7 @@ public abstract class OpenObject implements Proxy { } public void reduceHistory(final String index) { - // ---------------------------------------- - for (Iterator i = contents.iterator(); i.hasNext();) { + for (Iterator i = _contents.iterator(); i.hasNext();) { DocumentFacade doc = i.next(); if (!doc.getIndex().equals(index)) { continue; @@ -262,8 +247,7 @@ public abstract class OpenObject implements Proxy { } public void reduceKnowledge(final String index) { - // ------------------------------------------ - for (Iterator i = knowledge.iterator(); i.hasNext();) { + for (Iterator i = _knowledge.iterator(); i.hasNext();) { List knowelms = i.next() .getKnowledgeElements(); for (Iterator j = knowelms.iterator(); j @@ -283,13 +267,12 @@ public abstract class OpenObject implements Proxy { // ============================================================================================================================== protected void setupContents() { - // ------------------------------- // Description // Initialized in subclasses // Knowledge elements supposed ordered by type - if (ustep.mayContain(KnowledgeElement.class)) { - Scenario scene = (Scenario) ustep.getOwner(); + if (_ustep.mayContain(KnowledgeElement.class)) { + Scenario scene = (Scenario) _ustep.getOwner(); List types = getKnowledgeElementTypeService() .selectTypesWhere(ProgressState.APPROVED); List kelms = scene.getAllKnowledgeElements(); @@ -299,7 +282,7 @@ public abstract class OpenObject implements Proxy { current = more.next(); } - knowledge = new ArrayList(types.size()); + _knowledge = new ArrayList(types.size()); for (Iterator i = types.iterator(); i .hasNext();) { KnowledgeElementType type = i.next(); @@ -309,7 +292,8 @@ public abstract class OpenObject implements Proxy { KnowledgeElementFacade facade = knowpres.get(current .getIndex()); if (facade == null) { - facade = new KnowledgeElementFacade(BeanHelper.copyBean(current, KnowledgeElementDTO.class)); + facade = new KnowledgeElementFacade(BeanHelper + .copyBean(current, KnowledgeElementDTO.class)); knowpres.put(current.getIndex(), facade); } display.add(facade); @@ -319,16 +303,16 @@ public abstract class OpenObject implements Proxy { current = null; } } - knowledge.add(new KnowledgeIterator(type, display)); + _knowledge.add(new KnowledgeIterator(type, display)); } } else { - knowledge = null; + _knowledge = null; } // Documents - if (ustep.mayContain(Document.class)) { - List list = ustep.getAllDocuments(); + if (_ustep.mayContain(Document.class)) { + List list = _ustep.getAllDocuments(); - contents = new ArrayList(list.size()); + _contents = new ArrayList(list.size()); for (Iterator i = list.iterator(); i.hasNext();) { Publication present = i.next(); Long index = present.getIndex(); @@ -338,10 +322,10 @@ public abstract class OpenObject implements Proxy { getProjectSettings(), getPublicationService()); docpres.put(index, facade); } - contents.add(facade); + _contents.add(facade); } } else { - contents = null; + _contents = null; } } @@ -351,7 +335,7 @@ public abstract class OpenObject implements Proxy { * @return Project settings service */ public ProjectSettingsService getProjectSettings() { - return _projectSettingsService; + return _projectSettings; } /** @@ -369,8 +353,9 @@ public abstract class OpenObject implements Proxy { * @param projectSettingsService * project settings service */ - public void setProjectSettings(final ProjectSettingsService projectSettingsService) { - _projectSettingsService = projectSettingsService; + public void setProjectSettings( + final ProjectSettingsService projectSettingsService) { + _projectSettings = projectSettingsService; } /** @@ -379,7 +364,8 @@ public abstract class OpenObject implements Proxy { * @param publicationService * the publicationService to set */ - public void setPublicationService(final PublicationService publicationService) { + public void setPublicationService( + final PublicationService publicationService) { _publicationService = publicationService; } @@ -390,7 +376,7 @@ public abstract class OpenObject implements Proxy { * the menu to set */ public void setMenu(final Menu menu) { - this.menu = menu; + this._menu = menu; } /** @@ -415,6 +401,7 @@ public abstract class OpenObject implements Proxy { /** * Get the knowledgeElementTypeService. + * * @return the knowledgeElementTypeService */ public KnowledgeElementTypeService getKnowledgeElementTypeService() { @@ -423,7 +410,9 @@ public abstract class OpenObject implements Proxy { /** * Set the knowledgeElementTypeService. - * @param knowledgeElementTypeService the knowledgeElementTypeService to set + * + * @param knowledgeElementTypeService + * the knowledgeElementTypeService to set */ public void setKnowledgeElementTypeService( final KnowledgeElementTypeService knowledgeElementTypeService) { @@ -432,6 +421,7 @@ public abstract class OpenObject implements Proxy { /** * Get the applicationSettings. + * * @return the applicationSettings */ public ApplicationSettings getApplicationSettings() { @@ -440,9 +430,12 @@ public abstract class OpenObject implements Proxy { /** * Set the applicationSettings. - * @param applicationSettings the applicationSettings to set + * + * @param applicationSettings + * the applicationSettings to set */ - public void setApplicationSettings(final ApplicationSettings applicationSettings) { + public void setApplicationSettings( + final ApplicationSettings applicationSettings) { _applicationSettings = applicationSettings; } } \ No newline at end of file diff --git a/Workspace/Siman/src/org/splat/simer/SearchBaseAction.java b/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java similarity index 66% rename from Workspace/Siman/src/org/splat/simer/SearchBaseAction.java rename to Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java index 7db86ad..f62ade4 100644 --- a/Workspace/Siman/src/org/splat/simer/SearchBaseAction.java +++ b/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java @@ -1,38 +1,64 @@ package org.splat.simer; +import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; -import java.util.Vector; +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.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; +import org.splat.service.technical.ProjectSettingsService; +import org.splat.som.ApplicationRights; -public abstract class SearchBaseAction extends Action { +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"; - 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 manager = null; - protected SimulationContextType newtype; // Context type to be valued - protected List newvalue; // Context value to be selected - protected List critext; // Addable context types - protected List context; // Current contexts search criteria - protected List 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 _candidates = null; + /** + * Context type to be valued. + */ + protected transient SimulationContextType _newtype; + /** + * Context value to be selected. + */ + protected transient List _newvalue; + /** + * Addable context types. + */ + protected transient List _critext; + /** + * Current contexts search criteria. + */ + protected transient List _context; + protected transient List _result; /** * Injected simulation context service. */ @@ -54,16 +80,17 @@ public abstract class SearchBaseAction extends Action { public String doSubmitForm() { // Identification of the user action UserAction action = UserAction.refreshResult; - if (ctype != null && Integer.valueOf(ctype) > 0) + if (_ctype != null && Integer.valueOf(_ctype) > 0) { action = UserAction.selectContextType; - else if (cvalue != null && Integer.valueOf(cvalue) > 0) + } else if (_cvalue != null && Integer.valueOf(_cvalue) > 0) { action = UserAction.selectContextValue; - else if (cindex.length() > 0) { - int index = Integer.valueOf(cindex); - if (index > 0) + } else if (_cindex.length() > 0) { + int index = Integer.valueOf(_cindex); + if (index > 0) { action = UserAction.removeContext; - else if (index < 0) + } else if (index < 0) { action = UserAction.cancelSelect; + } } // Execution of the user action String done; @@ -83,42 +110,43 @@ public abstract class SearchBaseAction extends Action { 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; + 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("search.result"); - else - result = (List) getSession().get("search.result"); // We keep the previous result search, if valid + _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) getSession().get(RESULT_KEY); // We keep the previous result search, if valid + } return "selectype"; } protected String doAddContext() { SimulationContext selected = getSimulationContextService() - .selectSimulationContext(Integer.valueOf(cvalue)); + .selectSimulationContext(Integer.valueOf(_cvalue)); - context.add(selected); + _context.add(selected); setContextTypeOptions(getInvolvedContexts()); // Sets critext - getSession().remove("search.result"); // The current result is obsolete + getSession().remove(RESULT_KEY); // The current result is obsolete return "refresh"; } protected String doRemoveContext() { - int index = Integer.valueOf(cindex); - for (Iterator selected = context.iterator(); selected + int index = Integer.valueOf(_cindex); + for (Iterator selected = _context.iterator(); selected .hasNext();) { if (selected.next().getIndex() == index) { selected.remove(); @@ -126,13 +154,13 @@ public abstract class SearchBaseAction extends Action { } } setContextTypeOptions(getInvolvedContexts()); // Sets critext - getSession().remove("search.result"); // The current result is obsolete + getSession().remove(RESULT_KEY); // The current result is obsolete return "refresh"; } @SuppressWarnings("unchecked") protected String doCancel() { - result = (List) getSession().get("search.result"); // Current result search + _result = (List) getSession().get(RESULT_KEY); // Current result search setContextTypeOptions(getInvolvedContexts()); // Sets critext return "refresh"; } @@ -142,71 +170,72 @@ public abstract class SearchBaseAction extends Action { // ============================================================================================================================== public String getAuthor() { - return author; + return _author; } public List getCandidates() { - return manager; + return _candidates; } public List getContextTypeOptions() { - return critext; + return _critext; } public List getContextValueOptions() { - return newvalue; + return _newvalue; } public SimulationContextType getSelectedContextType() { - return newtype; + return _newtype; } public List getSimulationContexts() { - return context; + return _context; } public List getResult() { - return result; + return _result; } // ============================================================================================================================== // Setters // ============================================================================================================================== - public void setAuthor(String index) { - this.author = index; + public void setAuthor(final String index) { + this._author = index; } - public void setContextType(String type) { - this.ctype = type; + public void setContextType(final String type) { + this._ctype = type; } - public void setContextValue(String value) { - this.cvalue = value; + public void setContextValue(final String value) { + this._cvalue = value; } - public void setContextIndex(String value) { - this.cindex = value; + public void setContextIndex(final String value) { + this._cindex = value; } protected void setCandidates() { - manager = new Vector(); + _candidates = new ArrayList(); List users = getUserService().selectAllUsers(); User me = getConnectedUser(); // May be null for (Iterator 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); + if (next.equals(me)) { + _candidates.add(0, new ValidationFacade.ByManager(me)); + } else { + _candidates.add(next); + } } } } - protected void setContextTypeOptions(List critext) { - for (Iterator i = context.iterator(); i.hasNext();) { + protected void setContextTypeOptions(final List critext) { + for (Iterator i = _context.iterator(); i.hasNext();) { critext.remove(i.next().getType()); // Already used context type } // Ordering by alphabetical order of localized context types @@ -219,17 +248,20 @@ public abstract class SearchBaseAction extends Action { int to = 0; while (to < types.length - 1) { to += 1; - if (types[to].isAttachedTo(step)) + if (types[to].isAttachedTo(step)) { continue; + } - if (to > from + 1) + if (to > from + 1) { Arrays.sort(types, from, to, compare); + } from = to; step = getSimulationContextService().getAttachedStep(types[to]); } - if (to > from) + if (to > from) { Arrays.sort(types, from, to + 1, compare); - this.critext = Arrays.asList(types); + } + this._critext = Arrays.asList(types); } // ============================================================================================================================== @@ -260,7 +292,7 @@ public abstract class SearchBaseAction extends Action { * the simulationContextService to set */ public void setSimulationContextService( - SimulationContextService simulationContextService) { + final SimulationContextService simulationContextService) { _simulationContextService = simulationContextService; } @@ -276,7 +308,7 @@ public abstract class SearchBaseAction extends Action { * Set the userService. * @param userService the userService to set */ - public void setUserService(UserService userService) { + public void setUserService(final UserService userService) { _userService = userService; } } \ No newline at end of file diff --git a/Workspace/Siman/src/org/splat/simer/Action.java b/Workspace/Siman/src/org/splat/simer/Action.java index 47e928d..e2446fe 100644 --- a/Workspace/Siman/src/org/splat/simer/Action.java +++ b/Workspace/Siman/src/org/splat/simer/Action.java @@ -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()); diff --git a/Workspace/Siman/src/org/splat/simer/ConnectionAction.java b/Workspace/Siman/src/org/splat/simer/ConnectionAction.java index 6f7eab9..2838c97 100644 --- a/Workspace/Siman/src/org/splat/simer/ConnectionAction.java +++ b/Workspace/Siman/src/org/splat/simer/ConnectionAction.java @@ -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 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 session = getSession(); - // Map kfilter = (Map)session.get("knowledge.filter"); - Map sfilter = (Map) 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 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 session = getSession(); + // Map kfilter = (Map)session.get("knowledge.filter"); + Map sfilter = (Map) 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 session = getSession(); // Map kfilter = (Map)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/DisplayKnowledgeAction.java b/Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java index 4fbcd3e..6e7d032 100644 --- a/Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java +++ b/Workspace/Siman/src/org/splat/simer/DisplayKnowledgeAction.java @@ -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 getDocuments() { - return myknelm.getDisplayedDocuments(); + return _myknelm.getDisplayedDocuments(); } - public List getKnowledges() { - return myknelm.getDisplayedKnowledges(); + public List getKnowledges() { + return _myknelm.getDisplayedKnowledges(); } public List 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; } /** diff --git a/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java b/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java index 6a9536c..b0852f0 100644 --- a/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java +++ b/Workspace/Siman/src/org/splat/simer/DisplayStudyStepAction.java @@ -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 getDocuments() { - return mystudy.getDisplayedDocuments(); + return _openStudy.getDisplayedDocuments(); } - public List getKnowledges() { - return mystudy.getDisplayedKnowledges(); + public List getKnowledges() { + return _openStudy.getDisplayedKnowledges(); } public List 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; } diff --git a/Workspace/Siman/src/org/splat/simer/DocumentFacade.java b/Workspace/Siman/src/org/splat/simer/DocumentFacade.java index 074b9e4..f94b37c 100644 --- a/Workspace/Siman/src/org/splat/simer/DocumentFacade.java +++ b/Workspace/Siman/src/org/splat/simer/DocumentFacade.java @@ -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 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); } diff --git a/Workspace/Siman/src/org/splat/simer/EditDocumentAction.java b/Workspace/Siman/src/org/splat/simer/EditDocumentAction.java index 955e65b..1cac34a 100644 --- a/Workspace/Siman/src/org/splat/simer/EditDocumentAction.java +++ b/Workspace/Siman/src/org/splat/simer/EditDocumentAction.java @@ -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); diff --git a/Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java b/Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java index 7f9afa1..76a15f5 100644 --- a/Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java +++ b/Workspace/Siman/src/org/splat/simer/EditKnowledgeElementAction.java @@ -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; } /** diff --git a/Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java b/Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java index 782798f..501a3c5 100644 --- a/Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java +++ b/Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java @@ -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() { diff --git a/Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java b/Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java index 31ec5a3..5ed1a7d 100644 --- a/Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java +++ b/Workspace/Siman/src/org/splat/simer/EditSimulationContextAction.java @@ -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 getInvolvedContexts() { // ---------------------------------------------------------- SimulationContextType.Properties sprop = new SimulationContextType.Properties() - .setStep(mystudy.getSelectedStep().getStep()); + .setStep(_openStudy.getSelectedStep().getStep()); List contype = getSimulationContextService() .selectTypesWhere(sprop); diff --git a/Workspace/Siman/src/org/splat/simer/EditStudyAction.java b/Workspace/Siman/src/org/splat/simer/EditStudyAction.java index 2cef5d0..755ba3f 100644 --- a/Workspace/Siman/src/org/splat/simer/EditStudyAction.java +++ b/Workspace/Siman/src/org/splat/simer/EditStudyAction.java @@ -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"); diff --git a/Workspace/Siman/src/org/splat/simer/LeftMenuSettings.java b/Workspace/Siman/src/org/splat/simer/LeftMenuSettings.java index 1c3942b..86206fb 100644 --- a/Workspace/Siman/src/org/splat/simer/LeftMenuSettings.java +++ b/Workspace/Siman/src/org/splat/simer/LeftMenuSettings.java @@ -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; } diff --git a/Workspace/Siman/src/org/splat/simer/MenuAction.java b/Workspace/Siman/src/org/splat/simer/MenuAction.java index 1c026e3..3764e28 100644 --- a/Workspace/Siman/src/org/splat/simer/MenuAction.java +++ b/Workspace/Siman/src/org/splat/simer/MenuAction.java @@ -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 diff --git a/Workspace/Siman/src/org/splat/simer/MenuBarSettings.java b/Workspace/Siman/src/org/splat/simer/MenuBarSettings.java index 57c89b2..4956e00 100644 --- a/Workspace/Siman/src/org/splat/simer/MenuBarSettings.java +++ b/Workspace/Siman/src/org/splat/simer/MenuBarSettings.java @@ -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; } } diff --git a/Workspace/Siman/src/org/splat/simer/NewStudyAction.java b/Workspace/Siman/src/org/splat/simer/NewStudyAction.java index 94b4017..40ae3ff 100644 --- a/Workspace/Siman/src/org/splat/simer/NewStudyAction.java +++ b/Workspace/Siman/src/org/splat/simer/NewStudyAction.java @@ -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 contelm = null; + private transient List _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 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; diff --git a/Workspace/Siman/src/org/splat/simer/OpenKnowledge.java b/Workspace/Siman/src/org/splat/simer/OpenKnowledge.java index 7795dbe..cca5b9f 100644 --- a/Workspace/Siman/src/org/splat/simer/OpenKnowledge.java +++ b/Workspace/Siman/src/org/splat/simer/OpenKnowledge.java @@ -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(); - menu = new Menu(getInvolvedSteps()); - selection = menu.getSelection(); // The default selection is set in the menu definition - int index = Integer.valueOf(selection); - for (Iterator i = involving.iterator(); i.hasNext();) { + _involving = knelm.getInvolving(); + _context = new ArrayList(); + _menu = new Menu(getInvolvedSteps()); + _selection = _menu.getSelection(); // The default selection is set in the menu definition + int index = Integer.valueOf(_selection); + for (Iterator i = _involving.iterator(); i.hasNext();) { Step next = i.next(); if (next.getNumber() == index) { - ustep = next; + _ustep = next; } for (Iterator 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("
") .append(sceneTitle/* scene.getTitle() */).append(".").append( "

"); - 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 i = involving.iterator(); i.hasNext();) { - ustep = i.next(); - if (ustep.getNumber() == index) { + _selection = step; + int index = Integer.valueOf(_selection); + for (Iterator 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/OpenStudy.java b/Workspace/Siman/src/org/splat/simer/OpenStudy.java index 0769013..47f1a00 100644 --- a/Workspace/Siman/src/org/splat/simer/OpenStudy.java +++ b/Workspace/Siman/src/org/splat/simer/OpenStudy.java @@ -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(1); - context = new ArrayList(); - ustep = getProjectElementService().getFirstStep(_mystudy); - ustep.setActor(cuser); - involving.add(ustep); - for (Iterator i = ustep.getAllSimulationContexts() + _description = _mystudy.getDescription(); + _involving = new ArrayList(1); + _context = new ArrayList(); + _ustep = getProjectElementService().getFirstStep(_mystudy); + _ustep.setActor(_cuser); + _involving.add(_ustep); + for (Iterator 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 i = contents.iterator(); i.hasNext();) { + for (Iterator 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 i = context.iterator(); i + for (Iterator 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 i = known.list.iterator(); i + for (Iterator 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 i = involving.iterator(); i.hasNext();) { + _context.clear(); + for (Iterator i = _involving.iterator(); i.hasNext();) { for (Iterator 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/SearchKnowledgeAction.java b/Workspace/Siman/src/org/splat/simer/SearchKnowledgeAction.java index 0720eae..0ef7fc9 100644 --- a/Workspace/Siman/src/org/splat/simer/SearchKnowledgeAction.java +++ b/Workspace/Siman/src/org/splat/simer/SearchKnowledgeAction.java @@ -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 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 _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 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 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 getInvolvedContexts() { // ------------------------------------------------------------ return getSimulationContextService().selectAllTypes(); } + @Override @SuppressWarnings("unchecked") protected void loadFilter() { // ---------------------------- @@ -240,20 +271,21 @@ public class SearchKnowledgeAction extends SearchBaseAction { Map filter = (Map) 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) 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) 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 filter = (Map) 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) filter.get("context"); // Only criteria not part of the form + _context = (List) 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; } diff --git a/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java b/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java index f752eb3..766971a 100644 --- a/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java +++ b/Workspace/Siman/src/org/splat/simer/SearchStudyAction.java @@ -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 Roman Kozlov (RKV) */ -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 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 getInvolvedContexts() { - // ------------------------------------------------------------ List 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 session = getSession(); User user = getConnectedUser(); Map filter = (Map) 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) 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) filter.get("context"); if (user == null) { - visibility = "onlypublic"; + _visibility = "onlypublic"; } } + @Override @SuppressWarnings("unchecked") protected void saveFilter() { - // ---------------------------- Map session = getSession(); Map filter = (Map) 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) filter.get("context"); // Only criteria not part of the form + _context = (List) 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; } diff --git a/Workspace/Siman/src/org/splat/simer/SimulationContextFacade.java b/Workspace/Siman/src/org/splat/simer/SimulationContextFacade.java index 3cd145f..1124d3d 100644 --- a/Workspace/Siman/src/org/splat/simer/SimulationContextFacade.java +++ b/Workspace/Siman/src/org/splat/simer/SimulationContextFacade.java @@ -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 allSteps) { -// -------------------------------------------------------------- - my = represented; - popup = ApplicationSettings.getPopupMenu("scontext"); - - SimulationContextType type = my.getType(); - for (Iterator 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 allSteps) { + _my = represented; + _popup = ApplicationSettings.getPopupMenu("scontext"); + + SimulationContextType type = _my.getType(); + for (Iterator 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 diff --git a/Workspace/Siman/src/org/splat/simer/StampFacade.java b/Workspace/Siman/src/org/splat/simer/StampFacade.java index 481133f..368f1da 100644 --- a/Workspace/Siman/src/org/splat/simer/StampFacade.java +++ b/Workspace/Siman/src/org/splat/simer/StampFacade.java @@ -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 diff --git a/Workspace/Siman/src/org/splat/simer/StartAction.java b/Workspace/Siman/src/org/splat/simer/StartAction.java index 8eaab0a..1299731 100644 --- a/Workspace/Siman/src/org/splat/simer/StartAction.java +++ b/Workspace/Siman/src/org/splat/simer/StartAction.java @@ -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 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 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; diff --git a/Workspace/Siman/src/org/splat/simer/StudyMenu.java b/Workspace/Siman/src/org/splat/simer/StudyMenu.java index a3af298..be1930d 100644 --- a/Workspace/Siman/src/org/splat/simer/StudyMenu.java +++ b/Workspace/Siman/src/org/splat/simer/StudyMenu.java @@ -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; } diff --git a/Workspace/Siman/src/org/splat/simer/StudyPropertiesAction.java b/Workspace/Siman/src/org/splat/simer/StudyPropertiesAction.java index e38497d..452ee07 100644 --- a/Workspace/Siman/src/org/splat/simer/StudyPropertiesAction.java +++ b/Workspace/Siman/src/org/splat/simer/StudyPropertiesAction.java @@ -120,13 +120,13 @@ public class StudyPropertiesAction extends DisplayStudyStepAction { */ public String doInitialize() { - mystudy = getOpenStudy(); + _openStudy = getOpenStudy(); validation = new Vector(); validefault = null; other = getDocumentTypeService().selectResultTypes(); - Study study = mystudy.getStudyObject(); - StudyRights user = mystudy.getStudyRights(); + Study study = _openStudy.getStudyObject(); + StudyRights user = _openStudy.getStudyRights(); for (Iterator 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(); validefault = null; other = getDocumentTypeService().selectResultTypes(); - Study study = mystudy.getStudyObject(); + Study study = _openStudy.getStudyObject(); for (Iterator 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(); validefault = null; other = getDocumentTypeService().selectAllTypes(); - Study study = mystudy.getStudyObject(); + Study study = _openStudy.getStudyObject(); for (Iterator 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(); validefault = null; other = getDocumentTypeService().selectResultTypes(); - Study study = mystudy.getStudyObject(); + Study study = _openStudy.getStudyObject(); for (Iterator 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 getCandidates() { @@ -418,7 +418,7 @@ public class StudyPropertiesAction extends DisplayStudyStepAction { public String getStudyTitle() { // ------------------------------ - return mystudy.getTitle(); + return _openStudy.getTitle(); } public List getValidations() { diff --git a/Workspace/Siman/src/org/splat/simer/ValidationFacade.java b/Workspace/Siman/src/org/splat/simer/ValidationFacade.java index 34c665d..ba40df6 100644 --- a/Workspace/Siman/src/org/splat/simer/ValidationFacade.java +++ b/Workspace/Siman/src/org/splat/simer/ValidationFacade.java @@ -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 diff --git a/Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java b/Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java index d171ce1..f962e76 100644 --- a/Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java +++ b/Workspace/Siman/src/org/splat/simer/VersionDocumentAction.java @@ -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 usedby = null; + private transient List _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(); - usedby = new Vector(); - - if (!extractProperties(upfile, doc)) { - if (!("none".equals(_toolProperty))) { - setToolProperty("none"); - setLeftMenuProperty("study"); + defuses = new ArrayList(); + _usedby = new ArrayList(); + + String res = SUCCESS; + if (extractProperties(upfile, doc)) { + setupDefaultUses(deftype); + // Add additional documents used by the current version + List uses = doc.getRelations(UsesRelation.class); + for (Iterator 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 uses = doc.getRelations(UsesRelation.class); - for (Iterator i = uses.iterator(); i.hasNext();) { - Document used = (Document) i.next().getTo(); - if (!defuses.contains(used)) - defuses.add(used); - } - // Setup dependencies - List relist = tag.getRelations(UsedByRelation.class); - for (Iterator 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 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 index 0000000..54fc75f --- /dev/null +++ b/Workspace/Siman/src/org/splat/wapp/Constants.java @@ -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"; +} diff --git a/Workspace/Siman/src/spring/applicationContext.xml b/Workspace/Siman/src/spring/applicationContext.xml index cdcfa55..d51647d 100644 --- a/Workspace/Siman/src/spring/applicationContext.xml +++ b/Workspace/Siman/src/spring/applicationContext.xml @@ -68,7 +68,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> scope="session" parent="slidMenu" /> + class="org.splat.simer.AbstractOpenObject" scope="session"> -- 2.39.2
<%=locale.getString("type.knowledge." + type.getType())%>