From 10aced1a95cb83f35ee202f70fbc5f8132238354 Mon Sep 17 00:00:00 2001 From: rkv Date: Wed, 13 Feb 2013 11:41:31 +0000 Subject: [PATCH] JSP are updated to use more struts tags. Javadoc comments are added. --- Workspace/Siman/WebContent/js/search.js | 5 - .../Siman/WebContent/jsp/editKnowledge.jsp | 4 +- Workspace/Siman/WebContent/login.jsp | 8 +- .../Siman/WebContent/study/importDocument.jsp | 88 ++++----- .../WebContent/study/searchKnowledge.jsp | 116 +++++------- .../Siman/WebContent/study/searchStudy.jsp | 124 ++++++------- .../splat/simer/AbstractSearchBaseAction.java | 85 ++++++++- .../org/splat/simer/ImportDocumentAction.java | 171 +++++++++++------- 8 files changed, 332 insertions(+), 269 deletions(-) diff --git a/Workspace/Siman/WebContent/js/search.js b/Workspace/Siman/WebContent/js/search.js index 91956e1..69c905b 100644 --- a/Workspace/Siman/WebContent/js/search.js +++ b/Workspace/Siman/WebContent/js/search.js @@ -1,5 +1,4 @@ function initialize (result) { -// ---------------------------- var state = search.state.value; if (state == "inWORK" || state == "inDRAFT" || state == "inCHECK") { @@ -11,7 +10,6 @@ } function setState () { -// -------------------- var state = search.state.value; if (state == "inWORK" || state == "inDRAFT" || state == "inCHECK") { @@ -26,7 +24,6 @@ } function changeFilter () { -// ------------------------ var result = document.getElementById("resulist"); search.elements[0].value = "0"; // Marks the result obsolete @@ -35,13 +32,11 @@ } function removeContext (index) { -// ------------------------------ search.elements[0].value = index; search.submit(); } function cancel () { -// ------------------ search.elements[0].value = "-1"; search.submit(); } \ No newline at end of file diff --git a/Workspace/Siman/WebContent/jsp/editKnowledge.jsp b/Workspace/Siman/WebContent/jsp/editKnowledge.jsp index 2ae4fd4..745e5df 100644 --- a/Workspace/Siman/WebContent/jsp/editKnowledge.jsp +++ b/Workspace/Siman/WebContent/jsp/editKnowledge.jsp @@ -21,8 +21,8 @@ %> + - <% for (Iterator knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) { AbstractOpenObject.KnowledgeIterator type = knowtypes.next(); @@ -77,7 +77,6 @@ <% if (todo == Action.editKnowledge && kelm.getIndex().equals(typenumber)) { %>
- @@ -115,7 +114,6 @@
- diff --git a/Workspace/Siman/WebContent/login.jsp b/Workspace/Siman/WebContent/login.jsp index 5c5f09f..30a641c 100644 --- a/Workspace/Siman/WebContent/login.jsp +++ b/Workspace/Siman/WebContent/login.jsp @@ -19,13 +19,11 @@ $(document).ready(function () { - - - - + - + diff --git a/Workspace/Siman/WebContent/study/importDocument.jsp b/Workspace/Siman/WebContent/study/importDocument.jsp index 957a23b..8d8c00b 100644 --- a/Workspace/Siman/WebContent/study/importDocument.jsp +++ b/Workspace/Siman/WebContent/study/importDocument.jsp @@ -3,95 +3,83 @@ <%@ taglib prefix="s" uri="/struts-tags"%> -
-
-
- - +
+
+
+
+ - +
- - - + name="version" /> +
+ - - + + - - + + - + - - + - - + +
      
- -   - - " - />   + + + +
::
" checked>
" /> " />   +
diff --git a/Workspace/Siman/WebContent/study/searchKnowledge.jsp b/Workspace/Siman/WebContent/study/searchKnowledge.jsp index a2fc887..301513c 100644 --- a/Workspace/Siman/WebContent/study/searchKnowledge.jsp +++ b/Workspace/Siman/WebContent/study/searchKnowledge.jsp @@ -1,38 +1,16 @@ <%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> -<%@page import="org.splat.som.ApplicationRights"%> -<%@page import="java.util.ResourceBundle"%> -<%@page import="java.text.SimpleDateFormat"%> -<%@page import="org.splat.simer.Action"%> -<%@page import="com.opensymphony.xwork2.ActionContext"%> <%@taglib prefix="s" uri="/struts-tags"%> -<% - ApplicationRights rights = (ApplicationRights)session.getAttribute("user.rights"); - Action anAction = (Action)ActionContext.getContext().getActionInvocation().getAction(); - ResourceBundle locale = ResourceBundle.getBundle("som", - anAction.getApplicationSettings().getCurrentLocale()); - String format = locale.getString("date.format"); - SimpleDateFormat tostring = new SimpleDateFormat(format); - String result = "uptodate"; - boolean connected = false; - - if (rights.getUser() != null) connected = true; - if (session.getAttribute("search.result") == null) result = "obsolete"; -%> - -<%=connected%> -<%=format%> -<%=tostring.format(java.util.Calendar.getInstance().getTime())%> @@ -43,49 +21,49 @@ $(document).ready(function () {
- + - - -
+ + + - - +
    - +   - + - +   - + |   + |       - +   - + - +   - +
- - -
- +
+ + -
+ - - + - - + - - + + - + - +
  +  
  +  
   " /> " />   " />" />
- +
- + - +
" value="" onKeydown="changeFilter()" title="" />" value="" onKeydown="changeFilter()" title="" />
" value="" onKeydown="changeFilter()" title="" />" value="" onKeydown="changeFilter()" title="" />
- +
+ - +
')"> ')">  @@ -191,10 +169,10 @@ $(document).ready(function () {
- +
- - + +
" disabled/>" disabled/>
@@ -205,23 +183,23 @@ $(document).ready(function () { -
-
-
-
+
+
+
+
- - - - +
+ + + - + - + - +
" border="none"/>
" width=12 height=12 border="none" title=""/>" width="12" height="12" border="none" title=""/> diff --git a/Workspace/Siman/WebContent/study/searchStudy.jsp b/Workspace/Siman/WebContent/study/searchStudy.jsp index 67166f5..b2280e1 100644 --- a/Workspace/Siman/WebContent/study/searchStudy.jsp +++ b/Workspace/Siman/WebContent/study/searchStudy.jsp @@ -1,94 +1,72 @@ <%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> -<%@page import="org.splat.som.ApplicationRights"%> -<%@page import="java.util.ResourceBundle"%> -<%@page import="java.text.SimpleDateFormat"%> -<%@page import="org.splat.simer.Action"%> -<%@page import="com.opensymphony.xwork2.ActionContext"%> <%@taglib prefix="s" uri="/struts-tags"%> -<% - ApplicationRights rights = (ApplicationRights)session.getAttribute("user.rights"); - Action anAction = (Action)ActionContext.getContext().getActionInvocation().getAction(); - ResourceBundle locale = ResourceBundle.getBundle("som", - anAction.getApplicationSettings().getCurrentLocale()); - String format = locale.getString("date.format"); - SimpleDateFormat tostring = new SimpleDateFormat(format); - String result = "uptodate"; - boolean connected = false; - - if (rights.getUser() != null) connected = true; - if (session.getAttribute("search.result") == null) result = "obsolete"; -%> - -<%=connected%> -<%=format%> -<%=tostring.format(java.util.Calendar.getInstance().getTime())%> -
-
+
+
- + - - -
+ + + - - +
    - +   - + - +   - + |   + |       - +   - + - +   - +
- - -
- +
+ + -
+ - - + - - + - - + + - + - + - + - +
  +  
  +  
   " /> " />   " />" />
   " /> " />   " />" />
- +
- + - +
" value="" onKeydown="changeFilter()" title="" />" value="" onKeydown="changeFilter()" title="" />
" value="" onKeydown="changeFilter()" title="" />" value="" onKeydown="changeFilter()" title="" />
- +
+ - +
')"> ')">  @@ -197,10 +175,10 @@ $(document).ready(function () {
- +
- - + +
" disabled/>" disabled/>
@@ -211,20 +189,20 @@ $(document).ready(function () { -
-
-
-
+
+
+
+
- - - - +
+ + + - + - + diff --git a/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java b/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java index c966268..276ca13 100644 --- a/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java +++ b/Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java @@ -1,5 +1,6 @@ package org.splat.simer; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -16,6 +17,11 @@ import org.splat.service.dto.Proxy; import org.splat.service.technical.ProjectSettingsService; import org.splat.som.ApplicationRights; +/** + * Base search action class used for searching studies and knowledge. + * + * @author Roman Kozlov (RKV) + */ public abstract class AbstractSearchBaseAction extends Action { /** @@ -58,6 +64,9 @@ public abstract class AbstractSearchBaseAction extends Action { * Current contexts search criteria. */ protected transient List _context; + /** + * List of found objects. + */ protected transient List _result; /** * Injected simulation context service. @@ -69,6 +78,9 @@ public abstract class AbstractSearchBaseAction extends Action { */ private UserService _userService; + /** + * Search action modes enumeration. + */ enum UserAction { refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext } @@ -77,6 +89,11 @@ public abstract class AbstractSearchBaseAction extends Action { // Action methods // ============================================================================================================================== + /** + * Perform actions according to the current mode. + * + * @return action result or ERROR if failed + */ public String doSubmitForm() { // Identification of the user action UserAction action = UserAction.refreshResult; @@ -118,6 +135,11 @@ public abstract class AbstractSearchBaseAction extends Action { return done; } + /** + * Add a selected context type to the search filter. Obsolete the current result if necessary. + * + * @return "selectype" + */ @SuppressWarnings("unchecked") protected String doSelectContextType() { SimulationContext.Properties sprop = new SimulationContext.Properties(); @@ -129,11 +151,17 @@ public abstract class AbstractSearchBaseAction extends Action { 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 + // We keep the previous result search, if valid + _result = (List) getSession().get(RESULT_KEY); } return "selectype"; } + /** + * Add a selected context to the search filter. Obsolete the current result. + * + * @return "refresh" + */ protected String doAddContext() { SimulationContext selected = getSimulationContextService() .selectSimulationContext(Integer.valueOf(_cvalue)); @@ -144,6 +172,11 @@ public abstract class AbstractSearchBaseAction extends Action { return "refresh"; } + /** + * Remove context from the search filter. + * + * @return "refresh" + */ protected String doRemoveContext() { int index = Integer.valueOf(_cindex); for (Iterator selected = _context.iterator(); selected @@ -158,6 +191,10 @@ public abstract class AbstractSearchBaseAction extends Action { return "refresh"; } + /** + * + * @return + */ @SuppressWarnings("unchecked") protected String doCancel() { _result = (List) getSession().get(RESULT_KEY); // Current result search @@ -169,6 +206,41 @@ public abstract class AbstractSearchBaseAction extends Action { // Getters // ============================================================================================================================== + /** + * Get date format string. + * + * @return date format string + */ + public String getFormat() { + return getText("date.format"); + } + + /** + * Get formatted today date as a string. + * + * @return current date as a string + */ + public String getToday() { + SimpleDateFormat tostring = new SimpleDateFormat(getFormat(), + getApplicationSettings().getCurrentLocale()); + return tostring.format(java.util.Calendar.getInstance().getTime()); + } + + /** + * Get search result state. + * + * @return "obsolete" if there is no results in the session, otherwise "uptodate" + */ + public String getResultState() { + String result; + if (getSession().get(RESULT_KEY) == null) { + result = "obsolete"; + } else { + result = "uptodate"; + } + return result; + } + public String getAuthor() { return _author; } @@ -193,6 +265,11 @@ public abstract class AbstractSearchBaseAction extends Action { return _context; } + /** + * Get list of found objects. + * + * @return list of found objects + */ public List getResult() { return _result; } @@ -235,6 +312,12 @@ public abstract class AbstractSearchBaseAction extends Action { } } + /** + * Build available context types list with localized names. + * + * @param critext + * context types already used in the search filter + */ protected void setContextTypeOptions( final List critext) { for (Iterator i = _context.iterator(); i.hasNext();) { diff --git a/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java b/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java index faf4dfe..1b376a4 100644 --- a/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java +++ b/Workspace/Siman/src/org/splat/simer/ImportDocumentAction.java @@ -38,7 +38,13 @@ public class ImportDocumentAction extends UploadBaseNextAction { */ private static final long serialVersionUID = 2587822564883588556L; + /** + * Sorted list of document types for the selected study step. + */ private transient List _documentTypes = null; + /** + * The selected document type. + */ private long _documentType = 0; /** * Reference extracted from the imported file, if exist. @@ -109,7 +115,7 @@ public class ImportDocumentAction extends UploadBaseNextAction { // Set the document type by default deftype = getApplicationSettings().getDefaultDocumentType(step, filext); if (deftype != null) { - setDefaultDocumentType(Long.toString(deftype.getIndex())); + setDefaultDocumentType(deftype.getIndex()); } defuses = new ArrayList(); state = ProgressState.inWORK; @@ -196,7 +202,8 @@ public class ImportDocumentAction extends UploadBaseNextAction { ResourceBundle locale = ResourceBundle.getBundle("som", getApplicationSettings().getCurrentLocale()); SimpleDateFormat check = new SimpleDateFormat(locale - .getString("date.format")); + .getString("date.format"), + getApplicationSettings().getCurrentLocale()); try { check.parse(_documentDate); } catch (ParseException e) { @@ -257,80 +264,82 @@ public class ImportDocumentAction extends UploadBaseNextAction { * @return SUCCESS if ok, "cancel" - if canceled, ERROR - if error */ public String doImport() { + String result = ERROR; initializationScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU, Constants.TRUE); if (action == ToDo.cancel) { - return "cancel"; - } - if (_documentType == 0) { + result = "cancel"; + } else if (_documentType == 0) { setErrorCode("message.error.import.type"); initializationFullScreenContext(Constants.STUDY_MENU, Constants.STUDY_MENU, Constants.TRUE, Constants.NONE, Constants.STUDY_MENU); - - return ERROR; - } - try { - // Getting user inputs - mystudy = getOpenStudy(); - User user = getConnectedUser(); - Step step = mystudy.getSelectedStep(); - Date docdate = null; - if (_documentDate.length() > 0) { - ResourceBundle locale = ResourceBundle.getBundle("som", - getApplicationSettings().getCurrentLocale()); - SimpleDateFormat get = new SimpleDateFormat(locale - .getString("date.format")); - docdate = get.parse(_documentDate); - } - // Creation of uses relations - List uses = new ArrayList(); - if (docuses != null) { - String[] list = docuses.split(","); - for (int i = 0; i < list.length; i++) { - uses.add(Long.valueOf(list[i].trim())); + } else { + try { + // Getting user inputs + mystudy = getOpenStudy(); + User user = getConnectedUser(); + Step step = mystudy.getSelectedStep(); + Date docdate = null; + if (_documentDate.length() > 0) { + ResourceBundle locale = ResourceBundle.getBundle("som", + getApplicationSettings().getCurrentLocale()); + SimpleDateFormat get = new SimpleDateFormat(locale + .getString("date.format"), getApplicationSettings() + .getCurrentLocale()); + docdate = get.parse(_documentDate); } - } - if (LOG.isDebugEnabled()) { - LOG - .debug("Document to be imported uses documents with following ids:"); - for (Long usesId : uses) { - LOG.debug("#" + usesId); + // Creation of uses relations + List uses = new ArrayList(); + if (docuses != null) { + String[] list = docuses.split(","); + for (int i = 0; i < list.length; i++) { + uses.add(Long.valueOf(list[i].trim())); + } } - } - Publication addoc = getPublicationService().createDoc( - mystudy.getIndex(), step, _documentType, user.getIndex(), - filename, docname, state, _reference, _version, docdate, - uses); + if (LOG.isDebugEnabled()) { + LOG + .debug("Document to be imported uses documents with following ids:"); + for (Long usesId : uses) { + LOG.debug("#" + usesId); + } + } + Publication addoc = getPublicationService().createDoc( + mystudy.getIndex(), step, _documentType, + user.getIndex(), filename, docname, state, _reference, + _version, docdate, uses); - if (_reference.length() > 0) { // Importation of a not foreign document - mystudy.updateSimulationContexts(); // In case of simulation contexts extracted from the imported document + if (_reference.length() > 0) { // Importation of a not foreign document + mystudy.updateSimulationContexts(); // In case of simulation contexts extracted from the imported document + } + + // Creation of derived the document formats + // Document ndoc = addoc.value(); + // Converter send = getApplicationSettings().getConverter(ndoc.getType(), ndoc.getFormat()); + // + // if (send != null) send.converts(addoc); // Asynchronous process + + mystudy.add(addoc); // Updates the presentation + result = SUCCESS; + } catch (FileNotFoundException error) { + LOG.error("Reason:", error); + setErrorCode("message.error.import.file"); + } catch (Exception error) { + LOG.error("Reason:", error); + setErrorCode("message.error.internal"); } - // Creation of derived the document formats - // Document ndoc = addoc.value(); - // Converter send = getApplicationSettings().getConverter(ndoc.getType(), ndoc.getFormat()); - // - // if (send != null) send.converts(addoc); // Asynchronous process - - mystudy.add(addoc); // Updates the presentation - return SUCCESS; - } catch (FileNotFoundException error) { - LOG.error("Reason:", error); - setErrorCode("message.error.import.file"); - } catch (Exception error) { - LOG.error("Reason:", error); - setErrorCode("message.error.internal"); + if (!SUCCESS.equals(result)) { + initializationFullScreenContext(Constants.STUDY_MENU, + Constants.STUDY_MENU, Constants.TRUE, Constants.NONE, + Constants.STUDY_MENU); + } } - initializationFullScreenContext(Constants.STUDY_MENU, - Constants.STUDY_MENU, Constants.TRUE, Constants.NONE, - Constants.STUDY_MENU); - - return ERROR; + return result; } // ============================================================================================================================== @@ -346,6 +355,11 @@ public class ImportDocumentAction extends UploadBaseNextAction { return _documentDate; } + /** + * Get sorted list of document types valid for the selected study step. + * + * @return sorted list of document types + */ public List getDocumentTypes() { return _documentTypes; } @@ -397,6 +411,12 @@ public class ImportDocumentAction extends UploadBaseNextAction { this.docname = name; // Name entered by the user if enabled } + /** + * Set the default title if no title was defined. + * + * @param name + * the default document title + */ public void setDocumentTitle(final String name) { // Called even if DocumentName is enabled if (this.docname == null) { this.docname = name; @@ -409,19 +429,31 @@ public class ImportDocumentAction extends UploadBaseNextAction { * @param value * the id as string */ - public void setDocumentType(final String value) { - this._documentType = Integer.valueOf(value); + public void setDocumentType(final Long value) { + this._documentType = value; } + /** + * Set the default state if no state was selected. + * + * @param state + * the default state + */ public void setDefaultDocumentState(final String state) { // Called even if DocumentState is enabled if (this.state == null) { this.state = ProgressState.valueOf(state); } } - public void setDefaultDocumentType(final String value) { // Called even if DocumentType is enabled + /** + * Set the default type if no type was selected. + * + * @param value + * the default document type id + */ + public void setDefaultDocumentType(final Long value) { // Called even if DocumentType is enabled if (this._documentType == 0) { - this._documentType = Integer.valueOf(value); + this._documentType = value; } } @@ -561,4 +593,17 @@ public class ImportDocumentAction extends UploadBaseNextAction { final DocumentTypeService documentTypeService) { _documentTypeService = documentTypeService; } + + /** + * Get sorted list of available document states. + * + * @return the documentStates + */ + public List getDocumentStates() { + List states = new ArrayList(); + states.add(ProgressState.inWORK); + states.add(ProgressState.inDRAFT); + states.add(ProgressState.EXTERN); + return states; + } } \ No newline at end of file -- 2.39.2
" border="none"/>
" width=12 height=12 border="none" title=""/>