<%@ page import="org.splat.wapp.Menu"%>
<%@ page import="org.splat.wapp.MenuItem"%>
<%@ page import="org.splat.simer.Action"%>
+<%@page import="com.opensymphony.xwork2.ActionContext"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
- <%@page import="com.opensymphony.xwork2.ActionContext"%>
<s:set var="menuname" value="leftMenuSettings.menuName" />
<s:set var="namespace" value="leftMenuSettings.menuNamespace" />
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
%>
-<%@ page import="org.splat.dal.bo.som.KnowledgeElement"%>
-<%@ page import="org.splat.som.ApplicationRights"%>
-<%@ page import="org.splat.simer.ApplicationSettings"%>
-<%@ page import="java.util.ResourceBundle"%>
-<%@ page import="java.util.Calendar"%>
-<%@ page import="java.text.SimpleDateFormat"%>
-<%@
- taglib prefix="s" uri="/struts-tags"
-%>
+<%@page import="org.splat.dal.bo.som.KnowledgeElement"%>
+<%@page import="org.splat.som.ApplicationRights"%>
+<%@page import="org.splat.simer.ApplicationSettings"%>
+<%@page import="java.util.ResourceBundle"%>
+<%@page import="java.util.Calendar"%>
+<%@page import="java.text.SimpleDateFormat"%>
+<%@page import="org.splat.simer.Action"%>
+<%@page import="com.opensymphony.xwork2.ActionContext"%>
+<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Initialization of the context
-->
<%
ApplicationRights rights = (ApplicationRights)session.getAttribute("user.rights");
- ResourceBundle locale = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
+ 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";
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
%>
-<%@ page import="org.splat.dal.bo.som.Study"%>
-<%@ page import="org.splat.som.ApplicationRights"%>
-<%@ page import="org.splat.simer.ApplicationSettings"%>
-<%@ page import="java.util.ResourceBundle"%>
-<%@ page import="java.util.Calendar"%>
-<%@ page import="java.text.SimpleDateFormat"%>
-<%@
- taglib prefix="s" uri="/struts-tags"
-%>
+<%@page import="org.splat.dal.bo.som.Study"%>
+<%@page import="org.splat.som.ApplicationRights"%>
+<%@page import="org.splat.simer.ApplicationSettings"%>
+<%@page import="java.util.ResourceBundle"%>
+<%@page import="java.util.Calendar"%>
+<%@page import="java.text.SimpleDateFormat"%>
+<%@page import="org.splat.simer.Action"%>
+<%@page import="com.opensymphony.xwork2.ActionContext"%>
+<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Initialization of the context
-->
<%
ApplicationRights rights = (ApplicationRights)session.getAttribute("user.rights");
- ResourceBundle locale = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
+ 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";
*/
public abstract class AbstractOpenObject implements Proxy {
- protected static Map<Long, DocumentFacade> docpres = null;
- protected static Map<Long, KnowledgeElementFacade> knowpres = null;
+ /**
+ * Current open study step cache for presented documents.
+ */
+ protected Map<Long, DocumentFacade> docpres = null;
+ /**
+ * Current open study step cache for presented knowledges.
+ */
+ protected Map<Long, KnowledgeElementFacade> knowpres = null;
/**
* Connected user.
.getIndex());
if (facade == null) {
facade = new KnowledgeElementFacade(BeanHelper
- .copyBean(current, KnowledgeElementDTO.class));
+ .copyBean(current, KnowledgeElementDTO.class),
+ getApplicationSettings());
knowpres.put(current.getIndex(), facade);
}
display.add(facade);
DocumentFacade facade = docpres.get(index);
if (facade == null) {
facade = new DocumentFacade(this, present,
- getProjectSettings(), getPublicationService());
+ getProjectSettings(), getPublicationService(),
+ getApplicationSettings());
docpres.put(index, facade);
}
_contents.add(facade);
* Serial version ID.
*/
private static final long serialVersionUID = 7863055790228544510L;
-
+
/**
* Search result key in the session.
*/
_newtype = getSimulationContextService().selectType(
Integer.valueOf(_ctype));
- _newvalue = getSimulationContextService().selectSimulationContextsWhere(
- sprop.setType(_newtype));
+ _newvalue = getSimulationContextService()
+ .selectSimulationContextsWhere(sprop.setType(_newtype));
if (_cindex.length() > 0 && Integer.valueOf(_cindex) == 0) {
getSession().remove(RESULT_KEY);
} else {
ApplicationRights he = new ApplicationRights(next);
if (he.canCreateStudy()) {
if (next.equals(me)) {
- _candidates.add(0, new ValidationFacade.ByManager(me));
+ _candidates.add(0, new ValidationFacade.ByManager(me,
+ getApplicationSettings().getCurrentLocale()));
} else {
_candidates.add(next);
}
}
}
- protected void setContextTypeOptions(final List<SimulationContextType> critext) {
+ protected void setContextTypeOptions(
+ final List<SimulationContextType> critext) {
for (Iterator<SimulationContext> i = _context.iterator(); i.hasNext();) {
critext.remove(i.next().getType()); // Already used context type
}
/**
* Get the userService.
+ *
* @return the userService
*/
public UserService getUserService() {
/**
* Set the userService.
- * @param userService the userService to set
+ *
+ * @param userService
+ * the userService to set
*/
public void setUserService(final UserService userService) {
_userService = userService;
*/
public int compare(final DocumentType t1, final DocumentType t2) {
ResourceBundle locale = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
String name1 = t1.getName();
if (t1.isApproved()) {
name1 = locale.getString("type.document." + name1);
public int compare(final SimulationContextType t1,
final SimulationContextType t2) {
ResourceBundle locale = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
String name1 = t1.getName();
if (t1.isApproved()) {
name1 = locale.getString("type.context." + name1);
import java.util.Properties;
import java.util.Set;
-import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.splat.wapp.PopupMenu;
import org.splat.wapp.SimpleMenu;
import org.splat.wapp.ToolBar;
-import org.springframework.web.context.ServletContextAware;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* SIMAN project settings service. Provides settings according to XML customization.
*/
-public class ApplicationSettings implements ServletContextAware {
+public class ApplicationSettings {
/**
* Application settings logger.
*/
protected final static Logger LOG = Logger
.getLogger(ApplicationSettings.class);
-
/**
- * Singleton instance of application settings service.
+ * JNDI context for launching converters.
+ */
+ private transient static final Properties _jndprops;
+ /**
+ * Siman web application name.
*/
- private static final ApplicationSettings MY_APP = new ApplicationSettings();
+ private transient static String _wappname;
+ /**
+ * General properties from the application properties files.
+ */
+ private transient static final Properties _wapprops = new Properties();
+ /**
+ * Siman web application root path on the server.
+ */
+ private transient static String _wapproot;
+ /**
+ * Available template files.
+ */
+ private transient static Map<String, String> _tempfile;
+ /**
+ * List of file extensions mapped to a viewer.
+ */
+ private transient static String[] _viewermap;
+ /**
+ * Available document format converters.
+ */
+ private transient static Map<String, Converter> _convertmap;
+
+ static {
+ synchronized (_wapprops) {
+ // Do common configuration for all users
+
+ _jndprops = new Properties();
+ _tempfile = new HashMap<String, String>();
+ _viewermap = new String[0];
+ _convertmap = new HashMap<String, Converter>();
+
+ ClassLoader cloader = Thread.currentThread()
+ .getContextClassLoader();
+ HttpServletRequest curRequest = ((ServletRequestAttributes) RequestContextHolder
+ .currentRequestAttributes()).getRequest();
+ String appname = curRequest.getContextPath();
+ if (appname.startsWith("/")) {
+ _wappname = appname.substring(1);
+ }
+ // Set local path on the server to the application root.
+ _wapproot = curRequest.getSession().getServletContext()
+ .getRealPath("/");
+
+ try {
+ _jndprops.load(cloader.getResourceAsStream("jndi.properties"));
+ _wapprops.load(cloader.getResourceAsStream(_wappname
+ + ".properties"));
+ } catch (IOException e) {
+ LOG.info(
+ "Can't load application properties: " + e.getMessage(),
+ e);
+ }
+
+ // Configure login security
+ System.setProperty("java.security.auth.login.config", _wapproot
+ + ApplicationSettings.getApplicationProperty("wapp.login"));
+
+ // Customization (must be done after above default settings)
+ File config = new File(_wapproot
+ + getApplicationProperty("wapp.customization"));
+ if (config.exists()) {
+ loadCustomization(config); // Sets default document types, installed modules and available templates
+ } else {
+ LOG.info("Could not find the application configuration file \""
+ + config.getAbsolutePath()
+ + "\", using default settings");
+ }
+ }
+ }
/**
* All value.
*/
private static final String ACT_VERSION = "select-file?nextAction=version";
- /**
- * Injected servlet context to get path to resources.
- */
- private transient ServletContext _servletContext;
-
/**
* Siman application server name.
*/
- private transient String _wappserver;
- /**
- * Siman web application name.
- */
- private transient String _wappname;
- /**
- * General properties from the application properties files.
- */
- private transient final Properties _wapprops = new Properties();
+ private transient final String _wappserver;
/**
* Current user locale.
*/
* Named search filters.
*/
private transient Map<String, Map<String, Object>> _filter = null;
- /**
- * Available template files.
- */
- private transient Map<String, String> _tempfile = null;
- /**
- * List of file extensions mapped to a viewer.
- */
- private transient String[] _viewermap = null;
- /**
- * Available document format converters.
- */
- private transient Map<String, Converter> _convertmap = null;
- /**
- * JNDI context for launching converters.
- */
- private transient final Properties _jndprops = new Properties();
/**
* Injected project settings service.
*/
*/
private DocumentTypeService _documentTypeService;
+ /**
+ * Application settings constructor.
+ */
+ public ApplicationSettings() {
+ HttpServletRequest curRequest = ((ServletRequestAttributes) RequestContextHolder
+ .currentRequestAttributes()).getRequest();
+ _wappserver = curRequest.getServerName() + ":"
+ + curRequest.getServerPort();
+
+ LOG.info("Application server is set to " + _wappserver);
+ LOG.info("Application name is set to " + _wappname);
+ }
+
/**
* Get the projectSettingsService.
*
super("create");
addItem("new-empty", "menu.new.empty", "image.empty.png",
"select?menu=create&item=new-empty");
- addItem("new-copy",
- new MenuItem("menu.new.copy").icon("image.copy.png"));
- addItem("new-instance",
- new MenuItem("menu.new.instance").icon(IMG_HOLD));
- addItem("new-import",
- new MenuItem("menu.new.import").icon("icon.upload.png"));
+ addItem("new-copy", new MenuItem("menu.new.copy")
+ .icon("image.copy.png"));
+ addItem("new-instance", new MenuItem("menu.new.instance")
+ .icon(IMG_HOLD));
+ addItem("new-import", new MenuItem("menu.new.import")
+ .icon("icon.upload.png"));
this.selects("new-empty");
}
}
"select?menu=search&item=search-study");
addItem("search-knowledge", "menu.search.idea", "image.idea.png",
"select?menu=search&item=search-knowledge");
- addItem("search-document",
- new MenuItem("menu.search.document").icon("icon.any.png"));
+ addItem("search-document", new MenuItem("menu.search.document")
+ .icon("icon.any.png"));
this.selects("search-study");
}
}
"select?menu=datadmin&item=admin-scontext");
addItem("admin-knowelm", "menu.admin.knowledge", "image.idea.png",
"select?menu=datadmin&item=admin-knowelm");
- addItem("admin-study",
- new MenuItem("menu.admin.study").icon("image.study.png"));
+ addItem("admin-study", new MenuItem("menu.admin.study")
+ .icon("image.study.png"));
}
}
private EditableStudyPopup() {
super();
- addItem(MNU_PUBLISH,
- new PopupItem(MNU_NAME_PUBLISH).icon("image.publish.png")
- .action("edit-study?action=publish")
- .confirmation("message.publish.study"));
+ addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PUBLISH).icon(
+ "image.publish.png").action("edit-study?action=publish")
+ .confirmation("message.publish.study"));
addItem(MNU_PROMOTE, new PopupItem("menu.archive"));
addSeparator();
- addItem(MNU_EDIT,
- new PopupItem("menu.properties").icon("icon.ed.png")
- .action("../select?menu=properties"));
+ addItem(MNU_EDIT, new PopupItem("menu.properties").icon(
+ "icon.ed.png").action("../select?menu=properties"));
addSeparator();
- addItem(MNU_SCRIPT,
- new PopupItem(MNU_NAME_SCRIPT).action("add-scenario"));
- addItem(MNU_VERSION,
- new PopupItem(MNU_NAME_VERSION).icon(IMG_VERSION).action(
- ACT_NOT_YET_IMPLEMENTED));
+ addItem(MNU_SCRIPT, new PopupItem(MNU_NAME_SCRIPT)
+ .action("add-scenario"));
+ addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+ IMG_VERSION).action(ACT_NOT_YET_IMPLEMENTED));
addSeparator();
- addItem(MNU_PURGE,
- new PopupItem(MNU_NAME_PURGE)
- .confirmation("message.purge.study"));
- addItem("export",
- new PopupItem("menu.export").icon("image.export.png")); // For future needs
- addItem(MNU_REMOVE,
- new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
- .action(ACT_NOT_YET_IMPLEMENTED)
- .confirmation("message.delete.study"));
+ addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE)
+ .confirmation("message.purge.study"));
+ addItem("export", new PopupItem("menu.export")
+ .icon("image.export.png")); // For future needs
+ addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
+ .action(ACT_NOT_YET_IMPLEMENTED).confirmation(
+ "message.delete.study"));
}
@Override
private EditableDocumentPopup() {
super();
- addItem("accept",
- new PopupItem("menu.accept").icon("image.accept.png")
- .action("setDocument?action=accept")
- .confirmation("message.accept.document"));
- addItem(MNU_PROMOTE,
- new PopupItem(MNU_NAME_PROMOTE).icon("image.publish.png")
- .action("setDocument?action=promote")
- .confirmation("message.promote.document"));
+ addItem("accept", new PopupItem("menu.accept").icon(
+ "image.accept.png").action("setDocument?action=accept")
+ .confirmation("message.accept.document"));
+ addItem(MNU_PROMOTE, new PopupItem(MNU_NAME_PROMOTE).icon(
+ "image.publish.png").action("setDocument?action=promote")
+ .confirmation("message.promote.document"));
addSeparator();
- addItem(MNU_RENAME,
- new PopupItem(MNU_NAME_RENAME)
- .action("edit-document?action=renameDocument"));
+ addItem(MNU_RENAME, new PopupItem(MNU_NAME_RENAME)
+ .action("edit-document?action=renameDocument"));
addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
.action(ACT_ATTACH));
addSeparator();
- addItem(MNU_VERSION,
- new PopupItem(MNU_NAME_VERSION).icon(IMG_VERSION).action(
- ACT_VERSION));
- addItem("replace",
- new PopupItem("menu.replace").icon("image.replace.png")
- .action("select-file?nextAction=replace"));
+ addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+ IMG_VERSION).action(ACT_VERSION));
+ addItem("replace", new PopupItem("menu.replace").icon(
+ "image.replace.png").action(
+ "select-file?nextAction=replace"));
addSeparator();
- addItem(MNU_PURGE,
- new PopupItem(MNU_NAME_PURGE).action(
- ACT_NOT_YET_IMPLEMENTED).confirmation(
- "message.purge.document"));
- addItem(MNU_REMOVE,
- new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
- .action("remove-document")
- .confirmation("message.delete.document"));
+ addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE).action(
+ ACT_NOT_YET_IMPLEMENTED).confirmation(
+ "message.purge.document"));
+ addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
+ .action("remove-document").confirmation(
+ "message.delete.document"));
}
@Override
private ReviewableDocumentPopup() {
super();
- addItem(MNU_DEMOTE,
- new PopupItem(MNU_NAME_DEMOTE).icon("image.demote.png")
- .action("setDocument?action=demote")
- .confirmation("message.demote.document"));
- addItem(MNU_PROMOTE,
- new PopupItem("menu.review").icon("image.review.png")
- .action("setDocument?action=review")
- .confirmation("message.review.document"));
+ addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
+ "image.demote.png").action("setDocument?action=demote")
+ .confirmation("message.demote.document"));
+ addItem(MNU_PROMOTE, new PopupItem("menu.review").icon(
+ "image.review.png").action("setDocument?action=review")
+ .confirmation("message.review.document"));
addSeparator();
addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
.action(ACT_ATTACH));
addSeparator();
- addItem(MNU_VERSION,
- new PopupItem(MNU_NAME_VERSION).icon(IMG_VERSION).action(
- ACT_VERSION));
+ addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+ IMG_VERSION).action(ACT_VERSION));
addSeparator();
- addItem(MNU_PURGE,
- new PopupItem(MNU_NAME_PURGE).action(
- ACT_NOT_YET_IMPLEMENTED).confirmation(
- "message.purge.document"));
+ addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE).action(
+ ACT_NOT_YET_IMPLEMENTED).confirmation(
+ "message.purge.document"));
}
@Override
private NotResultDocumentPopup() {
super();
- addItem(MNU_DEMOTE,
- new PopupItem(MNU_NAME_DEMOTE).icon("image.demote.png")
- .action("setDocument?action=demote")
- .confirmation("message.demote.document"));
+ addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
+ "image.demote.png").action("setDocument?action=demote")
+ .confirmation("message.demote.document"));
addSeparator();
addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
.action(ACT_ATTACH));
addSeparator();
- addItem(MNU_VERSION,
- new PopupItem(MNU_NAME_VERSION).icon(IMG_VERSION).action(
- ACT_VERSION));
+ addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+ IMG_VERSION).action(ACT_VERSION));
addSeparator();
- addItem(MNU_PURGE,
- new PopupItem(MNU_NAME_PURGE).action(
- ACT_NOT_YET_IMPLEMENTED).confirmation(
- "message.purge.document"));
- addItem(MNU_REMOVE,
- new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
- .action("remove-document")
- .confirmation("message.delete.document"));
+ addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE).action(
+ ACT_NOT_YET_IMPLEMENTED).confirmation(
+ "message.purge.document"));
+ addItem(MNU_REMOVE, new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
+ .action("remove-document").confirmation(
+ "message.delete.document"));
}
}
private ApprovableDocumentPopup() {
super();
- addItem("undo",
- new PopupItem(MNU_NAME_DEMOTE).icon("image.invalidate.png")
- .action("setDocument?action=invalidate")
- .confirmation("message.demote.document"));
- addItem(MNU_DEMOTE,
- new PopupItem("menu.disapprove").icon("image.demote.png")
- .action("setDocument?action=disapprove")
- .confirmation("message.disapprove.document"));
- addItem("approve",
- new PopupItem("menu.approve").icon("icon.APPROVED.png")
- .action("setDocument?action=approve")
- .confirmation("message.approve.document"));
+ addItem("undo", new PopupItem(MNU_NAME_DEMOTE).icon(
+ "image.invalidate.png").action(
+ "setDocument?action=invalidate").confirmation(
+ "message.demote.document"));
+ addItem(MNU_DEMOTE, new PopupItem("menu.disapprove").icon(
+ "image.demote.png").action("setDocument?action=disapprove")
+ .confirmation("message.disapprove.document"));
+ addItem("approve", new PopupItem("menu.approve").icon(
+ "icon.APPROVED.png").action("setDocument?action=approve")
+ .confirmation("message.approve.document"));
}
@Override
addItem(MNU_ATTACH, new PopupItem(MNU_NAME_ATTACH).icon(IMG_ATTACH)
.action(ACT_ATTACH));
addSeparator();
- addItem(MNU_VERSION,
- new PopupItem(MNU_NAME_VERSION).icon(IMG_VERSION).action(
- ACT_VERSION));
+ addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon(
+ IMG_VERSION).action(ACT_VERSION));
}
}
private ExternPopup() {
super();
- addItem(MNU_RENAME,
- new PopupItem(MNU_NAME_RENAME)
- .action("edit-document?action=renameDocument"));
- addItem("replace",
- new PopupItem("menu.replace").icon("image.replace.png")
- .action("select-file?nextAction=replace"));
+ addItem(MNU_RENAME, new PopupItem(MNU_NAME_RENAME)
+ .action("edit-document?action=renameDocument"));
+ addItem("replace", new PopupItem("menu.replace").icon(
+ "image.replace.png").action(
+ "select-file?nextAction=replace"));
addSeparator();
- addItem(MNU_REMOVE,
- new PopupItem("menu.remove.document").icon(IMG_DELETE)
- .action("remove-document")
- .confirmation("message.delete.document"));
+ addItem(MNU_REMOVE, new PopupItem("menu.remove.document").icon(
+ IMG_DELETE).action("remove-document").confirmation(
+ "message.delete.document"));
}
@Override
private ScontextPopup() {
super();
- addItem(MNU_RENAME,
- new PopupItem(MNU_NAME_RENAME)
- .action("edit-context?action=renameContext"));
- addItem(MNU_EDIT,
- new PopupItem(MNU_NAME_EDIT)
- .action("edit-context?action=editContext"));
+ addItem(MNU_RENAME, new PopupItem(MNU_NAME_RENAME)
+ .action("edit-context?action=renameContext"));
+ addItem(MNU_EDIT, new PopupItem(MNU_NAME_EDIT)
+ .action("edit-context?action=editContext"));
addSeparator();
- addItem(MNU_REMOVE,
- new PopupItem("menu.remove").icon(IMG_DELETE)
- .action("remove-context")
- .confirmation("message.delete.context"));
+ addItem(MNU_REMOVE, new PopupItem("menu.remove").icon(IMG_DELETE)
+ .action("remove-context").confirmation(
+ "message.delete.context"));
}
@Override
private FeedbexPopup() {
super();
- addItem(MNU_PROMOTE,
- new PopupItem(MNU_NAME_PROMOTE).icon("image.review.png")
- .action("promote-knowledge")
- .confirmation("message.promote.knowledge"));
- addItem(MNU_DEMOTE,
- new PopupItem(MNU_NAME_DEMOTE).icon("image.invalidate.png")
- .action("demote-knowledge")
- .confirmation("message.demote.knowledge"));
+ addItem(MNU_PROMOTE, new PopupItem(MNU_NAME_PROMOTE).icon(
+ "image.review.png").action("promote-knowledge")
+ .confirmation("message.promote.knowledge"));
+ addItem(MNU_DEMOTE, new PopupItem(MNU_NAME_DEMOTE).icon(
+ "image.invalidate.png").action("demote-knowledge")
+ .confirmation("message.demote.knowledge"));
addSeparator();
- addItem(MNU_RENAME,
- new PopupItem(MNU_NAME_RENAME)
- .action("edit-knowledge?action=renameKnowledge"));
- addItem(MNU_EDIT,
- new PopupItem(MNU_NAME_EDIT)
- .action("edit-knowledge?action=editKnowledge"));
+ addItem(MNU_RENAME, new PopupItem(MNU_NAME_RENAME)
+ .action("edit-knowledge?action=renameKnowledge"));
+ addItem(MNU_EDIT, new PopupItem(MNU_NAME_EDIT)
+ .action("edit-knowledge?action=editKnowledge"));
addSeparator();
- addItem(MNU_REMOVE,
- new PopupItem("menu.remove").icon(IMG_DELETE)
- .action("remove-knowledge")
- .confirmation("message.delete.knowledge"));
+ addItem(MNU_REMOVE, new PopupItem("menu.remove").icon(IMG_DELETE)
+ .action("remove-knowledge").confirmation(
+ "message.delete.knowledge"));
}
@Override
// Construction
// ==============================================================================================================================
- public static ApplicationSettings getMe() {
- return MY_APP; // The application is supposed being previously created below
- }
-
- /**
- * @param wappurl
- * @param lang
- * @return
- */
- public ApplicationSettings init(final String wappurl, final Locale lang)
- throws IOException {
- ClassLoader cloader = Thread.currentThread().getContextClassLoader();
- String[] wurl = wappurl.split("/"); // [0]="http:", [1]="", [2]="{server}:{port}", [3]="name"
-
- synchronized (MY_APP) {
- MY_APP._locale = lang;
- MY_APP._wappserver = wurl[2];
- MY_APP._wappname = wurl[3];
- MY_APP._wapprops.clear();
- MY_APP._jndprops.clear();
- MY_APP._wapprops.load(cloader.getResourceAsStream(_wappname
- + ".properties"));
- MY_APP._jndprops.load(cloader
- .getResourceAsStream("jndi.properties"));
- }
-
- LOG.info("Application root set to "
- + _wapprops.getProperty("wapp.root"));
- return MY_APP;
- }
-
// ==============================================================================================================================
// Public member functions
// ==============================================================================================================================
- public void configure(final String filename) {
+ public void configure() {
// Non customizable settings
_menus.clear();
SimpleMenu menu = new NewMenu();
_filter.put("study", fprop);
_filter.put("knowledge", gprop);
- _tempfile = new HashMap<String, String>();
- _viewermap = new String[0];
- _convertmap = new HashMap<String, Converter>();
-
- // Customization (must be done after above default settings)
- File config = new File(filename);
- if (config.exists()) {
- loadCustomization(config); // Sets default document types, installed modules and available templates
- } else {
- LOG.info("Could not find the application configuration file \""
- + config.getAbsolutePath() + "\", using default settings");
- }
// Settings based on the customization
configureToolbars();
}
} else {
icon = "tool." + icon.toLowerCase() + ".png";
}
- File image = new File(
- ApplicationSettings.getApplicationSkinPath() + icon);
+ File image = new File(ApplicationSettings
+ .getApplicationSkinPath()
+ + icon);
if (!image.exists()) {
icon = "tool.any.png";
}
} else {
docname = "/jsp/newDocument.jsp?type=" + docname;
String icon = "tool." + name[0].toLowerCase() + ".png";
- File image = new File(
- ApplicationSettings.getApplicationSkinPath() + icon);
+ File image = new File(ApplicationSettings
+ .getApplicationSkinPath()
+ + icon);
if (!image.exists()) {
icon = "tool.any.png";
}
}
}
- public String getApplicationProperty(final String name) {
+ public static String getApplicationProperty(final String name) {
return _wapprops.getProperty(name); // May be null
}
- public String getApplicationRootPath() {
- // RKV: return getApplicationProperty("wapp.root"); // The property is supposed including the Web application name
- return _servletContext.getRealPath("/");
+ public static String getApplicationRootPath() {
+ // The property is supposed including the Web application name
+ return _wapproot;
}
public String getApplicationURL() {
- StringBuffer url = new StringBuffer("http://")
- .append(MY_APP._wappserver).append("/").append(_wappname);
+ StringBuffer url = new StringBuffer("http://").append(_wappserver)
+ .append("/").append(_wappname);
return url.toString();
}
return _bars.get(step.getNumber());
}
- public Properties getNamingProperties() {
+ static public Properties getNamingProperties() {
return _jndprops;
}
// ==============================================================================================================================
public static String getApplicationPluginPath() {
- return MY_APP.getApplicationRootPath() + "plugin/";
+ return getApplicationRootPath() + "plugin/";
}
public static String getApplicationResourcePath() {
- return MY_APP.getApplicationRootPath() + "WEB-INF/classes/";
+ return getApplicationRootPath() + "WEB-INF/classes/";
}
public static String getApplicationSkinPath() {
- return MY_APP.getApplicationRootPath() + "skin/";
+ return getApplicationRootPath() + "skin/";
}
public static Converter getConverter(final DocumentType type,
final String format) {
- return MY_APP._convertmap.get(format + type.getName()); // May be null;
+ return _convertmap.get(format + type.getName()); // May be null;
}
public DocumentType getDefaultDocumentType(final Step step,
format); // May be null
}
- public static String getDownloadURL(final User user) {
- StringBuffer url = new StringBuffer("http://")
- .append(MY_APP._wappserver).append("/download/")
- .append(user.getUsername()).append("/");
+ public String getDownloadURL(final User user) {
+ StringBuffer url = new StringBuffer("http://").append(_wappserver)
+ .append("/download/").append(user.getUsername()).append("/");
return url.toString(); // The download Tomcat context is supposed being defined
}
- public static Locale getCurrentLocale() {
- return MY_APP._locale;
+ public Locale getCurrentLocale() {
+ return _locale;
}
- public static SimpleMenu getMenu(final String name) {
- return MY_APP._menus.get(name);
+ public SimpleMenu getMenu(final String name) {
+ return _menus.get(name);
}
- public static PopupMenu getPopupMenu(final String name) {
- return MY_APP._popups.get(name);
+ public PopupMenu getPopupMenu(final String name) {
+ return _popups.get(name);
}
- public static String getRepositoryURL() {
- StringBuffer url = new StringBuffer("http://").append(
- MY_APP._wappserver).append("/repository/");
+ public String getRepositoryURL() {
+ StringBuffer url = new StringBuffer("http://").append(_wappserver)
+ .append("/repository/");
return url.toString(); // The repository Tomcat context is supposed being defined
}
public static Locale[] getSupportedLocales() {
- String[] code = MY_APP._wapprops.getProperty("locale.supported").split(
- ",");
+ String[] code = _wapprops.getProperty("locale.supported").split(",");
Locale[] result = new Locale[code.length];
for (int i = 0; i < code.length; i++) {
result[i] = new Locale(code[i]);
}
public static String[] getViewersMapping() {
- return MY_APP._viewermap;
+ return _viewermap;
}
public static String getWebSiteURL() {
- return MY_APP.getApplicationProperty("wapp.website");
+ return getApplicationProperty("wapp.website");
}
public static String getHelpURL() {
- return MY_APP.getApplicationProperty("wapp.onlinehelp");
+ return getApplicationProperty("wapp.onlinehelp");
}
// ==============================================================================================================================
// ==============================================================================================================================
/**
- * Load customization of workflow from the given XML file.
+ * Load application custom configuration from the given XML file (see conf/my.xml).
*
* @param config
* the XML configuration file
*/
- private void loadCustomization(final File config) {
+ private static void loadCustomization(final File config) {
try {
DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
.newInstance();
* @param children
* XML nodes
*/
- private void loadModules(final Map<String, Node> children) {
+ private static void loadModules(final Map<String, Node> children) {
Node child = children.get("modules");
NodeList nlist = child.getChildNodes();
for (int i = 0; i < nlist.getLength(); i++) {
* @param children
* XML nodes
*/
- private void loadConverters(final Map<String, Node> children) {
+ private static void loadConverters(final Map<String, Node> children) {
Node child = children.get("converters");
NodeList nlist = child.getChildNodes();
for (int i = 0; i < nlist.getLength(); i++) {
* @param children
* XML nodes
*/
- private void loadTemplates(final Map<String, Node> children) {
+ private static void loadTemplates(final Map<String, Node> children) {
Node child = children.get("templates");
NodeList nlist = child.getChildNodes();
for (int i = 0; i < nlist.getLength(); i++) {
}
/**
- * {@inheritDoc}
+ * Get the locale.
+ *
+ * @return the locale
+ */
+ public Locale getLocale() {
+ return _locale;
+ }
+
+ /**
+ * Set the locale.
*
- * @see org.apache.struts2.util.ServletContextAware#setServletContext(javax.servlet.ServletContext)
+ * @param locale
+ * the locale to set
*/
- @Override
- public void setServletContext(final ServletContext context) {
- _servletContext = context;
+ public void setLocale(final Locale locale) {
+ _locale = locale;
}
}
\ No newline at end of file
}
try {
// Initialization of the asynchronous communication with the actual converter
- ApplicationSettings settings = ApplicationSettings.getMe();
- Context context = new InitialContext(settings.getNamingProperties());
+ Context context = new InitialContext(ApplicationSettings.getNamingProperties());
ConnectionFactory factory = (javax.jms.QueueConnectionFactory)context.lookup("QueueConnectionFactory");
Connection connex = factory.createConnection();
Session session = connex.createSession(false, Session.AUTO_ACKNOWLEDGE);
/**
* Presents the current open study information.
+ *
* @author Daniel Brunier-Coulin.
- *
+ *
*/
public class DisplayStudyStepAction extends AbstractDisplayAction {
* Injected study service.
*/
private StudyService _studyService;
-
+
/**
- * Value of the menu property.
- * It can be: none, create, open, study, knowledge, sysadmin, help.
+ * 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;
-
+
/**
- * 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;
-
+
/**
- * 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";
res = ERROR;
}
}
- if (!ERROR.equals(res)){
+ if (!ERROR.equals(res)) {
// Initialization of menus
ProjectElement owner = _openStudy.getSelectedStep().getOwner();
- SimpleMenu menu = ApplicationSettings.getMenu("configuration");
+ SimpleMenu menu = getApplicationSettings().getMenu("configuration");
if (owner instanceof Scenario) {
menu.enables(Constants.PROP_SCENARIO);
menu.selects(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()) {
+ 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);
+
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
}
return res;
}
}
// Re-initialization of the properties menu according to the selected step
ProjectElement owner = _openStudy.getSelectedStep().getOwner();
- SimpleMenu menu = ApplicationSettings.getMenu("configuration");
+ SimpleMenu menu = getApplicationSettings().getMenu("configuration");
if (owner instanceof Scenario) {
menu.enables(Constants.PROP_SCENARIO);
menu.selects(Constants.PROP_SCENARIO);
menu.disables(Constants.PROP_SCENARIO);
menu.selects("prop-general");
}
-
+
setMenuProperty(Constants.STUDY_MENU);
setTitleProperty(Constants.STUDY_MENU);
- if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ 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);
-
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
return SUCCESS;
}
} else if (todo == Execute.reduceall) {
_openStudy.reduceDocument(_myindex);
}
-
+
setMenuProperty(Constants.STUDY_MENU);
setTitleProperty(Constants.STUDY_MENU);
- if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ 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);
-
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
return SUCCESS;
}
} else if (todo == Execute.reduce) {
_openStudy.reduceKnowledge(_myindex);
}
-
+
setMenuProperty(Constants.STUDY_MENU);
setTitleProperty(Constants.STUDY_MENU);
- if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ 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);
-
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
return SUCCESS;
}
public String doClose() {
closeStudy();
-
+
setMenuProperty("none");
initializationScreenContext(_menuProperty);
-
+
return SUCCESS;
}
super.setOpenStudy(study);
_openStudy = study;
}
-
+
/**
* Get the menuProperty.
+ *
* @return the menuProperty
*/
public String getMenuProperty() {
/**
* Set the menuProperty.
- * @param menuProperty the menuProperty to set
+ *
+ * @param menuProperty
+ * the menuProperty to set
*/
public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
-
+
/**
* Get the _titleProperty.
+ *
* @return the _titleProperty
*/
public String getTitleProperty() {
/**
* Set the _titleProperty.
- * @param _titleProperty the titleProperty to set
+ *
+ * @param _titleProperty
+ * the titleProperty to set
*/
public void setTitleProperty(final String titleProperty) {
_titleProperty = titleProperty;
/**
* Get the editDisabledProperty.
+ *
* @return the editDisabledProperty
*/
public String getEditDisabledProperty() {
/**
* Set the editDisabledProperty.
- * @param editDisabledProperty the editDisabledProperty to set
+ *
+ * @param editDisabledProperty
+ * the editDisabledProperty to set
*/
public void setEditDisabledProperty(final String editDisabledProperty) {
_editDisabledProperty = editDisabledProperty;
}
-
+
/**
* Get the toolProperty.
+ *
* @return the toolProperty
*/
public String getToolProperty() {
/**
* 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() {
/**
* Set the leftMenuProperty.
- * @param leftMenuProperty the leftMenuProperty to set
+ *
+ * @param leftMenuProperty
+ * the leftMenuProperty to set
*/
public void setLeftMenuProperty(final String leftMenuProperty) {
_leftMenuProperty = leftMenuProperty;
import java.util.List;
import java.util.ResourceBundle;
-import org.splat.manox.XMLDocument;
import org.splat.dal.bo.kernel.Relation;
import org.splat.dal.bo.som.ConvertsRelation;
import org.splat.dal.bo.som.Document;
-import org.splat.som.DocumentRights;
import org.splat.dal.bo.som.DocumentType;
import org.splat.dal.bo.som.ProgressState;
-import org.splat.service.PublicationService;
-import org.splat.service.technical.ProjectSettingsService;
import org.splat.dal.bo.som.Publication;
-import org.splat.som.Revision;
-import org.splat.som.Step;
import org.splat.dal.bo.som.Timestamp;
import org.splat.dal.bo.som.UsesRelation;
import org.splat.dal.bo.som.VersionsRelation;
+import org.splat.manox.XMLDocument;
+import org.splat.service.PublicationService;
+import org.splat.service.technical.ProjectSettingsService;
+import org.splat.som.DocumentRights;
+import org.splat.som.Revision;
+import org.splat.som.Step;
import org.splat.wapp.PopupMenu;
+/**
+ * Document wrapper class for presentation layer.
+ */
public class DocumentFacade implements HistoryFacade {
- private AbstractOpenObject owner;
- private Publication me;
- private Document my; // Published document
+ private final AbstractOpenObject owner;
+ private final Publication me;
+ private final Document my; // Published document
private ProgressState state; // Document state
private String version; // My document version in customized format
private State display; // Presentation state
private List<FileFacade> exports;
private List<HistoryFacade> history;
private PopupMenu popup;
+ /**
+ * Injected project settings service.
+ */
private ProjectSettingsService _projectSettingsService;
+ /**
+ * Injected publication service.
+ */
private PublicationService _publicationService;
+ /**
+ * Injected application settings.
+ */
+ private ApplicationSettings _applicationSettings;
private enum State {
closed, open, deepopen
// Constructors
// ==============================================================================================================================
- public DocumentFacade(AbstractOpenObject opened, Publication represented,
- ProjectSettingsService projectSettings,
- PublicationService publicationService) {
- // ------------------------------------------------------------------
+ public DocumentFacade(final AbstractOpenObject opened,
+ final Publication represented,
+ final ProjectSettingsService projectSettings,
+ final PublicationService publicationService,
+ final ApplicationSettings applicationSettings) {
setProjectSettings(projectSettings);
setPublicationService(publicationService);
+ setApplicationSettings(applicationSettings);
owner = opened;
me = represented;
my = me.value();
* @param represented
* the represented history document
*/
- private DocumentFacade(AbstractOpenObject opened, Document represented,
- ProjectSettingsService projectSettings,
- PublicationService publicationService) {
- // ----------------------------------------------------------------
+ private DocumentFacade(final AbstractOpenObject opened,
+ final Document represented,
+ final ProjectSettingsService projectSettings,
+ final PublicationService publicationService,
+ final ApplicationSettings applicationSettings) {
setProjectSettings(projectSettings);
setPublicationService(publicationService);
+ setApplicationSettings(applicationSettings);
owner = opened;
me = null; // Marks the history context
my = represented;
state = my.getProgressState(); // In reality, HISTORY
display = State.open; // Because the given document is a history document
description = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale()).getString(
+ applicationSettings.getCurrentLocale()).getString(
"history.creation")
+ " " + my.getAuthor().toString();
uses = null;
// ==============================================================================================================================
public void develop() {
- // -------------------
if (display != State.open) { // Opening the document
if (uses == null) {
List<Publication> relist = me.getRelations(UsesRelation.class);
for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
Publication used = i.next();
long index = used.getIndex();
- DocumentFacade facade = AbstractOpenObject.docpres.get(index);
+ DocumentFacade facade = owner.docpres
+ .get(index);
if (facade == null) {
- facade = new DocumentFacade(owner, used, getProjectSettings(), getPublicationService());
- AbstractOpenObject.docpres.put(index, facade);
+ facade = new DocumentFacade(owner, used,
+ getProjectSettings(), getPublicationService(),
+ getApplicationSettings());
+ owner.docpres.put(index, facade);
}
uses.add(facade);
}
exports = new ArrayList<FileFacade>(relation.size());
for (Iterator<Relation> i = relation.iterator(); i.hasNext();) {
ConvertsRelation export = (ConvertsRelation) i.next();
- exports.add(new FileFacade(export));
+ exports
+ .add(new FileFacade(export,
+ getApplicationSettings()));
}
}
if (history == null) {
if (my.getPreviousVersion() != null
|| state == ProgressState.inCHECK
- || state == ProgressState.APPROVED)
+ || state == ProgressState.APPROVED) {
history = new ArrayList<HistoryFacade>();
+ }
}
display = State.open;
} else { // Opening the history of document, if exist
- if (history.isEmpty())
+ if (history.isEmpty()) {
collectHistory(my);
+ }
display = State.deepopen;
}
}
public void reduce() {
- // ---------------------
- if (display == State.deepopen)
+ if (display == State.deepopen) {
display = State.open;
+ }
}
public void reduceAll() {
- // ------------------------
display = State.closed;
}
// ==============================================================================================================================
public List<FileFacade> getAttachments() {
- // ------------------------------------------
return exports;
}
public String getDate() {
- // ------------------------
return date;
}
public String getDescription() {
- // -------------------------------
return description;
}
public String getEditIcon() {
- // ----------------------------
return "icon.ed" + state + ".png";
}
public String getFileIcon() {
- // ----------------------------
return icon;
}
public List<HistoryFacade> getHistory() {
- // ----------------------------------------
return history;
}
public String getIndex() {
- // -------------------------
return String.valueOf(my.getIndex());
}
public PopupMenu getPopup() { // Contextualizes the pop-up
- // ----------------------------
popup.setContext("document", new DocumentRights(owner.getUser(), me));
return popup; // callers must "use" the returned pop-up before getting another pop-up
}
public String getPresentationState() {
- // -------------------------------------
return display.toString();
}
public String getProgressState() {
- // ---------------------------------
return state.toString();
}
public String getSharingIcon() {
- // -------------------------------
return sharing;
}
public String getSize() {
- // ------------------------
return size;
}
public String getStateIcon() {
- // -----------------------------
return "icon." + state + ".png";
}
public String getTitle() {
- // -------------------------
return my.getTitle();
}
public String getURL() {
- // -----------------------
return surl;
}
public List<DocumentFacade> getUses() {
- // ---------------------------------------
return uses;
}
public String getVersion() {
- // ---------------------------
return version;
}
public String getVersioningIcon() {
- // ----------------------------------
return updated;
}
- public boolean isFacadeOf(Publication represented) {
- // ---------------------------------------------------
+ public boolean isFacadeOf(final Publication represented) {
return me.equals(represented);
}
// ==============================================================================================================================
protected void refresh() {
- // -------------------------
ResourceBundle custom = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
+ getApplicationSettings().getCurrentLocale());
DecimalFormat sizstring = new DecimalFormat(custom
.getString("size.format")); // Locale size display format
SimpleDateFormat datstring = new SimpleDateFormat(custom
for (int i = 0; i < mapping.length; i++) {
org.splat.dal.bo.som.File export = my.getAttachedFile(mapping[i]);
- if (export == null)
+ if (export == null) {
continue;
+ }
path = export.getRelativePath();
break;
}
- surl = ApplicationSettings.getRepositoryURL() + path;
+ surl = getApplicationSettings().getRepositoryURL() + path;
surl = surl.replaceAll("'", "\\\\'");
format = my.getFormat();
- if (format.equals("xml"))
+ if (format.equals("xml")) {
format = XMLDocument.getActualFormat(my.getSourceFile().asFile());
+ }
// Document state (overridable by the publication - see below)
state = my.getProgressState();
updated = "image.hold.gif";
File image = new File(ApplicationSettings.getApplicationSkinPath()
+ icon);
- if (!image.exists())
+ if (!image.exists()) {
icon = "icon.any.png";
+ }
if (me != null) {
if (me.getOwnerStudy().shares(my)) {
sharing = "image.share.png";
updated = "icon.hold.png";
}
- if (me.isOutdated())
+ if (me.isOutdated()) {
state = ProgressState.inWORK; // Overrides the document state
+ }
} else { // Facade in the history folder
if (!my.isVersioned()) { // History of the last version
- if (state != ProgressState.inWORK)
+ if (state != ProgressState.inWORK) {
icon = "icon.inWORK.png";
- else
+ } else {
icon = "icon." + state.toString() + ".png";
+ }
} else if (my.isPublished()) {
sharing = "image.share.png"; // Not correct if published in a previous version of the study
updated = "icon.hold.png";
description = versions.getDescription();
}
// File details
- if (state != ProgressState.EXTERN)
+ if (state != ProgressState.EXTERN) {
version = verstring.format(version);
+ }
size = sizstring.format(my.getSourceFile().asFile().length() / 1000);
date = datstring.format(my.getLastModificationDate());
collectHistory(my);
}
// Popup menus
- if (me == null)
+ if (me == null) {
return; // No pop-up (yet) in the history folder
- if (state == ProgressState.EXTERN)
- popup = ApplicationSettings.getPopupMenu("extern");
- else if (state == ProgressState.inWORK)
- popup = ApplicationSettings.getPopupMenu("editable");
- else if (state == ProgressState.inDRAFT)
- popup = ApplicationSettings.getPopupMenu("reviewable");
- else if (state == ProgressState.APPROVED)
- popup = ApplicationSettings.getPopupMenu("approved");
- else { // (state == ProgressState.inCHECK)
+ }
+ if (state == ProgressState.EXTERN) {
+ popup = getApplicationSettings().getPopupMenu("extern");
+ } else if (state == ProgressState.inWORK) {
+ popup = getApplicationSettings().getPopupMenu("editable");
+ } else if (state == ProgressState.inDRAFT) {
+ popup = getApplicationSettings().getPopupMenu("reviewable");
+ } else if (state == ProgressState.APPROVED) {
+ popup = getApplicationSettings().getPopupMenu("approved");
+ } else { // (state == ProgressState.inCHECK)
DocumentType mytype = me.value().getType(); // Only result documents need to be approved
Step mystep = getPublicationService().getInvolvedStep(me);
- if (mytype.isResultOf(mystep.getStep()))
- popup = ApplicationSettings.getPopupMenu("approvable");
- else
- popup = ApplicationSettings.getPopupMenu("notresult");
+ if (mytype.isResultOf(mystep.getStep())) {
+ popup = getApplicationSettings().getPopupMenu("approvable");
+ } else {
+ popup = getApplicationSettings().getPopupMenu("notresult");
+ }
}
}
protected void setVersioned() {
- // ------------------------------
updated = "image.modified.png";
}
// Private services
// ==============================================================================================================================
- private void collectHistory(Document given) {
- // --------------------------------------------
+ private void collectHistory(final Document given) {
VersionsRelation versions = (VersionsRelation) given
.getFirstRelation(VersionsRelation.class);
Timestamp[] stamp = given.getStamps(); // Stamps in ascending order of date
- for (int i = stamp.length - 1; i > -1; i--)
- history.add(new StampFacade(stamp[i]));
- history.add(new DocumentFacade(owner, given, getProjectSettings(), getPublicationService()));
- if (versions != null)
+ for (int i = stamp.length - 1; i > -1; i--) {
+ history.add(new StampFacade(stamp[i], getApplicationSettings()
+ .getCurrentLocale()));
+ }
+ history.add(new DocumentFacade(owner, given, getProjectSettings(),
+ getPublicationService(), getApplicationSettings()));
+ if (versions != null) {
collectHistory(versions.getTo());
+ }
}
/**
* @param projectSettingsService
* project settings service
*/
- public void setProjectSettings(ProjectSettingsService projectSettingsService) {
+ public void setProjectSettings(
+ final ProjectSettingsService projectSettingsService) {
_projectSettingsService = projectSettingsService;
}
* @param publicationService
* the publicationService to set
*/
- public void setPublicationService(PublicationService publicationService) {
+ public void setPublicationService(
+ final PublicationService publicationService) {
_publicationService = publicationService;
}
+
+ /**
+ * Get the applicationSettings.
+ *
+ * @return the applicationSettings
+ */
+ public ApplicationSettings getApplicationSettings() {
+ return _applicationSettings;
+ }
+
+ /**
+ * Set the applicationSettings.
+ *
+ * @param applicationSettings
+ * the applicationSettings to set
+ */
+ public void setApplicationSettings(
+ final ApplicationSettings applicationSettings) {
+ _applicationSettings = applicationSettings;
+ }
}
\ No newline at end of file
import org.splat.dal.bo.som.ConvertsRelation;
-
public class FileFacade {
- private String surl; // URL of the file
- private String format; // Extension of the file
- private String comment; // Short description
- private String size;
- private String date;
+ private String surl; // URL of the file
+ private final String format; // Extension of the file
+ private String comment; // Short description
+ private final String size;
+ private final String date;
+
+ // ==============================================================================================================================
+ // Constructor
+ // ==============================================================================================================================
+
+ public FileFacade(final ConvertsRelation represented,
+ final ApplicationSettings applicationSettings) {
+ ResourceBundle custom = ResourceBundle.getBundle("som",
+ applicationSettings.getCurrentLocale());
+ File export = represented.getTo().asFile();
+ String path = export.getPath();
+ String[] table = path.split("\\x2E");
+ DecimalFormat tostring = new DecimalFormat(custom
+ .getString("size.format")); // Locale size display format
+ SimpleDateFormat convert = new SimpleDateFormat(custom
+ .getString("date.format")); // Date display format
+
+ surl = applicationSettings.getRepositoryURL() + path;
+ surl = surl.replaceAll("'", "\\\\'");
+ format = table[table.length - 1].toUpperCase();
+ size = tostring.format(export.length() / 1000);
+ date = convert.format(represented.getTo().getDate());
+ comment = represented.getDescription();
+ if (comment == null) {
+ comment = "";
+ }
+ }
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
-// ==============================================================================================================================
-// Constructor
-// ==============================================================================================================================
+ public String getDate() {
+ return date;
+ }
- public FileFacade (ConvertsRelation represented) {
-// ------------------------------------------------
- ResourceBundle custom = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
- File export = represented.getTo().asFile();
- String path = export.getPath();
- String[] table = path.split("\\x2E");
- DecimalFormat tostring = new DecimalFormat(custom.getString("size.format")); // Locale size display format
- SimpleDateFormat convert = new SimpleDateFormat(custom.getString("date.format")); // Date display format
+ public String getDescription() {
+ return comment;
+ }
- surl = ApplicationSettings.getRepositoryURL() + path;
- surl = surl.replaceAll("'", "\\\\'");
- format = table[table.length-1].toUpperCase();
- size = tostring.format(export.length()/1000);
- date = convert.format(represented.getTo().getDate());
- comment = represented.getDescription();
- if (comment == null) comment = "";
- }
+ public String getFormat() {
+ return format;
+ }
-// ==============================================================================================================================
-// Getters
-// ==============================================================================================================================
+ public String getSize() {
+ return size;
+ }
- public String getDate () {
-// ------------------------
- return date;
- }
- public String getDescription () {
-// -------------------------------
- return comment;
- }
- public String getFormat () {
-// -----------------------
- return format;
- }
- public String getSize () {
-// ------------------------
- return size;
- }
- public String getURL () {
-// -----------------------
- return surl;
- }
+ public String getURL() {
+ return surl;
+ }
}
\ No newline at end of file
private transient State _state;
private transient String _value;
private transient PopupMenu _popup;
+ /**
+ * Injected application settings service.
+ */
+ private ApplicationSettings _applicationSettings;
private enum State {
closed, open
// Constructor
// ==============================================================================================================================
- public KnowledgeElementFacade(final KnowledgeElementDTO represented) {
+ public KnowledgeElementFacade(final KnowledgeElementDTO represented,
+ final ApplicationSettings app) {
_my = represented;
_state = State.closed;
+ setApplicationSettings(app);
this.refresh(); // Initializes the presentation of my knowledge
}
private void refresh() {
String[] tags = { "<b>", "<i>", "<u>", "<sup>", "<sub>" };
- _popup = ApplicationSettings.getPopupMenu("feedbex");
+ _popup = getApplicationSettings().getPopupMenu("feedbex");
_value = _my.getValue();
// One line extract of the knowledge value
}
return res;
}
+
+ /**
+ * Get the applicationSettings.
+ *
+ * @return the applicationSettings
+ */
+ public ApplicationSettings getApplicationSettings() {
+ return _applicationSettings;
+ }
+
+ /**
+ * Set the applicationSettings.
+ *
+ * @param applicationSettings
+ * the applicationSettings to set
+ */
+ public void setApplicationSettings(
+ final ApplicationSettings applicationSettings) {
+ _applicationSettings = applicationSettings;
+ }
}
\ No newline at end of file
* @return the selected menu item
*/
public String doSelectItem() {
- SimpleMenu menu = ApplicationSettings.getMenu(_menu);
+ SimpleMenu menu = getApplicationSettings().getMenu(_menu);
if (_item == null) { // Switch back to the menu, keeping the last selection
getSession().put("menu.open", menu); // Activates the menu
for (Iterator<SimulationContext> j = next
.getAllSimulationContexts().iterator(); j.hasNext();) {
_context.add(new SimulationContextFacade(j.next(),
- getProjectSettings().getAllSteps()));
+ getProjectSettings().getAllSteps(),
+ getApplicationSettings()));
}
}
value.append("<p>").append("<b>").append(
for (Iterator<SimulationContext> i = _ustep.getAllSimulationContexts()
.iterator(); i.hasNext();) {
_context.add(new SimulationContextFacade(i.next(),
- getProjectSettings().getAllSteps()));
+ getProjectSettings().getAllSteps(),
+ getApplicationSettings()));
}
if (getStudyService().isStaffedBy(_mystudy, _cuser)
|| getStudyService().hasActor(_mystudy, _cuser)) {
protected void add(final Publication doc) {
DocumentFacade facade = new DocumentFacade(this, doc,
- getProjectSettings(), getPublicationService());
+ getProjectSettings(), getPublicationService(),
+ getApplicationSettings());
boolean first = (_contents.size() == 0);
docpres.put(doc.getIndex(), facade);
protected void add(final SimulationContext contex) {
SimulationContextFacade facade = new SimulationContextFacade(contex,
- getProjectSettings().getAllSteps());
+ getProjectSettings().getAllSteps(), getApplicationSettings());
_context.add(facade);
}
protected void add(final KnowledgeElement kelm) {
KnowledgeElementFacade facade = new KnowledgeElementFacade(BeanHelper
- .copyBean(kelm, KnowledgeElementDTO.class));
+ .copyBean(kelm, KnowledgeElementDTO.class),
+ getApplicationSettings());
// RKV KnowledgeIterator known = knowledge.get(kelm.getType().getIndex() - 2);
// 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
for (Iterator<SimulationContext> j = i.next()
.getAllSimulationContexts().iterator(); j.hasNext();) {
_context.add(new SimulationContextFacade(j.next(),
- getProjectSettings().getAllSteps()));
+ getProjectSettings().getAllSteps(),
+ getApplicationSettings()));
}
}
}
// ==============================================================================================================================
public SimulationContextFacade(final SimulationContext represented,
- final List<ProjectSettingsService.Step> allSteps) {
+ final List<ProjectSettingsService.Step> allSteps,
+ final ApplicationSettings app) {
_my = represented;
- _popup = ApplicationSettings.getPopupMenu("scontext");
+ _popup = app.getPopupMenu("scontext");
SimulationContextType type = _my.getType();
for (Iterator<ProjectSettingsService.Step> i = allSteps.iterator(); i
_state = _my.getProgressState(); // inCHECK or APPROVED
_name = type.getName();
if (type.isApproved()) {
- _name = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale()).getString(
- "type.context." + _name);
+ _name = ResourceBundle.getBundle("som", app.getCurrentLocale())
+ .getString("type.context." + _name);
} else {
_state = ProgressState.inDRAFT;
}
*/
import java.text.SimpleDateFormat;
+import java.util.Locale;
import java.util.ResourceBundle;
import org.splat.dal.bo.som.Timestamp;
// Constructor
// ==============================================================================================================================
- public StampFacade(final Timestamp stamp) {
- ResourceBundle labels = ResourceBundle.getBundle("labels",
- ApplicationSettings.getCurrentLocale());
- ResourceBundle custom = ResourceBundle.getBundle("som",
- ApplicationSettings.getCurrentLocale());
+ public StampFacade(final Timestamp stamp, final Locale locale) {
+ ResourceBundle labels = ResourceBundle.getBundle("labels", locale);
+ ResourceBundle custom = ResourceBundle.getBundle("som", locale);
SimpleDateFormat convert = new SimpleDateFormat(custom
.getString("date.format")); // Date display format
ValidationStep type = stamp.getType();
.append("...").toString());
try {
ProjectSettingsService project = getProjectSettings();
- ApplicationSettings wapp = getApplicationSettings().init(
- wappurl.toString(), this.getLocale());
- String root = wapp.getApplicationRootPath();
+ ApplicationSettings wapp = getApplicationSettings();
+ wapp.setLocale(this.getLocale());
+ String root = ApplicationSettings.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"));
+ + ApplicationSettings.getApplicationProperty("wapp.configuration"));
+ // Configure menus for the current user
+ wapp.configure();
+
// Initialization of the user session
Map<String, Object> session = getSession();
import java.util.List;
import java.util.Vector;
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.Study;
+import org.splat.dal.bo.som.ValidationCycle;
+import org.splat.dal.bo.som.ValidationStep;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.Name;
-import org.splat.dal.bo.kernel.User;
import org.splat.service.DocumentTypeService;
import org.splat.service.StudyService;
import org.splat.service.UserService;
import org.splat.som.ApplicationRights;
-import org.splat.dal.bo.som.DocumentType;
-import org.splat.dal.bo.som.Study;
import org.splat.som.StudyRights;
-import org.splat.dal.bo.som.ValidationCycle;
-import org.splat.dal.bo.som.ValidationStep;
/**
* Edit/display study properties (study configuration) screen action.
* Injected user service.
*/
private UserService _userService;
-
+
/**
- * Value of the menu property.
- * It can be: none, create, open, study, knowledge, sysadmin, help.
+ * 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;
-
+
/**
- * 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;
-
+
/**
- * 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";
StudyRights user = _openStudy.getStudyRights();
for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ study, type);
if (cycle.isDefault()) {
- validefault = new ValidationFacade(cycle);
+ validefault = new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale());
continue;
}
- validation.add(new ValidationFacade(cycle));
+ validation.add(new ValidationFacade(cycle, getApplicationSettings()
+ .getCurrentLocale()));
i.remove();
}
- if (validefault != null)
+ if (validefault != null) {
validation.add(validefault); // In order to be at the end
+ }
member = getStudyService().getContributors(study);
staff = null;
validor = null;
-
+
setMenuProperty("study");
setTitleProperty("study");
setEditDisabledProperty("true");
setToolProperty("back");
setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
- if (_openStudy.isOpenForWriting() && user.canEditProperties()) {
+ if (_openStudy.isOpenForWriting() && user.canEditProperties()) {
return "edit";
- }
- else {
+ } else {
return "display";
}
}
public String doEditTitle() {
-// Session connex = Database.getCurSession();
-// Transaction transax = connex.beginTransaction();
+ // Session connex = Database.getCurSession();
+ // Transaction transax = connex.beginTransaction();
_openStudy = getOpenStudy();
validation = new Vector<ValidationFacade>();
Study study = _openStudy.getStudyObject();
for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ study, type);
if (cycle.isDefault()) {
- validefault = new ValidationFacade(cycle);
+ validefault = new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale());
continue;
}
- validation.add(new ValidationFacade(cycle));
+ validation.add(new ValidationFacade(cycle, getApplicationSettings()
+ .getCurrentLocale()));
}
- if (validefault != null)
+ if (validefault != null) {
validation.add(validefault); // In order to be at the end
+ }
member = getStudyService().getContributors(study);
staff = null;
validor = null;
other = null;
-// transax.commit();
-
+ // transax.commit();
+
setMenuProperty("study");
setTitleProperty("study");
setEditDisabledProperty("true");
setToolProperty("back");
setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
setActionType("edititle");
return SUCCESS;
}
public String doEditContributors() {
-// Session connex = Database.getCurSession();
-// Transaction transax = connex.beginTransaction();
+ // Session connex = Database.getCurSession();
+ // Transaction transax = connex.beginTransaction();
_openStudy = getOpenStudy();
validation = new Vector<ValidationFacade>();
Study study = _openStudy.getStudyObject();
for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ study, type);
if (cycle.isDefault()) {
- validefault = new ValidationFacade(cycle);
+ validefault = new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale());
continue;
}
- validation.add(new ValidationFacade(cycle));
+ validation.add(new ValidationFacade(cycle, getApplicationSettings()
+ .getCurrentLocale()));
}
- if (validefault != null)
+ if (validefault != null) {
validation.add(validefault); // In order to be at the end
+ }
member = getStudyService().getContributors(study);
staff = getUserService().selectAllUsers();
validor = null;
User next = i.next();
ApplicationRights he = new ApplicationRights(next);
if (next.equals(me) || member.contains(next)
- || !he.canContributeToStudy())
+ || !he.canContributeToStudy()) {
i.remove();
+ }
}
-// transax.commit();
-
+ // transax.commit();
+
setMenuProperty("study");
setTitleProperty("study");
setEditDisabledProperty("true");
setToolProperty("back");
setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
setActionType("edibutor");
return SUCCESS;
}
public String doEditCycle() {
-// Session connex = Database.getCurSession();
-// Transaction transax = connex.beginTransaction();
+ // Session connex = Database.getCurSession();
+ // Transaction transax = connex.beginTransaction();
_openStudy = getOpenStudy();
validation = new Vector<ValidationFacade>();
Study study = _openStudy.getStudyObject();
for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ study, type);
if (cycle.isDefault()) {
- validefault = new ValidationFacade(cycle);
+ validefault = new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale());
continue;
}
if (type.getName().equals(edicycle)) {
this.type = type.getIndex();
}
- validation.add(new ValidationFacade(cycle));
+ validation.add(new ValidationFacade(cycle, getApplicationSettings()
+ .getCurrentLocale()));
i.remove();
}
- if (validefault != null)
+ if (validefault != null) {
validation.add(validefault); // In order to be at the end
+ }
member = getStudyService().getContributors(study);
validor = new Vector<Name>();
staff = null;
User next = i.next();
ApplicationRights he = new ApplicationRights(next);
if (he.canValidate()) {
- if (next.equals(study.getAuthor()))
- validor.add(new ValidationFacade.ByManager(next));
- else
+ if (next.equals(study.getAuthor())) {
+ validor.add(new ValidationFacade.ByManager(next,
+ getApplicationSettings().getCurrentLocale()));
+ } else {
validor.add(next);
+ }
}
}
-// transax.commit();
-
+ // transax.commit();
+
setMenuProperty("study");
setTitleProperty("study");
setEditDisabledProperty("true");
setToolProperty("back");
setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
setActionType("edicycle");
-
+
return SUCCESS;
}
public String doEdition() {
// --------------------------
-// Session connex = Database.getCurSession();
-// Transaction transax = connex.beginTransaction();
+ // Session connex = Database.getCurSession();
+ // Transaction transax = connex.beginTransaction();
Study study = getOpenStudy().getStudyObject();
if (tosave == Save.title) {
} else if (tosave == Save.contributor) {
// Edition of contributors
- if (contributors == null)
+ if (contributors == null) {
contributors = "";
- if (candidates == null)
+ }
+ if (candidates == null) {
candidates = "";
+ }
String[] parsekept = contributors.split(",");
String[] parsenew = candidates.split(",");
- Vector<User> toremove = new Vector<User>(getStudyService().getContributors(study));
+ Vector<User> toremove = new Vector<User>(getStudyService()
+ .getContributors(study));
for (int i = 0; i < parsekept.length; i++) {
- if (parsekept[i].length() == 0)
+ if (parsekept[i].length() == 0) {
continue; // Yet no contributor
+ }
int index = Integer.valueOf(parsekept[i].trim());
for (Iterator<User> j = toremove.iterator(); j.hasNext();) {
long present = j.next().getIndex();
- if (present != index)
+ if (present != index) {
continue;
+ }
j.remove();
break;
}
}
int size = toremove.size();
- if (size > 0)
+ if (size > 0) {
getStudyService().removeContributor(study,
toremove.toArray(new User[size]));
+ }
for (int i = 0; i < parsenew.length; i++) {
- if (parsenew[i].length() == 0)
+ if (parsenew[i].length() == 0) {
continue; // No any new contributor
+ }
int index = Integer.valueOf(parsenew[i].trim());
User newser = getUserService().selectUser(index);
}
getStudyService().setValidationCycle(study, apply, vprop);
}
-// transax.commit();
+ // transax.commit();
doInitialize(); // Re-initialization following the above edition
-
+
setMenuProperty("study");
setTitleProperty("study");
setEditDisabledProperty("true");
setToolProperty("back");
setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
}
* @param documentTypeService
* the documentTypeService to set
*/
- public void setDocumentTypeService(final DocumentTypeService documentTypeService) {
+ public void setDocumentTypeService(
+ final DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
/**
* Get the userService.
+ *
* @return the userService
*/
public UserService getUserService() {
/**
* Set the userService.
- * @param userService the userService to set
+ *
+ * @param userService
+ * the userService to set
*/
public void setUserService(final UserService userService) {
_userService = userService;
}
-
+
/**
* Get the menuProperty.
+ *
* @return the menuProperty
*/
@Override
/**
* Set the menuProperty.
- * @param menuProperty the menuProperty to set
+ *
+ * @param menuProperty
+ * the menuProperty to set
*/
@Override
public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
-
+
/**
* Get the _titleProperty.
+ *
* @return the _titleProperty
*/
@Override
/**
* Set the _titleProperty.
- * @param _titleProperty the titleProperty to set
+ *
+ * @param _titleProperty
+ * the titleProperty to set
*/
@Override
public void setTitleProperty(final String titleProperty) {
/**
* Get the editDisabledProperty.
+ *
* @return the editDisabledProperty
*/
@Override
/**
* Set the editDisabledProperty.
- * @param editDisabledProperty the editDisabledProperty to set
+ *
+ * @param editDisabledProperty
+ * the editDisabledProperty to set
*/
@Override
public final void setEditDisabledProperty(final String editDisabledProperty) {
/**
* Get the toolProperty.
+ *
* @return the toolProperty
*/
@Override
/**
* Set the toolProperty.
- * @param toolProperty the toolProperty to set
+ *
+ * @param toolProperty
+ * the toolProperty to set
*/
@Override
public void setToolProperty(final String toolProperty) {
_toolProperty = toolProperty;
}
-
+
/**
* Get the leftMenuProperty.
+ *
* @return the leftMenuProperty
*/
@Override
/**
* Set the leftMenuProperty.
- * @param leftMenuProperty the leftMenuProperty to set
+ *
+ * @param leftMenuProperty
+ * the leftMenuProperty to set
*/
@Override
public void setLeftMenuProperty(final String leftMenuProperty) {
package org.splat.simer;
+import java.util.Locale;
import java.util.ResourceBundle;
import org.splat.dal.bo.kernel.User;
protected transient String _name;
protected transient long _index;
+ /**
+ * Create a localized named user option.
+ * @param key option label key
+ * @param locale current locale
+ */
+ public UserOption(final String key, final Locale locale) {
+ super();
+ _name = ResourceBundle.getBundle("labels", locale).getString(key);
+ }
+
public long getIndex() {
return _index;
}
}
protected static class NotRequired extends UserOption {
- protected NotRequired() {
- super();
- _name = ResourceBundle.getBundle("labels",
- ApplicationSettings.getCurrentLocale()).getString(
- "label.skipped");
+ protected NotRequired(final Locale locale) {
+ super("label.skipped", locale);
_index = 0;
}
}
protected static class ByAuthor extends UserOption {
- protected ByAuthor() {
- super();
- _name = ResourceBundle.getBundle("labels",
- ApplicationSettings.getCurrentLocale()).getString(
- "label.bytheauthor");
+ protected ByAuthor(final Locale locale) {
+ super("label.bytheauthor", locale);
_index = 0;
}
}
protected static class ByManager extends UserOption {
- protected ByManager(final User manager) {
- super();
- _name = ResourceBundle.getBundle("labels",
- ApplicationSettings.getCurrentLocale()).getString(
- "label.me");
+ protected ByManager(final User manager, final Locale locale) {
+ super("label.me", locale);
_index = manager.getIndex();
}
}
// Constructors
// ==============================================================================================================================
- public ValidationFacade(final ValidationCycle cycle) {
+ public ValidationFacade(final ValidationCycle cycle, final Locale locale) {
_myicon = "icon.empty.png";
if (cycle.isDefault()) {
_myname = "default";
_myreviewer = cycle.getActor(ValidationStep.REVIEW);
_myapprover = cycle.getActor(ValidationStep.APPROVAL);
if (_mypublisher == null) {
- _mypublisher = new ByAuthor();
+ _mypublisher = new ByAuthor(locale);
}
if (_myreviewer == null || _myapprover == null) {
- Name skipped = new NotRequired();
+ Name skipped = new NotRequired(locale);
if (_myreviewer == null) {
_myreviewer = skipped;
}
}
public boolean isCurrent() {
- return _locale.equals(ApplicationSettings.getCurrentLocale());
+ return _locale.equals(getApplicationSettings().getCurrentLocale());
}
}
<!-- property name="parentMessageSource" ref="baseMessageSource"/ -->
<bean id="applicationSettings"
- class="org.splat.simer.ApplicationSettings" factory-method="getMe">
+ class="org.splat.simer.ApplicationSettings" scope="session">
<property name="projectSettings" ref="projectSettings" />
<property name="documentTypeService" ref="documentTypeService" />
</bean>