protected Role () {
}
// Initialization constructor
- protected Role (String username, String role) {
+ protected Role (final String username, final String role) {
// ---------------------------------------------
this.username = username;
this.role = role;
// Protected member functions
// ==============================================================================================================================
- protected void addRole (String role) {
+ protected void addRole (final String role) {
// ------------------------------------
this.role = this.role + "," + role;
}
return role;
}
- public boolean is (String name) {
+ public boolean is (final String name) {
// -------------------------------
return this.role.equals(name);
}
- public boolean isSame (Role other) {
+ public boolean isSame (final Role other) {
// ----------------------------------
return this.role.equals(other.role);
}
+
}
\ No newline at end of file
<!-- int history -->
<property name="history" column="history" access="field" not-null="true" />
+
+ <!-- int mark as reference flag -->
+ <property name="markreference" column="markreference" access="field" not-null="true" />
</union-subclass>
* Persistent history property. It is a number of studies versioning this one, if any.
*/
private int history;
+
+ /**
+ * Persistent property. Flag: marked the given study as reference or not.
+ */
+ private int markreference;
// Transient fields
/**
// - Global validity check
+ @Override
public void checkValidity() throws MissedPropertyException,
InvalidPropertyException, MultiplyDefinedException {
if (title == null) {
// RKV scenarii = new LinkedList<Scenario>();
visibility = Visibility.PRIVATE;
state = ProgressState.inWORK;
+ markreference = 0;
credate = sprop.date; // Inherited attribute
if (credate == null) {
public Study getOwnerStudy() {
return this;
}
+
+ /**
+ * Get the markreference.
+ * @return the markreference
+ */
+ public int getMarkreference() {
+ return markreference;
+ }
+
+ /**
+ * Set the markreference.
+ * @param markreference the markreference to set
+ */
+ public void setMarkreference(final int markreference) {
+ this.markreference = markreference;
+ }
+
}
\ No newline at end of file
import org.splat.dal.bo.som.Publication;
import org.splat.dal.bo.som.SimulationContext;
import org.splat.dal.bo.som.Study;
-import org.splat.dal.bo.som.ValidationCycle;
import org.splat.dal.bo.som.Study.Properties;
+import org.splat.dal.bo.som.ValidationCycle;
import org.splat.kernel.InvalidPropertyException;
import org.splat.kernel.MissedPropertyException;
import org.splat.kernel.MultiplyDefinedException;
* @return the unmodifiable not null transient list of contributors of this study
*/
List<User> getContributors(Study aStudy);
+
+ /**
+ * Mark study as reference.
+ *
+ * @param aStudy - the Study
+ * @return true if operation is success
+ */
+ void markStudyAsReference(Study aStudy);
+
+ /**
+ * Remove study as reference.
+ * This operation is inverse one to Mark as reference.
+ *
+ * @param aStudy - the Study
+ * @return true if operation is success
+ */
+ void removeStudyAsReference(Study aStudy);
}
aStudy.getActor().add(((ActorRelation) link).getTo());
}
}
+
+ /**
+ *
+ * {@inheritDoc}
+ * @see org.splat.service.StudyService#markStudyAsReference(org.splat.dal.bo.som.Study)
+ */
+ @Override
+ @Transactional
+ public void markStudyAsReference (final Study aStudy) {
+
+ aStudy.setMarkreference(1);
+ aStudy.setProgressState(ProgressState.TEMPLATE);
+ getStudyDAO().update(aStudy);
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ * @see org.splat.service.StudyService#removeStudyAsReference(org.splat.dal.bo.som.Study)
+ */
+ @Override
+ @Transactional
+ public void removeStudyAsReference(final Study aStudy) {
+
+ aStudy.setMarkreference(0);
+ aStudy.setProgressState(ProgressState.APPROVED);
+ getStudyDAO().update(aStudy);
+ }
/**
* Get project settings.
}
return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
}
+
+ /**
+ * Can the given study be marked as reference or not.
+ * @return true/false.
+ */
+ public boolean canMarkStudyAsReference() {
+
+ if (_operand.getProgressState() == ProgressState.APPROVED /*&& "knowledgineer".equals(_user.getRole().getName())*/) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Can the given study be unmarked as reference or not.
+ * @return true/false.
+ */
+ public boolean canRemoveStudyAsReference() {
+
+ if (_operand.getProgressState() == ProgressState.TEMPLATE /*&& "knowledgineer".equals(_user.getRole().getName())*/) {
+ return true;
+ }
+ return false;
+ }
// ==============================================================================================================================
// Getter
message.error.reference.mismatch = Ce document porte une référence différente du document versionné.
message.error.format.version = Ce document porte un numéro de version illicite.
message.error.format.date = Ce document porte une date illicite ou définie dans un format non supporté.
-message.error.version.mismatch = Ce document porte un numéro de version illicite ou incorrect.
\ No newline at end of file
+message.error.version.mismatch = Ce document porte un numéro de version illicite ou incorrect.
+
+#Validation errors
+message.error.noenteredvalue=The field ''{0}'' must be filled
\ No newline at end of file
message.error.reference.mismatch = The reference of this document does not match the one of the versioned document.
message.error.format.version = The revision number of this document is illicit.
message.error.format.date = The date of this document is illicit or is defined in an unsupported format.
-message.error.version.mismatch = The revision number of this document is illicit or incorrect.
\ No newline at end of file
+message.error.version.mismatch = The revision number of this document is illicit or incorrect.
+
+#Validation errors
+message.error.noenteredvalue=The field ''{0}'' must be filled
\ No newline at end of file
* 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.
*/
private static final String MNU_NAME_MARK_AS_REFERENCE = "menu.markasreference";
+ /**
+ * Remove as reference menu item label key.
+ */
+ private static final String MNU_NAME_REMOVE_AS_REFERENCE = "menu.removeasreference";
/**
* Not yet implemented action name.
*/
* Version action name.
*/
private static final String ACT_VERSION = "select-file?nextAction=version";
+ /**
+ * Mark as reference action name.
+ */
+ private static final String ACT_MARK_AS_REFERENCE = "markasref-study";
+ /**
+ * Remove as reference action name.
+ */
+ private static final String ACT_REMOVE_AS_REFERENCE = "removeasref-study";
/**
* Siman application server name.
};
// Resources relative to studies
- private static class EditableStudyPopup extends PopupMenu {
+ private static class EditableMarkedStudyPopup extends PopupMenu {
private transient StudyRights _user = null;
- private EditableStudyPopup() {
+ private EditableMarkedStudyPopup() {
super();
- addItem(MNU_MARK_AS_REFERENCE, new PopupItem(
- MNU_NAME_MARK_AS_REFERENCE).action(ACT_NOT_YET_IMPLEMENTED)
- .confirmation("message.markasreference.study"));
+ addItem(MNU_MARK_AS_REFERENCE, new PopupItem(MNU_NAME_MARK_AS_REFERENCE)
+ .action(ACT_MARK_AS_REFERENCE).confirmation(
+ "message.markasreference.study"));
addItem(MNU_PUBLISH, new PopupItem(MNU_NAME_PUBLISH).icon(
"image.publish.png").action("edit-study?action=publish")
.confirmation("message.publish.study"));
case purge:
res = _user.canPurge();
break;
+ case markasreference:
+ res = _user.canMarkStudyAsReference();
+ break;
+ default:
+ res = false;
+ }
+ }
+ return res;
+ }
+
+ @Override
+ public void setContext(final String name, final Object context) {
+ if (context instanceof StudyRights) {
+ _user = (StudyRights) context; // Just for optimizing
+ boolean history = _user.getOperand().isVersioned();
+ PopupItem item = this.item(MNU_REMOVE);
+ if (history) {
+ item.rename(MNU_NAME_REMOVE);
+ } else {
+ item.rename("menu.remove.study");
+ }
+ }
+ }
+ }
+
+ // Resources relative to studies
+ private static class EditableUnmarkedStudyPopup extends PopupMenu {
+ private transient StudyRights _user = null;
+
+ private EditableUnmarkedStudyPopup() {
+ super();
+ addItem(MNU_MARK_AS_REFERENCE, new PopupItem(
+ MNU_NAME_REMOVE_AS_REFERENCE).action(ACT_REMOVE_AS_REFERENCE)
+ .confirmation("message.removeasreference.study"));
+ addItem(MNU_PUBLISH,
+ new PopupItem(MNU_NAME_PUBLISH).icon("image.publish.png")
+ .action("edit-study?action=publish")
+ .confirmation("message.publish.study"));
+ /* addItem(MNU_PROMOTE, new PopupItem("menu.archive")); */
+ addSeparator();
+ addItem(MNU_EDIT,
+ new PopupItem("menu.properties").icon("icon.ed.png")
+ .action("../select?menu=properties"));
+ addSeparator();
+ addItem(MNU_SCRIPT,
+ new PopupItem(MNU_NAME_SCRIPT).action("add-scenario"));
+ /*
+ * addItem(MNU_VERSION, new PopupItem(MNU_NAME_VERSION).icon( IMG_VERSION).action(ACT_NOT_YET_IMPLEMENTED));
+ */
+ addSeparator();
+ /*
+ * addItem(MNU_PURGE, new PopupItem(MNU_NAME_PURGE) .confirmation("message.purge.study")); addItem("export", new
+ * PopupItem("menu.export") .icon("image.export.png")); // For future needs
+ */addItem(
+ MNU_REMOVE,
+ new PopupItem(MNU_NAME_REMOVE).icon(IMG_DELETE)
+ .action(ACT_NOT_YET_IMPLEMENTED)
+ .confirmation("message.delete.study"));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.splat.wapp.ContextualMenu#isEnabled(java.lang.String)
+ */
+ @Override
+ public boolean isEnabled(final String name) {
+ boolean res = (_user != null);
+ if (res) {
+ Item item = Item.valueOf(name);
+ switch (item) {
+ case publish:
+ res = _user.canPublish();
+ break;
+ case edit:
+ res = _user.canEditProperties();
+ break;
+ case script:
+ res = _user.canAddScenario();
+ break;
+ case version:
+ res = _user.canVersion();
+ break;
+ case remove:
+ res = _user.canRemove();
+ break;
+ case purge:
+ res = _user.canPurge();
+ break;
+ case markasreference:
+ res = _user.canRemoveStudyAsReference();
+ break;
default:
res = false;
}
_menus.put(menu.getName(), menu);
_popups = new HashMap<String, PopupMenu>();
- _popups.put("steditable", new EditableStudyPopup());
+ _popups.put("steditablemark", new EditableMarkedStudyPopup());
+ _popups.put("steditableunmark", new EditableUnmarkedStudyPopup());
_popups.put("editable", new EditableDocumentPopup());
_popups.put("notresult", new NotResultDocumentPopup());
_popups.put("reviewable", new ReviewableDocumentPopup());
package org.splat.simer;
import org.splat.dal.bo.som.Study;
+import org.splat.service.StudyService;
public class EditStudyAction extends DisplayStudyStepAction {
* Serial version ID.
*/
private static final long serialVersionUID = -4865668290514118396L;
+
+ /**
+ * Injected study service.
+ */
+ private StudyService _studyService;
private enum Execute {
publish, promote
return SUCCESS;
}
+
+ /**
+ * Mark study as reference functionality.
+ * @return SUCCESS
+ */
+ public String doMarkAsReference() {
+
+ _openStudy = getOpenStudy();
+ Study study = _openStudy.getStudyObject();
+
+ _studyService.markStudyAsReference(study);
+
+ return SUCCESS;
+ }
+
+ /**
+ * Remove study as reference functionality.
+ * @return SUCCESS
+ */
+ public String doRemoveAsReference() {
+
+ _openStudy = getOpenStudy();
+ Study study = _openStudy.getStudyObject();
+
+ _studyService.removeStudyAsReference(study);
+
+ return SUCCESS;
+ }
+
+ /**
+ * 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;
+ }
+
}
\ No newline at end of file
// 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(
- "steditable");
+ /* else */
+ if (_mystudy.getProgressState() == ProgressState.TEMPLATE) {
+ _popup = getApplicationSettings().getPopupMenu(
+ "steditableunmark");
+ } else {
+ _popup = getApplicationSettings().getPopupMenu(
+ "steditablemark");
+ }
_popup.setContext("study", new StudyRights(_cuser, _mystudy));
}
_urightstudy = new StudyRights(_cuser, _mystudy);
_cuser = user;
_popup = null;
if (getStudyService().isStaffedBy(_mystudy, _cuser)) {
- _popup = getApplicationSettings().getPopupMenu("steditable");
+ _popup = getApplicationSettings().getPopupMenu("steditablemark");
_popup.setContext("study", new StudyRights(_cuser, _mystudy));
}
// ustep = getProjectElementService().getFirstStep(mystudy);
<bean id="editStudyAction" class="org.splat.simer.EditStudyAction"
scope="prototype" parent="displayStudyStepAction">
+ <property name="studyService" ref="studyService" />
</bean>
<bean id="editScenarioPropertiesAction"
<interceptor name="file-upload"
class="org.apache.struts2.interceptor.FileUploadInterceptor">
</interceptor>
+
+ <interceptor-stack name="siman-validation">
+ <interceptor-ref name="validation">
+ <param name="excludeMethods">input,back,cancel,browse</param>
+ </interceptor-ref>
+ <interceptor-ref name="workflow"/>
+ </interceptor-stack>
<interceptor-stack name="simanBasicStack">
<interceptor-ref name="exception" />
</action>
<action name="valid-new" class="newStudyAction"
method="create">
+ <!--interceptor-ref name="siman-validation" /-->
<result name="success" type="redirectAction">
open-study?selection=0.1
</result>
page.displaystudy
</result>
</action>
+ <action name="markasref-study" class="editStudyAction"
+ method="markAsReference">
+ <result name="success" type="tiles">
+ page.displaystudy
+ </result>
+ </action>
+ <action name="removeasref-study" class="editStudyAction"
+ method="removeAsReference">
+ <result name="success" type="tiles">
+ page.displaystudy
+ </result>
+ </action>
+
<action name="add-scenario" class="newScenarioAction"
method="initialize">
<result name="success" type="tiles">