import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.apache.log4j.Logger;
import org.splat.wapp.Menu;
+/**
+ * Base Siman action.
+ */
public class Action extends ActionSupport implements ServletRequestAware, SessionAware {
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = -895295026709526501L;
+ /**
+ * Action logger.
+ */
+ protected static final Logger logger = Logger.getLogger(Action.class);
+
+ /**
+ * Http servlet request.
+ */
+ private HttpServletRequest request;
+ /**
+ * Http session container.
+ */
private Map<String, Object> session;
+ /**
+ * Error code.
+ */
private String mercode;
+ /**
+ * Current open study facade object.
+ */
private OpenStudy _openStudy;
+ /**
+ * Current open knowledge facade object.
+ */
private OpenKnowledge _openKnowledge;
+
/**
* MenuBarSettings bean.
*/
* TitleBarSettings bean.
*/
private TitleBarSettings _titleBarSettings;
-
- private HttpServletRequest request;
-
- /**
- * Serial version ID.
- */
- private static final long serialVersionUID = -895295026709526501L;
/**
- * Action logger.
+ * Injected application settings bean.
*/
- protected static final Logger logger = Logger.getLogger(Action.class);
+ private ApplicationSettings _applicationSettings;
public class DocumentTypeComparator implements Comparator<DocumentType> {
-// -----------------------------------------------------------------------
public int compare(DocumentType t1, DocumentType t2)
{
ResourceBundle locale = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
}
}
public class ContextTypeComparator implements Comparator<SimulationContextType> {
-// --------------------------------------------------------------------------------
public int compare(SimulationContextType t1, SimulationContextType t2)
{
ResourceBundle locale = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
// ==============================================================================================================================
protected void closeKnowledge () {
-// --------------------------------
OpenObject open = (OpenObject)session.remove("knowledge.open");
if (open != null) {
if (session.get("study.open") == null) open.clearFacades(); // For eventually reopening the knowledge from a fresh context
}
}
protected void closeStudy () {
-// ----------------------------
OpenObject open = (OpenObject)session.remove("study.open");
if (open != null) {
if (session.get("knowledge.open") == null) open.clearFacades(); // For eventually reopening the study from a fresh context
}
}
protected void connect (LoginContext context, User user) {
-// --------------------------------------------------------
OpenStudy open = getOpenStudy();
if (open != null) {
open.changeUser(user);
session.put("login.context", context); // For executing the deconnection, when requested
}
protected void disconnect () {
-// ----------------------------
OpenStudy open = getOpenStudy();
if (open != null) {
open.changeUser(null);
session.remove("login.context");
}
protected User getConnectedUser () {
-// ----------------------------------
ApplicationRights rights = (ApplicationRights)session.get("user.rights");
return rights.getUser(); // May be null
}
protected Menu getMenu (String name) {
-// ------------------------------------
return (Menu)session.get("menu." + name);
}
public void setOpenKnowledge (OpenKnowledge kelm) {
return _openStudy; // May be null
}
protected OpenKnowledge open (KnowledgeElement kelm) {
-// ----------------------------------------------------
OpenKnowledge open = _openKnowledge.open(kelm);
closeKnowledge(); // Just in case
return open;
}
protected OpenStudy open (Study study) {
-// --------------------------------------
- OpenStudy open = _openStudy.open(getConnectedUser(), study); // The connected user may be null
+ OpenStudy open = _openStudy.open(getConnectedUser(), study); // The connected user may be null
closeStudy(); // Just in case
session.put("study.open", open);
}
public String getErrorCode () {
-// -----------------------------
return mercode;
}
public Map<String, Object> getSession () {
-// ----------------------------------------
return session;
}
public void setErrorCode (String code) {
-// --------------------------------------
this.mercode = code;
}
public void setSession (Map<String, Object> session) {
-// ----------------------------------------------------
this.session = session;
}
public void setTitleBarSettings(TitleBarSettings titleBarSettings) {
_titleBarSettings = titleBarSettings;
}
+ /**
+ * Get the applicationSettings.
+ * @return the applicationSettings
+ */
+ public ApplicationSettings getApplicationSettings() {
+ return _applicationSettings;
+ }
+ /**
+ * Set the applicationSettings.
+ * @param applicationSettings the applicationSettings to set
+ */
+ public void setApplicationSettings(ApplicationSettings applicationSettings) {
+ _applicationSettings = applicationSettings;
+ }
}
\ No newline at end of file