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