Rev 1580 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1579 | jmachado | 1 | package pt.estgp.estgweb.services.questionarios; |
2 | |||
3 | import jomm.dao.impl.AbstractDao; |
||
4 | import org.apache.log4j.Logger; |
||
5 | import pt.estgp.estgweb.domain.*; |
||
6 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
||
7 | import pt.estgp.estgweb.services.jobs.JobDeamon; |
||
8 | import pt.estgp.estgweb.services.jobs.ServiceJob; |
||
9 | import pt.estgp.estgweb.utils.ConfigProperties; |
||
10 | import pt.estgp.estgweb.web.exceptions.NotAuthorizedException; |
||
11 | import pt.estgp.estgweb.web.form.questionarios.widgets.ReportAdminAlunosWidgetForm; |
||
12 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
||
13 | |||
14 | import java.util.ArrayList; |
||
15 | import java.util.HashSet; |
||
16 | import java.util.List; |
||
17 | import java.util.Set; |
||
18 | |||
19 | /** |
||
20 | * Created by jorgemachado on 21/03/16. |
||
21 | */ |
||
22 | public class QuestionariosReportsService implements IService |
||
23 | { |
||
24 | |||
25 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(QuestionariosReportsService.class); |
||
26 | |||
27 | |||
28 | public void saveReportGroup(1.5.0/docs/api/java/lang/String.html">String title,1.5.0/docs/api/java/lang/String.html">String classType, UserSession userSession) throws 1.5.0/docs/api/java/lang/ClassNotFoundException.html">ClassNotFoundException, 1.5.0/docs/api/java/lang/IllegalAccessException.html">IllegalAccessException, 1.5.0/docs/api/java/lang/InstantiationException.html">InstantiationException |
||
29 | { |
||
30 | QuestionarioReportFileGroup reportFileGroup = (QuestionarioReportFileGroup) 1.5.0/docs/api/java/lang/Class.html">Class.forName(classType).newInstance(); |
||
31 | reportFileGroup.setTitle(title); |
||
32 | 1.5.0/docs/api/java/lang/String.html">String processorClassForGroup = ConfigProperties.getProperty("questionarios.processor." + classType); |
||
33 | reportFileGroup.setReportProcessorClass(processorClassForGroup); |
||
34 | AbstractDao.getCurrentSession().save(reportFileGroup); |
||
35 | } |
||
36 | |||
37 | public QuestionarioReportFileGroupImpl runJobGenerate(long reportGroupId, UserSession session) throws NotAuthorizedException, 1.5.0/docs/api/java/lang/ClassNotFoundException.html">ClassNotFoundException { |
||
38 | |||
39 | QuestionarioReportFileGroupImpl reportGroup = (QuestionarioReportFileGroupImpl) DaoFactory.getQuestionarioReportFileGroupDaoImpl().load(reportGroupId); |
||
40 | |||
41 | Set<JobServiceTaskParameter> paramsJob = new HashSet<JobServiceTaskParameter>(); |
||
42 | |||
43 | JobServiceTaskParameterImpl paramJob = DomainObjectFactory.createJobServiceTaskParameterImpl(); |
||
44 | paramJob.setName(ServiceJob.JOB_questionario_report_id_KEY); |
||
45 | paramJob.setDescription("ID do Report Group"); |
||
46 | paramJob.setObject("" + reportGroupId); |
||
47 | paramsJob.add(paramJob); |
||
48 | |||
49 | 1.5.0/docs/api/java/lang/Class.html">Class reportGeneratorServiceClass = 1.5.0/docs/api/java/lang/Class.html">Class.forName(reportGroup.getReportProcessorClass()); |
||
50 | |||
51 | JobServiceTask job = JobDeamon.createServiceJob(reportGeneratorServiceClass, session.getUser(), paramsJob, |
||
52 | "Service: Geração de Reports para o group " + reportGroupId + " - " + reportGroup.getTitle()); |
||
53 | reportGroup.setReportGenerationTaskId(job.getId()); |
||
54 | |||
55 | return reportGroup; |
||
56 | } |
||
57 | |||
58 | |||
59 | /*************WIDGET ALUNOS REPORTS***************/ |
||
60 | |||
61 | public void saveReportGroupAlunosParameters(ReportAdminAlunosWidgetForm form, UserSession userSession) throws 1.5.0/docs/api/java/lang/ClassNotFoundException.html">ClassNotFoundException, 1.5.0/docs/api/java/lang/IllegalAccessException.html">IllegalAccessException, 1.5.0/docs/api/java/lang/InstantiationException.html">InstantiationException |
||
62 | { |
||
63 | QuestionarioReportFileGroupAnoImpl reportGroup = (QuestionarioReportFileGroupAnoImpl) DaoFactory.getQuestionarioReportFileGroupAnoDaoImpl().load(form.getQuestionarioReportGroupId()); |
||
64 | List<String> periodos = new ArrayList<String>(); |
||
65 | List<String> degrees = new ArrayList<String>(); |
||
66 | reportGroup.setImportYear(form.getAno()); |
||
67 | |||
68 | if(form.isAnuais()) |
||
69 | periodos.add("A"); |
||
70 | if(form.isSemestre1()) |
||
71 | periodos.add("S1"); |
||
72 | if(form.isSemestre2()) |
||
73 | periodos.add("S2"); |
||
74 | if(form.isTrimestre1()) |
||
75 | periodos.add("T1"); |
||
76 | if(form.isTrimestre2()) |
||
77 | periodos.add("T2"); |
||
78 | if(form.isTrimestre3()) |
||
79 | periodos.add("T3"); |
||
80 | if(form.isTrimestre4()) |
||
81 | periodos.add("T4"); |
||
82 | |||
83 | if(form.isLicenciaturas()) |
||
84 | degrees.add("L"); |
||
85 | if(form.isMestrados()) |
||
86 | degrees.add("M"); |
||
87 | if(form.isTesps()) |
||
88 | degrees.add("T"); |
||
89 | if(form.isCets()) |
||
90 | degrees.add("E"); |
||
91 | |||
92 | |||
93 | reportGroup.setPeriodosList(periodos); |
||
94 | reportGroup.setDegreesList(degrees); |
||
95 | |||
96 | |||
97 | } |
||
98 | |||
99 | |||
100 | |||
101 | |||
102 | } |