Salome HOME
It was impossible to edit the body of the knowledge when the ordered or unordered...
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / OpenStudy.java
1 package org.splat.simer;
2
3 /**
4  * 
5  * @author    Daniel Brunier-Coulin
6  * @copyright OPEN CASCADE 2012
7  */
8
9 import java.io.File;
10 import java.net.URL;
11 import java.text.SimpleDateFormat;
12 import java.util.ArrayList;
13 import java.util.Iterator;
14 import java.util.List;
15 import java.util.ResourceBundle;
16
17 import org.splat.dal.bo.kernel.User;
18 import org.splat.dal.bo.som.Document;
19 import org.splat.dal.bo.som.DocumentType;
20 import org.splat.dal.bo.som.KnowledgeElement;
21 import org.splat.dal.bo.som.ProgressState;
22 import org.splat.dal.bo.som.Publication;
23 import org.splat.dal.bo.som.Scenario;
24 import org.splat.dal.bo.som.SimulationContext;
25 import org.splat.dal.bo.som.Study;
26 import org.splat.dal.bo.som.UsesRelation;
27 import org.splat.kernel.Do;
28 import org.splat.log.AppLogger;
29 import org.splat.manox.Toolbox;
30 import org.splat.manox.Writer;
31 import org.splat.service.DocumentService;
32 import org.splat.service.DocumentTypeService;
33 import org.splat.service.StepService;
34 import org.splat.service.StudyService;
35 import org.splat.service.dto.KnowledgeElementDTO;
36 import org.splat.service.technical.RepositoryService;
37 import org.splat.som.Revision;
38 import org.splat.som.Step;
39 import org.splat.som.StepRights;
40 import org.splat.som.StudyRights;
41 import org.splat.util.BeanHelper;
42 import org.splat.wapp.Constants;
43 import org.splat.wapp.ToolBar;
44
45 /**
46  * Presentation of the currently open study.
47  */
48 public class OpenStudy extends AbstractOpenObject implements OpenStudyServices {
49
50         /**
51          * Serial version ID.
52          */
53         protected final static AppLogger LOGGER = org.splat.simer.Action.LOG;
54
55         /**
56          * The currently open study.
57          */
58         private transient Study _mystudy;
59         /**
60          * User rights on the open study.
61          */
62         private transient StudyRights _urightstudy;
63         /**
64          * User rights on the selected step.
65          */
66         private transient StepRights _urightstep;
67         /**
68          * The study version.
69          */
70         private transient String _version;
71         /**
72          * The study creation date.
73          */
74         private transient String _credate;
75         /**
76          * The study modification date.
77          */
78         private transient String _lasdate;
79         /**
80          * The selected document publication.
81          */
82         private transient Publication _selecdoc;
83         /**
84          * Injected step service.
85          */
86         private StepService _stepService;
87         /**
88          * Injected repository service.
89          */
90         private RepositoryService _repositoryService;
91         /**
92          * Injected document type service.
93          */
94         private DocumentTypeService _documentTypeService;
95         /**
96          * Injected document service.
97          */
98         private DocumentService _documentService;
99         /**
100          * The injected Study service.
101          */
102         private StudyService _studyService;
103
104         // =========================================================================
105         // Constructor
106         // =========================================================================
107
108         /**
109          * Open the given study in the current http session.
110          * 
111          * @param user
112          *            the current user
113          * @param study
114          *            the study to open
115          * @return this open study object
116          */
117         public OpenStudy open(final User user, final Study study) {
118                 ResourceBundle custom = ResourceBundle.getBundle("som",
119                                 getApplicationSettings().getCurrentLocale());
120                 SimpleDateFormat datstring = new SimpleDateFormat(custom
121                                 .getString("date.format"), getApplicationSettings()
122                                 .getCurrentLocale());
123                 Revision.Format verstring = new Revision.Format(getProjectSettings()
124                                 .getRevisionPattern());
125
126                 _cuser = user; // May be null if nobody connected
127                 _mystudy = study;
128                 _selection = "0.1"; // Default selection
129                 _selecdoc = null;
130
131                 // Preparation of the display
132                 _version = verstring.format(_mystudy.getVersion());
133                 _credate = datstring.format(_mystudy.getDate());
134                 _lasdate = datstring.format(_mystudy.getLastModificationDate());
135                 _description = _mystudy.getDescription();
136                 _involving = new ArrayList<Step>(1);
137                 _context = new ArrayList<SimulationContextFacade>();
138                 _ustep = getProjectElementService().getFirstStep(_mystudy);
139                 _ustep.setActor(_cuser);
140                 _involving.add(_ustep);
141                 for (Iterator<SimulationContext> i = _ustep.getAllSimulationContexts()
142                                 .iterator(); i.hasNext();) {
143                         _context.add(new SimulationContextFacade(i.next(),
144                                         getProjectSettings().getAllSteps(),
145                                         getApplicationSettings()));
146                 }
147                 if (getStudyService().isStaffedBy(_mystudy, _cuser)
148                                 || getStudyService().hasActor(_mystudy, _cuser)) {
149                         // ProgressState state = mystudy.getProgressState();
150                         // if (state == ProgressState.inCHECK) popup = getApplicationSettings().getPopupMenu("stapprovable");
151                         // else if (state == ProgressState.APPROVED) popup = getApplicationSettings().getPopupMenu("stapproved");
152                         /* else */
153
154                         if (_mystudy.getProgressState() == ProgressState.TEMPLATE) {
155                                 if (_mystudy.isPublic()) {
156                                         _popup = getApplicationSettings().getPopupMenu(
157                                                         "steditableunmarkprivate");
158                                 } else {
159                                         _popup = getApplicationSettings().getPopupMenu(
160                                                         "steditableunmarkpublic");
161                                 }
162                         } else {
163
164                                 if (_mystudy.isPublic()) {
165                                         _popup = getApplicationSettings().getPopupMenu(
166                                                         "steditablemarkprivate");
167                                 } else {
168                                         if (_mystudy.getProgressState() == ProgressState.inWORK) {
169                                                 _popup = getApplicationSettings().getPopupMenu(
170                                                                 "steditable");
171                                         } else if (_mystudy.getProgressState() == ProgressState.inDRAFT) {
172                                                 _popup = getApplicationSettings().getPopupMenu(
173                                                                 "streviewable");
174                                         } else if (_mystudy.getProgressState() == ProgressState.inCHECK) {
175                                                 _popup = getApplicationSettings().getPopupMenu(
176                                                                 "stapprovable");
177                                         } else { // APPROVED
178                                                 _popup = getApplicationSettings().getPopupMenu(
179                                                                 "steditablemarkpublic");
180                                         }
181                                 }
182
183                         }
184                         _popup.setContext(Constants.STUDY_MENU, new StudyRights(_cuser,
185                                         _mystudy));
186                 }
187                 _urightstudy = new StudyRights(_cuser, _mystudy);
188                 _urightstep = new StepRights(_cuser, _ustep);
189
190                 // RKV menu = new StudyMenu(mystudy);
191                 _menu = (getMenu()).init(_mystudy); // RKV
192                 _menu.selects(_selection); // Initializes menu items to be displayed
193                 setupContents(); // Initializes documents and knowledge at ustep
194                 return this;
195         }
196
197         // =========================================================================
198         // Getters
199         // =========================================================================
200
201         /**
202          * {@inheritDoc}
203          * 
204          * @see org.splat.service.dto.Proxy#getAuthorName()
205          */
206         @Override
207         public String getAuthorName() {
208                 return _mystudy.getAuthor().toString();
209         }
210
211         /**
212          * {@inheritDoc}
213          * 
214          * @see org.splat.service.dto.Proxy#getIndex()
215          */
216         @Override
217         public Long getIndex() {
218                 return _mystudy.getIndex();
219         }
220
221         /**
222          * Get creation date.
223          * 
224          * @return the date
225          */
226         public String getDate() {
227                 return _credate;
228         }
229
230         /**
231          * {@inheritDoc}
232          * 
233          * @see org.splat.simer.AbstractOpenObject#getMenu()
234          */
235         @Override
236         public StudyMenu getMenu() {
237                 return (StudyMenu) _menu;
238         }
239
240         /**
241          * Set study menu.
242          * 
243          * @param aMenu
244          *            the study menu
245          */
246         public void setMenu(final StudyMenu aMenu) {
247                 _menu = aMenu;
248         }
249
250         /**
251          * {@inheritDoc}
252          * 
253          * @see org.splat.service.dto.Proxy#getProgressState()
254          */
255         @Override
256         public ProgressState getProgressState() {
257                 return _mystudy.getProgressState();
258         }
259
260         /**
261          * Get last modification date.
262          * 
263          * @return the date
264          */
265         public String getLastModificationDate() {
266                 return _lasdate;
267         }
268
269         /**
270          * Get the toolbar with buttons of available modules.
271          * 
272          * @return the toolbar
273          */
274         public ToolBar getModuleBar() {
275                 return getApplicationSettings().getModuleBar(getSelectedStep());
276         }
277
278         /**
279          * {@inheritDoc}
280          * 
281          * @see org.splat.service.dto.Proxy#getReference()
282          */
283         @Override
284         public String getReference() {
285                 return _mystudy.getReference();
286         }
287
288         /**
289          * {@inheritDoc}
290          * 
291          * @see org.splat.simer.OpenStudyServices#getSelectedDocument()
292          */
293         @Override
294         public Publication getSelectedDocument() {
295                 return _selecdoc;
296         }
297
298         /**
299          * Get user rights for the selected step.
300          * 
301          * @return user step rights
302          */
303         public StepRights getSelectedStepRights() {
304                 return _urightstep;
305         }
306
307         /**
308          * Get user rights for the study.
309          * 
310          * @return user study rights
311          */
312         public StudyRights getStudyRights() {
313                 return _urightstudy;
314         }
315
316         /**
317          * Get the detached study object.
318          * 
319          * @return the detached study object
320          */
321         public Study getStudyObject() {
322                 return _mystudy;
323         }
324
325         /**
326          * {@inheritDoc}
327          * 
328          * @see org.splat.service.dto.Proxy#getTitle()
329          */
330         @Override
331         public String getTitle() {
332                 return _mystudy.getTitle();
333         }
334
335         /**
336          * {@inheritDoc}
337          * 
338          * @see org.splat.service.dto.Proxy#getType()
339          */
340         @Override
341         public String getType() {
342                 return Constants.STUDY_MENU;
343         }
344         
345         /** 
346          * {@inheritDoc}
347          * @see org.splat.simer.AbstractOpenObject#getTypeName()
348          */
349         @Override
350         public String getTypeName() {
351                 return ResourceBundle.getBundle("labels", getApplicationSettings().getCurrentLocale()).getString( "label.study");
352         }
353
354         /**
355          * Get the study version.
356          * 
357          * @return the version string
358          */
359         public String getVersion() {
360                 return _version;
361         }
362
363         /**
364          * Check if the selected step is enabled for writing.
365          * 
366          * @return true if the selected step is enabled for writing
367          */
368         public boolean isStepEnabled() {
369                 return _urightstep.isEnabled();
370         }
371
372         // =========================================================================
373         // Public services
374         // =========================================================================
375
376         @Override
377         public URL newTemplateBasedDocument(final String typename, final User author) {
378                 String filename = typename + ".xml"; // Only XML templates are writeable
379                 File template = new File(getRepositoryService().getTemplatePath()
380                                 + filename);
381                 if (!template.exists()) {
382                         return null;
383                 }
384
385                 // Session connex = Database.getCurSession();
386                 // Transaction transax = connex.beginTransaction();
387                 try {
388                         File udir = getRepositoryService().getDownloadDirectory(author);
389                         File credoc = new File(udir.getPath() + "/" + filename);
390
391                         // Creation of the meta-document
392                         Step step = getSelectedStep(); // Should we check if the given document type is compatible ?
393                         DocumentType type = getDocumentTypeService().selectType(typename);
394                         Document.Properties dprop = new Document.Properties();
395                         Document medoc = getStepService().createDocument(step,
396                                         dprop.setType(type).setFormat("xml").setAuthor(author))
397                                         .value();
398                         // transax.commit();
399
400                         // Instantiation of the template into the user download directory
401                         if (!udir.exists()) {
402                                 udir.mkdir();
403                         }
404                         if (credoc.exists()) {
405                                 credoc.delete();
406                         }
407                         Do.copy(template, credoc);
408
409                         // Transfer to the document of all known properties
410                         ResourceBundle locale = ResourceBundle.getBundle("som",
411                                         getApplicationSettings().getCurrentLocale());
412                         SimpleDateFormat get = new SimpleDateFormat(locale
413                                         .getString("date.format"), getApplicationSettings()
414                                         .getCurrentLocale());
415                         Writer tool = Toolbox.getWriter(credoc);
416                         List<Step> slist = getInvolvedSteps();
417                         for (Iterator<Step> i = slist.iterator(); i.hasNext();) {
418                                 List<SimulationContext> clist = i.next()
419                                                 .getAllSimulationContexts();
420                                 for (Iterator<SimulationContext> j = clist.iterator(); j
421                                                 .hasNext();) {
422                                         SimulationContext context = j.next();
423                                         tool.updateProperty(context.getType().getName(), context
424                                                         .getValue());
425                                 }
426                         }
427                         tool.updateProperty("reference", medoc.getReference());
428                         tool.updateProperty(Constants.STUDY_MENU, _mystudy.getTitle());
429                         tool.updateProperty("step", locale.getString(
430                                         "folder.step." + step.getNumber()).replaceAll("''", "'"));
431                         tool.updateProperty("author", author.getUsername().toUpperCase());
432                         tool.updateProperty("date", get.format(medoc.getCreationDate()));
433                         tool.updateProperty("history", locale.getString("label.creation")
434                                         .replaceAll("''", "'"));
435                         tool.save();
436
437                         return new URL(getApplicationSettings().getDownloadURL(author)
438                                         + filename);
439                 } catch (Exception saverror) {
440                         LOGGER.error("Reason:", saverror);
441                         return null;
442                 }
443         }
444
445         public void selectDocument(final String docurl) {
446                 String prefix = getApplicationSettings().getRepositoryURL();
447
448                 if (docurl.startsWith(prefix)) {
449                         try {
450                                 String path = docurl.substring(prefix.length());
451                                 Document value = getDocumentService().getDocumentByPath(path);
452
453                                 _selecdoc = _ustep.getDocument(value.getIndex());
454                         } catch (Exception error) {
455                                 LOGGER.error("Reason:", error);
456                         }
457                 }
458         }
459
460         /**
461          * Select an activity (step).
462          * 
463          * @param step
464          *            the key of the step to select
465          */
466         public void setSelection(final String step) {
467                 if (!step.equals(_selection)) {
468                         _selection = step;
469                         _selecdoc = null;
470                         setupPreviousToSelectedSteps();
471                         updateSimulationContexts(); // Initializes contexts according to the selected steps
472                 }
473                 _ustep = _involving.get(_involving.size() - 1);
474                 _urightstep = new StepRights(_cuser, _ustep);
475                 _ustep.setActor(_cuser);
476                 _menu.selects(_selection); // Updates menu items to be displayed
477                 setupContents(); // The contents may have changed even if the selection is the same
478         }
479
480         // =========================================================================
481         // Protected services
482         // =========================================================================
483
484         /**
485          * Add a new document presentation facade.
486          * 
487          * @param doc
488          *            the document publication
489          */
490         protected void add(final Publication doc) {
491                 DocumentFacade facade = new DocumentFacade(this, doc,
492                                 getProjectSettings(), getPublicationService(),
493                                 getApplicationSettings());
494                 boolean first = (_contents.size() == 0);
495
496                 _docpres.put(doc.getIndex(), facade);
497                 _contents.add(0, facade); // Prepend the new publication
498                 if (first) {
499                         this.getMenu().refreshSelectedItem();
500                 }
501                 // Refresh dependencies. They can not be removed until removing this document.
502                 for (Publication pub : doc.getRelations(UsesRelation.class)) {
503                         update(pub);
504                 }
505         }
506
507         /**
508          * Add a simulation context presentation facade.
509          * 
510          * @param contex
511          *            the simulation context to add
512          */
513         protected void add(final SimulationContext contex) {
514                 SimulationContextFacade facade = new SimulationContextFacade(contex,
515                                 getProjectSettings().getAllSteps(), getApplicationSettings());
516
517                 _context.add(facade);
518         }
519
520         /**
521          * Add a knowledge element presentation facade.
522          * 
523          * @param kelm
524          *            the knowledge element to add
525          */
526         protected void add(final KnowledgeElement kelm) {
527                 KnowledgeElementFacade facade = new KnowledgeElementFacade(BeanHelper
528                                 .copyBean(kelm, KnowledgeElementDTO.class),
529                                 getApplicationSettings());
530                 // RKV KnowledgeIterator known = knowledge.get(kelm.getType().getIndex() - 2);
531                 // Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
532                 // RKV:Begin: Find a knowledge iterator for appropriate knowledge type
533                 KnowledgeIterator known = null;
534                 for (KnowledgeIterator aKnowledgeSection : _knowledge) {
535                         if (aKnowledgeSection.getIndex().equals(
536                                         String.valueOf(kelm.getType().getIndex()))) {
537                                 known = aKnowledgeSection;
538                                 break;
539                         }
540                 }
541                 if (known != null) { // RKV:End
542                         _knowpres.put(kelm.getIndex(), facade);
543                         known._list.add(facade); // Insert the new knowledge at the end of the corresponding knowledge type
544                 }
545         }
546
547         /**
548          * Remove the document presentation facade.
549          * 
550          * @param doctag
551          *            the document publication to remove
552          */
553         protected void remove(final Publication doctag) {
554                 for (Iterator<DocumentFacade> i = _contents.iterator(); i.hasNext();) {
555                         DocumentFacade facade = i.next();
556                         if (facade.isFacadeOf(doctag)) {
557                                 i.remove();
558                                 break;
559                         }
560                 }
561                 if (_contents.size() == 0) {
562                         this.getMenu().refreshSelectedItem();
563                 }
564         }
565
566         /**
567          * Change the currently connected user and refresh user's rights.
568          * 
569          * @param user
570          *            the new connected user
571          */
572         protected void changeUser(final User user) {
573                 _cuser = user;
574                 _popup = null;
575                 if (getStudyService().isStaffedBy(_mystudy, _cuser)) {
576                         _popup = getApplicationSettings().getPopupMenu(
577                                         "steditablemarkpublic");
578                         _popup.setContext(Constants.STUDY_MENU, new StudyRights(_cuser,
579                                         _mystudy));
580                 }
581                 // ustep = getProjectElementService().getFirstStep(mystudy);
582                 if (_ustep != null) {
583                         _ustep.setActor(_cuser);
584                 }
585                 _urightstudy = new StudyRights(_cuser, _mystudy);
586                 _urightstep = new StepRights(_cuser, _ustep);
587         }
588
589         /**
590          * Remove the simulation context presentation facade.
591          * 
592          * @param contex
593          *            the simulation context to remove
594          */
595         protected void remove(final SimulationContext contex) {
596                 for (Iterator<SimulationContextFacade> i = _context.iterator(); i
597                                 .hasNext();) {
598                         SimulationContextFacade facade = i.next();
599                         if (facade.isFacadeOf(contex)) {
600                                 i.remove();
601                                 break;
602                         }
603                 }
604         }
605
606         /**
607          * Remove the knowledge element presentation facade.
608          * 
609          * @param kelm
610          *            the knowledge element to remove
611          */
612         protected void remove(final KnowledgeElement kelm) {
613                 // RKV: KnowledgeIterator known = _knowledge.get((int) (kelm.getType()
614                 // RKV: .getIndex() - 2));
615                 // Knowledges are ordered by type index, from 0 to n-1, the first one being reserved (reason for -2)
616                 // RKV:Begin: Find a knowledge iterator for appropriate knowledge type
617                 KnowledgeIterator known = null;
618                 for (KnowledgeIterator aKnowledgeSection : _knowledge) {
619                         if (aKnowledgeSection.getIndex().equals(
620                                         String.valueOf(kelm.getType().getIndex()))) {
621                                 known = aKnowledgeSection;
622                                 break;
623                         }
624                 }
625                 if (known != null) { // RKV:End
626                         _knowpres.remove(kelm.getIndex());
627                         for (Iterator<KnowledgeElementFacade> i = known._list.iterator(); i
628                                         .hasNext();) {
629                                 KnowledgeElementFacade facade = i.next();
630                                 if (!facade.isFacadeOf(BeanHelper.copyBean(kelm,
631                                                 KnowledgeElementDTO.class))) {
632                                         continue;
633                                 }
634                                 i.remove();
635                                 break;
636                         }
637                 }
638         }
639
640         /**
641          * Refresh the document presentation facade.
642          * 
643          * @param doc
644          *            the document publication
645          */
646         protected void update(final Publication doc) {
647                 DocumentFacade facade = _docpres.get(doc.getIndex());
648                 if (facade != null) {
649                         facade.refresh();
650                 }
651         }
652
653         /**
654          * Refresh the knowledge element presentation facade.
655          * 
656          * @param kelm
657          *            the knowledge element DTO
658          */
659         protected void update(final KnowledgeElementDTO kelm) {
660                 KnowledgeElementFacade facade = _knowpres.get(kelm.getIndex());
661                 if (facade != null) {
662                         facade.refresh(kelm);
663                 }
664         }
665
666         /**
667          * Refresh simulation contexts presentation facades.
668          */
669         protected void updateSimulationContexts() {
670                 _context.clear();
671                 for (Iterator<Step> i = _involving.iterator(); i.hasNext();) {
672                         for (Iterator<SimulationContext> j = i.next()
673                                         .getAllSimulationContexts().iterator(); j.hasNext();) {
674                                 _context.add(new SimulationContextFacade(j.next(),
675                                                 getProjectSettings().getAllSteps(),
676                                                 getApplicationSettings()));
677                         }
678                 }
679         }
680
681         // =========================================================================
682         // Private services
683         // =========================================================================
684
685         private void setupPreviousToSelectedSteps() {
686                 String[] item = _selection.split("\\x2E");
687                 int major = Integer.valueOf(item[0]);
688                 int minor = Integer.valueOf(item[1]);
689                 int base = minor;
690                 Step[] step;
691
692                 _involving.clear();
693                 if (major > 0) {
694                         Scenario[] branch = _mystudy.getScenarii();
695                         Scenario scenar = branch[0];
696                         for (int i = 0; i < branch.length; i++) {
697                                 scenar = branch[i];
698                                 if (scenar.getIndex() == major) {
699                                         break; // Supposed exist
700                                 }
701                         }
702                         step = getProjectElementService().getSteps(scenar);
703                         base = step[0].getNumber() - 1;
704                         for (int i = 0; i + base < minor; i++) {
705                                 _involving.add(step[i]);
706                         }
707                 }
708                 step = getProjectElementService().getSteps(_mystudy);
709                 for (int i = step.length - 1; i > -1; i--) {
710                         Step firstep = step[i];
711                         if (firstep.getNumber() <= base) {
712                                 _involving.add(0, firstep);
713                         }
714                 }
715         }
716
717         /**
718          * Get the stepService.
719          * 
720          * @return the stepService
721          */
722         public StepService getStepService() {
723                 return _stepService;
724         }
725
726         /**
727          * Set the stepService.
728          * 
729          * @param stepService
730          *            the stepService to set
731          */
732         public void setStepService(final StepService stepService) {
733                 _stepService = stepService;
734         }
735
736         /**
737          * Get the repositoryService.
738          * 
739          * @return the repositoryService
740          */
741         public RepositoryService getRepositoryService() {
742                 return _repositoryService;
743         }
744
745         /**
746          * Set the repositoryService.
747          * 
748          * @param repositoryService
749          *            the repositoryService to set
750          */
751         public void setRepositoryService(final RepositoryService repositoryService) {
752                 _repositoryService = repositoryService;
753         }
754
755         /**
756          * Get the documentTypeService.
757          * 
758          * @return the documentTypeService
759          */
760         public DocumentTypeService getDocumentTypeService() {
761                 return _documentTypeService;
762         }
763
764         /**
765          * Set the documentTypeService.
766          * 
767          * @param documentTypeService
768          *            the documentTypeService to set
769          */
770         public void setDocumentTypeService(
771                         final DocumentTypeService documentTypeService) {
772                 _documentTypeService = documentTypeService;
773         }
774
775         /**
776          * Get the studyService.
777          * 
778          * @return the studyService
779          */
780         public StudyService getStudyService() {
781                 return _studyService;
782         }
783
784         /**
785          * Set the studyService.
786          * 
787          * @param studyService
788          *            the studyService to set
789          */
790         public void setStudyService(final StudyService studyService) {
791                 _studyService = studyService;
792         }
793
794         /**
795          * Get the documentService.
796          * 
797          * @return the documentService
798          */
799         public DocumentService getDocumentService() {
800                 return _documentService;
801         }
802
803         /**
804          * Set the documentService.
805          * 
806          * @param documentService
807          *            the documentService to set
808          */
809         public void setDocumentService(final DocumentService documentService) {
810                 _documentService = documentService;
811         }
812
813         /**
814          * Get the detached study object.
815          * 
816          * @return the detached study object
817          */
818         public Study getMystudy() {
819                 return _mystudy;
820         }
821
822         /**
823          * Set the study to present.
824          * 
825          * @param mystudy
826          *            the selected study detached object
827          */
828         public void setMystudy(final Study mystudy) {
829                 this._mystudy = mystudy;
830         }
831 }