import java.util.List;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.splat.dal.dao.som.Database;
import org.splat.dal.bo.som.ProjectElement;
import org.splat.dal.bo.som.Scenario;
import org.splat.service.StudyService;
import org.splat.wapp.PopupMenu;
import org.splat.wapp.SimpleMenu;
-
public class DisplayStudyStepAction extends DisplayBaseAction {
- protected OpenStudy mystudy = null; // Presented study
+ /**
+ * Serial version ID.
+ */
+ private static final long serialVersionUID = 6467920934724352021L;
+
+ /**
+ * Presented study.
+ */
+ protected OpenStudy mystudy = null;
+ /**
+ * Injected study service.
+ */
private StudyService _studyService;
- private static final long serialVersionUID = 6467920934724352021L;
+ // ==============================================================================================================================
+ // Action methods
+ // ==============================================================================================================================
+
+ public String doOpen() {
+ Study study;
+ mystudy = getOpenStudy();
+ if (myindex != null)
+ 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
+ // 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
+ }
+ } catch (Exception error) {
+ logger.error("Reason:", error);
+ return 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());
+
+ return SUCCESS;
+ }
+
+ public String doSelectStep() {
+
+ mystudy = getOpenStudy();
+ if (selection == null) { // Switch back to the current study
+ selection = mystudy.getSelection();
+ } else { // Selection of a step of current study
+ mystudy.setSelection(selection);
+ }
+ // Re-initialization of the properties menu according to the selected step
+ 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");
+ }
+ 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);
+ return SUCCESS;
+ }
-// ==============================================================================================================================
-// Action methods
-// ==============================================================================================================================
-
- public String doOpen () {
-// -----------------------
- Session connex = Database.getCurSession();
- Transaction transax = connex.beginTransaction();
- Study study;
-
- mystudy = getOpenStudy();
- if (myindex != null) 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
- //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
- }
- }
- catch (Exception error) {
- logger.error("Reason:", error);
- return 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());
-
- transax.commit();
- return SUCCESS;
- }
-
- public String doSelectStep () {
-// -----------------------------
- Session connex = Database.getCurSession();
- Transaction transax = connex.beginTransaction();
-
- mystudy = getOpenStudy();
- if (selection == null) { // Switch back to the current study
- selection = mystudy.getSelection();
- } else { // Selection of a step of current study
- mystudy.setSelection(selection);
- }
-// Re-initialization of the properties menu according to the selected step
- 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");
- }
- transax.commit();
- 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);
- 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);
- return SUCCESS;
- }
-
- public String doClose () {
-// ------------------------
- closeStudy();
- return SUCCESS;
- }
-// ==============================================================================================================================
-// Getters
-// ==============================================================================================================================
-
- public String getAction () {
-// --------------------------
- return action;
- }
- public List<DocumentFacade> getDocuments () {
-// -------------------------------------------
- return mystudy.getDisplayedDocuments();
- }
- public List<OpenObject.KnowledgeIterator> getKnowledges () {
-// ----------------------------------------------------------
- return mystudy.getDisplayedKnowledges();
- }
- public List<SimulationContextFacade> getSimulationContexts () {
-// -------------------------------------------------------------
- return mystudy.getDisplayedSimulationContexts();
- }
- public PopupMenu getPopup () {
-// ----------------------------
- return mystudy.getPopup();
- }
- public int getStepNumber () {
-// ---------------------------
- return mystudy.getSelectedStep().getNumber();
- }
- public String getStepEnabled () {
-// -------------------------------
- return String.valueOf(mystudy.isStepEnabled());
- }
- public StepRights getUserRights () {
-// ----------------------------------
- return mystudy.getSelectedStepRights();
- }
- public String getWriteAccess () {
-// -------------------------------
- return String.valueOf(mystudy.isOpenForWriting());
- }
+ 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);
+ return SUCCESS;
+ }
+
+ public String doClose() {
+ closeStudy();
+ return SUCCESS;
+ }
+
+ // ==============================================================================================================================
+ // Getters
+ // ==============================================================================================================================
+
+ public String getAction() {
+ return action;
+ }
+
+ public List<DocumentFacade> getDocuments() {
+ return mystudy.getDisplayedDocuments();
+ }
+
+ public List<OpenObject.KnowledgeIterator> getKnowledges() {
+ return mystudy.getDisplayedKnowledges();
+ }
+
+ public List<SimulationContextFacade> getSimulationContexts() {
+ return mystudy.getDisplayedSimulationContexts();
+ }
+
+ public PopupMenu getPopup() {
+ return mystudy.getPopup();
+ }
+
+ public int getStepNumber() {
+ return mystudy.getSelectedStep().getNumber();
+ }
+
+ public String getStepEnabled() {
+ return String.valueOf(mystudy.isStepEnabled());
+ }
+
+ public StepRights getUserRights() {
+ return mystudy.getSelectedStepRights();
+ }
+
+ public String getWriteAccess() {
+ return String.valueOf(mystudy.isOpenForWriting());
+ }
/**
* Get the studyService.
_studyService = studyService;
}
- /**
+ /**
* {@inheritDoc}
+ *
* @see org.splat.simer.Action#setOpenStudy(org.splat.simer.OpenStudy)
*/
@Override