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