/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/xsd/UnidadeImpl.java |
---|
11,4 → 11,173 |
return horasContacto; |
} |
public static int getAnoFromPlano(String id) |
{ |
if(id.equals("S1")) |
return 1; |
else if(id.equals("S2")) |
return 1; |
else if(id.equals("S3")) |
return 2; |
else if(id.equals("S4")) |
return 2; |
else if(id.equals("S5")) |
return 3; |
else if(id.equals("S6")) |
return 3; |
else if(id.equals("A1")) |
return 1; |
else if(id.equals("A2")) |
return 2; |
else if(id.equals("A3")) |
return 3; |
else if(id.equals("A4")) |
return 4; |
else if(id.equals("T1")) |
return 1; |
else if(id.equals("T2")) |
return 1; |
else if(id.equals("T3")) |
return 1; |
else if(id.equals("T4")) |
return 1; |
else if(id.equals("T5")) |
return 2; |
else if(id.equals("T6")) |
return 2; |
else if(id.equals("T7")) |
return 2; |
else if(id.equals("T8")) |
return 2; |
return -1; |
} |
public static int getSemestreConvertido(String id) |
{ |
if(id.equals("S1")) |
return 1; |
else if(id.equals("S2")) |
return 2; |
else if(id.equals("S3")) |
return 3; |
else if(id.equals("S4")) |
return 4; |
else if(id.equals("S5")) |
return 5; |
else if(id.equals("S6")) |
return 6; |
else if(id.equals("A1")) |
return -1; |
else if(id.equals("A2")) |
return -1; |
else if(id.equals("A3")) |
return -1; |
else if(id.equals("A4")) |
return -1; |
else if(id.equals("T1")) |
return 1; |
else if(id.equals("T2")) |
return 1; |
else if(id.equals("T3")) |
return 2; |
else if(id.equals("T4")) |
return 2; |
else if(id.equals("T5")) |
return 3; |
else if(id.equals("T6")) |
return 3; |
else if(id.equals("T7")) |
return 4; |
else if(id.equals("T8")) |
return 4; |
return -1; |
} |
public static int getSemestreAbsoluto(String id) |
{ |
if(id.equals("S1")) |
return 1; |
else if(id.equals("S2")) |
return 2; |
else if(id.equals("S3")) |
return 1; |
else if(id.equals("S4")) |
return 2; |
else if(id.equals("S5")) |
return 1; |
else if(id.equals("S6")) |
return 2; |
else if(id.equals("A1")) |
return -1; |
else if(id.equals("A2")) |
return -1; |
else if(id.equals("A3")) |
return -1; |
else if(id.equals("A4")) |
return -1; |
else if(id.equals("T1")) |
return 1; |
else if(id.equals("T2")) |
return 1; |
else if(id.equals("T3")) |
return 2; |
else if(id.equals("T4")) |
return 2; |
else if(id.equals("T5")) |
return 1; |
else if(id.equals("T6")) |
return 1; |
else if(id.equals("T7")) |
return 2; |
else if(id.equals("T8")) |
return 2; |
return -1; |
} |
public static String getPeriodoSiges(String id) |
{ |
if(id.equals("S1")) |
return "S1"; |
else if(id.equals("S2")) |
return "S2"; |
else if(id.equals("S3")) |
return "S1"; |
else if(id.equals("S4")) |
return "S2"; |
else if(id.equals("S5")) |
return "S1"; |
else if(id.equals("S6")) |
return "S2"; |
else if(id.equals("A1")) |
return "A"; |
else if(id.equals("A2")) |
return "A"; |
else if(id.equals("A3")) |
return "A"; |
else if(id.equals("A4")) |
return "A"; |
else if(id.equals("T1")) |
return "T1"; |
else if(id.equals("T2")) |
return "T2"; |
else if(id.equals("T3")) |
return "T3"; |
else if(id.equals("T4")) |
return "T4"; |
else if(id.equals("T5")) |
return "T1"; |
else if(id.equals("T6")) |
return "T2"; |
else if(id.equals("T7")) |
return "T3"; |
else if(id.equals("T8")) |
return "T4"; |
return null; |
} |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/services/questionarios/pedagogico/OlapGenerationProcessor.java |
---|
32,6 → 32,7 |
//int unidadesNaoVistasAlunos = 0; |
int cursosUtilizados = 0; |
//int respostasRequisitadas = 0; |
int cursosSemDepartamento = 0; |
/** |
58,8 → 59,10 |
cursosUtilizados = 0; |
//respostasRequisitadas = 0; |
cursosSemDepartamento = 0; |
QuestionarioImpl q = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().load(questionarioId); |
try{ |
81,15 → 84,17 |
if(questionarios.size() > 0) |
{ |
olapEntityQuestionario = questionarios.get(0); |
preencheQuestionarioOlap(olapEntityQuestionario,q); |
updateOlapQuestionario(olapEntityQuestionario, q); |
List<OlapHistoryDimension> histories = AbstractDao.getCurrentSession().createQuery("select x from x in class " + OlapHistoryDimension.class.getName() + " where x.questionario.id = " + questionarioId).list(); |
olapHistoryDimension = histories.get(0); |
} |
else |
{ |
olapEntityQuestionario = criaQuestionarioOlap(q); |
//+++++++ todo CRIANDO OLAP Questionario |
olapEntityQuestionario = createQuestionarioOlap(q); |
olapHistoryDimension = new OlapHistoryDimension(); |
olapHistoryDimension.setQuestionario(q); |
//+++++++ todo CRIANDO OLAP History |
DaoFactory.getOlapHistoryDimensionDaoImpl().save(olapHistoryDimension); |
} |
olapHistoryDimension.setNome(q.getQuestionarioHistoryDrive().getCodeName()); |
108,10 → 113,10 |
int size=cursosAfetosIds.size(); |
//+++++++ todo CRIANDO OLAP Perguntas |
HashMap<String,Long> mapaIdsPerguntasPersistentes = createOlapQuestionarioPergunta(q); |
HashMap<String,Long> mapaIdsPerguntasPersistentes = generateEntidadesPerguntaResposta(q); |
for(Long cursoAfetoId : cursosAfetosIds) |
{ |
count++; |
129,7 → 134,8 |
logger.info(msg); |
serviceLogInfo(msg); |
//TODO CRIAR ENTIDADE OLAP CURSO |
//+++++++ todo CRIANDO OLAP Curso |
OlapEntityQuestionarioCurso questionarioCurso = createQuestionarioCursoOlap(logMessages, q, cu); |
int unidades; |
if(cu.getUnidadesAfetas() != null) |
151,7 → 157,7 |
msg = "!!! A unidade está marcada para NÃO SER UTILIZADA, passando à próxima"; |
serviceLogWarn(msg); |
logger.warn(msg); |
logMessages.addMessage(new DefaultLogMessage("questionario.answers.assigning", LogMessageTypeEnum.WARNING,msg)); |
logMessages.addMessage(new DefaultLogMessage("questionario.olap", LogMessageTypeEnum.WARNING,msg)); |
} |
else |
{ |
228,14 → 234,46 |
return logMessages; |
} |
private OlapEntityQuestionario criaQuestionarioOlap(QuestionarioImpl q) |
private OlapEntityQuestionarioCurso createQuestionarioCursoOlap(DefaultLogMessages logMessages, QuestionarioImpl q, QuestionarioPedagogicoCursoAfeto cu) { |
OlapEntityQuestionarioCurso questionarioCurso; |
String msg; |
questionarioCurso = new OlapEntityQuestionarioCurso(); |
questionarioCurso.setQuestionario(q); |
questionarioCurso.setCodigoCurso(cu.getCodigoCurso()); |
questionarioCurso.setDegree(cu.getCourse().getDegree()); |
if(cu.getCourse().getDepartment() == null) |
{ |
msg = "Curso sem departamento corrigir situação: " + cu.getNome(); |
logger.warn(msg); |
serviceLogWarn(msg); |
logMessages.addMessage(new DefaultLogMessage("questionario.olap", LogMessageTypeEnum.WARNING,msg)); |
} |
else |
{ |
cursosSemDepartamento++; |
questionarioCurso.setDepartament(cu.getCourse().getDepartment().getSigla()); |
} |
questionarioCurso.setNomeCurso(cu.getNome()); |
questionarioCurso.setNomeInstituicao(cu.getNomeInstituicao()); |
questionarioCurso.setCodigoInstituicao(cu.getCodigoInstituicao()); |
DaoFactory.getOlapEntityQuestionarioCursoDaoImpl().save(questionarioCurso); |
return questionarioCurso; |
} |
private OlapEntityQuestionario createQuestionarioUnidadeOlap(QuestionarioImpl q) |
{ |
return null; |
} |
private OlapEntityQuestionario createQuestionarioOlap(QuestionarioImpl q) |
{ |
OlapEntityQuestionario olapEntityQuestionario = new OlapEntityQuestionario(); |
DaoFactory.getOlapEntityQuestionarioDaoImpl().save(olapEntityQuestionario); |
return preencheQuestionarioOlap(olapEntityQuestionario,q); |
return updateOlapQuestionario(olapEntityQuestionario, q); |
} |
private OlapEntityQuestionario preencheQuestionarioOlap(OlapEntityQuestionario olapEntityQuestionario, QuestionarioImpl q) |
private OlapEntityQuestionario updateOlapQuestionario(OlapEntityQuestionario olapEntityQuestionario, QuestionarioImpl q) |
{ |
olapEntityQuestionario.setQuestionario(q); |
olapEntityQuestionario.setAno(q.getYear()); |
248,7 → 286,7 |
* @param q |
* @return |
*/ |
private HashMap<String,Long> generateEntidadesPerguntaResposta(QuestionarioImpl q) |
private HashMap<String,Long> createOlapQuestionarioPergunta(QuestionarioImpl q) |
{ |
HashMap<String,Long> mapaIdsPerguntasPersistentes = new HashMap<String, Long>(); |
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/CourseImpl.java |
---|
1,9 → 1,16 |
package pt.estgp.estgweb.domain; |
import org.apache.log4j.Logger; |
import pt.estgp.estgweb.services.courses.CoursesService; |
import pt.estgp.estgweb.services.courses.xsd.Curso; |
import pt.estgp.estgweb.services.courses.xsd.UnidadeImpl; |
import pt.estgp.estgweb.services.courses.xsd.UnidadeType; |
import pt.estgp.estgweb.utils.ConfigProperties; |
import java.io.Serializable; |
import java.util.HashMap; |
import java.util.List; |
import java.util.Map; |
/** |
* @author Jorge Machado |
14,6 → 21,8 |
public class CourseImpl extends Course |
{ |
private static final Logger logger = Logger.getLogger(CourseImpl.class); |
public Serializable getSerializable() |
{ |
return getId(); |
104,4 → 113,170 |
public List<Teacher> getCourseComission() { |
return courseComission; |
} |
/** |
* Services |
*/ |
/* |
Os identificadores sao formados por codigo-siges + $ + semestreId (S1,S2,A,T1,T2,T3,T4) |
Isto foi feito assim porque no caso de uma unidade existir nos dois semestres S1 e S2 |
nao existem duvidas da qual se trata |
Ou seja imagine-se um plano em que uma unidade 123 esta' em S2 (corresponde a S2 no siges ano 1) e |
tambem em S3 (corresponde a S1 no siges ano 2) |
No caso dos questionarios cada questionario esta associado ou a S1 ou S2 ou a A, no momento da invocacao |
deste servico, dependendo do semestre requisitado assim vai |
ser a unidade devolvida, ou seja se o invocador pedir 123 S1 o ano fornecido sera 2 caso seja 123 S2 o ano |
devolvido sera 1 |
*/ |
private Map<String,Integer> sigesAnoPlano = null; |
private Map<String,String> sigesPeriodoPlano = null; |
private Map<String,Integer> sigesSemestrePlanoConvertido = null; |
private Map<String,Integer> sigesSemestrePlanoAbsoluto = null; |
/** |
* Require Opened Transaction |
*/ |
public CourseStudiesPlan getStudiesPlanLastVersion() |
{ |
if(getStudiesPlans() != null && getStudiesPlans().size() > 0) |
{ |
return getStudiesPlans().iterator().next(); |
} |
return null; |
} |
/** |
* Este serviço inicializa mapas de correspondencia entre unidades dado o seu codigo siges |
* e o periodo siges onde estão inseridas e as suas posicoes no plano de estudo |
* |
* Exemplo dado 12344 e S1 |
* Podemos ter que a unidade está em periodo plano S3, anoPlano 2 semestre convertido 3 e semestre absoluto 1 |
* |
* Exemplo para 12345 e T7 |
* Podemos ter que a unidade está em periodo plano T7, anoPlano 2 semestre convertido 4 e semestre absoluto 2 |
*/ |
public void initUnitsAnosFromStudiesPlan() |
{ |
sigesAnoPlano = new HashMap<String, Integer>(); |
sigesPeriodoPlano = new HashMap<String, String>(); |
sigesSemestrePlanoConvertido = new HashMap<String, Integer>(); |
sigesSemestrePlanoAbsoluto = new HashMap<String, Integer>(); |
CoursesService coursesService = new CoursesService(); |
CourseStudiesPlanImpl lastVersion = (CourseStudiesPlanImpl) getStudiesPlanLastVersion(); |
if(lastVersion != null) |
{ |
Curso curso = coursesService.loadCursoPlanoFromXml(lastVersion.getXml()); |
if(curso == null) |
{ |
logger.error("Cant init course units anos from studies plan because JaxB parse from Xml return null (see more in CoursesService().loadCursoPlanoFromXml())"); |
return; |
} |
for(Curso.Semestre semestre: curso.getSemestre()) |
{ |
String periodoSiges = UnidadeImpl.getPeriodoSiges(semestre.getId()); |
if(periodoSiges == null) |
{ |
logger.info("Semestre provavelmente opcional ignorado " + semestre.getId()); |
} |
else |
{ |
Integer anoPlano = UnidadeImpl.getAnoFromPlano(semestre.getId()); |
Integer semestrePlanoConvertido = UnidadeImpl.getSemestreConvertido(semestre.getId()); |
Integer semestrePlanoAbsoluto = UnidadeImpl.getSemestreAbsoluto(semestre.getId()); |
for(Curso.Semestre.Perfil perfil: semestre.getPerfil()) |
{ |
for(UnidadeType unidade: perfil.getUnidade()) |
{ |
sigesAnoPlano.put(unidade.getSiges() + "$" + periodoSiges,anoPlano); |
sigesPeriodoPlano.put(unidade.getSiges() + "$" + periodoSiges,semestre.getId()); |
sigesSemestrePlanoConvertido.put(unidade.getSiges() + "$" + periodoSiges,semestrePlanoConvertido); |
sigesSemestrePlanoAbsoluto.put(unidade.getSiges() + "$" + periodoSiges,semestrePlanoAbsoluto); |
} |
} |
for(UnidadeType unidade: semestre.getUnidade()) |
{ |
sigesAnoPlano.put(unidade.getSiges() + "$" + periodoSiges,anoPlano); |
sigesPeriodoPlano.put(unidade.getSiges() + "$" + periodoSiges,semestre.getId()); |
sigesSemestrePlanoConvertido.put(unidade.getSiges() + "$" + periodoSiges,semestrePlanoConvertido); |
sigesSemestrePlanoAbsoluto.put(unidade.getSiges() + "$" + periodoSiges,semestrePlanoAbsoluto); |
} |
} |
} |
} |
} |
/** |
* require open transaction |
* @param periodoSiges |
* @param sigesCode |
* @return 1, 2, 3, 4 |
*/ |
public Integer getUnidadeAnoPlano(String periodoSiges,String sigesCode) |
{ |
if(sigesAnoPlano == null) |
initUnitsAnosFromStudiesPlan(); |
return sigesAnoPlano.get(sigesCode + "$" + periodoSiges); |
} |
/** |
* require open transaction |
* @param periodoSiges |
* @param sigesCode |
* @return S1, .., S8, T1 .. T8, A1 .. A4 |
*/ |
public String getUnidadePeriodoPlano(String periodoSiges,String sigesCode) |
{ |
if(sigesPeriodoPlano == null) |
initUnitsAnosFromStudiesPlan(); |
return sigesPeriodoPlano.get(sigesCode + "$" + periodoSiges); |
} |
/** |
* require open transaction |
* @param periodoSiges |
* @param sigesCode |
* @return S1 = 1, S2 = 2,S3 = 3,S4 = 4 ...T1 e T2 = 1, T2 e T3 = 2, T4 e T5 = 3 ... |
* |
*/ |
public Integer getUnidadeSemestrePlanoConvertido(String periodoSiges,String sigesCode) |
{ |
if(sigesSemestrePlanoConvertido == null) |
initUnitsAnosFromStudiesPlan(); |
return sigesSemestrePlanoConvertido.get(sigesCode + "$" + periodoSiges); |
} |
/** |
* require open transaction |
* @param periodoSiges |
* @param sigesCode |
* @return S1 = 1, S2 = 2, S3 = 1, S4 = 2 ... T1 e T2 = 1, T2 e T3 = 2, T4 e T5 = 1, T6 e T7 = 2 |
*/ |
public Integer getUnidadeSemestrePlanoAbsoluto(String periodoSiges,String sigesCode) |
{ |
if(sigesSemestrePlanoAbsoluto == null) |
initUnitsAnosFromStudiesPlan(); |
return sigesSemestrePlanoAbsoluto.get(sigesCode + "$" + periodoSiges); |
} |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/CourseUnitImpl.java |
---|
1148,7 → 1148,50 |
} |
/**Services**/ |
/** |
* Require Open Transaction |
* @return 1, 2, 3, 4 |
*/ |
public int getAnoPlanoFromStudiesPlan() |
{ |
CourseImpl courseImpl = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(getCourse()); |
return courseImpl.getUnidadeAnoPlano(getSemestre(),getCode()); |
} |
/** |
* Require Open Transaction |
* @return S1, .., S8, T1 .. T8, A1 .. A4 |
*/ |
public String getPeriodoPlanoFromStudiesPlan() |
{ |
CourseImpl courseImpl = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(getCourse()); |
return courseImpl.getUnidadePeriodoPlano(getSemestre(),getCode()); |
} |
/** |
* Require Open Transaction |
* @return S1 = 1, S2 = 2,S3 = 3,S4 = 4 ...T1 e T2 = 1, T2 e T3 = 2, T4 e T5 = 3 ... |
*/ |
public int getSemestrePlanoConvertido() |
{ |
CourseImpl courseImpl = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(getCourse()); |
return courseImpl.getUnidadeSemestrePlanoConvertido(getSemestre(),getCode()); |
} |
/** |
* Require Open Transaction |
* @return S1 = 1, S2 = 2, S3 = 1, S4 = 2 ... T1 e T2 = 1, T2 e T3 = 2, T4 e T5 = 1, T6 e T7 = 2 |
*/ |
public int getSemestrePlanoAbsoluto() |
{ |
CourseImpl courseImpl = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(getCourse()); |
return courseImpl.getUnidadeSemestrePlanoAbsoluto(getSemestre(),getCode()); |
} |
} |
/branches/v3/impl/src/hbm/pt/estgp/estgweb/domain/OlapQuestionarios.hbm.xml |
---|
36,13 → 36,16 |
<id name="id" type="long" unsaved-value="0"> |
<generator class="native"/> |
</id> |
<property name="codigoCurso" type="long" index="codigoCursoIndex"/> |
<property name="codigoCurso" type="string" index="codigoCursoIndex"/> |
<property name="nomeCurso" type="string" index="nomeCursoIndex"/> |
<property name="codigoInstituicao" type="long" index="codigoInstituicaoIndex"/> |
<property name="codigoInstituicao" type="string" index="codigoInstituicaoIndex"/> |
<property name="nomeInstituicao" type="string" index="nomeInstituicaoIndex"/> |
<property name="degree" type="string" index="degreeIndex"/> |
<property name="degree" type="string" index="degreeIndex"> |
<column name="degree" index="degreeIndex" /> |
</property> |
<property name="departament" type="string" index="departamentIndex"/> |
<many-to-one name="questionario" class="pt.estgp.estgweb.domain.Questionario" outer-join="false" lazy="proxy"/> |
</class> |
58,6 → 61,23 |
</id> |
<property name="codigo" type="long" index="codigoIndex"/> |
<property name="nome" type="string"/> |
<!-- S1 S2 A T1 T2 T3 T4 --> |
<property name="periodoSigesS1ouS2ouAouT1aT4" type="string" index="persigesIndex"/> |
<!-- S1, S2, S3 ..., T1, T2, T3 ... A1, A2--> |
<property name="periodoPlanoS1T8" type="string" index="perplanIndex"/> |
<!-- 1, 2, 3--> |
<property name="anoPlano1a4" type="string" index="anoplaIndex"/> |
<!-- S1 = 1, S2 = 2, S3 = 3, S4 = 4 ...T1 e T2 = 1, T2 e T3 = 2, T4 e T5 = 3 ... --> |
<property name="semestrePlanoConvertido1a4" type="string" index="semplaconvIndex"/> |
<!-- S1 = 1, S2 = 2, S3 = 1, S4 = 2 ... T1 e T2 = 1, T2 e T3 = 2, T4 e T5 = 1, T6 e T7 = 2--> |
<property name="semestrePlanoAbsoluto1ou2" type="string" index="semplaabsIndex"/> |
<many-to-one name="questionario" class="pt.estgp.estgweb.domain.Questionario" outer-join="false" lazy="proxy"/> |
</class> |