X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Workspace%2FSiman%2Fsrc%2Forg%2Fsplat%2Fsimer%2FOpenStudy.java;h=e6190801bf1d92edd4f670094ac5fc78ea7cc00d;hb=eb90d68aafe1fbc1307dd1121500a97ffd940d21;hp=d869148add43abd13a6089ac250dc860ecb64888;hpb=967487668f1719e7a8d80d55bd5377e0170a1b25;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 d869148..e619080 100644 --- a/Workspace/Siman/src/org/splat/simer/OpenStudy.java +++ b/Workspace/Siman/src/org/splat/simer/OpenStudy.java @@ -1,4 +1,5 @@ package org.splat.simer; + /** * * @author Daniel Brunier-Coulin @@ -13,393 +14,637 @@ import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; -import org.apache.log4j.Logger; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.Transaction; +import org.splat.dal.bo.kernel.User; +import org.splat.dal.bo.som.Document; +import org.splat.dal.bo.som.DocumentType; +import org.splat.dal.bo.som.KnowledgeElement; +import org.splat.dal.bo.som.ProgressState; +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.kernel.Do; -import org.splat.kernel.User; +import org.splat.log.AppLogger; import org.splat.manox.Toolbox; import org.splat.manox.Writer; -import org.splat.som.Database; -import org.splat.som.Document; -import org.splat.som.DocumentType; -import org.splat.som.KnowledgeElement; -import org.splat.som.ProgressState; -import org.splat.som.ProjectSettings; -import org.splat.som.Publication; +import org.splat.service.DocumentService; +import org.splat.service.DocumentTypeService; +import org.splat.service.StepService; +import org.splat.service.StudyService; +import org.splat.service.dto.KnowledgeElementDTO; +import org.splat.service.technical.RepositoryService; import org.splat.som.Revision; -import org.splat.som.Scenario; -import org.splat.som.SimulationContext; import org.splat.som.Step; import org.splat.som.StepRights; -import org.splat.som.Study; import org.splat.som.StudyRights; +import org.splat.util.BeanHelper; +import org.splat.wapp.Constants; import org.splat.wapp.ToolBar; - -public class OpenStudy extends OpenObject implements OpenStudyServices { - - private Study mystudy; - private StudyRights urightstudy; // User rights on the open study - private StepRights urightstep; // User rights on the selected step - private String version; - private String credate; - private String lasdate; - private Publication selecdoc; - - protected final static Logger logger = org.splat.simer.Action.logger; - -// ============================================================================================================================== -// Constructor -// ============================================================================================================================== - - public OpenStudy (User user, Study study) { -// ----------------------------------------- - ResourceBundle custom = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale()); - SimpleDateFormat datstring = new SimpleDateFormat(custom.getString("date.format")); - Revision.Format verstring = new Revision.Format(ProjectSettings.getRevisionPattern()); - - cuser = user; // May be null if nobody connected - mystudy = study; - 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(1); - context = new ArrayList(); - ustep = mystudy.getFirstStep(); - ustep.setActor(cuser); - involving.add(ustep); - for (Iterator i=ustep.getAllSimulationContexts().iterator(); i.hasNext(); ) { - context.add( new SimulationContextFacade(i.next()) ); - } - if (mystudy.isStaffedBy(cuser) || mystudy.hasActor(cuser)) { -// ProgressState state = mystudy.getProgressState(); -// if (state == ProgressState.inCHECK) popup = ApplicationSettings.getPopupMenu("stapprovable"); -// else if (state == ProgressState.APPROVED) popup = ApplicationSettings.getPopupMenu("stapproved"); -/* else */ popup = ApplicationSettings.getPopupMenu("steditable"); - popup.setContext("study", new StudyRights(cuser, mystudy)); - } - urightstudy = new StudyRights(cuser, mystudy); - urightstep = new StepRights(cuser, ustep); - - menu = new StudyMenu(mystudy); - menu.selects(selection); // Initializes menu items to be displayed - setupContents(); // Initializes documents and knowledge at ustep - } - -// ============================================================================================================================== -// Getters -// ============================================================================================================================== - - public String getAuthorName() { -// ----------------------------- - return mystudy.getAuthor().toString(); - } - public Integer getIndex() { -// ------------------------- - return mystudy.getIndex(); - } - public String getDate () { -// ------------------------ - return credate; - } - public StudyMenu getMenu () { -// --------------------------- - return (StudyMenu)menu; - } - public ProgressState getProgressState() { -// ---------------------------------------- - return mystudy.getProgressState(); - } - public String getLastModificationDate () { -// ---------------------------------------- - return lasdate; - } - public ToolBar getModuleBar () { -// ------------------------------ - return ApplicationSettings.getMe().getModuleBar(getSelectedStep()); - } - public String getReference() { -// ---------------------------- - return mystudy.getReference(); - } - public Publication getSelectedDocument () { -// ----------------------------------------- - return selecdoc; - } - public StepRights getSelectedStepRights () { -// ------------------------------------------ - return urightstep; - } - public StudyRights getStudyRights () { -// ------------------------------------ - return urightstudy; - } - public Study getStudyObject () { -// ------------------------------ - return mystudy; - } - public String getTitle() { -// ------------------------ - return mystudy.getTitle(); - } - public String getType () { -// ------------------------ - return ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale()).getString("label.study"); - } - public String getVersion () { -// --------------------------- - return version; - } - public boolean isStepEnabled () { -// ------------------------------- - return urightstep.isEnabled(); - } - -// ============================================================================================================================== -// Public services -// ============================================================================================================================== - - public URL newTemplateBasedDocument (String typename, User author) { -// ------------------------------------------------------------------ - String filename = typename + ".xml"; // Only XML templates are writeable - File template = new File(Database.getTemplatePath() + filename); - if (!template.exists()) return null; - - Session connex = Database.getSession(); - Transaction transax = connex.beginTransaction(); - try { - File udir = Database.getDownloadDirectory(author); - File credoc = new File(udir.getPath() + "/" + filename); - -// Creation of the meta-document - Step step = getSelectedStep(); // Should we check if the given document type is compatible ? - DocumentType type = Document.selectType(typename); - Document.Properties dprop = new Document.Properties(); - Document medoc = step.createDocument(dprop.setType(type).setFormat("xml").setAuthor(author)).value(); - transax.commit(); - -// Instantiation of the template into the user download directory - if (!udir.exists()) udir.mkdir(); - if (credoc.exists()) credoc.delete(); - Do.copy(template, credoc); - -// Transfer to the document of all known properties - ResourceBundle locale = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale()); - SimpleDateFormat get = new SimpleDateFormat(locale.getString("date.format")); - Writer tool = Toolbox.getWriter(credoc); - List slist = getInvolvedSteps(); - for (Iterator i=slist.iterator(); i.hasNext(); ) { - List clist = i.next().getAllSimulationContexts(); - for (Iterator j=clist.iterator(); j.hasNext(); ) { - SimulationContext context = j.next(); - tool.updateProperty(context.getType().getName(), context.getValue()); - } - } - tool.updateProperty("reference", medoc.getReference()); - tool.updateProperty("study", mystudy.getTitle()); - tool.updateProperty("step", locale.getString("folder.step." + step.getNumber()).replaceAll("''", "'")); - tool.updateProperty("author", author.getUsername().toUpperCase()); - tool.updateProperty("date", get.format(medoc.getCreationDate())); - tool.updateProperty("history", locale.getString("label.creation").replaceAll("''", "'")); - tool.save(); - - return new URL(ApplicationSettings.getDownloadURL(author) + filename); - } - catch (Exception saverror) { - logger.error("Reason:", saverror); - if (transax != null && transax.isActive()) { -// Second try-catch as the rollback could fail as well - try { - transax.rollback(); - } catch (HibernateException backerror) { - logger.debug("Error rolling back transaction", backerror); - } - } - return null; - } - } - - public void selectDocument (String docurl) { -// ------------------------------------------ - String prefix = ApplicationSettings.getRepositoryURL(); - - if (docurl.startsWith(prefix)) try { - Session connex = Database.getSession(); - Transaction transax = connex.beginTransaction(); - String path = docurl.substring(prefix.length()); - String[] parse = path.split("'"); - - path = parse[0]; - for (int i=1; i i=contents.iterator(); i.hasNext(); ) { - DocumentFacade facade = i.next(); - if (!facade.isFacadeOf(doctag)) continue; - i.remove(); - break; - } - if (contents.size() == 0) this.getMenu().refreshSelectedItem(); - } - - protected void changeUser (User user) { -// ------------------------------------- - cuser = user; - popup = null; - if (mystudy.isStaffedBy(cuser)) { - popup = ApplicationSettings.getPopupMenu("steditable"); - popup.setContext("study", new StudyRights(cuser, mystudy)); - } - ustep.setActor(cuser); - urightstudy = new StudyRights(cuser, mystudy); - urightstep = new StepRights(cuser, ustep); - } - - protected void remove (SimulationContext contex) { -// ------------------------------------------------ - for (Iterator i=context.iterator(); i.hasNext(); ) { - SimulationContextFacade facade = i.next(); - if (!facade.isFacadeOf(contex)) continue; - i.remove(); - break; - } - } - - protected void remove (KnowledgeElement kelm) { -// --------------------------------------------- - KnowledgeIterator known = knowledge.get(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 i=known.list.iterator(); i.hasNext(); ) { - KnowledgeElementFacade facade = i.next(); - if (!facade.isFacadeOf(kelm)) continue; - i.remove(); - break; - } - } - - protected void update (Publication doc) { -// --------------------------------------- - DocumentFacade facade = docpres.get(doc.getIndex()); - if (facade != null) { - facade.refresh(); - } - } - - protected void update (KnowledgeElement kelm) { -// --------------------------------------------- - KnowledgeElementFacade facade = knowpres.get(kelm.getIndex()); - if (facade != null) { - facade.refresh(); - } - } - - protected void updateSimulationContexts () { -// ------------------------------------------ - context.clear(); - for (Iterator i=involving.iterator(); i.hasNext(); ) { - for (Iterator j=i.next().getAllSimulationContexts().iterator(); j.hasNext(); ) { - context.add( new SimulationContextFacade(j.next()) ); - } - } - } - -// ============================================================================================================================== -// Private services -// ============================================================================================================================== - - private void setupPreviousToSelectedSteps () { -// -------------------------------------------- - String[] item = selection.split("\\x2E"); - int major = Integer.valueOf(item[0]); - int minor = Integer.valueOf(item[1]); - int base = minor; - Step[] step; - - involving.clear(); - if (major > 0) { - Scenario[] branch = mystudy.getScenarii(); - Scenario scenar = branch[0]; - for (int i=0; i-1; i--) { - Step firstep = step[i]; - if(firstep.getNumber() > base) continue; - involving.add(0, firstep); - } - } +/** + * Presentation of the currently open study. + */ +public class OpenStudy extends AbstractOpenObject implements OpenStudyServices { + + /** + * Serial version ID. + */ + protected final static AppLogger LOGGER = org.splat.simer.Action.LOG; + + /** + * The currently open study. + */ + private transient Study _mystudy; + /** + * 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; + private transient Publication _selecdoc; + /** + * Injected step service. + */ + private StepService _stepService; + /** + * Injected repository service. + */ + private RepositoryService _repositoryService; + /** + * Injected document type service. + */ + private DocumentTypeService _documentTypeService; + /** + * Injected document service. + */ + private DocumentService _documentService; + /** + * The injected Study service. + */ + private StudyService _studyService; + + // ============================================================================================================================== + // Constructor + // ============================================================================================================================== + + /** + * Open the given study in the current http session. + * + * @param user + * the current user + * @param study + * the study to open + * @return this open study object + */ + public OpenStudy open(final User user, final Study study) { + ResourceBundle custom = ResourceBundle.getBundle("som", + getApplicationSettings().getCurrentLocale()); + SimpleDateFormat datstring = new SimpleDateFormat(custom + .getString("date.format"), getApplicationSettings() + .getCurrentLocale()); + Revision.Format verstring = new Revision.Format(getProjectSettings() + .getRevisionPattern()); + + _cuser = user; // May be null if nobody connected + _mystudy = study; + _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(1); + _context = new ArrayList(); + _ustep = getProjectElementService().getFirstStep(_mystudy); + _ustep.setActor(_cuser); + _involving.add(_ustep); + for (Iterator i = _ustep.getAllSimulationContexts() + .iterator(); i.hasNext();) { + _context.add(new SimulationContextFacade(i.next(), + getProjectSettings().getAllSteps(), + getApplicationSettings())); + } + 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 */ + + if (_mystudy.getProgressState() == ProgressState.TEMPLATE) { + if (_mystudy.isPublic()) { + _popup = getApplicationSettings().getPopupMenu( + "steditableunmarkprivate"); + } else { + _popup = getApplicationSettings().getPopupMenu( + "steditableunmarkpublic"); + } + } else { + + if (_mystudy.isPublic()) { + _popup = getApplicationSettings().getPopupMenu( + "steditablemarkprivate"); + } else { + if (_mystudy.getProgressState() == ProgressState.inWORK) { + _popup = getApplicationSettings().getPopupMenu( + "steditable"); + } else if (_mystudy.getProgressState() == ProgressState.inDRAFT) { + _popup = getApplicationSettings().getPopupMenu( + "streviewable"); + } else if (_mystudy.getProgressState() == ProgressState.inCHECK) { + _popup = getApplicationSettings().getPopupMenu( + "stapprovable"); + } else { // APPROVED + _popup = getApplicationSettings().getPopupMenu( + "steditablemarkpublic"); + } + } + + } + _popup.setContext(Constants.STUDY_MENU, new StudyRights(_cuser, + _mystudy)); + } + _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 + setupContents(); // Initializes documents and knowledge at ustep + return this; + } + + // ============================================================================================================================== + // Getters + // ============================================================================================================================== + + @Override + public String getAuthorName() { + return _mystudy.getAuthor().toString(); + } + + @Override + public Long getIndex() { + return _mystudy.getIndex(); + } + + public String getDate() { + return _credate; + } + + @Override + public StudyMenu getMenu() { + return (StudyMenu) _menu; + } + + public void setMenu(final StudyMenu aMenu) { + _menu = aMenu; + } + + @Override + public ProgressState getProgressState() { + return _mystudy.getProgressState(); + } + + public String getLastModificationDate() { + return _lasdate; + } + + public ToolBar getModuleBar() { + return getApplicationSettings().getModuleBar(getSelectedStep()); + } + + @Override + public String getReference() { + return _mystudy.getReference(); + } + + @Override + public Publication getSelectedDocument() { + return _selecdoc; + } + + public StepRights getSelectedStepRights() { + return _urightstep; + } + + public StudyRights getStudyRights() { + return _urightstudy; + } + + public Study getStudyObject() { + return _mystudy; + } + + @Override + public String getTitle() { + return _mystudy.getTitle(); + } + + @Override + public String getType() { + /* + * RKV: return ResourceBundle.getBundle("labels", getApplicationSettings().getCurrentLocale()).getString( "label.study"); + */ + return Constants.STUDY_MENU; + } + + public String getVersion() { + return _version; + } + + public boolean isStepEnabled() { + return _urightstep.isEnabled(); + } + + // ============================================================================================================================== + // Public services + // ============================================================================================================================== + + @Override + public URL newTemplateBasedDocument(final String typename, final User author) { + String filename = typename + ".xml"; // Only XML templates are writeable + File template = new File(getRepositoryService().getTemplatePath() + + filename); + if (!template.exists()) { + return null; + } + + // Session connex = Database.getCurSession(); + // Transaction transax = connex.beginTransaction(); + try { + File udir = getRepositoryService().getDownloadDirectory(author); + File credoc = new File(udir.getPath() + "/" + filename); + + // Creation of the meta-document + Step step = getSelectedStep(); // Should we check if the given document type is compatible ? + DocumentType type = getDocumentTypeService().selectType(typename); + Document.Properties dprop = new Document.Properties(); + Document medoc = getStepService().createDocument(step, + dprop.setType(type).setFormat("xml").setAuthor(author)) + .value(); + // transax.commit(); + + // Instantiation of the template into the user download directory + if (!udir.exists()) { + udir.mkdir(); + } + if (credoc.exists()) { + credoc.delete(); + } + Do.copy(template, credoc); + + // Transfer to the document of all known properties + ResourceBundle locale = ResourceBundle.getBundle("som", + getApplicationSettings().getCurrentLocale()); + SimpleDateFormat get = new SimpleDateFormat(locale + .getString("date.format"), getApplicationSettings() + .getCurrentLocale()); + Writer tool = Toolbox.getWriter(credoc); + List slist = getInvolvedSteps(); + for (Iterator i = slist.iterator(); i.hasNext();) { + List clist = i.next() + .getAllSimulationContexts(); + for (Iterator j = clist.iterator(); j + .hasNext();) { + SimulationContext context = j.next(); + tool.updateProperty(context.getType().getName(), context + .getValue()); + } + } + tool.updateProperty("reference", medoc.getReference()); + tool.updateProperty(Constants.STUDY_MENU, _mystudy.getTitle()); + tool.updateProperty("step", locale.getString( + "folder.step." + step.getNumber()).replaceAll("''", "'")); + tool.updateProperty("author", author.getUsername().toUpperCase()); + tool.updateProperty("date", get.format(medoc.getCreationDate())); + tool.updateProperty("history", locale.getString("label.creation") + .replaceAll("''", "'")); + tool.save(); + + return new URL(getApplicationSettings().getDownloadURL(author) + + filename); + } catch (Exception saverror) { + LOGGER.error("Reason:", saverror); + return null; + } + } + + public void selectDocument(final String docurl) { + String prefix = getApplicationSettings().getRepositoryURL(); + + if (docurl.startsWith(prefix)) { + try { + String path = docurl.substring(prefix.length()); + Document value = getDocumentService().getDocumentByPath(path); + + _selecdoc = _ustep.getDocument(value.getIndex()); + } catch (Exception error) { + LOGGER.error("Reason:", error); + } + } + } + + public void setSelection(final String 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 + setupContents(); // The contents may have changed even if the selection is the same + } + + // ============================================================================================================================== + // Protected services + // ============================================================================================================================== + + protected void add(final Publication doc) { + DocumentFacade facade = new DocumentFacade(this, doc, + getProjectSettings(), getPublicationService(), + getApplicationSettings()); + boolean first = (_contents.size() == 0); + + _docpres.put(doc.getIndex(), facade); + _contents.add(0, facade); // Prepend the new publication + if (first) { + this.getMenu().refreshSelectedItem(); + } + + } + + protected void add(final SimulationContext contex) { + SimulationContextFacade facade = new SimulationContextFacade(contex, + getProjectSettings().getAllSteps(), getApplicationSettings()); + + _context.add(facade); + } + + protected void add(final KnowledgeElement kelm) { + KnowledgeElementFacade facade = new KnowledgeElementFacade(BeanHelper + .copyBean(kelm, KnowledgeElementDTO.class), + getApplicationSettings()); + // RKV KnowledgeIterator known = knowledge.get(kelm.getType().getIndex() - 2); + // 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) { + if (aKnowledgeSection.getIndex().equals( + String.valueOf(kelm.getType().getIndex()))) { + known = aKnowledgeSection; + break; + } + } + 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 + } + } + + protected void remove(final Publication doctag) { + for (Iterator i = _contents.iterator(); i.hasNext();) { + DocumentFacade facade = i.next(); + if (facade.isFacadeOf(doctag)) { + i.remove(); + break; + } + } + 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( + "steditablemarkpublic"); + _popup.setContext(Constants.STUDY_MENU, new StudyRights(_cuser, + _mystudy)); + } + // ustep = getProjectElementService().getFirstStep(mystudy); + if (_ustep != null) { + _ustep.setActor(_cuser); + } + _urightstudy = new StudyRights(_cuser, _mystudy); + _urightstep = new StepRights(_cuser, _ustep); + } + + protected void remove(final SimulationContext contex) { + for (Iterator i = _context.iterator(); i + .hasNext();) { + SimulationContextFacade facade = i.next(); + if (!facade.isFacadeOf(contex)) { + continue; + } + i.remove(); + break; + } + } + + protected void remove(final KnowledgeElement kelm) { + // RKV: KnowledgeIterator known = _knowledge.get((int) (kelm.getType() + // RKV: .getIndex() - 2)); + // 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) { + if (aKnowledgeSection.getIndex().equals( + String.valueOf(kelm.getType().getIndex()))) { + known = aKnowledgeSection; + break; + } + } + if (known != null) { // RKV:End + _knowpres.remove(kelm.getIndex()); + for (Iterator i = known._list.iterator(); i + .hasNext();) { + KnowledgeElementFacade facade = i.next(); + if (!facade.isFacadeOf(BeanHelper.copyBean(kelm, + KnowledgeElementDTO.class))) { + continue; + } + i.remove(); + break; + } + } + } + + protected void update(final Publication doc) { + DocumentFacade facade = _docpres.get(doc.getIndex()); + if (facade != null) { + facade.refresh(); + } + } + + protected void update(final KnowledgeElementDTO kelm) { + KnowledgeElementFacade facade = _knowpres.get(kelm.getIndex()); + if (facade != null) { + facade.refresh(kelm); + } + } + + protected void updateSimulationContexts() { + _context.clear(); + for (Iterator i = _involving.iterator(); i.hasNext();) { + for (Iterator j = i.next() + .getAllSimulationContexts().iterator(); j.hasNext();) { + _context.add(new SimulationContextFacade(j.next(), + getProjectSettings().getAllSteps(), + getApplicationSettings())); + } + } + } + + // ============================================================================================================================== + // Private services + // ============================================================================================================================== + + private void setupPreviousToSelectedSteps() { + String[] item = _selection.split("\\x2E"); + int major = Integer.valueOf(item[0]); + int minor = Integer.valueOf(item[1]); + int base = minor; + Step[] step; + + _involving.clear(); + if (major > 0) { + Scenario[] branch = _mystudy.getScenarii(); + Scenario scenar = branch[0]; + for (int i = 0; i < branch.length; i++) { + scenar = branch[i]; + if (scenar.getIndex() == major) { + break; // Supposed exist + } + } + step = getProjectElementService().getSteps(scenar); + base = step[0].getNumber() - 1; + for (int i = 0; i + base < minor; i++) { + _involving.add(step[i]); + } + } + step = getProjectElementService().getSteps(_mystudy); + for (int i = step.length - 1; i > -1; i--) { + Step firstep = step[i]; + if (firstep.getNumber() <= base) { + _involving.add(0, firstep); + } + } + } + + /** + * Get the stepService. + * + * @return the stepService + */ + public StepService getStepService() { + return _stepService; + } + + /** + * Set the stepService. + * + * @param stepService + * the stepService to set + */ + public void setStepService(final StepService stepService) { + _stepService = stepService; + } + + /** + * Get the repositoryService. + * + * @return the repositoryService + */ + public RepositoryService getRepositoryService() { + return _repositoryService; + } + + /** + * Set the repositoryService. + * + * @param repositoryService + * the repositoryService to set + */ + public void setRepositoryService(final RepositoryService repositoryService) { + _repositoryService = repositoryService; + } + + /** + * Get the documentTypeService. + * + * @return the documentTypeService + */ + public DocumentTypeService getDocumentTypeService() { + return _documentTypeService; + } + + /** + * Set the documentTypeService. + * + * @param documentTypeService + * the documentTypeService to set + */ + public void setDocumentTypeService( + final DocumentTypeService documentTypeService) { + _documentTypeService = documentTypeService; + } + + /** + * Get the studyService. + * + * @return the studyService + */ + public StudyService getStudyService() { + return _studyService; + } + + /** + * Set the studyService. + * + * @param studyService + * the studyService to set + */ + public void setStudyService(final StudyService studyService) { + _studyService = studyService; + } + + /** + * Get the documentService. + * + * @return the documentService + */ + public DocumentService getDocumentService() { + return _documentService; + } + + /** + * Set the documentService. + * + * @param documentService + * the documentService to set + */ + public void setDocumentService(final DocumentService documentService) { + _documentService = documentService; + } + + public Study getMystudy() { + return _mystudy; + } + + public void setMystudy(final Study mystudy) { + this._mystudy = mystudy; + } } \ No newline at end of file