Subversion Repositories bacoAlunos

Rev

Rev 1579 | Rev 1586 | 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 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
 
1580 jmachado 37
    public void updateReportGroup(long reportGroupId, 1.5.0/docs/api/java/lang/String.html">String title, 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
38
    {
39
        QuestionarioReportFileGroupImpl reportGroup = (QuestionarioReportFileGroupImpl) DaoFactory.getQuestionarioReportFileGroupDaoImpl().load(reportGroupId);
40
        reportGroup.setTitle(title);
41
    }
1579 jmachado 42
 
1580 jmachado 43
    public QuestionarioReportFileGroupImpl runJobGenerate(long reportGroupId,1.5.0/docs/api/java/lang/String.html">String title, UserSession session) throws NotAuthorizedException, 1.5.0/docs/api/java/lang/ClassNotFoundException.html">ClassNotFoundException {
44
 
1579 jmachado 45
        QuestionarioReportFileGroupImpl reportGroup = (QuestionarioReportFileGroupImpl) DaoFactory.getQuestionarioReportFileGroupDaoImpl().load(reportGroupId);
1580 jmachado 46
        reportGroup.setTitle(title);
1579 jmachado 47
        Set<JobServiceTaskParameter> paramsJob = new HashSet<JobServiceTaskParameter>();
48
 
49
        JobServiceTaskParameterImpl paramJob = DomainObjectFactory.createJobServiceTaskParameterImpl();
50
        paramJob.setName(ServiceJob.JOB_questionario_report_id_KEY);
51
        paramJob.setDescription("ID do Report Group");
52
        paramJob.setObject("" + reportGroupId);
53
        paramsJob.add(paramJob);
54
 
55
        1.5.0/docs/api/java/lang/Class.html">Class reportGeneratorServiceClass = 1.5.0/docs/api/java/lang/Class.html">Class.forName(reportGroup.getReportProcessorClass());
56
 
57
        JobServiceTask job = JobDeamon.createServiceJob(reportGeneratorServiceClass, session.getUser(), paramsJob,
58
                "Service: Geração de Reports para o group " + reportGroupId + " - " + reportGroup.getTitle());
59
        reportGroup.setReportGenerationTaskId(job.getId());
60
 
61
        return reportGroup;
62
    }
63
 
64
 
65
    /*************WIDGET ALUNOS REPORTS***************/
66
 
67
    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
68
    {
69
        QuestionarioReportFileGroupAnoImpl reportGroup = (QuestionarioReportFileGroupAnoImpl) DaoFactory.getQuestionarioReportFileGroupAnoDaoImpl().load(form.getQuestionarioReportGroupId());
70
        List<String> periodos = new ArrayList<String>();
71
        List<String> degrees = new ArrayList<String>();
72
        reportGroup.setImportYear(form.getAno());
73
 
74
        if(form.isAnuais())
75
            periodos.add("A");
76
        if(form.isSemestre1())
77
            periodos.add("S1");
78
        if(form.isSemestre2())
79
            periodos.add("S2");
80
        if(form.isTrimestre1())
81
            periodos.add("T1");
82
        if(form.isTrimestre2())
83
            periodos.add("T2");
84
        if(form.isTrimestre3())
85
            periodos.add("T3");
86
        if(form.isTrimestre4())
87
            periodos.add("T4");
88
 
89
        if(form.isLicenciaturas())
90
            degrees.add("L");
91
        if(form.isMestrados())
92
            degrees.add("M");
93
        if(form.isTesps())
94
            degrees.add("T");
95
        if(form.isCets())
96
            degrees.add("E");
97
 
98
 
99
        reportGroup.setPeriodosList(periodos);
100
        reportGroup.setDegreesList(degrees);
101
 
102
 
103
    }
104
 
105
 
106
 
107
 
108
}