Salome HOME
Modifications to respect PMD rules.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / OpenStudy.java
index 0769013e3bbae45424fd58d3ac7e04e2e8de4fd9..47f1a00900a425218927e537c48a2e4f7cb37646 100644 (file)
@@ -40,7 +40,7 @@ import org.splat.som.StudyRights;
 import org.splat.util.BeanHelper;
 import org.splat.wapp.ToolBar;
 
-public class OpenStudy extends OpenObject implements OpenStudyServices {
+public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
 
        /**
         * Serial version ID.
@@ -48,8 +48,14 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        protected final static Logger LOGGER = org.splat.simer.Action.LOG;
 
        private transient Study _mystudy;
-       private transient StudyRights _urightstudy; // User rights on the open study
-       private transient StepRights _urightstep; // User rights on the selected step
+       /**
+        * User rights on the open study.
+        */
+       private transient StudyRights _urightstudy;
+       /**
+        * User rights on the selected step.
+        */
+       private transient StepRights _urightstep;
        private transient String _version;
        private transient String _credate;
        private transient String _lasdate;
@@ -96,41 +102,41 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                Revision.Format verstring = new Revision.Format(getProjectSettings()
                                .getRevisionPattern());
 
-               cuser = user; // May be null if nobody connected
+               _cuser = user; // May be null if nobody connected
                _mystudy = study;
-               selection = "0.1"; // Default selection
+               _selection = "0.1"; // Default selection
                _selecdoc = null;
 
                // Preparation of the display
                _version = verstring.format(_mystudy.getVersion());
                _credate = datstring.format(_mystudy.getDate());
                _lasdate = ""; // Not yet supported
-               description = _mystudy.getDescription();
-               involving = new ArrayList<Step>(1);
-               context = new ArrayList<SimulationContextFacade>();
-               ustep = getProjectElementService().getFirstStep(_mystudy);
-               ustep.setActor(cuser);
-               involving.add(ustep);
-               for (Iterator<SimulationContext> i = ustep.getAllSimulationContexts()
+               _description = _mystudy.getDescription();
+               _involving = new ArrayList<Step>(1);
+               _context = new ArrayList<SimulationContextFacade>();
+               _ustep = getProjectElementService().getFirstStep(_mystudy);
+               _ustep.setActor(_cuser);
+               _involving.add(_ustep);
+               for (Iterator<SimulationContext> i = _ustep.getAllSimulationContexts()
                                .iterator(); i.hasNext();) {
-                       context.add(new SimulationContextFacade(i.next(),
+                       _context.add(new SimulationContextFacade(i.next(),
                                        getProjectSettings().getAllSteps()));
                }
-               if (getStudyService().isStaffedBy(_mystudy, cuser)
-                               || getStudyService().hasActor(_mystudy, cuser)) {
+               if (getStudyService().isStaffedBy(_mystudy, _cuser)
+                               || getStudyService().hasActor(_mystudy, _cuser)) {
                        // 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(
+                       /* else */_popup = getApplicationSettings().getPopupMenu(
                                        "steditable");
-                       popup.setContext("study", new StudyRights(cuser, _mystudy));
+                       _popup.setContext("study", new StudyRights(_cuser, _mystudy));
                }
-               _urightstudy = new StudyRights(cuser, _mystudy);
-               _urightstep = new StepRights(cuser, ustep);
+               _urightstudy = new StudyRights(_cuser, _mystudy);
+               _urightstep = new StepRights(_cuser, _ustep);
 
                // RKV menu = new StudyMenu(mystudy);
-               menu = (getMenu()).init(_mystudy); // RKV
-               menu.selects(selection); // Initializes menu items to be displayed
+               _menu = (getMenu()).init(_mystudy); // RKV
+               _menu.selects(_selection); // Initializes menu items to be displayed
                setupContents(); // Initializes documents and knowledge at ustep
                return this;
        }
@@ -153,11 +159,11 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
 
        @Override
        public StudyMenu getMenu() {
-               return (StudyMenu) menu;
+               return (StudyMenu) _menu;
        }
 
        public void setMenu(final StudyMenu aMenu) {
-               menu = aMenu;
+               _menu = aMenu;
        }
 
        public ProgressState getProgressState() {
@@ -289,7 +295,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                                String path = docurl.substring(prefix.length());
                                Document value = getDocumentService().getDocumentByPath(path);
 
-                               _selecdoc = ustep.getDocument(value.getIndex());
+                               _selecdoc = _ustep.getDocument(value.getIndex());
                        } catch (Exception error) {
                                LOGGER.error("Reason:", error);
                        }
@@ -297,16 +303,16 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        }
 
        public void setSelection(final String step) {
-               if (!step.equals(selection)) {
-                       selection = step;
+               if (!step.equals(_selection)) {
+                       _selection = step;
                        _selecdoc = null;
                        setupPreviousToSelectedSteps();
                        updateSimulationContexts(); // Initializes contexts according to the selected steps
                }
-               ustep = involving.get(involving.size() - 1);
-               _urightstep = new StepRights(cuser, ustep);
-               ustep.setActor(cuser);
-               menu.selects(selection); // Updates menu items to be displayed
+               _ustep = _involving.get(_involving.size() - 1);
+               _urightstep = new StepRights(_cuser, _ustep);
+               _ustep.setActor(_cuser);
+               _menu.selects(_selection); // Updates menu items to be displayed
                setupContents(); // The contents may have changed even if the selection is the same
        }
 
@@ -317,10 +323,10 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        protected void add(final Publication doc) {
                DocumentFacade facade = new DocumentFacade(this, doc,
                                getProjectSettings(), getPublicationService());
-               boolean first = (contents.size() == 0);
+               boolean first = (_contents.size() == 0);
 
                docpres.put(doc.getIndex(), facade);
-               contents.add(0, facade); // Prepend the new publication
+               _contents.add(0, facade); // Prepend the new publication
                if (first) {
                        this.getMenu().refreshSelectedItem();
                }
@@ -331,7 +337,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                SimulationContextFacade facade = new SimulationContextFacade(contex,
                                getProjectSettings().getAllSteps());
 
-               context.add(facade);
+               _context.add(facade);
        }
 
        protected void add(final KnowledgeElement kelm) {
@@ -341,7 +347,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                // Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
                // RKV:Begin: Find a knowledge iterator for appropriate knowledge type
                KnowledgeIterator known = null;
-               for (KnowledgeIterator aKnowledgeSection : knowledge) {
+               for (KnowledgeIterator aKnowledgeSection : _knowledge) {
                        if (aKnowledgeSection.getIndex().equals(
                                        String.valueOf(kelm.getType().getIndex()))) {
                                known = aKnowledgeSection;
@@ -350,12 +356,12 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                }
                if (known != null) { // RKV:End
                        knowpres.put(kelm.getIndex(), facade);
-                       known.list.add(facade); // Insert the new knowledge at the end of the corresponding knowledge type
+                       known._list.add(facade); // Insert the new knowledge at the end of the corresponding knowledge type
                }
        }
 
        protected void remove(final Publication doctag) {
-               for (Iterator<DocumentFacade> i = contents.iterator(); i.hasNext();) {
+               for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
                        DocumentFacade facade = i.next();
                        if (!facade.isFacadeOf(doctag)) {
                                continue;
@@ -363,28 +369,28 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                        i.remove();
                        break;
                }
-               if (contents.size() == 0) {
+               if (_contents.size() == 0) {
                        this.getMenu().refreshSelectedItem();
                }
        }
 
        protected void changeUser(final User user) {
-               cuser = user;
-               popup = null;
-               if (getStudyService().isStaffedBy(_mystudy, cuser)) {
-                       popup = getApplicationSettings().getPopupMenu("steditable");
-                       popup.setContext("study", new StudyRights(cuser, _mystudy));
+               _cuser = user;
+               _popup = null;
+               if (getStudyService().isStaffedBy(_mystudy, _cuser)) {
+                       _popup = getApplicationSettings().getPopupMenu("steditable");
+                       _popup.setContext("study", new StudyRights(_cuser, _mystudy));
                }
                // ustep = getProjectElementService().getFirstStep(mystudy);
-               if (ustep != null) {
-                       ustep.setActor(cuser);
+               if (_ustep != null) {
+                       _ustep.setActor(_cuser);
                }
-               _urightstudy = new StudyRights(cuser, _mystudy);
-               _urightstep = new StepRights(cuser, ustep);
+               _urightstudy = new StudyRights(_cuser, _mystudy);
+               _urightstep = new StepRights(_cuser, _ustep);
        }
 
        protected void remove(final SimulationContext contex) {
-               for (Iterator<SimulationContextFacade> i = context.iterator(); i
+               for (Iterator<SimulationContextFacade> i = _context.iterator(); i
                                .hasNext();) {
                        SimulationContextFacade facade = i.next();
                        if (!facade.isFacadeOf(contex)) {
@@ -396,11 +402,11 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        }
 
        protected void remove(final KnowledgeElement kelm) {
-               KnowledgeIterator known = knowledge.get((int) (kelm.getType()
+               KnowledgeIterator known = _knowledge.get((int) (kelm.getType()
                                .getIndex() - 2));
                // Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
                knowpres.remove(kelm.getIndex());
-               for (Iterator<KnowledgeElementFacade> i = known.list.iterator(); i
+               for (Iterator<KnowledgeElementFacade> i = known._list.iterator(); i
                                .hasNext();) {
                        KnowledgeElementFacade facade = i.next();
                        if (!facade.isFacadeOf(BeanHelper.copyBean(kelm,
@@ -427,11 +433,11 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        }
 
        protected void updateSimulationContexts() {
-               context.clear();
-               for (Iterator<Step> i = involving.iterator(); i.hasNext();) {
+               _context.clear();
+               for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
                        for (Iterator<SimulationContext> j = i.next()
                                        .getAllSimulationContexts().iterator(); j.hasNext();) {
-                               context.add(new SimulationContextFacade(j.next(),
+                               _context.add(new SimulationContextFacade(j.next(),
                                                getProjectSettings().getAllSteps()));
                        }
                }
@@ -442,13 +448,13 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
        // ==============================================================================================================================
 
        private void setupPreviousToSelectedSteps() {
-               String[] item = selection.split("\\x2E");
+               String[] item = _selection.split("\\x2E");
                int major = Integer.valueOf(item[0]);
                int minor = Integer.valueOf(item[1]);
                int base = minor;
                Step[] step;
 
-               involving.clear();
+               _involving.clear();
                if (major > 0) {
                        Scenario[] branch = _mystudy.getScenarii();
                        Scenario scenar = branch[0];
@@ -461,7 +467,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                        step = getProjectElementService().getSteps(scenar);
                        base = step[0].getNumber() - 1;
                        for (int i = 0; i + base < minor; i++) {
-                               involving.add(step[i]);
+                               _involving.add(step[i]);
                        }
                }
                step = getProjectElementService().getSteps(_mystudy);
@@ -470,7 +476,7 @@ public class OpenStudy extends OpenObject implements OpenStudyServices {
                        if (firstep.getNumber() > base) {
                                continue;
                        }
-                       involving.add(0, firstep);
+                       _involving.add(0, firstep);
                }
        }