Rev 1586 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1544 | jmachado | 1 | package pt.estgp.estgweb.services.questionarios.pedagogico; |
2 | |||
1545 | jmachado | 3 | import jomm.dao.impl.AbstractDao; |
1566 | jmachado | 4 | import jomm.utils.MyCalendar; |
1544 | jmachado | 5 | import org.apache.log4j.Logger; |
1545 | jmachado | 6 | import pt.estgp.estgweb.domain.*; |
1544 | jmachado | 7 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
8 | import pt.estgp.estgweb.services.jobs.ServiceJob; |
||
9 | import pt.estgp.estgweb.services.logresults.ILogMessages; |
||
1545 | jmachado | 10 | import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum; |
11 | import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage; |
||
1544 | jmachado | 12 | import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages; |
1565 | jmachado | 13 | import pt.estgp.estgweb.utils.ConfigProperties; |
1566 | jmachado | 14 | import pt.estgp.estgweb.utils.DatesUtils; |
1553 | jmachado | 15 | import pt.estgp.estgweb.utils.DistritosUtils; |
1544 | jmachado | 16 | |
1547 | jmachado | 17 | import java.util.*; |
1544 | jmachado | 18 | |
1545 | jmachado | 19 | |
1544 | jmachado | 20 | /** |
21 | * Created by jorgemachado on 22/03/16. |
||
22 | */ |
||
23 | public class OlapGenerationProcessor extends ServiceJob |
||
24 | { |
||
25 | |||
26 | //int unidadesNaoUtilizadas = 0; |
||
27 | |||
28 | |||
29 | private static 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(OlapGenerationProcessor.class); |
||
30 | |||
1545 | jmachado | 31 | int unidadesNaoUtilizadas = 0; |
32 | int unidadesUtilizadas = 0; |
||
1626 | jmachado | 33 | int tipologiasExcluidas = 0; |
1545 | jmachado | 34 | //int unidadesMarcadas = 0; |
35 | //int unidadesNaoVistasProf = 0; |
||
36 | //int unidadesNaoVistasAlunos = 0; |
||
37 | int cursosUtilizados = 0; |
||
38 | //int respostasRequisitadas = 0; |
||
1546 | jmachado | 39 | int cursosSemDepartamento = 0; |
1547 | jmachado | 40 | int unidadesSemPeriodoNoPlano = 0; |
1544 | jmachado | 41 | |
1545 | jmachado | 42 | |
1547 | jmachado | 43 | |
1544 | jmachado | 44 | /** |
45 | * ############# JOB TASK ############ |
||
46 | * ############# JOB TASK ############ |
||
47 | * @return |
||
48 | * @throws Throwable |
||
49 | */ |
||
50 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
51 | protected ILogMessages runJobServiceTask() throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable |
||
52 | { |
||
53 | |||
1545 | jmachado | 54 | |
1544 | jmachado | 55 | long questionarioId = 1.5.0/docs/api/java/lang/Long.html">Long.parseLong(getParametersMap().get(ServiceJob.JOB_questionario_id_KEY).getObject()); |
56 | DefaultLogMessages logMessages = new DefaultLogMessages(); |
||
57 | |||
58 | //unidadesNaoUtilizadas = 0; |
||
59 | |||
1545 | jmachado | 60 | unidadesNaoUtilizadas = 0; |
61 | unidadesUtilizadas = 0; |
||
62 | //unidadesMarcadas = 0; |
||
63 | //unidadesNaoVistasProf = 0; |
||
64 | //unidadesNaoVistasAlunos = 0; |
||
65 | cursosUtilizados = 0; |
||
66 | //respostasRequisitadas = 0; |
||
1544 | jmachado | 67 | |
1546 | jmachado | 68 | cursosSemDepartamento = 0; |
1547 | jmachado | 69 | unidadesSemPeriodoNoPlano = 0; |
1545 | jmachado | 70 | |
71 | |||
1546 | jmachado | 72 | |
1544 | jmachado | 73 | QuestionarioImpl q = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().load(questionarioId); |
1545 | jmachado | 74 | try{ |
1544 | jmachado | 75 | |
1549 | jmachado | 76 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapStarFactQuestionarioCurso.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
77 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapStarFactQuestionarioUnidade.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
||
78 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapStarFactQuestionarioTipologia.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
||
79 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapStarFactQuestionario.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
||
1547 | jmachado | 80 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapStarFactQuestionarioAnswer.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
1572 | jmachado | 81 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapStarFactQuestionarioAnswerEsforco.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
1544 | jmachado | 82 | |
1553 | jmachado | 83 | AbstractDao.getCurrentSession().getTransaction().commit(); |
84 | AbstractDao.getCurrentSession().beginTransaction(); |
||
1549 | jmachado | 85 | |
1547 | jmachado | 86 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapEntityQuestionarioUser.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
87 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapEntityQuestionarioCurso.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
||
88 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapEntityQuestionarioUnidade.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
||
89 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapEntityQuestionarioPergunta.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
||
1572 | jmachado | 90 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapEntityQuestionarioPerguntaEsforco.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
1547 | jmachado | 91 | AbstractDao.getCurrentSession().createQuery("delete from " + OlapEntityQuestionarioTipologia.class.getName() + " x where x.questionario.id = " + questionarioId).executeUpdate(); |
1545 | jmachado | 92 | |
1553 | jmachado | 93 | AbstractDao.getCurrentSession().getTransaction().commit(); |
94 | AbstractDao.getCurrentSession().beginTransaction(); |
||
1545 | jmachado | 95 | |
1553 | jmachado | 96 | q = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().load(questionarioId); |
1545 | jmachado | 97 | |
1547 | jmachado | 98 | List<OlapEntityQuestionario> questionarios = AbstractDao.getCurrentSession().createQuery("select x from x in class " + OlapEntityQuestionario.class.getName() + " where x.questionario.id = " + questionarioId).list(); |
99 | OlapEntityQuestionario olapQuestionario; |
||
100 | OlapHistoryDimension olapHistoryDimension; |
||
101 | if(questionarios.size() > 0) |
||
102 | { |
||
103 | olapQuestionario = questionarios.get(0); |
||
104 | updateOlapQuestionario(olapQuestionario, q); |
||
105 | List<OlapHistoryDimension> histories = AbstractDao.getCurrentSession().createQuery("select x from x in class " + OlapHistoryDimension.class.getName() + " where x.questionario.id = " + questionarioId).list(); |
||
106 | olapHistoryDimension = histories.get(0); |
||
107 | } |
||
108 | else |
||
109 | { |
||
110 | //+++++++ todo CRIANDO OLAP Questionario |
||
111 | olapQuestionario = createQuestionarioOlap(q); |
||
1586 | jmachado | 112 | olapHistoryDimension = new OlapHistoryDimensionImpl(); |
1547 | jmachado | 113 | olapHistoryDimension.setQuestionario(q); |
114 | //+++++++ todo CRIANDO OLAP History |
||
115 | DaoFactory.getOlapHistoryDimensionDaoImpl().save(olapHistoryDimension); |
||
116 | } |
||
117 | olapHistoryDimension.setNome(q.getQuestionarioHistoryDrive().getCodeName()); |
||
118 | olapHistoryDimension.setDescricao(q.getQuestionarioHistoryDrive().getDescription()); |
||
1545 | jmachado | 119 | |
120 | |||
1547 | jmachado | 121 | //Colocamos já aqui o estado para nao se poder mudar o Ano e o Semestre |
1544 | jmachado | 122 | |
1547 | jmachado | 123 | /**logging**/ |
124 | 1.5.0/docs/api/java/lang/String.html">String msg = "Starting running service OLAP GENERATION generation for questionario: " + q.getId() + " - " + q.getiAnswersProcessorClass().getTitle(); |
||
125 | serviceLogInfo(msg); |
||
126 | logger.info(msg); |
||
1544 | jmachado | 127 | |
1547 | jmachado | 128 | List<Long> cursosAfetosIds = DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().findCursosAfetosIds(questionarioId); |
129 | int count = 0; |
||
130 | int size=cursosAfetosIds.size(); |
||
1544 | jmachado | 131 | |
132 | |||
1547 | jmachado | 133 | //+++++++ todo CRIANDO OLAP Perguntas |
134 | HashMap<Integer,Long> mapaIdsPerguntasPersistentes = createOlapQuestionarioPergunta(q); |
||
1572 | jmachado | 135 | HashMap<Integer,Long> mapaIdsPerguntasEsforcoPersistentes = createOlapQuestionarioPerguntaEsforco(q); |
1545 | jmachado | 136 | |
137 | |||
1547 | jmachado | 138 | for(1.5.0/docs/api/java/lang/Long.html">Long cursoAfetoId : cursosAfetosIds) |
139 | { |
||
140 | count++; |
||
1545 | jmachado | 141 | |
1547 | jmachado | 142 | /** COMMIT OPERATION **/ |
143 | setProgress((int)((((float)count)/((float)size))*100.0f)); |
||
144 | commitPartially(); |
||
145 | q = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().load(questionarioId); |
||
146 | /** COMMIT OPERATION **/ |
||
1544 | jmachado | 147 | |
148 | |||
149 | |||
1547 | jmachado | 150 | QuestionarioPedagogicoCursoAfeto cu = DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().get(cursoAfetoId); |
151 | msg = "(+) Iniciando geração OLAP para o curso " + cu.getNome() + " (" + cu.getCodigoCurso() + ") escola " + cu.getNomeInstituicao() + "(" + cu.getCodigoInstituicao() + ")"; |
||
152 | logger.info(msg); |
||
153 | serviceLogInfo(msg); |
||
1544 | jmachado | 154 | |
1547 | jmachado | 155 | //+++++++ todo CRIANDO OLAP Curso |
1549 | jmachado | 156 | int unidadesCurso = 0; |
157 | int tipologiasCurso = 0; |
||
158 | int respostasCandidatasCurso = 0; |
||
159 | int respostasObtidasCurso = 0; |
||
1547 | jmachado | 160 | OlapEntityQuestionarioCurso olapQuestionarioCurso = createQuestionarioCursoOlap(logMessages, q, cu); |
1544 | jmachado | 161 | |
1547 | jmachado | 162 | int unidades; |
163 | if(cu.getUnidadesAfetas() != null) |
||
1545 | jmachado | 164 | { |
1547 | jmachado | 165 | unidades = cu.getUnidadesAfetas().size(); |
1549 | jmachado | 166 | unidadesCurso = unidades; |
1547 | jmachado | 167 | int countUnidades = 0; |
168 | for(QuestionarioPedagogicoUnidadeCurricularAfeta unidadeCurricularAfeta: cu.getUnidadesAfetas()) |
||
169 | { |
||
170 | countUnidades++; |
||
171 | msg = unidadeCurricularAfeta.isUsar() ? "(+)" : "(----IGNORADA-----)"; |
||
172 | msg += "(" + countUnidades + "/" + unidades + ") Iniciando OLAP de Unidade Curricular Afeta " + unidadeCurricularAfeta.getCodigoUnidade() + " - " + unidadeCurricularAfeta.getNome(); |
||
173 | logger.info(msg); |
||
174 | serviceLogInfo(msg); |
||
1545 | jmachado | 175 | |
176 | |||
1547 | jmachado | 177 | if(!unidadeCurricularAfeta.isUsar() || !unidadeCurricularAfeta.isUsarOlap()) |
178 | { |
||
179 | unidadesNaoUtilizadas++; |
||
180 | msg = "!!! A unidade está marcada para NÃO SER UTILIZADA, passando à próxima"; |
||
181 | serviceLogWarn(msg); |
||
182 | logger.warn(msg); |
||
183 | logMessages.addMessage(new DefaultLogMessage("questionario.olap", LogMessageTypeEnum.WARNING,msg)); |
||
184 | } |
||
185 | else |
||
186 | { |
||
187 | CourseUnitImpl cuImpl = (CourseUnitImpl) DaoFactory.getCourseUnitDaoImpl().narrow(unidadeCurricularAfeta.getCourseUnit()); |
||
188 | CourseImpl courseImpl = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(unidadeCurricularAfeta.getCourseUnit().getCourse()); |
||
1545 | jmachado | 189 | |
1547 | jmachado | 190 | //TODO CRIANDO ENTIDADE OLAP UNIDADE |
1549 | jmachado | 191 | int tipologiasUnidade = unidadeCurricularAfeta.getTipologiasRequisitadas().size(); |
192 | int respostasCandidatasUnidade = 0; |
||
193 | int respostasObtidasUnidade = 0; |
||
194 | tipologiasCurso += tipologiasUnidade; |
||
1547 | jmachado | 195 | OlapEntityQuestionarioUnidade olapQuestionarioUnidade = createOlapQuestionarioUnidade(logMessages, q, unidadeCurricularAfeta, cuImpl); |
1545 | jmachado | 196 | |
1547 | jmachado | 197 | unidadesUtilizadas++; |
1545 | jmachado | 198 | |
1547 | jmachado | 199 | for(QuestionarioPedagogicoTipologiaRequisitada tipologiaRequisitada: unidadeCurricularAfeta.getTipologiasRequisitadas()) |
1545 | jmachado | 200 | { |
1547 | jmachado | 201 | msg ="Iniciando OLAP de Tipologia Requisitada " + tipologiaRequisitada.getDsTipologia() + " " + tipologiaRequisitada.getCdTipologia() |
202 | + " docente: " + tipologiaRequisitada.getCdDocente() + "(" + tipologiaRequisitada.getNomeDocente() + ")" |
||
203 | + " turma: " + tipologiaRequisitada.getCdTurma(); |
||
204 | serviceLogInfo(msg); |
||
205 | logger.info(msg); |
||
1545 | jmachado | 206 | |
1626 | jmachado | 207 | if(!AnswersAlunosProcessor.canUse(tipologiaRequisitada,cuImpl)) |
208 | { |
||
209 | tipologiasExcluidas ++; |
||
210 | msg ="------###### Tipologia Excluida do processamento " + tipologiaRequisitada.getDsTipologia() + " " + tipologiaRequisitada.getCdTipologia() |
||
211 | + " docente: " + tipologiaRequisitada.getCdDocente() + "(" + tipologiaRequisitada.getNomeDocente() + ")" |
||
212 | + " turma: " + tipologiaRequisitada.getCdTurma(); |
||
213 | serviceLogInfo(msg); |
||
214 | logger.info(msg); |
||
215 | continue; |
||
216 | } |
||
1545 | jmachado | 217 | |
1626 | jmachado | 218 | |
1547 | jmachado | 219 | //TODO CRIANDO ENTIDADE OLAP TIPOLOGIA |
1549 | jmachado | 220 | int respostasCandidatasTipologia = tipologiaRequisitada.getAlunosRequisitados().size(); |
221 | int respostasObtidasTipologia = 0; |
||
222 | respostasCandidatasCurso += respostasCandidatasTipologia; |
||
223 | respostasCandidatasUnidade += respostasCandidatasTipologia; |
||
1547 | jmachado | 224 | OlapEntityQuestionarioTipologia olapQuestionarioTipologia = createOlapQuestionarioTipologia(q, tipologiaRequisitada); |
1545 | jmachado | 225 | |
1547 | jmachado | 226 | for(QuestionarioPedagogicoAlunoRequisitado alunoRequisitado: tipologiaRequisitada.getAlunosRequisitados()) |
227 | { |
||
228 | QuestionarioRespostaRequisitada respostaRequisitada = alunoRequisitado.getRespostaRequisitada(); |
||
1545 | jmachado | 229 | |
1547 | jmachado | 230 | //TODO CRIANDO NESTE QUESTIONARIO ENTIDADE PERFIL UTILIZADOR |
231 | OlapEntityQuestionarioUser olapQuestionarioUser = createOlapQuestionarioUser(q, alunoRequisitado); |
||
1545 | jmachado | 232 | |
233 | |||
1547 | jmachado | 234 | //TODO CRIANDO ENTIDADE FACTO RESPOSTA RESPONDIDA/NAO RESPONDIDA |
235 | createOlapStarFactQuestionario(q, olapQuestionario, olapHistoryDimension, olapQuestionarioCurso, olapQuestionarioUnidade, olapQuestionarioTipologia, respostaRequisitada, olapQuestionarioUser); |
||
236 | |||
237 | |||
238 | //TODO USAR ENTIDADES RESPOSTAPERGUNTA COM BASE NO QUESTIONARIO EM QUESTAO |
||
239 | if(respostaRequisitada.getResposta() != null) |
||
240 | { |
||
241 | QuestionarioResposta resposta = respostaRequisitada.getResposta(); |
||
1549 | jmachado | 242 | respostasObtidasCurso++; |
243 | respostasObtidasUnidade++; |
||
244 | respostasObtidasTipologia++; |
||
1547 | jmachado | 245 | //TODO CRIAR FACTOS RESPOSTA COM BASE NA RESPOSTA |
246 | |||
1572 | jmachado | 247 | |
248 | |||
249 | |||
1547 | jmachado | 250 | List<OlapStarFactQuestionarioAnswer> factRespostas = new ArrayList<OlapStarFactQuestionarioAnswer>(); |
251 | for(1.5.0/docs/api/java/util/Map.html">Map.Entry<Integer,Long> entryPergunta : mapaIdsPerguntasPersistentes.entrySet()) |
||
252 | { |
||
253 | int numeroPergunta = entryPergunta.getKey(); |
||
254 | 1.5.0/docs/api/java/lang/Long.html">Long idPerguntaBd = entryPergunta.getValue(); |
||
255 | OlapEntityQuestionarioPergunta olapPergunta = DaoFactory.getOlapEntityQuestionarioPerguntaDaoImpl().load(idPerguntaBd); |
||
256 | |||
257 | |||
258 | |||
259 | 1.5.0/docs/api/java/lang/Long.html">Long timeTakenRN = (1.5.0/docs/api/java/lang/Long.html">Long) QuestionarioResposta.class.getMethod("getTimeTakenR" + numeroPergunta).invoke(resposta); |
||
260 | 1.5.0/docs/api/java/lang/Long.html">Long timeEventRN = (1.5.0/docs/api/java/lang/Long.html">Long) QuestionarioResposta.class.getMethod("getTimeEventR" + numeroPergunta).invoke(resposta); |
||
261 | 1.5.0/docs/api/java/lang/String.html">String respostaN = (1.5.0/docs/api/java/lang/String.html">String) QuestionarioResposta.class.getMethod("getR" + numeroPergunta).invoke(resposta); |
||
262 | |||
263 | |||
264 | if(respostaN != null) |
||
265 | { |
||
1549 | jmachado | 266 | createOlapQuestionarioAnswer(q, olapQuestionario, olapHistoryDimension, olapQuestionarioCurso, olapQuestionarioUnidade, olapQuestionarioTipologia, olapQuestionarioUser, factRespostas, olapPergunta, timeTakenRN, timeEventRN, respostaN); |
1547 | jmachado | 267 | } |
268 | } |
||
269 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(factRespostas,new Comparator<OlapStarFactQuestionarioAnswer>() { |
||
270 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
271 | public int compare(OlapStarFactQuestionarioAnswer o1, OlapStarFactQuestionarioAnswer o2) { |
||
272 | return (int) (o1.getDataEvento().getTime() - o2.getDataEvento().getTime()); |
||
273 | } |
||
274 | }); |
||
275 | int i = 1; |
||
276 | for(OlapStarFactQuestionarioAnswer fact: factRespostas) |
||
277 | { |
||
278 | fact.setOrdemResposta(i); |
||
279 | i++; |
||
280 | } |
||
281 | |||
282 | |||
1572 | jmachado | 283 | //PERGUNTAS DE ESFORCO Tudo Igual mas para Esforco------------------------------------------- |
284 | List<OlapStarFactQuestionarioAnswerEsforco> factRespostasEsforco = new ArrayList<OlapStarFactQuestionarioAnswerEsforco>(); |
||
285 | for(1.5.0/docs/api/java/util/Map.html">Map.Entry<Integer,Long> entryPerguntaEsforco : mapaIdsPerguntasEsforcoPersistentes.entrySet()) |
||
286 | { |
||
287 | int numeroPergunta = entryPerguntaEsforco.getKey(); |
||
288 | 1.5.0/docs/api/java/lang/Long.html">Long idPerguntaBd = entryPerguntaEsforco.getValue(); |
||
289 | OlapEntityQuestionarioPerguntaEsforco olapPerguntaEsforco = DaoFactory.getOlapEntityQuestionarioPerguntaEsforcoDaoImpl().load(idPerguntaBd); |
||
290 | |||
291 | |||
292 | |||
293 | 1.5.0/docs/api/java/lang/Long.html">Long timeTakenRN = (1.5.0/docs/api/java/lang/Long.html">Long) QuestionarioResposta.class.getMethod("getTimeTakenRe" + numeroPergunta).invoke(resposta); |
||
294 | 1.5.0/docs/api/java/lang/Long.html">Long timeEventRN = (1.5.0/docs/api/java/lang/Long.html">Long) QuestionarioResposta.class.getMethod("getTimeEventRe" + numeroPergunta).invoke(resposta); |
||
295 | 1.5.0/docs/api/java/lang/String.html">String respostaN = (1.5.0/docs/api/java/lang/String.html">String) QuestionarioResposta.class.getMethod("getRe" + numeroPergunta).invoke(resposta); |
||
296 | |||
297 | |||
298 | if(respostaN != null) |
||
299 | { |
||
300 | createOlapQuestionarioAnswerEsforco(q, olapQuestionario, olapHistoryDimension, olapQuestionarioCurso, olapQuestionarioUnidade, olapQuestionarioTipologia, olapQuestionarioUser, factRespostasEsforco, olapPerguntaEsforco, timeTakenRN, timeEventRN, respostaN); |
||
301 | } |
||
302 | } |
||
303 | 1.5.0/docs/api/java/util/Collections.html">Collections.sort(factRespostasEsforco,new Comparator<OlapStarFactQuestionarioAnswerEsforco>() { |
||
304 | @1.5.0/docs/api/java/lang/Override.html">Override |
||
305 | public int compare(OlapStarFactQuestionarioAnswerEsforco o1, OlapStarFactQuestionarioAnswerEsforco o2) { |
||
306 | return (int) (o1.getDataEvento().getTime() - o2.getDataEvento().getTime()); |
||
307 | } |
||
308 | }); |
||
309 | i = 1; |
||
310 | for(OlapStarFactQuestionarioAnswerEsforco fact: factRespostasEsforco) |
||
311 | { |
||
312 | fact.setOrdemResposta(i); |
||
313 | i++; |
||
314 | } |
||
315 | |||
1547 | jmachado | 316 | } |
1545 | jmachado | 317 | } |
318 | |||
1549 | jmachado | 319 | //TODO CRIANDO FACTO TIPOLOGIA |
320 | createOlapStarFactTipologia(q, olapQuestionario, olapHistoryDimension, olapQuestionarioCurso, olapQuestionarioUnidade, respostasCandidatasTipologia, respostasObtidasTipologia, olapQuestionarioTipologia); |
||
1545 | jmachado | 321 | |
1549 | jmachado | 322 | |
1547 | jmachado | 323 | } |
1549 | jmachado | 324 | |
325 | //TODO CRIANDO FACTO UNIDADE |
||
326 | createOlapStarFactUnidade(q, olapQuestionario, olapHistoryDimension, olapQuestionarioCurso, olapQuestionarioUnidade, tipologiasUnidade, respostasCandidatasUnidade, respostasObtidasUnidade); |
||
327 | |||
1545 | jmachado | 328 | } |
329 | } |
||
330 | } |
||
1549 | jmachado | 331 | //TODO CRIANDO FACTO CURSO |
332 | createOlapStarFactCurso(q, olapQuestionario, olapHistoryDimension, olapQuestionarioCurso, tipologiasCurso, unidadesCurso, respostasCandidatasCurso, respostasObtidasCurso); |
||
333 | |||
1545 | jmachado | 334 | } |
1544 | jmachado | 335 | |
1547 | jmachado | 336 | /** COMMIT OPERATION **/ |
337 | setProgress(100); |
||
338 | commitPartially(); |
||
339 | DaoFactory.getQuestionarioDaoImpl().update(q); |
||
340 | /** COMMIT OPERATION **/ |
||
1544 | jmachado | 341 | |
1547 | jmachado | 342 | msg = "Set courses state as " + QuestionarioImpl.1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.OLAP.name(); |
343 | serviceLogInfo(msg); |
||
344 | logger.info(msg); |
||
345 | q.setStateClass(QuestionarioImpl.1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.OLAP); |
||
346 | commitPartially(); |
||
1544 | jmachado | 347 | |
348 | |||
1547 | jmachado | 349 | serviceLogInfo("######################################"); |
350 | serviceLogInfo("######################################"); |
||
1626 | jmachado | 351 | serviceLogInfo("#unidadesNaoUtilizadas:" + unidadesNaoUtilizadas); |
352 | serviceLogInfo("#unidadesUtilizadas:" + unidadesUtilizadas); |
||
353 | serviceLogInfo("#tipologiasExcluidas:" + tipologiasExcluidas); |
||
354 | serviceLogInfo("#cursosSemDepartamento:" + cursosSemDepartamento); |
||
355 | serviceLogInfo("#unidadesSemPeriodoNoPlano:" + unidadesSemPeriodoNoPlano); |
||
356 | serviceLogInfo("#cursosUtilizados:" + cursosUtilizados); |
||
1544 | jmachado | 357 | |
1547 | jmachado | 358 | logger.info("######################################"); |
359 | logger.info("######################################"); |
||
1626 | jmachado | 360 | logger.info("#unidadesNaoUtilizadas:" + unidadesNaoUtilizadas); |
361 | logger.info("#unidadesUtilizadas:" + unidadesUtilizadas); |
||
362 | logger.info("#tipologiasExcluidas:" + tipologiasExcluidas); |
||
363 | logger.info("#cursosSemDepartamento:" + cursosSemDepartamento); |
||
364 | logger.info("#unidadesSemPeriodoNoPlano:" + unidadesSemPeriodoNoPlano); |
||
365 | logger.info("#cursosUtilizados:" + cursosUtilizados); |
||
1545 | jmachado | 366 | } |
367 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
368 | { |
||
369 | logger.error(e,e); |
||
370 | q.setStateClass(QuestionarioImpl.1.5.0/docs/api/org/omg/PortableServer/POAManagerPackage/State.html">State.CLOSED); |
||
371 | throw e; |
||
372 | } |
||
1544 | jmachado | 373 | return logMessages; |
374 | } |
||
375 | |||
1549 | jmachado | 376 | private void createOlapStarFactCurso(QuestionarioImpl q, OlapEntityQuestionario olapQuestionario, OlapHistoryDimension olapHistoryDimension, OlapEntityQuestionarioCurso olapQuestionarioCurso,int unidadesCurso, int tipologiasCurso, int respostasCandidatasCurso, int respostasObtidasCurso) |
377 | { |
||
1586 | jmachado | 378 | OlapStarFactQuestionarioCurso factQuestionarioCurso = new OlapStarFactQuestionarioCursoImpl(); |
1549 | jmachado | 379 | factQuestionarioCurso.setUnidades(unidadesCurso); |
380 | factQuestionarioCurso.setTipologias(tipologiasCurso); |
||
381 | factQuestionarioCurso.setRespostasCandidatas(respostasCandidatasCurso); |
||
382 | factQuestionarioCurso.setRespostasObtidas(respostasObtidasCurso); |
||
383 | factQuestionarioCurso.setQuestionario(q); |
||
384 | factQuestionarioCurso.setOlapTimeLine(olapHistoryDimension); |
||
385 | factQuestionarioCurso.setOlapQuestionario(olapQuestionario); |
||
386 | factQuestionarioCurso.setOlapCurso(olapQuestionarioCurso); |
||
387 | DaoFactory.getOlapStarFactQuestionarioCursoDaoImpl().save(factQuestionarioCurso); |
||
388 | } |
||
389 | |||
390 | private void createOlapStarFactUnidade(QuestionarioImpl q, OlapEntityQuestionario olapQuestionario, OlapHistoryDimension olapHistoryDimension, OlapEntityQuestionarioCurso olapQuestionarioCurso, OlapEntityQuestionarioUnidade olapQuestionarioUnidade,int tipologiasUnidade, int respostasCandidatasUnidade, int respostasObtidasUnidade) |
||
391 | { |
||
1586 | jmachado | 392 | OlapStarFactQuestionarioUnidade factQuestionarioUnidade = new OlapStarFactQuestionarioUnidadeImpl(); |
1549 | jmachado | 393 | factQuestionarioUnidade.setTipologias(tipologiasUnidade); |
394 | factQuestionarioUnidade.setRespostasCandidatas(respostasCandidatasUnidade); |
||
395 | factQuestionarioUnidade.setRespostasObtidas(respostasObtidasUnidade); |
||
396 | factQuestionarioUnidade.setQuestionario(q); |
||
397 | factQuestionarioUnidade.setOlapTimeLine(olapHistoryDimension); |
||
398 | factQuestionarioUnidade.setOlapQuestionario(olapQuestionario); |
||
399 | factQuestionarioUnidade.setOlapCurso(olapQuestionarioCurso); |
||
400 | factQuestionarioUnidade.setOlapUnidade(olapQuestionarioUnidade); |
||
401 | DaoFactory.getOlapStarFactQuestionarioUnidadeDaoImpl().save(factQuestionarioUnidade); |
||
402 | } |
||
403 | |||
404 | private void createOlapStarFactTipologia(QuestionarioImpl q, OlapEntityQuestionario olapQuestionario, OlapHistoryDimension olapHistoryDimension, OlapEntityQuestionarioCurso olapQuestionarioCurso, OlapEntityQuestionarioUnidade olapQuestionarioUnidade, int respostasCandidatasTipologia, int respostasObtidasTipologia, OlapEntityQuestionarioTipologia olapQuestionarioTipologia) { |
||
1586 | jmachado | 405 | OlapStarFactQuestionarioTipologia factQuestionarioTipologia = new OlapStarFactQuestionarioTipologiaImpl(); |
1549 | jmachado | 406 | factQuestionarioTipologia.setRespostasCandidatas(respostasCandidatasTipologia); |
407 | factQuestionarioTipologia.setRespostasObtidas(respostasObtidasTipologia); |
||
408 | factQuestionarioTipologia.setQuestionario(q); |
||
409 | factQuestionarioTipologia.setOlapTimeLine(olapHistoryDimension); |
||
410 | factQuestionarioTipologia.setOlapQuestionario(olapQuestionario); |
||
411 | factQuestionarioTipologia.setOlapCurso(olapQuestionarioCurso); |
||
412 | factQuestionarioTipologia.setOlapUnidade(olapQuestionarioUnidade); |
||
413 | factQuestionarioTipologia.setOlapTipologia(olapQuestionarioTipologia); |
||
414 | DaoFactory.getOlapStarFactQuestionarioTipologiaDaoImpl().save(factQuestionarioTipologia); |
||
415 | } |
||
416 | |||
417 | private void createOlapQuestionarioAnswer(QuestionarioImpl q, OlapEntityQuestionario olapQuestionario, OlapHistoryDimension olapHistoryDimension, OlapEntityQuestionarioCurso olapQuestionarioCurso, OlapEntityQuestionarioUnidade olapQuestionarioUnidade, OlapEntityQuestionarioTipologia olapQuestionarioTipologia, OlapEntityQuestionarioUser olapQuestionarioUser, List<OlapStarFactQuestionarioAnswer> factRespostas, OlapEntityQuestionarioPergunta olapPergunta, 1.5.0/docs/api/java/lang/Long.html">Long timeTakenRN, 1.5.0/docs/api/java/lang/Long.html">Long timeEventRN, 1.5.0/docs/api/java/lang/String.html">String respostaN) { |
||
1586 | jmachado | 418 | OlapStarFactQuestionarioAnswer factQuestionarioAnswer = new OlapStarFactQuestionarioAnswerImpl(); |
1549 | jmachado | 419 | factQuestionarioAnswer.setQuestionario(q); |
420 | factQuestionarioAnswer.setOlapTimeLine(olapHistoryDimension); |
||
421 | factQuestionarioAnswer.setOlapQuestionario(olapQuestionario); |
||
422 | factQuestionarioAnswer.setOlapUnidade(olapQuestionarioUnidade); |
||
423 | factQuestionarioAnswer.setOlapPerfilUser(olapQuestionarioUser); |
||
424 | factQuestionarioAnswer.setOlapTipologia(olapQuestionarioTipologia); |
||
425 | factQuestionarioAnswer.setOlapCurso(olapQuestionarioCurso); |
||
426 | |||
427 | factQuestionarioAnswer.setOlapPergunta(olapPergunta); |
||
428 | factQuestionarioAnswer.setDataEvento(new 5+0%2Fdocs%2Fapi+Date">Date(timeEventRN)); |
||
429 | factQuestionarioAnswer.setTempoLevado(timeTakenRN); |
||
430 | factQuestionarioAnswer.setIntResposta(1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(respostaN)); |
||
431 | factRespostas.add(factQuestionarioAnswer); |
||
432 | DaoFactory.getOlapStarFactQuestionarioAnswerDaoImpl().save(factQuestionarioAnswer); |
||
433 | } |
||
434 | |||
1572 | jmachado | 435 | private void createOlapQuestionarioAnswerEsforco(QuestionarioImpl q, OlapEntityQuestionario olapQuestionario, OlapHistoryDimension olapHistoryDimension, OlapEntityQuestionarioCurso olapQuestionarioCurso, OlapEntityQuestionarioUnidade olapQuestionarioUnidade, OlapEntityQuestionarioTipologia olapQuestionarioTipologia, OlapEntityQuestionarioUser olapQuestionarioUser, List<OlapStarFactQuestionarioAnswerEsforco> factRespostasEsforco, OlapEntityQuestionarioPerguntaEsforco olapPergunta, 1.5.0/docs/api/java/lang/Long.html">Long timeTakenRN, 1.5.0/docs/api/java/lang/Long.html">Long timeEventRN, 1.5.0/docs/api/java/lang/String.html">String respostaN) { |
1586 | jmachado | 436 | OlapStarFactQuestionarioAnswerEsforco factQuestionarioAnswerEsforco = new OlapStarFactQuestionarioAnswerEsforcoImpl(); |
1572 | jmachado | 437 | factQuestionarioAnswerEsforco.setQuestionario(q); |
438 | factQuestionarioAnswerEsforco.setOlapTimeLine(olapHistoryDimension); |
||
439 | factQuestionarioAnswerEsforco.setOlapQuestionario(olapQuestionario); |
||
440 | factQuestionarioAnswerEsforco.setOlapUnidade(olapQuestionarioUnidade); |
||
441 | factQuestionarioAnswerEsforco.setOlapPerfilUser(olapQuestionarioUser); |
||
442 | factQuestionarioAnswerEsforco.setOlapTipologia(olapQuestionarioTipologia); |
||
443 | factQuestionarioAnswerEsforco.setOlapCurso(olapQuestionarioCurso); |
||
444 | |||
445 | factQuestionarioAnswerEsforco.setOlapPerguntaEsforco(olapPergunta); |
||
446 | factQuestionarioAnswerEsforco.setDataEvento(new 5+0%2Fdocs%2Fapi+Date">Date(timeEventRN)); |
||
447 | factQuestionarioAnswerEsforco.setTempoLevado(timeTakenRN); |
||
448 | factQuestionarioAnswerEsforco.setIntResposta(1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(respostaN)); |
||
449 | factRespostasEsforco.add(factQuestionarioAnswerEsforco); |
||
450 | DaoFactory.getOlapStarFactQuestionarioAnswerEsforcoDaoImpl().save(factQuestionarioAnswerEsforco); |
||
451 | } |
||
452 | |||
1547 | jmachado | 453 | private OlapStarFactQuestionario createOlapStarFactQuestionario(QuestionarioImpl q, OlapEntityQuestionario olapQuestionario, OlapHistoryDimension olapHistoryDimension, OlapEntityQuestionarioCurso olapQuestionarioCurso, OlapEntityQuestionarioUnidade olapQuestionarioUnidade, OlapEntityQuestionarioTipologia olapQuestionarioTipologia, QuestionarioRespostaRequisitada respostaRequisitada, OlapEntityQuestionarioUser olapQuestionarioUser) { |
454 | QuestionarioResposta resposta = respostaRequisitada.getResposta(); |
||
1546 | jmachado | 455 | |
1586 | jmachado | 456 | OlapStarFactQuestionario factQuestionario = new OlapStarFactQuestionarioImpl(); |
1547 | jmachado | 457 | factQuestionario.setQuestionario(q); |
458 | factQuestionario.setOlapTimeLine(olapHistoryDimension); |
||
459 | factQuestionario.setOlapQuestionario(olapQuestionario); |
||
460 | factQuestionario.setOlapUnidade(olapQuestionarioUnidade); |
||
461 | factQuestionario.setOlapPerfilUser(olapQuestionarioUser); |
||
462 | factQuestionario.setOlapTipologia(olapQuestionarioTipologia); |
||
463 | factQuestionario.setOlapCurso(olapQuestionarioCurso); |
||
464 | factQuestionario.setRespondido(resposta != null); |
||
465 | if(resposta != null) |
||
466 | { |
||
467 | factQuestionario.setDataInicio(new 5+0%2Fdocs%2Fapi+Date">Date(resposta.getTimeStart())); |
||
468 | factQuestionario.setDataFim(new 5+0%2Fdocs%2Fapi+Date">Date(resposta.getTimeEnd())); |
||
469 | factQuestionario.setTempoTotal(resposta.getTotalTime()); |
||
470 | } |
||
471 | DaoFactory.getOlapStarFactQuestionarioDaoImpl().save(factQuestionario); |
||
472 | return factQuestionario; |
||
473 | } |
||
1546 | jmachado | 474 | |
1547 | jmachado | 475 | private OlapEntityQuestionarioUser createOlapQuestionarioUser(QuestionarioImpl q, QuestionarioPedagogicoAlunoRequisitado alunoRequisitado) { |
1586 | jmachado | 476 | OlapEntityQuestionarioUser questionarioUser = new OlapEntityQuestionarioUserImpl(); |
1547 | jmachado | 477 | questionarioUser.setQuestionario(q); |
1553 | jmachado | 478 | questionarioUser.setSigesCode("" + alunoRequisitado.getAluno().getSigesCode()); |
1547 | jmachado | 479 | questionarioUser.setBirthDate(alunoRequisitado.getAluno().getBirthDate()); |
480 | questionarioUser.setCountry(alunoRequisitado.getAluno().getCountry()); |
||
1553 | jmachado | 481 | questionarioUser.setNacionalidade(alunoRequisitado.getAluno().getNacionalidade()); |
482 | |||
1547 | jmachado | 483 | questionarioUser.setScholarDegree(alunoRequisitado.getAluno().getScholarDegree()); |
484 | questionarioUser.setSex(alunoRequisitado.getAluno().getSex()); |
||
1553 | jmachado | 485 | |
486 | if(!alunoRequisitado.isTipoAlunoFoiExtraido()) |
||
487 | { |
||
488 | //este procedimento aplica-se a casos de importacao anteriores a criacao |
||
489 | //dos campos tipo de aluno no aluno requisitado |
||
490 | alunoRequisitado.setPropinasEmDia(alunoRequisitado.getAluno().isPropinasEmDia()); |
||
491 | alunoRequisitado.setTipoAlunoBolseiro(alunoRequisitado.getAluno().isTipoAlunoBolseiro()); |
||
492 | alunoRequisitado.setTipoAlunoNormal(alunoRequisitado.getAluno().isTipoAlunoNormal()); |
||
493 | alunoRequisitado.setTipoAlunoVascodagama(alunoRequisitado.getAluno().isTipoAlunoVascodagama()); |
||
494 | alunoRequisitado.setTipoAlunoMilitar(alunoRequisitado.getAluno().isTipoAlunoMilitar()); |
||
495 | alunoRequisitado.setTipoAlunoDirigenteAssociativo(alunoRequisitado.getAluno().isTipoAlunoDirigenteAssociativo()); |
||
496 | alunoRequisitado.setTipoAlunoBombeiro(alunoRequisitado.getAluno().isTipoAlunoBombeiro()); |
||
497 | alunoRequisitado.setTipoAlunoDeficiente(alunoRequisitado.getAluno().isTipoAlunoDeficiente()); |
||
498 | alunoRequisitado.setTipoAlunoErasmus(alunoRequisitado.getAluno().isTipoAlunoErasmus()); |
||
499 | alunoRequisitado.setTipoAlunoTrabalhadorEstudante(alunoRequisitado.getAluno().isTipoAlunoTrabalhadorEstudante()); |
||
500 | alunoRequisitado.setTipoAlunoFoiExtraido(true); |
||
501 | } |
||
502 | questionarioUser.setPropinasEmDia(alunoRequisitado.isPropinasEmDia()); |
||
503 | questionarioUser.setTipoAlunoBolseiro(alunoRequisitado.isTipoAlunoBolseiro()); |
||
504 | questionarioUser.setTipoAlunoNormal(alunoRequisitado.isTipoAlunoNormal()); |
||
505 | questionarioUser.setTipoAlunoVascodagama(alunoRequisitado.isTipoAlunoVascodagama()); |
||
506 | questionarioUser.setTipoAlunoMilitar(alunoRequisitado.isTipoAlunoMilitar()); |
||
507 | questionarioUser.setTipoAlunoDirigenteAssociativo(alunoRequisitado.isTipoAlunoDirigenteAssociativo()); |
||
508 | questionarioUser.setTipoAlunoBombeiro(alunoRequisitado.isTipoAlunoBombeiro()); |
||
509 | questionarioUser.setTipoAlunoDeficiente(alunoRequisitado.isTipoAlunoDeficiente()); |
||
510 | questionarioUser.setTipoAlunoErasmus(alunoRequisitado.isTipoAlunoErasmus()); |
||
511 | questionarioUser.setTipoAlunoTrabalhadorEstudante(alunoRequisitado.isTipoAlunoTrabalhadorEstudante()); |
||
512 | |||
513 | |||
1547 | jmachado | 514 | questionarioUser.setZip(alunoRequisitado.getAluno().getZip()); |
1553 | jmachado | 515 | 1.5.0/docs/api/java/lang/String.html">String zipCandidate = alunoRequisitado.getAluno().getZip(); |
516 | if(alunoRequisitado.getAluno().getZip()!= null && alunoRequisitado.getAluno().getZip().indexOf("-")>=0) |
||
517 | { |
||
518 | zipCandidate = alunoRequisitado.getAluno().getZip().substring(0, alunoRequisitado.getAluno().getZip().indexOf("-")); |
||
519 | } |
||
520 | if(zipCandidate!=null) |
||
521 | { |
||
522 | try |
||
523 | { |
||
524 | questionarioUser.setZipInt(1.5.0/docs/api/java/lang/Integer.html">Integer.parseInt(zipCandidate)); |
||
525 | questionarioUser.setDistrito(DistritosUtils.getDistrito(alunoRequisitado.getAluno().getZip())); |
||
526 | questionarioUser.setConcelho(DistritosUtils.getConselho(alunoRequisitado.getAluno().getZip())); |
||
527 | } |
||
528 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
||
529 | { |
||
530 | questionarioUser.setZipInt(0); |
||
531 | questionarioUser.setDistrito("DESCONHECIDO"); |
||
532 | questionarioUser.setConcelho("DESCONHECIDO"); |
||
533 | logger.info("Zip code error in student (siges code): " + alunoRequisitado.getAluno().getSigesCode()); |
||
534 | } |
||
535 | } |
||
1547 | jmachado | 536 | |
1553 | jmachado | 537 | |
538 | |||
1547 | jmachado | 539 | DaoFactory.getOlapEntityQuestionarioUserDaoImpl().save(questionarioUser); |
540 | return questionarioUser; |
||
541 | } |
||
542 | |||
543 | private OlapEntityQuestionarioTipologia createOlapQuestionarioTipologia(QuestionarioImpl q, QuestionarioPedagogicoTipologiaRequisitada tipologiaRequisitada) { |
||
1586 | jmachado | 544 | OlapEntityQuestionarioTipologia questionarioTipologia = new OlapEntityQuestionarioTipologiaImpl(); |
1547 | jmachado | 545 | questionarioTipologia.setQuestionario(q); |
546 | |||
547 | questionarioTipologia.setCodigoTipologia(tipologiaRequisitada.getCdTipologia()); |
||
548 | questionarioTipologia.setCodigoTurma(tipologiaRequisitada.getCdTurma()); |
||
549 | questionarioTipologia.setDescricao(tipologiaRequisitada.getDsTipologia()); |
||
550 | //DOCENTE |
||
551 | questionarioTipologia.setNome(tipologiaRequisitada.getNomeDocente()); |
||
552 | questionarioTipologia.setCodigoSiges(tipologiaRequisitada.getCdDocente()); |
||
553 | questionarioTipologia.setBi(tipologiaRequisitada.getDocenteAfeto().getBi()); |
||
554 | questionarioTipologia.setEmail(tipologiaRequisitada.getDocenteAfeto().getEmail()); |
||
555 | questionarioTipologia.setUsername(tipologiaRequisitada.getDocenteAfeto().getUsername()); |
||
556 | |||
557 | DaoFactory.getOlapEntityQuestionarioTipologiaDaoImpl().save(questionarioTipologia); |
||
558 | return questionarioTipologia; |
||
559 | } |
||
560 | |||
561 | private OlapEntityQuestionarioUnidade createOlapQuestionarioUnidade(DefaultLogMessages logMessages, QuestionarioImpl q, QuestionarioPedagogicoUnidadeCurricularAfeta unidadeCurricularAfeta, CourseUnitImpl cuImpl) { |
||
562 | 1.5.0/docs/api/java/lang/String.html">String msg; |
||
1586 | jmachado | 563 | OlapEntityQuestionarioUnidade olapEntityQuestionarioUnidade = new OlapEntityQuestionarioUnidadeImpl(); |
1547 | jmachado | 564 | |
565 | olapEntityQuestionarioUnidade.setQuestionario(q); |
||
566 | olapEntityQuestionarioUnidade.setNome(unidadeCurricularAfeta.getNome()); |
||
567 | olapEntityQuestionarioUnidade.setCodigo(unidadeCurricularAfeta.getCodigoUnidade()); |
||
568 | |||
569 | olapEntityQuestionarioUnidade.setPeriodoPlanoS1T8(cuImpl.getPeriodoPlanoFromStudiesPlan()); |
||
570 | olapEntityQuestionarioUnidade.setSemestrePlanoAbsoluto1ou2(cuImpl.getSemestrePlanoAbsoluto()); |
||
571 | olapEntityQuestionarioUnidade.setPeriodoSigesS1ouS2ouAouT1aT4(cuImpl.getSemestre()); |
||
1585 | jmachado | 572 | //Semestre S1 a T8 ainda nao sao usados em lado nenhum neste sistema, era pensado para se usar nas estatisticas |
573 | //de forma a juntar unidades nos mesmos semestres mas ainda nao esta em uso |
||
1547 | jmachado | 574 | if(olapEntityQuestionarioUnidade.getPeriodoPlanoS1T8() == null) |
575 | { |
||
576 | unidadesSemPeriodoNoPlano++; |
||
577 | msg = "!!! A unidade " + cuImpl.getCode() + " não tem periodo atribuido no Plano"; |
||
578 | serviceLogWarn(msg); |
||
579 | logger.warn(msg); |
||
580 | logMessages.addMessage(new DefaultLogMessage("questionario.olap", LogMessageTypeEnum.WARNING,msg)); |
||
581 | } |
||
582 | else |
||
583 | { |
||
584 | olapEntityQuestionarioUnidade.setAnoPlano1a4(cuImpl.getAnoPlanoFromStudiesPlan()); |
||
1585 | jmachado | 585 | if(olapEntityQuestionarioUnidade.getAnoPlano1a4() <= 0) |
586 | { |
||
587 | msg = "!!! A unidade " + cuImpl.getCode() + " tem periodo atribuido no Plano MAS O ANO ESTA MAL"; |
||
588 | serviceLogWarn(msg); |
||
589 | logger.warn(msg); |
||
590 | } |
||
591 | //tem de ser igual ao semestre.getId() rever situação com um if e warn se falhar |
||
1547 | jmachado | 592 | olapEntityQuestionarioUnidade.setSemestrePlanoConvertido1a6(cuImpl.getSemestrePlanoConvertido()); |
1585 | jmachado | 593 | if(olapEntityQuestionarioUnidade.getSemestrePlanoConvertido1a6() <= 0) |
594 | { |
||
595 | msg = "!!! A unidade " + cuImpl.getCode() + " tem getPeriodoPlanoS1T8 atribuido no Plano MAS ESTA MAL"; |
||
596 | serviceLogWarn(msg); |
||
597 | logger.warn(msg); |
||
598 | } |
||
1547 | jmachado | 599 | } |
600 | DaoFactory.getOlapEntityQuestionarioUnidadeDaoImpl().save(olapEntityQuestionarioUnidade); |
||
601 | return olapEntityQuestionarioUnidade; |
||
602 | } |
||
603 | |||
604 | |||
1546 | jmachado | 605 | private OlapEntityQuestionarioCurso createQuestionarioCursoOlap(DefaultLogMessages logMessages, QuestionarioImpl q, QuestionarioPedagogicoCursoAfeto cu) { |
606 | OlapEntityQuestionarioCurso questionarioCurso; |
||
607 | 1.5.0/docs/api/java/lang/String.html">String msg; |
||
1586 | jmachado | 608 | questionarioCurso = new OlapEntityQuestionarioCursoImpl(); |
1546 | jmachado | 609 | questionarioCurso.setQuestionario(q); |
610 | questionarioCurso.setCodigoCurso(cu.getCodigoCurso()); |
||
611 | questionarioCurso.setDegree(cu.getCourse().getDegree()); |
||
612 | if(cu.getCourse().getDepartment() == null) |
||
613 | { |
||
614 | msg = "Curso sem departamento corrigir situação: " + cu.getNome(); |
||
615 | logger.warn(msg); |
||
616 | serviceLogWarn(msg); |
||
617 | logMessages.addMessage(new DefaultLogMessage("questionario.olap", LogMessageTypeEnum.WARNING,msg)); |
||
618 | } |
||
619 | else |
||
620 | { |
||
621 | cursosSemDepartamento++; |
||
622 | questionarioCurso.setDepartament(cu.getCourse().getDepartment().getSigla()); |
||
623 | } |
||
624 | questionarioCurso.setNomeCurso(cu.getNome()); |
||
625 | questionarioCurso.setNomeInstituicao(cu.getNomeInstituicao()); |
||
626 | questionarioCurso.setCodigoInstituicao(cu.getCodigoInstituicao()); |
||
1565 | jmachado | 627 | questionarioCurso.setCodigoNacionalInstituicao(ConfigProperties.getProperty("institution.national.code."+cu.getCodigoInstituicao())); |
1546 | jmachado | 628 | DaoFactory.getOlapEntityQuestionarioCursoDaoImpl().save(questionarioCurso); |
629 | return questionarioCurso; |
||
630 | } |
||
631 | private OlapEntityQuestionario createQuestionarioUnidadeOlap(QuestionarioImpl q) |
||
1545 | jmachado | 632 | { |
1546 | jmachado | 633 | |
634 | return null; |
||
635 | } |
||
636 | private OlapEntityQuestionario createQuestionarioOlap(QuestionarioImpl q) |
||
637 | { |
||
1586 | jmachado | 638 | OlapEntityQuestionario olapEntityQuestionario = new OlapEntityQuestionarioImpl(); |
1545 | jmachado | 639 | DaoFactory.getOlapEntityQuestionarioDaoImpl().save(olapEntityQuestionario); |
1546 | jmachado | 640 | return updateOlapQuestionario(olapEntityQuestionario, q); |
1545 | jmachado | 641 | } |
1544 | jmachado | 642 | |
1546 | jmachado | 643 | private OlapEntityQuestionario updateOlapQuestionario(OlapEntityQuestionario olapEntityQuestionario, QuestionarioImpl q) |
1545 | jmachado | 644 | { |
645 | olapEntityQuestionario.setQuestionario(q); |
||
646 | olapEntityQuestionario.setAno(q.getYear()); |
||
647 | olapEntityQuestionario.setSemestre(q.getSemestre()); |
||
1566 | jmachado | 648 | int firstYear = DatesUtils.getFirstFromImportYear(q.getYear()); |
649 | int secondYear = DatesUtils.getSecondFromImportYear(q.getYear()); |
||
650 | |||
651 | if(q.getSemestre().equals("T1")) |
||
652 | { |
||
653 | olapEntityQuestionario.setGeneratedTime(new MyCalendar(firstYear,11,1).getTime()); |
||
654 | } |
||
655 | else if(q.getSemestre().equals("S1") || q.getSemestre().equals("T2")) |
||
656 | { |
||
657 | olapEntityQuestionario.setGeneratedTime(new MyCalendar(secondYear,2,1).getTime()); |
||
658 | } |
||
659 | else if(q.getSemestre().equals("T3")) |
||
660 | { |
||
661 | olapEntityQuestionario.setGeneratedTime(new MyCalendar(secondYear,5,1).getTime()); |
||
662 | } |
||
663 | else if(q.getSemestre().equals("S2") || q.getSemestre().equals("T4") || q.getSemestre().equals("A")) |
||
664 | { |
||
665 | olapEntityQuestionario.setGeneratedTime(new MyCalendar(secondYear,8,1).getTime()); |
||
666 | } |
||
667 | else |
||
668 | { |
||
669 | logger.error("AVISO, DATA Não tem semestre correcto"); |
||
670 | } |
||
1545 | jmachado | 671 | return olapEntityQuestionario; |
672 | } |
||
1544 | jmachado | 673 | |
1545 | jmachado | 674 | /** |
675 | * Return a map of ID's given the question number |
||
676 | * @param q |
||
677 | * @return |
||
678 | */ |
||
1547 | jmachado | 679 | private HashMap<Integer,Long> createOlapQuestionarioPergunta(QuestionarioImpl q) |
1545 | jmachado | 680 | { |
1544 | jmachado | 681 | |
1547 | jmachado | 682 | /** |
683 | * Numero da Pergunta VS Id na base de dados da dimensão |
||
684 | */ |
||
685 | HashMap<Integer,Long> mapaIdsPerguntasPersistentes = new HashMap<Integer, Long>(); |
||
1544 | jmachado | 686 | |
1572 | jmachado | 687 | for(int i = 1; i <= 40;i++) |
1545 | jmachado | 688 | { |
1586 | jmachado | 689 | OlapEntityQuestionarioPergunta pergunta = new OlapEntityQuestionarioPerguntaImpl(); |
1545 | jmachado | 690 | pergunta.setNumero("" + i); |
691 | pergunta.setPergunta(q.getPergunta("" + i)); |
||
692 | if(pergunta.getPergunta() == null || pergunta.getPergunta().trim().length() == 0) |
||
693 | continue; |
||
694 | pergunta.setGrupoCode(q.getGrupoCode("" + i)); |
||
695 | if(pergunta.getGrupoCode() == null || pergunta.getGrupoCode().trim().length() == 0) |
||
696 | continue; |
||
697 | pergunta.setGrupoTitle(q.getGrupoTitle("" + i)); |
||
1563 | jmachado | 698 | |
699 | 1.5.0/docs/api/java/lang/String.html">String subGroupCode = q.getSubGrupoCode("" + i); |
||
700 | if(subGroupCode != null) |
||
701 | { |
||
702 | pergunta.setSubGrupoCode(subGroupCode); |
||
703 | pergunta.setSubGrupoTitle(q.getSubGrupoTitle("" + i)); |
||
704 | } |
||
705 | |||
1545 | jmachado | 706 | pergunta.setQuestionario(q); |
1544 | jmachado | 707 | |
1545 | jmachado | 708 | DaoFactory.getOlapEntityQuestionarioPerguntaDaoImpl().save(pergunta); |
709 | |||
1547 | jmachado | 710 | mapaIdsPerguntasPersistentes.put(i,pergunta.getId()); |
1545 | jmachado | 711 | |
1553 | jmachado | 712 | 1.5.0/docs/api/java/lang/System.html">System.out.println("Pergunta OLAP Entity " + i + " ID: " + pergunta.getId()); |
1545 | jmachado | 713 | 1.5.0/docs/api/java/lang/System.html">System.out.println(pergunta.getNumero()); |
714 | 1.5.0/docs/api/java/lang/System.html">System.out.println(pergunta.getPergunta()); |
||
715 | 1.5.0/docs/api/java/lang/System.html">System.out.println(pergunta.getGrupoCode()); |
||
716 | 1.5.0/docs/api/java/lang/System.html">System.out.println(pergunta.getGrupoTitle()); |
||
717 | |||
718 | |||
719 | } |
||
720 | |||
721 | return mapaIdsPerguntasPersistentes; |
||
722 | |||
723 | |||
724 | } |
||
725 | |||
1572 | jmachado | 726 | private HashMap<Integer,Long> createOlapQuestionarioPerguntaEsforco(QuestionarioImpl q) |
727 | { |
||
1545 | jmachado | 728 | |
1572 | jmachado | 729 | /** |
730 | * Numero da Pergunta VS Id na base de dados da dimensão |
||
731 | */ |
||
732 | HashMap<Integer,Long> mapaIdsPerguntasEsforcoPersistentes = new HashMap<Integer, Long>(); |
||
733 | |||
734 | for(int i = 1; i <= 10;i++) |
||
735 | { |
||
1586 | jmachado | 736 | OlapEntityQuestionarioPerguntaEsforco perguntaEsforco = new OlapEntityQuestionarioPerguntaEsforcoImpl(); |
1572 | jmachado | 737 | perguntaEsforco.setNumero("" + i); |
738 | perguntaEsforco.setPergunta(q.getPerguntaE("" + i)); |
||
739 | if(perguntaEsforco.getPergunta() == null || perguntaEsforco.getPergunta().trim().length() == 0) |
||
740 | continue; |
||
741 | perguntaEsforco.setGrupoCode(q.getGrupoCodeE("" + i)); |
||
742 | if(perguntaEsforco.getGrupoCode() == null || perguntaEsforco.getGrupoCode().trim().length() == 0) |
||
743 | continue; |
||
744 | perguntaEsforco.setGrupoTitle(q.getGrupoTitleE("" + i)); |
||
745 | |||
746 | 1.5.0/docs/api/java/lang/String.html">String subGroupCode = q.getSubGrupoCodeE("" + i); |
||
747 | if(subGroupCode != null) |
||
748 | { |
||
749 | perguntaEsforco.setSubGrupoCode(subGroupCode); |
||
750 | perguntaEsforco.setSubGrupoTitle(q.getSubGrupoTitleE("" + i)); |
||
751 | } |
||
752 | |||
753 | perguntaEsforco.setQuestionario(q); |
||
754 | |||
755 | DaoFactory.getOlapEntityQuestionarioPerguntaEsforcoDaoImpl().save(perguntaEsforco); |
||
756 | |||
757 | mapaIdsPerguntasEsforcoPersistentes.put(i,perguntaEsforco.getId()); |
||
758 | |||
759 | 1.5.0/docs/api/java/lang/System.html">System.out.println("Pergunta Esforco OLAP Entity " + i + " ID: " + perguntaEsforco.getId()); |
||
760 | 1.5.0/docs/api/java/lang/System.html">System.out.println(perguntaEsforco.getNumero()); |
||
761 | 1.5.0/docs/api/java/lang/System.html">System.out.println(perguntaEsforco.getPergunta()); |
||
762 | 1.5.0/docs/api/java/lang/System.html">System.out.println(perguntaEsforco.getGrupoCode()); |
||
763 | 1.5.0/docs/api/java/lang/System.html">System.out.println(perguntaEsforco.getGrupoTitle()); |
||
764 | |||
765 | |||
766 | } |
||
767 | |||
768 | return mapaIdsPerguntasEsforcoPersistentes; |
||
769 | |||
770 | |||
771 | } |
||
772 | |||
773 | |||
1544 | jmachado | 774 | } |