import java.security.Principal;
-import org.splat.dal.bo.kernel.Persistent;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
// - Public services
- public void clear () {
+ @Override
+ public void clear () {
super.clear();
username = null;
- password = null;;
+ password = null;
first = null;
last = null;
display = null;
}
// - Property setters
- public Properties addRole (String role) throws InvalidPropertyException
+ public Properties addRole (final String role) throws InvalidPropertyException
{
- if (role.length() == 0) throw new InvalidPropertyException("role");
+ if (role.length() == 0) {
+ throw new InvalidPropertyException("role");
+ }
if (this.role == null) {
this.role = new Role(username, role);
} else {
Role[] curole = this.role.toArray();
- for (int i=0; i<curole.length; i++) if (curole[i].is(role)) return this;
+ for (int i=0; i<curole.length; i++) {
+ if (curole[i].is(role)) {
+ return this;
+ }
+ }
this.role.addRole(role);
}
return this;
}
- public Properties setDisplayName (String display) throws InvalidPropertyException
+ public Properties setDisplayName (final String display) throws InvalidPropertyException
{
- if (display.length() == 0) throw new InvalidPropertyException("displayname");
+ if (display.length() == 0) {
+ throw new InvalidPropertyException("displayname");
+ }
this.display = display;
return this;
}
- public Properties setFirstName (String first) throws InvalidPropertyException
+ public Properties setFirstName (final String first) throws InvalidPropertyException
{
- if (first.length() == 0) throw new InvalidPropertyException("firstname");
+ if (first.length() == 0) {
+ throw new InvalidPropertyException("firstname");
+ }
this.first = first;
return this;
}
- public Properties setMailAddress (String address) throws InvalidPropertyException
+ public Properties setMailAddress (final String address) throws InvalidPropertyException
{
String[] term = address.split("@"); // Must be of the form x@y
- if (term.length != 2) throw new InvalidPropertyException("address");
+ if (term.length != 2) {
+ throw new InvalidPropertyException("address");
+ }
term = term[1].split("\\x2E"); // Must be of the form x@y.z
- if (term.length != 2) throw new InvalidPropertyException("address");
+ if (term.length != 2) {
+ throw new InvalidPropertyException("address");
+ }
this.email = address;
return this;
}
- public Properties setName (String last) throws InvalidPropertyException
+ public Properties setName (final String last) throws InvalidPropertyException
{
- if (last.length() == 0) throw new InvalidPropertyException("lastname");
+ if (last.length() == 0) {
+ throw new InvalidPropertyException("lastname");
+ }
this.last = last;
return this;
}
- public Properties setOrganizationName (String organization) throws InvalidPropertyException
+ public Properties setOrganizationName (final String organization) throws InvalidPropertyException
{
- if (organization.length() == 0) throw new InvalidPropertyException("organization");
+ if (organization.length() == 0) {
+ throw new InvalidPropertyException("organization");
+ }
this.organid = organization;
return this;
}
- public Properties setPassword (String password) throws InvalidPropertyException
+ public Properties setPassword (final String password) throws InvalidPropertyException
{
if (password != null) {
- if (password.length() < 1) throw new InvalidPropertyException("password");
+ if (password.length() < 1) {
+ throw new InvalidPropertyException("password");
+ }
this.password = String.valueOf(password.hashCode());
}
return this;
}
- public Properties setUsername (String username) throws InvalidPropertyException
+ public Properties setUsername (final String username) throws InvalidPropertyException
{
- if (username.length() == 0) throw new InvalidPropertyException("username");
+ if (username.length() == 0) {
+ throw new InvalidPropertyException("username");
+ }
this.username = username;
return this;
}
public void checkValidity () throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException
{
- if (username == null) throw new MissedPropertyException("username");
- if (first == null) throw new MissedPropertyException("firstname");
- if (last == null) throw new MissedPropertyException("lastname");
- if (role == null) throw new MissedPropertyException("role");
- if (email == null) throw new MissedPropertyException("email");
+ if (username == null) {
+ throw new MissedPropertyException("username");
+ }
+ if (first == null) {
+ throw new MissedPropertyException("firstname");
+ }
+ if (last == null) {
+ throw new MissedPropertyException("lastname");
+ }
+ if (role == null) {
+ throw new MissedPropertyException("role");
+ }
+ if (email == null) {
+ throw new MissedPropertyException("email");
//TODO: Check if username exists
+ }
}
}
// --------------
}
// Anonymous user supposed not to be saved
- public User (String name) {
+ public User (final String name) {
// -------------------------
username = null;
password = null;
organid = null;
}
// New user
- public User (Properties uprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
+ public User (final Properties uprop) throws MissedPropertyException, InvalidPropertyException, MultiplyDefinedException {
// ------------------------------
super(uprop); // Throws one of the above exception if not valid
this.username = uprop.username;
// Public member functions
// ==============================================================================================================================
- public boolean equals (Object item) {
+ @Override
+ public boolean equals (final Object item) {
// -----------------------------------
- if (item == null) return false;
+ if (item == null) {
+ return false;
+ }
if (item instanceof String) {
- return this.username.equals((String)item); // Usernames are unique
+ return this.username.equals(item); // Usernames are unique
}
else if (item instanceof User) {
User given = (User)item;
- if (isSaved()) return (this.getIndex() == given.getIndex());
- else return (given.username.equals(this.username)); // Usernames are unique
+ if (isSaved()) {
+ return (this.getIndex() == given.getIndex());
+ } else {
+ return (given.username.equals(this.username)); // Usernames are unique
+ }
} else {
return false;
}
public String getDisplayName () {
// -------------------------------
- if (display == null) return last + " " + first;
- else return display;
+ if (display == null) {
+ return last + " " + first;
+ } else {
+ return display;
+ }
}
public String getFirstName () {
return username;
}
- public String toString () {
+ @Override
+ public String toString () {
// -------------------------
return last + " " + first;
}
import org.splat.dal.bo.kernel.User;
import org.splat.service.ServiceLocatorImpl;
+/**
+ * Implementation of login module for SIMAN.
+ */
public class RealmLoginModule implements LoginModule {
- // Initial state
+ /**
+ * The logger.
+ */
+ private static final Logger LOG = Logger.getLogger(RealmLoginModule.class);
+
+ /**
+ * Initial state.
+ */
private transient Subject _subject;
private transient CallbackHandler _callbackHandler;
// private Map sharedState;
// private Map options;
- // Authentication status
+ /**
+ * Authentication status.
+ */
private transient boolean _succeeded = false;
private transient boolean _commit = false;
- // Principal
+ /**
+ * Principal.
+ */
private transient User _identity = null;
- private static final Logger LOG = Logger.getLogger(RealmLoginModule.class);
-
// ==============================================================================================================================
// Constructor
// ==============================================================================================================================
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.security.auth.spi.LoginModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler,
+ * java.util.Map, java.util.Map)
+ */
public void initialize(final Subject user, final CallbackHandler handler,
final Map<String, ?> state, final Map<String, ?> opts) {
- // --------------------------------------------------------------------------------------------------------
_subject = user;
_callbackHandler = handler;
// sharedState = state;
// options = opts;
// debug = "true".equalsIgnoreCase((String)options.get("debug"));
- //_logger = Logger.getLogger(RealmLoginModule.class);
+ // _logger = Logger.getLogger(RealmLoginModule.class);
}
// ==============================================================================================================================
// Public services
// ==============================================================================================================================
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.security.auth.spi.LoginModule#login()
+ */
public boolean login() throws LoginException {
boolean res = false;
try {
} catch (java.io.IOException ioe) {
throw new LoginException(ioe.getMessage()); // RKV: NOPMD: The message is sent into the constructor
} catch (UnsupportedCallbackException uce) {
- throw new LoginException("Error: " + uce.getCallback().toString() // RKV: NOPMD: Stacktrace is printed
+ throw new LoginException("Error: " // RKV: NOPMD: Stacktrace is printed
+ + uce.getCallback().toString()
+ " not available to garner authentication information"
+ " from the user");
}
return res;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.security.auth.spi.LoginModule#commit()
+ */
public boolean commit() throws LoginException {
boolean res = _succeeded;
if (res) {
return res;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.security.auth.spi.LoginModule#abort()
+ */
public boolean abort() throws LoginException {
boolean res = _succeeded;
if (res) {
- if (_succeeded && !_commit) {
+ if (_commit) {
+ logout();
+ } else {
_identity = null;
_succeeded = false;
- } else {
- logout();
}
}
return res;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.security.auth.spi.LoginModule#logout()
+ */
public boolean logout() throws LoginException {
_subject.getPrincipals().remove(_identity);
_identity = null;
-Simer {
+Siman {
org.splat.kernel.RealmLoginModule required debug=true;
};
\ No newline at end of file
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.util.ResourceBundle"%>
-<%@ page import="org.splat.simer.OpenObject"%>
+<%@ page import="org.splat.simer.AbstractOpenObject"%>
<%@ page import="org.splat.simer.OpenStudy"%>
<%@ page import="org.splat.simer.KnowledgeElementFacade"%>
<%!
Action todo = Action.valueOf(request.getParameter("action"));
String typenumber = request.getParameter("index");
OpenStudy study = (OpenStudy)session.getAttribute("study.open");
- List<OpenObject.KnowledgeIterator> knowlist = study.getDisplayedKnowledges();
+ List<AbstractOpenObject.KnowledgeIterator> knowlist = study.getDisplayedKnowledges();
ResourceBundle locale = ResourceBundle.getBundle("som");
%>
<s:url id="undo" namespace="/study" action="step-study"></s:url>
<table width=100% cellpadding=0 cellspacing=0 border=0 class=text>
<input type=hidden name=knowledgeType value="<%=typenumber%>"/>
<%
- for (Iterator<OpenObject.KnowledgeIterator> knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) {
- OpenObject.KnowledgeIterator type = knowtypes.next();
+ for (Iterator<AbstractOpenObject.KnowledgeIterator> knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) {
+ AbstractOpenObject.KnowledgeIterator type = knowtypes.next();
%>
<tr height=20>
<td width=38%><%=locale.getString("type.knowledge." + type.getType())%></td>
%>
<%@ taglib prefix="s" uri="/struts-tags"
%>
-<%@ page import="org.splat.simer.OpenObject"%>
+<%@ page import="org.splat.simer.AbstractOpenObject"%>
<%
// On the contrary of Struts tags, the Java implementation allows the HTML contents of knowledge values to be displayed
String entitype = request.getParameter("entity"); // Study or Knowledge element
- OpenObject object = (OpenObject)session.getAttribute(entitype + ".open");
+ AbstractOpenObject object = (AbstractOpenObject)session.getAttribute(entitype + ".open");
String description = object.getDisplayedDescription();
%>
<table cellpadding=0 cellspacing=0 border=0 class=text>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.util.ResourceBundle"%>
-<%@ page import="org.splat.simer.OpenObject"%>
+<%@ page import="org.splat.simer.AbstractOpenObject"%>
<%@ page import="org.splat.simer.OpenKnowledge"%>
<%@ page import="org.splat.simer.KnowledgeElementFacade"%>
-<%@ page import="org.splat.simer.DisplayBaseAction"%>
+<%@ page import="org.splat.simer.AbstractDisplayAction"%>
<%@ page import="com.opensymphony.xwork2.ActionContext"%>
<%@ page import="com.opensymphony.xwork2.util.ValueStack"%>
<%
// Scriptlet implementation is required for displaying HTML contents of knowledge values which does not work with Struts tags
ValueStack stack = ActionContext.getContext().getValueStack();
Object stacktop = stack.peek();
- DisplayBaseAction action = (DisplayBaseAction)stacktop;
+ AbstractDisplayAction action = (AbstractDisplayAction)stacktop;
String entitype = request.getParameter("entity"); // Study or Knowledge element
- OpenObject object = (OpenObject)session.getAttribute(entitype + ".open");
- List<OpenObject.KnowledgeIterator> knowlist = object.getDisplayedKnowledges();
+ AbstractOpenObject object = (AbstractOpenObject)session.getAttribute(entitype + ".open");
+ List<AbstractOpenObject.KnowledgeIterator> knowlist = object.getDisplayedKnowledges();
ResourceBundle locale = ResourceBundle.getBundle("som");
%>
<s:set var="entitype"><%=entitype%></s:set>
<table width=100% cellpadding=0 cellspacing=0 border=0 class=text>
<%
String curindex = object.getIndex().toString();
- for (Iterator<OpenObject.KnowledgeIterator> knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) {
- OpenObject.KnowledgeIterator type = knowtypes.next();
+ for (Iterator<AbstractOpenObject.KnowledgeIterator> knowtypes = knowlist.iterator(); knowtypes.hasNext(); ) {
+ AbstractOpenObject.KnowledgeIterator type = knowtypes.next();
%>
<tr height=20>
<td width=38%><%=locale.getString("type.knowledge." + type.getType())%></td>
--- /dev/null
+package org.splat.simer;
+
+
+public abstract class AbstractDisplayAction extends Action {
+
+ /**
+ * Index of the open object.
+ */
+ protected transient String _myindex = null;
+ /**
+ * User activity selection.
+ */
+ protected String _selection = null;
+ protected transient String _action = null;
+
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 3003902258668626946L;
+
+ protected enum Execute { popup, develop, reduce, reduceall }
+
+// ==============================================================================================================================
+// Getters and setters
+// ==============================================================================================================================
+
+ public String getSelection () {
+// -----------------------------
+ return _selection; // Equals to myobject.getSelection()
+ }
+
+ public void setAction (final String action) {
+// -------------------------------------
+ this._action = action;
+ }
+ public void setIndex (final String index) {
+// -----------------------------------
+ this._myindex = index;
+ }
+ public void setSelection (final String step) {
+// --------------------------------------
+ this._selection = step;
+ }
+
+// ==============================================================================================================================
+// Abstract services
+// ==============================================================================================================================
+
+ public abstract String getWriteAccess ();
+}
\ No newline at end of file
--- /dev/null
+package org.splat.simer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.Document;
+import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.KnowledgeElement;
+import org.splat.dal.bo.som.KnowledgeElementType;
+import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.Publication;
+import org.splat.dal.bo.som.Scenario;
+import org.splat.service.KnowledgeElementTypeService;
+import org.splat.service.ProjectElementService;
+import org.splat.service.PublicationService;
+import org.splat.service.dto.KnowledgeElementDTO;
+import org.splat.service.dto.Proxy;
+import org.splat.service.technical.ProjectSettingsService;
+import org.splat.som.Step;
+import org.splat.util.BeanHelper;
+import org.splat.wapp.Menu;
+import org.splat.wapp.PopupMenu;
+
+/**
+ * Open study or knowledge.
+ */
+public abstract class AbstractOpenObject implements Proxy {
+
+ protected static Map<Long, DocumentFacade> docpres = null;
+ protected static Map<Long, KnowledgeElementFacade> knowpres = null;
+
+ /**
+ * Connected user.
+ */
+ protected transient User _cuser = null;
+ /**
+ * Menu selected by the user.
+ */
+ protected transient String _selection = null;
+ /**
+ * Corresponding selected step.
+ */
+ protected transient Step _ustep = null;
+ /**
+ * Object description (rich text).
+ */
+ protected transient String _description = null;
+ protected transient List<Step> _involving = new ArrayList<Step>();
+ /**
+ * Simulation Context display representations.
+ */
+ protected transient List<SimulationContextFacade> _context = new ArrayList<SimulationContextFacade>();
+ /**
+ * Document display representations.
+ */
+ protected transient List<DocumentFacade> _contents = null;
+ /**
+ * Knowledge Element display representations structured by knowledge types.
+ */
+ protected transient List<KnowledgeIterator> _knowledge = null;
+
+ /**
+ * Left pane menu of this object.
+ */
+ protected Menu _menu = null;
+ /**
+ * Pop-up menu of this object, if the user has write access.
+ */
+ protected transient PopupMenu _popup = null;
+ /**
+ * Injected project settings service.
+ */
+ private ProjectSettingsService _projectSettings;
+ /**
+ * Injected application settings bean.
+ */
+ private ApplicationSettings _applicationSettings;
+ /**
+ * Injected publication service.
+ */
+ private PublicationService _publicationService;
+ /**
+ * Injected knowledge element service.
+ */
+ private KnowledgeElementTypeService _knowledgeElementTypeService;
+ /**
+ * Injected project element service.
+ */
+ private ProjectElementService _projectElementService;
+
+ public class KnowledgeIterator {
+ protected transient KnowledgeElementType _type;
+ protected transient List<KnowledgeElementFacade> _list;
+
+ public KnowledgeIterator(final KnowledgeElementType type,
+ final List<KnowledgeElementFacade> list) {
+ this._type = type;
+ this._list = list;
+ }
+
+ public String getIndex() {
+ return String.valueOf(_type.getIndex());
+ }
+
+ public String getType() {
+ return _type.getName();
+ }
+
+ public List<KnowledgeElementFacade> getKnowledgeElements() {
+ return _list;
+ }
+ }
+
+ // ==============================================================================================================================
+ // Constructor
+ // ==============================================================================================================================
+
+ protected AbstractOpenObject() {
+ // All member fields are supposed initialized by subclasses
+ if (docpres == null) {
+ docpres = new HashMap<Long, DocumentFacade>();
+ }
+ if (knowpres == null) {
+ knowpres = new HashMap<Long, KnowledgeElementFacade>();
+ }
+ }
+
+ // ==============================================================================================================================
+ // Public member functions
+ // ==============================================================================================================================
+
+ public void developDocument(final String index) {
+ for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
+ DocumentFacade doc = i.next();
+ if (!doc.getIndex().equals(index)) {
+ continue;
+ }
+ doc.develop();
+ return;
+ }
+ }
+
+ public void developKnowledge(final String index) {
+ for (Iterator<KnowledgeIterator> i = _knowledge.iterator(); i.hasNext();) {
+ List<KnowledgeElementFacade> knowelms = i.next()
+ .getKnowledgeElements();
+ for (Iterator<KnowledgeElementFacade> j = knowelms.iterator(); j
+ .hasNext();) {
+ KnowledgeElementFacade kelm = j.next();
+ if (!kelm.getIndex().equals(index)) {
+ continue;
+ }
+ kelm.develop();
+ return;
+ }
+ }
+ }
+
+ public void clearFacades() {
+ docpres.clear(); // For eventually reopening the knowledge from a fresh context
+ knowpres.clear(); // For eventually reopening the knowledge from a fresh context
+ }
+
+ public List<Document> collectInvolvedDocuments(final DocumentType type) {
+ List<Document> found = new ArrayList<Document>();
+ for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
+ Step step = i.next();
+ List<Publication> exist = step.getAllDocuments();
+ for (Iterator<Publication> j = exist.iterator(); j.hasNext();) {
+ Document doc = j.next().value();
+ if (doc.getType().equals(type)) {
+ found.add(doc);
+ }
+ }
+ }
+ return found;
+ }
+
+ public String getDisplayedDescription() {
+ return _description;
+ }
+
+ public List<DocumentFacade> getDisplayedDocuments() {
+ return _contents;
+ }
+
+ public List<SimulationContextFacade> getDisplayedSimulationContexts() {
+ return _context;
+ }
+
+ public List<KnowledgeIterator> getDisplayedKnowledges() {
+ return _knowledge;
+ }
+
+ public List<Step> getInvolvedSteps() {
+ return _involving;
+ }
+
+ public Menu getMenu() {
+ return _menu;
+ }
+
+ public PopupMenu getPopup() {
+ return _popup;
+ }
+
+ public Step getSelectedStep() {
+ return _ustep;
+ }
+
+ public String getSelection() {
+ return _selection;
+ }
+
+ public User getUser() {
+ return _cuser;
+ }
+
+ public boolean isOpenForWriting() {
+ return (_popup != null); // The pop-up is supposed existed when the user is staffed on the study
+ }
+
+ public void reduceDocument(final String index) {
+ for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
+ DocumentFacade doc = i.next();
+ if (!doc.getIndex().equals(index)) {
+ continue;
+ }
+ doc.reduceAll();
+ return;
+ }
+ }
+
+ public void reduceHistory(final String index) {
+ for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
+ DocumentFacade doc = i.next();
+ if (!doc.getIndex().equals(index)) {
+ continue;
+ }
+ doc.reduce();
+ return;
+ }
+ }
+
+ public void reduceKnowledge(final String index) {
+ for (Iterator<KnowledgeIterator> i = _knowledge.iterator(); i.hasNext();) {
+ List<KnowledgeElementFacade> knowelms = i.next()
+ .getKnowledgeElements();
+ for (Iterator<KnowledgeElementFacade> j = knowelms.iterator(); j
+ .hasNext();) {
+ KnowledgeElementFacade kelm = j.next();
+ if (!kelm.getIndex().equals(index)) {
+ continue;
+ }
+ kelm.reduce();
+ return;
+ }
+ }
+ }
+
+ // ==============================================================================================================================
+ // Protected services
+ // ==============================================================================================================================
+
+ protected void setupContents() {
+ // Description
+ // Initialized in subclasses
+
+ // Knowledge elements supposed ordered by type
+ if (_ustep.mayContain(KnowledgeElement.class)) {
+ Scenario scene = (Scenario) _ustep.getOwner();
+ List<KnowledgeElementType> types = getKnowledgeElementTypeService()
+ .selectTypesWhere(ProgressState.APPROVED);
+ List<KnowledgeElement> kelms = scene.getAllKnowledgeElements();
+ Iterator<KnowledgeElement> more = kelms.iterator();
+ KnowledgeElement current = null;
+ if (more.hasNext()) {
+ current = more.next();
+ }
+
+ _knowledge = new ArrayList<KnowledgeIterator>(types.size());
+ for (Iterator<KnowledgeElementType> i = types.iterator(); i
+ .hasNext();) {
+ KnowledgeElementType type = i.next();
+ List<KnowledgeElementFacade> display = new ArrayList<KnowledgeElementFacade>(
+ kelms.size());
+ while (current != null && current.getType().equals(type)) {
+ KnowledgeElementFacade facade = knowpres.get(current
+ .getIndex());
+ if (facade == null) {
+ facade = new KnowledgeElementFacade(BeanHelper
+ .copyBean(current, KnowledgeElementDTO.class));
+ knowpres.put(current.getIndex(), facade);
+ }
+ display.add(facade);
+ if (more.hasNext()) {
+ current = more.next();
+ } else {
+ current = null;
+ }
+ }
+ _knowledge.add(new KnowledgeIterator(type, display));
+ }
+ } else {
+ _knowledge = null;
+ }
+ // Documents
+ if (_ustep.mayContain(Document.class)) {
+ List<Publication> list = _ustep.getAllDocuments();
+
+ _contents = new ArrayList<DocumentFacade>(list.size());
+ for (Iterator<Publication> i = list.iterator(); i.hasNext();) {
+ Publication present = i.next();
+ Long index = present.getIndex();
+ DocumentFacade facade = docpres.get(index);
+ if (facade == null) {
+ facade = new DocumentFacade(this, present,
+ getProjectSettings(), getPublicationService());
+ docpres.put(index, facade);
+ }
+ _contents.add(facade);
+ }
+ } else {
+ _contents = null;
+ }
+ }
+
+ /**
+ * Get project settings.
+ *
+ * @return Project settings service
+ */
+ public ProjectSettingsService getProjectSettings() {
+ return _projectSettings;
+ }
+
+ /**
+ * Get the publicationService.
+ *
+ * @return the publicationService
+ */
+ public PublicationService getPublicationService() {
+ return _publicationService;
+ }
+
+ /**
+ * Set project settings service.
+ *
+ * @param projectSettingsService
+ * project settings service
+ */
+ public void setProjectSettings(
+ final ProjectSettingsService projectSettingsService) {
+ _projectSettings = projectSettingsService;
+ }
+
+ /**
+ * Set the publicationService.
+ *
+ * @param publicationService
+ * the publicationService to set
+ */
+ public void setPublicationService(
+ final PublicationService publicationService) {
+ _publicationService = publicationService;
+ }
+
+ /**
+ * Set the menu.
+ *
+ * @param menu
+ * the menu to set
+ */
+ public void setMenu(final Menu menu) {
+ this._menu = menu;
+ }
+
+ /**
+ * Get the projectElementService.
+ *
+ * @return the projectElementService
+ */
+ public ProjectElementService getProjectElementService() {
+ return _projectElementService;
+ }
+
+ /**
+ * Set the projectElementService.
+ *
+ * @param projectElementService
+ * the projectElementService to set
+ */
+ public void setProjectElementService(
+ final ProjectElementService projectElementService) {
+ _projectElementService = projectElementService;
+ }
+
+ /**
+ * Get the knowledgeElementTypeService.
+ *
+ * @return the knowledgeElementTypeService
+ */
+ public KnowledgeElementTypeService getKnowledgeElementTypeService() {
+ return _knowledgeElementTypeService;
+ }
+
+ /**
+ * Set the knowledgeElementTypeService.
+ *
+ * @param knowledgeElementTypeService
+ * the knowledgeElementTypeService to set
+ */
+ public void setKnowledgeElementTypeService(
+ final KnowledgeElementTypeService knowledgeElementTypeService) {
+ _knowledgeElementTypeService = knowledgeElementTypeService;
+ }
+
+ /**
+ * Get the applicationSettings.
+ *
+ * @return the applicationSettings
+ */
+ public ApplicationSettings getApplicationSettings() {
+ return _applicationSettings;
+ }
+
+ /**
+ * Set the applicationSettings.
+ *
+ * @param applicationSettings
+ * the applicationSettings to set
+ */
+ public void setApplicationSettings(
+ final ApplicationSettings applicationSettings) {
+ _applicationSettings = applicationSettings;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.splat.simer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.SimulationContext;
+import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.Name;
+import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
+import org.splat.service.dto.Proxy;
+import org.splat.service.technical.ProjectSettingsService;
+import org.splat.som.ApplicationRights;
+
+public abstract class AbstractSearchBaseAction extends Action {
+
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 7863055790228544510L;
+
+ /**
+ * Search result key in the session.
+ */
+ public static final String RESULT_KEY = "search.result";
+
+ /**
+ * Context type index, when selected.
+ */
+ protected transient String _ctype = null;
+ /**
+ * Context value index, when selected.
+ */
+ protected transient String _cvalue = null;
+ /**
+ * Context index, when removed.
+ */
+ protected transient String _cindex = "";
+ protected String _author = null;
+ protected List<Name> _candidates = null;
+ /**
+ * Context type to be valued.
+ */
+ protected transient SimulationContextType _newtype;
+ /**
+ * Context value to be selected.
+ */
+ protected transient List<SimulationContext> _newvalue;
+ /**
+ * Addable context types.
+ */
+ protected transient List<SimulationContextType> _critext;
+ /**
+ * Current contexts search criteria.
+ */
+ protected transient List<SimulationContext> _context;
+ protected transient List<Proxy> _result;
+ /**
+ * Injected simulation context service.
+ */
+ private SimulationContextService _simulationContextService;
+
+ /**
+ * Injected user service.
+ */
+ private UserService _userService;
+
+ enum UserAction {
+ refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
+ }
+
+ // ==============================================================================================================================
+ // Action methods
+ // ==============================================================================================================================
+
+ public String doSubmitForm() {
+ // Identification of the user action
+ UserAction action = UserAction.refreshResult;
+ if (_ctype != null && Integer.valueOf(_ctype) > 0) {
+ action = UserAction.selectContextType;
+ } else if (_cvalue != null && Integer.valueOf(_cvalue) > 0) {
+ action = UserAction.selectContextValue;
+ } else if (_cindex.length() > 0) {
+ int index = Integer.valueOf(_cindex);
+ if (index > 0) {
+ action = UserAction.removeContext;
+ } else if (index < 0) {
+ action = UserAction.cancelSelect;
+ }
+ }
+ // Execution of the user action
+ String done;
+ try {
+ saveFilter(); // Also reinitializes the form, if needed
+
+ if (action == UserAction.selectContextType) {
+ done = doSelectContextType();
+ } else if (action == UserAction.selectContextValue) {
+ done = doAddContext();
+ } else if (action == UserAction.removeContext) {
+ done = doRemoveContext();
+ } else if (action == UserAction.cancelSelect) {
+ done = doCancel();
+ } else { // UserAction.refreshResult
+ done = doSearch();
+ setContextTypeOptions(getInvolvedContexts()); // Done in other do functions, when required
+ }
+ setCandidates();
+ } catch (Exception error) {
+ // No need to roll back the transaction as it is read only
+ LOG.error("Reason: ", error);
+ done = ERROR;
+ }
+ return done;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected String doSelectContextType() {
+ SimulationContext.Properties sprop = new SimulationContext.Properties();
+
+ _newtype = getSimulationContextService().selectType(
+ Integer.valueOf(_ctype));
+ _newvalue = getSimulationContextService().selectSimulationContextsWhere(
+ sprop.setType(_newtype));
+ if (_cindex.length() > 0 && Integer.valueOf(_cindex) == 0) {
+ getSession().remove(RESULT_KEY);
+ } else {
+ _result = (List<Proxy>) getSession().get(RESULT_KEY); // We keep the previous result search, if valid
+ }
+ return "selectype";
+ }
+
+ protected String doAddContext() {
+ SimulationContext selected = getSimulationContextService()
+ .selectSimulationContext(Integer.valueOf(_cvalue));
+
+ _context.add(selected);
+ setContextTypeOptions(getInvolvedContexts()); // Sets critext
+ getSession().remove(RESULT_KEY); // The current result is obsolete
+ return "refresh";
+ }
+
+ protected String doRemoveContext() {
+ int index = Integer.valueOf(_cindex);
+ for (Iterator<SimulationContext> selected = _context.iterator(); selected
+ .hasNext();) {
+ if (selected.next().getIndex() == index) {
+ selected.remove();
+ break;
+ }
+ }
+ setContextTypeOptions(getInvolvedContexts()); // Sets critext
+ getSession().remove(RESULT_KEY); // The current result is obsolete
+ return "refresh";
+ }
+
+ @SuppressWarnings("unchecked")
+ protected String doCancel() {
+ _result = (List<Proxy>) getSession().get(RESULT_KEY); // Current result search
+ setContextTypeOptions(getInvolvedContexts()); // Sets critext
+ return "refresh";
+ }
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
+
+ public String getAuthor() {
+ return _author;
+ }
+
+ public List<Name> getCandidates() {
+ return _candidates;
+ }
+
+ public List<SimulationContextType> getContextTypeOptions() {
+ return _critext;
+ }
+
+ public List<SimulationContext> getContextValueOptions() {
+ return _newvalue;
+ }
+
+ public SimulationContextType getSelectedContextType() {
+ return _newtype;
+ }
+
+ public List<SimulationContext> getSimulationContexts() {
+ return _context;
+ }
+
+ public List<Proxy> getResult() {
+ return _result;
+ }
+
+ // ==============================================================================================================================
+ // Setters
+ // ==============================================================================================================================
+
+ public void setAuthor(final String index) {
+ this._author = index;
+ }
+
+ public void setContextType(final String type) {
+ this._ctype = type;
+ }
+
+ public void setContextValue(final String value) {
+ this._cvalue = value;
+ }
+
+ public void setContextIndex(final String value) {
+ this._cindex = value;
+ }
+
+ protected void setCandidates() {
+ _candidates = new ArrayList<Name>();
+ List<User> users = getUserService().selectAllUsers();
+ User me = getConnectedUser(); // May be null
+ for (Iterator<User> i = users.iterator(); i.hasNext();) {
+ User next = i.next();
+ ApplicationRights he = new ApplicationRights(next);
+ if (he.canCreateStudy()) {
+ if (next.equals(me)) {
+ _candidates.add(0, new ValidationFacade.ByManager(me));
+ } else {
+ _candidates.add(next);
+ }
+ }
+ }
+ }
+
+ protected void setContextTypeOptions(final List<SimulationContextType> critext) {
+ for (Iterator<SimulationContext> i = _context.iterator(); i.hasNext();) {
+ critext.remove(i.next().getType()); // Already used context type
+ }
+ // Ordering by alphabetical order of localized context types
+ SimulationContextType[] types = critext
+ .toArray(new SimulationContextType[critext.size()]);
+ ContextTypeComparator compare = new ContextTypeComparator();
+ ProjectSettingsService.Step step = getSimulationContextService()
+ .getAttachedStep(types[0]);
+ int from = 0;
+ int to = 0;
+ while (to < types.length - 1) {
+ to += 1;
+ if (types[to].isAttachedTo(step)) {
+ continue;
+ }
+
+ if (to > from + 1) {
+ Arrays.sort(types, from, to, compare);
+ }
+ from = to;
+ step = getSimulationContextService().getAttachedStep(types[to]);
+ }
+ if (to > from) {
+ Arrays.sort(types, from, to + 1, compare);
+ }
+ this._critext = Arrays.asList(types);
+ }
+
+ // ==============================================================================================================================
+ // Abstract services
+ // ==============================================================================================================================
+
+ protected abstract String doSearch() throws InvalidPropertyException;
+
+ protected abstract List<SimulationContextType> getInvolvedContexts();
+
+ protected abstract void loadFilter();
+
+ protected abstract void saveFilter();
+
+ /**
+ * Get the simulationContextService.
+ *
+ * @return the simulationContextService
+ */
+ public SimulationContextService getSimulationContextService() {
+ return _simulationContextService;
+ }
+
+ /**
+ * Set the simulationContextService.
+ *
+ * @param simulationContextService
+ * the simulationContextService to set
+ */
+ public void setSimulationContextService(
+ final SimulationContextService simulationContextService) {
+ _simulationContextService = simulationContextService;
+ }
+
+ /**
+ * Get the userService.
+ * @return the userService
+ */
+ public UserService getUserService() {
+ return _userService;
+ }
+
+ /**
+ * Set the userService.
+ * @param userService the userService to set
+ */
+ public void setUserService(final UserService userService) {
+ _userService = userService;
+ }
+}
\ No newline at end of file
* Remove the currently open knowledge from the session.
*/
protected void closeKnowledge() {
- OpenObject open = (OpenObject) _session.remove(KNOWLEDGE_OPEN);
+ AbstractOpenObject open = (AbstractOpenObject) _session.remove(KNOWLEDGE_OPEN);
if ((open != null) && (_session.get(STUDY_OPEN) == null)) {
open.clearFacades(); // For eventually reopening the knowledge from a fresh context
}
* Remove the currently open study from the session.
*/
protected void closeStudy() {
- OpenObject open = (OpenObject) _session.remove(STUDY_OPEN);
+ AbstractOpenObject open = (AbstractOpenObject) _session.remove(STUDY_OPEN);
if ((open != null) && (_session.get(KNOWLEDGE_OPEN) == null)) {
open.clearFacades(); // For eventually reopening the study from a fresh context
}
initializationContext();
- OpenObject entity = (OpenObject) _session.get(titleProperty + ".open");
+ AbstractOpenObject entity = (AbstractOpenObject) _session.get(titleProperty + ".open");
getTitleBarSettings().setProgressState(
entity.getProgressState().toString());
package org.splat.simer;
+import java.io.IOException;
import java.util.Map;
import java.util.Set;
-import javax.security.auth.login.LoginContext;
import javax.security.auth.Subject;
-import javax.security.auth.callback.*;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.LoginContext;
import org.splat.dal.bo.kernel.User;
import org.splat.som.ApplicationRights;
-import java.io.IOException;
-import javax.security.auth.login.FailedLoginException;
-
+/**
+ * User login action.
+ */
public class ConnectionAction extends Action {
- private String username = null;
- private String password = null;
- private String backmenu = null;
-
- private String _menuProperty;
+ /**
+ * User name.
+ */
+ private String _username = null;
+ /**
+ * User password.
+ */
+ private String _password = null;
+ private transient String _backmenu = null;
+
+ private String _menuProperty;
/**
* Serial version ID.
*/
private static final long serialVersionUID = 6095471616361606231L;
+ /**
+ * Handler for login into SIMAN.
+ */
private class Handler implements CallbackHandler {
- // ------------------------------------------------
- public void handle(Callback[] callbacks) throws IOException,
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.security.auth.callback.CallbackHandler#handle(javax.security.auth.callback.Callback[])
+ */
+ public void handle(final Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof TextOutputCallback) {
// Display a message according to a specified type
-
+ LOG.info(((TextOutputCallback) callbacks[i]).getMessage());
} else if (callbacks[i] instanceof NameCallback) {
// Get the username
NameCallback call = (NameCallback) callbacks[i];
- call.setName(username);
+ call.setName(_username);
} else if (callbacks[i] instanceof PasswordCallback) {
// Get the password
- if (password != null) {
+ if (_password != null) {
PasswordCallback call = (PasswordCallback) callbacks[i];
- call.setPassword(password.toCharArray());
+ call.setPassword(_password.toCharArray());
}
} else {
throw new UnsupportedCallbackException(callbacks[i],
// Action execution
// ==============================================================================================================================
+ /**
+ * Login the user with the given name and password into SIMAN.
+ *
+ * @return SUCCESS if succeeded, INPUT - if some mandatory parameter is absent or FailedLoginException is caught during login, ERROR -
+ * if other exception is caught
+ *
+ * @see org.splat.kernel.RealmLoginModule
+ */
@SuppressWarnings("unchecked")
- public String doLogin() throws Exception {
- // ------------------------
- if (username == null || username.length() == 0)
- return INPUT;
- if (password != null && password.length() == 0)
- password = null; // User having no password
- try {
- LoginContext context = new LoginContext("Simer", new Handler());
- context.login();
-
- Subject identity = context.getSubject();
- Set<User> table = identity.getPrincipals(User.class);
- if (table.isEmpty())
- throw new Exception();
-
- User user = table.iterator().next(); // The user is (apparently...) the 1st principal
- ApplicationRights logged = new ApplicationRights(user);
- if (logged.canContributeToStudy() || logged.canValidate()) {
- // TODO: Set the search filter according to user preferences
- Map<String, Object> session = getSession();
- // Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
- Map<String, Object> sfilter = (Map<String, Object>) session
- .get("study.filter");
+ public String doLogin() {
+ String res = INPUT;
+ if (_username != null && _username.length() > 0) {
+ if (_password != null && _password.length() == 0) {
+ _password = null; // User having no password
+ }
+ try {
+ LoginContext context = new LoginContext("Siman", new Handler());
+ context.login();
+
+ Subject identity = context.getSubject();
+ Set<User> table = identity.getPrincipals(User.class);
+ if (table.isEmpty()) {
+ throw new Exception();
+ }
- sfilter.put("state", "ANY");
- sfilter.put("visibility", "PRIVATE");
- if (logged.canCreateStudy())
- sfilter.put("author", String.valueOf(user.getIndex()));
+ User user = table.iterator().next(); // The user is (apparently...) the 1st principal
+ ApplicationRights logged = new ApplicationRights(user);
+ if (logged.canContributeToStudy() || logged.canValidate()) {
+ // TODO: Set the search filter according to user preferences
+ Map<String, Object> session = getSession();
+ // Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
+ Map<String, Object> sfilter = (Map<String, Object>) session
+ .get("study.filter");
+
+ sfilter.put("state", "ANY");
+ sfilter.put("visibility", "PRIVATE");
+ if (logged.canCreateStudy()) {
+ sfilter.put("author", String.valueOf(user.getIndex()));
+ }
+ }
+ this.connect(context, user); // Updates the session context
+
+ setMenuProperty("none");
+ initializationScreenContext(_menuProperty);
+
+ res = _backmenu;
+ } catch (FailedLoginException error) {
+ setErrorCode("message.error.login." + error.getMessage());
+ res = INPUT;
+ } catch (Exception error) {
+ LOG.error("Reason:", error);
+ res = ERROR;
}
- this.connect(context, user); // Updates the session context
-
- setMenuProperty("none");
- initializationScreenContext(_menuProperty);
-
- return backmenu;
- } catch (FailedLoginException error) {
- setErrorCode("message.error.login." + error.getMessage());
- return INPUT;
- } catch (Exception error) {
- LOG.error("Reason:", error);
- return ERROR;
}
+ return res;
}
-
+ /**
+ * Disconnect the current user from SIMAN application.
+ *
+ * @return SUCCESS if disconnected, ERROR - if exception is caught
+ */
@SuppressWarnings("unchecked")
public String doLogout() {
- // -------------------------
+ String res;
try {
Map<String, Object> session = getSession();
// Map<String,Object> kfilter = (Map<String, Object>)session.get("knowledge.filter");
if (getConnectedUser() != null) {
connectedUsr = getConnectedUser().toString();
}
-
- LOG.info("Deconnection of " + connectedUsr
- + ".");
-
+
+ LOG.info("Deconnection of " + connectedUsr + ".");
+
if (context != null) {
context.logout();
}
}
this.disconnect(); // Updates the session context
-
+
setMenuProperty("none");
initializationScreenContext(_menuProperty);
-
- return backmenu;
+
+ res = _backmenu;
} catch (Exception error) {
LOG.error("Reason:", error);
- return ERROR;
+ res = ERROR;
}
+ return res;
}
-// ==============================================================================================================================
-// Getters and setters
-// ==============================================================================================================================
-
- public String getUsername () {
-// ----------------------------
- return username;
- }
- public String getPassword () {
-// ----------------------------
- return password;
- }
-
- public void setUsername (String value) {
-// --------------------------------------
- this.username = value;
- }
- public void setPassword (String value) {
-// --------------------------------------
- this.password = value;
- }
- public void setBackMenu (String menu) {
-// -------------------------------------
- this.backmenu = menu;
- }
-
- /**
+ // ==============================================================================================================================
+ // Getters and setters
+ // ==============================================================================================================================
+
+ /**
+ * Get user name.
+ *
+ * @return user name
+ */
+ public String getUsername() {
+ return _username;
+ }
+
+ /**
+ * Get user password.
+ *
+ * @return user password
+ */
+ public String getPassword() {
+ return _password;
+ }
+
+ /**
+ * Set user name.
+ *
+ * @param value
+ * user name
+ */
+ public void setUsername(final String value) {
+ this._username = value;
+ }
+
+ /**
+ * Set user password.
+ *
+ * @param value
+ * the password
+ */
+ public void setPassword(final String value) {
+ this._password = value;
+ }
+
+ /**
+ * Set menu for the user.
+ *
+ * @param menu
+ * menu key string
+ */
+ public void setBackMenu(final String menu) {
+ this._backmenu = menu;
+ }
+
+ /**
* Get the menuProperty.
+ *
* @return the menuProperty
*/
public String getMenuProperty() {
/**
* Set the menuProperty.
- * @param menuProperty the menuProperty to set
+ *
+ * @param menuProperty
+ * the menuProperty to set
*/
- public void setMenuProperty(String menuProperty) {
+ public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
}
\ No newline at end of file
+++ /dev/null
-package org.splat.simer;
-
-
-public abstract class DisplayBaseAction extends Action {
-
- protected String myindex = null; // Index of the open object
- protected String selection = null; // User activity selection
- protected String action = null;
-
- /**
- * Serial version ID.
- */
- private static final long serialVersionUID = 3003902258668626946L;
-
- protected enum Execute { popup, develop, reduce, reduceall }
-
-// ==============================================================================================================================
-// Getters and setters
-// ==============================================================================================================================
-
- public String getSelection () {
-// -----------------------------
- return selection; // Equals to myobject.getSelection()
- }
-
- public void setAction (String action) {
-// -------------------------------------
- this.action = action;
- }
- public void setIndex (String index) {
-// -----------------------------------
- this.myindex = index;
- }
- public void setSelection (String step) {
-// --------------------------------------
- this.selection = step;
- }
-
-// ==============================================================================================================================
-// Abstract services
-// ==============================================================================================================================
-
- public abstract String getWriteAccess ();
-}
\ No newline at end of file
import java.util.List;
-import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.service.KnowledgeElementService;
import org.splat.service.dto.KnowledgeElementDTO;
import org.splat.som.Step;
+import org.splat.wapp.Constants;
-public class DisplayKnowledgeAction extends DisplayBaseAction {
+public class DisplayKnowledgeAction extends AbstractDisplayAction {
/**
* Serial version ID.
/**
* Current knowledge element details.
*/
- protected OpenKnowledge myknelm = null;
+ protected transient OpenKnowledge _myknelm = null;
/**
* Injected knowledge element service.
// ==============================================================================================================================
public String doOpen() {
- myknelm = getOpenKnowledge();
- if (myindex != null) {
+ _myknelm = getOpenKnowledge();
+ if (_myindex == null) {
+ if (_selection != null) { // Re-opening (refreshing) the currently open knowledge
+ KnowledgeElementDTO kelm = getKnowledgeElementService()
+ .getKnowledgeElement(_myknelm.getIndex());
+ _myknelm = open(kelm); // Closes the previously open knowledge
+ _myknelm.setSelection(_selection);
+ }
+ } else {
try { // Opening a knowledge from the search result
- int index = Integer.valueOf(myindex);
- if (myknelm != null && myknelm.getIndex() == index) { // - The selected knowledge is currently open
- selection = myknelm.getSelection(); // Current selection
+ int index = Integer.valueOf(_myindex);
+ if (_myknelm != null && _myknelm.getIndex() == index) { // - The selected knowledge is currently open
+ _selection = _myknelm.getSelection(); // Current selection
} else { // - The selected knowledge is new
KnowledgeElementDTO kelm = getKnowledgeElementService()
.getKnowledgeElement(index);
- myknelm = open(kelm);
- selection = myknelm.getSelection(); // Default selection
+ _myknelm = open(kelm);
+ _selection = _myknelm.getSelection(); // Default selection
}
} catch (Exception error) {
LOG.error("Reason:", error);
return ERROR;
}
- } else if (selection != null) { // Re-opening (refreshing) the currently open knowledge
- KnowledgeElementDTO kelm = getKnowledgeElementService()
- .getKnowledgeElement(myknelm.getIndex());
- myknelm = open(kelm); // Closes the previously open knowledge
- myknelm.setSelection(selection);
}
- getSession().put("menu.knowledge", myknelm.getMenu());
+ getSession().put("menu.knowledge", _myknelm.getMenu());
- setMenuProperty("knowledge");
- setTitleProperty("knowledge");
- setToolProperty("none");
- setLeftMenuProperty("knowledge");
+ setMenuProperty(Constants.KNOWLEDGE_MENU);
+ setTitleProperty(Constants.KNOWLEDGE_MENU);
+ setToolProperty(Constants.NONE);
+ setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
}
public String doSelectStep() {
- myknelm = getOpenKnowledge();
+ _myknelm = getOpenKnowledge();
- if (selection == null) { // Switch back to the current study
- selection = myknelm.getSelection();
+ if (_selection == null) { // Switch back to the current study
+ _selection = _myknelm.getSelection();
} else { // Selection of a step of current study
- myknelm.setSelection(selection);
+ _myknelm.setSelection(_selection);
}
- setMenuProperty("knowledge");
- setTitleProperty("knowledge");
- setToolProperty("none");
- setLeftMenuProperty("knowledge");
+ setMenuProperty(Constants.KNOWLEDGE_MENU);
+ setTitleProperty(Constants.KNOWLEDGE_MENU);
+ setToolProperty(Constants.NONE);
+ setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
}
public String doSelectDocument() {
- Execute todo = Execute.valueOf(action);
- myknelm = getOpenKnowledge();
- if (todo == Execute.develop)
- myknelm.developDocument(myindex);
- else if (todo == Execute.reduce)
- myknelm.reduceHistory(myindex);
- else if (todo == Execute.reduceall)
- myknelm.reduceDocument(myindex);
+ Execute todo = Execute.valueOf(_action);
+ _myknelm = getOpenKnowledge();
+ if (todo == Execute.develop) {
+ _myknelm.developDocument(_myindex);
+ } else if (todo == Execute.reduce) {
+ _myknelm.reduceHistory(_myindex);
+ } else if (todo == Execute.reduceall) {
+ _myknelm.reduceDocument(_myindex);
+ }
- setMenuProperty("knowledge");
- setTitleProperty("knowledge");
- setToolProperty("none");
- setLeftMenuProperty("knowledge");
+ setMenuProperty(Constants.KNOWLEDGE_MENU);
+ setTitleProperty(Constants.KNOWLEDGE_MENU);
+ setToolProperty(Constants.NONE);
+ setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
}
public String doSelectKnowledge() {
- Execute todo = Execute.valueOf(action);
- myknelm = getOpenKnowledge();
- if (todo == Execute.develop)
- myknelm.developKnowledge(myindex);
- else if (todo == Execute.reduce)
- myknelm.reduceKnowledge(myindex);
+ Execute todo = Execute.valueOf(_action);
+ _myknelm = getOpenKnowledge();
+ if (todo == Execute.develop) {
+ _myknelm.developKnowledge(_myindex);
+ } else if (todo == Execute.reduce) {
+ _myknelm.reduceKnowledge(_myindex);
+ }
- setMenuProperty("knowledge");
- setTitleProperty("knowledge");
- setToolProperty("none");
- setLeftMenuProperty("knowledge");
+ setMenuProperty(Constants.KNOWLEDGE_MENU);
+ setTitleProperty(Constants.KNOWLEDGE_MENU);
+ setToolProperty(Constants.NONE);
+ setLeftMenuProperty(Constants.KNOWLEDGE_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
public String doClose() {
closeKnowledge();
- setMenuProperty("none");
+ setMenuProperty(Constants.NONE);
initializationScreenContext(_menuProperty);
return SUCCESS;
// ==============================================================================================================================
public List<DocumentFacade> getDocuments() {
- return myknelm.getDisplayedDocuments();
+ return _myknelm.getDisplayedDocuments();
}
- public List<OpenObject.KnowledgeIterator> getKnowledges() {
- return myknelm.getDisplayedKnowledges();
+ public List<AbstractOpenObject.KnowledgeIterator> getKnowledges() {
+ return _myknelm.getDisplayedKnowledges();
}
public List<SimulationContextFacade> getSimulationContexts() {
- return myknelm.getDisplayedSimulationContexts();
+ return _myknelm.getDisplayedSimulationContexts();
}
public Step getSelectedStep() {
- return myknelm.getSelectedStep();
+ return _myknelm.getSelectedStep();
}
+ @Override
public String getWriteAccess() {
return "false";
}
* the knowledgeElementService to set
*/
public void setKnowledgeElementService(
- KnowledgeElementService knowledgeElementService) {
+ final KnowledgeElementService knowledgeElementService) {
_knowledgeElementService = knowledgeElementService;
}
* Set the menuProperty.
* @param menuProperty the menuProperty to set
*/
- public void setMenuProperty(String menuProperty) {
+ public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
* Set the _titleProperty.
* @param _titleProperty the titleProperty to set
*/
- public void setTitleProperty(String titleProperty) {
+ public void setTitleProperty(final String titleProperty) {
_titleProperty = titleProperty;
}
}
/**
- * Set the _editDisabledProperty.
- * @param _editDisabledProperty the _editDisabledProperty to set
+ * Set the editDisabledProperty.
+ * @param editDisabledProperty the editDisabledProperty to set
*/
- public final void setEditDisabledProperty(String _editDisabledProperty) {
- this._editDisabledProperty = _editDisabledProperty;
+ public final void setEditDisabledProperty(final String editDisabledProperty) {
+ this._editDisabledProperty = editDisabledProperty;
}
/**
import org.splat.dal.bo.som.ProjectElement;
import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.Study;
import org.splat.service.StudyService;
import org.splat.som.StepRights;
-import org.splat.dal.bo.som.Study;
+import org.splat.wapp.Constants;
import org.splat.wapp.PopupMenu;
import org.splat.wapp.SimpleMenu;
* @author Daniel Brunier-Coulin.
*
*/
-public class DisplayStudyStepAction extends DisplayBaseAction {
+public class DisplayStudyStepAction extends AbstractDisplayAction {
/**
* Serial version ID.
/**
* Presented study.
*/
- protected OpenStudy mystudy = null;
+ protected transient OpenStudy _openStudy = null;
/**
* Injected study service.
public String doOpen() {
Study study;
- mystudy = getOpenStudy();
- if (myindex != null)
+ String res = SUCCESS;
+ _openStudy = getOpenStudy();
+ if (_myindex == null) {
+ if (_selection == null) { // Opening a study just newed
+ _selection = _openStudy.getSelection(); // Default selection
+ study = _openStudy.getStudyObject();
+ } else { // Re-opening (refreshing) the currently open study
+ study = getStudyService().selectStudy(_openStudy.getIndex());
+ _openStudy = open(study); // Closes the previously open study
+ _openStudy.setSelection(_selection);
+ }
+ } else {
try { // Opening a study from the search result
- int index = Integer.valueOf(myindex);
- if (mystudy != null && mystudy.getStudyObject() != null
- && mystudy.getIndex() == index) { // - The selected study is currently open
- selection = mystudy.getSelection(); // Current selection
- study = mystudy.getStudyObject(); // Current Study object
+ int index = Integer.valueOf(_myindex);
+ if (_openStudy != null && _openStudy.getStudyObject() != null
+ && _openStudy.getIndex() == index) { // - The selected study is currently open
+ _selection = _openStudy.getSelection(); // Current selection
+ study = _openStudy.getStudyObject(); // Current Study object
// RKV:BEGIN: put in session if necessary
if (!getSession().containsKey("study.open")) {
open(study);
// RKV:END
} else { // - The selected study is new
study = getStudyService().selectStudy(index);
- mystudy = open(study);
- selection = mystudy.getSelection(); // Default selection
+ _openStudy = open(study);
+ _selection = _openStudy.getSelection(); // Default selection
}
} catch (Exception error) {
LOG.error("Reason:", error);
- return ERROR;
+ res = ERROR;
}
- else if (selection == null) { // Opening a study just newed
- selection = mystudy.getSelection(); // Default selection
- study = mystudy.getStudyObject();
- } else { // Re-opening (refreshing) the currently open study
- study = getStudyService().selectStudy(mystudy.getIndex());
- mystudy = open(study); // Closes the previously open study
- mystudy.setSelection(selection);
}
- // Initialization of menus
- ProjectElement owner = mystudy.getSelectedStep().getOwner();
- SimpleMenu menu = ApplicationSettings.getMenu("configuration");
- if (owner instanceof Scenario) {
- menu.enables("prop-scenario");
- menu.selects("prop-scenario");
- } else {
- menu.disables("prop-scenario");
- menu.selects("prop-general");
- }
- getSession().put("menu.study", mystudy.getMenu());
-
- setMenuProperty("study");
- setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
- setToolProperty("study");
- } else {
- setToolProperty("standard");
+ if (!ERROR.equals(res)){
+ // Initialization of menus
+ ProjectElement owner = _openStudy.getSelectedStep().getOwner();
+ SimpleMenu menu = ApplicationSettings.getMenu("configuration");
+ if (owner instanceof Scenario) {
+ menu.enables(Constants.PROP_SCENARIO);
+ menu.selects(Constants.PROP_SCENARIO);
+ } else {
+ menu.disables(Constants.PROP_SCENARIO);
+ menu.selects("prop-general");
+ }
+ getSession().put("menu.study", _openStudy.getMenu());
+
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
+ if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ setToolProperty(Constants.STUDY_MENU);
+ } else {
+ setToolProperty(Constants.STANDARD_MENU);
+ }
+
+ setLeftMenuProperty(Constants.STUDY_MENU);
+
+ initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
}
-
- setLeftMenuProperty("study");
-
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-
- return SUCCESS;
+ return res;
}
public String doSelectStep() {
- mystudy = getOpenStudy();
- if (selection == null) { // Switch back to the current study
- selection = mystudy.getSelection();
+ _openStudy = getOpenStudy();
+ if (_selection == null) { // Switch back to the current study
+ _selection = _openStudy.getSelection();
} else { // Selection of a step of current study
- mystudy.setSelection(selection);
+ _openStudy.setSelection(_selection);
}
// Re-initialization of the properties menu according to the selected step
- ProjectElement owner = mystudy.getSelectedStep().getOwner();
+ ProjectElement owner = _openStudy.getSelectedStep().getOwner();
SimpleMenu menu = ApplicationSettings.getMenu("configuration");
if (owner instanceof Scenario) {
- menu.enables("prop-scenario");
- menu.selects("prop-scenario");
+ menu.enables(Constants.PROP_SCENARIO);
+ menu.selects(Constants.PROP_SCENARIO);
} else {
- menu.disables("prop-scenario");
+ menu.disables(Constants.PROP_SCENARIO);
menu.selects("prop-general");
}
- setMenuProperty("study");
- setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
- setToolProperty("study");
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
+ if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ setToolProperty(Constants.STUDY_MENU);
} else {
- setToolProperty("standard");
+ setToolProperty(Constants.STANDARD_MENU);
}
- setLeftMenuProperty("study");
+ setLeftMenuProperty(Constants.STUDY_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
}
public String doSelectDocument() {
- mystudy = getOpenStudy();
- Execute todo = Execute.valueOf(action);
- if (todo == Execute.develop)
- mystudy.developDocument(myindex);
- else if (todo == Execute.reduce)
- mystudy.reduceHistory(myindex);
- else if (todo == Execute.reduceall)
- mystudy.reduceDocument(myindex);
+ _openStudy = getOpenStudy();
+ Execute todo = Execute.valueOf(_action);
+ if (todo == Execute.develop) {
+ _openStudy.developDocument(_myindex);
+ } else if (todo == Execute.reduce) {
+ _openStudy.reduceHistory(_myindex);
+ } else if (todo == Execute.reduceall) {
+ _openStudy.reduceDocument(_myindex);
+ }
- setMenuProperty("study");
- setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
- setToolProperty("study");
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
+ if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ setToolProperty(Constants.STUDY_MENU);
} else {
- setToolProperty("standard");
+ setToolProperty(Constants.STANDARD_MENU);
}
- setLeftMenuProperty("study");
+ setLeftMenuProperty(Constants.STUDY_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
}
public String doSelectKnowledge() {
- mystudy = getOpenStudy();
- Execute todo = Execute.valueOf(action);
- if (todo == Execute.develop)
- mystudy.developKnowledge(myindex);
- else if (todo == Execute.reduce)
- mystudy.reduceKnowledge(myindex);
+ _openStudy = getOpenStudy();
+ Execute todo = Execute.valueOf(_action);
+ if (todo == Execute.develop) {
+ _openStudy.developKnowledge(_myindex);
+ } else if (todo == Execute.reduce) {
+ _openStudy.reduceKnowledge(_myindex);
+ }
- setMenuProperty("study");
- setTitleProperty("study");
- if ("true".equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
- setToolProperty("study");
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
+ if (Constants.TRUE.equals(getWriteAccess()) && getUserRights().canCreateDocument()) {
+ setToolProperty(Constants.STUDY_MENU);
} else {
- setToolProperty("standard");
+ setToolProperty(Constants.STANDARD_MENU);
}
- setLeftMenuProperty("study");
+ setLeftMenuProperty(Constants.STUDY_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
return SUCCESS;
// ==============================================================================================================================
public String getAction() {
- return action;
+ return _action;
}
public List<DocumentFacade> getDocuments() {
- return mystudy.getDisplayedDocuments();
+ return _openStudy.getDisplayedDocuments();
}
- public List<OpenObject.KnowledgeIterator> getKnowledges() {
- return mystudy.getDisplayedKnowledges();
+ public List<AbstractOpenObject.KnowledgeIterator> getKnowledges() {
+ return _openStudy.getDisplayedKnowledges();
}
public List<SimulationContextFacade> getSimulationContexts() {
- return mystudy.getDisplayedSimulationContexts();
+ return _openStudy.getDisplayedSimulationContexts();
}
public PopupMenu getPopup() {
- return mystudy.getPopup();
+ return _openStudy.getPopup();
}
public int getStepNumber() {
- return mystudy.getSelectedStep().getNumber();
+ return _openStudy.getSelectedStep().getNumber();
}
public String getStepEnabled() {
- return String.valueOf(mystudy.isStepEnabled());
+ return String.valueOf(_openStudy.isStepEnabled());
}
public StepRights getUserRights() {
- return mystudy.getSelectedStepRights();
+ return _openStudy.getSelectedStepRights();
}
+ @Override
public String getWriteAccess() {
- return String.valueOf(mystudy.isOpenForWriting());
+ return String.valueOf(_openStudy.isOpenForWriting());
}
/**
* @param studyService
* the studyService to set
*/
- public void setStudyService(StudyService studyService) {
+ public void setStudyService(final StudyService studyService) {
_studyService = studyService;
}
* @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
*/
@Override
- public void setOpenStudy(OpenStudy study) {
+ public void setOpenStudy(final OpenStudy study) {
super.setOpenStudy(study);
- mystudy = study;
+ _openStudy = study;
}
/**
* Set the menuProperty.
* @param menuProperty the menuProperty to set
*/
- public void setMenuProperty(String menuProperty) {
+ public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
* Set the _titleProperty.
* @param _titleProperty the titleProperty to set
*/
- public void setTitleProperty(String titleProperty) {
+ public void setTitleProperty(final String titleProperty) {
_titleProperty = titleProperty;
}
* Set the editDisabledProperty.
* @param editDisabledProperty the editDisabledProperty to set
*/
- public void setEditDisabledProperty(String editDisabledProperty) {
+ public void setEditDisabledProperty(final String editDisabledProperty) {
_editDisabledProperty = editDisabledProperty;
}
public class DocumentFacade implements HistoryFacade {
- private OpenObject owner;
+ private AbstractOpenObject owner;
private Publication me;
private Document my; // Published document
private ProgressState state; // Document state
// Constructors
// ==============================================================================================================================
- public DocumentFacade(OpenObject opened, Publication represented,
+ public DocumentFacade(AbstractOpenObject opened, Publication represented,
ProjectSettingsService projectSettings,
PublicationService publicationService) {
// ------------------------------------------------------------------
* @param represented
* the represented history document
*/
- private DocumentFacade(OpenObject opened, Document represented,
+ private DocumentFacade(AbstractOpenObject opened, Document represented,
ProjectSettingsService projectSettings,
PublicationService publicationService) {
// ----------------------------------------------------------------
for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
Publication used = i.next();
long index = used.getIndex();
- DocumentFacade facade = OpenObject.docpres.get(index);
+ DocumentFacade facade = AbstractOpenObject.docpres.get(index);
if (facade == null) {
facade = new DocumentFacade(owner, used, getProjectSettings(), getPublicationService());
- OpenObject.docpres.put(index, facade);
+ AbstractOpenObject.docpres.put(index, facade);
}
uses.add(facade);
}
* @return SUCCESS
*/
public String doInitialize() {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
setMenuProperty("study");
setTitleProperty("study");
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
try {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
- Execute todo = Execute.valueOf(action);
- Step step = mystudy.getSelectedStep();
+ Execute todo = Execute.valueOf(_action);
+ Step step = _openStudy.getSelectedStep();
Publication doc = step.getDocument(Integer.valueOf(index));
if (todo == Execute.renameDocument) {
// Useless to update the document presentation
} else if (todo == Execute.accept) {
getPublicationService().actualize(doc);
- mystudy.update(doc);
+ _openStudy.update(doc);
} else if (todo == Execute.promote) {
getPublicationService().promote(doc,
Calendar.getInstance().getTime());
- mystudy.update(doc);
+ _openStudy.update(doc);
} else if (todo == Execute.demote) {
getPublicationService().demote(doc);
- mystudy.update(doc);
+ _openStudy.update(doc);
} else if (todo == Execute.review) {
getPublicationService().review(doc,
Calendar.getInstance().getTime());
- mystudy.update(doc);
+ _openStudy.update(doc);
} else if (todo == Execute.invalidate) {
getPublicationService().invalidate(doc);
- mystudy.update(doc);
+ _openStudy.update(doc);
} else if (todo == Execute.approve) {
getPublicationService().approve(doc,
Calendar.getInstance().getTime());
- mystudy.update(doc);
- mystudy.getMenu().refreshSelectedItem(); // Updates the menu icon, in case of other documents in approved state
+ _openStudy.update(doc);
+ _openStudy.getMenu().refreshSelectedItem(); // Updates the menu icon, in case of other documents in approved state
}
return SUCCESS;
} catch (RuntimeException saverror) {
try {
// Getting user inputs
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
User user = getConnectedUser();
- Step step = mystudy.getSelectedStep();
+ Step step = _openStudy.getSelectedStep();
File updir = getRepositoryService().getDownloadDirectory(user);
File upfile = new File(updir.getPath() + "/" + filename);
String[] parse = filename.split("\\x2E");
+ updir.getPath() + "\".");
upfile.renameTo(export.getTo().asFile());
- mystudy.update(edited);
+ _openStudy.update(edited);
return SUCCESS;
} catch (Exception error) {
LOG.error("Reason:", error);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
try {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
- Step step = mystudy.getSelectedStep();
+ Step step = _openStudy.getSelectedStep();
Publication doctag = step.getDocument(Integer.valueOf(index));
getStepService().removeDocument(step, doctag); // Updates the data structure
- mystudy.remove(doctag); // Updates the presentation
+ _openStudy.remove(doctag); // Updates the presentation
return SUCCESS;
} catch (RuntimeException saverror) {
LOG.error("Reason:", saverror);
* @return SUCCESS if no exceptions
*/
public String doInitialize() {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
setMenuProperty("study");
setTitleProperty("study");
try {
User user = getConnectedUser();
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
- Step step = mystudy.getSelectedStep();
+ Step step = _openStudy.getSelectedStep();
Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
if ((title == null) || (value == null)) {
} else { // Edition of a knowledge
getKnowledgeElementService().update(kelm, value);
}
- mystudy.update(kelm); // For updating the truncated value
+ _openStudy.update(kelm); // For updating the truncated value
} else { // Addition of a new Knowledge Element
KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
KnowledgeElementType ktype = getKnowledgeElementTypeService()
.selectType(Integer.valueOf(type));
kprop.setType(ktype).setTitle(title).setValue(value).setAuthor(
user);
- mystudy.add(getScenarioService().addKnowledgeElement(scene,
+ _openStudy.add(getScenarioService().addKnowledgeElement(scene,
kprop));
- getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of first added document
+ getMenu("study").selects(_openStudy.getSelection()); // Updates the menu icon, in case of first added document
}
return SUCCESS;
} catch (RuntimeException saverror) {
* @return SUCCESS if no exceptions
*/
public String doDeleteKnowledge() {
- mystudy = getOpenStudy();
- Step step = mystudy.getSelectedStep();
+ _openStudy = getOpenStudy();
+ Step step = _openStudy.getSelectedStep();
Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
KnowledgeElement kelm = scene.getKnowledgeElement(Integer
- .valueOf(myindex));
+ .valueOf(_myindex));
getScenarioService().removeKnowledgeElement(scene, kelm); // The knowledge element necessarily exists
- mystudy.remove(kelm);
+ _openStudy.remove(kelm);
updateMenu();
return SUCCESS;
* @return the selected knowledge element
*/
private KnowledgeElement getKnowledgeElement() {
- mystudy = getOpenStudy();
- Step step = mystudy.getSelectedStep();
+ _openStudy = getOpenStudy();
+ Step step = _openStudy.getSelectedStep();
Scenario scene = (Scenario) step.getOwner(); // It is necessarily a Scenario
- return scene.getKnowledgeElement(Integer.valueOf(myindex));
+ return scene.getKnowledgeElement(Integer.valueOf(_myindex));
}
/**
* Update current menu.
*/
private void updateMenu() {
- getMenu("study").selects(mystudy.getSelection()); // Updates the menu icon, in case of last removed document
+ getMenu("study").selects(_openStudy.getSelection()); // Updates the menu icon, in case of last removed document
setMenuProperty("study");
setTitleProperty("study");
*/
public String getSelectedKnowledge() {
// -------------------------------------
- return myindex;
+ return _myindex;
}
/**
custom.getString("date.format")); // Locale date display format
Step step;
- mystudy = getOpenStudy();
- step = mystudy.getSelectedStep();
+ _openStudy = getOpenStudy();
+ step = _openStudy.getSelectedStep();
myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
lasdate = datstring.format(myscenario.getLastModificationDate());
- subject = label.getString("label.study") + " " + mystudy.getTitle();
+ subject = label.getString("label.study") + " " + _openStudy.getTitle();
setMenuProperty("study");
setTitleProperty("study");
public String doCheckin() {
Step step;
- mystudy = getOpenStudy();
- selection = mystudy.getSelection();
- step = mystudy.getSelectedStep();
+ _openStudy = getOpenStudy();
+ _selection = _openStudy.getSelection();
+ step = _openStudy.getSelectedStep();
myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
getScenarioService().checkin(myscenario);
- mystudy.getMenu().refreshGivenStepItem(
+ _openStudy.getMenu().refreshGivenStepItem(
getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
setMenuProperty("study");
public StepRights getSelectedStep() {
// ------------------------------------
- return mystudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
+ return _openStudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
}
public String getSubject() {
public String doInitialize() {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
contype = getInvolvedContexts();
setMenuProperty("study");
}
public String doSelectContext() {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
setMenuProperty("study");
setTitleProperty("study");
public String doCreateContext() {
// --------------------------------
try {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
setMenuProperty("study");
setTitleProperty("study");
if (newtype.length() == 0 || value.length() == 0)
return INPUT;
- Step step = mystudy.getSelectedStep();
+ Step step = _openStudy.getSelectedStep();
ProjectElement owner = step.getOwner();
SimulationContext.Properties cprop = new SimulationContext.Properties();
else
contex = getStepService().addSimulationContext(step, cprop); // Re-indexes knowledges only
- mystudy.add(contex);
+ _openStudy.add(contex);
return SUCCESS;
} catch (RuntimeException saverror) {
LOG.error("Reason:", saverror);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
try {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
- Step step = mystudy.getSelectedStep();
+ Step step = _openStudy.getSelectedStep();
ProjectElement owner = step.getOwner();
SimulationContext context = step.getSimulationContext(Integer
- .valueOf(myindex));
+ .valueOf(_myindex));
if (owner instanceof Study)
getStudyService()
.removeProjectContext(((Study) owner), context); // Re-indexes knowledges and the study
else
getStepService().removeSimulationContext(step, context); // Re-indexes knowledges only
- mystudy.remove(context);
+ _openStudy.remove(context);
return SUCCESS;
} catch (RuntimeException saverror) {
LOG.error("Reason:", saverror);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
try {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
- Step step = mystudy.getSelectedStep();
+ Step step = _openStudy.getSelectedStep();
ProjectElement owner = step.getOwner();
SimulationContext contex = null;
else
contex = getStepService().addSimulationContext(step, cprop); // Re-indexes knowledges only
}
- mystudy.add(contex);
+ _openStudy.add(contex);
contype = getInvolvedContexts();
// transax.commit();
private List<SimulationContextType> getInvolvedContexts() {
// ----------------------------------------------------------
SimulationContextType.Properties sprop = new SimulationContextType.Properties()
- .setStep(mystudy.getSelectedStep().getStep());
+ .setStep(_openStudy.getSelectedStep().getStep());
List<SimulationContextType> contype = getSimulationContextService()
.selectTypesWhere(sprop);
public String doEdition () {
try {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
- Execute todo = Execute.valueOf(action);
- Study study = mystudy.getStudyObject();
+ Execute todo = Execute.valueOf(_action);
+ Study study = _openStudy.getStudyObject();
if (todo == Execute.publish) getStudyService().moveToPublic(study);
else if (todo == Execute.promote) getStudyService().moveToReference(study);
- mystudy.getPopup().setContext("study", mystudy.getStudyRights()); // The context has changed
+ _openStudy.getPopup().setContext("study", _openStudy.getStudyRights()); // The context has changed
setMenuProperty("study");
setTitleProperty("study");
/**
* The name of the left menu.
*/
- private String menuName;
+ private String _menuName;
/**
* The name space of the left menu.
*/
- private String menuNamespace;
+ private String _menuNamespace;
/**
* The left menu.
*/
- private Menu menu;
+ private Menu _menu;
/**
* Get the menuName.
* @return the menuName
*/
public String getMenuName() {
- return menuName;
+ return _menuName;
}
/**
* @param menuName the menuName to set
*/
public void setMenuName(final String menuName) {
- this.menuName = menuName;
+ this._menuName = menuName;
}
/**
* @return the menuNamespace
*/
public String getMenuNamespace() {
- return menuNamespace;
+ return _menuNamespace;
}
/**
* @param menuNamespace the menuNamespace to set
*/
public void setMenuNamespace(final String menuNamespace) {
- this.menuNamespace = menuNamespace;
+ this._menuNamespace = menuNamespace;
}
/**
* @return the menu
*/
public Menu getMenu() {
- return menu;
+ return _menu;
}
/**
* @param menu the menu to set
*/
public void setMenu(final Menu menu) {
- this.menu = menu;
+ this._menu = menu;
}
import org.splat.wapp.SimpleMenu;
-
+/**
+ * Menu selection action.
+ */
public class MenuAction extends Action {
-
- private String menuname;
- private String selection;
-
/**
* Serial version ID.
*/
private static final long serialVersionUID = 5904292225286579036L;
-// ==============================================================================================================================
-// Action methods
-// ==============================================================================================================================
-
- public String doSelectItem () {
-// -----------------------------
- SimpleMenu menu = ApplicationSettings.getMenu(menuname);
-
- if (selection == null) { // Switch back to the menu, keeping the last selection
- getSession().put("menu.open", menu); // Activates the menu
- selection = menu.getSelection();
- if (selection == null) selection = "none";
- } else { // Selection of another menu item
- menu.selects(selection);
- }
- return selection;
- }
-
-// ==============================================================================================================================
-// Getters and setters
-// ==============================================================================================================================
-
- public String getItem () {
-// ------------------------
- return selection;
- }
- public String getMenu () {
-// ------------------------
- return menuname;
- }
-
- public void setMenu (String name) {
-// ---------------------------------
- this.menuname = name;
- }
- public void setItem (String item) {
-// ---------------------------------
- this.selection = item;
- }
+ /**
+ * Current menu.
+ */
+ private String _menu;
+ /**
+ * Selected item.
+ */
+ private String _item;
+
+ // ==============================================================================================================================
+ // Action methods
+ // ==============================================================================================================================
+
+ /**
+ * Activate the menu and select the menu item.
+ *
+ * @return the selected menu item
+ */
+ public String doSelectItem() {
+ SimpleMenu menu = ApplicationSettings.getMenu(_menu);
+
+ if (_item == null) { // Switch back to the menu, keeping the last selection
+ getSession().put("menu.open", menu); // Activates the menu
+ _item = menu.getSelection();
+ if (_item == null) {
+ _item = "none";
+ }
+ } else { // Selection of another menu item
+ menu.selects(_item);
+ }
+ return _item;
+ }
+
+ // ==============================================================================================================================
+ // Getters and setters
+ // ==============================================================================================================================
+
+ /**
+ * Get selected menu item.
+ * @return the selected menu item
+ */
+ public String getItem() {
+ return _item;
+ }
+
+ /**
+ * Get current menu name.
+ * @return the menu name
+ */
+ public String getMenu() {
+ return _menu;
+ }
+
+ /**
+ * Set current menu name.
+ * @param name the menu name
+ */
+ public void setMenu(final String name) {
+ this._menu = name;
+ }
+
+ /**
+ * Set the selected menu item.
+ * @param item the selected item
+ */
+ public void setItem(final String item) {
+ this._item = item;
+ }
}
\ No newline at end of file
package org.splat.simer;
+import org.splat.wapp.Constants;
+
/**
* Settings for menu bar.
* @author Maria KRUCHININA
/**
* The SALOME WEB-site URL.
*/
- private String webSiteURL;
+ private String _webSiteURL;
/**
* Help URL.
*/
- private String helpURL;
+ private String _helpURL;
//=== MENUS==========================================
/**
* Property, is this menu the "Create the Study" one.
*/
- private Boolean isMenuCreate;
+ private Boolean _isMenuCreate;
/**
* Property, is this menu the "Open the Study" one.
*/
- private Boolean isMenuOpen;
+ private Boolean _isMenuOpen;
/**
* Property, is this menu the "Display the Open Study" one.
*/
- private Boolean isMenuStudy;
+ private Boolean _isMenuStudy;
/**
* Property, is this menu the "Display the Open Knowledge" one.
*/
- private Boolean isMenuKnowledge;
+ private Boolean _isMenuKnowledge;
/**
* Property, is this menu the "Managing the database" one.
*/
- private Boolean isMenuSysAdmin;
+ private Boolean _isMenuSysAdmin;
/**
* Property, is this menu the "Help" one.
*/
- private Boolean isMenuHelp;
+ private Boolean _isMenuHelp;
//=== OTHER OPERATIONS ============================
/**
* Can the given User create the given Study.
*/
- private Boolean canUserCreateStudy;
+ private Boolean _canUserCreateStudy;
/**
* Is the given Study NULL.
*/
- private Boolean isStudyNull;
+ private Boolean _isStudyNull;
/**
* Is the given Knowledge NULL.
*/
- private Boolean isKnowledgeNull;
+ private Boolean _isKnowledgeNull;
/**
* Can the given User manage the Database.
*/
- private Boolean canUserManageDatabase;
+ private Boolean _canUserManageDatabase;
/**
* Initialize the initial properties for menus.
*/
public void initializeInitialMenuProperties() {
- webSiteURL = ApplicationSettings.getWebSiteURL();
- helpURL = ApplicationSettings.getHelpURL();
+ _webSiteURL = ApplicationSettings.getWebSiteURL();
+ _helpURL = ApplicationSettings.getHelpURL();
}
setIsMenuCreate(true);
} else if ("open".equals(menuProperty)) {
setIsMenuOpen(true);
- } else if ("study".equals(menuProperty)) {
+ } else if (Constants.STUDY_MENU.equals(menuProperty)) {
setIsMenuStudy(true);
- } else if ("knowledge".equals(menuProperty)) {
+ } else if (Constants.KNOWLEDGE_MENU.equals(menuProperty)) {
setIsMenuKnowledge(true);
} else if ("sysadmin".equals(menuProperty)) {
setIsMenuSysAdmin(true);
* @return the webSiteURL
*/
public String getWebSiteURL() {
- return webSiteURL;
+ return _webSiteURL;
}
/**
* @param webSiteURL the webSiteURL to set
*/
public void setWebSiteURL(final String webSiteURL) {
- this.webSiteURL = webSiteURL;
+ this._webSiteURL = webSiteURL;
}
/**
* @return the helpURL
*/
public String getHelpURL() {
- return helpURL;
+ return _helpURL;
}
/**
* @param helpURL the helpURL to set
*/
public void setHelpURL(final String helpURL) {
- this.helpURL = helpURL;
+ this._helpURL = helpURL;
}
/**
* @return the isMenuCreate
*/
public Boolean getIsMenuCreate() {
- return isMenuCreate;
+ return _isMenuCreate;
}
/**
* @param isMenuCreate the isMenuCreate to set
*/
public void setIsMenuCreate(final Boolean isMenuCreate) {
- this.isMenuCreate = isMenuCreate;
+ this._isMenuCreate = isMenuCreate;
}
/**
* @return the isMenuOpen
*/
public Boolean getIsMenuOpen() {
- return isMenuOpen;
+ return _isMenuOpen;
}
/**
* @param isMenuOpen the isMenuOpen to set
*/
public void setIsMenuOpen(final Boolean isMenuOpen) {
- this.isMenuOpen = isMenuOpen;
+ this._isMenuOpen = isMenuOpen;
}
/**
* @return the isMenuStudy
*/
public Boolean getIsMenuStudy() {
- return isMenuStudy;
+ return _isMenuStudy;
}
/**
* @param isMenuStudy the isMenuStudy to set
*/
public void setIsMenuStudy(final Boolean isMenuStudy) {
- this.isMenuStudy = isMenuStudy;
+ this._isMenuStudy = isMenuStudy;
}
/**
* @return the isMenuKnowledge
*/
public Boolean getIsMenuKnowledge() {
- return isMenuKnowledge;
+ return _isMenuKnowledge;
}
/**
* @param isMenuKnowledge the isMenuKnowledge to set
*/
public void setIsMenuKnowledge(final Boolean isMenuKnowledge) {
- this.isMenuKnowledge = isMenuKnowledge;
+ this._isMenuKnowledge = isMenuKnowledge;
}
/**
* @return the isMenuSysAdmin
*/
public Boolean getIsMenuSysAdmin() {
- return isMenuSysAdmin;
+ return _isMenuSysAdmin;
}
/**
* @param isMenuSysAdmin the isMenuSysAdmin to set
*/
public void setIsMenuSysAdmin(final Boolean isMenuSysAdmin) {
- this.isMenuSysAdmin = isMenuSysAdmin;
+ this._isMenuSysAdmin = isMenuSysAdmin;
}
/**
* @return the isMenuHelp
*/
public Boolean getIsMenuHelp() {
- return isMenuHelp;
+ return _isMenuHelp;
}
/**
* @param isMenuHelp the isMenuHelp to set
*/
public void setIsMenuHelp(final Boolean isMenuHelp) {
- this.isMenuHelp = isMenuHelp;
+ this._isMenuHelp = isMenuHelp;
}
/**
* @return the canUserCreateStudy
*/
public Boolean getCanUserCreateStudy() {
- return canUserCreateStudy;
+ return _canUserCreateStudy;
}
/**
* @param canUserCreateStudy the canUserCreateStudy to set
*/
public void setCanUserCreateStudy(final Boolean canUserCreateStudy) {
- this.canUserCreateStudy = canUserCreateStudy;
+ this._canUserCreateStudy = canUserCreateStudy;
}
/**
* @return the isStudyNull
*/
public Boolean getIsStudyNull() {
- return isStudyNull;
+ return _isStudyNull;
}
/**
* @param isStudyNull the isStudyNull to set
*/
public void setIsStudyNull(final Boolean isStudyNull) {
- this.isStudyNull = isStudyNull;
+ this._isStudyNull = isStudyNull;
}
/**
* @return the isKnowledgeNull
*/
public Boolean getIsKnowledgeNull() {
- return isKnowledgeNull;
+ return _isKnowledgeNull;
}
/**
* @param isKnowledgeNull the isKnowledgeNull to set
*/
public void setIsKnowledgeNull(final Boolean isKnowledgeNull) {
- this.isKnowledgeNull = isKnowledgeNull;
+ this._isKnowledgeNull = isKnowledgeNull;
}
/**
* @return the canUserManageDatabase
*/
public Boolean getCanUserManageDatabase() {
- return canUserManageDatabase;
+ return _canUserManageDatabase;
}
/**
* @param canUserManageDatabase the canUserManageDatabase to set
*/
public void setCanUserManageDatabase(final Boolean canUserManageDatabase) {
- this.canUserManageDatabase = canUserManageDatabase;
+ this._canUserManageDatabase = canUserManageDatabase;
}
}
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
import org.splat.dal.bo.som.Study;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.kernel.MissedPropertyException;
+import org.splat.kernel.MultiplyDefinedException;
import org.splat.service.ScenarioService;
import org.splat.service.SimulationContextService;
/**
* Title of the new study.
*/
- private String title = null;
+ private String _title = null;
/**
* List of available project contexts for selection for the new study.
*/
- private List<SimulationContext> contelm = null;
+ private transient List<SimulationContext> _contelm = null;
/**
* Project context.
*/
- private String context = null;
+ private String _projectContext = null;
/**
* Injected simulation context service.
* Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
*/
private String _menuProperty;
-
+
/**
- * Value of the tool bar property.
- * It can be: none, standard, study, back.
+ * Value of the tool bar property. It can be: none, standard, study, back.
*/
private String _toolProperty;
-
+
/**
- * Value of the left menu property.
- * It can be: open, study, knowledge, scenario.
+ * Value of the left menu property. It can be: open, study, knowledge, scenario.
*/
private String _leftMenuProperty;
public String doInitialize() {
// get the list of the simulation contexts of the study
- contelm = getSimulationContextService().getSimulationContextList();
+ _contelm = getSimulationContextService().getSimulationContextList();
// set the default name of the new study
ResourceBundle locale = ResourceBundle.getBundle("labels",
getApplicationSettings().getCurrentLocale());
- title = locale.getString("label.study") + " "
+ _title = locale.getString("label.study") + " "
+ String.valueOf(number + 1);
setMenuProperty("create");
setToolProperty("none");
setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
+ initializationFullScreenContext(_menuProperty, _toolProperty,
+ _leftMenuProperty);
return SUCCESS;
}
* Create a new study.
*
* @return SUCCESS if the new study is created, INPUT if project context is not defined, ERROR if failed
- * @throws Exception
+ * @throws InvalidPropertyException
+ * if some property has invalid value
+ * @throws MultiplyDefinedException
+ * if some property is defined several times
+ * @throws MissedPropertyException
* if properties of the new study are invalid
*/
- public String doCreate() throws Exception {
- String[] input = context.split(",");
+ public String doCreate() throws InvalidPropertyException,
+ MissedPropertyException, MultiplyDefinedException {
+ String[] input = _projectContext.split(",");
int valid = Integer.valueOf(input[0]);
String value = ""; // input[1] if exists
SimulationContext.Properties cprop = new SimulationContext.Properties();
SimulationContextType product = getSimulationContextService()
.selectType("product");
- contelm = getSimulationContextService()
+ _contelm = getSimulationContextService()
.selectSimulationContextsWhere(cprop.setType(product));
return INPUT; // Title empty, simply wait for input without error message
}
return INPUT; // No need to reinitialize the list of existing products
}
}
- sprop.setTitle(title).setManager(getConnectedUser());
+ sprop.setTitle(_title).setManager(getConnectedUser());
sprop.checkValidity();
sprop.disableCheck();
try {
setMenuProperty("study");
setToolProperty("none");
setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
+ initializationFullScreenContext(_menuProperty, _toolProperty,
+ _leftMenuProperty);
return SUCCESS;
} catch (Exception error) {
/**
* Get the selected project context for the new study.
+ *
* @return the selected project context
*/
public String getProjectContext() {
- return context;
+ return _projectContext;
}
/**
* Get the list of available project contexts.
+ *
* @return the list of context values
*/
public List<SimulationContext> getProjectContextValues() {
- return contelm;
+ return _contelm;
}
/**
* Get the title of the new study.
+ *
* @return the title
*/
public String getTitle() {
- return title;
+ return _title;
}
/**
* Set the project context for the new study.
- * @param value the project context value.
+ *
+ * @param value
+ * the project context value.
*/
- public void setProjectContext(String value) {
- this.context = value;
+ public void setProjectContext(final String value) {
+ this._projectContext = value;
}
/**
* Set the title of the new study.
- * @param value the title to set
+ *
+ * @param value
+ * the title to set
*/
- public void setTitle(String value) {
- this.title = value;
+ public void setTitle(final String value) {
+ this._title = value;
}
/**
* the simulationContextService to set
*/
public void setSimulationContextService(
- SimulationContextService simulationContextService) {
+ final SimulationContextService simulationContextService) {
_simulationContextService = simulationContextService;
}
* @param scenarioService
* the scenarioService to set
*/
- public void setScenarioService(ScenarioService scenarioService) {
+ public void setScenarioService(final ScenarioService scenarioService) {
_scenarioService = scenarioService;
}
* @param menuProperty
* the menuProperty to set
*/
- public void setMenuProperty(String menuProperty) {
+ public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
-
+
/**
* Get the toolProperty.
+ *
* @return the toolProperty
*/
public String getToolProperty() {
/**
* 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;
/**
* Open knowledge details for presentation.
*/
-public class OpenKnowledge extends OpenObject {
+public class OpenKnowledge extends AbstractOpenObject {
/**
* The open knowledge element DTO.
// Preparation of the display
_credate = convert.format(_myknelm.getDate());
// involving = getAllSteps(knelm.getOwnerScenario());
- involving = knelm.getInvolving();
- context = new ArrayList<SimulationContextFacade>();
- menu = new Menu(getInvolvedSteps());
- selection = menu.getSelection(); // The default selection is set in the menu definition
- int index = Integer.valueOf(selection);
- for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
+ _involving = knelm.getInvolving();
+ _context = new ArrayList<SimulationContextFacade>();
+ _menu = new Menu(getInvolvedSteps());
+ _selection = _menu.getSelection(); // The default selection is set in the menu definition
+ int index = Integer.valueOf(_selection);
+ for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
Step next = i.next();
if (next.getNumber() == index) {
- ustep = next;
+ _ustep = next;
}
for (Iterator<SimulationContext> j = next
.getAllSimulationContexts().iterator(); j.hasNext();) {
- context.add(new SimulationContextFacade(j.next(),
+ _context.add(new SimulationContextFacade(j.next(),
getProjectSettings().getAllSteps()));
}
}
.append("\",").append("<br>")
.append(sceneTitle/* scene.getTitle() */).append(".").append(
"</p>");
- description = value.toString();
+ _description = value.toString();
setupContents(); // Initializes documents and knowledge at ustep
return this;
}
@Override
public Menu getMenu() {
- return (Menu) menu;
+ return (Menu) _menu;
}
public ProgressState getProgressState() {
}
public void setSelection(final String step) {
- selection = step;
- int index = Integer.valueOf(selection);
- for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
- ustep = i.next();
- if (ustep.getNumber() == index) {
+ _selection = step;
+ int index = Integer.valueOf(_selection);
+ for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
+ _ustep = i.next();
+ if (_ustep.getNumber() == index) {
break;
}
}
- menu.selects(selection);
+ _menu.selects(_selection);
setupContents(); // The contents may have changed even if the selection is the same
}
}
\ No newline at end of file
+++ /dev/null
-package org.splat.simer;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.splat.dal.bo.kernel.User;
-import org.splat.dal.bo.som.Document;
-import org.splat.dal.bo.som.DocumentType;
-import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.bo.som.KnowledgeElementType;
-import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.bo.som.Publication;
-import org.splat.dal.bo.som.Scenario;
-import org.splat.service.KnowledgeElementTypeService;
-import org.splat.service.ProjectElementService;
-import org.splat.service.PublicationService;
-import org.splat.service.dto.KnowledgeElementDTO;
-import org.splat.service.dto.Proxy;
-import org.splat.service.technical.ProjectSettingsService;
-import org.splat.som.Step;
-import org.splat.util.BeanHelper;
-import org.splat.wapp.Menu;
-import org.splat.wapp.PopupMenu;
-
-public abstract class OpenObject implements Proxy {
-
- protected static Map<Long, DocumentFacade> docpres = null;
- protected static Map<Long, KnowledgeElementFacade> knowpres = null;
-
- /**
- * Connected user.
- */
- protected User cuser = null;
- /**
- * Menu selected by the user.
- */
- protected String selection = null;
- /**
- * Corresponding selected step.
- */
- protected Step ustep = null;
- /**
- * Object description (rich text).
- */
- protected String description = null;
- protected List<Step> involving = new ArrayList<Step>();
- /**
- * Simulation Context display representations.
- */
- protected List<SimulationContextFacade> context = new ArrayList<SimulationContextFacade>(); // Simulation Context display representations
- /**
- * Document display representations.
- */
- protected List<DocumentFacade> contents = null;
- /**
- * Knowledge Element display representations structured by knowledge types.
- */
- protected List<KnowledgeIterator> knowledge = null;
-
- /**
- * Left pane menu of this object.
- */
- protected Menu menu = null;
- /**
- * Pop-up menu of this object, if the user has write access.
- */
- protected PopupMenu popup = null;
- /**
- * Injected project settings service.
- */
- private ProjectSettingsService _projectSettingsService;
- /**
- * Injected application settings bean.
- */
- private ApplicationSettings _applicationSettings;
- /**
- * Injected publication service.
- */
- private PublicationService _publicationService;
- /**
- * Injected knowledge element service.
- */
- private KnowledgeElementTypeService _knowledgeElementTypeService;
- /**
- * Injected project element service.
- */
- private ProjectElementService _projectElementService;
-
- public class KnowledgeIterator {
- protected KnowledgeElementType type;
- protected List<KnowledgeElementFacade> list;
-
- public KnowledgeIterator(final KnowledgeElementType type,
- final List<KnowledgeElementFacade> list) {
- this.type = type;
- this.list = list;
- }
-
- public String getIndex() {
- return String.valueOf(type.getIndex());
- }
-
- public String getType() {
- return type.getName();
- }
-
- public List<KnowledgeElementFacade> getKnowledgeElements() {
- return list;
- }
- }
-
- // ==============================================================================================================================
- // Constructor
- // ==============================================================================================================================
-
- protected OpenObject() {
- // -----------------------
- // All member fields are supposed initialized by subclasses
- if (docpres == null) {
- docpres = new HashMap<Long, DocumentFacade>();
- }
- if (knowpres == null) {
- knowpres = new HashMap<Long, KnowledgeElementFacade>();
- }
- }
-
- // ==============================================================================================================================
- // Public member functions
- // ==============================================================================================================================
-
- public void developDocument(final String index) {
- // ------------------------------------------
- for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
- DocumentFacade doc = i.next();
- if (!doc.getIndex().equals(index)) {
- continue;
- }
- doc.develop();
- return;
- }
- }
-
- public void developKnowledge(final String index) {
- // -------------------------------------------
- for (Iterator<KnowledgeIterator> i = knowledge.iterator(); i.hasNext();) {
- List<KnowledgeElementFacade> knowelms = i.next()
- .getKnowledgeElements();
- for (Iterator<KnowledgeElementFacade> j = knowelms.iterator(); j
- .hasNext();) {
- KnowledgeElementFacade kelm = j.next();
- if (!kelm.getIndex().equals(index)) {
- continue;
- }
- kelm.develop();
- return;
- }
- }
- }
-
- public void clearFacades() {
- // ---------------------------
- docpres.clear(); // For eventually reopening the knowledge from a fresh context
- knowpres.clear(); // For eventually reopening the knowledge from a fresh context
- }
-
- public List<Document> collectInvolvedDocuments(final DocumentType type) {
- // ------------------------------------------------------------------
- List<Document> found = new ArrayList<Document>();
- for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
- Step step = i.next();
- List<Publication> exist = step.getAllDocuments();
- for (Iterator<Publication> j = exist.iterator(); j.hasNext();) {
- Document doc = j.next().value();
- if (doc.getType().equals(type)) {
- found.add(doc);
- }
- }
- }
- return found;
- }
-
- public String getDisplayedDescription() {
- // ----------------------------------------
- return description;
- }
-
- public List<DocumentFacade> getDisplayedDocuments() {
- // -----------------------------------------------------
- return contents;
- }
-
- public List<SimulationContextFacade> getDisplayedSimulationContexts() {
- // ----------------------------------------------------------------------
- return context;
- }
-
- public List<KnowledgeIterator> getDisplayedKnowledges() {
- // --------------------------------------------------------
- return knowledge;
- }
-
- public List<Step> getInvolvedSteps() {
- // -------------------------------------
- return involving;
- }
-
- public Menu getMenu() {
- // ----------------------
- return menu;
- }
-
- public PopupMenu getPopup() {
- // ----------------------------
- return popup;
- }
-
- public Step getSelectedStep() {
- // ------------------------------
- return ustep;
- }
-
- public String getSelection() {
- // -----------------------------
- return selection;
- }
-
- public User getUser() {
- // ----------------------
- return cuser;
- }
-
- public boolean isOpenForWriting() {
- // ----------------------------------
- return (popup != null); // The pop-up is supposed existed when the user is staffed on the study
- }
-
- public void reduceDocument(final String index) {
- // -----------------------------------------
- for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
- DocumentFacade doc = i.next();
- if (!doc.getIndex().equals(index)) {
- continue;
- }
- doc.reduceAll();
- return;
- }
- }
-
- public void reduceHistory(final String index) {
- // ----------------------------------------
- for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
- DocumentFacade doc = i.next();
- if (!doc.getIndex().equals(index)) {
- continue;
- }
- doc.reduce();
- return;
- }
- }
-
- public void reduceKnowledge(final String index) {
- // ------------------------------------------
- for (Iterator<KnowledgeIterator> i = knowledge.iterator(); i.hasNext();) {
- List<KnowledgeElementFacade> knowelms = i.next()
- .getKnowledgeElements();
- for (Iterator<KnowledgeElementFacade> j = knowelms.iterator(); j
- .hasNext();) {
- KnowledgeElementFacade kelm = j.next();
- if (!kelm.getIndex().equals(index)) {
- continue;
- }
- kelm.reduce();
- return;
- }
- }
- }
-
- // ==============================================================================================================================
- // Protected services
- // ==============================================================================================================================
-
- protected void setupContents() {
- // -------------------------------
- // Description
- // Initialized in subclasses
-
- // Knowledge elements supposed ordered by type
- if (ustep.mayContain(KnowledgeElement.class)) {
- Scenario scene = (Scenario) ustep.getOwner();
- List<KnowledgeElementType> types = getKnowledgeElementTypeService()
- .selectTypesWhere(ProgressState.APPROVED);
- List<KnowledgeElement> kelms = scene.getAllKnowledgeElements();
- Iterator<KnowledgeElement> more = kelms.iterator();
- KnowledgeElement current = null;
- if (more.hasNext()) {
- current = more.next();
- }
-
- knowledge = new ArrayList<KnowledgeIterator>(types.size());
- for (Iterator<KnowledgeElementType> i = types.iterator(); i
- .hasNext();) {
- KnowledgeElementType type = i.next();
- List<KnowledgeElementFacade> display = new ArrayList<KnowledgeElementFacade>(
- kelms.size());
- while (current != null && current.getType().equals(type)) {
- KnowledgeElementFacade facade = knowpres.get(current
- .getIndex());
- if (facade == null) {
- facade = new KnowledgeElementFacade(BeanHelper.copyBean(current, KnowledgeElementDTO.class));
- knowpres.put(current.getIndex(), facade);
- }
- display.add(facade);
- if (more.hasNext()) {
- current = more.next();
- } else {
- current = null;
- }
- }
- knowledge.add(new KnowledgeIterator(type, display));
- }
- } else {
- knowledge = null;
- }
- // Documents
- if (ustep.mayContain(Document.class)) {
- List<Publication> list = ustep.getAllDocuments();
-
- contents = new ArrayList<DocumentFacade>(list.size());
- for (Iterator<Publication> i = list.iterator(); i.hasNext();) {
- Publication present = i.next();
- Long index = present.getIndex();
- DocumentFacade facade = docpres.get(index);
- if (facade == null) {
- facade = new DocumentFacade(this, present,
- getProjectSettings(), getPublicationService());
- docpres.put(index, facade);
- }
- contents.add(facade);
- }
- } else {
- contents = null;
- }
- }
-
- /**
- * Get project settings.
- *
- * @return Project settings service
- */
- public ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
- }
-
- /**
- * Get the publicationService.
- *
- * @return the publicationService
- */
- public PublicationService getPublicationService() {
- return _publicationService;
- }
-
- /**
- * Set project settings service.
- *
- * @param projectSettingsService
- * project settings service
- */
- public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
- }
-
- /**
- * Set the publicationService.
- *
- * @param publicationService
- * the publicationService to set
- */
- public void setPublicationService(final PublicationService publicationService) {
- _publicationService = publicationService;
- }
-
- /**
- * Set the menu.
- *
- * @param menu
- * the menu to set
- */
- public void setMenu(final Menu menu) {
- this.menu = menu;
- }
-
- /**
- * Get the projectElementService.
- *
- * @return the projectElementService
- */
- public ProjectElementService getProjectElementService() {
- return _projectElementService;
- }
-
- /**
- * Set the projectElementService.
- *
- * @param projectElementService
- * the projectElementService to set
- */
- public void setProjectElementService(
- final ProjectElementService projectElementService) {
- _projectElementService = projectElementService;
- }
-
- /**
- * Get the knowledgeElementTypeService.
- * @return the knowledgeElementTypeService
- */
- public KnowledgeElementTypeService getKnowledgeElementTypeService() {
- return _knowledgeElementTypeService;
- }
-
- /**
- * Set the knowledgeElementTypeService.
- * @param knowledgeElementTypeService the knowledgeElementTypeService to set
- */
- public void setKnowledgeElementTypeService(
- final KnowledgeElementTypeService knowledgeElementTypeService) {
- _knowledgeElementTypeService = knowledgeElementTypeService;
- }
-
- /**
- * Get the applicationSettings.
- * @return the applicationSettings
- */
- public ApplicationSettings getApplicationSettings() {
- return _applicationSettings;
- }
-
- /**
- * Set the applicationSettings.
- * @param applicationSettings the applicationSettings to set
- */
- public void setApplicationSettings(final ApplicationSettings applicationSettings) {
- _applicationSettings = applicationSettings;
- }
-}
\ No newline at end of file
import org.splat.util.BeanHelper;
import org.splat.wapp.ToolBar;
-public class OpenStudy extends OpenObject implements OpenStudyServices {
+public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
/**
* Serial version ID.
protected final static Logger LOGGER = org.splat.simer.Action.LOG;
private transient Study _mystudy;
- private transient StudyRights _urightstudy; // User rights on the open study
- private transient StepRights _urightstep; // User rights on the selected step
+ /**
+ * User rights on the open study.
+ */
+ private transient StudyRights _urightstudy;
+ /**
+ * User rights on the selected step.
+ */
+ private transient StepRights _urightstep;
private transient String _version;
private transient String _credate;
private transient String _lasdate;
Revision.Format verstring = new Revision.Format(getProjectSettings()
.getRevisionPattern());
- cuser = user; // May be null if nobody connected
+ _cuser = user; // May be null if nobody connected
_mystudy = study;
- selection = "0.1"; // Default selection
+ _selection = "0.1"; // Default selection
_selecdoc = null;
// Preparation of the display
_version = verstring.format(_mystudy.getVersion());
_credate = datstring.format(_mystudy.getDate());
_lasdate = ""; // Not yet supported
- description = _mystudy.getDescription();
- involving = new ArrayList<Step>(1);
- context = new ArrayList<SimulationContextFacade>();
- ustep = getProjectElementService().getFirstStep(_mystudy);
- ustep.setActor(cuser);
- involving.add(ustep);
- for (Iterator<SimulationContext> i = ustep.getAllSimulationContexts()
+ _description = _mystudy.getDescription();
+ _involving = new ArrayList<Step>(1);
+ _context = new ArrayList<SimulationContextFacade>();
+ _ustep = getProjectElementService().getFirstStep(_mystudy);
+ _ustep.setActor(_cuser);
+ _involving.add(_ustep);
+ for (Iterator<SimulationContext> i = _ustep.getAllSimulationContexts()
.iterator(); i.hasNext();) {
- context.add(new SimulationContextFacade(i.next(),
+ _context.add(new SimulationContextFacade(i.next(),
getProjectSettings().getAllSteps()));
}
- if (getStudyService().isStaffedBy(_mystudy, cuser)
- || getStudyService().hasActor(_mystudy, cuser)) {
+ if (getStudyService().isStaffedBy(_mystudy, _cuser)
+ || getStudyService().hasActor(_mystudy, _cuser)) {
// ProgressState state = mystudy.getProgressState();
// if (state == ProgressState.inCHECK) popup = getApplicationSettings().getPopupMenu("stapprovable");
// else if (state == ProgressState.APPROVED) popup = getApplicationSettings().getPopupMenu("stapproved");
- /* else */popup = getApplicationSettings().getPopupMenu(
+ /* else */_popup = getApplicationSettings().getPopupMenu(
"steditable");
- popup.setContext("study", new StudyRights(cuser, _mystudy));
+ _popup.setContext("study", new StudyRights(_cuser, _mystudy));
}
- _urightstudy = new StudyRights(cuser, _mystudy);
- _urightstep = new StepRights(cuser, ustep);
+ _urightstudy = new StudyRights(_cuser, _mystudy);
+ _urightstep = new StepRights(_cuser, _ustep);
// RKV menu = new StudyMenu(mystudy);
- menu = (getMenu()).init(_mystudy); // RKV
- menu.selects(selection); // Initializes menu items to be displayed
+ _menu = (getMenu()).init(_mystudy); // RKV
+ _menu.selects(_selection); // Initializes menu items to be displayed
setupContents(); // Initializes documents and knowledge at ustep
return this;
}
@Override
public StudyMenu getMenu() {
- return (StudyMenu) menu;
+ return (StudyMenu) _menu;
}
public void setMenu(final StudyMenu aMenu) {
- menu = aMenu;
+ _menu = aMenu;
}
public ProgressState getProgressState() {
String path = docurl.substring(prefix.length());
Document value = getDocumentService().getDocumentByPath(path);
- _selecdoc = ustep.getDocument(value.getIndex());
+ _selecdoc = _ustep.getDocument(value.getIndex());
} catch (Exception error) {
LOGGER.error("Reason:", error);
}
}
public void setSelection(final String step) {
- if (!step.equals(selection)) {
- selection = step;
+ if (!step.equals(_selection)) {
+ _selection = step;
_selecdoc = null;
setupPreviousToSelectedSteps();
updateSimulationContexts(); // Initializes contexts according to the selected steps
}
- ustep = involving.get(involving.size() - 1);
- _urightstep = new StepRights(cuser, ustep);
- ustep.setActor(cuser);
- menu.selects(selection); // Updates menu items to be displayed
+ _ustep = _involving.get(_involving.size() - 1);
+ _urightstep = new StepRights(_cuser, _ustep);
+ _ustep.setActor(_cuser);
+ _menu.selects(_selection); // Updates menu items to be displayed
setupContents(); // The contents may have changed even if the selection is the same
}
protected void add(final Publication doc) {
DocumentFacade facade = new DocumentFacade(this, doc,
getProjectSettings(), getPublicationService());
- boolean first = (contents.size() == 0);
+ boolean first = (_contents.size() == 0);
docpres.put(doc.getIndex(), facade);
- contents.add(0, facade); // Prepend the new publication
+ _contents.add(0, facade); // Prepend the new publication
if (first) {
this.getMenu().refreshSelectedItem();
}
SimulationContextFacade facade = new SimulationContextFacade(contex,
getProjectSettings().getAllSteps());
- context.add(facade);
+ _context.add(facade);
}
protected void add(final KnowledgeElement kelm) {
// Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
// RKV:Begin: Find a knowledge iterator for appropriate knowledge type
KnowledgeIterator known = null;
- for (KnowledgeIterator aKnowledgeSection : knowledge) {
+ for (KnowledgeIterator aKnowledgeSection : _knowledge) {
if (aKnowledgeSection.getIndex().equals(
String.valueOf(kelm.getType().getIndex()))) {
known = aKnowledgeSection;
}
if (known != null) { // RKV:End
knowpres.put(kelm.getIndex(), facade);
- known.list.add(facade); // Insert the new knowledge at the end of the corresponding knowledge type
+ known._list.add(facade); // Insert the new knowledge at the end of the corresponding knowledge type
}
}
protected void remove(final Publication doctag) {
- for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
+ for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
DocumentFacade facade = i.next();
if (!facade.isFacadeOf(doctag)) {
continue;
i.remove();
break;
}
- if (contents.size() == 0) {
+ if (_contents.size() == 0) {
this.getMenu().refreshSelectedItem();
}
}
protected void changeUser(final User user) {
- cuser = user;
- popup = null;
- if (getStudyService().isStaffedBy(_mystudy, cuser)) {
- popup = getApplicationSettings().getPopupMenu("steditable");
- popup.setContext("study", new StudyRights(cuser, _mystudy));
+ _cuser = user;
+ _popup = null;
+ if (getStudyService().isStaffedBy(_mystudy, _cuser)) {
+ _popup = getApplicationSettings().getPopupMenu("steditable");
+ _popup.setContext("study", new StudyRights(_cuser, _mystudy));
}
// ustep = getProjectElementService().getFirstStep(mystudy);
- if (ustep != null) {
- ustep.setActor(cuser);
+ if (_ustep != null) {
+ _ustep.setActor(_cuser);
}
- _urightstudy = new StudyRights(cuser, _mystudy);
- _urightstep = new StepRights(cuser, ustep);
+ _urightstudy = new StudyRights(_cuser, _mystudy);
+ _urightstep = new StepRights(_cuser, _ustep);
}
protected void remove(final SimulationContext contex) {
- for (Iterator<SimulationContextFacade> i = context.iterator(); i
+ for (Iterator<SimulationContextFacade> i = _context.iterator(); i
.hasNext();) {
SimulationContextFacade facade = i.next();
if (!facade.isFacadeOf(contex)) {
}
protected void remove(final KnowledgeElement kelm) {
- KnowledgeIterator known = knowledge.get((int) (kelm.getType()
+ KnowledgeIterator known = _knowledge.get((int) (kelm.getType()
.getIndex() - 2));
// Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
knowpres.remove(kelm.getIndex());
- for (Iterator<KnowledgeElementFacade> i = known.list.iterator(); i
+ for (Iterator<KnowledgeElementFacade> i = known._list.iterator(); i
.hasNext();) {
KnowledgeElementFacade facade = i.next();
if (!facade.isFacadeOf(BeanHelper.copyBean(kelm,
}
protected void updateSimulationContexts() {
- context.clear();
- for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
+ _context.clear();
+ for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
for (Iterator<SimulationContext> j = i.next()
.getAllSimulationContexts().iterator(); j.hasNext();) {
- context.add(new SimulationContextFacade(j.next(),
+ _context.add(new SimulationContextFacade(j.next(),
getProjectSettings().getAllSteps()));
}
}
// ==============================================================================================================================
private void setupPreviousToSelectedSteps() {
- String[] item = selection.split("\\x2E");
+ String[] item = _selection.split("\\x2E");
int major = Integer.valueOf(item[0]);
int minor = Integer.valueOf(item[1]);
int base = minor;
Step[] step;
- involving.clear();
+ _involving.clear();
if (major > 0) {
Scenario[] branch = _mystudy.getScenarii();
Scenario scenar = branch[0];
step = getProjectElementService().getSteps(scenar);
base = step[0].getNumber() - 1;
for (int i = 0; i + base < minor; i++) {
- involving.add(step[i]);
+ _involving.add(step[i]);
}
}
step = getProjectElementService().getSteps(_mystudy);
if (firstep.getNumber() > base) {
continue;
}
- involving.add(0, firstep);
+ _involving.add(0, firstep);
}
}
+++ /dev/null
-package org.splat.simer;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.splat.kernel.InvalidPropertyException;
-import org.splat.kernel.Name;
-import org.splat.dal.bo.kernel.User;
-import org.splat.som.ApplicationRights;
-import org.splat.service.SimulationContextService;
-import org.splat.service.UserService;
-import org.splat.service.technical.ProjectSettingsService;
-import org.splat.service.dto.Proxy;
-import org.splat.dal.bo.som.SimulationContext;
-import org.splat.dal.bo.som.SimulationContextType;
-
-public abstract class SearchBaseAction extends Action {
-
- /**
- * Serial version ID.
- */
- private static final long serialVersionUID = 7863055790228544510L;
-
- protected String ctype = null; // Context type index, when selected
- protected String cvalue = null; // Context value index, when selected
- protected String cindex = ""; // Context index, when removed
- protected String author = null;
- protected List<Name> manager = null;
- protected SimulationContextType newtype; // Context type to be valued
- protected List<SimulationContext> newvalue; // Context value to be selected
- protected List<SimulationContextType> critext; // Addable context types
- protected List<SimulationContext> context; // Current contexts search criteria
- protected List<Proxy> result;
- /**
- * Injected simulation context service.
- */
- private SimulationContextService _simulationContextService;
-
- /**
- * Injected user service.
- */
- private UserService _userService;
-
- enum UserAction {
- refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
- }
-
- // ==============================================================================================================================
- // Action methods
- // ==============================================================================================================================
-
- public String doSubmitForm() {
- // Identification of the user action
- UserAction action = UserAction.refreshResult;
- if (ctype != null && Integer.valueOf(ctype) > 0)
- action = UserAction.selectContextType;
- else if (cvalue != null && Integer.valueOf(cvalue) > 0)
- action = UserAction.selectContextValue;
- else if (cindex.length() > 0) {
- int index = Integer.valueOf(cindex);
- if (index > 0)
- action = UserAction.removeContext;
- else if (index < 0)
- action = UserAction.cancelSelect;
- }
- // Execution of the user action
- String done;
- try {
- saveFilter(); // Also reinitializes the form, if needed
-
- if (action == UserAction.selectContextType) {
- done = doSelectContextType();
- } else if (action == UserAction.selectContextValue) {
- done = doAddContext();
- } else if (action == UserAction.removeContext) {
- done = doRemoveContext();
- } else if (action == UserAction.cancelSelect) {
- done = doCancel();
- } else { // UserAction.refreshResult
- done = doSearch();
- setContextTypeOptions(getInvolvedContexts()); // Done in other do functions, when required
- }
- setCandidates();
- return done;
- } catch (Exception error) {
- // No need to roll back the transaction as it is read only
- LOG.error("Reason: ", error);
- return ERROR;
- }
- }
-
- @SuppressWarnings("unchecked")
- protected String doSelectContextType() {
- SimulationContext.Properties sprop = new SimulationContext.Properties();
-
- newtype = getSimulationContextService().selectType(
- Integer.valueOf(ctype));
- newvalue = getSimulationContextService().selectSimulationContextsWhere(
- sprop.setType(newtype));
- if (cindex.length() > 0 && Integer.valueOf(cindex) == 0)
- getSession().remove("search.result");
- else
- result = (List<Proxy>) getSession().get("search.result"); // We keep the previous result search, if valid
- return "selectype";
- }
-
- protected String doAddContext() {
- SimulationContext selected = getSimulationContextService()
- .selectSimulationContext(Integer.valueOf(cvalue));
-
- context.add(selected);
- setContextTypeOptions(getInvolvedContexts()); // Sets critext
- getSession().remove("search.result"); // The current result is obsolete
- return "refresh";
- }
-
- protected String doRemoveContext() {
- int index = Integer.valueOf(cindex);
- for (Iterator<SimulationContext> selected = context.iterator(); selected
- .hasNext();) {
- if (selected.next().getIndex() == index) {
- selected.remove();
- break;
- }
- }
- setContextTypeOptions(getInvolvedContexts()); // Sets critext
- getSession().remove("search.result"); // The current result is obsolete
- return "refresh";
- }
-
- @SuppressWarnings("unchecked")
- protected String doCancel() {
- result = (List<Proxy>) getSession().get("search.result"); // Current result search
- setContextTypeOptions(getInvolvedContexts()); // Sets critext
- return "refresh";
- }
-
- // ==============================================================================================================================
- // Getters
- // ==============================================================================================================================
-
- public String getAuthor() {
- return author;
- }
-
- public List<Name> getCandidates() {
- return manager;
- }
-
- public List<SimulationContextType> getContextTypeOptions() {
- return critext;
- }
-
- public List<SimulationContext> getContextValueOptions() {
- return newvalue;
- }
-
- public SimulationContextType getSelectedContextType() {
- return newtype;
- }
-
- public List<SimulationContext> getSimulationContexts() {
- return context;
- }
-
- public List<Proxy> getResult() {
- return result;
- }
-
- // ==============================================================================================================================
- // Setters
- // ==============================================================================================================================
-
- public void setAuthor(String index) {
- this.author = index;
- }
-
- public void setContextType(String type) {
- this.ctype = type;
- }
-
- public void setContextValue(String value) {
- this.cvalue = value;
- }
-
- public void setContextIndex(String value) {
- this.cindex = value;
- }
-
- protected void setCandidates() {
- manager = new Vector<Name>();
- List<User> users = getUserService().selectAllUsers();
- User me = getConnectedUser(); // May be null
- for (Iterator<User> i = users.iterator(); i.hasNext();) {
- User next = i.next();
- ApplicationRights he = new ApplicationRights(next);
- if (he.canCreateStudy()) {
- if (next.equals(me))
- manager.add(0, new ValidationFacade.ByManager(me));
- else
- manager.add(next);
- }
- }
- }
-
- protected void setContextTypeOptions(List<SimulationContextType> critext) {
- for (Iterator<SimulationContext> i = context.iterator(); i.hasNext();) {
- critext.remove(i.next().getType()); // Already used context type
- }
- // Ordering by alphabetical order of localized context types
- SimulationContextType[] types = critext
- .toArray(new SimulationContextType[critext.size()]);
- ContextTypeComparator compare = new ContextTypeComparator();
- ProjectSettingsService.Step step = getSimulationContextService()
- .getAttachedStep(types[0]);
- int from = 0;
- int to = 0;
- while (to < types.length - 1) {
- to += 1;
- if (types[to].isAttachedTo(step))
- continue;
-
- if (to > from + 1)
- Arrays.sort(types, from, to, compare);
- from = to;
- step = getSimulationContextService().getAttachedStep(types[to]);
- }
- if (to > from)
- Arrays.sort(types, from, to + 1, compare);
- this.critext = Arrays.asList(types);
- }
-
- // ==============================================================================================================================
- // Abstract services
- // ==============================================================================================================================
-
- protected abstract String doSearch() throws InvalidPropertyException;
-
- protected abstract List<SimulationContextType> getInvolvedContexts();
-
- protected abstract void loadFilter();
-
- protected abstract void saveFilter();
-
- /**
- * Get the simulationContextService.
- *
- * @return the simulationContextService
- */
- public SimulationContextService getSimulationContextService() {
- return _simulationContextService;
- }
-
- /**
- * Set the simulationContextService.
- *
- * @param simulationContextService
- * the simulationContextService to set
- */
- public void setSimulationContextService(
- SimulationContextService simulationContextService) {
- _simulationContextService = simulationContextService;
- }
-
- /**
- * Get the userService.
- * @return the userService
- */
- public UserService getUserService() {
- return _userService;
- }
-
- /**
- * Set the userService.
- * @param userService the userService to set
- */
- public void setUserService(UserService userService) {
- _userService = userService;
- }
-}
\ No newline at end of file
import java.util.List;
import java.util.Map;
-import org.splat.kernel.InvalidPropertyException;
import org.splat.dal.bo.kernel.User;
-import org.splat.service.KnowledgeElementTypeService;
-import org.splat.service.SearchService;
-import org.splat.service.SimulationContextService;
-import org.splat.service.UserService;
import org.splat.dal.bo.som.KnowledgeElement;
import org.splat.dal.bo.som.KnowledgeElementType;
import org.splat.dal.bo.som.ProgressState;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
import org.splat.dal.bo.som.Visibility;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.KnowledgeElementTypeService;
+import org.splat.service.SearchService;
+import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
/**
* Action for searching a knowledge in the database.
*/
-public class SearchKnowledgeAction extends SearchBaseAction {
+public class SearchKnowledgeAction extends AbstractSearchBaseAction {
/**
* Serial version ID.
*/
private static final long serialVersionUID = -3104321907432838476L;
- private String visibility = null; // "Private", "Public", "All"
- private String typid = null; // Knowledge type index when among all
- private String matchamong = null; // "all" or "any"
- private String matcontext = null; // "all" or "any"
- private String refid = null; // Knowledge reference when among ref
- private String words = null; // Full text search words
- private List<KnowledgeElementType> types; // Available knowledge types filter (initialized below)
+ /**
+ * "Private", "Public", "All".
+ */
+ private String _visibility = null;
+ /**
+ * Knowledge type index when among all.
+ */
+ private String _state = null;
+ /**
+ * Criteria match: "all" or "any".
+ */
+ private String _criteriaMatch = null;
+ /**
+ * Simulation context match: "all" or "any".
+ */
+ private String _contextMatch = null;
+ /**
+ * Knowledge reference when among ref.
+ */
+ private String _reference = null;
+ /**
+ * Full text search words.
+ */
+ private String _words = null;
+ /**
+ * Available knowledge types filter (initialized below).
+ */
+ private transient List<KnowledgeElementType> _knowledgeTypes;
+ /**
+ * Injected search service.
+ */
private SearchService _searchService;
/**
* Injected simulation context service.
setLeftMenuProperty("open");
initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
+ String res = SUCCESS;
try {
loadFilter();
doSearch();
// Final initialization of the form
- types = getKnowledgeElementTypeService().selectTypesWhere(
+ _knowledgeTypes = getKnowledgeElementTypeService().selectTypesWhere(
ProgressState.APPROVED);
setCandidates();
setContextTypeOptions(getInvolvedContexts());
-
- return SUCCESS;
} catch (Exception error) {
// No need to roll back the transaction as it is read only
LOG.error("Reason: ", error);
- return ERROR;
+ res = ERROR;
}
+ return res;
}
+ @Override
protected String doSearch() throws InvalidPropertyException {
// ----------------------------
setMenuProperty("open");
initializationScreenContext(_menuProperty);
Map<String, Object> session = getSession();
- User user = getConnectedUser();
KnowledgeElement.Properties sprop = new KnowledgeElement.Properties();
// Search matching all criteria
sprop.setType(getKnowledgeElementTypeService().selectType(
- Integer.valueOf(typid)));
- if (words.length() > 0)
- sprop.setTitle(words);
- if (refid.length() > 0)
- sprop.setReference(refid);
- if (context.size() > 0)
- sprop.setSimulationContexts(context);
- int index = Integer.valueOf(author);
+ Integer.valueOf(_state)));
+ if (_words.length() > 0) {
+ sprop.setTitle(_words);
+ }
+ if (_reference.length() > 0) {
+ sprop.setReference(_reference);
+ }
+ if (_context.size() > 0) {
+ sprop.setSimulationContexts(_context);
+ }
+ int index = Integer.valueOf(_author);
if (index > 0) {
User him = getUserService().selectUser(index);
sprop.setAuthor(him);
}
// Set of the visibility
- if (visibility.equals("all")) {
+ if ("all".equals(_visibility)) {
KnowledgeElement.Properties other = sprop.copy();
other.setVisibility(Visibility.PUBLIC);
sprop.setVisibility(Visibility.PRIVATE);
- sprop.setActor(user);
+ sprop.setActor(getConnectedUser());
- result = getSearchService().selectKnowledgeElementsWhere(sprop,
+ _result = getSearchService().selectKnowledgeElementsWhere(sprop,
other);
} else {
- Visibility reparea = null;
- if (visibility.equals("onlypublic"))
+ Visibility reparea;
+ if ("onlypublic".equals(_visibility)) {
reparea = Visibility.PUBLIC;
- else
- reparea = Visibility.valueOf(visibility);
+ } else {
+ reparea = Visibility.valueOf(_visibility);
+ }
sprop.setVisibility(reparea);
- if (reparea == Visibility.PRIVATE)
- sprop.setActor(user);
+ if (reparea == Visibility.PRIVATE) {
+ sprop.setActor(getConnectedUser());
+ }
- result = getSearchService().selectKnowledgeElementsWhere(sprop);
+ _result = getSearchService().selectKnowledgeElementsWhere(sprop);
}
- session.put("search.result", result); // For redisplaying the page without re-executing the search
+ session.put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
return "refresh";
}
public String getContextMatch() {
// --------------------------------
- return matcontext;
+ return _contextMatch;
}
public String getCriteriaMatch() {
// ---------------------------------
- return matchamong;
+ return _criteriaMatch;
}
public List<KnowledgeElementType> getKnowledgeTypes() {
// ------------------------------------------------------
- return types;
+ return _knowledgeTypes;
}
public String getReference() {
// -----------------------------
- return refid;
+ return _reference;
}
public String getState() {
// ------------------------
- return typid;
+ return _state;
}
public String getVisibility() {
// ------------------------------
- return visibility;
+ return _visibility;
}
public String getWords() {
// -------------------------
- return words;
+ return _words;
}
// ==============================================================================================================================
// Setters
// ==============================================================================================================================
- public void setContextMatch(String value) {
+ public void setContextMatch(final String value) {
// ------------------------------------------
- this.matcontext = value;
+ this._contextMatch = value;
}
- public void setCriteriaMatch(String value) {
+ public void setCriteriaMatch(final String value) {
// -------------------------------------------
- this.matchamong = value;
+ this._criteriaMatch = value;
}
- public void setReference(String value) {
+ public void setReference(final String value) {
// ---------------------------------------
- this.refid = value;
+ this._reference = value;
}
- public void setState(String value) {
+ public void setState(final String value) {
// ----------------------------------
- this.typid = value;
+ this._state = value;
}
- public void setVisibility(String value) {
+ public void setVisibility(final String value) {
// ----------------------------------------
- this.visibility = value;
+ this._visibility = value;
}
- public void setWords(String value) {
+ public void setWords(final String value) {
// -----------------------------------
- this.words = value;
+ this._words = value;
}
// ==============================================================================================================================
// Implementation of abstract services
// ==============================================================================================================================
+ @Override
protected List<SimulationContextType> getInvolvedContexts() {
// ------------------------------------------------------------
return getSimulationContextService().selectAllTypes();
}
+ @Override
@SuppressWarnings("unchecked")
protected void loadFilter() {
// ----------------------------
Map<String, Object> filter = (Map<String, Object>) session
.get("knowledge.filter"); // A default filter is supposed being set at start
- visibility = (String) filter.get("visibility");
- matchamong = (String) filter.get("matchamong");
- matcontext = (String) filter.get("matcontext");
- typid = (String) filter.get("type");
- author = (String) filter.get("author");
- refid = (String) filter.get("reference");
- words = (String) filter.get("title");
- context = (List<SimulationContext>) filter.get("context");
+ _visibility = (String) filter.get("visibility");
+ _criteriaMatch = (String) filter.get("matchamong");
+ _contextMatch = (String) filter.get("matcontext");
+ _state = (String) filter.get("type");
+ _author = (String) filter.get("author");
+ _reference = (String) filter.get("reference");
+ _words = (String) filter.get("title");
+ _context = (List<SimulationContext>) filter.get("context");
if (user == null) {
- visibility = "onlypublic";
+ _visibility = "onlypublic";
}
}
+ @Override
@SuppressWarnings("unchecked")
protected void saveFilter() {
// ----------------------------
Map<String, Object> filter = (Map<String, Object>) session
.get("knowledge.filter"); // A default filter is supposed being set at start
- filter.put("visibility", this.visibility);
- filter.put("matchamong", this.matchamong);
- filter.put("matcontext", this.matcontext);
- filter.put("type", this.typid);
- filter.put("author", this.author);
+ filter.put("visibility", this._visibility);
+ filter.put("matchamong", this._criteriaMatch);
+ filter.put("matcontext", this._contextMatch);
+ filter.put("type", this._state);
+ filter.put("author", this._author);
filter.put("reference", "");
- filter.put("title", this.words);
+ filter.put("title", this._words);
- context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
+ _context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
// Initialization required by all do functions
- types = getKnowledgeElementTypeService().selectTypesWhere(ProgressState.APPROVED);
+ _knowledgeTypes = getKnowledgeElementTypeService().selectTypesWhere(ProgressState.APPROVED);
}
/**
* @param searchService
* the searchService to set
*/
- public void setSearchService(SearchService searchService) {
+ public void setSearchService(final SearchService searchService) {
_searchService = searchService;
}
*
* @return the simulationContextService
*/
+ @Override
public SimulationContextService getSimulationContextService() {
return _simulationContextService;
}
* @param simulationContextService
* the simulationContextService to set
*/
+ @Override
public void setSimulationContextService(
- SimulationContextService simulationContextService) {
+ final SimulationContextService simulationContextService) {
_simulationContextService = simulationContextService;
}
* the knowledgeElementTypeService to set
*/
public void setKnowledgeElementTypeService(
- KnowledgeElementTypeService knowledgeElementTypeService) {
+ final KnowledgeElementTypeService knowledgeElementTypeService) {
_knowledgeElementTypeService = knowledgeElementTypeService;
}
* Get the userService.
* @return the userService
*/
+ @Override
public UserService getUserService() {
return _userService;
}
* Set the userService.
* @param userService the userService to set
*/
- public void setUserService(UserService userService) {
+ @Override
+ public void setUserService(final UserService userService) {
_userService = userService;
}
* Set the menuProperty.
* @param menuProperty the menuProperty to set
*/
- public void setMenuProperty(String menuProperty) {
+ public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
import java.util.List;
import java.util.Map;
-import org.splat.kernel.InvalidPropertyException;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.ProgressState;
-import org.splat.service.SearchService;
-import org.splat.service.SimulationContextService;
-import org.splat.service.UserService;
-import org.splat.service.technical.ProjectSettingsService;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
import org.splat.dal.bo.som.Study;
import org.splat.dal.bo.som.Visibility;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.service.SearchService;
+import org.splat.service.SimulationContextService;
+import org.splat.service.UserService;
+import org.splat.service.technical.ProjectSettingsService;
/**
* Search studies form action.
- *
- * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
*/
-public class SearchStudyAction extends SearchBaseAction {
-
- private String visibility = null; // "Private", "Public", "All"
- private String state = null; // "In-Work", "In-Draft", "In-Check"...
- private String matchamong = null; // "all" or "any"
- private String matcontext = null; // "all" or "any"
- private String refid = null; // Study reference
- private String words = null; // Full text search words
+public class SearchStudyAction extends AbstractSearchBaseAction {
+
+ /**
+ * "Private", "Public", "All".
+ */
+ private String _visibility = null;
+ /**
+ * "In-Work", "In-Draft", "In-Check"...
+ */
+ private String _state = null;
+ /**
+ * Criteria match: "all" or "any".
+ */
+ private String _criteriaMatch = null;
+ /**
+ * Simulation context match: "all" or "any".
+ */
+ private String _contextMatch = null;
+ /**
+ * Study reference.
+ */
+ private String _reference = null;
+ /**
+ * Full text search words.
+ */
+ private String _words = null;
/**
* Injected project settings service.
*/
- private ProjectSettingsService _projectSettingsService;
+ private ProjectSettingsService _projectSettings;
/**
* Injected search service.
*/
* @return SUCCESS if no exception, otherwise return ERROR
*/
public String doInitialize() {
+ String res = SUCCESS;
try {
loadFilter();
doSearch();
setToolProperty("none");
setLeftMenuProperty("open");
initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
-
- return SUCCESS;
} catch (Exception error) {
// No need to roll back the transaction as it is read only
LOG.error("Reason: ", error);
setMenuProperty("none");
initializationScreenContext(_menuProperty);
- return ERROR;
+ res = ERROR;
}
+ return res;
}
+ /**
+ * {@inheritDoc}
+ * @see org.splat.simer.AbstractSearchBaseAction#doSearch()
+ */
+ @Override
protected String doSearch() throws InvalidPropertyException {
- // ----------------------------
Map<String, Object> session = getSession();
- User user = getConnectedUser();
-
Study.Properties sprop = new Study.Properties();
// Search matching all criteria
- if (!this.state.equals("ANY"))
- sprop.setState(ProgressState.valueOf(this.state));
- if (words.length() > 0)
- sprop.setTitle(words);
- if (refid.length() > 0)
- sprop.setReference(refid);
- if (context.size() > 0)
- sprop.setSimulationContexts(context);
- int index = Integer.valueOf(author);
+ if (!this._state.equals("ANY")) {
+ sprop.setState(ProgressState.valueOf(this._state));
+ }
+ if (_words.length() > 0) {
+ sprop.setTitle(_words);
+ }
+ if (_reference.length() > 0) {
+ sprop.setReference(_reference);
+ }
+ if (_context.size() > 0) {
+ sprop.setSimulationContexts(_context);
+ }
+ int index = Integer.valueOf(_author);
if (index > 0) {
User him = getUserService().selectUser(index);
sprop.setManager(him);
}
// Set of the visibility
- if (visibility.equals("all")) {
+ if ("all".equals(_visibility)) {
Study.Properties other = sprop.copy();
other.setVisibility(Visibility.PUBLIC);
sprop.setVisibility(Visibility.PRIVATE);
- sprop.setActor(user);
+ sprop.setActor(getConnectedUser());
- result = getSearchService().selectStudiesWhere(sprop, other);
+ _result = getSearchService().selectStudiesWhere(sprop, other);
} else {
Visibility reparea = null;
- if (visibility.equals("onlypublic"))
+ if ("onlypublic".equals(_visibility)) {
reparea = Visibility.PUBLIC;
- else
- reparea = Visibility.valueOf(visibility);
+ } else {
+ reparea = Visibility.valueOf(_visibility);
+ }
sprop.setVisibility(reparea);
- if (reparea == Visibility.PRIVATE)
- sprop.setActor(user);
+ if (reparea == Visibility.PRIVATE) {
+ sprop.setActor(getConnectedUser());
+ }
- result = getSearchService().selectStudiesWhere(sprop);
+ _result = getSearchService().selectStudiesWhere(sprop);
}
- session.put("search.result", result); // For redisplaying the page without re-executing the search
+ session.put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
return "refresh";
}
// ==============================================================================================================================
public String getContextMatch() {
- // --------------------------------
- return matcontext;
+ return _contextMatch;
}
public String getCriteriaMatch() {
- // ---------------------------------
- return matchamong;
+ return _criteriaMatch;
}
public String getReference() {
- // -----------------------------
- return refid;
+ return _reference;
}
public String getState() {
- // -------------------------
- return state;
+ return _state;
}
public String getVisibility() {
- // ------------------------------
- return visibility;
+ return _visibility;
}
public String getWords() {
- // -------------------------
- return words;
+ return _words;
}
// ==============================================================================================================================
// Setters
// ==============================================================================================================================
- public void setContextMatch(String value) {
- // ------------------------------------------
- this.matcontext = value;
+ public void setContextMatch(final String value) {
+ this._contextMatch = value;
}
- public void setCriteriaMatch(String value) {
- // -------------------------------------------
- this.matchamong = value;
+ public void setCriteriaMatch(final String value) {
+ this._criteriaMatch = value;
}
- public void setReference(String value) {
- // ---------------------------------------
- this.refid = value;
+ public void setReference(final String value) {
+ this._reference = value;
}
- public void setState(String value) {
- // -----------------------------------
- this.state = value;
+ public void setState(final String value) {
+ this._state = value;
}
- public void setVisibility(String value) {
- // ----------------------------------------
- this.visibility = value;
+ public void setVisibility(final String value) {
+ this._visibility = value;
}
- public void setWords(String value) {
- // -----------------------------------
- this.words = value;
+ public void setWords(final String value) {
+ this._words = value;
}
// ==============================================================================================================================
// Implementation of abstract services
// ==============================================================================================================================
+ @Override
protected List<SimulationContextType> getInvolvedContexts() {
- // ------------------------------------------------------------
List<ProjectSettingsService.Step> steps = getProjectSettings()
.getStepsOf(Study.class);
ProjectSettingsService.Step[] number = steps
return getSimulationContextService().selectTypesOf(number);
}
+ @Override
@SuppressWarnings("unchecked")
protected void loadFilter() {
- // ----------------------------
Map<String, Object> session = getSession();
User user = getConnectedUser();
Map<String, Object> filter = (Map<String, Object>) session
.get("study.filter"); // A default filter is supposed being set at start
- visibility = (String) filter.get("visibility");
- matchamong = (String) filter.get("matchamong");
- matcontext = (String) filter.get("matcontext");
- state = (String) filter.get("state");
- author = (String) filter.get("author");
- refid = (String) filter.get("reference");
- words = (String) filter.get("title");
- context = (List<SimulationContext>) filter.get("context");
+ _visibility = (String) filter.get("visibility");
+ _criteriaMatch = (String) filter.get("matchamong");
+ _contextMatch = (String) filter.get("matcontext");
+ _state = (String) filter.get("state");
+ _author = (String) filter.get("author");
+ _reference = (String) filter.get("reference");
+ _words = (String) filter.get("title");
+ _context = (List<SimulationContext>) filter.get("context");
if (user == null) {
- visibility = "onlypublic";
+ _visibility = "onlypublic";
}
}
+ @Override
@SuppressWarnings("unchecked")
protected void saveFilter() {
- // ----------------------------
Map<String, Object> session = getSession();
Map<String, Object> filter = (Map<String, Object>) session
.get("study.filter"); // A default filter is supposed being set at start
- filter.put("visibility", this.visibility);
- filter.put("matchamong", this.matchamong);
- filter.put("matcontext", this.matcontext);
- filter.put("state", this.state);
- filter.put("author", this.author);
- filter.put("reference", this.refid);
- filter.put("title", this.words);
+ filter.put("visibility", this._visibility);
+ filter.put("matchamong", this._criteriaMatch);
+ filter.put("matcontext", this._contextMatch);
+ filter.put("state", this._state);
+ filter.put("author", this._author);
+ filter.put("reference", this._reference);
+ filter.put("title", this._words);
- context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
+ _context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
}
* @param searchService
* the searchService to set
*/
- public void setSearchService(SearchService searchService) {
+ public void setSearchService(final SearchService searchService) {
_searchService = searchService;
}
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
+ return _projectSettings;
}
/**
* @param projectSettingsService
* project settings service
*/
- public void setProjectSettings(ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
+ public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
+ _projectSettings = projectSettingsService;
}
/**
*
* @return the simulationContextService
*/
+ @Override
public SimulationContextService getSimulationContextService() {
return _simulationContextService;
}
* @param simulationContextService
* the simulationContextService to set
*/
+ @Override
public void setSimulationContextService(
- SimulationContextService simulationContextService) {
+ final SimulationContextService simulationContextService) {
_simulationContextService = simulationContextService;
}
*
* @return the userService
*/
+ @Override
public UserService getUserService() {
return _userService;
}
* @param userService
* the userService to set
*/
- public void setUserService(UserService userService) {
+ @Override
+ public void setUserService(final UserService userService) {
_userService = userService;
}
* Set the menuProperty.
* @param menuProperty the menuProperty to set
*/
- public void setMenuProperty(String menuProperty) {
+ public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
import java.util.ResourceBundle;
import org.splat.dal.bo.som.ProgressState;
-import org.splat.service.technical.ProjectSettingsService;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.SimulationContextType;
+import org.splat.service.technical.ProjectSettingsService;
import org.splat.wapp.PopupMenu;
-
public class SimulationContextFacade {
- private SimulationContext my;
- private String name;
- private int step;
- private ProgressState state;
- private PopupMenu popup;
-
-// ==============================================================================================================================
-// Constructor
-// ==============================================================================================================================
-
- public SimulationContextFacade (SimulationContext represented, List<ProjectSettingsService.Step> allSteps) {
-// --------------------------------------------------------------
- my = represented;
- popup = ApplicationSettings.getPopupMenu("scontext");
-
- SimulationContextType type = my.getType();
- for (Iterator<ProjectSettingsService.Step> i=allSteps.iterator(); i.hasNext(); ) {
- ProjectSettingsService.Step next = i.next();
- if (!type.isAttachedTo(next)) continue;
- step = next.getNumber();
- break;
- }
- state = my.getProgressState(); // inCHECK or APPROVED
- name = type.getName();
- if (type.isApproved()) {
- name = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale()).getString("type.context." + name);
- } else {
- state = ProgressState.inDRAFT;
- }
- }
-
-// ==============================================================================================================================
-// Getters
-// ==============================================================================================================================
-
- public String getEditIcon () {
-// ----------------------------
- return "icon.ed" + state + ".png";
- }
- public String getIndex () {
-// -------------------------
- return String.valueOf(my.getIndex());
- }
- public PopupMenu getPopup () {
-// ----------------------------
- popup.setContext("scontext", this); // Cannot be done at construction because pop-ups are shared
- return popup;
- }
- public String getStateIcon () {
-// -----------------------------
- return "icon." + state + ".png";
- }
- public String getStepNumber () {
-// ------------------------------
- return String.valueOf(step);
- }
- public String getTypeName () {
-// ----------------------------
- return name;
- }
- public String getValue () {
-// -------------------------
- return my.getValue();
- }
-
- public boolean isApproved () {
-// ----------------------------
- return (state == ProgressState.APPROVED);
- }
- public boolean isEditable () {
-// ----------------------------
- return !my.isShared();
- }
- public boolean isFacadeOf (SimulationContext represented) {
-// ---------------------------------------------------------
- return my.equals(represented);
- }
+ private final SimulationContext _my;
+ private String _name;
+ private int _step;
+ private ProgressState _state;
+ private final PopupMenu _popup;
+
+ // ==============================================================================================================================
+ // Constructor
+ // ==============================================================================================================================
+
+ public SimulationContextFacade(final SimulationContext represented,
+ final List<ProjectSettingsService.Step> allSteps) {
+ _my = represented;
+ _popup = ApplicationSettings.getPopupMenu("scontext");
+
+ SimulationContextType type = _my.getType();
+ for (Iterator<ProjectSettingsService.Step> i = allSteps.iterator(); i
+ .hasNext();) {
+ ProjectSettingsService.Step next = i.next();
+ if (!type.isAttachedTo(next)) {
+ continue;
+ }
+ _step = next.getNumber();
+ break;
+ }
+ _state = _my.getProgressState(); // inCHECK or APPROVED
+ _name = type.getName();
+ if (type.isApproved()) {
+ _name = ResourceBundle.getBundle("som",
+ ApplicationSettings.getCurrentLocale()).getString(
+ "type.context." + _name);
+ } else {
+ _state = ProgressState.inDRAFT;
+ }
+ }
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
+
+ public String getEditIcon() {
+
+ return "icon.ed" + _state + ".png";
+ }
+
+ public String getIndex() {
+ return String.valueOf(_my.getIndex());
+ }
+
+ public PopupMenu getPopup() {
+
+ _popup.setContext("scontext", this); // Cannot be done at construction because pop-ups are shared
+ return _popup;
+ }
+
+ public String getStateIcon() {
+ return "icon." + _state + ".png";
+ }
+
+ public String getStepNumber() {
+ return String.valueOf(_step);
+ }
+
+ public String getTypeName() {
+ return _name;
+ }
+
+ public String getValue() {
+ return _my.getValue();
+ }
+
+ public boolean isApproved() {
+ return (_state == ProgressState.APPROVED);
+ }
+
+ public boolean isEditable() {
+ return !_my.isShared();
+ }
+
+ public boolean isFacadeOf(final SimulationContext represented) {
+ return _my.equals(represented);
+ }
}
\ No newline at end of file
package org.splat.simer;
+
/**
*
* @author Daniel Brunier-Coulin
import org.splat.dal.bo.som.Timestamp;
import org.splat.dal.bo.som.ValidationStep;
-
public class StampFacade implements HistoryFacade {
- private String icon;
- private String comment;
- private String date;
- private String empty;
- private String nonicon;
-
-// ==============================================================================================================================
-// Constructor
-// ==============================================================================================================================
-
- public StampFacade (Timestamp stamp) {
-// ------------------------------------
- ResourceBundle labels = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale());
- ResourceBundle custom = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
- SimpleDateFormat convert = new SimpleDateFormat(custom.getString("date.format")); // Date display format
- ValidationStep type = stamp.getType();
-
- nonicon = "image.hold.gif";
- empty = "";
- date = convert.format(stamp.getDate());
- comment = labels.getString("label." + type.toString()) + " " + stamp.getAuthor().toString();
- if (type == ValidationStep.APPROVAL) icon = "icon.APPROVED.png";
- else if (type == ValidationStep.REVIEW) icon = "icon.inCHECK.png";
- else if (type == ValidationStep.PROMOTION) icon = "icon.inDRAFT.png";
- else icon = "icon.inWORK.png";
- }
-
-// ==============================================================================================================================
-// Getters
-// ==============================================================================================================================
-
- public String getDate () {
-// ------------------------
- return date;
- }
- public String getDescription () {
-// -------------------------------
- return comment;
- }
- public String getFileIcon () {
-// ----------------------------
- return icon;
- }
- public String getSharingIcon () {
-// -------------------------------
- return nonicon;
- }
- public String getSize () {
-// ------------------------
- return empty;
- }
- public String getVersion () {
-// ---------------------------
- return empty;
- }
- public String getVersioningIcon () {
-// ----------------------------------
- return nonicon;
- }
+ private transient String _icon;
+ private transient final String _comment;
+ private transient final String _date;
+ private transient final String _empty;
+ private transient final String _nonicon;
+
+ // ==============================================================================================================================
+ // Constructor
+ // ==============================================================================================================================
+
+ public StampFacade(final Timestamp stamp) {
+ ResourceBundle labels = ResourceBundle.getBundle("labels",
+ ApplicationSettings.getCurrentLocale());
+ ResourceBundle custom = ResourceBundle.getBundle("som",
+ ApplicationSettings.getCurrentLocale());
+ SimpleDateFormat convert = new SimpleDateFormat(custom
+ .getString("date.format")); // Date display format
+ ValidationStep type = stamp.getType();
+
+ _nonicon = "image.hold.gif";
+ _empty = "";
+ _date = convert.format(stamp.getDate());
+ _comment = labels.getString("label." + type.toString()) + " "
+ + stamp.getAuthor().toString();
+ if (type == ValidationStep.APPROVAL) {
+ _icon = "icon.APPROVED.png";
+ } else if (type == ValidationStep.REVIEW) {
+ _icon = "icon.inCHECK.png";
+ } else if (type == ValidationStep.PROMOTION) {
+ _icon = "icon.inDRAFT.png";
+ } else {
+ _icon = "icon.inWORK.png";
+ }
+ }
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
+
+ public String getDate() {
+ return _date;
+ }
+
+ public String getDescription() {
+ return _comment;
+ }
+
+ public String getFileIcon() {
+ return _icon;
+ }
+
+ public String getSharingIcon() {
+ return _nonicon;
+ }
+
+ public String getSize() {
+ return _empty;
+ }
+
+ public String getVersion() {
+ return _empty;
+ }
+
+ public String getVersioningIcon() {
+ return _nonicon;
+ }
}
\ No newline at end of file
import java.util.Map;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;
-import org.apache.struts2.util.ServletContextAware;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.splat.som.ApplicationRights;
-import org.splat.dal.dao.som.Database;
import org.splat.service.technical.ProjectSettingsService;
+import org.splat.som.ApplicationRights;
+import org.splat.wapp.Constants;
-
-
+/**
+ * Start application action.
+ */
public class StartAction extends Action implements ServletRequestAware {
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 5875058140682652964L;
- private HttpServletRequest request = null;
+ /**
+ * HTTP request.
+ */
+ private transient HttpServletRequest _request = null;
- private ProjectSettingsService _projectSettingsService;
- private ApplicationSettings _ApplicationSettings;
-
/**
- * Value of the menu property.
- * It can be: none, create, open, study, knowledge, sysadmin, help.
+ * Injected project settings service.
+ */
+ private ProjectSettingsService _projectSettings;
+ /**
+ * Injected application settings service.
+ */
+ private ApplicationSettings _applicationSettings;
+
+ /**
+ * Value of the menu property. It can be: none, create, open, study, knowledge, sysadmin, help.
*/
private String _menuProperty;
-
+
/**
- * Value of the title bar property.
- * It can be: study, knowledge.
+ * Value of the title bar property. It can be: study, knowledge.
*/
private String _titleProperty;
-
+
/**
- * Property that indicates whether the current open study is editable or not.
- * On the screen it looks like pen on the status icon, pop-up menu also can be called.
- * It is necessary for correct building the title bar.
+ * Property that indicates whether the current open study is editable or not. On the screen it looks like pen on the status icon, pop-up
+ * menu also can be called. It is necessary for correct building the title bar.
*/
private String _editDisabledProperty = "false";
-
+
/**
- * Value of the tool bar property.
- * It can be: none, standard, study, back.
+ * Value of the tool bar property. It can be: none, standard, study, back.
*/
private String _toolProperty;
-
+
/**
- * Value of the left menu property.
- * It can be: open, study, knowledge, scenario.
+ * Value of the left menu property. It can be: open, study, knowledge, scenario.
*/
private String _leftMenuProperty;
+ // ==============================================================================================================================
+ // Action execution
+ // ==============================================================================================================================
+
/**
- * Serial version ID.
+ * Initialize application.
+ * @return SUCCESS if succeeded, ERROR - if exception is caught
+ */
+ public String doInitialize() {
+ StringBuffer wappurl = _request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
+ String res = SUCCESS;
+
+ LOG.info(new StringBuffer("Initializing ").append(wappurl)
+ .append("...").toString());
+ try {
+ ProjectSettingsService project = getProjectSettings();
+ ApplicationSettings wapp = getApplicationSettings().init(
+ wappurl.toString(), this.getLocale());
+ String root = wapp.getApplicationRootPath();
+ LOG.debug("Application root: " + root);
+
+ // Database configuration
+ project.configure(root
+ + wapp.getApplicationProperty("wapp.configuration"));
+
+ // Application configuration
+ System.setProperty("java.security.auth.login.config", root
+ + wapp.getApplicationProperty("wapp.login"));
+ wapp.configure(root
+ + wapp.getApplicationProperty("wapp.customization"));
+
+ // Initialization of the user session
+ Map<String, Object> session = getSession();
+
+ session.put("user.rights", new ApplicationRights(null)); // No user connected yet
+ session.put("study.filter", wapp.getFilter(Constants.STUDY_MENU));
+ session.put("knowledge.filter", wapp
+ .getFilter(Constants.KNOWLEDGE_MENU));
+
+ setMenuProperty(Constants.NONE);
+ initializationScreenContext(_menuProperty);
+
+ } catch (Exception error) {
+ LOG.fatal("Reason:", error);
+
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
+ setEditDisabledProperty("true");
+ setToolProperty(Constants.NONE);
+ setLeftMenuProperty(Constants.STUDY_MENU);
+ initializationFullScreenContext(_menuProperty, _titleProperty,
+ _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
+ res = ERROR;
+ }
+ return res;
+ }
+
+ // ==============================================================================================================================
+ // Setter
+ // ==============================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ * @see org.splat.simer.Action#setServletRequest(javax.servlet.http.HttpServletRequest)
*/
- private static final long serialVersionUID = 5875058140682652964L;
-
-// ==============================================================================================================================
-// Action execution
-// ==============================================================================================================================
-
- public String doInitialize () throws Exception {
-// -----------------------------
-// Session connex = Database.getSession();
-// Transaction transax = connex.beginTransaction();
- StringBuffer wappurl = request.getRequestURL(); // "http://{server}:{port}/{webapp}/", including the leading '/'
-
- LOG.info( new StringBuffer("Initializing ").append(wappurl).append("...").toString() );
- try {
- ProjectSettingsService project = getProjectSettings();
- ApplicationSettings wapp = getApplicationSettings().init(wappurl.toString(), this.getLocale());
- String root = wapp.getApplicationRootPath();
- LOG.debug("Application root: " + root);
-
-// Database configuration
- project.configure(root + wapp.getApplicationProperty("wapp.configuration"));
-
-// Application configuration
- System.setProperty("java.security.auth.login.config", root + wapp.getApplicationProperty("wapp.login"));
- wapp.configure(root + wapp.getApplicationProperty("wapp.customization"));
-
-// Initialization of the user session
- Map<String, Object> session = getSession();
-
- session.put("user.rights", new ApplicationRights(null) ); // No user connected yet
- session.put("study.filter", wapp.getFilter("study"));
- session.put("knowledge.filter", wapp.getFilter("knowledge"));
-
-// transax.commit();
-
- setMenuProperty("none");
- initializationScreenContext(_menuProperty);
-
- return SUCCESS;
- }
- catch (Exception error) {
- LOG.fatal("Reason:", error);
-
- setMenuProperty("study");
- setTitleProperty("study");
- setEditDisabledProperty("true");
- setToolProperty("none");
- setLeftMenuProperty("study");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-
- return ERROR;
- }
- }
-
-// ==============================================================================================================================
-// Setter
-// ==============================================================================================================================
-
- public void setServletRequest (HttpServletRequest request) {
-// ----------------------------------------------------------
- this.request = request;
- }
- /**
- * Get project settings.
+ @Override
+ public void setServletRequest(final HttpServletRequest request) {
+ this._request = request;
+ }
+
+ /**
+ * Get project settings.
+ *
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
+ return _projectSettings;
}
/**
* Set project settings service.
- * @param projectSettingsService project settings service
+ *
+ * @param projectSettingsService
+ * project settings service
*/
public void setProjectSettings(
- ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
+ final ProjectSettingsService projectSettingsService) {
+ _projectSettings = projectSettingsService;
}
/**
* Get the applicationSettings.
+ *
* @return the applicationSettings
*/
+ @Override
public ApplicationSettings getApplicationSettings() {
- return _ApplicationSettings;
+ return _applicationSettings;
}
/**
* Set the applicationSettings.
- * @param applicationSettings the applicationSettings to set
+ *
+ * @param applicationSettings
+ * the applicationSettings to set
*/
- public void setApplicationSettings(ApplicationSettings applicationSettings) {
- _ApplicationSettings = applicationSettings;
+ @Override
+ public void setApplicationSettings(
+ final ApplicationSettings applicationSettings) {
+ _applicationSettings = applicationSettings;
}
-
+
/**
* Get the menuProperty.
+ *
* @return the menuProperty
*/
public String getMenuProperty() {
/**
* Set the menuProperty.
- * @param menuProperty the menuProperty to set
+ *
+ * @param menuProperty
+ * the menuProperty to set
*/
- public void setMenuProperty(String menuProperty) {
+ public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
-
+
/**
* Get the _titleProperty.
+ *
* @return the _titleProperty
*/
public String getTitleProperty() {
}
/**
- * Set the _titleProperty.
- * @param _titleProperty the titleProperty to set
+ * Set the titleProperty.
+ *
+ * @param titleProperty
+ * the titleProperty to set
*/
- public void setTitleProperty(String titleProperty) {
+ public void setTitleProperty(final String titleProperty) {
_titleProperty = titleProperty;
}
/**
* Get the editDisabledProperty.
+ *
* @return the editDisabledProperty
*/
public final String getEditDisabledProperty() {
/**
* Set the editDisabledProperty.
- * @param editDisabledProperty the editDisabledProperty to set
+ *
+ * @param editDisabledProperty
+ * the editDisabledProperty to set
*/
- public final void setEditDisabledProperty(String editDisabledProperty) {
+ public final void setEditDisabledProperty(final String editDisabledProperty) {
_editDisabledProperty = editDisabledProperty;
}
/**
* Get the toolProperty.
+ *
* @return the toolProperty
*/
public String getToolProperty() {
/**
* 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 org.splat.service.ProjectElementService;
import org.splat.service.ScenarioService;
import org.splat.som.Step;
+import org.splat.wapp.Constants;
import org.splat.wapp.MenuItem;
import org.splat.wapp.SlidMenu;
* Default constructor.
*/
public StudyMenu() {
- super("activities", "study");
+ super("activities", Constants.STUDY_MENU);
}
/**
* @param context the study
*/
public StudyMenu(final Study context) {
- super("activities", "study");
+ super("activities", Constants.STUDY_MENU);
_study = context;
}
*/
public String doInitialize() {
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
validation = new Vector<ValidationFacade>();
validefault = null;
other = getDocumentTypeService().selectResultTypes();
- Study study = mystudy.getStudyObject();
- StudyRights user = mystudy.getStudyRights();
+ Study study = _openStudy.getStudyObject();
+ StudyRights user = _openStudy.getStudyRights();
for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
DocumentType type = i.next();
ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
setLeftMenuProperty("open");
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
- if (mystudy.isOpenForWriting() && user.canEditProperties()) {
+ if (_openStudy.isOpenForWriting() && user.canEditProperties()) {
return "edit";
}
else {
// Session connex = Database.getCurSession();
// Transaction transax = connex.beginTransaction();
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
validation = new Vector<ValidationFacade>();
validefault = null;
other = getDocumentTypeService().selectResultTypes();
- Study study = mystudy.getStudyObject();
+ Study study = _openStudy.getStudyObject();
for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
DocumentType type = i.next();
ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
// Session connex = Database.getCurSession();
// Transaction transax = connex.beginTransaction();
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
validation = new Vector<ValidationFacade>();
validefault = null;
other = getDocumentTypeService().selectAllTypes();
- Study study = mystudy.getStudyObject();
+ Study study = _openStudy.getStudyObject();
for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
DocumentType type = i.next();
ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
// Session connex = Database.getCurSession();
// Transaction transax = connex.beginTransaction();
- mystudy = getOpenStudy();
+ _openStudy = getOpenStudy();
validation = new Vector<ValidationFacade>();
validefault = null;
other = getDocumentTypeService().selectResultTypes();
- Study study = mystudy.getStudyObject();
+ Study study = _openStudy.getStudyObject();
for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
DocumentType type = i.next();
ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
public User getAuthor() {
// ------------------------
- return mystudy.getStudyObject().getAuthor();
+ return _openStudy.getStudyObject().getAuthor();
}
public List<User> getCandidates() {
public String getStudyTitle() {
// ------------------------------
- return mystudy.getTitle();
+ return _openStudy.getTitle();
}
public List<ValidationFacade> getValidations() {
import java.util.ResourceBundle;
-import org.splat.kernel.Name;
import org.splat.dal.bo.kernel.User;
import org.splat.dal.bo.som.ValidationCycle;
import org.splat.dal.bo.som.ValidationStep;
-
+import org.splat.kernel.Name;
public class ValidationFacade {
- String myicon;
- String myname;
- Name mypublisher;
- Name myreviewer;
- Name myapprover;
-
- protected static abstract class UserOption implements Name {
-// ----------------------------------------------------------
- protected String name;
- protected long index;
-
- public long getIndex() {
- return index;
- }
- public String toString () {
- return name;
- }
- }
- protected static class NotRequired extends UserOption {
-// -----------------------------------------------------
- protected NotRequired () {
- name = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale()).getString("label.skipped");
- index = 0;
- }
- }
- protected static class ByAuthor extends UserOption {
-// --------------------------------------------------
- protected ByAuthor () {
- name = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale()).getString("label.bytheauthor");
- index = 0;
- }
- }
- protected static class ByManager extends UserOption {
-// ---------------------------------------------------
- protected ByManager (User manager) {
- name = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale()).getString("label.me");
- index = manager.getIndex();
- }
- }
-
-// ==============================================================================================================================
-// Constructors
-// ==============================================================================================================================
-
- public ValidationFacade (ValidationCycle cycle) {
-// -----------------------------------------------
- myicon = "icon.empty.png";
- if (cycle.isDefault()) {
- myname = "default";
- } else {
- if (cycle.isAssigned()) myicon = "icon.done.png";
- myname = cycle.getDocumentType().getName();
- }
- mypublisher = cycle.getActor(ValidationStep.PROMOTION);
- myreviewer = cycle.getActor(ValidationStep.REVIEW);
- myapprover = cycle.getActor(ValidationStep.APPROVAL);
- if (mypublisher == null) {
- mypublisher = new ByAuthor();
- }
- if (myreviewer == null || myapprover == null) {
- Name skipped = new NotRequired();
- if (myreviewer == null) myreviewer = skipped;
- if (myapprover == null) myapprover = skipped;
- }
+ private transient String _myicon;
+ private transient String _myname;
+ private transient Name _mypublisher;
+ private transient Name _myreviewer;
+ private transient Name _myapprover;
+
+ protected static class UserOption implements Name {
+ protected transient String _name;
+ protected transient long _index;
+
+ public long getIndex() {
+ return _index;
+ }
+
+ @Override
+ public String toString() {
+ return _name;
+ }
+ }
+
+ protected static class NotRequired extends UserOption {
+ protected NotRequired() {
+ super();
+ _name = ResourceBundle.getBundle("labels",
+ ApplicationSettings.getCurrentLocale()).getString(
+ "label.skipped");
+ _index = 0;
+ }
}
-// ==============================================================================================================================
-// Getters
-// ==============================================================================================================================
-
- public String getDocumentType () {
-// --------------------------------
- return myname;
- }
- public long getApproverIndex () {
-// ------------------------------
- return myapprover.getIndex();
- }
- public String getApproverName () {
-// --------------------------------
- return myapprover.toString();
- }
- public String getIcon () {
-// ------------------------
- return myicon;
- }
- public long getPublisherIndex () {
-// -------------------------------
- return mypublisher.getIndex();
- }
- public String getPublisherName () {
-// ---------------------------------
- return mypublisher.toString();
- }
- public long getReviewerIndex () {
-// ------------------------------
- return myreviewer.getIndex();
- }
- public String getReviewerName () {
-// --------------------------------
- return myreviewer.toString();
- }
+ protected static class ByAuthor extends UserOption {
+ protected ByAuthor() {
+ super();
+ _name = ResourceBundle.getBundle("labels",
+ ApplicationSettings.getCurrentLocale()).getString(
+ "label.bytheauthor");
+ _index = 0;
+ }
+ }
+
+ protected static class ByManager extends UserOption {
+ protected ByManager(final User manager) {
+ super();
+ _name = ResourceBundle.getBundle("labels",
+ ApplicationSettings.getCurrentLocale()).getString(
+ "label.me");
+ _index = manager.getIndex();
+ }
+ }
+
+ // ==============================================================================================================================
+ // Constructors
+ // ==============================================================================================================================
+
+ public ValidationFacade(final ValidationCycle cycle) {
+ _myicon = "icon.empty.png";
+ if (cycle.isDefault()) {
+ _myname = "default";
+ } else {
+ if (cycle.isAssigned()) {
+ _myicon = "icon.done.png";
+ }
+ _myname = cycle.getDocumentType().getName();
+ }
+ _mypublisher = cycle.getActor(ValidationStep.PROMOTION);
+ _myreviewer = cycle.getActor(ValidationStep.REVIEW);
+ _myapprover = cycle.getActor(ValidationStep.APPROVAL);
+ if (_mypublisher == null) {
+ _mypublisher = new ByAuthor();
+ }
+ if (_myreviewer == null || _myapprover == null) {
+ Name skipped = new NotRequired();
+ if (_myreviewer == null) {
+ _myreviewer = skipped;
+ }
+ if (_myapprover == null) {
+ _myapprover = skipped;
+ }
+ }
+ }
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
+
+ public String getDocumentType() {
+ return _myname;
+ }
+
+ public long getApproverIndex() {
+ return _myapprover.getIndex();
+ }
+
+ public String getApproverName() {
+ return _myapprover.toString();
+ }
+
+ public String getIcon() {
+ return _myicon;
+ }
+
+ public long getPublisherIndex() {
+ return _mypublisher.getIndex();
+ }
+
+ public String getPublisherName() {
+ return _mypublisher.toString();
+ }
+
+ public long getReviewerIndex() {
+ return _myreviewer.getIndex();
+ }
+
+ public String getReviewerName() {
+ return _myreviewer.toString();
+ }
}
\ No newline at end of file
import java.io.FileNotFoundException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
-import java.util.Vector;
-import org.splat.kernel.InvalidPropertyException;
import org.splat.dal.bo.kernel.Relation;
import org.splat.dal.bo.kernel.User;
-import org.splat.manox.Reader;
-import org.splat.manox.Toolbox;
import org.splat.dal.bo.som.Document;
import org.splat.dal.bo.som.ProgressState;
+import org.splat.dal.bo.som.Publication;
+import org.splat.dal.bo.som.UsedByRelation;
+import org.splat.dal.bo.som.UsesRelation;
+import org.splat.kernel.InvalidPropertyException;
+import org.splat.manox.Reader;
+import org.splat.manox.Toolbox;
import org.splat.service.PublicationService;
import org.splat.service.StepService;
import org.splat.service.technical.ProjectSettingsService;
import org.splat.service.technical.RepositoryService;
-import org.splat.dal.bo.som.Publication;
import org.splat.som.Revision;
import org.splat.som.Step;
-import org.splat.dal.bo.som.UsedByRelation;
-import org.splat.dal.bo.som.UsesRelation;
+import org.splat.wapp.Constants;
/**
* Action for creating a new version of a document.
/**
* Versioned document index.
*/
- private String index = null;
+ private String _index = null;
/**
* List of publications which use the selected document.
*/
- private List<Publication> usedby = null;
+ private transient List<Publication> _usedby = null;
/**
* List of selected impacted documents ids.
*/
- private long[] docusedby = null;
+ private transient long[] _docusedby = null;
/**
* Summary of changes in the new version.
*/
- private String summary = null;
+ private String _description = null;
/**
* Version number extracted from the imported file, if exist.
*/
- private String docver = "";
+ private String _version = "";
/**
* Date extracted from the imported file, if exist.
*/
- private String date = "";
+ private String _date = "";
/**
* Injected project settings service.
*/
- private ProjectSettingsService _projectSettingsService;
+ private ProjectSettingsService _projectSettings;
/**
* Injected publication service.
*/
*/
public String doInitialize() {
- setMenuProperty("study");
- setTitleProperty("study");
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
setEditDisabledProperty("true");
if ("true".equals(getWriteAccess())) {
- setToolProperty("study");
+ setToolProperty(Constants.STUDY_MENU);
} else {
- setToolProperty("none");
+ setToolProperty(Constants.NONE);
}
- setLeftMenuProperty("study");
+ setLeftMenuProperty(Constants.STUDY_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
User user = getConnectedUser();
mystudy = getOpenStudy();
Publication tag = mystudy.getSelectedStep().getDocument(
- Integer.valueOf(index));
+ Integer.valueOf(_index));
Document doc = tag.value();
deftype = doc.getType();
docname = doc.getTitle();
- defuses = new Vector<Document>();
- usedby = new Vector<Publication>();
-
- if (!extractProperties(upfile, doc)) {
- if (!("none".equals(_toolProperty))) {
- setToolProperty("none");
- setLeftMenuProperty("study");
+ defuses = new ArrayList<Document>();
+ _usedby = new ArrayList<Publication>();
+
+ String res = SUCCESS;
+ if (extractProperties(upfile, doc)) {
+ setupDefaultUses(deftype);
+ // Add additional documents used by the current version
+ List<Relation> uses = doc.getRelations(UsesRelation.class);
+ for (Iterator<Relation> i = uses.iterator(); i.hasNext();) {
+ Document used = (Document) i.next().getTo();
+ if (!defuses.contains(used)) {
+ defuses.add(used);
+ }
+ }
+ // Setup dependencies
+ _usedby.addAll(tag.getRelations(UsedByRelation.class));
+ } else {
+ if (!(Constants.NONE.equals(_toolProperty))) {
+ setToolProperty(Constants.NONE);
+ setLeftMenuProperty(Constants.STUDY_MENU);
initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
}
- return ERROR;
- }
- setupDefaultUses(deftype);
- // Add additional documents used by the current version
- List<Relation> uses = doc.getRelations(UsesRelation.class);
- for (Iterator<Relation> i = uses.iterator(); i.hasNext();) {
- Document used = (Document) i.next().getTo();
- if (!defuses.contains(used))
- defuses.add(used);
- }
- // Setup dependencies
- List<Publication> relist = tag.getRelations(UsedByRelation.class);
- for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
- usedby.add(i.next());
+ res = ERROR;
}
- return SUCCESS;
+ return res;
}
/**
* the document to version
* @return true if succeeded or if the file is not XML, otherwise return false
*/
- private boolean extractProperties(File upfile, Document doc) {
+ private boolean extractProperties(final File upfile, final Document doc) {
boolean res = true;
Reader tool = Toolbox.getReader(upfile);
if (tool != null) {
String fileref = tool.extractProperty("reference");
String filever = tool.extractProperty("version");
- if (fileref != null && !doc.getReference().equals(fileref)) {
- setErrorCode("reference.mismatch");
- res = false;
- } else {
+ if (fileref == null || doc.getReference().equals(fileref)) {
if (filever != null) {
try {
Revision.Format get = new Revision.Format(
} else {
state = ProgressState.inDRAFT;
}
- docver = newver.toString();
+ _version = newver.toString();
} catch (Exception e) {
setErrorCode("version.mismatch");
res = false;
}
}
if (res) {
- summary = tool.extractProperty("history");
- date = tool.extractProperty("date");
- if (date != null) {
+ _description = tool.extractProperty("history");
+ _date = tool.extractProperty("date");
+ if (_date == null) {
+ _date = "";
+ } else {
ResourceBundle locale = ResourceBundle.getBundle("som",
getApplicationSettings().getCurrentLocale());
SimpleDateFormat check = new SimpleDateFormat(locale
.getString("date.format"));
try {
- check.parse(date);
+ check.parse(_date);
} catch (ParseException e) {
setErrorCode("format.date");
res = false;
}
- } else {
- date = "";
}
}
+ } else {
+ setErrorCode("reference.mismatch");
+ res = false;
}
}
return res;
* @return SUCCESS - if succeeded, "cancel" - if canceled, ERROR - if failed
*/
public String doVersion() {
- setMenuProperty("study");
- setTitleProperty("study");
+ String res = ERROR;
+ setMenuProperty(Constants.STUDY_MENU);
+ setTitleProperty(Constants.STUDY_MENU);
setEditDisabledProperty("true");
initializationScreenContext(_menuProperty, _titleProperty, _editDisabledProperty);
- if (action == ToDo.cancel)
- return "cancel";
-
- try {
- // Getting user inputs
- mystudy = getOpenStudy();
- User user = getConnectedUser();
- Step step = mystudy.getSelectedStep();
- Date aDate = null;
- if (date.length() > 0) {
- ResourceBundle locale = ResourceBundle.getBundle("som",
- getApplicationSettings().getCurrentLocale());
- SimpleDateFormat get = new SimpleDateFormat(locale
- .getString("date.format"));
- aDate = get.parse(date);
+ if (action == ToDo.cancel) {
+ res = "cancel";
+ } else {
+
+ try {
+ // Getting user inputs
+ mystudy = getOpenStudy();
+ User user = getConnectedUser();
+ Step step = mystudy.getSelectedStep();
+ Date aDate = null;
+ if (_date.length() > 0) {
+ ResourceBundle locale = ResourceBundle.getBundle("som",
+ getApplicationSettings().getCurrentLocale());
+ SimpleDateFormat get = new SimpleDateFormat(locale
+ .getString("date.format"));
+ aDate = get.parse(_date);
+ }
+
+ String[] listDocuses = null;
+ if (docuses != null) {
+ listDocuses = docuses.split(",");
+ }
+ getPublicationService().versionDocument(step, user, filename,
+ Integer.valueOf(_index), _version, _description, state, aDate,
+ listDocuses, _docusedby);
+
+ // Update of the open study
+ mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
+ // TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
+
+ res = SUCCESS;
+ } catch (FileNotFoundException error) {
+ LOG.error("Reason:", error);
+ setErrorCode("import.file");
+ } catch (Exception error) {
+ LOG.error("Reason:", error);
+ setErrorCode("internal");
}
-
- String[] listDocuses = null;
- if (docuses != null) {
- listDocuses = docuses.split(",");
+ if (!SUCCESS.equals(res)) {
+ setToolProperty(Constants.NONE);
+
+ setLeftMenuProperty(Constants.STUDY_MENU);
+ initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
}
- getPublicationService().versionDocument(step, user, filename,
- Integer.valueOf(index), docver, summary, state, aDate,
- listDocuses, docusedby);
-
- // Update of the open study
- mystudy.setSelection(mystudy.getSelection()); // Rebuilds the presentation
- // TODO: Look is an optimization is possible (for example by updating the presentation of versioned document)
-
- return SUCCESS;
- } catch (FileNotFoundException error) {
- LOG.error("Reason:", error);
- setErrorCode("import.file");
- } catch (Exception error) {
- LOG.error("Reason:", error);
- setErrorCode("internal");
- }
-
- setToolProperty("none");
-
- setLeftMenuProperty("study");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-
- return ERROR;
+ }
+ return res;
}
// ==============================================================================================================================
// ==============================================================================================================================
public String getDate() {
- return date;
+ return _date;
}
public List<Publication> getDependencies() {
- return usedby;
+ return _usedby;
}
public String getDescription() {
- return summary;
+ return _description;
}
public String getIndex() {
- return index;
+ return _index;
}
public String getVersion() {
- return docver;
+ return _version;
}
- public void setDate(String date) {
- this.date = date;
+ public void setDate(final String date) {
+ this._date = date;
}
- public void setDefaultDescription(String summary) {
- if (this.summary == null)
- this.summary = summary;
+ public void setDefaultDescription(final String summary) {
+ if (this._description == null) {
+ this._description = summary;
+ }
}
- public void setDescription(String summary) {
- this.summary = summary;
+ public void setDescription(final String summary) {
+ this._description = summary;
}
- public void setIndex(String index) {
- this.index = index;
+ public void setIndex(final String index) {
+ this._index = index;
}
- public void setUsedBy(long[] list) {
- this.docusedby = list;
+ public void setUsedBy(final long[] list) {
+ this._docusedby = list;
}
- public void setVersion(String value) {
- this.docver = value;
+ public void setVersion(final String value) {
+ this._version = value;
}
/**
* @return Project settings service
*/
private ProjectSettingsService getProjectSettings() {
- return _projectSettingsService;
+ return _projectSettings;
}
/**
* @param projectSettingsService
* project settings service
*/
- public void setProjectSettings(ProjectSettingsService projectSettingsService) {
- _projectSettingsService = projectSettingsService;
+ public void setProjectSettings(final ProjectSettingsService projectSettingsService) {
+ _projectSettings = projectSettingsService;
}
/**
* @param publicationService
* the publicationService to set
*/
- public void setPublicationService(PublicationService publicationService) {
+ public void setPublicationService(final PublicationService publicationService) {
_publicationService = publicationService;
}
* @param stepService
* the stepService to set
*/
- public void setStepService(StepService stepService) {
+ public void setStepService(final StepService stepService) {
_stepService = stepService;
}
* @param repositoryService
* the repositoryService to set
*/
- public void setRepositoryService(RepositoryService repositoryService) {
+ public void setRepositoryService(final RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
* @param menuProperty
* the menuProperty to set
*/
- public void setMenuProperty(String menuProperty) {
+ public void setMenuProperty(final String menuProperty) {
this._menuProperty = menuProperty;
}
* @param titleProperty
* the titleProperty to set
*/
- public void setTitleProperty(String titleProperty) {
+ public void setTitleProperty(final String titleProperty) {
_titleProperty = titleProperty;
}
}
/**
- * Set the _editDisabledProperty.
+ * Set the editDisabledProperty.
*
- * @param _editDisabledProperty
- * the _editDisabledProperty to set
+ * @param editDisabledProperty
+ * the editDisabledProperty to set
*/
- public void setEditDisabledProperty(String _editDisabledProperty) {
- this._editDisabledProperty = _editDisabledProperty;
+ public void setEditDisabledProperty(final String editDisabledProperty) {
+ this._editDisabledProperty = editDisabledProperty;
}
/**
--- /dev/null
+/*****************************************************************************
+ * Company OPEN CASCADE
+ * Application SIMAN
+ * File $Id$
+ * Creation date 08.11.2012
+ * @author $Author$
+ * @version $Revision$
+ * @copyright OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.wapp;
+
+/**
+ * SIMAN constants.
+ */
+public class Constants {
+ public final static String STANDARD_MENU = "standard";
+ public final static String STUDY_MENU = "study";
+ public final static String KNOWLEDGE_MENU = "knowledge";
+ public final static String NONE = "none";
+ public final static String TRUE = "true";
+ public final static String PROP_SCENARIO = "prop-scenario";
+}
scope="session" parent="slidMenu" />
<bean id="openObject" abstract="true"
- class="org.splat.simer.OpenObject" scope="session">
+ class="org.splat.simer.AbstractOpenObject" scope="session">
<property name="applicationSettings" ref="applicationSettings" />
<property name="projectElementService"
ref="projectElementService" />