/**
* Current open study step cache for presented documents.
*/
- protected Map<Long, DocumentFacade> docpres = null;
+ protected transient Map<Long, DocumentFacade> _docpres = null;
/**
* Current open study step cache for presented knowledges.
*/
- protected Map<Long, KnowledgeElementFacade> knowpres = null;
+ protected transient Map<Long, KnowledgeElementFacade> _knowpres = null;
/**
* Connected user.
protected AbstractOpenObject() {
// All member fields are supposed initialized by subclasses
- if (docpres == null) {
- docpres = new HashMap<Long, DocumentFacade>();
+ if (_docpres == null) {
+ _docpres = new HashMap<Long, DocumentFacade>();
}
- if (knowpres == null) {
- knowpres = new HashMap<Long, KnowledgeElementFacade>();
+ if (_knowpres == null) {
+ _knowpres = new HashMap<Long, KnowledgeElementFacade>();
}
}
}
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
+ _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<KnowledgeElementFacade> display = new ArrayList<KnowledgeElementFacade>(
kelms.size());
while (current != null && current.getType().equals(type)) {
- KnowledgeElementFacade facade = knowpres.get(current
+ KnowledgeElementFacade facade = _knowpres.get(current
.getIndex());
if (facade == null) {
facade = new KnowledgeElementFacade(BeanHelper
.copyBean(current, KnowledgeElementDTO.class),
getApplicationSettings());
- knowpres.put(current.getIndex(), facade);
+ _knowpres.put(current.getIndex(), facade);
}
display.add(facade);
if (more.hasNext()) {
for (Iterator<Publication> i = list.iterator(); i.hasNext();) {
Publication present = i.next();
Long index = present.getIndex();
- DocumentFacade facade = docpres.get(index);
+ DocumentFacade facade = _docpres.get(index);
if (facade == null) {
facade = new DocumentFacade(this, present,
getProjectSettings(), getPublicationService(),
getApplicationSettings());
- docpres.put(index, facade);
+ _docpres.put(index, facade);
}
_contents.add(facade);
}
} else if (_cvalue != null && Integer.valueOf(_cvalue) > 0) {
action = UserAction.selectContextValue;
} else if (_cindex.length() > 0) {
- int index = Integer.valueOf(_cindex);
+ long index = Long.valueOf(_cindex);
if (index > 0) {
action = UserAction.removeContext;
} else if (index < 0) {
Integer.valueOf(_ctype));
_newvalue = getSimulationContextService()
.selectSimulationContextsWhere(sprop.setType(_newtype));
- if (_cindex.length() > 0 && Integer.valueOf(_cindex) == 0) {
+ if (_cindex.length() > 0 && Long.valueOf(_cindex) == 0) {
getSession().remove(RESULT_KEY);
} else {
// We keep the previous result search, if valid
* @return "refresh"
*/
protected String doRemoveContext() {
- int index = Integer.valueOf(_cindex);
+ long index = Long.valueOf(_cindex);
for (Iterator<SimulationContext> selected = _context.iterator(); selected
.hasNext();) {
if (selected.next().getIndex() == index) {
// Setters
// ==============================================================================================================================
+ /**
+ * Set author id to search.
+ *
+ * @param index
+ * persistent user id
+ */
public void setAuthor(final String index) {
this._author = index;
}
+ /**
+ * Set applied simulation context type id to search.
+ *
+ * @param type
+ * persistent simulation context type id
+ */
public void setContextType(final String type) {
this._ctype = type;
}
+ /**
+ * Set value of simulation context to search.
+ *
+ * @param value
+ * the simulation context value
+ */
public void setContextValue(final String value) {
this._cvalue = value;
}
+ /**
+ * Set simulation context value id.
+ *
+ * @param value
+ * the persistent id as string
+ */
public void setContextIndex(final String value) {
this._cindex = value;
}
* Mark as reference menu item name.
*/
private static final String MNU_MARK_AS_REFERENCE = "markasreference";
- /**
- * Remove as reference menu item name.
- */
- private static final String MNU_REMOVE_AS_REFERENCE = "removeasreference";
/**
* Mark as reference menu item label key.
*/
_state = _my.getProgressState();
_display = State.closed;
- refresh(); // Initializes the presentation of my document
+ refresh(); // Initializes the presentation of my document //NOPMD:RKV: to be reviewed
}
/**
for (Iterator<Publication> i = relist.iterator(); i.hasNext();) {
Publication used = i.next();
long index = used.getIndex();
- DocumentFacade facade = _owner.docpres.get(index);
+ DocumentFacade facade = _owner._docpres.get(index);
if (facade == null) {
facade = new DocumentFacade(_owner, used,
getProjectSettings(), getPublicationService(),
getApplicationSettings());
- _owner.docpres.put(index, facade);
+ _owner._docpres.put(index, facade);
}
_uses.add(facade);
}
_version = _my.getVersion(); // May be null
initIcons();
-
+
// Document description
VersionsRelation versions = (VersionsRelation) _my
.getFirstRelation(VersionsRelation.class);
import org.splat.dal.bo.som.ConvertsRelation;
+/**
+ * File representation class.
+ */
public class FileFacade {
- private String surl; // URL of the file
- private final String format; // Extension of the file
- private String comment; // Short description
- private final String size;
- private final String date;
+ private transient String _surl; // URL of the file
+ private transient final String _format; // Extension of the file
+ private transient String _comment; // Short description
+ private transient final String _size;
+ private transient final String _date;
// ==============================================================================================================================
// Constructor
DecimalFormat tostring = new DecimalFormat(custom
.getString("size.format")); // Locale size display format
SimpleDateFormat convert = new SimpleDateFormat(custom
- .getString("date.format")); // Date display format
+ .getString("date.format"), applicationSettings
+ .getCurrentLocale()); // Date display format
- surl = applicationSettings.getRepositoryURL() + path;
- surl = surl.replaceAll("'", "\\\\'");
- format = table[table.length - 1].toUpperCase();
- size = tostring.format(export.length() / 1000);
- date = convert.format(represented.getTo().getDate());
- comment = represented.getDescription();
- if (comment == null) {
- comment = "";
+ _surl = applicationSettings.getRepositoryURL() + path;
+ _surl = _surl.replaceAll("'", "\\\\'");
+ _format = table[table.length - 1].toUpperCase();
+ _size = tostring.format(export.length() / 1000);
+ _date = convert.format(represented.getTo().getDate());
+ _comment = represented.getDescription();
+ if (_comment == null) {
+ _comment = "";
}
}
// ==============================================================================================================================
public String getDate() {
- return date;
+ return _date;
}
public String getDescription() {
- return comment;
+ return _comment;
}
public String getFormat() {
- return format;
+ return _format;
}
public String getSize() {
- return size;
+ return _size;
}
public String getURL() {
- return surl;
+ return _surl;
}
}
\ No newline at end of file
* @param applicationSettings
* the applicationSettings to set
*/
- public void setApplicationSettings(
+ private void setApplicationSettings(
final ApplicationSettings applicationSettings) {
_applicationSettings = applicationSettings;
}
package org.splat.simer;
+import java.util.ArrayList;
import java.util.Iterator;
-import java.util.Vector;
+import java.util.List;
import org.splat.dal.bo.som.Scenario;
+import org.splat.dal.bo.som.Study;
import org.splat.service.ProjectElementService;
import org.splat.service.ScenarioService;
import org.splat.som.Step;
-import org.splat.dal.bo.som.Study;
+import org.splat.wapp.Constants;
import org.splat.wapp.MenuItem;
import org.splat.wapp.SlidMenu;
public class NewScenarioMenu extends SlidMenu {
- private Study study;
- private Scenario scopen; // Currently "open" scenario
- private Step stopen; // Currently selected step
+ /**
+ * Currently "open" study.
+ */
+ private transient Study _study;
+ /**
+ * Currently "open" scenario.
+ */
+ private transient Scenario _scopen;
+ /**
+ * Currently selected step.
+ */
+ private transient Step _stopen;
+ /**
+ * Injected project element service.
+ */
private ProjectElementService _projectElementService;
+ /**
+ * Injected scenario service.
+ */
private ScenarioService _scenarioService;
// ==============================================================================================================================
public NewScenarioMenu() {
super("scenarii", "study");
- scopen = null;
+ _scopen = null;
}
- public NewScenarioMenu init(Study context) {
- study = context;
- scopen = null;
+ public NewScenarioMenu init(final Study context) {
+ _study = context;
+ _scopen = null;
init();
return this;
}
- public NewScenarioMenu(Study context) {
- // -----------------------------------
+ public NewScenarioMenu(final Study context) {
super("scenarii", "study");
- study = context;
- scopen = null;
+ _study = context;
+ _scopen = null;
}
// ==============================================================================================================================
// Member functions
// ==============================================================================================================================
- public void selects(String name) {
- // ---------------------------------
+ @Override
+ public void selects(final String name) {
String[] parse = name.split("\\x2E");
- Scenario[] scenes = study.getScenarii();
- Scenario scenew = scopen;
+ Scenario[] scenes = _study.getScenarii();
+ Scenario scenew = _scopen;
int askid = 0;
// Initialization
- if (scenew == null && scenes.length == 1)
+ if (scenew == null && scenes.length == 1) {
scenew = scenes[0];
+ }
try {
int askdex = Integer.valueOf(parse[0]);
if (askdex > 0) {
while (askid < scenes.length) {
- if (scenes[askid].getIndex() == askdex)
+ if (scenes[askid].getIndex() == askdex) {
break;
+ }
askid += 1;
}
scenew = scenes[askid]; // Throws an exception if the scenario does not exist (that is, if name is not correct)
// Study with several scenarii, non of them open
// Collection of steps to be displayed
- Vector<Step> steps = new Vector<Step>();
+ List<Step> steps = new ArrayList<Step>();
Step[] newstep = getProjectElementService().getSteps(scenes[0]); // All scenarii have the same steps
- for (int i = 0; i < scenes.length; i++)
+ for (int i = 0; i < scenes.length; i++) {
steps.add(getProjectElementService().getFirstStep(scenes[i]));
- newstep = getProjectElementService().getSteps(study);
- stopen = newstep[0]; // Default selected step
+ }
+ newstep = getProjectElementService().getSteps(_study);
+ _stopen = newstep[0]; // Default selected step
// Creation of the menu
for (Iterator<Step> i = steps.iterator(); i.hasNext();) {
long index = group.getIndex();
String value = index + "." + number;
String icon;
- if (getScenarioService().isEmpty(group))
- icon = "icon.empty.png";
- // else if (group.isFinished()) icon = "icon.checked.png";
- else
- icon = "icon.done.png";
- addGroup(value, group.getTitle(), icon,
- "select-step?selection=" + value + "&title=%{title}");
+ if (getScenarioService().isEmpty(group)) {
+ icon = Constants.IMG_EMPTY;
+ // else if (group.isFinished()) icon = Constants.IMG_CHECKED;
+ } else {
+ icon = Constants.IMG_DONE;
+ }
+ addGroup(value, group.getTitle(), icon, getSelectStepUrl(value));
}
- } else if (scopen == null || !scenew.equals(scopen)) {
+ } else if (_scopen == null || !scenew.equals(_scopen)) {
// Opening a scenario
this.clear();
// Collection of steps to be displayed
- Vector<Step> steps = new Vector<Step>();
+ List<Step> steps = new ArrayList<Step>();
Step[] newstep = getProjectElementService().getSteps(scenew);
for (int i = 0; i < newstep.length; i++) {
steps.add(newstep[i]);
}
- for (int i = askid - 1; i > -1; i--)
- steps.add(0, getProjectElementService().getFirstStep(scenes[i]));
- newstep = getProjectElementService().getSteps(study);
- for (int i = askid + 1; i < scenes.length; i++)
+ for (int i = askid - 1; i > -1; i--) {
+ steps
+ .add(0, getProjectElementService().getFirstStep(
+ scenes[i]));
+ }
+ newstep = getProjectElementService().getSteps(_study);
+ for (int i = askid + 1; i < scenes.length; i++) {
steps.add(getProjectElementService().getFirstStep(scenes[i]));
+ }
// Creation of the menu
boolean first = true; // For differentiating the first scenario step
Step step = i.next();
int number = step.getNumber();
String icon;
- if (!step.isStarted())
- icon = "icon.empty.png";
- else if (step.isFinished())
- icon = "icon.checked.png";
- else
- icon = "icon.done.png";
- if (number == askdex)
- stopen = step;
+ if (step.isStarted()) {
+ if (step.isFinished()) {
+ icon = Constants.IMG_CHECKED;
+ } else {
+ icon = Constants.IMG_DONE;
+ }
+ } else {
+ icon = Constants.IMG_EMPTY;
+ }
+ if (number == askdex) {
+ _stopen = step;
+ }
Scenario group = (Scenario) step.getOwner();
long index = group.getIndex();
String value = index + "." + number;
- if (index != scenew.getIndex()) {
- if (getScenarioService().isEmpty(group))
- icon = "icon.empty.png";
- // else if (group.isFinished()) icon = "icon.checked.png";
- else
- icon = "icon.done.png";
- addGroup(value, group.getTitle(), icon,
- "select-step?selection=" + value
- + "&title=%{title}");
- } else if (first) {
- addGroup(value, scenew.getTitle(), icon,
- "select-step?selection=" + value
- + "&title=%{title}");
- first = false;
+ if (index == scenew.getIndex()) {
+ if (first) {
+ addGroup(value, scenew.getTitle(), icon,
+ getSelectStepUrl(value));
+ first = false;
+ } else {
+ addSubItem(value, "menu.step." + number, icon,
+ getSelectStepUrl(value));
+ }
} else {
- addSubItem(value, "menu.step." + number, icon,
- "select-step?selection=" + value
- + "&title=%{title}");
+ if (getScenarioService().isEmpty(group)) {
+ icon = Constants.IMG_EMPTY;
+ // else if (group.isFinished()) icon = Constants.IMG_CHECKED;
+ } else {
+ icon = Constants.IMG_DONE;
+ }
+ addGroup(value, group.getTitle(), icon,
+ getSelectStepUrl(value));
}
}
- scopen = scenew;
+ _scopen = scenew;
}
super.selects(name);
}
+ /**
+ * Build URL for selecting a study step.
+ *
+ * @param value
+ * selection
+ * @return URL relative to the web application context, i.e. the part after http://host/siman/
+ */
+ private String getSelectStepUrl(final String value) {
+ return "select-step?selection=" + value + "&title=%{title}";
+ }
+
+ /**
+ * Refresh the icon of the selected menu item.
+ */
public void refreshSelectedItem() {
- // ----------------------------------
MenuItem item = this.getSelectedItem();
String icon;
- if (!stopen.isStarted())
- icon = "icon.empty.png";
- else if (stopen.isFinished())
- icon = "icon.checked.png";
- else
- icon = "icon.done.png";
+ if (_stopen.isStarted()) {
+ if (_stopen.isFinished()) {
+ icon = Constants.IMG_CHECKED;
+ } else {
+ icon = Constants.IMG_DONE;
+ }
+ } else {
+ icon = Constants.IMG_EMPTY;
+ }
item.icon(icon);
}
* @param scenarioService
* the scenarioService to set
*/
- public void setScenarioService(ScenarioService scenarioService) {
+ public void setScenarioService(final ScenarioService scenarioService) {
_scenarioService = scenarioService;
}
* the projectElementService to set
*/
public void setProjectElementService(
- ProjectElementService projectElementService) {
+ final ProjectElementService projectElementService) {
_projectElementService = projectElementService;
}
}
\ No newline at end of file
import org.splat.dal.bo.som.SimulationContext;
import org.splat.service.dto.KnowledgeElementDTO;
import org.splat.som.Step;
+import org.splat.wapp.Constants;
import org.splat.wapp.SimpleMenu;
/**
j = i + 1; // Steps are numbered from 1 to N
}
if (step.isStarted()) {
- icon = "icon.done.png";
+ icon = Constants.IMG_DONE;
} else {
- icon = "icon.empty.png";
+ icon = Constants.IMG_EMPTY;
}
addItem(String.valueOf(number), "folder.step." + number, icon,
"step-knowledge?selection=" + number);
ResourceBundle custom = ResourceBundle.getBundle("som",
getApplicationSettings().getCurrentLocale());
SimpleDateFormat convert = new SimpleDateFormat(custom
- .getString("date.format"));
+ .getString("date.format"), getApplicationSettings()
+ .getCurrentLocale());
StringBuffer value = new StringBuffer(knelm.getValue());
String sceneTitle = knelm.getScenarioTitle();
String studyTitle = knelm.getStudyTitle();
}
public String getType() {
- /*RKV: return ResourceBundle.getBundle("som",
- getApplicationSettings().getCurrentLocale()).getString(
- "type.knowledge." + _myknelm.getType().getName());*/
+ /*
+ * RKV: return ResourceBundle.getBundle("som", getApplicationSettings().getCurrentLocale()).getString( "type.knowledge." +
+ * _myknelm.getType().getName());
+ */
return "knowledge";
}
import org.splat.som.StepRights;
import org.splat.som.StudyRights;
import org.splat.util.BeanHelper;
+import org.splat.wapp.Constants;
import org.splat.wapp.ToolBar;
/**
ResourceBundle custom = ResourceBundle.getBundle("som",
getApplicationSettings().getCurrentLocale());
SimpleDateFormat datstring = new SimpleDateFormat(custom
- .getString("date.format"));
+ .getString("date.format"), getApplicationSettings()
+ .getCurrentLocale());
Revision.Format verstring = new Revision.Format(getProjectSettings()
.getRevisionPattern());
// if (state == ProgressState.inCHECK) popup = getApplicationSettings().getPopupMenu("stapprovable");
// else if (state == ProgressState.APPROVED) popup = getApplicationSettings().getPopupMenu("stapproved");
/* else */
-
+
if (_mystudy.getProgressState() == ProgressState.TEMPLATE) {
if (_mystudy.isPublic()) {
_popup = getApplicationSettings().getPopupMenu(
- "steditableunmarkprivate");
+ "steditableunmarkprivate");
} else {
_popup = getApplicationSettings().getPopupMenu(
"steditableunmarkpublic");
}
} else {
-
+
if (_mystudy.isPublic()) {
_popup = getApplicationSettings().getPopupMenu(
- "steditablemarkprivate");
+ "steditablemarkprivate");
} else {
_popup = getApplicationSettings().getPopupMenu(
"steditablemarkpublic");
}
}
- _popup.setContext("study", new StudyRights(_cuser, _mystudy));
+ _popup.setContext(Constants.STUDY_MENU, new StudyRights(_cuser,
+ _mystudy));
}
_urightstudy = new StudyRights(_cuser, _mystudy);
_urightstep = new StepRights(_cuser, _ustep);
/*
* RKV: return ResourceBundle.getBundle("labels", getApplicationSettings().getCurrentLocale()).getString( "label.study");
*/
- return "study";
+ return Constants.STUDY_MENU;
}
public String getVersion() {
ResourceBundle locale = ResourceBundle.getBundle("som",
getApplicationSettings().getCurrentLocale());
SimpleDateFormat get = new SimpleDateFormat(locale
- .getString("date.format"));
+ .getString("date.format"), getApplicationSettings()
+ .getCurrentLocale());
Writer tool = Toolbox.getWriter(credoc);
List<Step> slist = getInvolvedSteps();
for (Iterator<Step> i = slist.iterator(); i.hasNext();) {
}
}
tool.updateProperty("reference", medoc.getReference());
- tool.updateProperty("study", _mystudy.getTitle());
+ tool.updateProperty(Constants.STUDY_MENU, _mystudy.getTitle());
tool.updateProperty("step", locale.getString(
"folder.step." + step.getNumber()).replaceAll("''", "'"));
tool.updateProperty("author", author.getUsername().toUpperCase());
getApplicationSettings());
boolean first = (_contents.size() == 0);
- docpres.put(doc.getIndex(), facade);
+ _docpres.put(doc.getIndex(), facade);
_contents.add(0, facade); // Prepend the new publication
if (first) {
this.getMenu().refreshSelectedItem();
}
}
if (known != null) { // RKV:End
- knowpres.put(kelm.getIndex(), facade);
+ _knowpres.put(kelm.getIndex(), facade);
known._list.add(facade); // Insert the new knowledge at the end of the corresponding knowledge type
}
}
_cuser = user;
_popup = null;
if (getStudyService().isStaffedBy(_mystudy, _cuser)) {
- _popup = getApplicationSettings().getPopupMenu("steditablemarkpublic");
- _popup.setContext("study", new StudyRights(_cuser, _mystudy));
+ _popup = getApplicationSettings().getPopupMenu(
+ "steditablemarkpublic");
+ _popup.setContext(Constants.STUDY_MENU, new StudyRights(_cuser,
+ _mystudy));
}
// ustep = getProjectElementService().getFirstStep(mystudy);
if (_ustep != null) {
}
}
if (known != null) { // RKV:End
- knowpres.remove(kelm.getIndex());
+ _knowpres.remove(kelm.getIndex());
for (Iterator<KnowledgeElementFacade> i = known._list.iterator(); i
.hasNext();) {
KnowledgeElementFacade facade = i.next();
}
protected void update(final Publication doc) {
- DocumentFacade facade = docpres.get(doc.getIndex());
+ DocumentFacade facade = _docpres.get(doc.getIndex());
if (facade != null) {
facade.refresh();
}
}
protected void update(final KnowledgeElementDTO kelm) {
- KnowledgeElementFacade facade = knowpres.get(kelm.getIndex());
+ KnowledgeElementFacade facade = _knowpres.get(kelm.getIndex());
if (facade != null) {
facade.refresh(kelm);
}
ResourceBundle labels = ResourceBundle.getBundle("labels", locale);
ResourceBundle custom = ResourceBundle.getBundle("som", locale);
SimpleDateFormat convert = new SimpleDateFormat(custom
- .getString("date.format")); // Date display format
+ .getString("date.format"), locale); // Date display format
ValidationStep type = stamp.getType();
_nonicon = "image.hold.gif";
*/
public class StudyMenu extends SlidMenu {
- /**
- * Empty element icon.
- */
- private static final String IMG_EMPTY = "icon.empty.png";
- /**
- * Checked element icon.
- */
- private static final String IMG_CHECKED = "icon.checked.png";
- /**
- * Finished element icon.
- */
- private static final String IMG_DONE = "icon.done.png";
- /**
- * Checked out element icon.
- */
- private static final String IMG_CHECKEDOUT = "icon.checkedout.png";
/**
* Selection URL.
*/
if (index == scenew.getIndex()) {
if (first) {
if (group.isCheckedout()) {
- icon = IMG_CHECKEDOUT;
+ icon = Constants.IMG_CHECKEDOUT;
}
addGroup(value, scenew.getTitle(), icon, SELECTION_URL
+ value);
private void addItemsGroup(final Scenario group, final String value) {
String icon;
if (group.isCheckedout()) {
- icon = IMG_CHECKEDOUT;
+ icon = Constants.IMG_CHECKEDOUT;
} else if (getScenarioService().isEmpty(group)) {
- icon = IMG_EMPTY;
+ icon = Constants.IMG_EMPTY;
// else if (group.isFinished()) icon = IMG_CHECKED;
} else {
- icon = IMG_DONE;
+ icon = Constants.IMG_DONE;
}
addGroup(value, group.getTitle(), icon, SELECTION_URL + value);
}
String icon;
if (step.isStarted()) {
if (step.isFinished()) {
- icon = IMG_CHECKED;
+ icon = Constants.IMG_CHECKED;
} else {
- icon = IMG_DONE;
+ icon = Constants.IMG_DONE;
}
} else {
- icon = IMG_EMPTY;
+ icon = Constants.IMG_EMPTY;
}
return icon;
}
String icon;
if (owner instanceof Scenario) {
if (range == 0 && ((Scenario) owner).isCheckedout()) {
- icon = IMG_CHECKEDOUT;
+ icon = Constants.IMG_CHECKEDOUT;
}
range += 1;
}
* Left menu property "open".
*/
public final static String OPEN = "open";
+ /**
+ * Empty element icon.
+ */
+ public static final String IMG_EMPTY = "icon.empty.png";
+ /**
+ * Checked element icon.
+ */
+ public static final String IMG_CHECKED = "icon.checked.png";
+ /**
+ * Finished element icon.
+ */
+ public static final String IMG_DONE = "icon.done.png";
+ /**
+ * Checked out element icon.
+ */
+ public static final String IMG_CHECKEDOUT = "icon.checkedout.png";
}