private static final long serialVersionUID = 4210696018741092900L;
// Presentation fields
+ /**
+ * List of available users which are not yet included into contributors.
+ */
private transient List<User> _staff;
+ /**
+ * Study contributors list.
+ */
private transient List<User> _member;
+ /**
+ * List of validators.
+ */
private transient List<Name> _validor;
+ /**
+ * List of specific study validation cycles presentations.
+ */
private transient List<ValidationFacade> _validation;
+ /**
+ * Default validation cycle presentation.
+ */
private transient ValidationFacade _validefault;
+ /**
+ * List of document types which have no specific validation cycles for this study.
+ */
private transient List<DocumentType> _other;
// User input fields
* Edition action (title, contributors or cycle).
*/
private transient Save _tosave;
+ /**
+ * Document type name for the modified validation cycle.
+ */
private transient String _edicycle;
/**
* Title of the study.
* Type of document to be included in the validation process.
*/
private transient long _type;
- private transient int _publisher;
- private transient int _reviewer;
- private transient int _approver;
+ /**
+ * Validation cycle publisher's id.
+ */
+ private transient long _publisher;
+ /**
+ * Validation cycle reviewer's id.
+ */
+ private transient long _reviewer;
+ /**
+ * Validation cycle approver's id.
+ */
+ private transient long _approver;
/**
* Injected document type service.
* Injected user service.
*/
private UserService _userService;
-
+
/**
* Study readers list.
*/
- List<UserDTO> _readers;
+ private List<UserDTO> _readers;
/**
* Study reader id list.
*/
- List<Long > _readerIds;
+ private List<Long> _readerIds;
/**
* Save operation type enumeration pointing which section of properties has been edited.
*/
public String doInitialize() {
- String res;
_openStudy = getOpenStudy();
- _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();) {
- DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(
- study, type);
- if (cycle.isDefault()) {
- _validefault = new ValidationFacade(cycle,
- getApplicationSettings().getCurrentLocale());
- continue;
- }
- _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);
+
+ initData(study);
+
_staff = null;
_validor = null;
- initializationFullScreenContext(Constants.STUDY_MENU,
- Constants.STUDY_MENU, Constants.TRUE, Constants.BACK,
- Constants.OPEN);
-
+ String res;
+ StudyRights user = _openStudy.getStudyRights();
if (_openStudy.isOpenForWriting() && user.canEditProperties()) {
res = "edit";
} else {
res = "display";
}
-
+
try {
- _readers = getStudyService().getReaders(getOpenStudy().getIndex().longValue());
- } catch(InvalidParameterException e) {
- LOG.error(e.getMessage(), e);
+ _readers = getStudyService().getReaders(
+ getOpenStudy().getIndex().longValue());
+ } catch (InvalidParameterException e) {
+ LOG.error(e.getMessage(), e);
}
return res;
}
- public String doEditTitle() {
-
- _openStudy = getOpenStudy();
+ /**
+ * Initialize common study data presented on the screen.
+ *
+ * @param study
+ * the selected study
+ */
+ private void initData(final Study study) {
_validation = new ArrayList<ValidationFacade>();
_validefault = null;
- _other = getDocumentTypeService().selectResultTypes();
+ // RKV: _other = getDocumentTypeService().selectResultTypes();
+ _other = getDocumentTypeService().selectAllTypes(); // RKV
- Study study = _openStudy.getStudyObject();
for (Iterator<DocumentType> i = _other.iterator(); i.hasNext();) {
DocumentType type = i.next();
ValidationCycle cycle = getStudyService().getValidationCycleOf(
study, type);
if (cycle.isDefault()) {
- _validefault = new ValidationFacade(cycle,
- getApplicationSettings().getCurrentLocale());
- continue;
+ if (_validefault == null) {
+ _validefault = new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale());
+ }
+ } else {
+ if (type.getName().equals(_edicycle)) {
+ this._type = type.getIndex();
+ }
+ _validation.add(new ValidationFacade(cycle,
+ getApplicationSettings().getCurrentLocale()));
+ i.remove();
}
- _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 = null;
- _validor = null;
- _other = null;
initializationFullScreenContext(Constants.STUDY_MENU,
Constants.STUDY_MENU, Constants.TRUE, Constants.BACK,
Constants.OPEN);
-
+ }
+
+ /**
+ * Prepare study title editing.
+ *
+ * @return SUCCESS
+ */
+ public String doEditTitle() {
+
+ _openStudy = getOpenStudy();
+
+ initData(_openStudy.getStudyObject());
+
+ _staff = null;
+ _validor = null;
+ _other = null;
+
try {
- _readers = getStudyService().getReaders(getOpenStudy().getIndex().longValue());
- } catch(InvalidParameterException e) {
- LOG.error(e.getMessage(), e);
+ _readers = getStudyService().getReaders(
+ getOpenStudy().getIndex().longValue());
+ } catch (InvalidParameterException e) {
+ LOG.error(e.getMessage(), e);
}
setActionType("edititle");
return SUCCESS;
}
+ /**
+ * Prepare contributors list editing for the selected study.
+ *
+ * @return SUCCESS
+ */
public String doEditContributors() {
_openStudy = getOpenStudy();
- _validation = new ArrayList<ValidationFacade>();
- _validefault = null;
- _other = getDocumentTypeService().selectAllTypes();
-
Study study = _openStudy.getStudyObject();
- for (Iterator<DocumentType> i = _other.iterator(); i.hasNext();) {
- DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(
- study, type);
- if (cycle.isDefault()) {
- _validefault = new ValidationFacade(cycle,
- getApplicationSettings().getCurrentLocale());
- continue;
- }
- _validation.add(new ValidationFacade(cycle,
- getApplicationSettings().getCurrentLocale()));
- }
- if (_validefault != null) {
- _validation.add(_validefault); // In order to be at the end
- }
- _member = getStudyService().getContributors(study);
+
+ initData(study);
+
_staff = getUserService().selectAllUsers();
_validor = null;
_other = null;
}
}
- initializationFullScreenContext(Constants.STUDY_MENU,
- Constants.STUDY_MENU, Constants.TRUE, Constants.BACK,
- Constants.OPEN);
-
try {
- _readers = getStudyService().getReaders(getOpenStudy().getIndex().longValue());
- } catch(InvalidParameterException e) {
+ _readers = getStudyService().getReaders(
+ getOpenStudy().getIndex().longValue());
+ } catch (InvalidParameterException e) {
LOG.error(e.getMessage(), e);
}
setActionType("edibutor");
return SUCCESS;
}
-
+
/**
* Initialize edit readers screen.
+ *
* @return SUCCES
*/
public String doInitEditReaders() {
doInitialize();
-
+
_staff = getUserService().selectAllUsers();
-
- //remove user from potential readers
+
+ // remove user from potential readers
_staff.remove(getConnectedUser());
-
- //remove contributors from potential readers
- if(_member != null) {
+
+ // remove contributors from potential readers
+ if (_member != null) {
_staff.removeAll(_member);
}
-
- //remove readers from potential readers
+
+ // remove readers from potential readers
List<User> readers = new ArrayList<User>();
- for(UserDTO userDTO : _readers) {
+ for (UserDTO userDTO : _readers) {
readers.add(BeanHelper.copyBean(userDTO, User.class));
}
_staff.removeAll(readers);
-
+
setActionType("editReaders");
-
- return SUCCESS;
+
+ return SUCCESS;
}
+ /**
+ * Add or edit a document validation cycle for the selected study.
+ *
+ * @return SUCCESS
+ */
public String doEditCycle() {
_openStudy = getOpenStudy();
- _validation = new ArrayList<ValidationFacade>();
- _validefault = null;
- _other = getDocumentTypeService().selectResultTypes();
-
Study study = _openStudy.getStudyObject();
- for (Iterator<DocumentType> i = _other.iterator(); i.hasNext();) {
- DocumentType type = i.next();
- ValidationCycle cycle = getStudyService().getValidationCycleOf(
- study, type);
- if (cycle.isDefault()) {
- _validefault = new ValidationFacade(cycle,
- getApplicationSettings().getCurrentLocale());
- continue;
- }
- if (type.getName().equals(_edicycle)) {
- this._type = type.getIndex();
- }
- _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);
+
+ initData(study);
+
_validor = new ArrayList<Name>();
_staff = null;
List<User> user = getUserService().selectAllUsers();
}
}
- initializationFullScreenContext(Constants.STUDY_MENU,
- Constants.STUDY_MENU, Constants.TRUE, Constants.BACK,
- Constants.OPEN);
-
try {
- _readers = getStudyService().getReaders(getOpenStudy().getIndex().longValue());
- } catch(InvalidParameterException e) {
- LOG.error(e.getMessage(), e);
+ _readers = getStudyService().getReaders(
+ getOpenStudy().getIndex().longValue());
+ } catch (InvalidParameterException e) {
+ LOG.error(e.getMessage(), e);
}
setActionType("edicycle");
return SUCCESS;
}
+ /**
+ * Save modifications.
+ *
+ * @return SUCCESS
+ * @throws InvalidParameterException
+ * if can't modify readers list
+ */
public String doEdition() throws InvalidParameterException {
Study study = getOpenStudy().getStudyObject();
try {
getStudyService().update(study, sprop.setTitle(_stitle));
} catch (InvalidPropertyException e) {
- // TODO:
LOG.error(e.getMessage(), e);
}
} else if (_tosave == Save.contributor) {
+ saveContributor(study);
+
+ } else if (_tosave == Save.cycle) {
+ saveValidationCycle(study);
- // Edition of contributors
- if (_contributors == null) {
- _contributors = "";
+ } else if (_tosave == Save.readers) {
+ saveReaders(study);
+ }
+
+ doInitialize(); // Re-initialization following the above edition
+
+ return SUCCESS;
+ }
+
+ /**
+ * Save the study readers list.
+ *
+ * @param study
+ * the selected study
+ * @throws InvalidParameterException
+ * if the study readers list modification is failed
+ */
+ private void saveReaders(final Study study)
+ throws InvalidParameterException {
+ long studyId = getOpenStudy().getIndex().longValue();
+ _readers = getStudyService().getReaders(studyId);
+
+ // Remove newly unchecked users
+ if (_readers != null) {
+ for (UserDTO userDTO : _readers) {
+ if (_readerIds == null
+ || !_readerIds.contains(userDTO.getIndex())) {
+ getStudyService().removeReader(studyId, userDTO.getIndex());
+ }
}
- if (_candidates == null) {
- _candidates = "";
+ }
+
+ // Add newly checked users
+ if (_readerIds != null) {
+ for (Long userId : _readerIds) {
+ if (_readers == null) {
+ getStudyService().addReader(studyId, userId);
+ } else {
+ boolean contains = false;
+ for (UserDTO userDTO : _readers) {
+ if (userId.longValue() == userDTO.getIndex()) {
+ contains = true;
+ break;
+ }
+ }
+ if (!contains) {
+ getStudyService().addReader(studyId, userId);
+ }
+ }
}
+ }
- String[] parsekept = _contributors.split(",");
- String[] parsenew = _candidates.split(",");
- List<User> toremove = new ArrayList<User>(getStudyService()
- .getContributors(study));
+ // Update OpenStudy
+ _openStudy.open(getConnectedUser(), getStudyService().selectStudy(
+ _openStudy.getIndex()));
+ }
- for (int i = 0; i < parsekept.length; i++) {
- if (parsekept[i].length() == 0) {
- continue; // Yet no contributor
- }
+ /**
+ * Save the study document validation cycle.
+ *
+ * @param study
+ * the selected study
+ */
+ private void saveValidationCycle(final Study study) {
+ // Addition of a document validation cycle
+ DocumentType apply = getDocumentTypeService().selectType(_type);
+ ValidationCycle.Properties vprop = new ValidationCycle.Properties();
+ if (_publisher > 0) {
+ User actor = getUserService().selectUser(_publisher);
+ vprop.setActor(ValidationStep.PROMOTION, actor);
+ }
+ if (_reviewer > 0) {
+ User actor = getUserService().selectUser(_reviewer);
+ vprop.setActor(ValidationStep.REVIEW, actor);
+ }
+ if (_approver > 0) {
+ User actor = getUserService().selectUser(_approver);
+ vprop.setActor(ValidationStep.APPROVAL, actor);
+ }
+ getStudyService().setValidationCycle(study, apply, vprop);
+ }
+
+ /**
+ * Save the study contributors list.
+ *
+ * @param study
+ * the selected study
+ */
+ private void saveContributor(final Study study) {
+ // Edition of contributors
+ if (_contributors == null) {
+ _contributors = "";
+ }
+ if (_candidates == null) {
+ _candidates = "";
+ }
+
+ 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) {
int index = Integer.valueOf(parsekept[i].trim());
for (Iterator<User> j = toremove.iterator(); j.hasNext();) {
long present = j.next().getIndex();
- if (present != index) {
- continue;
+ if (present == index) {
+ j.remove();
+ break;
}
- j.remove();
- break;
}
}
- int size = toremove.size();
- if (size > 0) {
- getStudyService().removeContributor(study,
- toremove.toArray(new User[size]));
- }
+ }
+ int size = toremove.size();
+ if (size > 0) {
+ getStudyService().removeContributor(study,
+ toremove.toArray(new User[size]));
+ }
- for (int i = 0; i < parsenew.length; i++) {
- if (parsenew[i].length() == 0) {
- continue; // No any new contributor
- }
+ for (int i = 0; i < parsenew.length; i++) {
+ if (parsenew[i].length() != 0) {
int index = Integer.valueOf(parsenew[i].trim());
User newser = getUserService().selectUser(index);
getStudyService().addContributor(study, newser);
}
- } else if (_tosave == Save.cycle) {
-
- // Addition of a document validation cycle
- DocumentType apply = getDocumentTypeService().selectType(_type);
- ValidationCycle.Properties vprop = new ValidationCycle.Properties();
- if (_publisher > 0) {
- User actor = getUserService().selectUser(_publisher);
- vprop.setActor(ValidationStep.PROMOTION, actor);
- }
- if (_reviewer > 0) {
- User actor = getUserService().selectUser(_reviewer);
- vprop.setActor(ValidationStep.REVIEW, actor);
- }
- if (_approver > 0) {
- User actor = getUserService().selectUser(_approver);
- vprop.setActor(ValidationStep.APPROVAL, actor);
- }
- getStudyService().setValidationCycle(study, apply, vprop);
- } else if(_tosave == Save.readers) {
- long studyId = getOpenStudy().getIndex().longValue();
- _readers = getStudyService().getReaders(studyId);
-
- //Remove newly unchecked users
- if(_readers != null) {
- for(UserDTO userDTO : _readers) {
- if(_readerIds == null || !_readerIds.contains(userDTO.getIndex())) {
- getStudyService().removeReader(studyId, userDTO.getIndex());
- }
- }
- }
-
- //Add newly checked users
- if(_readerIds != null) {
- for(Long userId : _readerIds) {
- if(_readers == null) {
- getStudyService().addReader(studyId, userId);
- } else {
- boolean contains = false;
- for(UserDTO userDTO : _readers) {
- if(userId.longValue() == userDTO.getIndex()) {
- contains = true;
- break;
- }
- }
- if(!contains) {
- getStudyService().addReader(studyId, userId);
- }
- }
- }
- }
-
- //Update OpenStudy
- _openStudy.open(getConnectedUser(), getStudyService().selectStudy(_openStudy.getIndex()));
}
-
- doInitialize(); // Re-initialization following the above edition
-
- initializationFullScreenContext(Constants.STUDY_MENU,
- Constants.STUDY_MENU, Constants.TRUE, Constants.BACK,
- Constants.OPEN);
-
- return SUCCESS;
}
- // ==============================================================================================================================
- // Getters
- // ==============================================================================================================================
-
+ /**
+ * Get the study author.
+ *
+ * @return the study author
+ */
public User getAuthor() {
return _openStudy.getStudyObject().getAuthor();
}
+ /**
+ * Get list of available candidates.
+ *
+ * @return list of candidates
+ */
public List<User> getCandidates() {
return _staff;
}
+ /**
+ * Get the document type name of the modified validation cycle.
+ *
+ * @return the type name of the modified cycle
+ */
public String getCycle() {
return _edicycle;
}
+ /**
+ * Get study contributors list.
+ *
+ * @return list of contributors
+ */
public List<User> getContributors() {
return _member;
}
+ /**
+ * Get default validation cycle presentation.
+ *
+ * @return default validation cycle presentation
+ */
public ValidationFacade getDefaultValidation() {
return _validefault;
}
+ /**
+ * Get selected document type id.
+ *
+ * @return the selected document type id
+ */
public long getDocumentTypeIndex() {
return _type;
}
+ /**
+ * Get list of document types which have no specific validation cycles for this study.
+ *
+ * @return list of document types
+ */
public List<DocumentType> getOtherDocumentTypes() {
return _other;
}
+ /**
+ * Get study title.
+ *
+ * @return the study title
+ */
public String getStudyTitle() {
return _openStudy.getTitle();
}
+ /**
+ * Get the list of specific study validation cycles presentations.
+ *
+ * @return list of validation cycles facades
+ */
public List<ValidationFacade> getValidations() {
return _validation;
}
+ /**
+ * Get the list of validators.
+ *
+ * @return list of user names
+ */
public List<Name> getValidationActors() {
return _validor;
}
- // ==============================================================================================================================
- // Setters
- // ==============================================================================================================================
-
+ /**
+ * Set the list of candidates ids.
+ *
+ * @param indices
+ * the list of users ids
+ */
public void setCandidates(final String indices) {
_candidates = indices;
}
+ /**
+ * Set the document type name for the modified validation cycle.
+ *
+ * @param type
+ * the document type name
+ */
public void setCycle(final String type) {
_edicycle = type;
}
+ /**
+ * Set the list of contributors ids.
+ *
+ * @param indices
+ * the list of users ids
+ */
public void setMembers(final String indices) {
_contributors = indices;
}
+ /**
+ * Set the id of the selected document type.
+ *
+ * @param index
+ * document type id
+ */
public void setDocumentType(final String index) {
- _type = Integer.valueOf(index);
+ _type = Long.valueOf(index);
}
+ /**
+ * Set the selected approver id.
+ *
+ * @param index
+ * the user id
+ */
public void setApprover(final String index) {
- _approver = Integer.valueOf(index);
+ _approver = Long.valueOf(index);
}
+ /**
+ * Set the selected publisher id.
+ *
+ * @param index
+ * the user id
+ */
public void setPublisher(final String index) {
- _publisher = Integer.valueOf(index);
+ _publisher = Long.valueOf(index);
}
+ /**
+ * Set the selected reviewer id.
+ *
+ * @param index
+ * the user id
+ */
public void setReviewer(final String index) {
- _reviewer = Integer.valueOf(index);
+ _reviewer = Long.valueOf(index);
}
+ /**
+ * Set the study title.
+ *
+ * @param title
+ * the study title
+ */
public void setTitle(final String title) {
_stitle = title;
}
+ /**
+ * Set the current operation to title saving.
+ *
+ * @param save
+ * unused parameter
+ */
public void setSaveTitle(final String save) {
_tosave = Save.title;
}
+ /**
+ * Set the current operation to contributors saving.
+ *
+ * @param save
+ * unused parameter
+ */
public void setSaveContributors(final String save) {
_tosave = Save.contributor;
}
+ /**
+ * Set the current operation to validation cycle saving.
+ *
+ * @param save
+ * unused parameter
+ */
public void setSaveCycle(final String save) {
_tosave = Save.cycle;
}
/**
- * Set tosave to readers.
- * @param save the save
+ * Set the current operation to readers saving.
+ *
+ * @param save
+ * unused parameter
*/
public void setSaveReaders(final String save) {
_tosave = Save.readers;
}
-
+
/**
* Get the documentTypeService.
*
/**
* Get the readers.
+ *
* @return the readers
*/
public List<UserDTO> getReaders() {
/**
* Set the readers.
- * @param readers the readers to set
+ *
+ * @param readers
+ * the readers to set
*/
public void setReaders(final List<UserDTO> readers) {
_readers = readers;
}
/**
- * Get the readerIds.
- * @return the readerIds
+ * Get the list of readers ids.
+ *
+ * @return the list of users ids
*/
public List<Long> getReaderIds() {
return _readerIds;
}
/**
- * Set the readerIds.
- * @param readerIds the readerIds to set
+ * Set the list of readers ids.
+ *
+ * @param readerIds
+ * the list of users ids to set
*/
public void setReaderIds(final List<Long> readerIds) {
this._readerIds = readerIds;