package org.splat.simer;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.Study;
+import org.splat.dal.bo.som.ValidationCycle;
+import org.splat.dal.bo.som.ValidationStep;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.Name;
-import org.splat.dal.bo.kernel.User;
import org.splat.service.DocumentTypeService;
-import org.splat.service.StudyService;
import org.splat.service.UserService;
import org.splat.som.ApplicationRights;
-import org.splat.dal.bo.som.DocumentType;
-import org.splat.dal.bo.som.Study;
import org.splat.som.StudyRights;
-import org.splat.dal.bo.som.ValidationCycle;
-import org.splat.dal.bo.som.ValidationStep;
+import org.splat.wapp.Constants;
/**
* Edit/display study properties (study configuration) screen action.
private static final long serialVersionUID = 4210696018741092900L;
// Presentation fields
- private List<User> staff;
- private List<User> member;
- private List<Name> validor;
- private List<ValidationFacade> validation;
- private ValidationFacade validefault;
- private List<DocumentType> other;
+ private transient List<User> _staff;
+ private transient List<User> _member;
+ private transient List<Name> _validor;
+ private transient List<ValidationFacade> _validation;
+ private transient ValidationFacade _validefault;
+ private transient List<DocumentType> _other;
// User input fields
- private Save tosave; // Edition action (title, contributors or cycle)
- private String edicycle;
- private String stitle; // Title of the study
- private String contributors; // List of existing contributors, some of them may have been removed
- private String candidates; // List of added contributors
- private long type; // Type of document to be included in the validation process
- private int publisher;
- private int reviewer;
- private int approver;
-
/**
- * Injected study service.
+ * Edition action (title, contributors or cycle).
*/
- private StudyService _studyService;
+ private transient Save _tosave;
+ private transient String _edicycle;
/**
- * Injected document type service.
+ * Title of the study.
*/
- private DocumentTypeService _documentTypeService;
-
+ private transient String _stitle;
/**
- * Injected user service.
+ * List of existing contributors, some of them may have been removed.
*/
- private UserService _userService;
-
+ private transient String _contributors;
/**
- * Value of the menu property.
- * It can be: none, create, open, study, knowledge, sysadmin, help.
+ * List of added contributors.
*/
- private String _menuProperty;
-
+ private transient String _candidates;
/**
- * Value of the title bar property.
- * It can be: study, knowledge.
+ * Type of document to be included in the validation process.
*/
- private String _titleProperty;
-
- /**
- * Value of the tool bar property.
- * It can be: none, standard, study, back.
- */
- private String _toolProperty;
-
+ private transient long _type;
+ private transient int _publisher;
+ private transient int _reviewer;
+ private transient int _approver;
+
/**
- * Value of the left menu property.
- * It can be: open, study, knowledge, scenario.
+ * Injected document type service.
*/
- private String _leftMenuProperty;
-
+ private DocumentTypeService _documentTypeService;
+
/**
- * 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.
+ * Injected user service.
*/
- private String _editDisabledProperty = "false";
+ private UserService _userService;
/**
* Save operation type enumeration pointing which section of properties has been edited.
*/
public String doInitialize() {
+ String res;
_openStudy = getOpenStudy();
- validation = new Vector<ValidationFacade>();
- validefault = null;
- other = getDocumentTypeService().selectResultTypes();
+ _validation = new ArrayList<ValidationFacade>();
+ _validefault = null;
+ _other = getDocumentTypeService().selectResultTypes();
Study study = _openStudy.getStudyObject();
StudyRights user = _openStudy.getStudyRights();
- for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
+ for (Iterator<DocumentType> i = _other.iterator(); i.hasNext();) {
DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ study, type);
if (cycle.isDefault()) {
- validefault = new ValidationFacade(cycle);
+ _validefault = new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale());
continue;
}
- validation.add(new ValidationFacade(cycle));
+ _validation.add(new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale()));
i.remove();
}
- if (validefault != null)
- validation.add(validefault); // In order to be at the end
- member = getStudyService().getContributors(study);
- staff = null;
- validor = null;
-
- setMenuProperty("study");
- setTitleProperty("study");
- setEditDisabledProperty("true");
- setToolProperty("back");
- setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
-
- if (_openStudy.isOpenForWriting() && user.canEditProperties()) {
- return "edit";
+ if (_validefault != null) {
+ _validation.add(_validefault); // In order to be at the end
}
- else {
- return "display";
+ _member = getStudyService().getContributors(study);
+ _staff = null;
+ _validor = null;
+
+ initializationFullScreenContext(Constants.STUDY_MENU,
+ Constants.STUDY_MENU, Constants.TRUE, Constants.BACK,
+ Constants.OPEN);
+
+ if (_openStudy.isOpenForWriting() && user.canEditProperties()) {
+ res = "edit";
+ } else {
+ res = "display";
}
+ return res;
}
public String doEditTitle() {
-// Session connex = Database.getCurSession();
-// Transaction transax = connex.beginTransaction();
_openStudy = getOpenStudy();
- validation = new Vector<ValidationFacade>();
- validefault = null;
- other = getDocumentTypeService().selectResultTypes();
+ _validation = new ArrayList<ValidationFacade>();
+ _validefault = null;
+ _other = getDocumentTypeService().selectResultTypes();
Study study = _openStudy.getStudyObject();
- for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
+ for (Iterator<DocumentType> i = _other.iterator(); i.hasNext();) {
DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ study, type);
if (cycle.isDefault()) {
- validefault = new ValidationFacade(cycle);
+ _validefault = new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale());
continue;
}
- validation.add(new ValidationFacade(cycle));
+ _validation.add(new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale()));
+ }
+ if (_validefault != null) {
+ _validation.add(_validefault); // In order to be at the end
}
- if (validefault != null)
- validation.add(validefault); // In order to be at the end
- member = getStudyService().getContributors(study);
- staff = null;
- validor = null;
- other = null;
-
-// transax.commit();
-
- setMenuProperty("study");
- setTitleProperty("study");
- setEditDisabledProperty("true");
- setToolProperty("back");
- setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+ _member = getStudyService().getContributors(study);
+ _staff = null;
+ _validor = null;
+ _other = null;
+
+ initializationFullScreenContext(Constants.STUDY_MENU,
+ Constants.STUDY_MENU, Constants.TRUE, Constants.BACK,
+ Constants.OPEN);
setActionType("edititle");
return SUCCESS;
}
public String doEditContributors() {
-// Session connex = Database.getCurSession();
-// Transaction transax = connex.beginTransaction();
_openStudy = getOpenStudy();
- validation = new Vector<ValidationFacade>();
- validefault = null;
- other = getDocumentTypeService().selectAllTypes();
+ _validation = new ArrayList<ValidationFacade>();
+ _validefault = null;
+ _other = getDocumentTypeService().selectAllTypes();
Study study = _openStudy.getStudyObject();
- for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
+ for (Iterator<DocumentType> i = _other.iterator(); i.hasNext();) {
DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ study, type);
if (cycle.isDefault()) {
- validefault = new ValidationFacade(cycle);
+ _validefault = new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale());
continue;
}
- validation.add(new ValidationFacade(cycle));
+ _validation.add(new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale()));
}
- if (validefault != null)
- validation.add(validefault); // In order to be at the end
- member = getStudyService().getContributors(study);
- staff = getUserService().selectAllUsers();
- validor = null;
- other = null;
+ if (_validefault != null) {
+ _validation.add(_validefault); // In order to be at the end
+ }
+ _member = getStudyService().getContributors(study);
+ _staff = getUserService().selectAllUsers();
+ _validor = null;
+ _other = null;
User me = this.getConnectedUser();
- for (Iterator<User> i = staff.iterator(); i.hasNext();) {
+ for (Iterator<User> i = _staff.iterator(); i.hasNext();) {
User next = i.next();
ApplicationRights he = new ApplicationRights(next);
- if (next.equals(me) || member.contains(next)
- || !he.canContributeToStudy())
+ if (next.equals(me) || _member.contains(next)
+ || !he.canContributeToStudy()) {
i.remove();
+ }
}
-// transax.commit();
-
- setMenuProperty("study");
- setTitleProperty("study");
- setEditDisabledProperty("true");
- setToolProperty("back");
- setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
+ initializationFullScreenContext(Constants.STUDY_MENU,
+ Constants.STUDY_MENU, Constants.TRUE, Constants.BACK,
+ Constants.OPEN);
setActionType("edibutor");
return SUCCESS;
}
public String doEditCycle() {
-// Session connex = Database.getCurSession();
-// Transaction transax = connex.beginTransaction();
_openStudy = getOpenStudy();
- validation = new Vector<ValidationFacade>();
- validefault = null;
- other = getDocumentTypeService().selectResultTypes();
+ _validation = new ArrayList<ValidationFacade>();
+ _validefault = null;
+ _other = getDocumentTypeService().selectResultTypes();
Study study = _openStudy.getStudyObject();
- for (Iterator<DocumentType> i = other.iterator(); i.hasNext();) {
+ for (Iterator<DocumentType> i = _other.iterator(); i.hasNext();) {
DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(study, type);
+ ValidationCycle cycle = getStudyService().getValidationCycleOf(
+ study, type);
if (cycle.isDefault()) {
- validefault = new ValidationFacade(cycle);
+ _validefault = new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale());
continue;
}
- if (type.getName().equals(edicycle)) {
- this.type = type.getIndex();
+ if (type.getName().equals(_edicycle)) {
+ this._type = type.getIndex();
}
- validation.add(new ValidationFacade(cycle));
+ _validation.add(new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale()));
i.remove();
}
- if (validefault != null)
- validation.add(validefault); // In order to be at the end
- member = getStudyService().getContributors(study);
- validor = new Vector<Name>();
- staff = null;
+ if (_validefault != null) {
+ _validation.add(_validefault); // In order to be at the end
+ }
+ _member = getStudyService().getContributors(study);
+ _validor = new ArrayList<Name>();
+ _staff = null;
List<User> user = getUserService().selectAllUsers();
for (Iterator<User> i = user.iterator(); i.hasNext();) {
User next = i.next();
ApplicationRights he = new ApplicationRights(next);
if (he.canValidate()) {
- if (next.equals(study.getAuthor()))
- validor.add(new ValidationFacade.ByManager(next));
- else
- validor.add(next);
+ if (next.equals(study.getAuthor())) {
+ _validor.add(new ValidationFacade.ByManager(next,
+ getApplicationSettings().getCurrentLocale()));
+ } else {
+ _validor.add(next);
+ }
}
}
-// transax.commit();
-
- setMenuProperty("study");
- setTitleProperty("study");
- setEditDisabledProperty("true");
- setToolProperty("back");
- setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
+ initializationFullScreenContext(Constants.STUDY_MENU,
+ Constants.STUDY_MENU, Constants.TRUE, Constants.BACK,
+ Constants.OPEN);
setActionType("edicycle");
-
+
return SUCCESS;
}
public String doEdition() {
- // --------------------------
-// Session connex = Database.getCurSession();
-// Transaction transax = connex.beginTransaction();
Study study = getOpenStudy().getStudyObject();
- if (tosave == Save.title) {
+ if (_tosave == Save.title) {
// Edition of the title
Study.Properties sprop = new Study.Properties();
try {
- getStudyService().update(study, sprop.setTitle(stitle));
+ getStudyService().update(study, sprop.setTitle(_stitle));
} catch (InvalidPropertyException e) {
- // TODO
+ // TODO:
+ LOG.error(e.getMessage(), e);
}
- } else if (tosave == Save.contributor) {
+ } else if (_tosave == Save.contributor) {
// Edition of contributors
- if (contributors == null)
- contributors = "";
- if (candidates == null)
- candidates = "";
+ if (_contributors == null) {
+ _contributors = "";
+ }
+ if (_candidates == null) {
+ _candidates = "";
+ }
- String[] parsekept = contributors.split(",");
- String[] parsenew = candidates.split(",");
- Vector<User> toremove = new Vector<User>(getStudyService().getContributors(study));
+ String[] parsekept = _contributors.split(",");
+ String[] parsenew = _candidates.split(",");
+ List<User> toremove = new ArrayList<User>(getStudyService()
+ .getContributors(study));
for (int i = 0; i < parsekept.length; i++) {
- if (parsekept[i].length() == 0)
+ if (parsekept[i].length() == 0) {
continue; // Yet no contributor
+ }
int index = Integer.valueOf(parsekept[i].trim());
for (Iterator<User> j = toremove.iterator(); j.hasNext();) {
long present = j.next().getIndex();
- if (present != index)
+ if (present != index) {
continue;
+ }
j.remove();
break;
}
}
int size = toremove.size();
- if (size > 0)
+ if (size > 0) {
getStudyService().removeContributor(study,
toremove.toArray(new User[size]));
+ }
for (int i = 0; i < parsenew.length; i++) {
- if (parsenew[i].length() == 0)
+ if (parsenew[i].length() == 0) {
continue; // No any new contributor
+ }
int index = Integer.valueOf(parsenew[i].trim());
User newser = getUserService().selectUser(index);
getStudyService().addContributor(study, newser);
}
- } else if (tosave == Save.cycle) {
+ } else if (_tosave == Save.cycle) {
// Addition of a document validation cycle
- DocumentType apply = getDocumentTypeService().selectType(type);
+ DocumentType apply = getDocumentTypeService().selectType(_type);
ValidationCycle.Properties vprop = new ValidationCycle.Properties();
- if (publisher > 0) {
- User actor = getUserService().selectUser(publisher);
+ if (_publisher > 0) {
+ User actor = getUserService().selectUser(_publisher);
vprop.setActor(ValidationStep.PROMOTION, actor);
}
- if (reviewer > 0) {
- User actor = getUserService().selectUser(reviewer);
+ if (_reviewer > 0) {
+ User actor = getUserService().selectUser(_reviewer);
vprop.setActor(ValidationStep.REVIEW, actor);
}
- if (approver > 0) {
- User actor = getUserService().selectUser(approver);
+ if (_approver > 0) {
+ User actor = getUserService().selectUser(_approver);
vprop.setActor(ValidationStep.APPROVAL, actor);
}
getStudyService().setValidationCycle(study, apply, vprop);
}
-// transax.commit();
doInitialize(); // Re-initialization following the above edition
-
- setMenuProperty("study");
- setTitleProperty("study");
- setEditDisabledProperty("true");
- setToolProperty("back");
- setLeftMenuProperty("open");
- initializationFullScreenContext(_menuProperty, _titleProperty, _editDisabledProperty, _toolProperty, _leftMenuProperty);
+
+ initializationFullScreenContext(Constants.STUDY_MENU,
+ Constants.STUDY_MENU, Constants.TRUE, Constants.BACK,
+ Constants.OPEN);
return SUCCESS;
}
// ==============================================================================================================================
public User getAuthor() {
- // ------------------------
return _openStudy.getStudyObject().getAuthor();
}
public List<User> getCandidates() {
- // ----------------------------------
- return staff;
+ return _staff;
}
public String getCycle() {
- // -------------------------
- return edicycle;
+ return _edicycle;
}
public List<User> getContributors() {
- // ------------------------------------
- return member;
+ return _member;
}
public ValidationFacade getDefaultValidation() {
- // -----------------------------------------------
- return validefault;
+ return _validefault;
}
public long getDocumentTypeIndex() {
- // ----------------------------------
- return type;
+ return _type;
}
public List<DocumentType> getOtherDocumentTypes() {
- // --------------------------------------------------
- return other;
+ return _other;
}
public String getStudyTitle() {
- // ------------------------------
return _openStudy.getTitle();
}
public List<ValidationFacade> getValidations() {
- // -----------------------------------------------
- return validation;
+ return _validation;
}
public List<Name> getValidationActors() {
- // ----------------------------------------
- return validor;
+ return _validor;
}
// ==============================================================================================================================
// ==============================================================================================================================
public void setCandidates(final String indices) {
- // ------------------------------------------
- candidates = indices;
+ _candidates = indices;
}
public void setCycle(final String type) {
- // ----------------------------------
- edicycle = type;
+ _edicycle = type;
}
public void setMembers(final String indices) {
- // ---------------------------------------
- contributors = indices;
+ _contributors = indices;
}
public void setDocumentType(final String index) {
- // ------------------------------------------
- type = Integer.valueOf(index);
+ _type = Integer.valueOf(index);
}
public void setApprover(final String index) {
- // --------------------------------------
- approver = Integer.valueOf(index);
+ _approver = Integer.valueOf(index);
}
public void setPublisher(final String index) {
- // ---------------------------------------
- publisher = Integer.valueOf(index);
+ _publisher = Integer.valueOf(index);
}
public void setReviewer(final String index) {
- // --------------------------------------
- reviewer = Integer.valueOf(index);
+ _reviewer = Integer.valueOf(index);
}
public void setTitle(final String title) {
- // -----------------------------------
- stitle = title;
+ _stitle = title;
}
public void setSaveTitle(final String save) {
- // --------------------------------------
- tosave = Save.title;
+ _tosave = Save.title;
}
public void setSaveContributors(final String save) {
- // ---------------------------------------------
- tosave = Save.contributor;
+ _tosave = Save.contributor;
}
public void setSaveCycle(final String save) {
- // --------------------------------------
- tosave = Save.cycle;
- }
-
- /**
- * Get the studyService.
- *
- * @return the studyService
- */
- @Override
- public StudyService getStudyService() {
- return _studyService;
- }
-
- /**
- * Set the studyService.
- *
- * @param studyService
- * the studyService to set
- */
- @Override
- public void setStudyService(final StudyService studyService) {
- _studyService = studyService;
+ _tosave = Save.cycle;
}
/**
* @param documentTypeService
* the documentTypeService to set
*/
- public void setDocumentTypeService(final DocumentTypeService documentTypeService) {
+ public void setDocumentTypeService(
+ final DocumentTypeService documentTypeService) {
_documentTypeService = documentTypeService;
}
/**
* Get the userService.
+ *
* @return the userService
*/
public UserService getUserService() {
/**
* Set the userService.
- * @param userService the userService to set
+ *
+ * @param userService
+ * the userService to set
*/
public void setUserService(final UserService userService) {
_userService = userService;
}
-
- /**
- * Get the menuProperty.
- * @return the menuProperty
- */
- @Override
- public String getMenuProperty() {
- return _menuProperty;
- }
-
- /**
- * Set the menuProperty.
- * @param menuProperty the menuProperty to set
- */
- @Override
- public void setMenuProperty(final String menuProperty) {
- this._menuProperty = menuProperty;
- }
-
- /**
- * Get the _titleProperty.
- * @return the _titleProperty
- */
- @Override
- public String getTitleProperty() {
- return _titleProperty;
- }
-
- /**
- * Set the _titleProperty.
- * @param _titleProperty the titleProperty to set
- */
- @Override
- public void setTitleProperty(final String titleProperty) {
- _titleProperty = titleProperty;
- }
-
- /**
- * Get the editDisabledProperty.
- * @return the editDisabledProperty
- */
- @Override
- public final String getEditDisabledProperty() {
- return _editDisabledProperty;
- }
-
- /**
- * Set the editDisabledProperty.
- * @param editDisabledProperty the editDisabledProperty to set
- */
- @Override
- public final void setEditDisabledProperty(final String editDisabledProperty) {
- _editDisabledProperty = editDisabledProperty;
- }
-
- /**
- * Get the toolProperty.
- * @return the toolProperty
- */
- @Override
- public String getToolProperty() {
- return _toolProperty;
- }
-
- /**
- * Set the toolProperty.
- * @param toolProperty the toolProperty to set
- */
- @Override
- public void setToolProperty(final String toolProperty) {
- _toolProperty = toolProperty;
- }
-
- /**
- * Get the leftMenuProperty.
- * @return the leftMenuProperty
- */
- @Override
- public String getLeftMenuProperty() {
- return _leftMenuProperty;
- }
-
- /**
- * Set the leftMenuProperty.
- * @param leftMenuProperty the leftMenuProperty to set
- */
- @Override
- public void setLeftMenuProperty(final String leftMenuProperty) {
- _leftMenuProperty = leftMenuProperty;
- }
}
\ No newline at end of file