Salome HOME
2e3fc4538e3f9af18d1473a7f3099a09c8ec20c1
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / StudyServiceImpl.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            Id: 
5  * Creation date   02.10.2012
6  * @author         Author: Maria KRUCHININA
7  * @version        Revision: 
8  *****************************************************************************/
9
10 package org.splat.service;
11
12 import java.awt.Graphics2D;
13 import java.io.File;
14 import java.io.FileNotFoundException;
15 import java.io.FileOutputStream;
16 import java.io.IOException;
17 import java.text.DecimalFormat;
18 import java.text.SimpleDateFormat;
19 import java.util.Calendar;
20 import java.util.Collections;
21 import java.util.Date;
22 import java.util.Iterator;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Scanner;
26 import java.util.Set;
27
28 import org.apache.lucene.index.IndexWriter;
29 import org.apache.lucene.store.FSDirectory;
30 import org.hibernate.criterion.Restrictions;
31 import org.jfree.chart.ChartFactory;
32 import org.jfree.chart.JFreeChart;
33 import org.jfree.chart.plot.PlotOrientation;
34 import org.jfree.data.xy.XYSeries;
35 import org.jfree.data.xy.XYSeriesCollection;
36 import org.splat.common.properties.MessageKeyEnum;
37 import org.splat.dal.bo.kernel.Relation;
38 import org.splat.dal.bo.kernel.User;
39 import org.splat.dal.bo.som.ActorRelation;
40 import org.splat.dal.bo.som.ContributorRelation;
41 import org.splat.dal.bo.som.DescriptionAttribute;
42 import org.splat.dal.bo.som.DocumentType;
43 import org.splat.dal.bo.som.IDBuilder;
44 import org.splat.dal.bo.som.ProgressState;
45 import org.splat.dal.bo.som.Publication;
46 import org.splat.dal.bo.som.SimulationContext;
47 import org.splat.dal.bo.som.Study;
48 import org.splat.dal.bo.som.Study.Properties;
49 import org.splat.dal.bo.som.ValidationCycle;
50 import org.splat.dal.bo.som.ValidationCycle.Actor;
51 import org.splat.dal.bo.som.ValidationCycleRelation;
52 import org.splat.dal.bo.som.ValidationStep;
53 import org.splat.dal.bo.som.Visibility;
54 import org.splat.dal.dao.som.DescriptionAttributeDAO;
55 import org.splat.dal.dao.som.DocumentDAO;
56 import org.splat.dal.dao.som.IDBuilderDAO;
57 import org.splat.dal.dao.som.PublicationDAO;
58 import org.splat.dal.dao.som.ScenarioDAO;
59 import org.splat.dal.dao.som.StudyDAO;
60 import org.splat.dal.dao.som.ValidationCycleDAO;
61 import org.splat.exception.IncompatibleDataException;
62 import org.splat.exception.InvalidParameterException;
63 import org.splat.kernel.InvalidPropertyException;
64 import org.splat.kernel.MissedPropertyException;
65 import org.splat.kernel.MultiplyDefinedException;
66 import org.splat.log.AppLogger;
67 import org.splat.service.dto.DocToCompareDTO;
68 import org.splat.service.technical.IndexService;
69 import org.splat.service.technical.ProjectSettingsService;
70 import org.splat.service.technical.ProjectSettingsServiceImpl;
71 import org.splat.service.technical.RepositoryService;
72 import org.splat.som.Revision;
73 import org.springframework.transaction.annotation.Transactional;
74
75 import com.lowagie.text.Document;
76 import com.lowagie.text.DocumentException;
77 import com.lowagie.text.Rectangle;
78 import com.lowagie.text.pdf.DefaultFontMapper;
79 import com.lowagie.text.pdf.PdfContentByte;
80 import com.lowagie.text.pdf.PdfTemplate;
81 import com.lowagie.text.pdf.PdfWriter;
82
83
84 /**
85  * This class defines all methods for creation, modification the study.
86  * 
87  * @author Maria KRUCHININA
88  * 
89  */
90 public class StudyServiceImpl implements StudyService {
91
92         /**
93          * logger for the service.
94          */
95         public final static AppLogger LOG = AppLogger
96                         .getLogger(StudyServiceImpl.class);
97
98         /**
99          * Injected index service.
100          */
101         private IndexService _indexService;
102
103         /**
104          * Injected step service.
105          */
106         private StepService _stepService;
107
108         /**
109          * Injected project service.
110          */
111         private ProjectSettingsService _projectSettings;
112
113         /**
114          * Injected project element service.
115          */
116         private ProjectElementService _projectElementService;
117
118         /**
119          * Injected study DAO.
120          */
121         private StudyDAO _studyDAO;
122
123         /**
124          * Injected scenario DAO.
125          */
126         private ScenarioDAO _scenarioDAO;
127
128         /**
129          * Injected validation cycle DAO.
130          */
131         private ValidationCycleDAO _validationCycleDAO;
132
133         /**
134          * Injected IDBuilder DAO.
135          */
136         private IDBuilderDAO _iDBuilderDAO;
137
138         /**
139          * Injected document type service.
140          */
141         private DocumentTypeService _documentTypeService;
142
143         /**
144          * Injected user service.
145          */
146         private UserService _userService;
147         
148         /**
149          * Injected publication DAO.
150          */
151         private PublicationDAO _publicationDAO;
152
153         /**
154          * Injected repository service.
155          */
156         private RepositoryService _repositoryService;
157
158         /**
159          * Injected document DAO.
160          */
161         private DocumentDAO _documentDAO;
162
163         /**
164          * Injected description attribute DAO.
165          */
166         private DescriptionAttributeDAO _descriptionAttributeDAO;
167
168         /**
169          * {@inheritDoc}
170          * 
171          * @see org.splat.service.StudyService#selectStudy(long)
172          */
173         @Transactional
174         public Study selectStudy(final long index) {
175                 Study result = getStudyDAO().get(index);
176                 loadWorkflow(result);
177                 return result;
178         }
179
180         /** 
181          * {@inheritDoc}
182          * @see org.splat.service.StudyService#removeStudy(long)
183          */
184         @Transactional
185         public void removeStudy(final long index) {
186                 Study study = getStudyDAO().get(index);
187                 if (study != null) {
188                         getStudyDAO().delete(study);
189                 }
190         }
191
192         /**
193          * Get study by its reference.
194          * 
195          * @param refid
196          *            the study reference
197          * @return found study or null
198          */
199         @Transactional(readOnly = true)
200         public Study selectStudy(final String refid) {
201                 Study result = getStudyDAO().findByCriteria(
202                                 Restrictions.eq("sid", refid));
203                 loadWorkflow(result);
204                 return result;
205         }
206
207         /**
208          * {@inheritDoc}
209          * 
210          * @see org.splat.service.StudyService#createStudy(org.splat.dal.bo.som.Study.Properties)
211          */
212         @Transactional
213         public Study createStudy(final Study.Properties sprop)
214                         throws MissedPropertyException, InvalidPropertyException,
215                         MultiplyDefinedException {
216                 sprop.setReference(getProjectSettings().getReferencePattern());
217                 Study study = new Study(sprop);
218
219                 buildReference(study);
220                 getStudyDAO().create(study);
221 //              try {
222 //                      IndexService lucin = getIndex();
223 //                      lucin.add(study);
224 //              } catch (IOException error) {
225 //                      LOG.error("Unable to index the study '" + study.getIndex()
226 //                                      + "', reason:", error);
227 //                      // Continue and try to index later
228 //              }
229                 return study;
230         }
231
232         /**
233          * {@inheritDoc}
234          * 
235          * @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext.Properties)
236          */
237         @Transactional
238         public SimulationContext addProjectContext(final Study aStudy,
239                         final SimulationContext.Properties cprop)
240                         throws MissedPropertyException, InvalidPropertyException,
241                         MultiplyDefinedException {
242                 SimulationContext added = getStepService().addSimulationContext(
243                                 getProjectElementService().getFirstStep(aStudy), cprop);
244                 update(aStudy);
245                 return added;
246         }
247
248         /**
249          * {@inheritDoc}
250          * 
251          * @see org.splat.service.StudyService#addProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext)
252          */
253         @Transactional
254         public SimulationContext addProjectContext(final Study aStudy,
255                         final SimulationContext context) {
256                 SimulationContext added = getStepService().addSimulationContext(
257                                 getProjectElementService().getFirstStep(aStudy), context);
258                 update(aStudy);
259                 return added;
260         }
261
262         /**
263          * {@inheritDoc}
264          * 
265          * @see org.splat.service.StudyService#addContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User)
266          */
267         public boolean addContributor(final Study aStudy, final User user) {
268                 List<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
269                 for (Iterator<User> i = contributor.iterator(); i.hasNext();) {
270                         User present = i.next();
271                         if (present.equals(user)) {
272                                 return false;
273                         }
274                 }
275                 boolean absent = getModifiableActors(aStudy).add(user); // User may already be a reviewer or an approver
276
277                 aStudy.addRelation(new ContributorRelation(aStudy, user));
278                 if (absent) {
279                         update(aStudy); // Else, useless to re-index the study
280                 }
281                 contributor.add(user);
282                 return true;
283         }
284
285         /**
286          * Moves this study from the Public to the Reference area of the repository. For being moved to the Reference area, the study must
287          * previously be approved.
288          * 
289          * @param aStudy
290          *            the study to move
291          * @return true if the move succeeded.
292          * @see #moveToPublic()
293          * @see #isPublic()
294          * @see Publication#approve(Date)
295          */
296         public boolean moveToReference(final Study aStudy) {
297                 if (aStudy.getProgressState() != ProgressState.APPROVED) {
298                         return false;
299                 }
300                 if (aStudy.getVisibility() != Visibility.PUBLIC) {
301                         return false;
302                 }
303
304                 aStudy.setVisibility(Visibility.REFERENCE);
305                 if (update(aStudy)) {
306                         return updateKnowledgeElementsIndex(aStudy); // If fails, the database roll-back is under responsibility of the caller
307                 }
308                 return false;
309         }
310
311         /**
312          * {@inheritDoc}
313          * 
314          * @see org.splat.service.StudyService#update(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.Study.Properties)
315          */
316         public boolean update(final Study aStudy, final Properties sprop)
317                         throws InvalidPropertyException {
318                 if (sprop.getTitle() != null) {
319                         aStudy.setTitle(sprop.getTitle());
320                 }
321                 if (sprop.getSummary() != null) {
322                         aStudy.setAttribute(new DescriptionAttribute(aStudy, sprop
323                                         .getSummary()));
324                 }
325                 // TODO: To be completed
326                 return update(aStudy);
327         }
328
329         /**
330          * Check if the document is published in the study.
331          * 
332          * @param aStudy
333          *            the study
334          * @param doc
335          *            the document
336          * @return true if the document is published in the study
337          */
338 /*      private boolean publishes(final Study aStudy, final Document doc) {
339                 if (!aStudy.publishes(doc)) {
340                         Scenario[] scene = aStudy.getScenarii();
341                         for (int i = 0; i < scene.length; i++) {
342                                 if (scene[i].publishes(doc)) {
343                                         return true;
344                                 }
345                         }
346                 }
347                 return false;
348         }
349 */
350         /**
351          * {@inheritDoc}
352          * 
353          * @see org.splat.service.StudyService#removeContributor(org.splat.dal.bo.som.Study, org.splat.dal.bo.kernel.User[])
354          */
355         public boolean removeContributor(final Study aStudy, final User... users) {
356                 List<User> contributor = getModifiableContributors(aStudy); // Initializes contributor
357                 Boolean done = false;
358                 for (int i = 0; i < users.length; i++) {
359                         User user = users[i];
360                         for (Iterator<User> j = contributor.iterator(); j.hasNext();) {
361                                 User present = j.next();
362                                 if (!present.equals(user)) {
363                                         continue;
364                                 }
365
366                                 aStudy.removeRelation(ContributorRelation.class, user);
367                                 j.remove(); // Updates the contributor shortcut
368                                 done = true;
369                                 break;
370                         }
371                 }
372                 if (done) {
373                         update(aStudy);
374                 }
375                 return done;
376         }
377
378         /**
379          * {@inheritDoc}
380          * 
381          * @see org.splat.service.StudyService#removeProjectContext(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.SimulationContext)
382          */
383         public boolean removeProjectContext(final Study aStudy,
384                         final SimulationContext context) {
385                 boolean done = getStepService().removeSimulationContext(
386                                 getProjectElementService().getFirstStep(aStudy), context);
387                 update(aStudy);
388                 return done;
389         }
390
391         /**
392          * {@inheritDoc}
393          * 
394          * @see org.splat.service.StudyService#setValidationCycle(org.splat.dal.bo.som.Study, org.splat.dal.bo.som.DocumentType,
395          *      org.splat.dal.bo.som.ValidationCycle.Properties)
396          */
397         @Transactional
398         public void setValidationCycle(final Study aStudyDTO, final DocumentType type,
399                         final ValidationCycle.Properties vprop) {
400                 Map<String, ValidationCycle> validactor = aStudyDTO.getValidationCycles();
401                 if (validactor == null) {
402                         setShortCuts(aStudyDTO); // Initializes validactor and actor
403                 }
404
405                 Study aStudy = selectStudy(aStudyDTO.getIndex());
406                 
407                 String cname = type.getName();
408                 ValidationCycle cycle = validactor.get(cname);
409
410                 if (cycle != null && cycle.isAssigned()) {
411                         resetActors(cycle, vprop);
412                 } else {
413                         try {
414                                 cycle = new ValidationCycle(aStudy, vprop.setDocumentType(type));
415
416                                 getValidationCycleDAO().create(cycle); // RKV
417
418                                 ValidationCycleRelation link = cycle.getContext();
419                                 aStudy.addRelation(link);
420                                 aStudyDTO.getAllRelations().add(link); // RKV
421
422                                 validactor.put(cname, link.getTo()); // Replaces the cycle if exists as default,
423                         } catch (Exception error) {
424                                 LOG.error("Unable to re-index Knowledge Elements, reason:",
425                                                 error);
426                                 return;
427                         }
428                 }
429                 resetActorsShortCut(aStudyDTO);
430                 update(aStudy); // Re-index the study, just in case
431         }
432
433         /**
434          * Demotes this study from In-Check to In-Draft then In-Work states. This function is called internally when demoting the final result
435          * document of the study.
436          * 
437          * @param aStudy
438          *            a study to demote
439          * @return true if the demotion succeeded.
440          */
441         public boolean demote(final Study aStudy) {
442                 if (aStudy.getProgressState() == ProgressState.inCHECK) {
443                         aStudy.setProgressState(ProgressState.inDRAFT);
444                 } else if (aStudy.getProgressState() == ProgressState.inDRAFT) {
445                         aStudy.setProgressState(ProgressState.inWORK);
446                 } else {
447                         return false;
448                 }
449                 return update(aStudy);
450         }
451
452         /**
453          * {@inheritDoc}
454          * 
455          * @see org.splat.service.StudyService#generateLocalIndex(org.splat.dal.bo.som.Study)
456          */
457         @Transactional
458         public int generateLocalIndex(final Study aStudy) {
459                 aStudy.setLastLocalIndex(aStudy.getLastLocalIndex() + 1);
460                 return aStudy.getLastLocalIndex();
461         }
462
463         /**
464          * Promotes this study from In-Work to In-Draft then In-Check and APPROVED states. This function is called internally when promoting the
465          * final result document of the study.
466          * 
467          * @param aStudy
468          *            a study to promote
469          * @return true if the demotion succeeded.
470          */
471         @Transactional
472         public boolean promote(final Study aStudy) {
473                 if (aStudy.getProgressState() == ProgressState.inWORK) {
474                         aStudy.setProgressState(ProgressState.inDRAFT);
475                 } else if (aStudy.getProgressState() == ProgressState.inDRAFT) {
476                         aStudy.setProgressState(ProgressState.inCHECK);
477                         Revision myvers = new Revision(aStudy.getVersion());
478                         if (myvers.isMinor()) {
479                                 aStudy.setVersion(myvers.incrementAs(aStudy.getProgressState())
480                                                 .toString());
481                         }
482                 } else if (aStudy.getProgressState() == ProgressState.inCHECK) {
483                         aStudy.setProgressState(ProgressState.APPROVED);
484                 } else {
485                         return false;
486                 }
487
488                 return update(aStudy);
489         }
490
491         /**
492          * Moves this study from the Private to the Public area of the repository.
493          * 
494          * @param aStudy
495          *            a study to move
496          * @return true if the move succeeded.
497          * @see #isPublic()
498          */
499         @Transactional
500         public boolean moveToPublic(final Study aStudy) {
501                 boolean isOk = false;
502                 if (aStudy.getVisibility() == Visibility.PRIVATE) {
503                         aStudy.setVisibility(Visibility.PUBLIC);
504                         if (update(aStudy)) {
505                                 isOk = updateKnowledgeElementsIndex(aStudy); // If fails, the database roll-back is under responsibility of the caller
506                         }
507                 }
508                 return isOk;
509         }
510         
511         /**
512          * Moves this study from the Public to the Private area of the repository.
513          * 
514          * @param aStudy
515          *            a study to move
516          * @return true if the move succeeded.
517          */
518         @Transactional
519         public boolean moveToPrivate(final Study aStudy) {
520                 boolean isOk = false;
521                 if (aStudy.getVisibility() == Visibility.PUBLIC) {
522                         aStudy.setVisibility(Visibility.PRIVATE);
523                         if (update(aStudy)) {
524                                 isOk = updateKnowledgeElementsIndex(aStudy); // If fails, the database roll-back is under responsibility of the caller
525                         }
526                 }
527                 return isOk;
528         }
529
530         /**
531          * Update a study in the database.
532          * 
533          * @param aStudy
534          *            the study to update
535          * @return true if the study is updated successfully
536          */
537         @Transactional
538         private boolean update(final Study aStudy) {
539                 boolean isOk = false;
540                 try {
541                         getStudyDAO().merge(aStudy); // Update of relational base
542                         setShortCuts(aStudy); // RKV: initialize transient actors set
543                         //RKV: getIndex().update(aStudy); // Update of Lucene index
544                         isOk = true;
545                 } catch (Exception e) {
546                         LOG.error("STD-000001", e, aStudy.getIndex(), e.getMessage());
547                 }
548                 return isOk;
549         }
550
551         /**
552          * Build reference for the study. The reference of the study is stored as a new reference pattern (IDBuilder).
553          * 
554          * @param aStudy
555          *            the study
556          * @return true if reference building is succeded
557          */
558         @Transactional
559         private boolean buildReference(final Study aStudy) {
560                 String pattern = aStudy.getReference(); // The study being supposed just created, its reference is the reference pattern
561                 IDBuilder tool = selectIDBuilder(aStudy.getDate());
562                 if (tool == null) {
563                         tool = new IDBuilder(aStudy.getDate());
564                         getIDBuilderDAO().create(tool);
565                 }
566                 aStudy.setReference(buildReference(tool, pattern, aStudy));
567                 return true;
568         }
569
570         /**
571          * Build reference for the study. The reference of the study is stored as a new reference pattern (IDBuilder).
572          * 
573          * @param aBuilder
574          *            the id builder
575          * @param study
576          *            the study
577          * @param pattern
578          *            the reference pattern
579          * @return true if reference building is succeded
580          */
581         @Transactional
582         public String buildReference(final IDBuilder aBuilder,
583                         final String pattern, final Study study) {
584                 char[] format = pattern.toCharArray();
585                 char[] ref = new char[80]; // Better evaluate the length of the generated string
586                 int next = aBuilder.getBase() + 1;
587
588                 int count = 0;
589                 for (int i = 0; i < format.length; i++) {
590
591                         // Insertion of attribute values
592                         if (format[i] == '%') {
593                                 i += 1;
594
595                                 if (format[i] == 'y') { // Insertion of year in format 2 (e.g. 09) or 4 (e.g. 2009) digits
596                                         int n = i;
597                                         while (format[i] == 'y') {
598                                                 i += 1;
599                                                 if (i == format.length) {
600                                                         break;
601                                                 }
602                                         }
603                                         SimpleDateFormat tostring = new SimpleDateFormat("yyyy"); //RKV: NOPMD: TODO: Use locale here?
604                                         String year = tostring.format(study.getDate());
605                                         year = year.substring(4 - (i - n), 4); // 4-(i-n) must be equal to either 0 or 2
606                                         for (int j = 0; j < year.length(); j++) {
607                                                 ref[count] = year.charAt(j);
608                                                 count += 1;
609                                         }
610                                         i -= 1; // Back to the last 'y' character
611                                 } else if (format[i] == '0') { // Insertion of the index
612                                         int n = i;
613                                         while (format[i] == '0') {
614                                                 i += 1;
615                                                 if (i == format.length) {
616                                                         break;
617                                                 }
618                                         }
619                                         DecimalFormat tostring = new DecimalFormat(pattern
620                                                         .substring(n, i));
621                                         String number = tostring.format(next);
622                                         for (int j = 0; j < number.length(); j++) {
623                                                 ref[count] = number.charAt(j);
624                                                 count += 1;
625                                         }
626                                         i -= 1; // Back to the last '0' character
627                                 }
628                                 // Keep the character
629                         } else {
630                                 ref[count] = format[i];
631                                 count += 1;
632                         }
633                 }
634                 // Incrementation of the number of study
635                 aBuilder.setBase(next);
636                 getIDBuilderDAO().update(aBuilder);
637                 return String.copyValueOf(ref, 0, count);
638         }
639
640         /**
641          * Find an id builder by date.
642          * 
643          * @param date
644          *            the date
645          * @return found id builder
646          */
647         private IDBuilder selectIDBuilder(final Date date) {
648                 Calendar aDate = Calendar.getInstance();
649                 aDate.setTime(date);
650                 return getIDBuilderDAO().findByCriteria(
651                                 Restrictions.eq("cycle", aDate.get(Calendar.YEAR)));
652         }
653
654         /**
655          * Fill transient collection ModifiableActors of the study.
656          * 
657          * @param aStudy
658          *            the study
659          */
660         private void resetActorsShortCut(final Study aStudy) {
661                 getModifiableActors(aStudy).clear();
662                 // Get all actors involved in validation cycles
663                 for (Iterator<ValidationCycle> i = aStudy.getValidationCycles()
664                                 .values().iterator(); i.hasNext();) {
665                         ValidationCycle cycle = i.next();
666                         User[] user = cycle.getAllActors();
667                         for (int j = 0; j < user.length; j++) {
668                                 getModifiableActors(aStudy).add(user[j]);
669                         }
670                 }
671                 // Get all other actors
672                 for (Iterator<Relation> i = aStudy.getAllRelations().iterator(); i
673                                 .hasNext();) {
674                         Relation link = i.next();
675                         Class<?> kindof = link.getClass().getSuperclass();
676                         if (!kindof.equals(ActorRelation.class)) {
677                                 continue;
678                         }
679                         getModifiableActors(aStudy).add(((ActorRelation) link).getTo());
680                 }
681         }
682
683         /**
684          * Update lucene index for the study knowledge elements.
685          * 
686          * @param aStudy
687          *            the study
688          * @return true if reindexing succeeded
689          */
690         private boolean updateKnowledgeElementsIndex(final Study aStudy) {
691 //              boolean isOk = false;
692 //              try {
693 //                      IndexService lucin = getIndex();
694 //
695 //                      for (Iterator<Scenario> i = aStudy.getScenariiList().iterator(); i
696 //                                      .hasNext();) {
697 //                              Scenario scene = i.next();
698 //                              for (Iterator<KnowledgeElement> j = scene
699 //                                              .getAllKnowledgeElements().iterator(); j.hasNext();) {
700 //                                      KnowledgeElement kelm = j.next();
701 //                                      lucin.update(kelm);
702 //                              }
703 //                      }
704 //                      isOk = true;
705 //              } catch (Exception error) {
706 //                      LOG.error("Unable to re-index Knowledge Elements, reason:",
707 //                                      error);
708 //              }
709 //              return isOk;
710                 return true;
711         }
712
713         /**
714          * Get lucene index service. Create a lucene index if it does not exist.
715          * 
716          * @return index service
717          * @throws IOException
718          *             if error occurs during lucene index creation
719          */
720         private IndexService getIndex() throws IOException {
721                 IndexService lucin = getIndexService();
722                 if (IndexWriter.isLocked(FSDirectory.open(getRepositoryService()
723                                 .getRepositoryIndexDirectory()))) {
724                         IndexWriter.unlock(FSDirectory.open(getRepositoryService()
725                                         .getRepositoryIndexDirectory()));
726                 }
727                 if (!lucin.exists()) {
728                         lucin.create(); // Happens when re-indexing all studies
729                 }
730                 return lucin;
731         }
732
733         /**
734          * Create a new validation cycle for documents of the given study.
735          * 
736          * @param from
737          *            the study
738          * @param cycle
739          *            the cycle description
740          * @return the new validation cycle
741          */
742         protected ValidationCycle createValidationCycle(
743                         final Study from,
744                         final ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle) {
745                 Actor[] actype = cycle.getActorTypes();
746                 User.Properties uprop = new User.Properties();
747
748                 ValidationCycle aValidationCycle = new ValidationCycle();
749                 aValidationCycle.setDocumentType(getDocumentTypeService().selectType(
750                                 cycle.getName())); // Null in case of default validation cycle
751                 // context = new ValidationCycleRelation(from, vprop);
752                 // RKV aValidationCycle.context = null; // Validation cycle defined in the workflow
753                 for (int i = 0; i < actype.length; i++) {
754                         User actor = null;
755                         if (actype[i] != null) {
756                                 try {
757                                         if (actype[i] == Actor.manager) {
758                                                 actor = from.getAuthor();
759                                         } else if (actype[i] == Actor.Nx1) {
760                                                 List<User> manager = getUserService().selectUsersWhere(
761                                                                 uprop.setOrganizationName("Nx1"));
762                                                 if (manager.size() == 1) {
763                                                         actor = manager.get(0);
764                                                 }
765                                         } else if (actype[i] == Actor.Nx2) {
766                                                 List<User> manager = getUserService().selectUsersWhere(
767                                                                 uprop.setOrganizationName("Nx2"));
768                                                 if (manager.size() == 1) {
769                                                         actor = manager.get(0);
770                                                 }
771                                         } else { /* Actor.customer */
772                                                 actor = from.getAuthor();
773                                                 // TODO: Get the customer of the study, if exists
774                                         }
775                                 } catch (Exception e) { // Should not happen
776                                         actor = null;
777                                 }
778                         }
779                         if (i == 0) {
780                                 aValidationCycle.setReviewer(actor);
781                         } else if (i == 1) {
782                                 aValidationCycle.setApprover(actor);
783                         } else if (i == 2) {
784                                 aValidationCycle.setSignatory(actor);
785                         }
786                 }
787                 return aValidationCycle;
788         }
789
790         /**
791          * Remove a validation step from the validation cycle.
792          * 
793          * @param aValidationCycle
794          *            the validation cycle
795          * @param step
796          *            the validation step to remove
797          */
798         @Transactional
799         protected void remove(final ValidationCycle aValidationCycle,
800                         final ValidationStep step) {
801                 if (step == ValidationStep.REVIEW) {
802                         aValidationCycle.setReviewer(null);
803                 } else if (step == ValidationStep.APPROVAL) {
804                         aValidationCycle.setApprover(null);
805                 } else if (step == ValidationStep.ACCEPTANCE
806                                 || step == ValidationStep.REFUSAL) {
807                         aValidationCycle.setSignatory(null);
808                 }
809                 if (aValidationCycle.isSaved()) {
810                         getValidationCycleDAO().update(aValidationCycle);
811                 }
812         }
813
814         /**
815          * Reset actors for the validation cycle.
816          * 
817          * @param aValidationCycle
818          *            the validation cycle to update
819          * @param vprop
820          *            new validation cycle properties containing new actors
821          */
822         @Transactional
823         public void resetActors(final ValidationCycle aValidationCycle,
824                         final ValidationCycle.Properties vprop) {
825                 aValidationCycle.setPublisher(vprop.getPublisher()); // May be null
826                 aValidationCycle.setReviewer(vprop.getReviewer()); // May be null
827                 aValidationCycle.setApprover(vprop.getApprover()); // May be null
828                 aValidationCycle.setSignatory(vprop.getSignatory()); // May be null
829                 if (aValidationCycle.isSaved()) {
830                         getValidationCycleDAO().merge(aValidationCycle);
831                 }
832         }
833
834         /**
835          * Set actor for the given validation cycle and validation step.
836          * 
837          * @param aValidationCycle
838          *            the validation cycle
839          * @param step
840          *            the validation step
841          * @param actor
842          *            the actor to set
843          */
844         @Transactional
845         protected void setActor(final ValidationCycle aValidationCycle,
846                         final ValidationStep step, final User actor) {
847                 if (step == ValidationStep.PROMOTION) {
848                         aValidationCycle.setPublisher(actor);
849                 } else if (step == ValidationStep.REVIEW) {
850                         aValidationCycle.setReviewer(actor);
851                 } else if (step == ValidationStep.APPROVAL) {
852                         aValidationCycle.setApprover(actor);
853                 } else if (step == ValidationStep.ACCEPTANCE
854                                 || step == ValidationStep.REFUSAL) {
855                         aValidationCycle.setSignatory(actor);
856                 }
857                 if (aValidationCycle.isSaved()) {
858                         getValidationCycleDAO().update(aValidationCycle);
859                 }
860         }
861
862         /**
863          * Returns all actors of this study other than the author, including contributors, reviewers and approvers.
864          * 
865          * @param aStudy
866          *            the study
867          * @return the actors of this study
868          * @see #hasActor(User)
869          */
870         public Set<User> getActors(final Study aStudy) {
871                 if (aStudy.getActor() == null) {
872                         setShortCuts(aStudy);
873                 }
874                 return Collections.unmodifiableSet(aStudy.getActor());
875         }
876
877         /**
878          * Returns all actors of this study other than the author, including contributors, reviewers and approvers.
879          * 
880          * @param aStudy
881          *            the study
882          * @return the modifiable set of actors of this study
883          * @see #hasActor(User)
884          */
885         public Set<User> getModifiableActors(final Study aStudy) {
886                 if (aStudy.getActor() == null) {
887                         setShortCuts(aStudy);
888                 }
889                 return aStudy.getActor();
890         }
891
892         /**
893          * Returns unmodifiable initialized transient list of contributors of this study.
894          * 
895          * @param aStudy
896          *            the study
897          * @return the unmodifiable not null transient list of contributors of this study
898          */
899         public List<User> getContributors(final Study aStudy) {
900                 if (aStudy.getContributor() == null) {
901                         setShortCuts(aStudy);
902                 }
903                 return Collections.unmodifiableList(aStudy.getContributor()); // May be empty
904         }
905
906         /**
907          * Returns modifiable initialized transient list of contributors of this study.
908          * 
909          * @param aStudy
910          *            the study
911          * @return the modifiable not null transient list of contributors of this study
912          */
913         public List<User> getModifiableContributors(final Study aStudy) {
914                 if (aStudy.getContributor() == null) {
915                         setShortCuts(aStudy);
916                 }
917                 return aStudy.getContributor(); // May be empty
918         }
919
920         /**
921          * Returns the validation cycle of the given document type.
922          * 
923          * @param aStudy
924          *            the study
925          * @param type
926          *            the document type being subject of validation
927          * @return the validation cycle of the document, or null if not defined.
928          */
929         public ValidationCycle getValidationCycleOf(final Study aStudy,
930                         final DocumentType type) {
931                 if (aStudy.getValidationCycles() == null || aStudy.getValidationCycles().isEmpty()) {
932                         setShortCuts(aStudy);
933                 }
934                 ValidationCycle result = aStudy.getValidationCycles().get(
935                                 type.getName());
936                 if (result == null) {
937                         if (type.isStepResult()) {
938                                 result = aStudy.getValidationCycles().get("default"); // "default" validation cycle defined in the configuration, if exist
939                         }
940                         if (result == null) {
941                                 result = aStudy.getValidationCycles().get("built-in");
942                         }
943                 }
944                 return result;
945         }
946
947         /**
948          * Checks if the given user is actor of this study. Actors include contributors, reviewers and approvers.
949          * 
950          * @param aStudy
951          *            the study
952          * @param user
953          *            the user to look for
954          * @return true if the given user is actor of this study.
955          * @see #getActors()
956          */
957         public boolean hasActor(final Study aStudy, final User user) {
958                 if (user == null) {
959                         return false;
960                 }
961                 for (Iterator<User> i = getActors(aStudy).iterator(); i.hasNext();) {
962                         User involved = i.next();
963                         if (involved.equals(user)) {
964                                 return true;
965                         }
966                 }
967                 return false;
968         }
969
970         /**
971          * Checks if the given user participates to this study. The Study staff includes the author and contributors.
972          * 
973          * @param aStudy
974          *            the study
975          * @param user
976          *            the user to look for
977          * @return true if the given user is actor of this study.
978          * @see #getContributors()
979          */
980         public boolean isStaffedBy(final Study aStudy, final User user) {
981                 if (user == null) {
982                         return false;
983                 }
984                 if (aStudy == null) {
985                         return false;
986                 }
987                 if (aStudy.getAuthor() == null) {
988                         return false;
989                 }
990                 if (aStudy.getAuthor().equals(user)) {
991                         return true;
992                 }
993                 for (Iterator<User> i = getContributors(aStudy).iterator(); i.hasNext();) {
994                         if (i.next().equals(user)) {
995                                 return true;
996                         }
997                 }
998                 return false;
999         }
1000
1001         /**
1002          * Initialize shortcuts of the study as its transient collections.
1003          * 
1004          * @param aStudy
1005          *            the study
1006          */
1007         public void loadWorkflow(final Study aStudy) {
1008                 setShortCuts(aStudy);
1009         }
1010
1011         /**
1012          * Initialize shortcuts of the study as its transient collections.
1013          * 
1014          * @param aStudy
1015          *            the study
1016          */
1017         public void setShortCuts(final Study aStudy) {
1018                 aStudy.getContributor().clear();
1019                 aStudy.getValidationCycles().clear();
1020                 aStudy.getActor().clear();
1021
1022                 // Get the contributors
1023                 for (Iterator<Relation> i = aStudy.getRelations(
1024                                 ContributorRelation.class).iterator(); i.hasNext();) {
1025                         ContributorRelation link = (ContributorRelation) i.next();
1026                         aStudy.getContributor().add(link.getTo());
1027                 }
1028                 // Get the validation cycles specific to this study
1029                 for (Iterator<Relation> i = aStudy.getRelations(
1030                                 ValidationCycleRelation.class).iterator(); i.hasNext();) {
1031                         ValidationCycleRelation link = (ValidationCycleRelation) i.next();
1032                         aStudy.getValidationCycles().put(link.getDocumentType().getName(),
1033                                         link.getTo()); // The associated document type is necessarily not null in this
1034                         // context
1035                 }
1036                 // Get the validation cycles coming from the configured workflow and not overridden in this study
1037                 for (Iterator<ProjectSettingsServiceImpl.ProjectSettingsValidationCycle> i = getProjectSettings()
1038                                 .getAllValidationCycles().iterator(); i.hasNext();) {
1039                         ProjectSettingsServiceImpl.ProjectSettingsValidationCycle cycle = i
1040                                         .next();
1041                         String type = cycle.getName();
1042                         if (!aStudy.getValidationCycles().containsKey(type)) {
1043                                 aStudy.getValidationCycles().put(type,
1044                                                 createValidationCycle(aStudy, cycle));
1045                         }
1046                 }
1047                 // Get all corresponding actors
1048                 for (Iterator<ValidationCycle> i = aStudy.getValidationCycles()
1049                                 .values().iterator(); i.hasNext();) {
1050                         ValidationCycle cycle = i.next();
1051                         User[] user = cycle.getAllActors();
1052                         for (int j = 0; j < user.length; j++) {
1053                                 aStudy.getActor().add(user[j]);
1054                         }
1055                 }
1056                 // Get all other actors
1057                 for (Iterator<Relation> i = aStudy.getAllRelations().iterator(); i
1058                                 .hasNext();) {
1059                         Relation link = i.next();
1060                         Class<?> kindof = link.getClass().getSuperclass();
1061                         if (!kindof.equals(ActorRelation.class)) {
1062                                 continue;
1063                         }
1064                         aStudy.getActor().add(((ActorRelation) link).getTo());
1065                 }
1066         }
1067         
1068         /**
1069          * 
1070          * {@inheritDoc}
1071          * @see org.splat.service.StudyService#markStudyAsReference(org.splat.dal.bo.som.Study)
1072          */
1073         @Override
1074         @Transactional
1075         public void markStudyAsReference (final Study aStudy) {
1076                 
1077                 aStudy.setMarkreference(1);
1078                 aStudy.setProgressState(ProgressState.TEMPLATE);
1079                 getStudyDAO().merge(aStudy);
1080         }
1081         
1082         /**
1083          * 
1084          * {@inheritDoc}
1085          * @see org.splat.service.StudyService#removeStudyAsReference(org.splat.dal.bo.som.Study)
1086          */
1087         @Override
1088         @Transactional
1089         public void removeStudyAsReference(final Study aStudy) {
1090                 
1091                 aStudy.setMarkreference(0);
1092                 aStudy.setProgressState(ProgressState.APPROVED);
1093                 getStudyDAO().merge(aStudy);
1094         }
1095         
1096         /** 
1097          * {@inheritDoc}
1098          * @see org.splat.service.StudyService#getDescription(java.lang.Long)
1099          */
1100         @Override
1101         @Transactional(readOnly = true)
1102         public String getDescription(final Long studyId) throws InvalidParameterException {
1103                 if(studyId == null) {
1104                         throw new InvalidParameterException("studyId", "null");
1105                 }
1106                 Study study = _studyDAO.get(studyId);
1107                 if(study == null) {
1108                         throw new InvalidParameterException("studyId", studyId.toString());
1109                 }
1110                 return study.getDescription();
1111         }
1112         
1113         
1114         /** 
1115          * {@inheritDoc}
1116          * @see org.splat.service.StudyService#setDescription(java.lang.Long, java.lang.String)
1117          */
1118         @Override
1119         @Transactional
1120         public void setDescription(final Long studyId, final String descriptionText) 
1121                         throws InvalidParameterException {
1122                 if(studyId == null) {
1123                         throw new InvalidParameterException("studyId", "null");
1124                 }
1125                 Study study = _studyDAO.get(studyId);
1126                 if(study == null) {
1127                         throw new InvalidParameterException("studyId", studyId.toString());
1128                 }
1129                 study.setAttribute(new DescriptionAttribute(study, descriptionText));
1130         }
1131
1132         /**
1133          * {@inheritDoc}
1134          * @see org.splat.service.StudyService#removeStudyDescription(java.lang.Long)
1135          */
1136         @Override
1137         @Transactional
1138         public boolean removeDescription(final Long studyId) throws InvalidParameterException {
1139                 if(studyId == null) {
1140                         throw new InvalidParameterException("studyId", String.valueOf(studyId));
1141                 }
1142                 Study study = _studyDAO.get(studyId);
1143                 if(study == null) {
1144                         throw new InvalidParameterException("studyId", String.valueOf(studyId));
1145                 }
1146                 return study.removeAttribute(study.getAttribute(DescriptionAttribute.class));
1147         }
1148         
1149         /**
1150          * 
1151          * {@inheritDoc}
1152          * @see org.splat.service.StudyService#compare(java.util.List)
1153          */
1154         @Override
1155         public String compare (final List<DocToCompareDTO> docsList, final String userName) throws IncompatibleDataException {
1156                 
1157                 String axis1Name = "";
1158                 String axis2Name = "";
1159                 String resultPath = "";
1160                 
1161                 XYSeriesCollection dataset = new XYSeriesCollection();
1162                 
1163                 Iterator<DocToCompareDTO> docListIter = docsList.iterator();
1164                 
1165                 for (; docListIter.hasNext();) {
1166                         
1167                         DocToCompareDTO docDTO = docListIter.next();
1168                         String pathToFile = docDTO.getPathToFile();
1169                         File compDocFile = new File(pathToFile);
1170                         
1171                         resultPath = pathToFile.substring(0, pathToFile.indexOf("vault")) + "downloads" + File.separator + userName + File.separator + "ComparisonResult.pdf";
1172                         
1173                         XYSeries series = new XYSeries("Study: " + docDTO.getStudyTitle() + " Scenario: " + docDTO.getScenarioTitle());
1174                         
1175                         //read the file and get points information.
1176                         try {
1177                                 Scanner input = new Scanner(compDocFile);
1178                                 
1179                                 //get the name of the axis.
1180                                 if (input.hasNext()) {
1181                                         String[] tokens = input.nextLine().split(",");
1182                                         
1183                                         if (tokens.length < 2)
1184                                                 throw new IncompatibleDataException(MessageKeyEnum.IDT_000001.toString());
1185                                         
1186                                         if ("".equals(axis1Name)) {
1187                                                 axis1Name = tokens[0];
1188                                         } else if (!axis1Name.equals(tokens[0])) {
1189                                                 LOG.debug("Axis must be the same for all documents");
1190                                                 throw new IncompatibleDataException(MessageKeyEnum.IDT_000001.toString());
1191                                         }
1192                                         
1193                                         if ("".equals(axis2Name)) {
1194                                                 axis2Name = tokens[1];
1195                                         } else if (!axis2Name.equals(tokens[1])) {
1196                                                 LOG.debug("Axis must be the same for all documents");
1197                                                 throw new IncompatibleDataException(MessageKeyEnum.IDT_000001.toString());
1198                                         }
1199                                 }
1200                                 
1201                                 //Get the XY points series.
1202                                 while(input.hasNext()) {
1203                                         
1204                                         String currentString = input.nextLine();
1205                                         
1206                                         if ("".equals(currentString)) {
1207                                                 continue;
1208                                         }
1209                                         else {
1210                                                 String[] tokens = currentString.split(" ");
1211                                                 series.add(Double.valueOf(tokens[0]), Double.valueOf(tokens[1]));
1212                                         }                   
1213                                   
1214                                 } //while
1215                                 
1216                                 dataset.addSeries(series);
1217                                 
1218                         } catch (FileNotFoundException e) {
1219                                 // TODO Auto-generated catch block
1220                                 e.printStackTrace();
1221                                 return "ERROR";
1222                         }
1223                 } //for
1224                 
1225                 JFreeChart chart = ChartFactory.createXYLineChart(
1226                                 "Comparision of Studies Results", // Title
1227                                 axis1Name, // x-axis Label
1228                                 axis2Name, // y-axis Label
1229                                 dataset, // Dataset
1230                                 PlotOrientation.VERTICAL, // Plot Orientation
1231                                 true, // Show Legend
1232                                 true, // Use tooltips
1233                                 false // Configure chart to generate URLs?
1234                                 );
1235                 
1236                 //export to PDF - file.                 
1237                 int x = 500;
1238                 int y = 300;
1239                 Rectangle pagesize = new Rectangle(x, y);
1240                 Document document = new Document(pagesize, 50, 50, 50, 50);
1241         PdfWriter writer;
1242                 try {
1243                         File resFile = new File(resultPath);
1244                         File resFolder = new File(resultPath.substring(0, resultPath.lastIndexOf(File.separator)));
1245                         resFolder.mkdirs();
1246                         writer = PdfWriter.getInstance(document, new FileOutputStream(resFile));
1247                 
1248                 document.open();
1249                 PdfContentByte cb = writer.getDirectContent();
1250                 PdfTemplate tp = cb.createTemplate(x, y);
1251                 Graphics2D g2 = tp.createGraphics(x, y, new DefaultFontMapper());
1252                 chart.draw(g2, new java.awt.Rectangle(x,y));
1253                 g2.dispose();
1254                 cb.addTemplate(tp, 0, 0);
1255                 document.close(); 
1256         
1257                 } catch (FileNotFoundException e) {
1258                         // TODO Auto-generated catch block
1259                         e.printStackTrace();
1260                 } catch (DocumentException e) {
1261                         // TODO Auto-generated catch block
1262                         e.printStackTrace();
1263                 }
1264                 
1265                 return resultPath;
1266         }
1267
1268         /**
1269          * Get project settings.
1270          * 
1271          * @return Project settings service
1272          */
1273         private ProjectSettingsService getProjectSettings() {
1274                 return _projectSettings;
1275         }
1276
1277         /**
1278          * Set project settings service.
1279          * 
1280          * @param projectSettingsService
1281          *            project settings service
1282          */
1283         public void setProjectSettings(
1284                         final ProjectSettingsService projectSettingsService) {
1285                 _projectSettings = projectSettingsService;
1286         }
1287
1288         /**
1289          * Get the projectElementService.
1290          * 
1291          * @return the projectElementService
1292          */
1293         public ProjectElementService getProjectElementService() {
1294                 return _projectElementService;
1295         }
1296
1297         /**
1298          * Set the projectElementService.
1299          * 
1300          * @param projectElementService
1301          *            the projectElementService to set
1302          */
1303         public void setProjectElementService(
1304                         final ProjectElementService projectElementService) {
1305                 _projectElementService = projectElementService;
1306         }
1307
1308         /**
1309          * Get the stepService.
1310          * 
1311          * @return the stepService
1312          */
1313         public StepService getStepService() {
1314                 return _stepService;
1315         }
1316
1317         /**
1318          * Set the stepService.
1319          * 
1320          * @param stepService
1321          *            the stepService to set
1322          */
1323         public void setStepService(final StepService stepService) {
1324                 _stepService = stepService;
1325         }
1326
1327         /**
1328          * Get the indexService.
1329          * 
1330          * @return the indexService
1331          */
1332         public IndexService getIndexService() {
1333                 return _indexService;
1334         }
1335
1336         /**
1337          * Set the indexService.
1338          * 
1339          * @param indexService
1340          *            the indexService to set
1341          */
1342         public void setIndexService(final IndexService indexService) {
1343                 _indexService = indexService;
1344         }
1345
1346         /**
1347          * Get the studyDAO.
1348          * 
1349          * @return the studyDAO
1350          */
1351         public StudyDAO getStudyDAO() {
1352                 return _studyDAO;
1353         }
1354
1355         /**
1356          * Set the studyDAO.
1357          * 
1358          * @param studyDAO
1359          *            the studyDAO to set
1360          */
1361         public void setStudyDAO(final StudyDAO studyDAO) {
1362                 _studyDAO = studyDAO;
1363         }
1364
1365         /**
1366          * Get the iDBuilderDAO.
1367          * 
1368          * @return the iDBuilderDAO
1369          */
1370         public IDBuilderDAO getIDBuilderDAO() {
1371                 return _iDBuilderDAO;
1372         }
1373
1374         /**
1375          * Set the iDBuilderDAO.
1376          * 
1377          * @param builderDAO
1378          *            the iDBuilderDAO to set
1379          */
1380         public void setIDBuilderDAO(final IDBuilderDAO builderDAO) {
1381                 _iDBuilderDAO = builderDAO;
1382         }
1383
1384         /**
1385          * Get the scenarioDAO.
1386          * 
1387          * @return the scenarioDAO
1388          */
1389         public ScenarioDAO getScenarioDAO() {
1390                 return _scenarioDAO;
1391         }
1392
1393         /**
1394          * Set the scenarioDAO.
1395          * 
1396          * @param scenarioDAO
1397          *            the scenarioDAO to set
1398          */
1399         public void setScenarioDAO(final ScenarioDAO scenarioDAO) {
1400                 _scenarioDAO = scenarioDAO;
1401         }
1402
1403         /**
1404          * Get the validationCycleDAO.
1405          * 
1406          * @return the validationCycleDAO
1407          */
1408         public ValidationCycleDAO getValidationCycleDAO() {
1409                 return _validationCycleDAO;
1410         }
1411
1412         /**
1413          * Set the validationCycleDAO.
1414          * 
1415          * @param validationCycleDAO
1416          *            the validationCycleDAO to set
1417          */
1418         public void setValidationCycleDAO(
1419                         final ValidationCycleDAO validationCycleDAO) {
1420                 _validationCycleDAO = validationCycleDAO;
1421         }
1422
1423         /**
1424          * Get the documentTypeService.
1425          * 
1426          * @return the documentTypeService
1427          */
1428         public DocumentTypeService getDocumentTypeService() {
1429                 return _documentTypeService;
1430         }
1431
1432         /**
1433          * Set the documentTypeService.
1434          * 
1435          * @param documentTypeService
1436          *            the documentTypeService to set
1437          */
1438         public void setDocumentTypeService(
1439                         final DocumentTypeService documentTypeService) {
1440                 _documentTypeService = documentTypeService;
1441         }
1442
1443         /**
1444          * Get the userService.
1445          * 
1446          * @return the userService
1447          */
1448         public UserService getUserService() {
1449                 return _userService;
1450         }
1451
1452         /**
1453          * Set the userService.
1454          * 
1455          * @param userService
1456          *            the userService to set
1457          */
1458         public void setUserService(final UserService userService) {
1459                 _userService = userService;
1460         }
1461
1462         /**
1463          * Get the publicationDAO.
1464          * @return the publicationDAO
1465          */
1466         public PublicationDAO getPublicationDAO() {
1467                 return _publicationDAO;
1468         }
1469
1470         /**
1471          * Set the publicationDAO.
1472          * @param publicationDAO the publicationDAO to set
1473          */
1474         public void setPublicationDAO(final PublicationDAO publicationDAO) {
1475                 _publicationDAO = publicationDAO;
1476         }
1477
1478         /**
1479          * Get the repositoryService.
1480          * @return the repositoryService
1481          */
1482         public RepositoryService getRepositoryService() {
1483                 return _repositoryService;
1484         }
1485
1486         /**
1487          * Set the repositoryService.
1488          * @param repositoryService the repositoryService to set
1489          */
1490         public void setRepositoryService(final RepositoryService repositoryService) {
1491                 _repositoryService = repositoryService;
1492         }
1493
1494         /**
1495          * Get the documentDAO.
1496          * @return the documentDAO
1497          */
1498         public DocumentDAO getDocumentDAO() {
1499                 return _documentDAO;
1500         }
1501
1502         /**
1503          * Set the documentDAO.
1504          * @param documentDAO the documentDAO to set
1505          */
1506         public void setDocumentDAO(final DocumentDAO documentDAO) {
1507                 _documentDAO = documentDAO;
1508         }
1509
1510         /**
1511          * Get the descriptionAttributeDAO.
1512          * @return the descriptionAttributeDAO
1513          */
1514         public DescriptionAttributeDAO getDescriptionAttributeDAO() {
1515                 return _descriptionAttributeDAO;
1516         }
1517
1518         /**
1519          * Set the descriptionAttributeDAO.
1520          * @param descriptionAttributeDAO the descriptionAttributeDAO to set
1521          */
1522         public void setDescriptionAttributeDAO(
1523                         final DescriptionAttributeDAO descriptionAttributeDAO) {
1524                 _descriptionAttributeDAO = descriptionAttributeDAO;
1525         }
1526
1527 }