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