X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Workspace%2FSiman%2Fsrc%2Forg%2Fsplat%2Fsimer%2FOpenStudy.java;h=ed7628ad03204823ca31b14eda4cfc2a87d53587;hb=674a43e57cc119ec231258b1011593886a490cb8;hp=e6190801bf1d92edd4f670094ac5fc78ea7cc00d;hpb=285d6ede657df4c887920757f5986448afab4796;p=tools%2Fsiman.git diff --git a/Workspace/Siman/src/org/splat/simer/OpenStudy.java b/Workspace/Siman/src/org/splat/simer/OpenStudy.java index e619080..ed7628a 100644 --- a/Workspace/Siman/src/org/splat/simer/OpenStudy.java +++ b/Workspace/Siman/src/org/splat/simer/OpenStudy.java @@ -23,6 +23,7 @@ import org.splat.dal.bo.som.Publication; import org.splat.dal.bo.som.Scenario; import org.splat.dal.bo.som.SimulationContext; import org.splat.dal.bo.som.Study; +import org.splat.dal.bo.som.UsesRelation; import org.splat.kernel.Do; import org.splat.log.AppLogger; import org.splat.manox.Toolbox; @@ -63,9 +64,21 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { * User rights on the selected step. */ private transient StepRights _urightstep; + /** + * The study version. + */ private transient String _version; + /** + * The study creation date. + */ private transient String _credate; + /** + * The study modification date. + */ private transient String _lasdate; + /** + * The selected document publication. + */ private transient Publication _selecdoc; /** * Injected step service. @@ -88,9 +101,9 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { */ private StudyService _studyService; - // ============================================================================================================================== + // ========================================================================= // Constructor - // ============================================================================================================================== + // ========================================================================= /** * Open the given study in the current http session. @@ -181,73 +194,149 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { return this; } - // ============================================================================================================================== + // ========================================================================= // Getters - // ============================================================================================================================== + // ========================================================================= + /** + * {@inheritDoc} + * + * @see org.splat.service.dto.Proxy#getAuthorName() + */ @Override public String getAuthorName() { return _mystudy.getAuthor().toString(); } + /** + * {@inheritDoc} + * + * @see org.splat.service.dto.Proxy#getIndex() + */ @Override public Long getIndex() { return _mystudy.getIndex(); } + /** + * Get creation date. + * + * @return the date + */ public String getDate() { return _credate; } + /** + * {@inheritDoc} + * + * @see org.splat.simer.AbstractOpenObject#getMenu() + */ @Override public StudyMenu getMenu() { return (StudyMenu) _menu; } + /** + * Set study menu. + * + * @param aMenu + * the study menu + */ public void setMenu(final StudyMenu aMenu) { _menu = aMenu; } + /** + * {@inheritDoc} + * + * @see org.splat.service.dto.Proxy#getProgressState() + */ @Override public ProgressState getProgressState() { return _mystudy.getProgressState(); } + /** + * Get last modification date. + * + * @return the date + */ public String getLastModificationDate() { return _lasdate; } + /** + * Get the toolbar with buttons of available modules. + * + * @return the toolbar + */ public ToolBar getModuleBar() { return getApplicationSettings().getModuleBar(getSelectedStep()); } + /** + * {@inheritDoc} + * + * @see org.splat.service.dto.Proxy#getReference() + */ @Override public String getReference() { return _mystudy.getReference(); } + /** + * {@inheritDoc} + * + * @see org.splat.simer.OpenStudyServices#getSelectedDocument() + */ @Override public Publication getSelectedDocument() { return _selecdoc; } + /** + * Get user rights for the selected step. + * + * @return user step rights + */ public StepRights getSelectedStepRights() { return _urightstep; } + /** + * Get user rights for the study. + * + * @return user study rights + */ public StudyRights getStudyRights() { return _urightstudy; } + /** + * Get the detached study object. + * + * @return the detached study object + */ public Study getStudyObject() { return _mystudy; } + /** + * {@inheritDoc} + * + * @see org.splat.service.dto.Proxy#getTitle() + */ @Override public String getTitle() { return _mystudy.getTitle(); } + /** + * {@inheritDoc} + * + * @see org.splat.service.dto.Proxy#getType() + */ @Override public String getType() { /* @@ -256,17 +345,27 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { return Constants.STUDY_MENU; } + /** + * Get the study version. + * + * @return the version string + */ public String getVersion() { return _version; } + /** + * Check if the selected step is enabled for writing. + * + * @return true if the selected step is enabled for writing + */ public boolean isStepEnabled() { return _urightstep.isEnabled(); } - // ============================================================================================================================== + // ========================================================================= // Public services - // ============================================================================================================================== + // ========================================================================= @Override public URL newTemplateBasedDocument(final String typename, final User author) { @@ -352,6 +451,12 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { } } + /** + * Select an activity (step). + * + * @param step + * the key of the step to select + */ public void setSelection(final String step) { if (!step.equals(_selection)) { _selection = step; @@ -366,10 +471,16 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { setupContents(); // The contents may have changed even if the selection is the same } - // ============================================================================================================================== + // ========================================================================= // Protected services - // ============================================================================================================================== + // ========================================================================= + /** + * Add a new document presentation facade. + * + * @param doc + * the document publication + */ protected void add(final Publication doc) { DocumentFacade facade = new DocumentFacade(this, doc, getProjectSettings(), getPublicationService(), @@ -381,9 +492,18 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { if (first) { this.getMenu().refreshSelectedItem(); } - + // Refresh dependencies. They can not be removed until removing this document. + for (Publication pub : doc.getRelations(UsesRelation.class)) { + update(pub); + } } + /** + * Add a simulation context presentation facade. + * + * @param contex + * the simulation context to add + */ protected void add(final SimulationContext contex) { SimulationContextFacade facade = new SimulationContextFacade(contex, getProjectSettings().getAllSteps(), getApplicationSettings()); @@ -391,6 +511,12 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { _context.add(facade); } + /** + * Add a knowledge element presentation facade. + * + * @param kelm + * the knowledge element to add + */ protected void add(final KnowledgeElement kelm) { KnowledgeElementFacade facade = new KnowledgeElementFacade(BeanHelper .copyBean(kelm, KnowledgeElementDTO.class), @@ -412,6 +538,12 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { } } + /** + * Remove the document presentation facade. + * + * @param doctag + * the document publication to remove + */ protected void remove(final Publication doctag) { for (Iterator i = _contents.iterator(); i.hasNext();) { DocumentFacade facade = i.next(); @@ -425,6 +557,12 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { } } + /** + * Change the currently connected user and refresh user's rights. + * + * @param user + * the new connected user + */ protected void changeUser(final User user) { _cuser = user; _popup = null; @@ -442,18 +580,29 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { _urightstep = new StepRights(_cuser, _ustep); } + /** + * Remove the simulation context presentation facade. + * + * @param contex + * the simulation context to remove + */ protected void remove(final SimulationContext contex) { for (Iterator i = _context.iterator(); i .hasNext();) { SimulationContextFacade facade = i.next(); - if (!facade.isFacadeOf(contex)) { - continue; + if (facade.isFacadeOf(contex)) { + i.remove(); + break; } - i.remove(); - break; } } + /** + * Remove the knowledge element presentation facade. + * + * @param kelm + * the knowledge element to remove + */ protected void remove(final KnowledgeElement kelm) { // RKV: KnowledgeIterator known = _knowledge.get((int) (kelm.getType() // RKV: .getIndex() - 2)); @@ -482,6 +631,12 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { } } + /** + * Refresh the document presentation facade. + * + * @param doc + * the document publication + */ protected void update(final Publication doc) { DocumentFacade facade = _docpres.get(doc.getIndex()); if (facade != null) { @@ -489,6 +644,12 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { } } + /** + * Refresh the knowledge element presentation facade. + * + * @param kelm + * the knowledge element DTO + */ protected void update(final KnowledgeElementDTO kelm) { KnowledgeElementFacade facade = _knowpres.get(kelm.getIndex()); if (facade != null) { @@ -496,6 +657,9 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { } } + /** + * Refresh simulation contexts presentation facades. + */ protected void updateSimulationContexts() { _context.clear(); for (Iterator i = _involving.iterator(); i.hasNext();) { @@ -508,9 +672,9 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { } } - // ============================================================================================================================== + // ========================================================================= // Private services - // ============================================================================================================================== + // ========================================================================= private void setupPreviousToSelectedSteps() { String[] item = _selection.split("\\x2E"); @@ -640,10 +804,21 @@ public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { _documentService = documentService; } + /** + * Get the detached study object. + * + * @return the detached study object + */ public Study getMystudy() { return _mystudy; } + /** + * Set the study to present. + * + * @param mystudy + * the selected study detached object + */ public void setMystudy(final Study mystudy) { this._mystudy = mystudy; }