Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 863 → Rev 1052

/impl/importRoutines.xml
2,40 → 2,68
<project name="estgweb-import" basedir="." default="help">
 
 
 
<import file="build.xml"/>
 
 
<target name="courses">
<java classname="pt.estgp.estgweb.services.sigesimports.ImportCourseService" classpath="${build.dir.classes}" classpathref="pathToToolsLib">
<arg value="201314"/>
</java>
</target>
 
<!-- CLONE PROGRAMS -->
<target name="sincronizeunits">
<java classname="pt.estgp.estgweb.services.sigesimports.SincronizeLastYearCourseUnitProgramsService" classpath="${build.dir.classes}" classpathref="pathToToolsLib">
<arg value="201314"/>
<arg value="true"/>
<arg value="true"/>
<arg value="201516"/>
<arg value="true"/> <!-- Clone Only News -->
<arg value="false"/> <!-- Generate all pdfs -->
</java>
</target>
 
 
<!-- CORE PROCESSES -->
<target name="courses">
<java classname="pt.estgp.estgweb.services.sigesimports.ImportCourseService" classpath="${build.dir.classes}" classpathref="pathToToolsLib">
<!--<arg value="201314"/>-->
<!--<arg value="201415"/>-->
<arg value="201516"/>
</java>
</target>
<target name="teachers">
<java classname="pt.estgp.estgweb.services.sigesimports.ImportTeachersService" classpath="${build.dir.classes}" classpathref="pathToToolsLib">
<arg value="201314"/>
<!--<arg value="201314"/>-->
<!--<arg value="201415"/>-->
<arg value="201516"/>
</java>
</target>
<target name="students">
<java classname="pt.estgp.estgweb.services.sigesimports.ImportStudentsService" classpath="${build.dir.classes}" classpathref="pathToToolsLib">
<arg value="201314"/>
</java>
<!--<arg value="201314"/>-->
<!--<arg value="201415"/>-->
<arg value="201516"/>
</java>
</target>
<target name="grades">
<java classname="pt.estgp.estgweb.services.sigesimports.ImportGradesService" classpath="${build.dir.classes}" classpathref="pathToToolsLib"/>
<target name="summaries">
<java classname="pt.estgp.estgweb.services.sigesimports.ImportSumariesJson" classpath="${build.dir.classes}" classpathref="pathToToolsLib">
<arg value="201516"/>
<arg value="S1"/>
<arg value="true"/>
<arg value="false"/>
</java>
</target>
 
 
 
<!-- JOB RUNNER -->
<target name="jobs">
<java classname="pt.estgp.estgweb.services.jobs.JobDeamon" classpath="${build.dir.classes}" classpathref="pathToToolsLib"/>
</target>
<target name="summaries">
<java classname="pt.estgp.estgweb.services.sigesimports.ImportSumaries" classpath="${build.dir.classes}" classpathref="pathToToolsLib"/>
 
 
 
 
 
<!-- PONTUAIS -->
<target name="grades">
<java classname="pt.estgp.estgweb.services.sigesimports.ImportGradesService" classpath="${build.dir.classes}" classpathref="pathToToolsLib"/>
</target>
 
<target name="setAreas">
<java fork="true" classname="pt.estgp.estgweb.services.courses.SetUserArea" classpath="${build.dir.classes}" classpathref="pathToToolsLib"/>
</target>
51,4 → 79,15
<arg value="false"/>
</java>
</target>
 
<target name="storeAllProgramsFtp">
<java classname="pt.estgp.estgweb.services.courseunits.SaveCourseUnitProgram" classpath="${build.dir.classes}" classpathref="pathToToolsLib"/>
</target>
 
 
 
 
<target name="loadSummariesAtsi">
<java classname="pt.estgp.estgweb.services.sigesimports.LoadSumariesToPDF" classpath="${build.dir.classes}" classpathref="pathToToolsLib"/>
</target>
</project>
/impl/conf/language/MessageResourcesIntranet.properties
22,6 → 22,7
intranet.separator.utils=Utilitários
intranet.separator.utils.back=Voltar aos Utilitários
intranet.separator.contacts=Contactos
intranet.separator.courseunits=Perfil
 
intranet.contacts.lists=@Listas de Distribuição
intranet.contacts.labs=Laboratórios
/impl/conf/language/MessageResourcesCourse.properties
27,7 → 27,7
course.studies.plan.not.available=Não disponivel
course.courseunit.program.objectives.todo={0} Unidades em Falta (programa)
course.externalSite=Site Externo
course.studies.plan=Plano de Estudos
#course.studies.plan=Plano de Estudos
course.directed.coordinated.courses=Gestão de Unidades Curriculares
course.directed.coordinated.courses.updated.success={0} unidades curriculares actualizadas com sucesso
 
39,7 → 39,14
course.C=Acções de Formação de Curta Duração
course.A=Formações Avançadas
course.O=Outras Formações
course.T=TeSP
course.D=Diploma de Estudos Superiores Especializados
course.H=Doutoramento
course.Z=Desconhecido
 
 
 
 
course.Bs=Bacharelatos
course.Ls=Licenciaturas
course.Ms=Mestrados
53,6 → 60,7
course.valid.program=Programa Validado
course.directed.coordinated=Cursos que coordena e/ou dirige (Apenas os Presidentes dos Departamentos tem permissão para alterar o estado de um programa)
courseunit.programs=Programas Curriculares
courseunit.indexes=Índice de Unidades e Cursos (Gestão de Fichas)
course.directed.courses=Cursos que dirige
course.coordinated.courses=Cursos que coordena
course.unit.directed=Unidades Curriculares
60,15 → 68,15
course.program.courses=Programas Curriculares por Curso
course.program.coordinated.directed.courses=Programas Curriculares dos Cursos Coordenados e/ou dirigidos
course.program.courses.choose.year=Escolha o ano que deseja consultar
course.userGroupStudents=Grupo atribuido aos Alunos na Rede (Criação Pastas DTP)
 
#courseunit.programfile.valid=programa <u>Aprovado</u> pela Comissão de Curso
 
courseunit.programfile.valid=programa <u>Aprovado</u> pela Comissão de Curso
 
 
 
 
 
 
courses.all=Todos os Cursos
 
course.validation.role=Comissão de Curso para validação de Programas
90,3 → 98,5
course.menu.publicacoes=Publicações
 
status=Curso Activo
 
courses.fill.course=Por favor escolha pelo menos um curso nos filtros.
/impl/conf/language/MessageResourcesImportSiges.properties
6,12 → 6,25
import.semestre.separated=Importando as disciplinas por Semestre
import.semestre.repeated.S1=Unidade Repetida no 1º semestre
import.semestre.repeated.S2=Unidade Repetida no 2º Semestre
import.semestre.repeated.T1=Unidade Repetida no 1º Trimestre
import.semestre.repeated.T2=Unidade Repetida no 2º Trimestre
import.semestre.repeated.T3=Unidade Repetida no 3º Trimestre
import.semestre.repeated.T4=Unidade Repetida no 4º Trimestre
import.semestre.repeated.A=Unidade Repetida Anual
 
import.semestre.course.units.T1=Importando Unidades Curriculares do 1º Trimestre
import.semestre.course.units.T2=Importando Unidades Curriculares do 2º Trimestre
import.semestre.course.units.T3=Importando Unidades Curriculares do 3º Trimestre
import.semestre.course.units.T4=Importando Unidades Curriculares do 4º Trimestre
import.semestre.course.units.S1=Importando Unidades Curriculares do 1º Semestre
import.semestre.course.units.S2=Importando Unidades Curriculares do 2º Semestre
import.semestre.course.units.A=Importando Unidades Curriculares Anuais
import.semestre.updating.course.units.S1=Actualizando Unidades Curriculares do 1º Semestre
import.semestre.updating.course.units.S2=Actualizando Unidades Curriculares do 2º Semestre
import.semestre.updating.course.units.T1=Actualizando Unidades Curriculares do 1º Trimestre
import.semestre.updating.course.units.T2=Actualizando Unidades Curriculares do 2º Trimestre
import.semestre.updating.course.units.T3=Actualizando Unidades Curriculares do 3º Trimestre
import.semestre.updating.course.units.T4=Actualizando Unidades Curriculares do 4º Trimestre
import.semestre.updating.course.units.A=Actualizando Unidades Curriculares Anuais
import.semestre.updating.courses=Actualizando os Cursos
import.error=Erro na importação
/impl/conf/language/MessageResources.properties
158,6 → 158,7
fail.owner=Lamentamos o incómodo, mas não tem permissões sobre o objecto ao qual tentou aceder.
fail.timer=Lamentamos o incomodo, mas a acção que tentou efectuar não pode ser executada nesta data.
fail.authenticate=O nome de utilizador ou a palavra passe estão errados. Por favor tente de novo.
dontexist.authenticate=O utilizador já existe na rede interna mas ainda não está disponivel no sistema BACO, por favor dirija-se ao Centro Informático.
 
#palavras comuns
courseunit=Unidade Curricular
360,6 → 361,8
edit=Editar
delete=Apagar
confirm=Confirmar
save=Salvar
deliverEvaluation=Entregar Avaliação
add=Adicionar
put=Colocar
remove=Remover
445,7 → 448,7
 
 
 
 
user.role.courseValidateProgramGPME=Comissão de Curso de Gestão de PME
user.role.courseValidateProgramCET_TD=Comissão de Curso de CETS de TD
user.role.courseValidateProgramEI=Comissão de Curso de EI
user.role.courseValidateProgramEC=Comissão de Curso de EC
471,6 → 474,8
user.role.courseValidateProgramTGI=Comissão de Curso de TGI
user.role.courseValidateProgramRU=Comissão de Curso de RU
 
configuration.grades=Configuração Pautas
configuration=Configurações
 
 
 
505,4 → 510,3
 
 
 
 
/impl/conf/language/MessageResourcesCourseUnits.properties
45,6 → 45,8
courseunit.name=Nome
courseunit.code=C\u00f3digo
courseunit.semestre=Semestre
courseunit.trimestre=Trimestre
courseunit.anuais=Anuais
courseunit.importYear=Ano de Importa\u00e7\u00e3o
courseunit.course=Curso
 
61,7 → 63,12
courseunit.teacher.situation.all=Todos
courseunit.S1=1\u00ba Semestre
courseunit.S2=2\u00aa Semestre
courseunit.A=Anual
courseunit.ALL=Todos os Semestres
courseunit.T1=1\u00ba Trimestre
courseunit.T2=2\u00ba Trimestre
courseunit.T3=3\u00ba Trimestre
courseunit.T4=4\u00ba Trimestre
courseunit.assignement.delivered.date=Data de Entrega
courseunit.assignement.delivered.date.first.version=Data de Entrega da Primeira Vers\u00e3o
courseunit.assignement.delivered.versions=Total de Vers\u00f5es Entregues
101,6 → 108,7
courseunit.menu.presences=Assiduidade
courseunit.menu.contents=Conte\u00fados
courseunit.menu.grades=Avalia\u00e7\u00e3o
courseunit.menu.dtp=DTP
 
replace=Substituir
 
168,7 → 176,22
courseunit.program.cargaHorariaOT=OT
 
 
courseunit.evaluation=Ficha de Avalia\u00e7\u00e3o da Unidade Curricular
courseunit.evaluation.warning=Por favor v\u00e1 guardando a sua ficha no bot\u00e3o de Salvar para evitar que caso a sess\u00e3o expire perca o seu trabalho.
courseunit.evaluation.mapa1=Mapa 1
courseunit.evaluation.mapa1.desc=Dados relativos ao processo de avalia\u00e7\u00e3o
courseunit.menu.evaluation=Relat\u00f3rio de Avalia\u00e7\u00e3o
courseunit.evaluation.success=Ficha de Avalia\u00e7\u00e3o alterada com sucesso
 
 
 
 
 
 
 
 
courseunit.consultaroutros=Consultar outros programas
courseunit.confirmaclonagem=Tem a certeza que deseja clonar o programa do ano na caixa de selecção para este programa actualmente aberto para edição? Vai gerar uma nova versão de programa e a anterior será arquivada em PDF.
 
courseunit.dossier.tecnico.pedagogico=Dossier T\u00E9cnico Pedag\u00F3gico
 
/impl/conf/WEB-INF/struts/struts-courseunits.xml
9,6 → 9,7
<form-beans>
<form-bean type="pt.estgp.estgweb.web.form.courseunits.CourseUnitsForm" name="CourseUnitsForm"/>
<form-bean type="pt.estgp.estgweb.web.form.courseunits.CourseUnitProgramForm" name="CourseUnitProgramForm"/>
<form-bean type="pt.estgp.estgweb.web.form.courseunits.CourseUnitEvaluationForm" name="CourseUnitEvaluationForm"/>
</form-beans>
 
<global-exceptions>
31,6 → 32,10
<action path="/startLoadCourseUnit" forward="/courseUnitController.do?dispatch=load"/>
<action path="/startLoadTeacherCourseUnit" forward="/courseUnitController.do?dispatch=loadTeacher"/>
<action path="/startLoadStudentCourseUnit" forward="/courseUnitController.do?dispatch=loadStudent"/>
 
<action path="/startLoadCourseUnitSiges" forward="/courseUnitController.do?dispatch=loadCourseUnitWebSiteBySigesCodes"/>
<action path="/startLoadCourseUnitProgramSiges" forward="/courseUnitController.do?dispatch=loadCourseUnitProgramBySigesCodes"/>
 
<action path="/courseUnitController"
type="pt.estgp.estgweb.web.controllers.courseunits.CourseUnitsController"
name="CourseUnitsForm"
58,12 → 63,28
<forward name="edit.program" path="page.edit.courseunit.program"/>
</action>
 
 
<action path="/user/startLoadCourseUnitEvaluation" forward="/user/courseUnitEvaluationController.do?dispatch=editEvaluation"/>
 
 
<action path="/user/courseUnitEvaluationController"
type="pt.estgp.estgweb.web.controllers.courseunits.CourseUnitsEvaluationController"
name="CourseUnitEvaluationForm"
scope="request"
parameter="dispatch"
validate="false"
input="page.welcome">
<forward name="load" path="page.load.courseunit"/>
<forward name="edit.evaluation" path="page.edit.courseunit.evaluation"/>
</action>
 
<!--<action path="/user/startLoadCourseUnitFromHome" forward="page.load.courseunit.from.home"/>-->
 
<action path="/user/startLoadCourseUnitRootFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=loadRoot&amp;from=Home"/>
<action path="/user/startLoadCourseUnitContentsFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=loadContents&amp;from=Home"/>
<action path="/user/startLoadCourseUnitGradesFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=loadGrades&amp;from=Home"/>
<action path="/user/startLoadCourseUnitPresencesFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=loadPresences&amp;from=Home"/>
<action path="/user/startLoadCourseUnitDtpFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=loadDtp&amp;from=Home"/>
<action path="/user/startCourseUnitBlogFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=startBlog&amp;from=CourseUnit"/>
<action path="/user/startLoadCourseUnitAssignementFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=loadAssignement&amp;from=Home"/>
<action path="/user/startValidateInvalidateCourseUnitWorksFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=validateInvalidateAssignement&amp;from=Home"/>
74,6 → 95,12
<action path="/user/startLoadCourseUnitFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=load&amp;from=Home"/>
<action path="/user/startLoadTeacherCourseUnitFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=loadTeacher&amp;from=Home"/>
<action path="/user/startLoadStudentCourseUnitFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=loadStudent&amp;from=Home"/>
 
<action path="/user/startLoadCourseUnitDossierFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=loadDossier&amp;from=Home"/>
 
<action path="/user/startLoadCourseUnitSigesFromHome" forward="/user/courseUnitControllerFromHome.do?dispatch=loadCourseUnitWebSiteBySigesCodes&amp;from=Home"/>
 
 
<action path="/user/courseUnitControllerFromHome"
type="pt.estgp.estgweb.web.controllers.courseunits.CourseUnitsController"
name="CourseUnitsForm"
89,6 → 116,8
<forward name="submit" path="page.submit.courseunit.from.home"/>
<forward name="load.teacher" path="page.load.courseunit.teacher.from.home"/>
<forward name="load.student" path="page.load.courseunit.student.from.home"/>
<forward name="load.dossier" path="page.load.courseunit.dossier.tecnico.pedagogico"/>
 
</action>
 
 
/impl/conf/WEB-INF/struts/tiles-courseunits.xml
20,6 → 20,14
<put name="body" value="/user/courseunits/courseunitworks.jsp"/>
</definition>
 
 
<definition name="page.edit.courseunit.evaluation" extends="page.separators.home">
<put name="title" value="Ficha de Avaliação da Unidade Curricular"/>
<put name="topnav" value="/user/courseunits/topnavEvaluation.jsp"/>
<put name="navigation" value="/user/courseunits/menu.jsp"/>
<put name="body" value="/user/courseunits/courseunitEvaluation.jsp"/>
</definition>
 
<definition name="page.edit.courseunit.program" extends="base.layout1">
<put name="title" value="Ficha da Unidade Curricular"/>
<put name="topnav" value="/public/courseunits/topnavCourseUnitProgram.jsp"/>
107,6 → 115,9
<definition name="page.courseLayoutIOnlinePresences.proxy.ftp" extends="page.courseLayoutIOnline.proxy.ftp">
<put name="topnav" value="/user/home/topnavCourseUnitPresences.jsp"/>
</definition>
<definition name="page.courseLayoutIOnlineDtp.proxy.ftp" extends="page.courseLayoutIOnline.proxy.ftp">
<put name="topnav" value="/user/home/topnavCourseUnitDtp.jsp"/>
</definition>
 
 
 
157,7 → 168,16
 
 
 
<!-- Dossier Tecnico Pedagogico -->
 
 
<definition name="page.load.courseunit.dossier.tecnico.pedagogico" extends="page.separators.home">
<put name="title" value="Dossier Técnico Pedagógico"/>
<put name="topnav" value="/user/courseunits/topnavDossierTecnicoPedagogico.jsp"/>
<put name="left" value="/user/courseunits/menu.jsp"/>
<put name="body" value="/user/courseunits/dossierTecnicoPedagogico.jsp"/>
</definition>
 
 
 
</tiles-definitions>
/impl/conf/WEB-INF/struts/struts-configuration.xml
New file
0,0 → 1,39
<?xml version="1.0" encoding="UTF-8"?>
 
<!--<!DOCTYPE struts-config PUBLIC-->
<!--"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"-->
<!--"http://struts.apache.org/dtds/struts-config_1_3.dtd">-->
 
<struts-config>
<form-beans>
<form-bean type="pt.estgp.estgweb.web.form.configuration.ConfigurationGradesForm" name="ConfigurationGradesForm"/>
</form-beans>
 
<global-exceptions>
 
</global-exceptions>
 
<global-forwards>
 
</global-forwards>
<action-mappings>
 
 
 
<action path="/user/configurationGrades" forward="page.configuration.grades"/>
 
<action path="/user/grades"
type="pt.estgp.estgweb.web.controllers.configuration.GradesController"
name="ConfigurationGradesForm"
scope="request"
parameter="dispatch"
validate="false"
input="page.separators.serviceZone">
 
<forward name="save" path="page.separators.serviceZone"/>
<forward name="grades" path="page.configuration.grades"/>
</action>
 
 
</action-mappings>
</struts-config>
Property changes:
Added: svn:executable
+ *
/impl/conf/WEB-INF/struts/tiles-configuration.xml
New file
0,0 → 1,15
<?xml version="1.0" encoding="UTF-8" ?>
 
<!--<!DOCTYPE tiles-definitions PUBLIC-->
<!--"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"-->
<!--"http://struts.apache.org/dtds/tiles-config_1_1.dtd">-->
 
<tiles-definitions>
 
<definition name="page.configuration.grades" extends="page.separators.serviceZone">
<put name="title" value="Configuração Notas"/>
<put name="topnav" value="/user/serviceZone/topnavConfigurationGrades.jsp"/>
<put name="body" value="/admin/configuration/grades.jsp"/>
</definition>
</tiles-definitions>
Property changes:
Added: svn:executable
+ *
/impl/conf/WEB-INF/struts/struts-default.xml
20,10 → 20,12
 
<global-forwards>
<forward name="welcome" path="/Welcome.do"/>
<forward name="welcomeBootstrap" path="/WelcomeBootstrap.do"/>
<forward name="error503" path="/error503.do"/>
<forward name="error500" path="/error500.do"/>
<forward name="error404" path="/error404.do"/>
<forward name="error401" path="/error401.do"/>
<forward name="error408" path="/error408.do"/>
<forward name="errorNoCookies" path="page.no.cookies"/>
 
<!--Announcements-->
39,6 → 41,7
<!-- Start Pages -->
 
<action path="/Welcome" forward="page.welcome"/>
<action path="/WelcomeBootstrap" forward="page.welcome.bootstrap"/>
<action path="/StartAuthentication" forward="page.authentication"/>
<action path="/Logout" forward="/authenticate.do?dispatch=logout"/>
 
46,6 → 49,7
<action path="/errorNoCookies" forward="page.no.cookies"/>
<action path="/error401" forward="page.error.401"/>
<action path="/error404" forward="page.error.404"/>
<action path="/error408" forward="page.error.408"/>
<action path="/error500" forward="page.error.500"/>
<action path="/error503" forward="page.error.503"/>
 
142,6 → 146,7
<forward name="courseLayoutIOnlineContents.ftp" path="page.courseLayoutIOnlineContents.proxy.ftp"/>
<forward name="courseLayoutIOnlineGrades.ftp" path="page.courseLayoutIOnlineGrades.proxy.ftp"/>
<forward name="courseLayoutIOnlinePresences.ftp" path="page.courseLayoutIOnlinePresences.proxy.ftp"/>
<forward name="courseLayoutIOnlineDtp.ftp" path="page.courseLayoutIOnlineDtp.proxy.ftp"/>
 
<forward name="layoutIntranetUtils" path="page.layoutIntranetUtils.proxy"/>
<forward name="layoutIntranetContacts" path="page.layoutIntranetContacts.proxy"/>
205,7 → 210,8
/WEB-INF/struts/tiles-srusource.xml,
/WEB-INF/struts/tiles-survey.xml,
/WEB-INF/struts/tiles-processes.xml,
/WEB-INF/struts/tiles-comunicationfolder.xml"/> <!-- Duarte Santos -->
/WEB-INF/struts/tiles-comunicationfolder.xml,
/WEB-INF/struts/tiles-configuration.xml"/> <!-- Duarte Santos -->
</plug-in>
 
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
/impl/conf/WEB-INF/struts/tiles-default.xml
68,12 → 68,40
</definition>
 
 
 
<!-- Layout Old -->
<definition name="base.layoutWelcome" extends="base.definition" path="/layout/layoutWelcome.jsp">
<put name="navigationLeft" value="/layout/navigationLeft.jsp" />
<put name="navigationRight" value="/layout/navigationRight.jsp" />
</definition>
 
<!-- Testes com Layout Novo Bootstrap -->
<definition name="base.layoutWelcomeBootstrap" path="/layout/layoutWelcomeBootstrap.jsp">
<put name="title" value="x"/>
<put name="announcements" value="/layout/topnavempty.jsp"/>
<put name="header" value="/layout/header.jsp"/>
<put name="topnav" value="/layout/topnavempty.jsp" />
<put name="footer" value="/layout/footer.jsp" />
<put name="navigationTop" value="/layout/navigationTop.jsp"/>
<put name="navigationLeft" value="/layout/navigationLeft.jsp" />
<put name="navigationRight" value="/layout/navigationRight.jsp" />
</definition>
 
<!--Pagina inicial-->
<!-- welcome OLD -->
<definition name="page.welcome" extends="base.layoutWelcome">
<put name="title" value="ESTG" />
<put name="body" value="/public/index.jsp" />
</definition>
<!-- welcome NEW bootstrap -->
<definition name="page.welcome.bootstrap" extends="base.layoutWelcomeBootstrap">
<put name="title" value="ESTG" />
<put name="body" value="/public/indexBootstrap.jsp" />
</definition>
 
 
 
 
 
<definition name="base.layoutCourses" extends="base.definition" path="/layout/layout1.jsp">
<put name="topnav" value="/user/courses/topnavCourses.jsp"/>
<put name="navigation" value="/layout/navigationCourse.jsp" />
358,13 → 386,9
 
 
 
<!--Pagina inicial-->
<definition name="page.welcome" extends="base.layoutWelcome">
<put name="title" value="ESTG" />
<put name="body" value="/public/index.jsp" />
</definition>
 
 
 
<!-- Autenticacao -->
<definition name="page.authentication" extends="base.layout1">
<put name="title" value="Authentication" />
400,6 → 424,10
<put name="title" value="not found" />
<put name="body" value="/errors/404.jsp" />
</definition>
<definition name="page.error.408" extends="base.error.definition">
<put name="title" value="not found" />
<put name="body" value="/errors/408.jsp" />
</definition>
<definition name="page.no.cookies" extends="base.error.definition">
<put name="title" value="Turn on Cookies of your Browser" />
<put name="body" value="/errors/noCookies.jsp" />
/impl/conf/WEB-INF/tlds/baco.tld
252,4 → 252,28
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>object2Request</name>
<tagclass>pt.estgp.estgweb.web.tags.Object2RequestTag</tagclass>
<attribute>
<name>beanIdName</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>beanIdProperty</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>classname</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>useBean</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
/impl/conf/WEB-INF/web.xml
4,6 → 4,12
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
 
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
 
<filter>
<filter-name>RequestedUrlFilter</filter-name>
<filter-class>pt.estgp.estgweb.web.filters.RequestURLFilter</filter-class>
123,7 → 129,18
</filter-mapping>
<!---->
<!--SERVLETS-->
 
<!--SOAP Tutorial-->
<servlet>
<servlet-name>ws</servlet-name>
<servlet-class>
com.sun.xml.ws.transport.http.servlet.WSServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!--SOAP Tutorial-->
 
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
148,7 → 165,8
/WEB-INF/struts/struts-srusource.xml,
/WEB-INF/struts/struts-survey.xml, <!-- Duarte Santos -->
/WEB-INF/struts/struts-comunicationfolder.xml,
/WEB-INF/struts/struts-processes.xml
/WEB-INF/struts/struts-processes.xml,
/WEB-INF/struts/struts-configuration.xml
</param-value>
</init-param>
<init-param>
214,6 → 232,10
<servlet-class>pt.estgp.estgweb.web.RepositoryStream</servlet-class>
</servlet>
<servlet>
<servlet-name>ftpProxyStream</servlet-name>
<servlet-class>pt.estgp.estgweb.web.FTPFileProxy</servlet-class>
</servlet>
<servlet>
<servlet-name>repositoryStreamVersion</servlet-name>
<servlet-class>pt.estgp.estgweb.web.RepositoryStreamVersion</servlet-class>
</servlet>
225,7 → 247,20
 
 
<!--MAPPINGS-->
 
<!--SOAP Tutorial-->
<servlet-mapping>
<servlet-name>ws</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ws</servlet-name>
<url-pattern>/ws/api</url-pattern>
</servlet-mapping>
<!--SOAP Tutorial-->
 
 
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
278,6 → 313,10
<url-pattern>/repositoryStreamVersion/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ftpProxyStream</servlet-name>
<url-pattern>/ftpProxyStream/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BlogServlet</servlet-name>
<url-pattern>/blog/*</url-pattern>
</servlet-mapping>
313,6 → 352,10
<location>/errorNoCookies.do</location>
</error-page>
<error-page>
<exception-type>pt.estgp.estgweb.web.exceptions.NotAuthorizedException</exception-type>
<location>/error401.do</location>
</error-page>
<error-page>
<exception-type>pt.estgp.estgweb.web.exceptions.InternalException</exception-type>
<location>/error401.do</location>
</error-page>
345,6 → 388,10
<location>/error404.do</location>
</error-page>
<error-page>
<error-code>408</error-code>
<location>/error408.do</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error500.do</location>
</error-page>
/impl/conf/WEB-INF/sun-jaxws.xml
New file
0,0 → 1,16
<?xml version="1.0" encoding="UTF-8"?>
<!--SOAP Tutorial-->
<endpoints
xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"
version="2.0">
<endpoint
name="HelloWorld"
binding="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/"
implementation="pt.estgp.estgweb.web.soap.HelloWorldImpl"
url-pattern="/hello"/>
<endpoint
name="HelloWorld"
binding="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/"
implementation="pt.estgp.estgweb.web.soap.courses.CourseWsImpl"
url-pattern="/ws/api"/>
</endpoints>
/impl/conf/app.properties
1,7 → 1,7
 
#FICHEIRO DE CONFIGURACOES
 
import.year=201314
import.year=201516
tmp.dir=@tmp.dir@
data.dir=@data.dir@
use.ldap=@use.ldap@
11,14 → 11,28
site.url=@site.url@
 
admin.email=ci@estgp.pt
admin.email.2=jmachado@estgp.pt
 
 
email.local.suffix=estgp.pt
email.server=127.0.0.1
email.user=
email.password=
email.server=smtp.gmail.com
email.user=bacodev@estgp.pt
email.password=Agreyq54p7870#
email.from=bacodev@estgp.pt
email.templates.dir=@email.templates.dir@
#email.server.security=
#email.server.security=SSL
email.server.security=TLS
email.server.security.tls=587
email.server.security.ssl=465
 
 
#email.server=127.0.0.1
#email.user=Baco_web
#email.password=baco
#email.from=bacodev@baco.ipportalegre.pt
#email.templates.dir=@email.templates.dir@
#email.server.security=
#########################
##
########################
47,11 → 61,13
 
email.summaries=false
 
email.summary.subject.pt=Sumário lançado em {0}
email.summary.subject.en=Sumário lançado em {0}
email.summary.subject.pt=Sumario lançado em {0}
email.summary.subject.en=Sumario lançado em {0}
 
 
email.unidade.edicao.subject.pt=Ficha em edição {0}
email.relatorio.aval.unidade.editado.subject.pt=Relatorio Avaliacao Editado {0}
email.relatorio.aval.unidade.editado.subject.en=Unit Report Evaluation Edited {0}
email.unidade.edicao.subject.pt=Ficha em edicao {0}
email.unidade.edicao.subject.en=Unit in edition {0}
email.unidade.editada.subject.pt=Ficha editada {0}
email.unidade.editada.subject.en=Unit edited {0}
83,6 → 99,7
module.assessments=true
 
module.processes=true
module.courseunitevaluation=true
##################################################
# SMS
#
96,6 → 113,11
## Job Deamon seconds
job.deamon.sleep.seconds=30
 
 
//seconds
ftp.timeout.seconds=10
 
ftp.data.store.timeout.seconds=60
##################################################
##Proxy Servers
#If is an HTTP Server needs encoding config if FTP needs user pass config
104,8 → 126,25
server.ionline.start.path=
ionline.pass=baco
ionline.user=Baco_web
##ESTA CONFIGURACAO ESTA FUNCIONAL
## Ver nos Ficheiros FtpService metodo run
## Ver LayoutController
## Tem três metodos de autenticacao, ou com a CredentialsForm, ou com Static Access (Esta config) ou com a
## chave (String) ((UserSessionImpl)userSession).get(FtpService.FTP_PASSWORD); onde guardadmos a pass com
## que o user se autenticou no sistema
## Estas configs sao usadas para criar o FTPServer e Client
## FtpServer ftpServer = FtpServer.getNewServer(server, user, pass);
## Todos o sistema de ficheiros tem codigo espalhado das classes FTPServer e FTPClient
## Para se conseguir isolar o sistema deste código tem de se fazer um nivel de abstracao
## e remover todos o código de FTPServer e FTPClient
ionline.use.default.credentials.to.updates.and.deletes=false
 
server.grupos=ftp://ftppublic:ftppublic@w2.estgp.pt
server.grupos.start.path=/grupos
grupos.pass=ftppublic
grupos.user=ftppublic
 
 
server.estgp.start.path=
server.estgp=http://localhost:9090/static
estgp.encoding=UTF-8
203,7 → 242,7
user.role.63=courseValidateProgramAA
user.role.64=courseValidateProgramG
user.role.65=courseValidateProgramID
user.role.77=courseValidateProgramEGPMEestranho
user.role.66=courseValidateProgramGPME
 
 
user.role.78=courseValidateProgramRPS
233,6 → 272,7
announcements.text.summary.size=500
announcements.text.summary.size.small=100
announcements.max.visible=10
announcements.max.news.visible=15
announcements.top.flash.news.timeout.miliseconds=7000
 
announcements.type.0=news
419,12 → 459,26
#
 
siges.degree.1=L
siges.degree.2=B
siges.degree.3=D
siges.degree.4=M
siges.degree.8=C
siges.degree.5=H
siges.degree.6=P
siges.degree.7=Z
siges.degree.8=Z
siges.degree.9=A
siges.degree.10=T
siges.degree.11=E
siges.degree.12=Z
siges.degree.13=Z
siges.degree.14=Z
siges.degree.15=Z
siges.degree.16=C
siges.degree.17=O
 
national.institution.code=3122
siges.institution.code=1
ws.siges.wsdl=@ws.siges.wsdl@
# DONT USE ANY MORE NOW IS IN CONFIGURATION DAO national.institution.code=3122
# DONT USE ANY MORE NOW IS IN CONFIGURATION DAO siges.institution.code=1
# DONT USE ANY MORE NOW IS IN CONFIGURATION DAO ws.siges.wsdl=@ws.siges.wsdl@
ws.siges.target.namespace=@ws.siges.target.namespace@
 
ws.siges.secret=deptal1232007estg.
445,6 → 499,11
intranet.semestre.S2=Semestre2
intranet.semestre.A=Anual
 
intranet.semestre.T1=Trimestre1
intranet.semestre.T2=Trimestre2
intranet.semestre.T3=Trimestre3
intranet.semestre.T4=Trimestre4
 
intranet.setup.file=@intranet.setup.folders.file@
intranet.setup.users.filename=cursos.txt
intranet.setup.filename=@intranet.setup.folders.filename@
453,8 → 512,24
intranet.contents.dir=Conteudos
intranet.grades.dir=Avaliacao
intranet.presences.dir=Assiduidade
intranet.dtp.dir=DTP
 
intranet.dtp.planeamento=1.Planeamento
intranet.dtp.ficha_curricular=2.Ficha.Curricular
intranet.dtp.sumarios=3.Sumarios
intranet.dtp.avaliacao=4.Avaliacao
intranet.dtp.avaliacao.enunciados=4.1.Enunciados
intranet.dtp.avaliacao.pautas=4.2.Pautas
intranet.dtp.ficha_avaliacao=5.Relatorio.de.Avaliacao
intranet.dtp.inquerito_pedagogico=6.Inquerito.Pedagogico
intranet.dtp.course.coordinator.write=true
intranet.dtp.course.director.write=true
intranet.dtp.course.unit.responsible.write=true
 
##COLOCAR AQUI AS DEFINICOES DO DTP
 
 
 
#########################################################################
#
#PopService
597,3 → 672,16
assessments.correctA.1=notAnonymous
assessments.correction.selection.0=question
assessments.correction.selection.1=assessment
 
 
#################
# SIGES CODES
#
netpa.tipo.aula.1=Teorica
netpa.tipo.aula.2=Teorico-pratica
netpa.tipo.aula.3=Pratica Laboratorial
netpa.tipo.aula.4=Seminario
netpa.tipo.aula.5=Laboratorial
netpa.tipo.aula.6=OT-Orientacao Tutorial
netpa.tipo.aula.7=Ensino Clinico
netpa.tipo.aula.8=Estagio HO
/impl/conf/template/email/unidadeValidada_pt.txt
4,7 → 4,7
O BACO informa-o de que a ficha curricular da unidade de {0}
foi aprovada pela comissão de curso
 
Com os melhores cumprimentos
Cumprimentos
---------------------------------------------
Escola Superior de Tecnologia e Gestão
Instituto Politécnico de Portalegre
/impl/conf/template/email/courseUnitWork_pt.txt
15,7 → 15,8
 
{2}
 
Com os melhores cumprimentos {3}
Cumprimentos
{3}
 
---------------------------------------------
Escola Superior de Tecnologia e Gestão
/impl/conf/template/email/unidadeRelatorioAvaliacaoEditado_en.txt
New file
0,0 → 1,13
#Email unidade ficha em edicao
Caro membro da comissão de curso de {0}
 
O BACO informa-o de que o relatorio de avaliação da unidade curricular de {1}
foi alterado
 
Estado: {2}
 
Com os melhores cumprimentos
---------------------------------------------
Escola Superior de Tecnologia e Gestão
Instituto Politécnico de Portalegre
http://www.estgp.pt
Property changes:
Added: svn:executable
+ *
/impl/conf/template/email/summaries_pt.txt
New file
0,0 → 1,15
#Email course unit summaries
Caro Aluno
 
Seguem o sumarios atualizados da disciplina de {0} do dia {1}
 
Sumários
 
{2}
 
Cumprimentos
 
---------------------------------------------
Escola Superior de Tecnologia e Gestão
Instituto Politécnico de Portalegre
http://www.estgp.pt
/impl/conf/template/email/summariesFragment_en.txt
New file
0,0 → 1,7
#Email course unit summary Fragment
 
Title: {0}
Day: {1}
 
{2}
 
/impl/conf/template/email/courseUnitWorkChange_pt.txt
19,7 → 19,8
 
{2}
 
Com os melhores cumprimentos {3}
Cumprimentos
{3}
 
---------------------------------------------
Escola Superior de Tecnologia e Gestão
/impl/conf/template/email/courseUnitBlogPost_pt.txt
14,7 → 14,8
 
{2}
 
Com os melhores cumprimentos {3}
Cumprimentos
{3}
 
---------------------------------------------
Escola Superior de Tecnologia e Gestão
/impl/conf/template/email/courseUnitAnnouncement_pt.txt
15,7 → 15,8
 
{2}
 
Com os melhores cumprimentos {3}
Cumprimentos
{3}
 
---------------------------------------------
Escola Superior de Tecnologia e Gestão
/impl/conf/template/email/unidadeEdicao_pt.txt
4,7 → 4,7
O BACO informa-o de que a ficha curricular da unidade de {0}
se encontra disponivel para edição
 
Com os melhores cumprimentos
Cumprimentos
---------------------------------------------
Escola Superior de Tecnologia e Gestão
Instituto Politécnico de Portalegre
/impl/conf/template/email/sendPageFriend_pt.txt
5,7 → 5,7
 
{1}
 
Com os Melhores cumprimentos
Cumprimentos
 
---------------------------------------------
Escola Superior de Tecnologia e Gestão
/impl/conf/template/email/newGrades_pt.txt
5,7 → 5,7
 
{1}
 
Com os melhores cumprimentos
Cumprimentos
 
---------------------------------------------
Escola Superior de Tecnologia e Gestão
/impl/conf/template/email/message_pt.txt
13,7 → 13,7
 
{2}
 
<p>Com os melhores cumprimentos {3}</p>
<p>Cumprimentos, {3}</p>
 
---------------------------------------------
<p>Escola Superior de Tecnologia e Gestão</p>
/impl/conf/template/email/summaries_en.txt
New file
0,0 → 1,15
#Email course unit summares
Dear Student
 
Follow the updated summaries of {0} at day {1}
 
Summaries
 
{2}
 
Best Regards
 
---------------------------------------------
Escola Superior de Tecnologia e Gestão
Instituto Politécnico de Portalegre
http://www.estgp.pt
Property changes:
Added: svn:executable
+ *
/impl/conf/template/email/unidadeEditada_pt.txt
4,7 → 4,7
O BACO informa-o de que a ficha curricular da unidade de {1}
foi editada
 
Com os melhores cumprimentos
Cumprimentos
---------------------------------------------
Escola Superior de Tecnologia e Gestão
Instituto Politécnico de Portalegre
/impl/conf/template/email/unidadeRelatorioAvaliacaoEditado_pt.txt
New file
0,0 → 1,13
#Email unidade ficha em edicao
Caro membro da comissão de curso de {0}
 
O BACO informa-o de que o relatorio de avaliação da unidade curricular de {1}
foi editado
 
Estado: {2}
 
Cumprimentos
---------------------------------------------
Escola Superior de Tecnologia e Gestão
Instituto Politécnico de Portalegre
http://www.estgp.pt
/impl/conf/template/email/summariesFragment_pt.txt
New file
0,0 → 1,7
#Email course unit summary Fragment
 
Titulo: {0}
Dia: {1}
 
{2}
 
/impl/conf/template/email/summary_pt.txt
9,7 → 9,7
 
{4}
 
Com os melhores cumprimentos
Cumprimentos
 
---------------------------------------------
Escola Superior de Tecnologia e Gestão
/impl/conf/directories/futureStudent.xml
53,10 → 53,16
</node>
<node label="Orgãos de Gestão" id="OrgaosGestao" group="1">
<leaf absolute="false" url="/public/portal/orgaoDirector.html" proxy="estgp" id="orgaosDirector" label="Director"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoTecnicoCientifico.html" proxy="estgp" id="orgaosConselhoTecnicoCientifico" label="Conselho Técnico Científico"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoPedagogico.html" proxy="estgp" id="orgaosConselhoPedagogico" label="Conselho Pedagógico"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoRepresentantes.html" proxy="estgp" id="orgaosConselhoRepresentantes" label="Conselho Representantes"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoGestao.html" proxy="estgp" id="orgaosConselhogestao" label="Conselho de Gestão"></leaf>
 
<leaf absolute="false" url="/public/portal/orgaosConselhoTecnicoCientifico.html" proxy="estgp" id="orgaosConselhoTecnicoCientifico" label="Conselho Técnico Científico"></leaf>
<leaf absolute="false" url="/Conselho.Tecnico.Cientifico.Externo" proxy="grupos" id="pastaConselhoTecnicoCientificoExterna" label=" -----> Documentação CTC" remoteExtensionRoot="true" style="true" layout="true" />
<leaf absolute="false" url="/public/portal/orgaosConselhoPedagogico.html" proxy="estgp" id="orgaosConselhoPedagogico" label="Conselho Pedagógico"></leaf>
<leaf absolute="false" url="/Conselho.Pedagogico.Externo" proxy="grupos" id="pastaConselhoPegagogicoExterna" label=" -----> Documentação CP" remoteExtensionRoot="true" style="true" layout="true" />
<leaf absolute="false" url="/public/portal/orgaosConselhoRepresentantes.html" proxy="estgp" id="orgaosConselhoRepresentantes" label="Conselho Representantes"></leaf>
<leaf absolute="false" url="/Conselho.Representantes.Externo" proxy="grupos" id="pastaConselhoRepresentantesExterna" label=" -----> Documentação CR" remoteExtensionRoot="true" style="true" layout="true" />
 
 
<leaf absolute="false" url="/public/portal/orgaosConselhoGestao.html" proxy="estgp" id="orgaosConselhogestao" label="Conselho de Gestão"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoInterdepartamental.html" proxy="estgp" id="orgaosConselhoDepartamental" label="Conselho Departamental"></leaf>
</node>
<node label="Informação Académica" id="infoAcademica" group="2">
/impl/conf/directories/styleMapaDir.xsl
New file
0,0 → 1,43
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" xmlns:d="http://www.estgp.pt/baco/directory/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
 
<xsl:output method="html" encoding="UTF-8" omit-xml-declaration="yes" />
 
 
<xsl:template match="/">
<h1><xsl:value-of select="//d:directory/@label"/></h1>
<table border="1" width="100%">
<tr>
<td>NOME</td>
<td>SALTO EXTERNO</td>
<td>ULR</td>
<td width="20%">NOTAS</td>
</tr>
<xsl:for-each select="//d:node">
<tr>
<td colspan="4" style="background-color:#aaaaaa"><xsl:value-of select="@label"/></td>
</tr>
<xsl:for-each select="./d:leaf">
<tr>
<td><xsl:text>-&gt;</xsl:text><xsl:value-of select="@label"/></td>
<td>
<xsl:if test="@absolute='true'">
<label style="background-color:red">SIM</label>
</xsl:if>
<xsl:if test="@proxy='grupos'">
<label style="background-color:yellow">PASTA INTRANET</label>
</xsl:if>
 
</td>
<td><xsl:value-of select="@url"/></td>
<td></td>
</tr>
</xsl:for-each>
 
</xsl:for-each>
 
</table>
</xsl:template>
 
 
</xsl:stylesheet>
Property changes:
Added: svn:executable
+ *
/impl/conf/directories/utilsIntranet.xml
10,7 → 10,8
<leaf label="Atas" id="Actas" absolute="false" remoteExtensionRoot="true" style="true" proxy="ionline" layout="true" url="/Actas"/>
</leaf>
<leaf absolute="false" label="Horários" layout="true" proxy="estgp" id="horarios" url="/intranet/escola/horarios.html">
<leaf absolute="false" label="Horários de CET" layout="true" proxy="estgp" id="horariosCet" url="/intranet/escola/horarios_cets.html"/>
<leaf absolute="false" label="Horários de CTeSP" layout="true" proxy="estgp" id="horariosCTeSP" url="/intranet/escola/horarios_ctesps.html"/>
<leaf absolute="false" label="Horários de CET" layout="true" proxy="estgp" id="horariosCet" url="/intranet/escola/horarios_cets.html"/>
<leaf absolute="false" label="Horários de Licenciaturas" layout="true" proxy="estgp" id="horariosLicenciaturas" url="/intranet/escola/horarios_licenciaturas.html"/>
<leaf absolute="false" label="Horários de Mestrados" layout="true" proxy="estgp" id="horariosMestrados" url="/intranet/escola/horarios_mestrados.html"/>
<leaf absolute="false" label="Horários de Docentes" layout="true" proxy="estgp" id="horariosDocentes" url="/intranet/escola/horarios_Docentes.html"/>
/impl/conf/directories/student.xml
1,4 → 1,4
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<directory label="Alunos" place="home" layout="layout0" layoutRoot="layoutPortal" targetRole="student" id="student" menuKey="menu.alunos" style="style1.xsl" xmlns="http://www.estgp.pt/baco/directory/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.estgp.pt/baco/directory/ directory.xsd">
<groupsDeclaration>
<group>1</group>
20,7 → 20,7
<leaf absolute="false" url="/public/portal/contactosCentroInformatico.html" proxy="estgp" id="contCentroInformatico" label="Centro Informático"></leaf>
<leaf absolute="false" url="/public/portal/contactosGabineteComunicacao.html" proxy="estgp" id="contGabinetedeComunicacao" label="Gabinete de Comunicação"></leaf>
</node>
<node label="Biblioteca" id="biblioteca" group="1">
<node label="Biblioteca" id="biblioteca" group="1">
<leaf absolute="false" url="/public/portal/servicosBibliotecaApresentacao.html" proxy="estgp" id="servBiblioteca" label="Apresentação"></leaf>
<leaf absolute="false" url="/public/portal/servicosBibliotecaServicos.html" proxy="estgp" id="servBibliotecaServ" label="Serviços"></leaf>
<leaf absolute="false" url="/public/portal/servicosBibliotecaColeccoes.html" proxy="estgp" id="servBibliotecaColeccoes" label="Coleções"></leaf>
43,10 → 43,15
</node>
<node label="Orgãos de Gestão" id="OrgaosGestao" group="1">
<leaf absolute="false" url="/public/portal/orgaoDirector.html" proxy="estgp" id="orgaosDirector" label="Diretor"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoTecnicoCientifico.html" proxy="estgp" id="orgaosConselhoTecnicoCientifico" label="Conselho Técnico Científico"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoPedagogico.html" proxy="estgp" id="orgaosConselhoPedagogico" label="Conselho Pedagógico"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoRepresentantes.html" proxy="estgp" id="orgaosConselhoRepresentantes" label="Conselho Representantes"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoGestao.html" proxy="estgp" id="orgaosConselhogestao" label="Conselho de Gestão"></leaf>
 
<leaf absolute="false" url="/public/portal/orgaosConselhoTecnicoCientifico.html" proxy="estgp" id="orgaosConselhoTecnicoCientifico" label="Conselho Técnico Científico"></leaf>
<leaf absolute="false" url="/Conselho.Tecnico.Cientifico.Externo" proxy="grupos" id="pastaConselhoTecnicoCientificoExterna" label=" -----> Documentação CTC" remoteExtensionRoot="true" style="true" layout="true" />
<leaf absolute="false" url="/public/portal/orgaosConselhoPedagogico.html" proxy="estgp" id="orgaosConselhoPedagogico" label="Conselho Pedagógico"></leaf>
<leaf absolute="false" url="/Conselho.Pedagogico.Externo" proxy="grupos" id="pastaConselhoPegagogicoExterna" label=" -----> Documentação CP" remoteExtensionRoot="true" style="true" layout="true" />
<leaf absolute="false" url="/public/portal/orgaosConselhoRepresentantes.html" proxy="estgp" id="orgaosConselhoRepresentantes" label="Conselho Representantes"></leaf>
<leaf absolute="false" url="/Conselho.Representantes.Externo" proxy="grupos" id="pastaConselhoRepresentantesExterna" label=" -----> Documentação CR" remoteExtensionRoot="true" style="true" layout="true" />
 
<leaf absolute="false" url="/public/portal/orgaosConselhoGestao.html" proxy="estgp" id="orgaosConselhogestao" label="Conselho de Gestão"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoInterdepartamental.html" proxy="estgp" id="orgaosConselhoDepartamental" label="Conselho Interdepartamental"></leaf>
</node>
/impl/conf/directories/teacher.xml
42,12 → 42,15
<leaf absolute="false" url="/public/portal/PALVErasmusFormularioDocentes.html" proxy="estgp" id="PALVErasmusFomularioDocentes" label="Formulários Docentes"></leaf>
<leaf absolute="false" url="/public/portal/PALVErasmusContactos.html" proxy="estgp" id="PALVErasmusContactos" label="Contactos"></leaf>
</node>
><node label="Orgãos de Gestão" id="OrgaosGestao" group="1">
<node label="Orgãos de Gestão" id="OrgaosGestao" group="1">
<leaf absolute="false" url="/public/portal/orgaoDirector.html" proxy="estgp" id="orgaosDirector" label="Director"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoTecnicoCientifico.html" proxy="estgp" id="orgaosConselhoTecnicoCientifico" label="Conselho Técnico Científico"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoPedagogico.html" proxy="estgp" id="orgaosConselhoPedagogico" label="Conselho Pedagógico"></leaf>
<leaf absolute="false" url="/Conselho.Tecnico.Cientifico.Externo" proxy="grupos" id="pastaConselhoTecnicoCientificoExterna" label=" -----> Documentação CTC" remoteExtensionRoot="true" style="true" layout="true" />
<leaf absolute="false" url="/public/portal/orgaosConselhoPedagogico.html" proxy="estgp" id="orgaosConselhoPedagogico" label="Conselho Pedagógico"></leaf>
<leaf absolute="false" url="/Conselho.Pedagogico.Externo" proxy="grupos" id="pastaConselhoPegagogicoExterna" label=" -----> Documentação CP" remoteExtensionRoot="true" style="true" layout="true" />
<leaf absolute="false" url="/public/portal/orgaosConselhoRepresentantes.html" proxy="estgp" id="orgaosConselhoRepresentantes" label="Conselho Representantes"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoGestao.html" proxy="estgp" id="orgaosConselhogestao" label="Conselho de Gestão"></leaf>
<leaf absolute="false" url="/Conselho.Representantes.Externo" proxy="grupos" id="pastaConselhoRepresentantesExterna" label=" -----> Documentação CR" remoteExtensionRoot="true" style="true" layout="true" />
<leaf absolute="false" url="/public/portal/orgaosConselhoGestao.html" proxy="estgp" id="orgaosConselhogestao" label="Conselho de Gestão"></leaf>
<leaf absolute="false" url="/public/portal/orgaosConselhoInterdepartamental.html" proxy="estgp" id="orgaosConselhoInterdepartamental" label="Conselho Interdepartamental"></leaf>
</node>
<node label="Informação Académica" id="infoAcademica" group="2">
/impl/conf/berserk/sd.xml
266,7 → 266,20
</filterChains>
</service>
 
<service>
<name>LoadOwnerAnnouncementsMax</name>
<implementationClass>pt.estgp.estgweb.services.announcements.LoadOwnerAnnouncements</implementationClass>
<description>Load owner Blogs</description>
<isTransactional>true</isTransactional>
<defaultMethod>loadMax</defaultMethod>
<filterChains>
<chain name="Logger"/>
<chain name="Session"/>
<chain name="AuthenticatedUsers"/>
</filterChains>
</service>
 
 
<!--Teste-->
<service>
<name>TesteSaver</name>
421,7 → 434,20
<chain name="AuthenticatedUsers"/>
</filterChains>
</service>
 
<service>
<name>LoadEditableBlogsMax</name>
<implementationClass>pt.estgp.estgweb.services.blogs.LoadEditableBlogs</implementationClass>
<description>Load editable Blogs</description>
<isTransactional>true</isTransactional>
<defaultMethod>loadMax</defaultMethod>
<filterChains>
<chain name="Logger"/>
<chain name="Session"/>
<chain name="AuthenticatedUsers"/>
</filterChains>
</service>
<service>
<name>LoadOwnerBlogs</name>
<implementationClass>pt.estgp.estgweb.services.blogs.LoadOwnerBlogs</implementationClass>
<description>Load owner Blogs</description>
433,6 → 459,18
</filterChains>
</service>
<service>
<name>LoadOwnerBlogsMax</name>
<implementationClass>pt.estgp.estgweb.services.blogs.LoadOwnerBlogs</implementationClass>
<description>Load owner Blogs</description>
<isTransactional>true</isTransactional>
<defaultMethod>loadMax</defaultMethod>
<filterChains>
<chain name="Logger"/>
<chain name="Session"/>
<chain name="AuthenticatedUsers"/>
</filterChains>
</service>
<service>
<name>LoadOwnerBlogPosts</name>
<implementationClass>pt.estgp.estgweb.services.blogs.LoadOwnerBlogPosts</implementationClass>
<description>Load owner Blog Posts</description>
443,6 → 481,18
<chain name="AuthenticatedUsers"/>
</filterChains>
</service>
<service>
<name>LoadOwnerBlogPostsMax</name>
<implementationClass>pt.estgp.estgweb.services.blogs.LoadOwnerBlogPosts</implementationClass>
<description>Load owner Blog Posts</description>
<isTransactional>true</isTransactional>
<defaultMethod>loadMax</defaultMethod>
<filterChains>
<chain name="Logger"/>
<chain name="Session"/>
<chain name="AuthenticatedUsers"/>
</filterChains>
</service>
 
 
 
810,6 → 860,30
</service>
 
<service>
<name>SaveCourseUnitEvaluation</name>
<implementationClass>pt.estgp.estgweb.services.courseunits.SaveCourseUnitEvaluation</implementationClass>
<description>Save course unit evaluation</description>
<isTransactional>true</isTransactional>
<defaultMethod>save</defaultMethod>
<filterChains>
<chain name="Logger"/>
<chain name="Session"/>
</filterChains>
</service>
 
<service>
<name>OpenCourseUnitEvaluation</name>
<implementationClass>pt.estgp.estgweb.services.courseunits.SaveCourseUnitEvaluation</implementationClass>
<description>Open course unit evaluation for edition</description>
<isTransactional>true</isTransactional>
<defaultMethod>open</defaultMethod>
<filterChains>
<chain name="Logger"/>
<chain name="Session"/>
</filterChains>
</service>
 
<service>
<name>LoadCourseUnitsBySigesCodes</name>
<implementationClass>pt.estgp.estgweb.services.courseunits.LoadCourseUnitsBySigesCodesService</implementationClass>
<description>Load course old units</description>
819,7 → 893,20
<chain name="Session"/>
</filterChains>
</service>
 
<service>
<name>LoadCourseUnitsBySigesCodesSemestreLastYear</name>
<implementationClass>pt.estgp.estgweb.services.courseunits.LoadCourseUnitsBySigesCodesService</implementationClass>
<description>Load a unique unit by sigescode, semestre and course code</description>
<isTransactional>true</isTransactional>
<defaultMethod>loadLastYear</defaultMethod>
<filterChains>
<chain name="Logger"/>
<chain name="Session"/>
</filterChains>
</service>
 
<service>
<name>LoadCourseUnitWorks</name>
<implementationClass>pt.estgp.estgweb.services.courseunits.CourseUnitWorkService</implementationClass>
<description>Load course unit works</description>
1025,6 → 1112,15
</filterChains>
</service>
<service>
<name>LoadSubscribedUnitsGivenYear</name>
<implementationClass>pt.estgp.estgweb.services.courseunits.LoadSubscribedUnitsCurrentYearService</implementationClass>
<description>Load student units in current Year</description>
<isTransactional>true</isTransactional>
<defaultMethod>givenYear</defaultMethod>
<filterChains>
</filterChains>
</service>
<service>
<name>LoadSubscribedUnitsOldYears</name>
<implementationClass>pt.estgp.estgweb.services.courseunits.LoadSubscribedUnitsOldYearsService</implementationClass>
<description>Load student units in current Year</description>
1107,7 → 1203,7
<!--CourseUnitAssignements Backups-->
<service>
<name>CreateCourseUnitDirPackage</name>
<implementationClass>pt.estgp.estgweb.services.courseunits.CreateCourseUnitDirPackageService</implementationClass>
<implementationClass>pt.estgp.estgweb.services.courseunits.CreateCourseUnitDirPackageServiceBat</implementationClass>
<description>Create a zip file with Intranet folders</description>
<isTransactional>true</isTransactional>
<filterChains>
1975,4 → 2071,19
</service>
 
 
<!--Atention this method should be used with carefully because loads an object inconditionally without checking permissions-->
<service>
<name>LoadObjectService</name>
<implementationClass>pt.estgp.estgweb.services.common.LoadObjectService</implementationClass>
<description>Loads an object from Object Repository</description>
<isTransactional>true</isTransactional>
<defaultMethod>load</defaultMethod>
<filterChains>
<chain name="Logger"/>
<chain name="Session"/>
</filterChains>
</service>
 
 
 
</serviceDefinitions>
/impl/conf/hibernate.cfg.xml
22,7 → 22,7
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.max_size">30</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.idle_test_period">150</property>
<property name="hibernate.c3p0.idle_test_period">150</property>
<property name="hibernate.max_statements">50</property>
 
 
/impl/src/java/jomm/utils/AutoFillArrayList.java
20,7 → 20,7
{
super();
// this.c = c;
for(int i=0;i<600;i++)
for(int i=0;i<50;i++)
{
try
{
/impl/src/java/jomm/dao/impl/AbstractDao.java
13,7 → 13,6
import pt.estgp.estgweb.domain.DomainSerializableObject;
 
import java.io.Serializable;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Date;
import java.util.List;
116,16 → 115,12
{
try
{
getCurrentSession().connection().commit();
getCurrentSession().getTransaction().commit();
}
catch (HibernateException e)
{
throw new DaoException(e);
}
catch (SQLException e)
{
throw new DaoException(e);
}
}
 
 
341,6 → 336,8
*/
public CLAZZ narrow(CLAZZ o)
{
if(o == null)
return null;
if (o instanceof HibernateProxy)
{
return (CLAZZ) ((HibernateProxy)o).getHibernateLazyInitializer().getImplementation();
755,6 → 752,7
{
for (CLAZZ obj : objs)
{
System.out.println("CLEARING: " + obj);
evictAndDelete(obj);
}
}
/impl/src/java/jomm/web/ftp/impl/FtpFile.java
90,7 → 90,12
return URIUtil.encodePath(name,"ISO-8859-1");
}
 
public String getOriginalPathEncoded() throws URIException
{
return URIUtil.encodePath(path,"ISO-8859-1");
}
 
 
public String getNameEscapedHtml()
{
try {
189,4 → 194,17
}
return iFiles;
}
 
public String getServerRelativePathFile() throws URIException {
String path = getOriginalPathEncoded();
if(!path.startsWith("/"))
path = "/" + path;
 
if(!path.endsWith("/"))
path = path + "/";
 
String name = getNameEncoded();
 
return path + name;
}
}
/impl/src/java/jomm/web/ftp/IFile.java
1,15 → 1,12
package jomm.web.ftp;
 
import jomm.web.utils.NavPlace;
import org.apache.commons.httpclient.URIException;
 
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
 
import org.apache.commons.httpclient.URIException;
 
/**
* @author Jorge Machado
* @date 6/Fev/2008
32,4 → 29,5
public boolean isDirectory();
public FileType getType();
public String getCompleteUrl();
public String getServerRelativePathFile() throws URIException;
}
/impl/src/java/pt/estgp/estgweb/utils/DatesUtils.java
1,11 → 1,15
package pt.estgp.estgweb.utils;
 
import jomm.utils.MyCalendar;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;
import pt.estgp.estgweb.Globals;
 
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
25,7 → 29,7
static MessageFormat SIGES_importFinalFormatIntranet = new MessageFormat(Globals.SIGES_importFinalFormatIntranet);
static MessageFormat SIGES_importFinalFormatProgram = new MessageFormat(Globals.SIGES_importFinalFormatProgram);
 
public static String getImportYear()
/* public static String getImportYear()
{
return ConfigProperties.getProperty("import.year");
// MyCalendar mc = new MyCalendar();
48,7 → 52,7
//
// return getFormatedImportYear(firstYearStr,secondYearStr,SIGES_importFinalFormat);
}
 
*/
public static String getSemestre()
{
MyCalendar mc = new MyCalendar();
114,6 → 118,14
}
}
 
public static String getPreviousImportYear(String importYear)
{
String first = importYear.substring(0,4);
String second = importYear.substring(4);
first = "" + (Integer.parseInt(first)-1);
second = "" + (Integer.parseInt(second)-1);
return first+second;
}
public static String getImportYearIntranet()
{
MyCalendar mc = new MyCalendar();
161,6 → 173,22
return finalFormat.format(years);
}
 
static SimpleDateFormat formatFileSystem = new SimpleDateFormat("yyyyMMdd_HHmmss");
 
/**
*
* @param d java.util.Date
* @return a string formated like this:
*
* 20151103_043500
*
* for 2015/11/03 at 04:35:00 time
*/
public static String getFormatedFileSystem(Date d)
{
return formatFileSystem.format(d);
}
 
public static List<String> getImportYears(int size)
{
MyCalendar mc = new MyCalendar();
204,11 → 232,17
return years;
}
 
public static void main(String [] args)
{
public static void main(String [] args) throws JSONException {
 
System.out.println(getPreviousImportYear("201516"));
String json = "{\"paises\": {\"pais\": [ {\"populacao\":196655014,\"sigla\":\"BR\",\"nome\":\"Brasil\"}, {\"populacao\":40764561,\"sigla\":\"AR\",\"nome\":\"Argentina\"} ] } }";
JSONObject obj = new JSONObject(json);
System.out.println(XML.toString(obj));
 
/*
System.out.println(getImportYearIntranet("201213"));
System.out.println(getImportYearBefore("200001"));
System.out.println(getImportYear());
System.out.println(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYearCreateTransaction());
System.out.println(getImportYearFormatted("201314"));
java.util.List<String> years = new java.util.ArrayList<String>();
years.add("201314");
222,5 → 256,6
});
for(String y: years)
System.out.println(y);
*/
}
}
/impl/src/java/pt/estgp/estgweb/utils/Email.java
32,6 → 32,7
private String from;
private String emailTemplateName;
private List<String> arguments;
private String fromName = null;
 
 
public boolean isHtml() {
61,7 → 62,14
this.arguments = arguments;
}
 
public String getFromName() {
return fromName;
}
 
public void setFromName(String fromName) {
this.fromName = fromName;
}
 
public String getSubject()
{
return subject;
/impl/src/java/pt/estgp/estgweb/utils/StringsUtils.java
44,6 → 44,7
try{
if(nome != null)
{
nome = nome.replace("/","_");
String[] partes = nome.split(" ");
StringBuilder sb = new StringBuilder();
for(String n : partes)
/impl/src/java/pt/estgp/estgweb/Globals.java
1,13 → 1,12
package pt.estgp.estgweb;
 
import pt.estgp.estgweb.domain.DirectoryImpl;
import pt.estgp.estgweb.services.directories.DirectoryService;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.services.directories.DirectoryService;
import pt.estgp.estgweb.domain.DirectoryImpl;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigDecimal;
 
/**
* @author Jorge Machado
79,13 → 78,31
}
 
 
public static final int FTP_TIMEOUT_SECONDS = ConfigProperties.getIntProperty("ftp.timeout.seconds");
public static final int FTP_DATA_STORE_TIMEOUT_SECONDS = ConfigProperties.getIntProperty("ftp.data.store.timeout.seconds");
 
public static final boolean USE_TOP_FLASH_NEWS = ConfigProperties.getBooleanProperty("announcements.use.top.flash.news");
 
public static final String INTRANET_ROOT = ""; //e' mesmo assim
public static final String INTRANET_CONTENTS = ConfigProperties.getProperty("intranet.contents.dir");
public static final String INTRANET_GRADES = ConfigProperties.getProperty("intranet.grades.dir");
public static final String INTRANET_PRESENCES = ConfigProperties.getProperty("intranet.presences.dir");
public static final String INTRANET_DTP = ConfigProperties.getProperty("intranet.dtp.dir");
 
public static final String INTRANET_DTP_Planeamento = ConfigProperties.getProperty("intranet.dtp.planeamento");
public static final String INTRANET_DTP_FichaCurricular = ConfigProperties.getProperty("intranet.dtp.ficha_curricular");
public static final String INTRANET_DTP_Sumarios = ConfigProperties.getProperty("intranet.dtp.sumarios");
public static final String INTRANET_DTP_Avaliacao = ConfigProperties.getProperty("intranet.dtp.avaliacao");
public static final String INTRANET_DTP_Avaliacao_enunciados = ConfigProperties.getProperty("intranet.dtp.avaliacao.enunciados");
public static final String INTRANET_DTP_Avaliacao_pautas = ConfigProperties.getProperty("intranet.dtp.avaliacao.pautas");
public static final String INTRANET_DTP_FichaAvaliacao = ConfigProperties.getProperty("intranet.dtp.ficha_avaliacao");
public static final String INTRANET_DTP_InqueritoPedagogico = ConfigProperties.getProperty("intranet.dtp.inquerito_pedagogico");
public static final boolean INTRANET_DTP_CourseCoordinatorWrite = ConfigProperties.getBooleanProperty("intranet.dtp.course.coordinator.write");
public static final boolean INTRANET_DTP_CourseDirectorWrite = ConfigProperties.getBooleanProperty("intranet.dtp.course.director.write");
public static final boolean INTRANET_DTP_CourseUnitResponsibleWrite = ConfigProperties.getBooleanProperty("intranet.dtp.course.unit.responsible.write");
 
 
 
public static final int SEARCH_MAX_RESULTS = ConfigProperties.getIntProperty("search.max.results");
public static final int SEARCH_BEST_FRAGMENTS_MAX_FRAGMENT_SIZE = ConfigProperties.getIntProperty("search.best.fragments.max.fragment.size");
public static final int SEARCH_BEST_FRAGMENTS_MAX_FRAGMENTS = ConfigProperties.getIntProperty("search.best.fragments.max.fragments");
102,7 → 119,15
public static final List<String> AUTOMATIC_VALIDATION_ROLES = ConfigProperties.getListValues("announcements.automatic.validation.role");
public static final String TMP_DIR = ConfigProperties.getProperty("tmp.dir");
public static final String DATA_DIR = ConfigProperties.getProperty("data.dir");
public static final String JOB_SERVICES_LOG_DIR = ConfigProperties.getProperty("data.dir") + java.io.File.separator + "jobslogs";
;
public static final String EMAIL_SERVER_HOST = ConfigProperties.getProperty("email.server");
public static final String EMAIL_SERVER_SECURITY = ConfigProperties.getProperty("email.server.security");
public static final int EMAIL_SERVER_SECURITY_TLS = ConfigProperties.getIntProperty("email.server.security.tls");
public static final int EMAIL_SERVER_SECURITY_SSL = ConfigProperties.getIntProperty("email.server.security.ssl");
public static final String EMAIL_SERVER_USERNAME = ConfigProperties.getProperty("email.user");
public static final String EMAIL_SERVER_PASSWORD = ConfigProperties.getProperty("email.password");
 
public static final String SYSTEM_EMAIL_BOX = ConfigProperties.getProperty("email.from");
public static final String ANNOUNCEMENT_TYPE_NEWS = "news";
public static final String ANNOUNCEMENT_TYPE_TOP_FLASH_NEWS = "top.flash.news";
116,6 → 141,7
public static final int ANNOUNCEMENT_TYPE_TOP_FLASH_NEWS_TIMEOUT = ConfigProperties.getIntProperty("announcements.top.flash.news.timeout.miliseconds");
public static final List<String> ANNOUNCEMENT_NOT_STANDARD = ConfigProperties.getListValues("announcements.not.standard");
 
public static boolean USE_LDAP = ConfigProperties.getBooleanProperty("use.ldap");
public static List<String> USER_ROLES = ConfigProperties.getListValues("user.role");
 
public static final String STUDENT_ROLE = ConfigProperties.getProperty("user.student");
135,9 → 161,10
public static final List<String> DEPARTAMENTOS = ConfigProperties.getListValues("departamento");
 
/*SIGES WEB SERVICES*/
public static final BigDecimal NATIONAL_INSTITUTION_CODE = new BigDecimal(ConfigProperties.getIntProperty("national.institution.code"));
public static final BigDecimal SIGES_INSTITUTION_CODE = new BigDecimal(ConfigProperties.getIntProperty("siges.institution.code"));
public static final String SIGES_WEBSERVICE_WSDL = ConfigProperties.getProperty("ws.siges.wsdl");
//NAO É URGENTE PARA ACTUALIZACOES VAMOS DEIXAR CARREGAR DA BD E NAS ACTUALIZAÇOES MUDA AQUI
//public static BigDecimal NATIONAL_INSTITUTION_CODE = new BigDecimal(DaoFactory.getConfigurationDaoImpl().getNationalInstitutionCodeCreateTransaction());
// DONT USE NOW IN CONFIGURATION DAO public static final BigDecimal SIGES_INSTITUTION_CODE = new BigDecimal(ConfigProperties.getIntProperty("siges.institution.code"));
// DONT USE ANY MORE NOW IS IN CONFIGURATION DAOpublic static final String SIGES_WEBSERVICE_WSDL = ConfigProperties.getProperty("ws.siges.wsdl");
public static final String SIGES_WEBSERVICE_TARGET_NAMESPACE = ConfigProperties.getProperty("ws.siges.target.namespace");
public static final String SIGES_WEBSERVICE_SECRET = ConfigProperties.getProperty("ws.siges.secret");
 
198,7 → 225,13
public static final String INTRANET_SEMESTRE_S2 = ConfigProperties.getProperty("intranet.semestre.S2");
public static final String INTRANET_SEMESTRE_A = ConfigProperties.getProperty("intranet.semestre.A");
 
public static final String INTRANET_SEMESTRE_T1 = ConfigProperties.getProperty("intranet.semestre.T1");
public static final String INTRANET_SEMESTRE_T2 = ConfigProperties.getProperty("intranet.semestre.T2");
public static final String INTRANET_SEMESTRE_T3 = ConfigProperties.getProperty("intranet.semestre.T3");
public static final String INTRANET_SEMESTRE_T4 = ConfigProperties.getProperty("intranet.semestre.T4");
 
 
 
public static final String INTRANET_SETUP_FILE = ConfigProperties.getProperty("intranet.setup.file");
public static final String INTRANET_USERS_SETUP_FILE_NAME = ConfigProperties.getProperty("intranet.setup.users.filename");
public static final String INTRANET_SETUP_FILE_NAME = ConfigProperties.getProperty("intranet.setup.filename");
246,6 → 279,8
public static final boolean MODULE_STATUS_ASSESSMENTS = ConfigProperties.getBooleanProperty("module.assessments");
//Filipe Matos
 
 
public static final boolean MODULE_STATUS_COURSEUNITEVALUATION = ConfigProperties.getBooleanProperty("module.courseunitevaluation");
public static final boolean MODULE_STATUS_PROCESSES = ConfigProperties.getBooleanProperty("module.processes");
 
 
324,6 → 359,10
public static final String EMAIL_UNDADE_EDITADA_TEMPLATE_PT = "unidadeEditada_pt.txt";
public static final String EMAIL_UNDADE_EDITADA_TEMPLATE_EN = "unidadeEditada_en.txt";
 
public static final String EMAIL_RELATORIO_AVALIACAO_UNDADE_EDITADA_TEMPLATE_PT = "unidadeRelatorioAvaliacaoEditado_pt.txt";
public static final String EMAIL_RELATORIO_AVALIACAO_UNDADE_EDITADA_TEMPLATE_EN = "unidadeRelatorioAvaliacaoEditado_en.txt";
 
 
public static final String EMAIL_UNDADE_VALIDADA_TEMPLATE_PT = "unidadeValidada_pt.txt";
public static final String EMAIL_UNDADE_VALIDADA_TEMPLATE_EN = "unidadeValidada_en.txt";
 
331,16 → 370,32
public static final String EMAIL_UNDADE_EDICAO_SUBJECT_PT = "email.unidade.edicao.subject.pt";
public static final String EMAIL_UNDADE_EDICAO_SUBJECT_EN = "email.unidade.edicao.subject.en";
 
public static final String EMAIL_RELATORIO_AVALIACAO_UNDADE_EDITADA_SUBJECT_PT = "email.relatorio.aval.unidade.editado.subject.pt";
public static final String EMAIL_RELATORIO_AVALIACAO_UNDADE_EDITADA_SUBJECT_EN = "email.relatorio.aval.unidade.editado.subject.en";
 
public static final String EMAIL_UNDADE_EDITADA_SUBJECT_PT = "email.unidade.editada.subject.pt";
public static final String EMAIL_UNDADE_EDITADA_SUBJECT_EN = "email.unidade.editada.subject.en";
 
 
public static final String EMAIL_UNDADE_VALIDADA_SUBJECT_PT = "email.unidade.validade.subject.pt";
public static final String EMAIL_UNDADE_VALIDADA_SUBJECT_EN = "email.unidade.validada.subject.en";
 
public static final String EMAIL_SUMMARY_TEMPLATE_PT = "summary_pt.txt";
public static final String EMAIL_SUMMARY_TEMPLATE_EN = "summary_en.txt";
 
public static final String EMAIL_SUMMARIES_TEMPLATE_PT = "summaries_pt.txt";
public static final String EMAIL_SUMMARIES_TEMPLATE_EN = "summaries_en.txt";
 
public static final String EMAIL_SUMMARIES_FRAGMENT_TEMPLATE_PT = "summariesFragment_pt.txt";
public static final String EMAIL_SUMMARIES_FRAGMENT_TEMPLATE_EN = "summariesFragment_en.txt";
 
public static final String EMAIL_GRADE_UNIT_TEMPLATE = "GradeUnit.txt";
 
public static final String[] PROXY_EXTENSIONS = ConfigProperties.getProperty("proxy.extensions").split(" ");
 
 
public static final String FTP_IONLINE_URL = ConfigProperties.getProperty("server.ionline") + ConfigProperties.getProperty("server.ionline.start.path");
public static final String FTP_IONLINE_USER = ConfigProperties.getProperty("ionline.user");
public static final String FTP_IONLINE_PASS = ConfigProperties.getProperty("ionline.pass");
public static final String FTP_IONLINE_START_PATH = ConfigProperties.getProperty("server.ionline.start.path");
}
/impl/src/java/pt/estgp/estgweb/services/surveys/CreateEditSurveyService.java
44,7 → 44,7
surveyView.persistViewInObject(s);
s.setOwner(userSession.getUser());
s.setSemester(DatesUtils.getSemestre());
s.setYear(DatesUtils.getImportYear());
s.setYear(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
if(s.getStartDate() == null)
s.setStartDate(new Date());
s.setSaveDate(new Date());
/impl/src/java/pt/estgp/estgweb/services/courses/CoursesCommonServices.java
11,7 → 11,6
import pt.estgp.estgweb.services.common.impl.DefaultResult;
import pt.estgp.estgweb.services.common.impl.DefaultSearchResults;
import pt.estgp.estgweb.services.common.impl.DefaultToDo;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.ArrayList;
116,9 → 115,9
// }
// }
}
if(userSession.getUser().hasRole(Globals.COURSE_COMMISSION_PROGRAMS_ROLES))
/*if(userSession.getUser().hasRole(Globals.COURSE_COMMISSION_PROGRAMS_ROLES))
{
List<Course> courses = DaoFactory.getCourseDaoImpl().findAll(DatesUtils.getImportYear());
List<Course> courses = DaoFactory.getCourseDaoImpl().findAll(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
for(Course course: courses)
{
if(userSession.getUser().hasRole(course.getValidationRole()))
126,27 → 125,27
int missing = DaoFactory.getCourseUnitDaoImpl().countMissingProgramGivenCourse(course.getId());
if(missing > 0)
{
DefaultToDo defaultToDo = new DefaultToDo(course.getName(),null,null, "course.courseunit.program.objectives.todo",""+missing,"/user/startLoadCoursesProgramsFromHome.do#" + course.getId());
DefaultToDo defaultToDo = new DefaultToDo(course.getName(),null,null, "course.courseunit.program.objectives.todo",""+missing,"/user/startLoadCoursesProgramsFromHome.do?courseId=" + course.getId() + "#" + course.getId());
todos.add(defaultToDo);
}
int missingValidate = DaoFactory.getCourseUnitDaoImpl().countMissingProgramValidateCourse(course.getId());
if(missingValidate > 0)
{
DefaultToDo defaultToDo = new DefaultToDo(course.getName(),null,null, "course.courseunit.program.validate.todo",""+missingValidate,"/user/startLoadCoursesProgramsFromHome.do#" + course.getId());
DefaultToDo defaultToDo = new DefaultToDo(course.getName(),null,null, "course.courseunit.program.validate.todo",""+missingValidate,"/user/startLoadCoursesProgramsFromHome.do?courseId=" + course.getId() + "#" + course.getId());
todos.add(defaultToDo);
}
}
}
}
}*/
if(userSession.getUser().hasRole(Globals.SERVICES_PROGRAMS_ROLE))
{
List<Course> courses = DaoFactory.getCourseDaoImpl().findAll(DatesUtils.getImportYear());
List<Course> courses = DaoFactory.getCourseDaoImpl().findAll(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
for(Course course: courses)
{
int missing = DaoFactory.getCourseUnitDaoImpl().countMissingProgramGivenCourse(course.getId());
if(missing > 0)
{
DefaultToDo defaultToDo = new DefaultToDo(course.getName(),null,null, "course.courseunit.program.objectives.todo",""+missing,"/user/startLoadCoursesProgramsFromHome.do#" + course.getId());
DefaultToDo defaultToDo = new DefaultToDo(course.getName(),null,null, "course.courseunit.program.objectives.todo",""+missing,"/user/startLoadCoursesProgramsFromHome.do?courseId=" + course.getId() + "#" + course.getId());
todos.add(defaultToDo);
}
}
/impl/src/java/pt/estgp/estgweb/services/courses/CoursesService.java
13,9 → 13,8
import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum;
import pt.estgp.estgweb.services.data.IRepositoryFile;
import pt.estgp.estgweb.services.data.RepositoryService;
import pt.estgp.estgweb.services.expceptions.AlreadyExistsException;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.services.expceptions.AlreadyExistsException;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.utils.Dom4jUtil;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
24,7 → 23,9
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/*
* @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
139,7 → 140,9
try
{
Document dom = Dom4jUtil.parse(stream);
String html = Dom4jUtil.styleDocument(dom, Globals.TEMPLATE_COURSE_XSL_PATH);
Map<String,Object> parameters = new HashMap<String,Object>();
parameters.put("COURSE_SIGES_CODE",c.getCode());
String html = Dom4jUtil.styleDocument(dom, Globals.TEMPLATE_COURSE_XSL_PATH,parameters);
c.setCacheWebDocument(html);
}
catch (Exception e)
191,7 → 194,7
 
public List<CourseView> loadCoursesImportYear() throws ServiceException
{
String importYearIntranet = DatesUtils.getImportYear();
String importYearIntranet = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
List<Course> courses = DaoFactory.getCourseDaoImpl().findAllOrderByName(importYearIntranet);
List<CourseView> courseViews = new ArrayList<CourseView>();
for(Course c: courses)
203,7 → 206,7
}
public List<CourseView> loadCoursesImportYearByType(String type) throws ServiceException
{
String importYearIntranet = DatesUtils.getImportYear();
String importYearIntranet = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
List<Course> courses = DaoFactory.getCourseDaoImpl().findAllOrderByNameEvenWithoutCourseUnit(importYearIntranet,null,type);
List<CourseView> courseViews = new ArrayList<CourseView>();
for(Course c: courses)
216,7 → 219,7
 
public List<CourseView> loadActiveCoursesByType(String type) throws ServiceException
{
String importYearIntranet = DatesUtils.getImportYear();
String importYearIntranet = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
List<Course> courses = DaoFactory.getCourseDaoImpl().findAllActiveOrderByNameEvenWithoutCourseUnit(importYearIntranet,null,type);
List<CourseView> courseViews = new ArrayList<CourseView>();
for(Course c: courses)
/impl/src/java/pt/estgp/estgweb/services/courseunits/DirectedCoordinatedCourses.java
76,6 → 76,7
{
if(merge == null)
merge = new AutoFillArrayList<CourseView>(CourseView.class);
//merge = new ArrayList<CourseView>();
return merge;
}
 
/impl/src/java/pt/estgp/estgweb/services/courseunits/CreateCourseUnitXML.java
1,15 → 1,20
package pt.estgp.estgweb.services.courseunits;
 
import org.apache.fop.apps.FOPException;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentFactory;
import org.dom4j.Element;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.XML;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.utils.Dom4jUtil;
import pt.estgp.estgweb.web.utils.DatesUtils;
 
import javax.xml.transform.TransformerException;
import java.io.File;
import java.io.IOException;
import java.io.File;
 
/**
* @author Jorge Machado
40,7 → 45,7
Element rootElement = DocumentFactory.getInstance().createElement("courseUnit");
dom.setRootElement(rootElement);
rootElement.addAttribute("id", "" + courseUnit.getId());
rootElement.addAttribute("importYear", "" + courseUnit.getImportYear());
rootElement.addAttribute("importYear", "" + pt.estgp.estgweb.utils.DatesUtils.getImportYearIntranet(courseUnit.getImportYear()));
rootElement.addAttribute("institutionCode", "" + courseUnit.getInstitutionCode());
 
Element saveDate = DocumentFactory.getInstance().createElement("saveDate");
53,10 → 58,30
name.setText("" + courseUnit.getName());
 
Element courseName = DocumentFactory.getInstance().createElement("courseName");
name.setText("" + courseUnit.getCourseName());
courseName.setText("" + courseUnit.getCourseName());
 
Element courseCode = DocumentFactory.getInstance().createElement("courseCode");
courseCode.setText("" + courseUnit.getCourseCode());
 
Element courseUnitCode = DocumentFactory.getInstance().createElement("courseUnitCode");
 
courseUnitCode.setText("" + courseUnit.getCode());
 
if(courseUnit.getResponsableTeacher()!=null)
{
Teacher s = courseUnit.getResponsableTeacher();
Element responsavel = DocumentFactory.getInstance().createElement("responsavel");
responsavel.addAttribute("code",""+s.getSigesCode());
responsavel.addAttribute("name",""+s.getName());
responsavel.addAttribute("email",""+s.getEmail());
rootElement.add(responsavel);
}
 
rootElement.add(saveDate);
rootElement.add(name);
rootElement.add(courseUnitCode);
rootElement.add(courseName);
rootElement.add(courseCode);
 
if(courseUnit.getObjectives() != null)
{
65,7 → 90,8
rootElement.add(objectives);
}
 
if(courseUnit.getSummaries() != null)
/* use json now
if(courseUnit.getSummaries() != null)
{
Element summaries = DocumentFactory.getInstance().createElement("summaries");
summaries.addAttribute("number",""+courseUnit.getSummaries().size());
91,6 → 117,48
summary.add(titulo);
}
}
}*/
if(courseUnit.getSummariesJson() != null)
{
//Element summaries = DocumentFactory.getInstance().createElement("summaries");
try {
JSONObject obj = new JSONObject(courseUnit.getSummariesJson());
int number = ((JSONArray)obj.get("summary")).length();
String xml = XML.toString(obj);
//SAXReader reader = new SAXReader();
//Document domSumsJson = reader.read(new InputSource(new StringReader(xml)));
 
//org.w3c.dom.Element summaries = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xml))).getDocumentElement();
Element summaries = Dom4jUtil.parse("<summaries>" + xml + "</summaries>").getRootElement();
summaries.addAttribute("number",""+number);
//domSumsJson.getRootElement();
rootElement.add(summaries);
} catch (Throwable e) {
e.printStackTrace();
}
 
/* rootElement.add(summaries);
for(CourseUnitSummary a: courseUnit.getSummaries())
{
Element summary = DocumentFactory.getInstance().createElement("summary");
summaries.add(summary);
summary.addAttribute("id",""+a.getId());
summary.addAttribute("number",""+a.getNumeroAula());
summary.addAttribute("dateAula",""+a.getDataAula());
summary.addAttribute("studentsPresences",""+a.getAlunosPresentes());
if(a.getDescricao() != null)
{
Element text = DocumentFactory.getInstance().createElement("description");
text.setText(a.getDescricao());
summary.add(text);
}
if(a.getTitulo() != null)
{
Element titulo = DocumentFactory.getInstance().createElement("title");
titulo.setText(a.getTitulo());
summary.add(titulo);
}
}*/
}
 
if(courseUnit.getTeachers() != null)
104,7 → 172,7
teacher.addAttribute("code",""+s.getSigesCode());
teacher.addAttribute("name",""+s.getName());
teacher.addAttribute("email",""+s.getEmail());
if( userSession.getUser().isSuperuserOrAdmin() || userSession.getUser() instanceof Teacher)
if(userSession != null && (userSession.getUser().isSuperuserOrAdmin() || userSession.getUser() instanceof Teacher))
{
teacher.addAttribute("oemail",""+s.getOutEmail());
teacher.addAttribute("phone",""+s.getPhonenumber());
116,7 → 184,7
}
}
 
if( userSession.getUser().isSuperuserOrAdmin() || userSession.getUser() instanceof Teacher)
if(userSession != null && ( userSession.getUser().isSuperuserOrAdmin() || userSession.getUser() instanceof Teacher))
{
if(courseUnit.getStudents() != null)
{
138,7 → 206,7
}
}
}
if( userSession.getUser().isSuperuserOrAdmin() || userSession.getUser() instanceof Teacher)
if(userSession != null && ( userSession.getUser().isSuperuserOrAdmin() || userSession.getUser() instanceof Teacher))
{
if(courseUnit.getAnnouncements() != null)
{
168,7 → 236,7
}
}
 
if( userSession.getUser().isSuperuserOrAdmin() || userSession.getUser() instanceof Teacher)
if(userSession != null && ( userSession.getUser().isSuperuserOrAdmin() || userSession.getUser() instanceof Teacher))
{
if(courseUnit.getBlogs() != null)
{
213,4 → 281,60
}
return dom;
}
 
public static void main(String[] args) throws IOException, TransformerException, FOPException {
/*AbstractDao.getCurrentSession().beginTransaction();
 
CourseUnit c = CourseUnitDao.getInstance().load(new Long(4136));
 
 
String path = generatePdf(c);
AbstractDao.getCurrentSession().getTransaction().commit();
sendPdfFtpIonline(c,new ArrayList<String>(),null,path,null);
*/
 
 
}
 
/*
public static String generatePdf(CourseUnit c) throws IOException, TransformerException, FOPException {
Document dom = new CreateCourseUnitXML().run(c,null);
org.w3c.dom.Document dd = Dom4jUtil.toW3c(dom);
String path = Globals.TMP_DIR + File.separator + c.getCode() + "-" + c.getNormalizedName() + "-sumarios.pdf";
FileOutputStream out = new FileOutputStream(path);
Map<String,Object> params = new HashMap<String,Object>();
params.put("site", Globals.SITE_URL);
PdfUtils.createPdfFromXml(new DOMSource(dd), "pt/estgp/estgweb/services/courseunits/courseunitsummaries.fo.xsl", out, params);
out.flush();
out.close();
return path;
}
 
private static void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,String pdfPath,FTPClient client) throws IOException, TransformerException, FOPException {
 
FtpServer server = null;
if(client == null)
{
server = FtpServer.getNewServer(Globals.FTP_IONLINE_URL,Globals.FTP_IONLINE_USER,Globals.FTP_IONLINE_PASS);
client = server.getClient();
}
client.setFileType(FTP.BINARY_FILE_TYPE);
 
String pastaFichaCurricular = Globals.FTP_IONLINE_START_PATH + cu.getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_Sumarios;
if(!client.changeWorkingDirectory(pastaFichaCurricular))
{
logger.error("FTP CANT CHANGE TO PATH: " + pastaFichaCurricular);
}
else
{
client.storeFile(cu.getCode() + "_" + cu.getNormalizedName() + "_sumarios.pdf",new FileInputStream(pdfPath));
 
if(server != null)
{
client.quit();
client.disconnect();
}
}
//
}*/
}
/impl/src/java/pt/estgp/estgweb/services/courseunits/SaveCourseUnitProgram.java
1,12 → 1,17
package pt.estgp.estgweb.services.courseunits;
 
import jomm.dao.impl.AbstractDao;
import jomm.utils.PdfUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.fop.apps.FOPException;
import org.apache.log4j.Logger;
import org.dom4j.*;
import org.hibernate.Query;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.dao.impl.CourseUnitDaoImpl;
import pt.estgp.estgweb.domain.views.CourseUnitProgramView;
import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum;
import pt.estgp.estgweb.services.data.RepositoryService;
14,6 → 19,7
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.utils.Dom4jUtil;
import pt.estgp.estgweb.utils.StringsUtils;
import pt.estgp.estgweb.web.FtpServer;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import javax.xml.transform.TransformerException;
23,10 → 29,7
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
 
/*
* @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
110,10 → 113,100
public void createPdf(CourseUnit cu, List<String> errors) throws IOException, TransformerException, FOPException {
createPdf(cu,errors,null);
}
 
public void createPdf(CourseUnit cu, List<String> errors,UserSession u) throws IOException, TransformerException, FOPException {
 
((CourseUnitProgramImpl)cu.getCourseUnitProgram()).consistNullValues();
 
String path = generatePdfFile(cu, errors, u);
 
 
 
RepositoryService repositoryService = new RepositoryService();
User owner;
if(cu.getTeachers() != null && cu.getTeachers().size() > 0)
owner = cu.getTeachers().iterator().next();
else
owner = DaoFactory.getUserDaoImpl().load(new Long(1));
if(owner.getUsername() == null)
{
errors.add("Docente: " + owner.getName() + " ( " + owner.getId() + " ) don't have username check that situation");
// owner.setUsername("UKNOWN");
}
if(cu.getProgramStreamId() == null)
{
String identifier = repositoryService.storeRepositoryFile(new FileInputStream(path), "application/pdf", "pdf",((int) new File(path).length()), cu.getCode() + ".pdf", "courseunit.program.description" + cu.getName(), ResourceAccessControlEnum.publicDomain,owner);
cu.setProgramStreamId(identifier);
}
else
{
repositoryService.updateRepositoryFile(cu.getProgramStreamId(), new FileInputStream(path), "application/pdf", "pdf", ((int)new File(path).length()),cu.getCode() + ".pdf", "courseunit.program.description " + cu.getName(), ResourceAccessControlEnum.publicDomain);
}
cu.setObjectives(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getObjectivos());
//Obrigar a ser falso
 
//NOVO
RepositoryFileImpl repoFile = repositoryService.loadView(cu.getProgramStreamId());
sendPdfFtpIonline(cu,errors,u,path,repoFile.getLastVersion().getSaveDate(),null);
}
 
 
public boolean sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u, FTPClient client) throws IOException, TransformerException, FOPException
{
RepositoryService repositoryService = new RepositoryService();
if(cu.getProgramStreamId() != null && cu.getProgramStreamId().length()> 0)
{
RepositoryFileImpl repoFile = repositoryService.loadView(cu.getProgramStreamId());
String path = generatePdfFile(cu, errors, u);
sendPdfFtpIonline(cu,errors,u,path,repoFile.getLastVersion().getSaveDate(),client);
return true;
}
return false;
}
 
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd.HH_mm_ss");
private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,String pdfPath,Date versionDate,FTPClient client) throws IOException, TransformerException, FOPException {
 
FtpServer server = null;
if(client == null)
{
server = FtpServer.getNewServer(Globals.FTP_IONLINE_URL,Globals.FTP_IONLINE_USER,Globals.FTP_IONLINE_PASS);
client = server.getClient();
if(client == null)
{
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP - could be FTPTimeout: " + Globals.FTP_TIMEOUT_SECONDS);
errors.add("################### > CANT CONNECT FTP to send program " + ((CourseUnitImpl)cu).getSigesUniqueIdentifiers());
return;
}
}
client.setFileType(FTP.BINARY_FILE_TYPE);
 
String pastaFichaCurricular = Globals.FTP_IONLINE_START_PATH + cu.getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_FichaCurricular;
if(!client.changeWorkingDirectory(pastaFichaCurricular))
{
logger.error("FTP CANT CHANGE TO PATH: " + pastaFichaCurricular);
}
else
{
if(!client.storeFile(cu.getCode() + "_" + cu.getNormalizedName() + "_v" + sdf.format(versionDate) + ".pdf",new FileInputStream(pdfPath)))
{
errors.add("CANT store file in given time, probably timeout at " + Globals.FTP_DATA_STORE_TIMEOUT_SECONDS);
}
 
if(server != null)
{
client.quit();
client.disconnect();
}
}
//
}
 
private String generatePdfFile(CourseUnit cu, List<String> errors, UserSession u) throws TransformerException, IOException, FOPException {
 
CourseUnitProgramImpl cProgram = (CourseUnitProgramImpl) DaoFactory.getCourseUnitProgramDaoImpl().narrow(cu.getCourseUnitProgram());
cProgram.consistNullValues();
 
Document responseDoc = DocumentHelper.createDocument();
Namespace namespace = new Namespace("uc", "http://baco.estgp.pt/schemas/courseunits/program/");
responseDoc.setXMLEncoding("ISO-8859-1");
174,7 → 267,6
}
 
 
 
Element apresentacaoObjectivos = curriculum.addElement(new QName("objetivosDaAprendizagem",namespace));
apresentacaoObjectivos.setText(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getObjectivos());
 
290,18 → 382,11
cargaHorariaTotal.setText(cu.getCourseUnitProgram().getCargaHorariaTotal());
 
 
 
 
 
 
 
 
 
// Dom4jUtil.writeSout(responseDoc);
 
 
String path = Globals.TMP_DIR + File.separator + cu.getCode() + "-" + cu.getName() + ".pdf";
FileOutputStream teste = new FileOutputStream(path);
String path = Globals.TMP_DIR + File.separator + cu.getCode() + "-" + cu.getNormalizedName() + ".pdf";
FileOutputStream out = new FileOutputStream(path);
Map<String,Object> params = new HashMap<String,Object>();
params.put("site", Globals.SITE_URL);
if(cu.isValidProgram())
314,34 → 399,62
 
org.w3c.dom.Document dd = Dom4jUtil.toW3c(responseDoc);
 
PdfUtils.createPdfFromXml(new DOMSource(dd), "pt/estgp/estgweb/services/courseunits/courseunitprogram.fo.xsl", teste,params);
teste.flush();
teste.close();
PdfUtils.createPdfFromXml(new DOMSource(dd), "pt/estgp/estgweb/services/courseunits/courseunitprogram.fo.xsl", out, params);
out.flush();
out.close();
return path;
}
 
 
RepositoryService repositoryService = new RepositoryService();
User owner;
if(cu.getTeachers() != null && cu.getTeachers().size() > 0)
owner = cu.getTeachers().iterator().next();
else
owner = DaoFactory.getUserDaoImpl().load(new Long(1));
if(owner.getUsername() == null)
public void storeAllPrograms() throws IOException {
CourseUnitDaoImpl dao = DaoFactory.getCourseUnitDaoImpl();
Query q = AbstractDao.getCurrentSession().createQuery("select c from c in class " + CourseUnit.class.getName() + " where c.importYear = ?");
q.setString(0,DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
Iterator<CourseUnit> cuIter = q.iterate();
FtpServer server = FtpServer.getNewServer(Globals.FTP_IONLINE_URL,Globals.FTP_IONLINE_USER,Globals.FTP_IONLINE_PASS);
FTPClient client = server.getClient();
if(client == null)
{
errors.add("Docente: " + owner.getName() + " ( " + owner.getId() + " ) don't have username check that situation");
// owner.setUsername("UKNOWN");
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP");
return;
}
if(cu.getProgramStreamId() == null)
{
String identifier = repositoryService.storeRepositoryFile(new FileInputStream(path), "application/pdf", "pdf",((int) new File(path).length()), cu.getCode() + ".pdf", "courseunit.program.description" + cu.getName(), ResourceAccessControlEnum.publicDomain,owner);
cu.setProgramStreamId(identifier);
while (cuIter.hasNext()) {
CourseUnit next = cuIter.next();
 
try {
List<String> errors = new ArrayList<String>();
System.out.print("Sending " + next.getCourse().getName() + " - " + next.getSemestre() + " - " + next.getNormalizedName());
if(sendPdfFtpIonline(next,errors,null,client))
System.out.print(" ... OK");
else
System.out.print(" ... FAIL probably no StreamID");
System.out.print("\n");
if(errors.size()>0)
for(String error:errors)
logger.warn(error);
} catch (IOException e) {
logger.error(e,e);
} catch (TransformerException e) {
logger.error(e, e);
} catch (FOPException e) {
e.printStackTrace();
}
 
AbstractDao.getCurrentSession().evict(next);
}
else
{
repositoryService.updateRepositoryFile(cu.getProgramStreamId(), new FileInputStream(path), "application/pdf", "pdf", ((int)new File(path).length()),cu.getCode() + ".pdf", "courseunit.program.description " + cu.getName(), ResourceAccessControlEnum.publicDomain);
client.quit();
client.disconnect();
 
}
 
 
public static void main(String[] args) throws IOException {
 
AbstractDao.getCurrentSession().beginTransaction();
new SaveCourseUnitProgram().storeAllPrograms();
AbstractDao.getCurrentSession().flush();
AbstractDao.getCurrentSession().getTransaction().commit();
}
cu.setObjectives(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getObjectivos());
//Obrigar a ser falso
 
 
}
}
/impl/src/java/pt/estgp/estgweb/services/courseunits/SaveCourseUnitEvaluation.java
New file
0,0 → 1,290
package pt.estgp.estgweb.services.courseunits;
 
import jomm.utils.PdfUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.fop.apps.FOPException;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.CourseUnitEvaluationView;
import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum;
import pt.estgp.estgweb.services.data.RepositoryService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.utils.Dom4jUtil;
import pt.estgp.estgweb.web.FtpServer;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
 
/*
* @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
*
*
* Created at 17/Out/2003 , 23:45:24
*
*/
 
/**
* @author Jorge Machado
*
*
* So pode editar a avaliação da unidade o docente da unidade
* É gerado um PDF a cada gravação do Ficheiro
*
* Created at 17/Out/2003 , 23:45:24
*
*/
public class SaveCourseUnitEvaluation implements IService
{
private static final Logger logger = Logger.getLogger(SaveCourseUnitEvaluation.class);
 
RepositoryService repositoryService = new RepositoryService();
 
public CourseUnitEvaluationView save(CourseUnitEvaluationView cupv, Long coursUnitId, UserSession usession) throws ServiceException, TransformerException, IOException, FOPException {
 
CourseUnit c = DaoFactory.getCourseUnitDaoImpl().get(coursUnitId);
 
 
CourseUnitEvaluation evaluation = c.getCourseUnitEvaluation();
if(evaluation == null)
{
evaluation = new CourseUnitEvaluationImpl();
DaoFactory.getCourseUnitEvaluationDaoImpl().save(evaluation);
c.setCourseUnitEvaluation(evaluation);
cupv.setCourseUnitEvaluation(evaluation);
}
//
 
if(usession.getUser() instanceof Teacher &&
((((Teacher)(usession.getUser())).isTeacherOfCourseUnit(c.getId(),true))
||
(c.getResponsableTeacher()!=null && usession.getUser().getId() == c.getResponsableTeacher().getId())
))
{
cupv.persistViewInObjectTeacher(evaluation);
cupv.setCourseUnitEvaluation(evaluation);
}
if(usession.getUser() instanceof Teacher
&& (((usession.getUser())).hasRole(c.getCourse().getValidationRole())
||
((usession.getUser()) == c.getCourse().getCoordinator()))
)
{
cupv.persistViewInObjectTeacher(evaluation);
cupv.setCourseUnitEvaluation(evaluation);
}
List<String> errors = new ArrayList<String>();
String estado = "POR ENTREGAR";
if(cupv.isFechar())
{
evaluation.setClosed(true);
evaluation.setTeacherComplete(true);
estado = "Aceite pela Comissão de Curso";
}
else if(cupv.isTeacherComplete())
{
estado = "Entregue à Comissão de Curso pelo docente";
evaluation.setTeacherComplete(true);
}
else
{
estado = "Alterado pelo docente";
evaluation.setClosed(false);
//TODO novo
evaluation.setTeacherComplete(false);
}
 
 
 
createPdf(evaluation,c,usession,errors);
if(usession != null && usession.getUser() != null && usession.getUser() instanceof Teacher)
DirectedCoordinatedUnitsService.sendNotificationsCourseUnitEvaluationEditedInterestedPeople(c, estado, usession);
else
{
logger.info("Nao vai informar docentes");
}
return cupv;
}
 
public CourseUnitEvaluationView open(Long coursUnitId, UserSession usession) throws ServiceException {
 
CourseUnit c = DaoFactory.getCourseUnitDaoImpl().get(coursUnitId);
CourseUnitEvaluation evaluation = c.getCourseUnitEvaluation();
if(usession.getUser() instanceof Teacher &&
(((Teacher)usession.getUser()).isTeacherOfCourseUnit(c.getId(),true)
||
c.getResponsableTeacher()!=null && usession.getUser().getId() == c.getResponsableTeacher().getId()
||
usession.getUser().hasRole(c.getCourse().getValidationRole())
||
((usession.getUser()) == c.getCourse().getCoordinator())
))
{
evaluation.setClosed(false);
evaluation.setTeacherComplete(false);
}
CourseUnitEvaluationView cupv = new CourseUnitEvaluationView(evaluation);
if(usession != null && usession.getUser() != null && usession.getUser() instanceof Teacher)
DirectedCoordinatedUnitsService.sendNotificationsCourseUnitEvaluationEditedInterestedPeople(c, "Aberto pela Comissão de Curso", usession);
 
return cupv;
}
 
//TODO TEACHER COMPLETE OPEN not in use coordinatores open and close every fields
public CourseUnitEvaluationView setTeacherIncomplete(Long coursUnitId, UserSession usession) throws ServiceException {
 
CourseUnit c = DaoFactory.getCourseUnitDaoImpl().get(coursUnitId);
CourseUnitEvaluation evaluation = c.getCourseUnitEvaluation();
//So responsaveis e profs desdemente que a avaliação nao esteja fechada
//caso contrario so coordenadores
boolean isTeacherOfCourseUnitAndEvaluationNotClosed =
usession.getUser() instanceof Teacher
&&
(
((Teacher)usession.getUser()).isTeacherOfCourseUnit(c.getId(),true)
||
c.getResponsableTeacher()!=null && usession.getUser().getId() == c.getResponsableTeacher().getId()
)
&& !evaluation.isClosed();
 
boolean isCoordinatorOrCourseCommission =
usession.getUser() instanceof Teacher
&&
(
usession.getUser().hasRole(c.getCourse().getValidationRole())
||
((usession.getUser()) == c.getCourse().getCoordinator())
);
 
 
if(isTeacherOfCourseUnitAndEvaluationNotClosed || isCoordinatorOrCourseCommission)
{
evaluation.setTeacherComplete(false);
}
CourseUnitEvaluationView cupv = new CourseUnitEvaluationView(evaluation);
return cupv;
}
 
public void createPdf(CourseUnitEvaluation cuv, CourseUnit cu, UserSession userSession,List<String> errors) throws IOException, TransformerException, FOPException {
 
 
String path = generatePdf(cuv, cu);
 
 
 
RepositoryService repositoryService = new RepositoryService();
User owner = userSession.getUser();
 
if(cu.getEvaluationStreamId() == null)
{
String identifier = repositoryService.storeRepositoryFile(new FileInputStream(path), "application/pdf", "pdf",((int) new File(path).length()), cu.getCode() + "-evaluation.pdf", "courseunit.evaluation.description" + cu.getName(), ResourceAccessControlEnum.courseunitEvaluationDomain,owner);
cu.setEvaluationStreamId(identifier);
}
else
{
repositoryService.updateRepositoryFile(cu.getEvaluationStreamId(), new FileInputStream(path), "application/pdf", "pdf", ((int)new File(path).length()),cu.getCode() + "-evaluation.pdf", "evaluation.evaluation.description " + cu.getName(), ResourceAccessControlEnum.privateDomain);
}
 
//Obrigar a ser falso
 
//NOVO
 
/*
if(cuv.isClosed())
{
RepositoryFileImpl repoFile = repositoryService.loadView(cu.getEvaluationStreamId());
sendPdfFtpIonline(cu,errors,userSession,path,repoFile.getLastVersion().getSaveDate(),null);
}
*/
}
 
public String generatePdf(CourseUnitEvaluation cuv, CourseUnit c) throws IOException, TransformerException, FOPException {
 
CourseUnitEvaluationImpl cuvImpl = (CourseUnitEvaluationImpl) DaoFactory.getCourseUnitEvaluationDaoImpl().narrow(cuv);
Document responseDoc = cuvImpl.getDom(c);
responseDoc.setXMLEncoding("ISO-8859-1");
 
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
 
responseDoc.getRootElement().addAttribute("data", sdf.format(new java.util.Date()));
 
 
 
 
String path = Globals.TMP_DIR + File.separator + c.getCode() + "-" + c.getNormalizedName() + "-eval.pdf";
 
FileOutputStream out = new FileOutputStream(path);
Map<String,Object> params = new HashMap<String,Object>();
params.put("site", Globals.SITE_URL);
 
 
org.w3c.dom.Document dd = Dom4jUtil.toW3c(responseDoc);
 
PdfUtils.createPdfFromXml(new DOMSource(dd), "pt/estgp/estgweb/services/courseunits/courseunitevaluation.fo.xsl", out, params);
out.flush();
out.close();
return path;
}
 
 
 
/* public boolean sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u, FTPClient client) throws IOException, TransformerException, FOPException
{
RepositoryService repositoryService = new RepositoryService();
if(cu.getProgramStreamId() != null && cu.getProgramStreamId().length()> 0)
{
RepositoryFileImpl repoFile = repositoryService.loadView(cu.getProgramStreamId());
String path = generatePdfFile(cu, errors, u);
sendPdfFtpIonline(cu,errors,u,path,repoFile.getLastVersion().getSaveDate(),client);
return true;
}
return false;
}*/
 
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd.HH_mm_ss");
private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,String pdfPath,Date versionDate,FTPClient client) throws IOException, TransformerException, FOPException {
 
FtpServer server = null;
if(client == null)
{
server = FtpServer.getNewServer(Globals.FTP_IONLINE_URL,Globals.FTP_IONLINE_USER,Globals.FTP_IONLINE_PASS);
client = server.getClient();
if(client == null)
{
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP");
return;
}
}
client.setFileType(FTP.BINARY_FILE_TYPE);
 
String pastaFichaCurricular = Globals.FTP_IONLINE_START_PATH + cu.getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_FichaAvaliacao;
if(!client.changeWorkingDirectory(pastaFichaCurricular))
{
logger.error("FTP CANT CHANGE TO PATH: " + pastaFichaCurricular);
}
else
{
client.storeFile(cu.getCode() + "_" + cu.getNormalizedName() + "_v" + sdf.format(versionDate) + ".pdf",new FileInputStream(pdfPath));
 
if(server != null)
{
client.quit();
client.disconnect();
}
}
//
}
 
}
/impl/src/java/pt/estgp/estgweb/services/courseunits/courseunitsummaries.fo.xsl
New file
0,0 → 1,336
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uc="http://baco.estgp.pt/schemas/courseunits/program/">
<xsl:param name="site">http://localhost/bacoTESTE</xsl:param>
<xsl:param name="revisor">automático</xsl:param>
<xsl:param name="validadoCC">false</xsl:param>
 
 
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4VerticalFirst" page-width="210mm" page-height="297mm"
margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm"
reference-orientation="0">
<fo:region-body region-name="body" margin-top="20mm" margin-bottom="10mm" margin-right="0"
margin-left="0"/>
<fo:region-before region-name="header" extent="15mm"/>
<fo:region-after region-name="footer" extent="1cm"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="A4VerticalOther" page-width="210mm" page-height="297mm"
margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm"
reference-orientation="0">
<fo:region-body region-name="body" margin-top="20mm" margin-bottom="10mm" margin-right="0"
margin-left="0"/>
<fo:region-after region-name="footer" extent="1cm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="paginas">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference page-position="first" master-reference="A4VerticalFirst"/>
<fo:conditional-page-master-reference master-reference="A4VerticalOther"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
 
</fo:layout-master-set>
 
<!--LAYOUT DE PAGINA ESCOLHIDO-->
<fo:page-sequence master-reference="paginas" >
<xsl:call-template name="page"/>
</fo:page-sequence>
 
 
</fo:root>
</xsl:template>
 
 
<xsl:template name="page">
<fo:static-content flow-name="header">
 
<fo:block text-align="left" >
<fo:table width="100%" table-layout="fixed" border-bottom="1px solid black" margin-bottom="5pt">
<fo:table-column column-width="100%"/>
 
 
<fo:table-body>
<fo:table-row>
<fo:table-cell >
<fo:block>
<fo:external-graphic height="auto" width="auto"
content-height="30">
<!--<xsl:attribute name="src">url('http://www.ipportalegre.pt/imagens/Logos/ESTG/Logotipo%20ESTG.jpg')</xsl:attribute>-->
<xsl:attribute name="src">url('<xsl:value-of select="$site"/>/imgs/logoestg.gif')</xsl:attribute>
</fo:external-graphic>
</fo:block>
<fo:block font-size="16pt">
Sumários Lançados <xsl:value-of select="//anoLectivo"/>
</fo:block>
 
</fo:table-cell>
 
</fo:table-row>
 
</fo:table-body>
</fo:table>
 
</fo:block>
 
 
</fo:static-content>
<fo:static-content flow-name="footer">
 
<fo:table width="100%" table-layout="fixed" border-top="1px solid black" font-size="6.5pt" >
<fo:table-column column-width="20%"/>
<fo:table-column column-width="80%" />
 
 
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-top="3pt">
<fo:block >
Revisto a <xsl:value-of select="//updateDate"/> por <xsl:value-of select="$revisor"/> / Página <fo:page-number/>
</fo:block>
<fo:block font-size="5pt">
ESTG.SA.xxxx.1
</fo:block>
 
</fo:table-cell>
<fo:table-cell padding-top="3pt" >
<fo:block font-size="6pt" text-align="right">
http://www.estgp.pt | gerado pela plataforma baco® 2015
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
 
<fo:flow flow-name="body">
<fo:block>
<xsl:apply-templates select="/courseUnit"/>
</fo:block>
</fo:flow>
</xsl:template>
 
<xsl:template match="/courseUnit">
 
<fo:table table-layout="fixed" border="0px solid black" margin="0.5em" font-size="8.5pt">
<xsl:call-template name="gen_cols"/>
<fo:table-body text-align="left">
 
<xsl:call-template name="gen_header"/>
 
<xsl:call-template name="gen_line"/>
 
</fo:table-body>
</fo:table>
</xsl:template>
 
<xsl:template name="gen_cols">
<fo:table-column column-width="15em" />
<fo:table-column/>
</xsl:template>
 
 
 
 
<xsl:template name="gen_header">
 
</xsl:template>
 
 
 
 
 
 
 
 
<xsl:attribute-set name="myBorder">
<xsl:attribute name="border">solid 0.2mm black</xsl:attribute>
</xsl:attribute-set>
 
<xsl:template name="gen_line">
 
<fo:table-row background-color="#FFF" color="#000" padding="0">
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Ano Lectivo
</fo:block>
</fo:table-cell>
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block >
<xsl:value-of select="@importYear"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row background-color="#FFF" color="#000" padding="0">
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Curso
</fo:block>
</fo:table-cell>
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block >
<xsl:value-of select="//courseName"/> / <xsl:value-of select="//courseCode"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row background-color="#FFF" color="#000" padding="0">
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Unidade Curricular
</fo:block>
</fo:table-cell>
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block >
<xsl:value-of select="//name"/> / <xsl:value-of select="//courseUnitCode"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row background-color="#FFF" color="#000" padding="0">
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Professor Responsável
</fo:block>
</fo:table-cell>
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block >
<xsl:value-of select="//responsavel/@name"/> / <xsl:value-of select="//responsavel/@email"/>
</fo:block >
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="//teacher">
<fo:table-row background-color="#FFF" color="#000" padding="0">
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Docente
</fo:block>
</fo:table-cell>
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block >
<xsl:value-of select="./@name"/> / <xsl:value-of select="./@email"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
 
<fo:table-row background-color="#FFF" color="#000" padding="0">
 
<fo:table-cell number-columns-spanned="2" border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="left" padding="3pt" font-weight="bold">
Sumários Lançados (<xsl:value-of select="//summaries/@number"/>)
</fo:block>
</fo:table-cell>
 
 
</fo:table-row>
 
 
<xsl:if test="//summary">
<fo:table-row background-color="#FFF" color="#000" padding="0">
 
<fo:table-cell padding="0" number-columns-spanned="2" border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
 
 
<fo:table margin-top="10px" margin-bottom="5px" table-layout="fixed" border="1px solid black" >
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
 
<fo:table-body>
 
 
<xsl:for-each select="//summary">
<xsl:sort select="dataAula" case-order="lower-first"/>
<fo:table-row>
<fo:table-cell border-bottom="0.5px solid gray">
<fo:block font-size="8pt">
<xsl:value-of select="./dataAula"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border-bottom="0.5px solid gray" >
<fo:block font-size="8pt" >
Aula <xsl:value-of select="./numeroAula"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border-bottom="0.5px solid gray" >
<fo:block font-size="8pt">
<xsl:value-of select="./tipoAula"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border-bottom="0.5px solid gray">
<fo:block font-size="8pt">
<xsl:value-of select="./numeroHoras"/> Horas
</fo:block>
</fo:table-cell>
<fo:table-cell border-bottom="0.5px solid gray" >
<fo:block font-size="8pt">
<xsl:value-of select="./alunosPresentes"/> Alunos
</fo:block>
</fo:table-cell>
 
</fo:table-row>
 
<fo:table-row>
<fo:table-cell border-bottom="0.5px solid gray">
<fo:block font-size="8pt">
Titulo
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="4" border-bottom="0.5px solid gray">
<fo:block font-size="8pt">
<xsl:value-of select="./titulo"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
 
<fo:table-row>
<fo:table-cell border-bottom="1px solid gray" >
<fo:block font-size="8pt">
Descrição
</fo:block>
</fo:table-cell>
<fo:table-cell border-bottom="1px solid gray" number-columns-spanned="4">
<fo:block font-size="8pt">
<xsl:value-of select="./descricao"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
 
<fo:table-row height='20px'>
<fo:table-cell number-columns-spanned="5" >
<fo:block ></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:table-cell>
</fo:table-row>
</xsl:if>
 
<!--
 
<fo:table-cell border-bottom="1px solid gray" padding="0" padding-top="5px" padding-bottom="5px" padding-left="0mm" display-align="center">
 
 
 
 
 
</fo:table-cell>
-->
 
 
 
 
</xsl:template>
 
 
 
 
 
 
 
</xsl:stylesheet>
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/services/courseunits/courseunitprogram.fo.xsl
253,11 → 253,12
<xsl:with-param name="value"><xsl:value-of select="//uc:conteudosProgramaticos"/></xsl:with-param>
</xsl:call-template>
 
<!--<xsl:call-template name="tableGrayLine">-->
<!--<xsl:with-param name="label">Demonstração da coerência dos conteúdos programáticos com os objectivos da unidade curricular</xsl:with-param>-->
<!--<xsl:with-param name="label2"></xsl:with-param>-->
<!--<xsl:with-param name="value"><xsl:value-of select="//uc:demonstracaoCoerenciaConteudosObjectivos"/></xsl:with-param>-->
<!--</xsl:call-template>-->
<!-- Campo Novo Aprovado Luis Batista Mail de 3 de Setembro de 2015 assunto RE: Verificação conteudos - UC - CESH_TD-->
<xsl:call-template name="tableGrayLine">
<xsl:with-param name="label">Demonstração da coerência dos conteúdos programáticos com os objectivos da unidade curricular</xsl:with-param>
<xsl:with-param name="label2"></xsl:with-param>
<xsl:with-param name="value"><xsl:value-of select="//uc:demonstracaoCoerenciaConteudosObjectivos"/></xsl:with-param>
</xsl:call-template>
 
<xsl:call-template name="tableWhiteLine">
<xsl:with-param name="label">Metodologias de ensino e Aprendizagem</xsl:with-param>
265,12 → 266,14
<xsl:with-param name="value"><xsl:value-of select="//uc:metodologiasEnsino"/></xsl:with-param>
</xsl:call-template>
 
<!--<xsl:call-template name="tableGrayLine">-->
<!--<xsl:with-param name="label">Demonstração da coerência das metodologias de ensino com os objectivos da aprendizagem da unidade curricular</xsl:with-param>-->
<!--<xsl:with-param name="label2"></xsl:with-param>-->
<!--<xsl:with-param name="value"><xsl:value-of select="//uc:demonstracaoDaCoerenciaMetodologiasObjectivos"/></xsl:with-param>-->
<!--</xsl:call-template>-->
<!-- Campo Novo Aprovado Luis Batista Mail de 3 de Setembro de 2015 assunto RE: Verificação conteudos - UC - CESH_TD-->
 
<xsl:call-template name="tableGrayLine">
<xsl:with-param name="label">Demonstração da coerência das metodologias de ensino com os objectivos da aprendizagem da unidade curricular</xsl:with-param>
<xsl:with-param name="label2"></xsl:with-param>
<xsl:with-param name="value"><xsl:value-of select="//uc:demonstracaoDaCoerenciaMetodologiasObjectivos"/></xsl:with-param>
</xsl:call-template>
 
<xsl:call-template name="tableWhiteLine">
<xsl:with-param name="label">Língua de ensino</xsl:with-param>
<xsl:with-param name="label2"></xsl:with-param>
/impl/src/java/pt/estgp/estgweb/services/courseunits/CreateCourseUnitWorksBackupService.java
44,13 → 44,13
 
public String createSystemActualYearBackup(String importYear, UserSession userSession) throws ServiceException
{
return createSystemImportYearBackup(DatesUtils.getImportYear(),userSession);
return createSystemImportYearBackup(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(),userSession);
}
 
public String createSystemImportYearBackup(String importYear, UserSession userSession) throws ServiceException
{
if (importYear == null || importYear.trim().length() == 0)
importYear = DatesUtils.getImportYear();
importYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
String tmpName = BytesUtils.generateHexKey();
String tmpDir = Globals.TMP_DIR + "/" + tmpName;
new File(tmpDir).mkdirs();
155,7 → 155,7
public String createImportYearBackup(String importYear, UserSession userSession) throws ServiceException
{
if(importYear == null)
importYear = DatesUtils.getImportYear();
importYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
if (userSession.getUser() instanceof Teacher)
return createLoginTeacherActualYearBackup(importYear,userSession);
else if (userSession.getUser() instanceof Student)
172,9 → 172,9
public String createActualYearBackup(UserSession userSession) throws ServiceException
{
if (userSession.getUser() instanceof Teacher)
return createLoginTeacherActualYearBackup(DatesUtils.getImportYear(),userSession);
return createLoginTeacherActualYearBackup(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(),userSession);
else if (userSession.getUser() instanceof Student)
return createLoginStudentActualYearBackup(DatesUtils.getImportYear(), userSession);
return createLoginStudentActualYearBackup(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(), userSession);
return null;
}
 
281,7 → 281,7
 
private String createTeacherActualYearBackup(Teacher t,String importYear, UserSession userSession) throws ServiceException
{
List units = DaoFactory.getCourseUnitDaoImpl().loadTeachedImportYearUnits(t.getId(), DatesUtils.getImportYear());
List units = DaoFactory.getCourseUnitDaoImpl().loadTeachedImportYearUnits(t.getId(), DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
if (units == null || units.size() == 0)
return null;
return createTeacherBackup(units, t, userSession);
/impl/src/java/pt/estgp/estgweb/services/courseunits/LoadCourseUnitService.java
42,10 → 42,12
public CourseUnitView run(long id, boolean initTeachers, boolean initStudents, boolean initBlog, UserSession userSession) throws ServiceException
{
CourseUnit c = DaoFactory.getCourseUnitDaoImpl().get(id);
c.setCourseUnitEvaluation(DaoFactory.getCourseUnitEvaluationDaoImpl().narrow(c.getCourseUnitEvaluation()));
c.setCourseUnitProgram(DaoFactory.getCourseUnitProgramDaoImpl().narrow(c.getCourseUnitProgram()));
 
 
if(c == null)
return null;
 
CourseUnitView cV = new CourseUnitView(c,initTeachers,initStudents,initBlog);
 
if(c.getProgramStreamId()!= null)
/impl/src/java/pt/estgp/estgweb/services/courseunits/LoadSubscribedUnitsAnnouncementsService.java
1,19 → 1,18
package pt.estgp.estgweb.services.courseunits;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.Announcement;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.Student;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.Announcement;
import pt.estgp.estgweb.domain.views.AnnouncementView;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.AnnouncementView;
import pt.estgp.estgweb.services.courseunits.impl.DefaultCourseUnitAnnouncements;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.Set;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
 
/**
* @author Jorge Machado
36,7 → 35,7
else if(semestreModerate == DatesUtils.SemestreModerate.S2)
semestre = "S2";
 
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadSubscribedImportYearSemestreUnits(t.getId(), DatesUtils.getImportYear(),semestre);
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadSubscribedImportYearSemestreUnits(t.getId(), DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(),semestre);
 
if(units == null)
return courseUnitAnnouncementsLst;
/impl/src/java/pt/estgp/estgweb/services/courseunits/LoadSubscribedUnitsOldYearsService.java
1,10 → 1,8
package pt.estgp.estgweb.services.courseunits;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.Student;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.List;
 
18,7 → 16,7
public List<CourseUnit> run(long studentId)
{
// Student t = DaoFactory.getStudentDaoImpl().load(studentId);
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadSubscribedOtherImportYearUnits(studentId, DatesUtils.getImportYear());
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadSubscribedOtherImportYearUnits(studentId, DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
for(CourseUnit c: units)
{
c.getName();
/impl/src/java/pt/estgp/estgweb/services/courseunits/ScheduleCourseUnitAnnouncementSmsService.java
41,7 → 41,7
public String run(String importYear, UserSession userSession) throws ServiceException
{
if(importYear == null || importYear.trim().length() == 0)
importYear = DatesUtils.getImportYear();
importYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
String importYearIntranet = DatesUtils.getImportYearIntranet();
String tmpName = BytesUtils.generateHexKey();
String tmpDir = Globals.TMP_DIR + "/" + tmpName;
/impl/src/java/pt/estgp/estgweb/services/courseunits/LoadTeachedUnitsAnnouncementsService.java
1,16 → 1,18
package pt.estgp.estgweb.services.courseunits;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.Announcement;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.Teacher;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.AnnouncementView;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.courseunits.impl.DefaultCourseUnitAnnouncements;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
 
/**
* @author Jorge Machado
34,7 → 36,7
else if(semestreModerate == DatesUtils.SemestreModerate.S2)
semestre = "S2";
 
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadTeachedImportYearSemestreUnits(t.getId(), DatesUtils.getImportYear(),semestre);
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadTeachedImportYearSemestreUnits(t.getId(), DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(),semestre);
 
 
if(units == null)
/impl/src/java/pt/estgp/estgweb/services/courseunits/CourseUnitsCommonServices.java
1,17 → 1,16
package pt.estgp.estgweb.services.courseunits;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.common.*;
import pt.estgp.estgweb.services.common.impl.DefaultSearchResults;
import pt.estgp.estgweb.services.common.impl.DefaultResult;
import pt.estgp.estgweb.services.common.impl.DefaultSearchResults;
import pt.estgp.estgweb.services.common.impl.DefaultToDo;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import org.apache.log4j.Logger;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
 
/*
* @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
90,7 → 89,7
if(userSession.getUser() != null && userSession.getUser() instanceof Teacher)
{
// HashMap<Long,Long> doneProgramCodes = new HashMap<Long,Long>();
List<CourseUnit> courseUnits = DaoFactory.getCourseUnitDaoImpl().loadMissingObjectivesOrPrograms(userSession.getUser().getId());
/*List<CourseUnit> courseUnits = DaoFactory.getCourseUnitDaoImpl().loadMissingObjectivesOrPrograms(userSession.getUser().getId());
for(CourseUnit c: courseUnits)
{
DefaultToDo defaultToDo = new DefaultToDo(c.getName(),null,c.getCourseName(), "courseunit.program.objectives.todo","/user/startLoadCourseUnitFromHome.do?id=" + c.getId());
120,8 → 119,8
DefaultToDo defaultToDo = new DefaultToDo(c.getQuestion(),null,c.getCourseUnit().getName(), "courseunit.question.todo","/user/startLoadCourseUnitFromHome.do?id=" + c.getId());
todos.add(defaultToDo);
}
*/
 
 
}
if(userSession.getUser() != null && userSession.getUser() instanceof Student)
{
/impl/src/java/pt/estgp/estgweb/services/courseunits/DirectedCoordinatedUnitsService.java
12,7 → 12,6
import pt.estgp.estgweb.services.jobs.JobScheduleService;
import pt.estgp.estgweb.utils.AreasBelongUtils;
import pt.estgp.estgweb.utils.CourseViewComparator;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.web.exceptions.NotAuthorizedException;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
39,7 → 38,7
public DirectedCoordinatedCourses loadForUser(long teacherId, String importYear, UserSession userSession)
{
if(importYear == null)
importYear = DatesUtils.getImportYear();
importYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
List<Course> directorCourses = DaoFactory.getCourseDaoImpl().loadDirectorCourses(teacherId,importYear);
List<Course> coordinatorCourses = DaoFactory.getCourseDaoImpl().loadCoordinatedCourses(teacherId,importYear);
 
95,8 → 94,15
public DirectedCoordinatedCourses loadForServices(String importYear, long courseId, String semestre, String area, TeachersSituationEnum teachersSituationEnum, UserSession userSession)
{
if(importYear == null)
importYear = DatesUtils.getImportYear();
importYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
 
DirectedCoordinatedCourses directedCoordinatedCourses;
if(courseId <= 0)
{
directedCoordinatedCourses = new DirectedCoordinatedCourses();
return directedCoordinatedCourses;
}
 
/**
* Area and Course Initialization
*/
143,7 → 149,7
courseViews.add(cV);
}
fill(courseViews, semestre, importYear, teachersSituationEnum);
DirectedCoordinatedCourses directedCoordinatedCourses = new DirectedCoordinatedCourses();
directedCoordinatedCourses = new DirectedCoordinatedCourses();
directedCoordinatedCourses.setMerge(courseViews);
directedCoordinatedCourses.setArea(area);
directedCoordinatedCourses.setCourseId(courseId);
162,20 → 168,55
cV.setCourseUnitsWithProgramNotCheckedS2(new ArrayList<CourseUnitView>());
for (CourseUnitView cUV : cV.getCourseUnits())
{
 
 
if (cUV.getProgramStreamId() == null)
if (cUV.getSemestre().equals("S1"))
{
try {
((List<CourseUnitView>)
(cV.getClass()
.getMethod("getCourseUnitsWithNoProgram" + cUV.getSemestre())
.invoke(cV)))
.add(cUV);
} catch (Throwable e) {
logger.error(e,e);
}
}
/*if (cUV.getSemestre().equals("S1"))
cV.getCourseUnitsWithNoProgramS1().add(cUV);
else
cV.getCourseUnitsWithNoProgramS2().add(cUV);
cV.getCourseUnitsWithNoProgramS2().add(cUV);*/
else if (cUV.isValidProgram())
if (cUV.getSemestre().equals("S1"))
{
try {
((List<CourseUnitView>)
(cV.getClass()
.getMethod("getCourseUnitsWithProgramChecked" + cUV.getSemestre())
.invoke(cV)))
.add(cUV);
} catch (Throwable e) {
logger.error(e,e);
}
}
/*if (cUV.getSemestre().equals("S1"))
cV.getCourseUnitsWithProgramCheckedS1().add(cUV);
else
cV.getCourseUnitsWithProgramCheckedS2().add(cUV);
else if (cUV.getSemestre().equals("S1"))
cV.getCourseUnitsWithProgramCheckedS2().add(cUV);*/
else
try {
((List<CourseUnitView>)
(cV.getClass()
.getMethod("getCourseUnitsWithProgramNotChecked" + cUV.getSemestre())
.invoke(cV)))
.add(cUV);
} catch (Throwable e) {
logger.error(e,e);
}
 
/*if (cUV.getSemestre().equals("S1"))
cV.getCourseUnitsWithProgramNotCheckedS1().add(cUV);
else
cV.getCourseUnitsWithProgramNotCheckedS2().add(cUV);
cV.getCourseUnitsWithProgramNotCheckedS2().add(cUV);*/
}
}
}
192,12 → 233,27
 
for (CourseView cV : courseViews)
{
cV.setCourseUnitsWithNoProgramA(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithNoProgramS1(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithNoProgramS2(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithNoProgramT1(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithNoProgramT2(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithNoProgramT3(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithNoProgramT4(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramCheckedA(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramCheckedS1(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramCheckedS2(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramCheckedT1(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramCheckedT2(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramCheckedT3(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramCheckedT4(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramNotCheckedA(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramNotCheckedS1(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramNotCheckedS2(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramNotCheckedT1(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramNotCheckedT2(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramNotCheckedT3(new ArrayList<CourseUnitView>());
cV.setCourseUnitsWithProgramNotCheckedT4(new ArrayList<CourseUnitView>());
 
 
List<CourseUnit> courseUnits = DaoFactory.getCourseUnitDaoImpl().loadCourseUnits(cV.getId(),semestre,importYear,withTeacher,withNoTeacher);
205,19 → 261,48
{
CourseUnitView cUV = new CourseUnitView(cU,true,false,false,false);
if (cUV.getProgramStreamId() == null)
if (cUV.getSemestre().equals("S1"))
try {
((List<CourseUnitView>)
(cV.getClass()
.getMethod("getCourseUnitsWithNoProgram" + cUV.getSemestre())
.invoke(cV)))
.add(cUV);
} catch (Throwable e) {
logger.error(e,e);
}
/*if (cUV.getSemestre().equals("S1"))
cV.getCourseUnitsWithNoProgramS1().add(cUV);
else
cV.getCourseUnitsWithNoProgramS2().add(cUV);
cV.getCourseUnitsWithNoProgramS2().add(cUV);*/
else if (cUV.isValidProgram())
try {
((List<CourseUnitView>)
(cV.getClass()
.getMethod("getCourseUnitsWithProgramChecked" + cUV.getSemestre())
.invoke(cV)))
.add(cUV);
} catch (Throwable e) {
logger.error(e,e);
}
/*
if (cUV.getSemestre().equals("S1"))
cV.getCourseUnitsWithProgramCheckedS1().add(cUV);
else
cV.getCourseUnitsWithProgramCheckedS2().add(cUV);
else if (cUV.getSemestre().equals("S1"))
cV.getCourseUnitsWithProgramCheckedS2().add(cUV);*/
else
try {
((List<CourseUnitView>)
(cV.getClass()
.getMethod("getCourseUnitsWithProgramNotChecked" + cUV.getSemestre())
.invoke(cV)))
.add(cUV);
} catch (Throwable e) {
logger.error(e,e);
}
/*if (cUV.getSemestre().equals("S1"))
cV.getCourseUnitsWithProgramNotCheckedS1().add(cUV);
else
cV.getCourseUnitsWithProgramNotCheckedS2().add(cUV);
cV.getCourseUnitsWithProgramNotCheckedS2().add(cUV);*/
}
}
}
235,10 → 320,20
 
if(userSession.getUser().isAdmin() || userSession.getUser().hasRole("courseValidatePrograms") || userSession.getUser().hasRole(c.getValidationRole())) //NOVO para validação por programas
{
counter+=updateList(courseView.getCourseUnitsWithProgramCheckedA(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramCheckedS1(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramCheckedS2(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramCheckedT1(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramCheckedT2(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramCheckedT3(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramCheckedT4(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramNotCheckedA(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramNotCheckedS1(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramNotCheckedS2(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramNotCheckedT1(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramNotCheckedT2(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramNotCheckedT3(),userSession);
counter+=updateList(courseView.getCourseUnitsWithProgramNotCheckedT4(),userSession);
}
}
}
264,6 → 359,7
if(courseUnit.isValidProgram() != courseUnitView.isValidProgram())
{
courseUnit.setValidProgram(courseUnitView.isValidProgram());
courseUnit.setValidatorUser(usession.getUser());
counter++;
new SaveCourseUnitProgram().createPdf(courseUnit,null,usession);
 
323,8 → 419,27
}
}
 
public static void sendNotificationsCourseUnitEvaluationEditedInterestedPeople(CourseUnit courseUnit,String estado,UserSession u)
{
try{
SendEmailService sendEmailService = new SendEmailService();
List<String> emails = getEmailJobNotifications(courseUnit);
EMAILJob emailJob = new EMAILJob(sendEmailService.getRelatorioAvaliacaoUnidadeEditadaEmail(emails,courseUnit,LangEnum.PORTUGUESE,estado));
JobScheduleService.getInstance().scheduleNow(emailJob,"New Notification EMAIL unit state changed to courseComission and teachers " ,u);
}catch(Throwable t)
{
logger.error(t,t);
}
}
 
public static List<String> getEmailJobNotifications(CourseUnit courseUnit) {
List<String> emails = DaoFactory.getCourseUnitDaoImpl().getTeachersEmails(courseUnit.getId());
 
List<String> emails = new ArrayList<String>();
for(Teacher t: courseUnit.getTeachers())
{
if(t.getEmail() != null)
emails.add(t.getEmail());
}
if(emails == null)
emails = new ArrayList<String>();
if(courseUnit.getCourse().getCoordinator() != null && courseUnit.getCourse().getCoordinator().getEmail()!=null)
/impl/src/java/pt/estgp/estgweb/services/courseunits/CreateCourseUnitDirPackageServiceBat.java
New file
0,0 → 1,412
package pt.estgp.estgweb.services.courseunits;
 
import jomm.utils.BytesUtils;
import jomm.utils.FilesUtils;
import jomm.utils.StringsUtils;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.Course;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.Teacher;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
 
/*
* @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
*
*
* Created at 17/Out/2003 , 23:45:24
*
*/
 
/**
* @author Jorge Machado
*
*
* Created at 17/Out/2003 , 23:45:24
*
*/
public class CreateCourseUnitDirPackageServiceBat implements IService
{
private static final Logger logger = Logger.getLogger(CreateCourseUnitDirPackageServiceBat.class);
 
public String run(String importYear, UserSession userSession) throws ServiceException
{
if(importYear == null || importYear.trim().length() == 0)
importYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
String importYearIntranet = DatesUtils.getImportYearIntranet(importYear);
String tmpName = BytesUtils.generateHexKey();
String tmpDir = Globals.TMP_DIR + "/" + tmpName;
new File(tmpDir).mkdirs();
//List<Course> courses = DaoFactory.getCourseDaoImpl().findAll(importYear);
List<Course> courses = DaoFactory.getCourseDaoImpl().findAll();
try
{
FileWriter batRunner = new FileWriter(tmpDir + "/create.bat");
 
String back = "";
for(Course c: courses)
{
//O curso é sempre o mesmo ID mas muda de Ano consoante o ano de importação
List<CourseUnit> courseUnits = DaoFactory.getCourseUnitDaoImpl().loadByCourse(c.getId(),importYear);
if(courseUnits == null || courseUnits.size() == 0)
{
logger.info("Skipping course: " + c.getCode() + ":" + c.getName() + " zero units in " + importYear);
}
else{
String courseNormalizedName = StringsUtils.normalizeResourceName(c.getName()) + '.' + c.getCode();
String couseDirPath = tmpDir + "/" + courseNormalizedName;
// File courseDir = new File(couseDirPath);
//courseDir.mkdirs();
try
{
 
String courseImportYearPathDos = couseDirPath + "\\" + importYearIntranet;
String courseImportYearPath = couseDirPath + "/" + importYearIntranet;
File courseImportYearDir = new File(courseImportYearPath);
//courseImportYearDir.mkdirs();
//new File(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S1).mkdirs();
//new File(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S2).mkdirs();
//new File(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_A).mkdirs();
//FilesUtils.copy(CreateCourseUnitDirPackageServiceBat.class.getResourceAsStream(Globals.INTRANET_SETUP_FILE),courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S1 + "/" + Globals.INTRANET_SETUP_FILE_NAME);
//FilesUtils.copy(CreateCourseUnitDirPackageServiceBat.class.getResourceAsStream(Globals.INTRANET_SETUP_FILE),courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S2 + "/" + Globals.INTRANET_SETUP_FILE_NAME);
//FilesUtils.copy(CreateCourseUnitDirPackageServiceBat.class.getResourceAsStream(Globals.INTRANET_SETUP_FILE),courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_A + "/" + Globals.INTRANET_SETUP_FILE_NAME);
 
 
String relativeDirCourse = courseImportYearPathDos.substring(tmpDir.length() + 1);
//String callPathS1 = (courseImportYearPathDos + "\\" + Globals.INTRANET_SEMESTRE_S1 + "\\").substring(tmpDir.length() + 1);
//String callPathS2 = (courseImportYearPathDos + "\\" + Globals.INTRANET_SEMESTRE_S2 + "\\").substring(tmpDir.length() + 1);
//String callPathA = (courseImportYearPathDos + "\\" + Globals.INTRANET_SEMESTRE_A + "\\").substring(tmpDir.length() + 1);
//batRunner.write("cd " + back + relativeDirCourse + "\\");
//back = "..\\..\\..\\";
//back = "..\\..\\";
//batRunner.write("\n");
/*batRunner.write(Globals.INTRANET_SETUP_FILE_NAME + " " + Globals.INTRANET_USERS_SETUP_FILE_NAME);
batRunner.write("\n");
batRunner.write("cd " + back + callPathS2);
batRunner.write("\n");
batRunner.write(Globals.INTRANET_SETUP_FILE_NAME + " " + Globals.INTRANET_USERS_SETUP_FILE_NAME);
batRunner.write("\n");
batRunner.write("cd " + back + callPathA);
batRunner.write("\n");
batRunner.write(Globals.INTRANET_SETUP_FILE_NAME + " " + Globals.INTRANET_USERS_SETUP_FILE_NAME);
batRunner.write("\n");*/
 
//RETIRADO
//FileWriter confWriterSemestre1 = new FileWriter(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S1 + "/" + Globals.INTRANET_USERS_SETUP_FILE_NAME);
//FileWriter confWriterSemestre2 = new FileWriter(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S2 + "/" + Globals.INTRANET_USERS_SETUP_FILE_NAME);
// FileWriter confWriterA = new FileWriter(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_A + "/" + Globals.INTRANET_USERS_SETUP_FILE_NAME);
 
boolean at = false;
boolean s1t = false;
boolean s2t = false;
boolean t1t = false;
boolean t2t = false;
boolean t3t = false;
boolean t4t = false;
 
for(CourseUnit courseUnit: courseUnits)
{
if(courseUnit.getSemestre().equals("S1"))
s1t = true;
else if(courseUnit.getSemestre().equals("S2"))
s2t = true;
else if(courseUnit.getSemestre().equals("A"))
at = true;
else if(courseUnit.getSemestre().equals("T1"))
t1t = true;
else if(courseUnit.getSemestre().equals("T2"))
t2t = true;
else if(courseUnit.getSemestre().equals("T3"))
t3t = true;
else if(courseUnit.getSemestre().equals("T4"))
t4t = true;
}
 
batRunner.write("md " + courseNormalizedName + "\\\n");
batRunner.write("md " + relativeDirCourse + "\\\n");
if(s1t)
batRunner.write("md " + relativeDirCourse + "\\" + Globals.INTRANET_SEMESTRE_S1 + "\\\n");
if(s2t)
batRunner.write("md " + relativeDirCourse + "\\" + Globals.INTRANET_SEMESTRE_S2 + "\\\n");
if(at)
batRunner.write("md " + relativeDirCourse + "\\" + Globals.INTRANET_SEMESTRE_A + "\\\n");
if(t1t)
batRunner.write("md " + relativeDirCourse + "\\" + Globals.INTRANET_SEMESTRE_T1 + "\\\n");
if(t2t)
batRunner.write("md " + relativeDirCourse + "\\" + Globals.INTRANET_SEMESTRE_T2 + "\\\n");
if(t3t)
batRunner.write("md " + relativeDirCourse + "\\" + Globals.INTRANET_SEMESTRE_T3 + "\\\n");
if(t4t)
batRunner.write("md " + relativeDirCourse + "\\" + Globals.INTRANET_SEMESTRE_T4 + "\\\n");
batRunner.write("cd " + relativeDirCourse + "\\\n");
 
//back = "..\\..\\";
//batRunner.write("\n");
 
 
// List<CourseUnit> courseUnits = DaoFactory.getCourseUnitDaoImpl().loadByCourse(c.getId(),importYear);
for(CourseUnit courseUnit: courseUnits)
{
//FileWriter nowWriter;
String semestre;
if(courseUnit.getSemestre().equals("S1"))
{
//nowWriter = confWriterSemestre1;
semestre = Globals.INTRANET_SEMESTRE_S1;
}
else if(courseUnit.getSemestre().equals("S2"))
{
//nowWriter = confWriterSemestre2;
semestre = Globals.INTRANET_SEMESTRE_S2;
}
else if(courseUnit.getSemestre().equals("T1"))
{
//nowWriter = confWriterSemestre2;
semestre = Globals.INTRANET_SEMESTRE_T1;
}
else if(courseUnit.getSemestre().equals("T2"))
{
//nowWriter = confWriterSemestre2;
semestre = Globals.INTRANET_SEMESTRE_T2;
}
else if(courseUnit.getSemestre().equals("T3"))
{
//nowWriter = confWriterSemestre2;
semestre = Globals.INTRANET_SEMESTRE_T3;
}
else if(courseUnit.getSemestre().equals("T4"))
{
//nowWriter = confWriterSemestre2;
semestre = Globals.INTRANET_SEMESTRE_T4;
}
else
{
//nowWriter = confWriterA;
semestre = Globals.INTRANET_SEMESTRE_A;
}
/*md Unidade\DTP
md Unidade\DTP\1.Planeamento
md Unidade\DTP\2.Ficha.Curricular
md Unidade\DTP\3.Sumarios
md Unidade\DTP\4.Avaliacao
md Unidade\DTP\5.Ficha.de.Avaliacao.da.Unidade.Curricular
md Unidade\DTP\6.Inquerito.Pedagogico.Unidade.Curricular
md Unidade\DTP\7.Relatorio.Final*/
 
String normalizedName = StringsUtils.normalizeResourceName(courseUnit.getName());
String unitPath = courseImportYearPath + "/" + semestre + "/" + normalizedName;
courseUnit.setNormalizedName(normalizedName);
courseUnit.setPathIntranet(unitPath.substring(tmpDir.length()));
 
String semestreUnitName = semestre + "\\" + normalizedName + "\\";
String dtpUnitFolder = semestreUnitName + Globals.INTRANET_DTP + "\\";
String conteudosUnitFolder = semestreUnitName + Globals.INTRANET_CONTENTS + "\\";
 
batRunner.write("md " + semestreUnitName + "\n");
batRunner.write("md " + conteudosUnitFolder + "\n");
batRunner.write("md " + dtpUnitFolder + "\n");
 
batRunner.write("md " + dtpUnitFolder + Globals.INTRANET_DTP_Planeamento + "\\\n");
batRunner.write("md " + dtpUnitFolder + Globals.INTRANET_DTP_FichaCurricular + "\\\n");
batRunner.write("md " + dtpUnitFolder + Globals.INTRANET_DTP_Sumarios + "\\\n");
batRunner.write("md " + dtpUnitFolder + Globals.INTRANET_DTP_Avaliacao + "\\\n");
batRunner.write("md " + dtpUnitFolder + Globals.INTRANET_DTP_Avaliacao + "\\" + Globals.INTRANET_DTP_Avaliacao_enunciados + "\\\n");
batRunner.write("md " + dtpUnitFolder + Globals.INTRANET_DTP_Avaliacao + "\\" + Globals.INTRANET_DTP_Avaliacao_pautas + "\\\n");
batRunner.write("md " + dtpUnitFolder + Globals.INTRANET_DTP_FichaAvaliacao + "\\\n");
batRunner.write("md " + dtpUnitFolder + Globals.INTRANET_DTP_InqueritoPedagogico + "\\\n");
batRunner.write("cd " + semestreUnitName + "\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /p \"Domain Users\":n\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /p \"Authenticated Users\":n\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /p \"Intranet\":n\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /p \"Alunos\":n\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /r \"Domain Users\"\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /r \"Authenticated Users\"\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /r \"Intranet\"\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /r \"Alunos\"\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /g \"Docentes\":r\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /g \"" + c.getUserGroupStudents() + "\":r\n");
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /g \"" + ConfigProperties.getProperty("ionline.user") + "\":f\n");
 
 
/*
echo CACLS Seminario.Ii /T /E /R [NOME DO GRUPO DE TODOS OS ALUNOS DA ESTG tira os parentisis rectos]
echo CACLS Seminario.Ii /T /E /G [NOME DO GRUPO DE TODOS OS DOCENTES]:R
echo CACLS Seminario.Ii /T /E /G [NOME DO GRUPO DE TODOS OS ALUNOS DO CURSO]:R
echo CACLS Seminario.Ii /T /E /G secundino.lopes:C
*/
//batRunner.write("\n");
 
//nowWriter.write(normalizedName);
System.out.println("GENERATING LINE: " + normalizedName);
 
if(courseUnit.getTeachers() != null)
{
String users = "";
int counter = 0;
for(Teacher t: courseUnit.getTeachers())
{
if(t.getUsername() != null)
{
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /g \"" + t.getUsername() + "\":c\n");
//batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /r \"" + t.getUsername() + "\":c\n");
batRunner.write("cd " + Globals.INTRANET_DTP + "\n");
batRunner.write("cacls " + Globals.INTRANET_DTP_FichaCurricular + " /t /e /r \"" + t.getUsername() + "\"\n");
//batRunner.write("cacls " + Globals.INTRANET_DTP_FichaAvaliacao + " /t /e /r \"" + t.getUsername() + "\"\n");
batRunner.write("cd ..\\\n");
batRunner.write("cacls " + Globals.INTRANET_CONTENTS + " /t /e /g \"" + t.getUsername() + "\":c\n");
//users += " " + t.getUsername();
//counter++;
}
}
// nowWriter.write(" " + counter + users);
//nowWriter.write("\n");
}
if(Globals.INTRANET_DTP_CourseUnitResponsibleWrite && courseUnit.getResponsableTeacher() != null )
{
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /g \"" + courseUnit.getResponsableTeacher().getUsername() + "\":c\n");
batRunner.write("cd " + Globals.INTRANET_DTP + "\n");
batRunner.write("cacls " + Globals.INTRANET_DTP_FichaCurricular + " /t /e /r \"" + courseUnit.getResponsableTeacher().getUsername() + "\"\n");
batRunner.write("cacls " + Globals.INTRANET_DTP_FichaAvaliacao + " /t /e /r \"" + courseUnit.getResponsableTeacher().getUsername() + "\"\n");
batRunner.write("cd ..\\\n");
 
}
if(Globals.INTRANET_DTP_CourseCoordinatorWrite && c.getCoordinator() != null)
{
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /g \"" + c.getCoordinator().getUsername() + "\":c\n");
batRunner.write("cd " + Globals.INTRANET_DTP + "\n");
batRunner.write("cacls " + Globals.INTRANET_DTP_FichaCurricular + " /t /e /r \"" + c.getCoordinator().getUsername() + "\"\n");
batRunner.write("cacls " + Globals.INTRANET_DTP_FichaAvaliacao + " /t /e /r \"" + c.getCoordinator().getUsername() + "\"\n");
batRunner.write("cd ..\\\n");
 
}
if(Globals.INTRANET_DTP_CourseDirectorWrite && c.getCoordinator() != null)
{
batRunner.write("cacls " + Globals.INTRANET_DTP + " /t /e /g \"" + c.getDirector().getUsername() + "\":c\n");
batRunner.write("cd " + Globals.INTRANET_DTP + "\n");
batRunner.write("cacls " + Globals.INTRANET_DTP_FichaCurricular + " /t /e /r \"" + c.getDirector().getUsername() + "\"\n");
batRunner.write("cacls " + Globals.INTRANET_DTP_FichaAvaliacao + " /t /e /r \"" + c.getDirector().getUsername() + "\"\n");
batRunner.write("cd ..\\\n");
}
batRunner.write("cd ..\\..\\\n");
}
batRunner.write("cd ..\\..\\\n");
//confWriterSemestre1.flush();
//confWriterSemestre2.flush();
// confWriterA.flush();
// confWriterSemestre1.close();
// confWriterSemestre2.close();
// confWriterA.close();
}
catch (IOException e)
{
logger.error(e,e);
}
}
}
batRunner.write("cd " + back);
batRunner.close();
FilesUtils.zipFolder(tmpDir,tmpDir + ".zip");
FilesUtils.delete(tmpDir);
return tmpName + ".zip";
}
catch (IOException e)
{
logger.error(e,e);
}
return null;
}
 
public static void main(String[] args) throws ServiceException
{
String teste = "Sistemas Térmicos, Hidráulicos e Pneumáticos";
System.out.println(StringsUtils.normalizeResourceName(teste));
// AbstractDao.getCurrentSession().beginTransaction();
// new CreateCourseUnitDirPackageService().run(null,null);
// AbstractDao.getCurrentSession().getTransaction().commit();
}
 
 
}
 
/******
*
* MEMO COMANDOS WINDOWS
* Ok Jaime testa este comando se faz favor.
 
Por partes:
 
O ficheiro de input do mkcursos.exe é assim:
 
Seminario.Ii 1 secundino.lopes
Bases.De.Dados.Ii 1 vrealinho
Redes.De.Computadores.I 1 secundino.lopes
Teoria.Da.Computacao 1 jmachado
Seguranca 1 secundino.lopes
 
Em que o primeiro parâmetro é a pasta da unidade
O segundo é o numero de users que vêm seguidamente
 
O programa faz isto
 
O inicio cria uma pasta para a cadeira e 3 pastas lá dentro:
fscanf(fic, " %s", disc); //SCAN DO FICHEIRO DE UMA STRING para a var disc isto é o nome da pasta para a unidade
if (feof(fic)) exit(0);
sprintf(linha,"echo md %s", disc); //CONSTRUCAO DO COMANDO DE MD para a var linha para criar os três directorios
//disc = Seminario.Ii
//fica: linha = " echo md Seminario.Ii "
system(linha); //EXECUTA O COMANDO em Linha
sprintf(linha,"echo md %s\\\\Conteudos", disc); //fica: linha = " echo md Seminario.Ii\\Conteudos "
 
system(linha);
sprintf(linha,"echo md %s\\\\Avaliacao", disc); //fica: linha = " echo md Seminario.Ii\\ Avaliacao "
 
system(linha);
sprintf(linha,"echo md %s\\\\Assiduidade", disc); //fica: linha = " echo md Seminario.Ii\\ Assiduidade "
 
system(linha);
seguidamente o programa lê o inteiro no caso do seminario é "1" e de 0 até 1 ou seja só uma vez neste caso lê a próxima String neste caso secundino.lopes o ActiveDirectory tem lá este user
fscanf(fic, "%i", &n);
for (i=0; i<n; i++) {
fscanf(fic, " %s", doc); //Lê secundino.lopes aqui
sprintf(linha, "echo CACLS %s /T /E /G %s:C", disc, doc);
//fica linha=echo CACLS Seminario.Ii /T /E /G secundino.lopes:C
system(linha);
}
 
O CACLS muda isto:
discretionary access control list (DACL) da pasta
 
JAIME Metes-te no Donald em linha de comandos crias uma pasta num sitio de teste e escreves isto:
 
segundo a documentação da Microsoft:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cacls.mspx?mfr=true
O /T significa aplicar às subpastas
O /E significa editar em vez de a destruir o DACL para manter as permissões anteriores
O /G para garantir acesso ao user especificado no fomato User:permission permission pode ser C, R etc
logo Secundino.lopes:CREATE é o que quer dizer o secundino.lopes:C
/R User revoga direitos de acesso a um User
O que queremos é revogar a todos os utilizadores e de seguida adicionar permissões de leitura a
todos os docentes, leitura aos users do Curso e por fim escrita aos docentes da unidade
Agora resta saber a ordem como fazer isto para funcionar e isso tens de ser tu a testar JAIME
Tenta isto numa pasta de teste fora do i.online para não estragarmos nada
Retiramos aos alunos todos, damos leitura aos docentes todos, damos leitura aos alunos do curso
e por fim escrita ao docente de teste
echo CACLS Seminario.Ii /T /E /R [NOME DO GRUPO DE TODOS OS ALUNOS DA ESTG tira os parentisis rectos]
echo CACLS Seminario.Ii /T /E /G [NOME DO GRUPO DE TODOS OS DOCENTES]:R
echo CACLS Seminario.Ii /T /E /G [NOME DO GRUPO DE TODOS OS ALUNOS DO CURSO]:R
echo CACLS Seminario.Ii /T /E /G secundino.lopes:C
 
 
Experimenta isto ou noutra ordem e verifica como ficaram as permissões no fim e quando acertares o passo
manda-me o resultado para eu criar o ficheiro final com os BATS todos
*/
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/services/courseunits/LoadCourseUnitsBySigesCodesService.java
39,4 → 39,24
}
return courseUnitViews;
}
 
public CourseUnitView loadLastYear(String code, String courseCode, String semestre, UserSession userSession) throws ServiceException {
 
if(semestre.equals("S3"))
semestre = "S1";
else if(semestre.equals("S4"))
semestre = "S2";
else if(semestre.equals("S5"))
semestre = "S1";
else if(semestre.equals("S6"))
semestre = "S2";
else if(semestre.startsWith("A"))
semestre = "A";
 
CourseUnit courseUnit = DaoFactory.getCourseUnitDaoImpl().loadBySigesCodeUniqueLastYear(code, courseCode,semestre);
 
if(courseUnit == null)
return null;
return new CourseUnitView(courseUnit);
}
}
/impl/src/java/pt/estgp/estgweb/services/courseunits/LoadSubscribedUnitsCurrentYearService.java
1,13 → 1,11
package pt.estgp.estgweb.services.courseunits;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.Student;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.List;
import java.util.ArrayList;
 
/**
* @author Jorge Machado
19,7 → 17,7
public List<CourseUnit> run(long studentId)
{
Student t = DaoFactory.getStudentDaoImpl().load(studentId);
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadSubscribedImportYearUnits(studentId, DatesUtils.getImportYear());
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadSubscribedImportYearUnits(studentId, DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
for(CourseUnit c: units)
{
c.getName();
27,4 → 25,16
}
return units;
}
 
public List<CourseUnit> givenYear(long studentId,String year)
{
Student t = DaoFactory.getStudentDaoImpl().load(studentId);
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadSubscribedImportYearUnits(studentId, year);
for(CourseUnit c: units)
{
c.getName();
c.getCourse().getName();
}
return units;
}
}
/impl/src/java/pt/estgp/estgweb/services/courseunits/CreateCourseUnitAdminService.java
1,16 → 1,13
package pt.estgp.estgweb.services.courseunits;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.domain.views.CourseUnitView;
import pt.estgp.estgweb.domain.views.CourseUnitAssignementView;
import pt.estgp.estgweb.domain.UserSession;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.CourseUnitAssignement;
import pt.estgp.estgweb.domain.DomainObjectFactory;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.CourseUnitView;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.Globals;
import org.apache.log4j.Logger;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
/*
* @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
38,7 → 35,12
 
CourseUnit courseUnit;
if(cUV.getId() > 0)
{
courseUnit = DaoFactory.getCourseUnitDaoImpl().get(cUV.getId());
courseUnit.setCourseUnitEvaluation(DaoFactory.getCourseUnitEvaluationDaoImpl().narrow(courseUnit.getCourseUnitEvaluation()));
courseUnit.setCourseUnitProgram(DaoFactory.getCourseUnitProgramDaoImpl().narrow(courseUnit.getCourseUnitProgram()));
 
}
else
{
courseUnit = DomainObjectFactory.createCourseUnitImpl();
46,7 → 48,7
}
cUV.persistViewAdminInObject(courseUnit);
 
courseUnit.setInstitutionCode("" + Globals.SIGES_INSTITUTION_CODE.intValue());
courseUnit.setInstitutionCode("" + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode());
//por o curso
//por os profs
//por alunos
/impl/src/java/pt/estgp/estgweb/services/courseunits/CreateCourseUnitDirPackageService.java
40,7 → 40,7
public String run(String importYear, UserSession userSession) throws ServiceException
{
if(importYear == null || importYear.trim().length() == 0)
importYear = DatesUtils.getImportYear();
importYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
String importYearIntranet = DatesUtils.getImportYearIntranet(importYear);
String tmpName = BytesUtils.generateHexKey();
String tmpDir = Globals.TMP_DIR + "/" + tmpName;
74,13 → 74,26
new File(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S1).mkdirs();
new File(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S2).mkdirs();
new File(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_A).mkdirs();
new File(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T1).mkdirs();
new File(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T2).mkdirs();
new File(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T3).mkdirs();
new File(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T4).mkdirs();
FilesUtils.copy(CreateCourseUnitDirPackageService.class.getResourceAsStream(Globals.INTRANET_SETUP_FILE),courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S1 + "/" + Globals.INTRANET_SETUP_FILE_NAME);
FilesUtils.copy(CreateCourseUnitDirPackageService.class.getResourceAsStream(Globals.INTRANET_SETUP_FILE),courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S2 + "/" + Globals.INTRANET_SETUP_FILE_NAME);
FilesUtils.copy(CreateCourseUnitDirPackageService.class.getResourceAsStream(Globals.INTRANET_SETUP_FILE),courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_A + "/" + Globals.INTRANET_SETUP_FILE_NAME);
 
FilesUtils.copy(CreateCourseUnitDirPackageService.class.getResourceAsStream(Globals.INTRANET_SETUP_FILE),courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T1 + "/" + Globals.INTRANET_SETUP_FILE_NAME);
FilesUtils.copy(CreateCourseUnitDirPackageService.class.getResourceAsStream(Globals.INTRANET_SETUP_FILE),courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T2 + "/" + Globals.INTRANET_SETUP_FILE_NAME);
FilesUtils.copy(CreateCourseUnitDirPackageService.class.getResourceAsStream(Globals.INTRANET_SETUP_FILE),courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T3 + "/" + Globals.INTRANET_SETUP_FILE_NAME);
FilesUtils.copy(CreateCourseUnitDirPackageService.class.getResourceAsStream(Globals.INTRANET_SETUP_FILE),courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T4 + "/" + Globals.INTRANET_SETUP_FILE_NAME);
 
String callPathS1 = (courseImportYearPathDos + "\\" + Globals.INTRANET_SEMESTRE_S1 + "\\").substring(tmpDir.length() + 1);
String callPathS2 = (courseImportYearPathDos + "\\" + Globals.INTRANET_SEMESTRE_S2 + "\\").substring(tmpDir.length() + 1);
String callPathA = (courseImportYearPathDos + "\\" + Globals.INTRANET_SEMESTRE_A + "\\").substring(tmpDir.length() + 1);
String callPathT1 = (courseImportYearPathDos + "\\" + Globals.INTRANET_SEMESTRE_T1 + "\\").substring(tmpDir.length() + 1);
String callPathT2 = (courseImportYearPathDos + "\\" + Globals.INTRANET_SEMESTRE_T2 + "\\").substring(tmpDir.length() + 1);
String callPathT3 = (courseImportYearPathDos + "\\" + Globals.INTRANET_SEMESTRE_T3 + "\\").substring(tmpDir.length() + 1);
String callPathT4 = (courseImportYearPathDos + "\\" + Globals.INTRANET_SEMESTRE_T4 + "\\").substring(tmpDir.length() + 1);
batRunner.write("cd " + back + callPathS1);
back = "..\\..\\..\\";
batRunner.write("\n");
94,11 → 107,36
batRunner.write("\n");
batRunner.write(Globals.INTRANET_SETUP_FILE_NAME + " " + Globals.INTRANET_USERS_SETUP_FILE_NAME);
batRunner.write("\n");
 
batRunner.write("cd " + back + callPathT1);
batRunner.write("\n");
batRunner.write(Globals.INTRANET_SETUP_FILE_NAME + " " + Globals.INTRANET_USERS_SETUP_FILE_NAME);
batRunner.write("\n");
 
batRunner.write("cd " + back + callPathT2);
batRunner.write("\n");
batRunner.write(Globals.INTRANET_SETUP_FILE_NAME + " " + Globals.INTRANET_USERS_SETUP_FILE_NAME);
batRunner.write("\n");
 
batRunner.write("cd " + back + callPathT3);
batRunner.write("\n");
batRunner.write(Globals.INTRANET_SETUP_FILE_NAME + " " + Globals.INTRANET_USERS_SETUP_FILE_NAME);
batRunner.write("\n");
 
batRunner.write("cd " + back + callPathT4);
batRunner.write("\n");
batRunner.write(Globals.INTRANET_SETUP_FILE_NAME + " " + Globals.INTRANET_USERS_SETUP_FILE_NAME);
batRunner.write("\n");
FileWriter confWriterSemestre1 = new FileWriter(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S1 + "/" + Globals.INTRANET_USERS_SETUP_FILE_NAME);
FileWriter confWriterSemestre2 = new FileWriter(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_S2 + "/" + Globals.INTRANET_USERS_SETUP_FILE_NAME);
FileWriter confWriterA = new FileWriter(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_A + "/" + Globals.INTRANET_USERS_SETUP_FILE_NAME);
 
FileWriter confWriterTrimestre1 = new FileWriter(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T1 + "/" + Globals.INTRANET_USERS_SETUP_FILE_NAME);
FileWriter confWriterTrimestre2 = new FileWriter(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T2 + "/" + Globals.INTRANET_USERS_SETUP_FILE_NAME);
FileWriter confWriterTrimestre3 = new FileWriter(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T3 + "/" + Globals.INTRANET_USERS_SETUP_FILE_NAME);
FileWriter confWriterTrimestre4 = new FileWriter(courseImportYearPath + "/" + Globals.INTRANET_SEMESTRE_T4 + "/" + Globals.INTRANET_USERS_SETUP_FILE_NAME);
 
 
// List<CourseUnit> courseUnits = DaoFactory.getCourseUnitDaoImpl().loadByCourse(c.getId(),importYear);
for(CourseUnit courseUnit: courseUnits)
{
114,6 → 152,27
nowWriter = confWriterSemestre2;
semestre = Globals.INTRANET_SEMESTRE_S2;
}
else if(courseUnit.getSemestre().equals("T1"))
{
nowWriter = confWriterTrimestre1;
semestre = Globals.INTRANET_SEMESTRE_T1;
}
else if(courseUnit.getSemestre().equals("T2"))
{
nowWriter = confWriterTrimestre2;
semestre = Globals.INTRANET_SEMESTRE_T2;
}
else if(courseUnit.getSemestre().equals("T3"))
{
nowWriter = confWriterTrimestre3;
semestre = Globals.INTRANET_SEMESTRE_T3;
}
else if(courseUnit.getSemestre().equals("T4"))
{
nowWriter = confWriterTrimestre4;
semestre = Globals.INTRANET_SEMESTRE_T4;
}
 
else
{
nowWriter = confWriterA;
145,9 → 204,17
}
confWriterSemestre1.flush();
confWriterSemestre2.flush();
confWriterTrimestre1.flush();
confWriterTrimestre2.flush();
confWriterTrimestre3.flush();
confWriterTrimestre4.flush();
confWriterA.flush();
confWriterSemestre1.close();
confWriterSemestre2.close();
confWriterTrimestre1.close();
confWriterTrimestre2.close();
confWriterTrimestre3.close();
confWriterTrimestre4.close();
confWriterA.close();
}
catch (IOException e)
/impl/src/java/pt/estgp/estgweb/services/courseunits/courseunitevaluation.fo.xsl
New file
0,0 → 1,338
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:uc="http://baco.estgp.pt/schemas/courseunits/program/">
<xsl:param name="site">http://localhost/bacoTESTE</xsl:param>
<xsl:param name="revisor">automático</xsl:param>
<xsl:param name="validadoCC">false</xsl:param>
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4Vertical" page-width="210mm" page-height="297mm"
margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm"
reference-orientation="0">
<fo:region-body region-name="body" margin-top="20mm" margin-bottom="10mm" margin-right="0"
margin-left="0"/>
 
<fo:region-before region-name="header" extent="15mm"/>
<fo:region-after region-name="footer" extent="1cm"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="A4HorizontalRot" page-width="210mm" page-height="297mm"
margin-top="0.5cm" margin-bottom="0.5cm" margin-left="0.5cm" margin-right="0.5cm"
reference-orientation="90">
<fo:region-body region-name="body" margin-top="20mm" margin-bottom="10mm" margin-right="0"
margin-left="0"/>
<fo:region-before region-name="header" extent="15mm"/>
<fo:region-after region-name="footer" extent="1cm"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="A4Horizontal" page-width="297mm" page-height="210mm"
margin-top="0.5cm" margin-bottom="0.5cm" margin-left="0.5cm"
margin-right="0.5cm">
<fo:region-body region-name="body" margin-top="20mm" margin-bottom="15mm" margin-right="0"
margin-left="0"/>
<fo:region-before region-name="header" extent="15mm"/>
<fo:region-after region-name="footer" extent="1cm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="pages">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="pages" page-position="any"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
 
<!--LAYOUT DE PAGINA ESCOLHIDO-->
<fo:page-sequence master-reference="A4Vertical" initial-page-number="auto">
<xsl:call-template name="page"/>
</fo:page-sequence>
 
 
</fo:root>
</xsl:template>
 
 
<xsl:template name="page">
<fo:static-content flow-name="header">
 
<fo:block text-align="left" >
<fo:table width="100%" table-layout="fixed" border-bottom="1px solid black">
<fo:table-column column-width="100%"/>
 
 
<fo:table-body>
<fo:table-row>
<fo:table-cell >
<fo:block>
<fo:external-graphic height="auto" width="auto"
content-height="30">
<!--<xsl:attribute name="src">url('http://www.ipportalegre.pt/imagens/Logos/ESTG/Logotipo%20ESTG.jpg')</xsl:attribute>-->
<xsl:attribute name="src">url('<xsl:value-of select="$site"/>/imgs/logoestg.gif')</xsl:attribute>
</fo:external-graphic>
</fo:block>
<xsl:if test="//closed = 'false'">
<fo:block font-size="20pt">
(Este documento não está fechado)
</fo:block>
</xsl:if>
<xsl:if test="//closed = 'true'">
<fo:block font-size="20pt">
Relatório de avaliação curricular <xsl:value-of select="//anoLectivo"/>
</fo:block>
</xsl:if>
</fo:table-cell>
 
</fo:table-row>
 
</fo:table-body>
</fo:table>
 
</fo:block>
 
 
</fo:static-content>
<fo:static-content flow-name="footer">
 
<fo:table width="100%" table-layout="fixed" border-top="1px solid black" font-size="6.5pt" >
<fo:table-column column-width="20%"/>
<fo:table-column column-width="80%" />
 
 
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-top="3pt">
<fo:block >
Revisto a <xsl:value-of select="//updateDate"/> por <xsl:value-of select="$revisor"/> / Página <fo:page-number/>
</fo:block>
<fo:block font-size="5pt">
ESTG.SA.xxxx.1
</fo:block>
 
</fo:table-cell>
<fo:table-cell padding-top="3pt" >
<fo:block font-size="6pt" text-align="right">
http://www.estgp.pt | gerado pela plataforma baco® 2015
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
 
<fo:flow flow-name="body">
<fo:block>
<xsl:apply-templates select="/CourseUnitEvaluation"/>
</fo:block>
</fo:flow>
</xsl:template>
 
<xsl:template match="/CourseUnitEvaluation">
 
<fo:table table-layout="fixed" border="0px solid black" margin="0.5em" font-size="8.5pt">
<xsl:call-template name="gen_cols"/>
<fo:table-body text-align="left">
 
<xsl:call-template name="gen_header"/>
 
<xsl:call-template name="gen_line"/>
 
</fo:table-body>
</fo:table>
</xsl:template>
 
<xsl:template name="gen_cols">
<fo:table-column column-width="15em" />
<fo:table-column/>
</xsl:template>
 
 
 
 
<xsl:template name="gen_header">
 
</xsl:template>
 
 
 
 
 
 
 
 
<xsl:attribute-set name="myBorder">
<xsl:attribute name="border">solid 0.2mm black</xsl:attribute>
</xsl:attribute-set>
 
<xsl:template name="gen_line">
 
<fo:table-row background-color="#FFF" color="#000" padding="0">
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Ano Lectivo
</fo:block>
</fo:table-cell>
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block >
<xsl:value-of select="//anoLectivo"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row background-color="#FFF" color="#000" padding="0">
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Curso
</fo:block>
</fo:table-cell>
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block >
<xsl:value-of select="//curso/nome"/> / <xsl:value-of select="//curso/codigo"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row background-color="#FFF" color="#000" padding="0">
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Unidade Curricular
</fo:block>
</fo:table-cell>
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block >
<xsl:value-of select="//unidadecurricular/nome"/> / <xsl:value-of select="//unidadecurricular/codigo"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row background-color="#FFF" color="#000" padding="0">
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Professor Responsável
</fo:block>
</fo:table-cell>
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block >
<xsl:value-of select="//responsavel/nome"/> / <xsl:value-of select="//responsavel/email"/>
</fo:block >
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="//docente">
<fo:table-row background-color="#FFF" color="#000" padding="0">
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Docente
</fo:block>
</fo:table-cell>
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block >
<xsl:value-of select="./nome"/> / <xsl:value-of select="./email"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
 
<fo:table-row background-color="#FFF" color="#000" padding="0">
 
<fo:table-cell border-right="1px solid gray" border-bottom="1px solid gray" display-align="center" >
<fo:block text-align="right" padding="3pt" font-weight="bold">
Dados relativos ao processo de avaliação
</fo:block>
</fo:table-cell>
 
<fo:table-cell border-bottom="1px solid gray" padding="0" padding-top="5px" padding-bottom="5px" padding-left="0mm" display-align="center">
 
 
<fo:table margin="0" margin-left="0mm" border="0px solid black" font-size="5.5pt" >
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-body>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="myBorder" number-rows-spanned="2" padding-top="3pt"><fo:block > Nº Alunos Inscritos </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" number-rows-spanned="2" padding-top="3pt"><fo:block > Nº de alunos sem elementos de avaliação </fo:block> </fo:table-cell>
 
<fo:table-cell xsl:use-attribute-sets="myBorder" number-rows-spanned="1" number-columns-spanned="5" padding-top="3pt" display-align="center"><fo:block display-align="center"> Nº de alunos aprovados em </fo:block> </fo:table-cell>
 
<fo:table-cell xsl:use-attribute-sets="myBorder" number-rows-spanned="2" padding-top="3pt"><fo:block > Aprovados com a classificação entre 10 e 13 valores (%) </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" number-rows-spanned="2" padding-top="3pt"><fo:block > Aprovados com a classificação entre 14 e 16 valores (%) </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" number-rows-spanned="2" padding-top="3pt"><fo:block > Aprovados com a classificação entre 17 e 20 valores (%) </fo:block> </fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > Avaliação de frequência </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > Exame Época Normal </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > Exame Época Recurso </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > Exame Época Especial </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > Total </fo:block> </fo:table-cell>
 
</fo:table-row>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > <xsl:value-of select="//numAlunosInscritos"/> </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > <xsl:value-of select="//numAlunosSemElementosAvaliacao"/> </fo:block> </fo:table-cell>
 
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > <xsl:value-of select="//numAlunosAprovFrequencia"/> </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > <xsl:value-of select="//numAlunosAprovNormal"/> </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > <xsl:value-of select="//numAlunosAprovRecurso"/> </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > <xsl:value-of select="//numAlunosAprovEspecial"/> </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > <xsl:value-of select="//numAlunosAprovTotal"/> </fo:block> </fo:table-cell>
 
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > <xsl:value-of select="//numAlunosAprov1013"/> </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > <xsl:value-of select="//numAlunosAprov1416"/> </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding-top="3pt"><fo:block > <xsl:value-of select="//numAlunosAprov1720"/> </fo:block> </fo:table-cell>
 
</fo:table-row>
</fo:table-body>
</fo:table>
 
 
</fo:table-cell>
 
 
 
</fo:table-row>
 
<fo:table-row background-color="#FFF" color="#000">
<fo:table-cell border-bottom="1px solid gray" border-right="1px solid gray" padding-right="0.1em" display-align="center">
<fo:block text-align="center" font-weight="bold">Auto-avaliação</fo:block>
</fo:table-cell>
<fo:table-cell border-bottom="1px solid gray" display-align="center" padding="5px">
 
 
<fo:table margin="0" margin-left="0mm" border="0px solid black" font-size="5.5pt" >
<fo:table-column column-width="20%"/>
<fo:table-column/>
<fo:table-body>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="myBorder" display-align="center" padding="3pt"><fo:block font-weight="bold"> Apreciação dos resultados quantitativos obtidos pelos estudantes </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding="3pt"><fo:block > <xsl:value-of select="//qualApreciacaoQuantitivos"/> </fo:block> </fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="myBorder" display-align="center" padding="3pt"><fo:block font-weight="bold"> Apreciação do funcionamento da UC (Condições de funcionamento da UC; problemas detetados; identificação de práticas pedagógicas de mérito ou deficientes; etc.) </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding="3pt"><fo:block > <xsl:value-of select="//qualApreciacaoUC"/> </fo:block> </fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="myBorder" display-align="center" padding="3pt"><fo:block font-weight="bold"> Apreciação do cumprimento do programa da UC (Adequação das metodologias de ensino/aprendizagem utilizadas; competências efetivamente adquiridas e cumprimento dos conteúdos planificados) </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding="3pt"><fo:block > <xsl:value-of select="//qualApreciacaoCumprimentoPrograma"/> </fo:block> </fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="myBorder" display-align="center" padding="3pt"><fo:block font-weight="bold"> Conclusões (Pontos fortes e fracos; sugestões de melhoria e respetivo plano de ação para a sua concretização) </fo:block> </fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="myBorder" padding="3pt"><fo:block > <xsl:value-of select="//qualConclusoes"/> </fo:block> </fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
 
 
</fo:table-cell>
</fo:table-row>
 
 
</xsl:template>
 
 
 
 
 
 
 
</xsl:stylesheet>
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/services/courseunits/LoadTeachedUnitsCurrentYearService.java
1,14 → 1,12
package pt.estgp.estgweb.services.courseunits;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.CourseUnitImpl;
import pt.estgp.estgweb.domain.Teacher;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.List;
import java.util.ArrayList;
 
/**
* @author Jorge Machado
20,7 → 18,7
public List<CourseUnitImpl> run(long teacherId)
{
Teacher t = DaoFactory.getTeacherDaoImpl().load(teacherId);
List<CourseUnitImpl> units = DaoFactory.getCourseUnitDaoImpl().loadTeachedImportYearUnits(teacherId,DatesUtils.getImportYear());
List<CourseUnitImpl> units = DaoFactory.getCourseUnitDaoImpl().loadTeachedImportYearUnits(teacherId,DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
 
for(CourseUnit c: units)
{
/impl/src/java/pt/estgp/estgweb/services/email/SendEmailService.java
3,25 → 3,23
import jomm.utils.TemplateUtils;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.enums.LangEnum;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.utils.Email;
import pt.estgp.estgweb.web.utils.DatesUtils;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.domain.enums.LangEnum;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.utils.Email;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Message;
import javax.mail.Transport;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.InternetAddress;
import java.io.UnsupportedEncodingException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.Date;
import java.text.MessageFormat;
 
/**
* @author Jorge Machado
42,9 → 40,47
// Set up properties for mail session
Properties props = System.getProperties();
props.put("mail.smtp.host", Globals.EMAIL_SERVER_HOST);
final String username = Globals.EMAIL_SERVER_USERNAME;
final String password = Globals.EMAIL_SERVER_PASSWORD;
javax.mail.Authenticator authenticator = null;
if(Globals.EMAIL_SERVER_SECURITY != null && Globals.EMAIL_SERVER_SECURITY.compareTo("TLS")==0)
{
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.port", ""+ Globals.EMAIL_SERVER_SECURITY_TLS);
authenticator = new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
};
}
else if(Globals.EMAIL_SERVER_SECURITY != null && Globals.EMAIL_SERVER_SECURITY.compareTo("SSL")==0)
{
props.put("mail.smtp.socketFactory.port", Globals.EMAIL_SERVER_SECURITY_SSL);
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", Globals.EMAIL_SERVER_SECURITY_SSL);
authenticator = new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username,password);
}
};
}
else
{
 
}
 
 
 
 
 
 
// Get session
Session session = Session.getDefaultInstance(props, null);
Session session = Session.getDefaultInstance(props, authenticator);
session.setDebug(true);
session.setDebugOut(System.out);
 
// Create message
MimeMessage message = new MimeMessage(session);
66,20 → 102,49
// Format the mail message
String fullMessage = MessageFormat.format(content, email.getArguments().toArray());
 
logger.info("FROM:" + email.getFrom());
message.setFrom(new InternetAddress(email.getFrom()));
message.setSubject(email.getSubject());
 
 
logger.info("FROM:" + email.getFrom() + " but using: " + Globals.SYSTEM_EMAIL_BOX);
//if(email.getFromName() != null)
try {
message.setFrom(new InternetAddress(Globals.SYSTEM_EMAIL_BOX,Globals.SYSTEM_EMAIL_BOX));
} catch (UnsupportedEncodingException e) {
logger.error(e,e);
message.setFrom(new InternetAddress(email.getFrom()));
}
//else
// message.setFrom(new InternetAddress(Globals.SYSTEM_EMAIL_BOX));
message.setSubject(email.getSubject() + " - não responda para este endereço");
 
if(email.isHtml())
{
 
fullMessage += email.getFrom() != null && email.getFrom().length()>0 && !email.getFrom().equals(Globals.SYSTEM_EMAIL_BOX) ? "<br/><br/>Responda para " + email.getFrom() : "<br/><br/>Por favor não responda a este email";
fullMessage += " <br/> <br/> <h5> Mensagem Segura - enviada através da Google Apps Api através de baco 2015 </h5>";
 
}
else
{
fullMessage += email.getFrom() != null && email.getFrom().length()>0 && !email.getFrom().equals(Globals.SYSTEM_EMAIL_BOX) ? "\n\nResponda para " + email.getFrom() : "\n\nPor favor não responda a este email";
fullMessage += " \n\n Mensagem Segura - enviada através da Google Apps Api através de baco 2015";
}
 
message.setText(fullMessage,"utf-8");
 
 
if(email.isHtml())
{
message.setHeader("Content-Type","text/html; charset=\"utf-8\"");
}
else
{
message.setHeader("Content-Type","text/plain; charset=\"utf-8\"");
}
message.setHeader("Content-Transfer-Encoding", "quoted-printable");
logger.info("Sending email to transport:"+fullMessage);
 
 
 
Transport.send(message);
}
}
182,7 → 247,9
for(String rec: recipients)
logger.info(rec);
logger.info("arguments end");
return new Email(subject ,recipients,user.getEmail(),template,arguments,Message.RecipientType.BCC);
Email email = new Email(subject ,recipients,user.getEmail(),template,arguments,Message.RecipientType.BCC);
email.setFromName(from + " (ESTG)");
return email;
}
 
public Email getCourseUnitAnnouncementEmail(CourseUnitAnnouncement announcement, LangEnum langEnum, String from, List<User> users)
379,6 → 446,55
return new Email(subject ,recipients, Globals.SYSTEM_EMAIL_BOX,template,arguments);
}
 
 
//TODO TESTAR
public Email getSummariesEmail(List<String> emails, List<CourseUnitSummary> cUS, CourseUnit c, LangEnum langEnum)
{
 
 
String ultimaData = DatesUtils.getStringFromDate(cUS.get(cUS.size() - 1).getDataAula());
String subject;
String template;
String templateFragment;
 
if(langEnum == LangEnum.PORTUGUESE)
{
template = Globals.EMAIL_SUMMARIES_TEMPLATE_PT;
templateFragment = Globals.EMAIL_SUMMARIES_FRAGMENT_TEMPLATE_PT;
subject = Globals.EMAIL_SUMMARY_SUBJECT_PT;
}
else
{
template = Globals.EMAIL_SUMMARIES_TEMPLATE_EN;
templateFragment = Globals.EMAIL_SUMMARIES_FRAGMENT_TEMPLATE_EN;
subject = Globals.EMAIL_SUMMARY_SUBJECT_EN;
}
subject = TemplateUtils.formatMessageTemplate(subject,new String[]{c.getName()});
 
StringBuilder fragments = new StringBuilder();
 
List<String> arguments = new ArrayList<String>();
String fragmentSummaryTemplate = TemplateUtils.getOrLoadTemplate(Globals.TEMPLATE_EMAIL_PATH + "/" + templateFragment);
for(CourseUnitSummary summary: cUS)
{
List<String> argumentsFrag = new ArrayList<String>();
argumentsFrag.add(summary.getTitulo());
argumentsFrag.add(DatesUtils.getStringFromDate(summary.getDataAula()));
argumentsFrag.add(summary.getDescricao());
String fullMessage = MessageFormat.format(fragmentSummaryTemplate, argumentsFrag.toArray());
fragments.append("\n").append(fullMessage);
}
 
arguments.add(c.getName());
arguments.add(ultimaData);
arguments.add(fragments.toString());
 
List<String> recipients = new ArrayList<String>();
for(String email:emails)
recipients.add(email);
return new Email(subject ,recipients, Globals.SYSTEM_EMAIL_BOX,template,arguments);
}
 
public Email getUnidadeEdicaoEmail(List<String> emails, CourseUnit c, LangEnum langEnum)
{
List<String> arguments = new ArrayList<String>();
464,6 → 580,36
return new Email(subject ,recipients, Globals.SYSTEM_EMAIL_BOX,template,arguments);
}
 
public Email getRelatorioAvaliacaoUnidadeEditadaEmail(List<String> emails, CourseUnit c, LangEnum langEnum,String estado)
{
List<String> arguments = new ArrayList<String>();
 
 
String subject;
String template;
 
if(langEnum == LangEnum.PORTUGUESE)
{
template = Globals.EMAIL_RELATORIO_AVALIACAO_UNDADE_EDITADA_TEMPLATE_PT;
subject = Globals.EMAIL_RELATORIO_AVALIACAO_UNDADE_EDITADA_SUBJECT_PT;
}
else
{
template = Globals.EMAIL_RELATORIO_AVALIACAO_UNDADE_EDITADA_TEMPLATE_EN;
subject = Globals.EMAIL_RELATORIO_AVALIACAO_UNDADE_EDITADA_SUBJECT_EN;
}
subject = MessageFormat.format(ConfigProperties.getProperty(subject),new String[]{c.getName()});
 
arguments.add(c.getCourseName());
arguments.add(c.getName());
arguments.add(estado);
 
List<String> recipients = new ArrayList<String>();
for(String email:emails)
recipients.add(email);
return new Email(subject ,recipients, Globals.SYSTEM_EMAIL_BOX,template,arguments);
}
 
public boolean sendNewGrades(List<String[]> grades, LangEnum langEnum, String studentEmail, String studentName)
{
try
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportGradesService.java
1,31 → 1,30
package pt.estgp.estgweb.services.sigesimports;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import jomm.dao.impl.AbstractDao;
import jomm.utils.TemplateUtils;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.email.SendEmailService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.services.jobs.JobScheduleService;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.services.sms.SMSJob;
import pt.estgp.estgweb.services.jobs.JobScheduleService;
import pt.estgp.estgweb.services.email.EMAILJob;
import pt.estgp.estgweb.services.email.SendEmailService;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.enums.LangEnum;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.ipportalegre.siges.web.services.*;
import org.apache.log4j.Logger;
import pt.ipportalegre.siges.web.services.ArrayOfNota;
import pt.ipportalegre.siges.web.services.Nota;
import pt.ipportalegre.siges.web.services.SiGesWEB;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import javax.xml.namespace.QName;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.*;
 
import jomm.dao.impl.AbstractDao;
import jomm.utils.TemplateUtils;
 
/**
* @author Jorge Machado
* @date 11/May/2008
44,15 → 43,16
public ILogMessages run(String year) throws ServiceException
{
DefaultLogMessages logMessages = new DefaultLogMessages();
logMessages.addMessage(new DefaultLogMessage("import.grades", LogMessageTypeEnum.INFO, "instituicao " + Globals.SIGES_INSTITUTION_CODE));
logMessages.addMessage(new DefaultLogMessage("import.grades", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
logger.info("starting grades import");
try
{
AbstractDao.getCurrentSession().beginTransaction();
//AbstractDao.getCurrentSession().beginTransaction();
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
SiGesWEB service;
try
{
service = new SiGesWEB(new URL(Globals.SIGES_WEBSERVICE_WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
service = new SiGesWEB(new URL(WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
}
catch (MalformedURLException e)
{
60,7 → 60,7
logger.fatal(e, e);
return logMessages;
}
ArrayOfNota arrayOfNotas = service.getSiGesWEBSoap().getNotas(Globals.SIGES_INSTITUTION_CODE, year);
ArrayOfNota arrayOfNotas = service.getSiGesWEBSoap().getNotas(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year);
List<Nota> notas = arrayOfNotas.getNota();
int i = 0;
for (Nota nota : notas)
72,6 → 72,16
AbstractDao.getCurrentSession().beginTransaction();
}
 
/**
* n.codigo_aluno = getDecimal("CD_ALUNO",aReader); ----- OK
n.codigo_curso = getDecimal("CD_CURSO", aReader); ----- OK
n.codigo_disciplina = getDecimal("CD_DISCIP", aReader);- OK
n.nota = getDecimal("NR_AVALIA", aReader); ---------- OK
n.data_avaliacao = getDateTime("DT_AVALIA", aReader); - OK
n.status_epoca = getDecimal("CD_STA_EPO", aReader); -- OK
n.cd_duracao = getString("CD_DURACAO",aReader); - ------ OK
*/
 
int codAluno = nota.getCodigoAluno().intValue();
int codUnidade = nota.getCodigoDisciplina().intValue();
int codCurso = nota.getCodigoCurso().intValue();
131,13 → 141,13
}
sendSms(null);
sendEmail(null);
AbstractDao.getCurrentSession().getTransaction().commit();
//AbstractDao.getCurrentSession().getTransaction().commit();
}
catch (Throwable e)
{
logger.error(e, e);
 
AbstractDao.getCurrentSession().getTransaction().rollback();
//AbstractDao.getCurrentSession().getTransaction().rollback();
logMessages.addMessage(new DefaultLogMessage("import.error", e.toString(), "see log for details", LogMessageTypeEnum.ERROR));
throw new ServiceException(e.toString(), e);
}
187,6 → 197,7
 
private void sendEmail(UserSession userSession)
{
/*
if(Globals.EMAIL_NEW_GRADES && newGrades.size() > 0)
{
Set<Map.Entry<Long,List<Long>>> set = newGrades.entrySet();
206,7 → 217,7
EMAILJob emailJob = new EMAILJob(sendEmailService.getNewGradesEmail(gradesArray, LangEnum.PORTUGUESE,s.getEmail(),s.getName()));
JobScheduleService.getInstance().scheduleNow(emailJob,"New Grades EMAIL: to" + s.getUsername(),userSession);
}
}
}*/
}
 
/**
217,10 → 228,12
*/
public static void main(String[] args) throws ServiceException
{
String year = DatesUtils.getImportYear();
String year = DaoFactory.getConfigurationDaoImpl().getImportsDefaultImportYearCreateTransaction();;
if(args != null && args.length > 0)
year = args[0];
AbstractDao.getCurrentSession().beginTransaction();
new ImportGradesService().run(year);
AbstractDao.getCurrentSession().getTransaction().commit();
}
 
 
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportSumaries.java
24,6 → 24,7
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import javax.xml.namespace.QName;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
49,15 → 50,16
public ILogMessages run(String year) throws ServiceException
{
DefaultLogMessages logMessages = new DefaultLogMessages();
logMessages.addMessage(new DefaultLogMessage("import.summaries", LogMessageTypeEnum.INFO, "instituicao " + Globals.SIGES_INSTITUTION_CODE));
logMessages.addMessage(new DefaultLogMessage("import.summaries", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
logger.info("starting summaries import");
try
{
AbstractDao.getCurrentSession().beginTransaction();
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
SiGesWEB service;
try
{
service = new SiGesWEB(new URL(Globals.SIGES_WEBSERVICE_WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
service = new SiGesWEB(new URL(WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
}
catch (MalformedURLException e)
{
87,7 → 89,7
//comentario de teste
try
{
arrayOfAulas = service.getSiGesWEBSoap().getAulas(Globals.SIGES_INSTITUTION_CODE, year,c.getCode(),DatesUtils.getSemestre());
arrayOfAulas = service.getSiGesWEBSoap().getAulas(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year,c.getCode(),DatesUtils.getSemestre(),null);
break;
}
catch(Throwable t)
131,6 → 133,7
s.setTitulo(aula.getSumTitulo());
s.setDescricao(aula.getSumDescricao());
s.setcEstado(""+aula.getSumCdEstado().intValue());
s.setNumeroHoras("" + aula.getNumeroCelulas().intValue());
}
}
else
180,7 → 183,7
*/
public static void main(String[] args) throws ServiceException
{
String year = DatesUtils.getImportYear();
String year = DaoFactory.getConfigurationDaoImpl().getImportsDefaultImportYearCreateTransaction();
if(args != null && args.length > 0)
year = args[0];
new ImportSumaries().run(year);
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportStudentsService.java
3,18 → 3,20
import jomm.dao.impl.AbstractDao;
import jomm.utils.StringsUtils;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.StaleStateException;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.services.email.SendEmailService;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.common.CommonServicesManager;
import pt.estgp.estgweb.services.email.SendEmailService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.services.common.CommonServicesManager;
import pt.estgp.estgweb.services.jobs.ServiceJob;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.utils.Email;
import pt.ipportalegre.siges.web.services.*;
import pt.utl.ist.berserk.logic.serviceManager.IService;
32,60 → 34,101
* @time 12:51:32
* @see pt.estgp.estgweb
*/
public class ImportStudentsService implements IService
public class ImportStudentsService extends ServiceJob implements IService
{
 
private static final Logger logger = Logger.getLogger(ImportStudentsService.class);
private static final int MAX_COMMIT = 100;
 
int studentsMerged = 0;
int studentsNew = 0;
int studentsZeroUnits = 0;
int unitsNotFound = 0;
int unitsRemovedToStudents = 0;
int unitsLocalAddedNotRemoved = 0;
int unitsLocallyRemovedNotAdded = 0;
int alunosFound = 0;
int studentsChangeBI = 0;
int unitsAddedToStudents = 0;
 
public ILogMessages run(String year) throws ServiceException
{
 
studentsMerged = 0;
studentsNew = 0;
studentsZeroUnits = 0;
unitsNotFound = 0;
unitsRemovedToStudents = 0;
unitsLocalAddedNotRemoved = 0;
unitsLocallyRemovedNotAdded = 0;
alunosFound = 0;
studentsChangeBI = 0;
unitsAddedToStudents = 0;
 
String activeImportYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear();
 
String msgS = "STARTING STUDENTS IMPORT SERVICE FOR YEAR: " + year;
serviceLogInfo(msgS);
logger.info(msgS);
 
DefaultLogMessages logMessages = new DefaultLogMessages();
logMessages.addMessage(new DefaultLogMessage("import.students", LogMessageTypeEnum.INFO, "instituicao " + Globals.SIGES_INSTITUTION_CODE));
logger.info("starting student import");
logMessages.addMessage(new DefaultLogMessage("import.students", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
 
try
{
AbstractDao.getCurrentSession().beginTransaction();
SiGesWEB service;
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
try
{
service = new SiGesWEB(new URL(Globals.SIGES_WEBSERVICE_WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
serviceLogInfo("STARTING WEB SERVICE AT " + WSDL);
service = new SiGesWEB(new URL(WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
}
catch (MalformedURLException e)
{
logger.fatal(e, e);
logMessages.addMessage(new DefaultLogMessage("import.error",e.toString(),"erro na configuracao do WEB Service", LogMessageTypeEnum.INFO));
AbstractDao.getCurrentSession().getTransaction().rollback();
serviceLogFatal(logMessages.getLastMessage(), e);
return logMessages;
}
 
ArrayOfDecimal codigosAlunos = service.getSiGesWEBSoap().getCodigosAlunosInscritosDaInstituicao(Globals.SIGES_INSTITUTION_CODE, year);
ArrayOfDecimal codigosAlunos = service.getSiGesWEBSoap().getCodigosAlunosInscritosDaInstituicao(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year);
List<BigDecimal> codigos = codigosAlunos.getDecimal();
int i = 1;
 
for (BigDecimal c : codigos)
{
alunosFound++;
if (i++ > MAX_COMMIT)
{
i = 0;
setProgress((int) (((float)alunosFound)/((float)codigos.size())*100.0f));
AbstractDao.getCurrentSession().getTransaction().commit();
AbstractDao.getCurrentSession().beginTransaction();
}
 
Aluno d = service.getSiGesWEBSoap().getAlunoInscrito(c, Globals.SIGES_INSTITUTION_CODE, year);
User u = DaoFactory.getUserDaoImpl().loadByUsernameOrSigesCode(d.getCodigo().intValue());
Aluno alunoSiges = service.getSiGesWEBSoap().getAlunoInscrito(c, new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year);
User u = DaoFactory.getUserDaoImpl().loadByUsernameOrSigesCode(alunoSiges.getCodigo().intValue());
Student s = null;
boolean newUser = false;
if(u != null && !(u instanceof Student))
{
logger.warn("Student " + u.getUsername() + "already exist in system, will merge both users");
msgS = "Student " + u.getUsername() + " already exist in system but is not a Student is a standard USER, will merge both users";
studentsMerged++;
serviceLogWarn(msgS);
logger.warn(msgS);
// Set<Record> records = u.getCreatorRecords();
DaoFactory.getUserDaoImpl().delete(u);
logger.warn("Student " + u.getUsername() + "1");
msgS = "Student " + u.getUsername() + "1";
logger.warn(msgS);
serviceLogWarn(msgS);
i = 0;
 
AbstractDao.getCurrentSession().getTransaction().commit();
AbstractDao.getCurrentSession().beginTransaction();
 
AbstractDao.getCurrentSession().beginTransaction();
logger.warn("Student " + u.getUsername() + "2");
msgS = "Student " + u.getUsername() + "2";
logger.warn(msgS);
serviceLogWarn(msgS);
s = DomainObjectFactory.createStudentImpl();
DaoFactory.getStudentDaoImpl().save(s);
// for(Record r:records)
107,7 → 150,7
DaoFactory.getStudentDaoImpl().save(s);
newUser = true;
}
persist(d, s, newUser,year);
persist(alunoSiges, s, newUser,year,activeImportYear);
//Advising CommonsServicesManager before change password
 
if (newUser)
123,66 → 166,216
}
logMessages.addMessage(new DefaultLogMessage("import.students.terminating", LogMessageTypeEnum.INFO));
logger.info("terminating student import");
AbstractDao.getCurrentSession().getTransaction().commit();
serviceLogInfo("terminating student import");
}
catch(StaleStateException e)
{
AbstractDao.getCurrentSession().getTransaction().rollback();
AbstractDao.getCurrentSession().beginTransaction();
logger.error(e,e);
serviceLogError("Rolling back will lost previous updates: " + e.toString(),e);
sendNotificationAdmin("Erro de importacao de alunos",e.toString());
}
catch(HibernateException e)
{
AbstractDao.getCurrentSession().getTransaction().rollback();
AbstractDao.getCurrentSession().beginTransaction();
logger.error(e,e);
serviceLogError("Rolling back will lost previous updates: " + e.toString(),e);
sendNotificationAdmin("Erro de base de dados importacao de alunos, provavelmente chave errada, corrigir no MySql",e.toString());
}
catch(Throwable e)
{
logger.error(e,e);
AbstractDao.getCurrentSession().getTransaction().rollback();
logMessages.addMessage(new DefaultLogMessage("import.error",e.toString(), "see log for details", LogMessageTypeEnum.ERROR));
List<String> emails = new ArrayList<String>();
emails.add(ConfigProperties.getProperty("admin.email"));
List<String> arguments = new ArrayList<String>();
serviceLogError(e.toString(),e);
String cause = e.getCause() == null ? "" : e.getCause().toString();
arguments.add((e.toString() + "\n" + cause).replace("\n","<br/>"));
Email email = new Email("Erro de importação de alunos",emails,"baco@estgp.pt","messageToAdmin_pt.txt",arguments);
new SendEmailService().sendEmail(email);
sendNotificationAdmin("Erro de importacao de alunos",cause);
}
 
 
serviceLogInfo("############################");
serviceLogInfo("############################");
serviceLogInfo("#Students found: " + alunosFound);
serviceLogInfo("#Students New: " + studentsNew);
serviceLogInfo("#Students Merged: " + studentsMerged);
serviceLogInfo("#Students Zero Units: " + studentsZeroUnits);
serviceLogInfo("#Units not found: " + unitsNotFound);
serviceLogInfo("#Units added to Students: " + unitsAddedToStudents);
serviceLogInfo("#Units removed to Students: " + unitsRemovedToStudents);
serviceLogInfo("#Units not Removed because localy added: " + unitsLocalAddedNotRemoved);
serviceLogInfo("#Units not Added because localy removed: " + unitsLocallyRemovedNotAdded);
 
logger.info("############################");
logger.info("############################");
logger.info("#Students found: " + alunosFound);
logger.info("#Students New: " + studentsNew);
logger.info("#Students Merged: " + studentsMerged);
logger.info("#Students Zero Units: " + studentsZeroUnits);
logger.info("#Units not found: " + unitsNotFound);
logger.info("#Units added to Students: " + unitsAddedToStudents);
logger.info("#Units removed to Students: " + unitsRemovedToStudents);
logger.info("#Units not Removed because localy added: " + unitsLocalAddedNotRemoved);
logger.info("#Units not Added because localy removed: " + unitsLocallyRemovedNotAdded);
if(studentsChangeBI>0)
{
serviceLogInfo("#>>>>>AVISO AVISO<<<<<<<<<: ");
serviceLogInfo("#>>>>>AVISO AVISO<<<<<<<<<: ");
serviceLogInfo("#>>>>>NUMEROS DE ALUNOS MUDARAM DE BI<<<<<<<<<: CONSULTAR LOG");
serviceLogInfo("#CODIGO SIGES COM BIs DIFERENTES:" + studentsChangeBI);
logger.info("#>>>>>AVISO AVISO<<<<<<<<<: ");
logger.info("#>>>>>AVISO AVISO<<<<<<<<<: ");
logger.info("#>>>>>NUMEROS DE ALUNOS MUDARAM DE BI<<<<<<<<<: CONSULTAR LOG");
logger.info("#CODIGO SIGES COM BIs DIFERENTES:" + studentsChangeBI);
}
 
setProgress(100);
return logMessages;
}
 
/**
* Envio de Notificação aos operadores do CI
* @param subject
* @param cause
*/
private void sendNotificationAdmin(String subject, String cause)
{
List<String> emails = ConfigProperties.getListValues("admin.email");
for(String email:emails)
{
serviceLogWarn(">>>>>>>>ENVIANDO NOTIFICACAO A ADMINISTRACAO: " + email);
logger.warn(">>>>>>>>ENVIANDO NOTIFICACAO A ADMINISTRACAO: " + email);
}
List<String> arguments = new ArrayList<String>();
arguments.add(cause.replace("\n","<br/>"));
Email email = new Email(subject,emails,Globals.SYSTEM_EMAIL_BOX,"messageToAdmin_pt.txt",arguments);
email.setHtml(true);
try {
new SendEmailService().sendEmail(email);
} catch (ServiceException e) {
e.printStackTrace();
}
}
 
 
 
/**
* Nao esta testado
* jm
*
* @param d Aluno
* @param alunoSiges Aluno
* @param student Student
*/
private void persist(Aluno d, Student student, boolean newUser, String year)
private void persist(Aluno alunoSiges, Student student, boolean newUser, String year, String activeImportYear)
{
if(newUser)
{
student.setName(d.getNome());
student.setEmail(d.getEmail());
student.setSigesCode(d.getCodigo().intValue());
student.setAddress(d.getMorada());
student.setPhonenumber(StringsUtils.cleanKeepNumbers(d.getTelemovel()));
student.setZip("" + d.getCodigoPostal().intValue());
student.setBi(d.getNumeroBi());
student.setSex(d.getSexo());
student.setUserNameNetpa(d.getUsernameNetpa());
student.setBirthDate(d.getDataNascimento().toGregorianCalendar().getTime());
student.setUsername("a" + d.getCodigo().intValue());
studentsNew++;
cloneFields(alunoSiges, student);
serviceLogInfo("NOVO ALUNO ENCONTRADO: siges:" + student.getSigesCode() + " bi:" + student.getBi() + " nome:" + student.getName());
}
//CASO EM QUE O ALUNO NO SIGES FOI ATRIBUIDO A OUTRO ESTUDANTE PARA PREENCHER BURACO NA NUMERACAO
else if(alunoSiges.getNumeroBi() == null || student.getBi() == null || ! alunoSiges.getNumeroBi().equals(student.getBi()))
{
studentsChangeBI++;
 
StringBuilder builder = new StringBuilder();
 
builder.append("ATENCAO NUMERO DE ALUNO " + alunoSiges.getCodigo() + " MUDOU DE DONO VAI SER BLOQUEADO IMEDIATAMENTE\n");
builder.append("ALTERANDO DADOS DO ALUNO " + alunoSiges.getCodigo() + "\n");
builder.append("-----ANTES: " + "\n");
builder.append("-----BI: " + student.getBi() + "\n");
builder.append("-----Nome: " + student.getName() + "\n");
builder.append("-----Username: " + student.getUserNameNetpa() + "\n");
builder.append("-----Address: " + student.getAddress() + "\n");
builder.append("-----Zip: " + student.getZip() + "\n");
builder.append("-----Email: " + student.getEmail() + "\n");
builder.append("-----Phone: " + student.getPhonenumber() + "\n");
 
cloneFields(alunoSiges, student);
 
//todo verificar isto
//student.setAutoBlockMode(false);
//student.setManualBlock(true);
 
builder.append("DEPOIS: " + "\n");
builder.append("BI: " + student.getBi() + "\n");
builder.append("Nome: " + student.getName() + "\n");
builder.append("Username: " + student.getUserNameNetpa() + "\n");
builder.append("Address: " + student.getAddress() + "\n");
builder.append("Zip: " + student.getZip() + "\n");
builder.append("Email: " + student.getEmail() + "\n");
builder.append("Phone: " + student.getPhonenumber() + "\n");
 
serviceLogWarn(builder.toString());
 
sendNotificationAdmin("CODIGO SIGES " + alunoSiges.getCodigo() + " MUDOU DE DONO - FOI BLOQUEADO ",builder.toString());
 
 
}
 
if(alunoSiges.getHistoricos() == null || alunoSiges.getHistoricos().getAlunoHistorico() == null || alunoSiges.getHistoricos().getAlunoHistorico().size() == 0)
{
student.setPropinasEmDia(false);
serviceLogWarn("ATENTION Estudante sem historico de Matriculas para aferir propinas: codigo " + alunoSiges.getCodigo());
logger.warn("ATENTION Estudante sem historico de Matriculas para aferir propinas: codigo " + alunoSiges.getCodigo());
}
else
{
student.setPropinasEmDia(false);
student.setPropinasEmDiaYear(activeImportYear);
 
for(AlunoHistorico hist: alunoSiges.getHistoricos().getAlunoHistorico())
{
if(hist.getCodigoLectivo()!=null && hist.getCodigoLectivo().equals(activeImportYear))
{
if(hist.getPropinaEmDia().equalsIgnoreCase("s"))
{
student.setPropinasEmDia(true);
student.setPropinasEmDiaYear(activeImportYear);
}
break;
}
}
if(!student.isPropinasEmDia())
{
serviceLogWarn("ATENTION Estudante sem propina em dia: codigo " + alunoSiges.getCodigo());
logger.warn("ATENTION Estudante sem propina em dia: codigo " + alunoSiges.getCodigo());
}
}
/*Desta forma as relacoes antigas sao ignoradas cria-se uma lista nova e atribui-se ao Teacher, o Hibernate faz resto e apaga as chaves estrangeiras antigas */
if (d.getDisciplinasInscrito() == null || d.getDisciplinasInscrito().getDisciplina() == null || d.getDisciplinasInscrito().getDisciplina().size() == 0)
logger.warn("ATENTION STUDENT WITH ZERO UNITS: codigo " + d.getCodigo());
if (alunoSiges.getDisciplinasInscrito() == null || alunoSiges.getDisciplinasInscrito().getDisciplina() == null || alunoSiges.getDisciplinasInscrito().getDisciplina().size() == 0)
{
studentsZeroUnits++;
serviceLogWarn("ATENTION STUDENT WITH ZERO UNITS: codigo " + alunoSiges.getCodigo());
logger.warn("ATENTION STUDENT WITH ZERO UNITS: codigo " + alunoSiges.getCodigo());
}
else
{
//1 - PROCEDIMENTO CADEIRAS SAO CARREGADAS DO BACO DA LISTA QUE VEM DO SIGES -> units
//2 - Sao retiradas da lista units as que o aluno tem mas que foram removidas localmente
//3 - Sao adicionadas ao aluno as que o aluno ainda nao tiver da lista units
//4 - Remover da lista do aluno as unidades que não vêm do SIGES e que não foram adicionadas localmente
 
 
//PASSO 1
Set<CourseUnit> units = new HashSet<CourseUnit>();
ArrayOfDisciplina disciplinas = d.getDisciplinasInscrito();
ArrayOfDisciplina disciplinas = alunoSiges.getDisciplinasInscrito();
for (Disciplina disciplina : disciplinas.getDisciplina())
{
CourseUnit courseUnit = DaoFactory.getCourseUnitDaoImpl().loadBySigesCodeUnique("" + disciplina.getCodigo(),"" + disciplina.getCodigoCurso(),disciplina.getCdDuracao(),disciplina.getCdLectivo());
if(courseUnit == null)
{
logger.warn("Unit not found: semestre:" + disciplina.getCdDuracao() + " codigo:" + disciplina.getCodigo() + " course:" + disciplina.getCodigoCurso() + " year:" + disciplina.getCdLectivo());
unitsNotFound++;
String msg = "Unit not found: semestre:" + disciplina.getCdDuracao() + " codigo:" + disciplina.getCodigo() + " course:" + disciplina.getCodigoCurso() + " year:" + disciplina.getCdLectivo();
serviceLogWarn(msg);
logger.warn(msg);
}
else
units.add(courseUnit);
}
 
//PASSO 2
Iterator<CourseUnit> iter = units.iterator();
StudentImpl sImpl = (StudentImpl) DaoFactory.getStudentDaoImpl().narrow(student);
while (iter.hasNext())
192,11 → 385,15
 
if(sImpl.isLocalRemovedUnit(courseUnit))
{
logger.info("Removendo unidade: " + courseUnit.getCode() + " - do aluno: " + student.getSigesCode() + " - Associacao existe no SIGES mas foi removido LOCALMENTE");
unitsLocallyRemovedNotAdded++;
String msg = "Removendo unidade: " + ((CourseUnitImpl)courseUnit).getSigesUniqueIdentifiers() + " - do aluno: " + student.getSigesCode() + " - Associacao existe no SIGES mas foi removido LOCALMENTE";
serviceLogInfo(msg);
logger.info(msg);
iter.remove();
}
}
 
//PASSO 3
if(student.getSubscribedUnits() != null)
{
for(CourseUnit c: units)
211,12 → 408,19
}
}
if(!isIn)
{
String msg = "Adicionando unidade: " + ((CourseUnitImpl)c).getSigesUniqueIdentifiers() + " - ao aluno: " + student.getSigesCode() + " - Associacao nova no SIGES";
serviceLogInfo(msg);
logger.info(msg);
unitsAddedToStudents++;
student.getSubscribedUnits().add(c);
}
}
}
else
student.setSubscribedUnits(units);
 
//PASSO 4
//Remover unidades deste ano que nao vem do SIGES e que nao foram adicionadas localmente
Iterator<CourseUnit> iterNowUnits = student.getSubscribedUnits().iterator();
while(iterNowUnits.hasNext())
245,12 → 449,18
 
if(!sImpl.isLocalUnit(cUNow))
{
logger.info("Removendo unidade: " + cUNow.getCode() + " - do aluno: " + student.getSigesCode() + " - Associacao desapareceu do SIGES");
String msg = "Removendo unidade: " + ((CourseUnitImpl)cUNow).getSigesUniqueIdentifiers() + " - do aluno: " + student.getSigesCode() + " - Associacao desapareceu do SIGES";
serviceLogInfo(msg);
logger.info(msg);
iterNowUnits.remove();
unitsRemovedToStudents++;
}
else
{
logger.info("NAO REMOVIDA - Unidade: " + cUNow.getCode() + " - do aluno: " + student.getSigesCode() + " - Associacao desapareceu do SIGES mas foi adicionada localmente");
String msg = "NAO REMOVIDA - Unidade: " + ((CourseUnitImpl)cUNow).getSigesUniqueIdentifiers() + " - do aluno: " + student.getSigesCode() + " - Associacao desapareceu do SIGES mas foi adicionada localmente";
serviceLogInfo(msg);
logger.info(msg);
unitsLocalAddedNotRemoved++;
}
}
}
258,6 → 468,30
}
}
 
private void cloneFields(Aluno alunoSiges, Student student) {
student.setName(alunoSiges.getNome());
student.setEmail(alunoSiges.getEmail());
student.setSigesCode(alunoSiges.getCodigo().intValue());
student.setAddress(alunoSiges.getMorada());
student.setPhonenumber(StringsUtils.cleanKeepNumbers(alunoSiges.getTelemovel()));
student.setZip("" + alunoSiges.getCodigoPostal().intValue());
student.setBi(alunoSiges.getNumeroBi());
student.setSex(alunoSiges.getSexo());
student.setUserNameNetpa(alunoSiges.getUsernameNetpa());
student.setBirthDate(alunoSiges.getDataNascimento().toGregorianCalendar().getTime());
student.setUsername("a" + alunoSiges.getCodigo().intValue());
}
 
public static final String JOB_importYear_KEY = "JOB_importYear_KEY";
 
@Override
protected void runJobServiceTask() throws Throwable {
 
String importYear = (String) getParametersMap().get(JOB_importYear_KEY).getObject();
run(importYear);
 
}
 
/**
* Testar por aqui poi requer Super Role e assim e' autmatico
*
267,11 → 501,13
 
public static void main(String[] args) throws ServiceException
{
String year = DatesUtils.getImportYear();
System.out.println("YEAR:" + year);
String year = DaoFactory.getConfigurationDaoImpl().getImportsDefaultImportYearCreateTransaction();
System.out.println("YEAR:" + year);
if(args != null && args.length > 0)
year = args[0];
AbstractDao.getCurrentSession().beginTransaction();
new ImportStudentsService().run(year);
AbstractDao.getCurrentSession().getTransaction().commit();
}
}
 
/impl/src/java/pt/estgp/estgweb/services/sigesimports/LoadSumariesToPDF.java
New file
0,0 → 1,256
package pt.estgp.estgweb.services.sigesimports;
 
import jomm.dao.impl.AbstractDao;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.CourseUnitSummary;
import pt.estgp.estgweb.domain.DomainObjectFactory;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.enums.LangEnum;
import pt.estgp.estgweb.services.email.EMAILJob;
import pt.estgp.estgweb.services.email.SendEmailService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.services.jobs.JobScheduleService;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.ipportalegre.siges.web.services.ArrayOfAula;
import pt.ipportalegre.siges.web.services.Aula;
import pt.ipportalegre.siges.web.services.SiGesWEB;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import javax.xml.namespace.QName;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
 
/**
* @author Jorge Machado
* @date 11/May/2008
* @time 12:51:32
* @see pt.estgp.estgweb
*/
public class LoadSumariesToPDF implements IService
{
 
private static final Logger logger = Logger.getLogger(LoadSumariesToPDF.class);
 
private static final int MAX_COMMIT = 100;
 
private List<Long> newSummaries = new ArrayList<Long>();
 
public ILogMessages load(long courseUnitId)
{
 
 
DefaultLogMessages logMessages = new DefaultLogMessages();
logMessages.addMessage(new DefaultLogMessage("import.summaries", LogMessageTypeEnum.INFO, "courseunit id:" + courseUnitId));
SiGesWEB service;
try
{
//service = new SiGesWEB(new URL(Globals.SIGES_WEBSERVICE_WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
service = new SiGesWEB(new URL("http://127.0.0.1:8080/SigesWeb/SiGesWEB.asmx?wsdl"), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
}
catch (MalformedURLException e)
{
logMessages.addMessage(new DefaultLogMessage("import.error",e.toString(),"erro na configuracao do WEB Service", LogMessageTypeEnum.INFO));
logger.fatal(e, e);
return logMessages;
}
AbstractDao.getCurrentSession().beginTransaction();
CourseUnit c = DaoFactory.getCourseUnitDaoImpl().get(courseUnitId);
ArrayOfAula arrayOfAulas = service.getSiGesWEBSoap().getAulas(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), c.getImportYear(),c.getCode(),c.getSemestre(),c.getCourse().getCode());
 
if(arrayOfAulas != null && arrayOfAulas.getAula() != null)
{
List<CourseUnitSummary> summaries = new ArrayList<CourseUnitSummary>();
logMessages.setSummaries(summaries);
for(Aula aula: arrayOfAulas.getAula())
{
CourseUnitSummary s = DomainObjectFactory.createCourseUnitSummaryImpl();
summaries.add(s);
 
s.setCodigoSumario(""+aula.getCodigoSumario().intValue());
s.setCodigoAula(""+aula.getSumNumeroAula().intValue());
s.setNumeroAula(aula.getSumNumeroAula().intValue());
s.setDataAula(aula.getData().toGregorianCalendar().getTime());
s.setTipoAula(aula.getSumTipoAula());
s.setCodigoSalaAula("" + aula.getAulaCodigoSalaAula().intValue());
s.setAlunosPresentes(aula.getSumNumeroAlunos().intValue());
s.setTitulo(aula.getSumTitulo());
s.setDescricao(aula.getSumDescricao());
s.setcEstado(""+aula.getSumCdEstado().intValue());
s.setNumeroHoras("" + aula.getNumeroCelulas().intValue());
}
}
else
logger.error("Summaries come null in unit:" + c.getCode());
 
AbstractDao.getCurrentSession().getTransaction().commit();
return logMessages;
}
public ILogMessages run(String year) throws ServiceException
{
DefaultLogMessages logMessages = new DefaultLogMessages();
logMessages.addMessage(new DefaultLogMessage("import.summaries", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
logger.info("starting summaries import");
try
{
AbstractDao.getCurrentSession().beginTransaction();
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
SiGesWEB service;
try
{
service = new SiGesWEB(new URL(WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
}
catch (MalformedURLException e)
{
logMessages.addMessage(new DefaultLogMessage("import.error",e.toString(),"erro na configuracao do WEB Service", LogMessageTypeEnum.INFO));
logger.fatal(e, e);
return logMessages;
}
 
int i = 0;
List<Long> cUs = DaoFactory.getCourseUnitDaoImpl().loadIds(year,DatesUtils.getSemestre());
for(Long cId: cUs)
{
if (i++ > MAX_COMMIT)
{
i = 0;
AbstractDao.getCurrentSession().getTransaction().commit();
AbstractDao.getCurrentSession().beginTransaction();
}
CourseUnit c = DaoFactory.getCourseUnitDaoImpl().load(cId);
logMessages.addMessage(new DefaultLogMessage("import.info","","Importing Summaries to CourseUnit: " + c.getCode() + ": course: " + c.getCourse().getCode(), LogMessageTypeEnum.INFO));
logger.info("Importing Summaries to CourseUnit: " + c.getName() + " (" + c.getCode() + ") course " + c.getCourse().getName() + " (" + c.getCourse().getCode() + ")");
 
int tries = 3;
ArrayOfAula arrayOfAulas = null;
while(tries > 0)
{
//comentario de teste
try
{
arrayOfAulas = service.getSiGesWEBSoap().getAulas(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year,c.getCode(),DatesUtils.getSemestre(),c.getCourse().getCode());
break;
}
catch(Throwable t)
{
if(tries-- == 0)
{
logger.error("Giving up of courseUnit:" + cId + " ( " + c.getName() + " ) ",t);
break;
}
 
logger.error("WebService Fail, trying " + tries + " times sleeping a while");
Thread.sleep(5000);
}
}
if(arrayOfAulas != null && arrayOfAulas.getAula() != null)
{
HashMap<String, CourseUnitSummary> map = new HashMap<String, CourseUnitSummary>();
if(c.getSummaries() != null && c.getSummaries().size() > 0)
for(CourseUnitSummary s: c.getSummaries())
map.put(s.getCodigoAula() + ":" + s.getCodigoSumario(),s);
else
c.setSummaries(new HashSet<CourseUnitSummary>());
for(Aula aula: arrayOfAulas.getAula())
{
CourseUnitSummary s = map.get(aula.getSumNumeroAula() + ":" + aula.getCodigoSumario());
if(s == null)
{
s = DomainObjectFactory.createCourseUnitSummaryImpl();
s.setCourseUnit(c);
c.getSummaries().add(s);
DaoFactory.getCourseUnitSummaryDaoImpl().save(s);
newSummaries.add(s.getId());
}
s.setCodigoSumario(""+aula.getCodigoSumario().intValue());
s.setCodigoAula(""+aula.getSumNumeroAula().intValue());
s.setNumeroAula(aula.getSumNumeroAula().intValue());
s.setDataAula(aula.getData().toGregorianCalendar().getTime());
s.setTipoAula(aula.getSumTipoAula());
s.setCodigoSalaAula("" + aula.getAulaCodigoSalaAula().intValue());
s.setAlunosPresentes(aula.getSumNumeroAlunos().intValue());
s.setTitulo(aula.getSumTitulo());
s.setDescricao(aula.getSumDescricao());
s.setcEstado(""+aula.getSumCdEstado().intValue());
}
}
else
logger.error("Summaries come null in unit:" + c.getCode());
}
sendEmail(null);
AbstractDao.getCurrentSession().getTransaction().commit();
}
catch (Throwable e)
{
logger.error(e, e);
AbstractDao.getCurrentSession().getTransaction().rollback();
logMessages.addMessage(new DefaultLogMessage("import.error", e.toString(), "see log for details", LogMessageTypeEnum.ERROR));
throw new ServiceException(e.toString(), e);
}
 
logMessages.addMessage(new DefaultLogMessage("import.summaries.terminating", LogMessageTypeEnum.INFO));
logger.info("terminating summaries import");
return logMessages;
}
 
 
public static SendEmailService sendEmailService = new SendEmailService();
 
private void sendEmail(UserSession userSession)
{
if(Globals.EMAIL_SUMMARIES && newSummaries.size() > 0)
{
for(long id: newSummaries)
{
CourseUnitSummary summary = DaoFactory.getCourseUnitSummaryDaoImpl().load(id);
List<String> emails = DaoFactory.getCourseUnitSummaryDaoImpl().getStudentsEmails(summary.getId());
if(emails == null)
logger.warn("No students emails in unit: code:" + summary.getCourseUnit().getCode() + " " + summary.getCourseUnit().getName());
EMAILJob emailJob = new EMAILJob(sendEmailService.getSummaryEmail(emails,summary,summary.getCourseUnit(), LangEnum.PORTUGUESE));
JobScheduleService.getInstance().scheduleNow(emailJob,"New Summary EMAIL from: " + summary.getCourseUnit().getName() + " aula: " +summary.getNumeroAula() ,userSession);
}
}
}
 
/**
* Testar por aqui poi requer Super Role e assim e' autmatico
*
*
* @param args of main
* @throws pt.estgp.estgweb.services.expceptions.ServiceException on error
*/
/*public static void main(String[] args) throws ServiceException
{
String year = DatesUtils.getImportYear();
if(args != null && args.length > 0)
year = args[0];
new LoadSumariesToPDF().run(year);
}*/
public static void main(String[] args) throws ServiceException
{
 
ILogMessages m = new LoadSumariesToPDF().load(4136);
List<CourseUnitSummary> su = m.getSummaries();
for(CourseUnitSummary s: su)
{
System.out.println(s.toString());
}
//m.toString();
 
 
}
 
 
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/services/sigesimports/SincronizeLastYearCourseUnitProgramsService.java
1,22 → 1,20
package pt.estgp.estgweb.services.sigesimports;
 
import com.lowagie.text.pdf.SimpleBookmark;
import jomm.dao.impl.AbstractDao;
import org.apache.fop.apps.FOPException;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.CourseUnitView;
import pt.estgp.estgweb.services.courseunits.SaveCourseUnitProgram;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.services.jobs.ServiceJob;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.utl.ist.berserk.logic.serviceManager.IService;
import sun.tools.java.Imports;
 
import javax.xml.transform.TransformerException;
import java.io.IOException;
28,10 → 26,15
/**
* @author Jorge Machado
*/
public class SincronizeLastYearCourseUnitProgramsService implements IService
public class SincronizeLastYearCourseUnitProgramsService extends ServiceJob implements IService
{
private static final Logger logger = Logger.getLogger(SincronizeLastYearCourseUnitProgramsService.class);
private static final int MAX_COMMIT = 100;
 
public ILogMessages run(String year,boolean cloneOnlyNews,boolean generateAllPdfs) throws ServiceException
{
return run( year, cloneOnlyNews, generateAllPdfs,false);
}
 
/**
* DESCRICAO DE SERVICO
53,30 → 56,46
* @return
* @throws ServiceException
*/
public ILogMessages run(String year,boolean cloneOnlyNews,boolean generateAllPdfs) throws ServiceException
public ILogMessages run(String year,boolean cloneOnlyNews,boolean generateAllPdfs,boolean validate) throws ServiceException
{
 
System.out.println("Using year = " + year);
System.out.println("Using only news = " + cloneOnlyNews);
String msgS = "STARTING SUMARIES IMPORT SERVICE FOR year: " + year + " cloneOnlyNews: " + cloneOnlyNews + " generateAllPdfs: " + generateAllPdfs + " validate: " + validate;
serviceLogInfo(msgS);
logger.info(msgS);
 
int foundTotal = 0;
int found = 0;
int updated=0;
List<String> naoAfectadasPermissao = new ArrayList<String>();
List<String> clonados = new ArrayList<String>();
List<String> foundnprog = new ArrayList<String>();
List<String> nfound = new ArrayList<String>();
List<String> notChangedNotNew = new ArrayList<String>();
 
String importYearBefore = DatesUtils.getImportYearBefore(year);
DefaultLogMessages logMessages = new DefaultLogMessages();
try
{
logMessages.addMessage(new DefaultLogMessage("courseunitprograms.sincronization", LogMessageTypeEnum.INFO, "instituicao " + Globals.SIGES_INSTITUTION_CODE));
logger.info("S1");
logMessages.addMessage(new DefaultLogMessage("courseunitprograms.sincronization", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
serviceLogInfo(logMessages.getLastMessage());
 
int i = 0;
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadYear(year);
for (CourseUnit cu: units)
{
 
SaveCourseUnitProgram service = new SaveCourseUnitProgram();
 
foundTotal++;
 
if (i++ > MAX_COMMIT)
{
i = 0;
setProgress((int) (((float)foundTotal)/((float)units.size())*100.0f));
AbstractDao.getCurrentSession().getTransaction().commit();
AbstractDao.getCurrentSession().beginTransaction();
serviceLogInfo("Commiting database");
}
if(cu.getCourseUnitProgram() == null || !cloneOnlyNews)
{
 
84,7 → 103,10
if(lista != null && lista.size() > 0)
{
 
logger.info("OK - Unit siges: " + cu.getCode() + " without program will try found old to clone");
String msg = "OK - Unit siges: " + cu.getCode() + " without program will try found old to clone";
logger.info(msg);
serviceLogInfo(msg);
 
CourseUnit cuOld = lista.get(0);
if(cuOld.getCourseUnitProgram() != null)
{
96,71 → 118,152
 
if(cu.getCourseUnitProgram() == null)
{
serviceLogInfo("Ficha NOVA nao existe vai tentar clonar");
novaFicha = true;
CourseUnitProgram program = new CourseUnitProgramImpl();
DaoFactory.getCourseUnitProgramDaoImpl().save(program);
program.setCourseUnitProgramPart2(new CourseUnitProgramPart2Impl());
DaoFactory.getCourseUnitProgramPart2DaoImpl().save(program.getCourseUnitProgramPart2());
cu.setCourseUnitProgram(program);
cu.setValidProgram(false);
}
 
//So clona a ficha no caso de n�o estar validada pelo CC
//So clona a ficha no caso de nao estar validada pelo CC
if(novaFicha || (!cu.isValidProgram() && !cloneOnlyNews))
{
updated++;
((CourseUnitProgramImpl)cu.getCourseUnitProgram()).cloneFrom(cuOld.getCourseUnitProgram());
CourseUnitProgramImpl cProgram = (CourseUnitProgramImpl) DaoFactory.getCourseUnitProgramDaoImpl().narrow(cu.getCourseUnitProgram());
cProgram.cloneFrom(cuOld.getCourseUnitProgram());
List<String> errors = new ArrayList<String>();
clonados.add(cu.getCode());
service.createPdf(cu,errors);
if(errors.size() > 0)
{
for(String error:errors)
serviceLogError(error);
}
cu.setValidProgram(validate);
}
else
{
naoAfectadasPermissao.add(cu.getCode());
if(cu.isValidProgram())
serviceLogInfo("Ficha nao alterada. razao: VALIDADA");
else
serviceLogInfo("Ficha nao alterada. razao: cloneOnlyNews=true");
}
 
}
else
{
foundnprog.add(cu.getCode());
 
String msgN = "FOUND OLD Unit siges: " + cu.getCode() + " OK but NO program to clone";
logger.warn(msgN);
serviceLogWarn(msgN);
}
}
else
{
nfound.add(cu.getCode());
logger.info("NOT FOUND - Unit siges: " + cu.getCode() + " without program don't have old to clone");
String msg = "NOT FOUND OLD for - Unit siges: " + cu.getCode();
logger.info(msg);
serviceLogWarn(msg);
}
}
else if(generateAllPdfs)
else
{
List<String> errors = new ArrayList<String>();
if(cu.getCourseUnitProgram() != null)
service.createPdf(cu,errors);
notChangedNotNew.add(cu.getCode());
serviceLogInfo("Ficha nao alterada. razao: cloneOnlyNews=true");
if(generateAllPdfs)
{
List<String> errors = new ArrayList<String>();
if(cu.getCourseUnitProgram() != null)
service.createPdf(cu,errors);
}
}
 
cu.setValidProgram(true);
//cu.setValidProgram(true);
}
logger.info("######################################");
serviceLogInfo("######################################");
logger.info("######################################");
serviceLogInfo("######################################");
logger.info("STATS " + year);
logger.info("Total: " + foundTotal);
logger.info("Programas alterados: " + updated);
logger.info("Previous Unit Found with program : " + found);
logger.info("Previous Unit Found without program: " + foundnprog.size());
logger.info("Previous Unit Not Found: " + nfound.size());
logger.info("### Found No Prog:");
serviceLogInfo("STATS " + year);
logger.info("Total Analisadas: " + foundTotal);
serviceLogInfo("Total Analisadas: " + foundTotal);
logger.info("CANDIDATAS - Unidades antigas encontrada com programa : " + found);
serviceLogInfo("CANDIDATAS - Unidades antigas encontrada com programa : " + found);
logger.info("NADA FEITO - Unidade antiga encontrada mas sem programa: " + foundnprog.size());
serviceLogInfo("NADA FEITO - Unidade antiga encontrada mas sem programa: " + foundnprog.size());
logger.info("NADA FEITO - Unidade antiga nao encontrada: " + nfound.size());
serviceLogInfo("NADA FEITO - Unidade antiga nao encontrada: " + nfound.size());
logger.info("OK - Programas CLONADOS: " + updated);
serviceLogInfo("OK - Programas CLONADOS: " + updated);
logger.info("NAO CLONADOS - NAO PERMITIDOS JA EXISTIAM VALIDADOS: " + naoAfectadasPermissao.size());
serviceLogInfo("NAO CLONADOS - NAO PERMITIDOS JA EXISTIAM VALIDADOS: " + naoAfectadasPermissao.size());
 
 
 
if(cloneOnlyNews)
{
logger.info("NAO PERMITIDA (cloneOnlyNews = true) - Nao alterada por ja existir programa: " + notChangedNotNew.size());
serviceLogInfo("NAO PERMITIDA (cloneOnlyNews = true) - Nao alterada por ja existir programa: " + notChangedNotNew.size());
}
 
logger.info("######################################");
logger.info("###NAO CLONADOS - NAO PERMITIDOS JA EXISTIAM VALIDADOS (SIGES CODE):");
serviceLogInfo("######################################");
serviceLogInfo("###NAO CLONADOS - NAO PERMITIDOS JA EXISTIAM VALIDADOS (SIGES CODE):");
for(String c : naoAfectadasPermissao)
{
logger.info(c);
serviceLogInfo(c);
}
logger.info("###OK - Programas CLONADOS (SIGES CODE):");
serviceLogInfo("###OK - Programas CLONADOS (SIGES CODE):");
for(String c : clonados)
{
logger.info(c);
serviceLogInfo(c);
}
 
logger.info("###NADA FEITO - Unidade antiga encontrada sem programa (SIGES CODE):");
serviceLogInfo("###NADA FEITO - Unidade antiga encontrada sem programa (SIGES CODE):");
for(String c : foundnprog)
{
logger.info(c);
serviceLogInfo(c);
}
logger.info("### Not Found:");
logger.info("###NADA FEITO - Unidade antiga nao encontrada (SIGES CODE):");
serviceLogInfo("###NADA FEITO - Unidade antiga nao encontrada (SIGES CODE):");
for(String c : nfound)
{
logger.info(c);
serviceLogInfo(c);
}
 
if(cloneOnlyNews)
{
logger.info("###NAO PERMITIDA (cloneOnlyNews) - Nao alterada por ja existir programa (SIGES CODE):");
serviceLogInfo("###NAO PERMITIDA (cloneOnlyNews) - Nao alterada por ja existir programa (SIGES CODE):");
for(String c : notChangedNotNew)
{
logger.info(c);
serviceLogInfo(c);
}
}
 
}
catch (Throwable e)
{
logger.error(e,e);
logMessages.addMessage(new DefaultLogMessage("import.error",e.toString(), "see log for details", LogMessageTypeEnum.ERROR));
serviceLogError(e.toString(),e);
}
logger.info("terminating programs sincronization");
serviceLogInfo("terminating programs sincronization");
logMessages.addMessage(new DefaultLogMessage("courseunitprograms.sincronization.terminating", LogMessageTypeEnum.INFO));
setProgress(100);
return logMessages;
}
 
244,14 → 347,15
cuInto.setCourseUnitProgram(program);
cuInto.setValidProgram(false);
}
logger.info("AQUI");
((CourseUnitProgramImpl)cuInto.getCourseUnitProgram()).cloneFrom(cuFrom.getCourseUnitProgram());
DaoFactory.getCourseUnitProgramDaoImpl().saveOrUpdate(((CourseUnitProgramImpl)cuInto.getCourseUnitProgram()));
DaoFactory.getCourseUnitProgramPart2DaoImpl().saveOrUpdate(((CourseUnitProgramImpl)cuInto.getCourseUnitProgram()).getCourseUnitProgramPart2());
CourseUnitProgramImpl cProgram = (CourseUnitProgramImpl) DaoFactory.getCourseUnitProgramDaoImpl().narrow(cuInto.getCourseUnitProgram());
cProgram.cloneFrom(cuFrom.getCourseUnitProgram());
DaoFactory.getCourseUnitProgramDaoImpl().saveOrUpdate((cuInto.getCourseUnitProgram()));
DaoFactory.getCourseUnitProgramPart2DaoImpl().saveOrUpdate((cuInto.getCourseUnitProgram()).getCourseUnitProgramPart2());
 
SaveCourseUnitProgram service = new SaveCourseUnitProgram();
List<String> errors = new ArrayList<String>();
try {
//Cria PDF's e envia-os para o i.online
service.createPdf(cuInto,errors);
} catch (IOException e) {
e.printStackTrace();
266,7 → 370,7
 
public static void main(String[] args) throws ServiceException
{
String year = DatesUtils.getImportYear();
String year = DaoFactory.getConfigurationDaoImpl().getImportsDefaultImportYearCreateTransaction();
if(args != null && args.length > 0)
year = args[0];
boolean cloneOnlyNews = true;
281,4 → 385,27
}
 
 
public static final String JOB_importYear_KEY = "JOB_importYear_KEY";
public static final String JOB_cloneOnlyNews_KEY = "JOB_cloneOnlyNews_KEY";
public static final String JOB_generateAllPdfs_KEY = "JOB_generateAllPdfs_KEY";
public static final String JOB_validate_KEY = "JOB_validade_KEY";
 
/**
* Parameters for ServiceJob
* importYear : String
* cloneOnlyNews : Boolean
* generateAllPdfs : Boolean
*
* @throws Throwable
*/
@Override
protected void runJobServiceTask() throws Throwable
{
String importYear = (String) getParametersMap().get(JOB_importYear_KEY).getObject();
Boolean cloneOnlyNews = (Boolean) getParametersMap().get(JOB_cloneOnlyNews_KEY).getObject();
Boolean generateAllPdfs = (Boolean) getParametersMap().get(JOB_generateAllPdfs_KEY).getObject();
Boolean validate = (Boolean) getParametersMap().get(JOB_validate_KEY).getObject();
run(importYear,cloneOnlyNews,generateAllPdfs,validate);
}
 
}
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportTeachersService.java
2,21 → 2,20
 
import jomm.dao.impl.AbstractDao;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.StaleStateException;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.DomainObjectFactory;
import pt.estgp.estgweb.domain.Teacher;
import pt.estgp.estgweb.domain.TeacherImpl;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.common.CommonServicesManager;
import pt.estgp.estgweb.services.email.SendEmailService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.services.jobs.ServiceJob;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.utils.Email;
import pt.ipportalegre.siges.web.services.ArrayOfDecimal;
import pt.ipportalegre.siges.web.services.Disciplina;
36,47 → 35,107
* @time 12:51:32
* @see pt.estgp.estgweb
*/
public class ImportTeachersService implements IService
public class ImportTeachersService extends ServiceJob implements IService
{
 
private static final Logger logger = Logger.getLogger(ImportTeachersService.class);
 
private static final int MAX_COMMIT = 100;
 
//int studentsMerged = 0;
int teachersNew = 0;
int teachersZeroUnits = 0;
int unitsNotFound = 0;
int unitsAddedToTeachers = 0;
int unitsRemovedToTeachers = 0;
int unitsLocalAddedNotRemoved = 0;
int teachersFound = 0;
int teachersChangeBI = 0;
int unitsLocallyRemovedNotAdded = 0;
 
//todo meter a zero no run
 
public ILogMessages run(String year) throws ServiceException
{
 
teachersNew = 0;
teachersZeroUnits = 0;
unitsNotFound = 0;
unitsAddedToTeachers = 0;
unitsRemovedToTeachers = 0;
unitsLocalAddedNotRemoved = 0;
teachersFound = 0;
teachersChangeBI = 0;
unitsLocallyRemovedNotAdded = 0;
 
String msgS = "STARTING TEACHERS IMPORT SERVICE FOR YEAR: " + year;
serviceLogInfo(msgS);
logger.info(msgS);
 
DefaultLogMessages logMessages = new DefaultLogMessages();
logMessages.addMessage(new DefaultLogMessage("import.teachers", LogMessageTypeEnum.INFO, "instituicao " + Globals.SIGES_INSTITUTION_CODE));
logger.info("starting teacher import");
logMessages.addMessage(new DefaultLogMessage("import.teachers", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
 
try
{
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
SiGesWEB service;
try
{
service = new SiGesWEB(new URL(Globals.SIGES_WEBSERVICE_WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
serviceLogInfo("STARTING WEB SERVICE AT " + WSDL);
service = new SiGesWEB(new URL(WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
}
catch (MalformedURLException e)
{
logMessages.addMessage(new DefaultLogMessage("import.error", e.toString(), "erro na configuracao do WEB Service", LogMessageTypeEnum.INFO));
logger.fatal(e, e);
serviceLogFatal(logMessages.getLastMessage(), e);
return logMessages;
}
ArrayOfDecimal codigosDocentes = service.getSiGesWEBSoap().getCodigosDocentesInscritosDaInstituicao(Globals.SIGES_INSTITUTION_CODE, year);
ArrayOfDecimal codigosDocentes = service.getSiGesWEBSoap().getCodigosDocentesInscritosDaInstituicao(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year);
List<BigDecimal> codigos = codigosDocentes.getDecimal();
 
int i = 1;
for (BigDecimal c : codigos)
{
Docente d = service.getSiGesWEBSoap().getDocente(c, Globals.SIGES_INSTITUTION_CODE, year);
logger.info("Codigo Funcionario Importado:" + d.getCodigoFuncionario().intValue() + " email IPP SIGES: " + d.getEmail());
 
teachersFound++;
if (i++ > MAX_COMMIT)
{
i = 0;
setProgress((int) (((float)teachersFound)/((float)codigos.size())*100.0f));
AbstractDao.getCurrentSession().getTransaction().commit();
AbstractDao.getCurrentSession().beginTransaction();
}
 
 
Docente d = service.getSiGesWEBSoap().getDocente(c, new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year);
logger.info("Codigo Funcionario Importado: SIGES(" + d.getCodigoFuncionario().intValue() + ") email IPP SIGES: " + d.getEmail());
logger.info("SIGES IMPORTED INFO: " + docenteToString(d));
Teacher t = DaoFactory.getTeacherDaoImpl().loadBySigesCode(d.getCodigoFuncionario().intValue());
boolean newUser = false;
if (t == null)
{
msgS = "Teacher does not exist in baco, will create SIGES:" + d.getCodigoFuncionario().intValue();
logger.info(msgS);
serviceLogInfo(msgS);
 
t = DomainObjectFactory.createTeacherImpl();
DaoFactory.getTeacherDaoImpl().save(t);
newUser = true;
teachersNew++;
}
logger.info("Importing: (" + t.getUsername() + ") " + t.getName());
else
{
msgS = "Teacher EXIST in baco with SIGES: " + d.getCodigoFuncionario().intValue();
logger.info(msgS);
//serviceLogInfo(msgS); //NOT NEED EXCESS OF INFORMATION
}
msgS = "Will persist SIGES(" + d.getCodigoFuncionario().intValue() + ") baco (username:" + t.getUsername() + ") baco name:" + t.getName();
logger.info(msgS);
serviceLogInfo(msgS);
try
{
persist(d, t, newUser);
persist(d, t, newUser,year);
}
catch (Exception e)
{
93,85 → 152,337
t.setPassword(password);
}
}
 
}
catch(StaleStateException e)
{
AbstractDao.getCurrentSession().getTransaction().rollback();
AbstractDao.getCurrentSession().beginTransaction();
logger.error(e,e);
serviceLogError("Rolling back will lost previous updates: " + e.toString(),e);
sendNotificationAdmin("Erro de importacao de docentes",e.toString());
}
catch(HibernateException e)
{
AbstractDao.getCurrentSession().getTransaction().rollback();
AbstractDao.getCurrentSession().beginTransaction();
logger.error(e,e);
serviceLogError("Rolling back will lost previous updates: " + e.toString(),e);
sendNotificationAdmin("Erro de base de dados importacao de docentes, provavelmente chave errada, corrigir no MySql",e.toString());
}
catch (Throwable e)
{
logMessages.addMessage(new DefaultLogMessage("import.error", e.toString(), "see log for details", LogMessageTypeEnum.ERROR));
logger.error(e, e);
throw new ServiceException(e.toString(), e);
}
 
 
 
 
 
 
serviceLogInfo("############################");
serviceLogInfo("############################");
serviceLogInfo("#Teachers found: " + teachersFound);
serviceLogInfo("#Teachers New: " + teachersNew);
serviceLogInfo("#Teachers Zero Units: " + teachersZeroUnits);
serviceLogInfo("#Units not found: " + unitsNotFound);
serviceLogInfo("#Units removed to Teachers: " + unitsRemovedToTeachers);
serviceLogInfo("#Units added to Teachers: " + unitsAddedToTeachers);
serviceLogInfo("#Units not Removed because localy added: " + unitsLocalAddedNotRemoved);
serviceLogInfo("#Units not Added because localy removed: " + unitsLocallyRemovedNotAdded);
 
logger.info("############################");
logger.info("############################");
logger.info("#Teachers found: " + teachersFound);
logger.info("#Teachers New: " + teachersNew);
logger.info("#Teachers Zero Units: " + teachersZeroUnits);
logger.info("#Units not found: " + unitsNotFound);
logger.info("#Units removed to Teachers: " + unitsRemovedToTeachers);
logger.info("#Units added to Teachers: " + unitsAddedToTeachers);
logger.info("#Units not Removed because localy added: " + unitsLocalAddedNotRemoved);
logger.info("#Units not Added because localy removed: " + unitsLocallyRemovedNotAdded);
 
 
if(teachersChangeBI>0)
{
serviceLogInfo("#>>>>>AVISO AVISO<<<<<<<<<: ");
serviceLogInfo("#>>>>>AVISO AVISO<<<<<<<<<: ");
serviceLogInfo("#>>>>>NUMEROS DE PROFESSORES MUDARAM DE BI<<<<<<<<<: CONSULTAR LOG");
serviceLogInfo("#CODIGO SIGES COM BIs DIFERENTES:" + teachersChangeBI);
 
logger.info("#>>>>>AVISO AVISO<<<<<<<<<: ");
logger.info("#>>>>>AVISO AVISO<<<<<<<<<: ");
logger.info("#>>>>>NUMEROS DE PROFESSORES MUDARAM DE BI<<<<<<<<<: CONSULTAR LOG");
logger.info("#CODIGO SIGES COM BIs DIFERENTES:" + teachersChangeBI);
}
setProgress(100);
 
logMessages.addMessage(new DefaultLogMessage("import.teachers.terminating", LogMessageTypeEnum.INFO));
logger.info("terminating teacher import");
serviceLogInfo("terminating teacher import");
return logMessages;
}
 
 
/**
* Envio de Notificação aos operadores do CI
* @param subject
* @param cause
*/
private void sendNotificationAdmin(String subject, String cause)
{
//todo JOB
 
List<String> emails = ConfigProperties.getListValues("admin.email");
for(String email:emails)
{
serviceLogWarn(">>>>>>>>ENVIANDO NOTIFICACAO A ADMINISTRACAO: " + email);
logger.warn(">>>>>>>>ENVIANDO NOTIFICACAO A ADMINISTRACAO: " + email);
}
List<String> arguments = new ArrayList<String>();
arguments.add(cause.replace("\n","<br/>"));
Email email = new Email(subject,emails,Globals.SYSTEM_EMAIL_BOX,"messageToAdmin_pt.txt",arguments);
email.setHtml(true);
try {
new SendEmailService().sendEmail(email);
} catch (ServiceException e) {
e.printStackTrace();
}
 
}
 
/**
* Implementação local do toString para a class Docente que foi gerada pelos web-services
* @param d
* @return
*/
 
public String docenteToString(Docente d)
{
return "Docente{" +
"codigoFuncionario=" + d.getCodigoFuncionario() +
", nomeFuncionario='" + d.getNomeFuncionario() + '\'' +
", nomeFuncionarioInt='" + d.getNomeFuncionarioInt() + '\'' +
", nomeAcademico='" + d.getNomeAcademico() + '\'' +
", sexo='" + d.getSexo() + '\'' +
", dataNascimento=" + d.getDataNascimento() +
", morada='" + d.getMorada() + '\'' +
", codigoPostal=" + d.getCodigoPostal() +
", subCodigoPostal=" + d.getSubCodigoPostal() +
", email='" + d.getEmail() + '\'' +
", numeroBi='" + d.getNumeroBi() + '\'' +
", usernameNetpa='" + d.getUsernameNetpa() + '\'' +
", disciplinas=" + d.getDisciplinas() +
'}';
}
 
private void cloneFields(Docente teacherSiges, Teacher teacher)
{
 
teacher.setName(teacherSiges.getNomeFuncionarioInt());
teacher.setEmail(teacherSiges.getEmail());
String msgS;
 
if(teacherSiges.getEmail() != null && teacherSiges.getEmail().endsWith(Globals.EMAIL_LOCAL_SUFFIX))
{
int atIndex = teacherSiges.getEmail().indexOf("@");
if (atIndex > 0)
{
teacher.setUsername(teacherSiges.getEmail().substring(0, atIndex));
msgS = "Teacher SIGES:" + teacherSiges.getCodigoFuncionario().intValue() + " foi-lhe atribuido o username d" + teacherSiges.getEmail().substring(0, atIndex);
logger.info(msgS);
serviceLogInfo(msgS);
}
else
{
msgS = "Teacher SIGES:" + teacherSiges.getCodigoFuncionario().intValue() + " NAO lhe foi atribuido username o email não tem o caracter @";
logger.info(msgS);
serviceLogInfo(msgS);
}
}
else
{
msgS = "Teacher SIGES:" + teacherSiges.getCodigoFuncionario().intValue() + " nao tem email no SIGES foi-lhe atribuido o username d" + teacherSiges.getCodigoFuncionario().intValue();
logger.info(msgS);
serviceLogInfo(msgS);
teacher.setUsername("d" + teacherSiges.getCodigoFuncionario().intValue());
}
teacher.setSigesCode(teacherSiges.getCodigoFuncionario().intValue());
teacher.setAddress(teacherSiges.getMorada());
teacher.setZip("" + teacherSiges.getCodigoPostal().intValue());
teacher.setBi(teacherSiges.getNumeroBi());
teacher.setEmployerName(teacherSiges.getNomeFuncionario());
teacher.setAcademicName(teacherSiges.getNomeAcademico());
teacher.setBirthDate(teacherSiges.getDataNascimento().toGregorianCalendar().getTime());
}
/**
* Nao esta testado
* jm
*
* @param d docente
* @param t teacher
* @param teacherSiges docente
* @param teacher teacher
* @throws Exception .
*/
private void persist(Docente d, Teacher t, boolean newUser) throws Exception
private void persist(Docente teacherSiges, Teacher teacher, boolean newUser, String year) throws Exception
{
String msgS;
 
 
try
{
if(t.getName() == null || t.getName().length() == 0)
t.setName(d.getNomeFuncionarioInt());
//Email instituicao
if(t.getEmail() == null || t.getEmail().indexOf("@") < 0)
t.setEmail(d.getEmail());
if (d.getEmail() != null && (t.getUsername() == null || t.getUsername().trim().length() == 0) && d.getEmail().endsWith(Globals.EMAIL_LOCAL_SUFFIX))
 
if(newUser)
{
int atIndex = d.getEmail().indexOf("@");
if (atIndex > 0)
t.setUsername(d.getEmail().substring(0, atIndex));
teachersNew++;
cloneFields(teacherSiges, teacher);
serviceLogInfo("NOVO PROFESSOR ENCONTRADO: siges:" + teacherSiges.getCodigoFuncionario() + " bi:" + teacher.getBi() + " nome:" + teacher.getName());
}
t.setSigesCode(d.getCodigoFuncionario().intValue());
if(t.getAddress() == null || t.getAddress().length() == 0)
t.setAddress(d.getMorada());
if(t.getZip() == null || t.getZip().length() == 0)
t.setZip("" + d.getCodigoPostal().intValue());
if(t.getBi() == null || t.getBi().length() == 0)
t.setBi(d.getNumeroBi());
t.setEmployerName(d.getNomeFuncionario());
t.setAcademicName(d.getNomeAcademico());
if(t.getBirthDate() == null || t.getBirthDate().getTime() == 0)
t.setBirthDate(d.getDataNascimento().toGregorianCalendar().getTime());
//CASO EM QUE O DOCENTE NO SIGES FOI ATRIBUIDO A OUTRO ESTUDANTE PARA PREENCHER BURACO NA NUMERACAO
else if(teacherSiges.getNumeroBi() == null || teacher.getBi() == null || ! teacherSiges.getNumeroBi().equals(teacher.getBi()))
{
teachersChangeBI++;
 
StringBuilder builder = new StringBuilder();
 
builder.append("ATENCAO NUMERO DE PROFESSOR " + teacherSiges.getCodigoFuncionario() + " MUDOU DE DONO VAI SER BLOQUEADO IMEDIATAMENTE\n");
builder.append("ALTERANDO DADOS DO PROFESSOR " + teacherSiges.getCodigoFuncionario() + "\n");
builder.append("-------ANTES: " + "\n");
builder.append("-------BI: " + teacher.getBi() + "\n");
builder.append("-------Nome: " + teacher.getName() + "\n");
builder.append("-------Username: " + teacher.getUserNameNetpa() + "\n");
builder.append("-------Address: " + teacher.getAddress() + "\n");
builder.append("-------Zip: " + teacher.getZip() + "\n");
builder.append("-------Email: " + teacher.getEmail() + "\n");
builder.append("-------Phone: " + teacher.getPhonenumber() + "\n");
 
cloneFields(teacherSiges, teacher);
 
//teacher.setAutoBlockMode(false);
//teacher.setManualBlock(true);
 
builder.append("DEPOIS: " + "\n");
builder.append("BI: " + teacher.getBi() + "\n");
builder.append("Nome: " + teacher.getName() + "\n");
builder.append("Username: " + teacher.getUserNameNetpa() + "\n");
builder.append("Address: " + teacher.getAddress() + "\n");
builder.append("Zip: " + teacher.getZip() + "\n");
builder.append("Email: " + teacher.getEmail() + "\n");
builder.append("Phone: " + teacher.getPhonenumber() + "\n");
 
serviceLogWarn(builder.toString());
 
sendNotificationAdmin("CODIGO SIGES PROFESSOR " + teacherSiges.getCodigoFuncionario() + " MUDOU DE DONO - NAO FOI BLOQUEADO OS DADOS FORAM REPOSTOS ",builder.toString());
 
}
else
{
//VAMOS APENAS ADICIONAR CAMPOS QUE AINDA NAO EXISTAM IGUAL AO CLONE MAS NAO MECHE
if(teacher.getName() == null || teacher.getName().length() == 0)
teacher.setName(teacherSiges.getNomeFuncionarioInt());
//Email instituicao
if(teacher.getEmail() == null || teacher.getEmail().indexOf("@") < 0)
teacher.setEmail(teacherSiges.getEmail());
 
if (teacherSiges.getEmail() != null && (teacher.getUsername() == null || teacher.getUsername().trim().length() == 0) && teacherSiges.getEmail().endsWith(Globals.EMAIL_LOCAL_SUFFIX))
{
int atIndex = teacherSiges.getEmail().indexOf("@");
if (atIndex > 0)
{
teacher.setUsername(teacherSiges.getEmail().substring(0, atIndex));
msgS = "Teacher SIGES:" + teacherSiges.getCodigoFuncionario().intValue() + " foi-lhe atribuido o username d" + teacherSiges.getEmail().substring(0, atIndex);
logger.info(msgS);
serviceLogInfo(msgS);
}
else
{
msgS = "Teacher SIGES:" + teacherSiges.getCodigoFuncionario().intValue() + " NAO lhe foi atribuido username o email não tem o caracter @";
logger.info(msgS);
serviceLogInfo(msgS);
}
}
else if(teacher.getUsername() == null || teacher.getUsername().trim().length() == 0)
{
msgS = "Teacher SIGES:" + teacherSiges.getCodigoFuncionario().intValue() + " nao tem email no SIGES foi-lhe atribuido o username d" + teacherSiges.getCodigoFuncionario().intValue();
logger.info(msgS);
serviceLogInfo(msgS);
teacher.setUsername("d" + teacherSiges.getCodigoFuncionario().intValue());
}
else
{
//ALL OK
//username não foi alterado
//msgS="Teacher SIGES:" + teacherSiges.getCodigoFuncionario().intValue() + " nao lhe foi alterado o username " + teacher.getUsername();
//logger.info(msgS);
//serviceLogInfo(msgS);
}
teacher.setSigesCode(teacherSiges.getCodigoFuncionario().intValue());
if(teacher.getAddress() == null || teacher.getAddress().length() == 0)
teacher.setAddress(teacherSiges.getMorada());
if(teacher.getZip() == null || teacher.getZip().length() == 0)
teacher.setZip("" + teacherSiges.getCodigoPostal().intValue());
if(teacher.getBi() == null || teacher.getBi().length() == 0)
teacher.setBi(teacherSiges.getNumeroBi());
teacher.setEmployerName(teacherSiges.getNomeFuncionario());
teacher.setAcademicName(teacherSiges.getNomeAcademico());
if(teacher.getBirthDate() == null || teacher.getBirthDate().getTime() == 0)
teacher.setBirthDate(teacherSiges.getDataNascimento().toGregorianCalendar().getTime());
}
 
//Desta forma as relacoes antigas sao ignoradas cria-se uma lista nova e atribui-se ao Teacher, o Hibernate faz resto e apaga as chaves estrangeiras antigas
if (d.getDisciplinas() == null || d.getDisciplinas().getDisciplina() == null || d.getDisciplinas().getDisciplina().size() == 0)
logger.warn("ATENTION TEACHER WITH ZERO UNITS: codigoFuncionario " + d.getCodigoFuncionario());
if (teacherSiges.getDisciplinas() == null || teacherSiges.getDisciplinas().getDisciplina() == null || teacherSiges.getDisciplinas().getDisciplina().size() == 0)
{
msgS = "ATENTION TEACHER WITH ZERO UNITS: codigoFuncionario " + teacherSiges.getCodigoFuncionario();
logger.warn(msgS);
serviceLogInfo(msgS);
 
}
else
{
//1 - PROCEDIMENTO CADEIRAS SAO CARREGADAS DO BACO DA LISTA QUE VEM DO SIGES -> units
//2 - Sao retiradas da lista units as que o teacher tem mas que foram removidas localmente
//3 - Sao adicionadas ao teacher as que o docente ainda nao tiver da lista units
//4 - Remover da lista do teacher as unidades que não vêm do SIGES e que não foram adicionadas localmente
 
//PASSO 1
Set<CourseUnit> units = new HashSet<CourseUnit>();
for (Disciplina disciplina : d.getDisciplinas().getDisciplina())
for (Disciplina disciplina : teacherSiges.getDisciplinas().getDisciplina())
{
CourseUnit courseUnit = DaoFactory.getCourseUnitDaoImpl().loadBySigesCodeUnique("" + disciplina.getCodigo(), "" + disciplina.getCodigoCurso(), "" + disciplina.getCdDuracao(), "" + disciplina.getCdLectivo());
 
if (courseUnit == null)
{
logger.warn("Unit not found: semestre:" + disciplina.getCdDuracao() + " codigo:" + disciplina.getCodigo() + " course:" + disciplina.getCodigoCurso() + " year:" + disciplina.getCdLectivo());
msgS = "Unit not found: semestre:" + disciplina.getCdDuracao() + " codigo:" + disciplina.getCodigo() + " course:" + disciplina.getCodigoCurso() + " year:" + disciplina.getCdLectivo();
logger.warn(msgS);
serviceLogWarn(msgS);
}
else
units.add(courseUnit);
}
//PASSO 2
Iterator<CourseUnit> iter = units.iterator();
while (iter.hasNext())
{
CourseUnit courseUnit = iter.next();
//In case of a comming proxy
TeacherImpl tImpl = (TeacherImpl) DaoFactory.getTeacherDaoImpl().narrow(t);
TeacherImpl tImpl = (TeacherImpl) DaoFactory.getTeacherDaoImpl().narrow(teacher);
if (tImpl.isLocalRemovedUnit(courseUnit))
{
unitsLocallyRemovedNotAdded++;
String msg = "Removendo unidade: " + ((CourseUnitImpl)courseUnit).getSigesUniqueIdentifiers() + " - do professor: " + tImpl.getSigesCode() + " - Associacao existe no SIGES mas foi removido LOCALMENTE";
serviceLogInfo(msg);
logger.info(msg);
iter.remove();
}
}
if (t.getTeachedUnits() != null)
//PASSO 3
if (teacher.getTeachedUnits() != null)
{
for (CourseUnit c : units)
{
boolean isIn = false;
for (CourseUnit tc : t.getTeachedUnits())
for (CourseUnit tc : teacher.getTeachedUnits())
{
if (tc.equals(c))
{
180,12 → 491,70
}
}
if (!isIn)
t.getTeachedUnits().add(c);
{
String msg = "Adicionando unidade: " + ((CourseUnitImpl)c).getSigesUniqueIdentifiers() + " - ao teacher: " + teacher.getSigesCode() + " - Associacao nova no SIGES";
serviceLogInfo(msg);
logger.info(msg);
unitsAddedToTeachers++;
teacher.getTeachedUnits().add(c);
}
}
}
else
t.setTeachedUnits(units);
teacher.setTeachedUnits(units);
 
 
//PASSO 4 nao é feito nos teacher mas deveria ser
 
//PASSO 4
//Remover unidades deste ano que nao vem do SIGES e que nao foram adicionadas localmente
Iterator<CourseUnit> iterNowUnits = teacher.getTeachedUnits().iterator();
TeacherImpl tImpl = (TeacherImpl) DaoFactory.getTeacherDaoImpl().narrow(teacher);
while(iterNowUnits.hasNext())
{
CourseUnit cUNow = iterNowUnits.next();
if(cUNow.getImportYear().equals(year))
//Apenas tentamos apagar as unidades do ano corrente.
//Este servico trabalha com unidades importadas do ano que e passado como argumento
//Se importamos unidades desse ano, as dos outros anos nao vem na lista, logo
//iriamos constatar que nenhuma estava no SIGES o que nao e verdade.
//Assim so apagamos unidades do ano que estamos a importar e que nao venham
//na importacao desse ano
{
 
boolean added = false;
for(CourseUnit c: units)
{
if(cUNow.equals(c))
{
added = true;
break;
}
}
if(!added)
{
 
if(!tImpl.isLocalRemovedUnit(cUNow))
{
String msg = "Removendo unidade: " + ((CourseUnitImpl)cUNow).getSigesUniqueIdentifiers() + " - do docente: " + teacher.getSigesCode() + " - Associacao desapareceu do SIGES";
serviceLogInfo(msg);
logger.info(msg);
iterNowUnits.remove();
unitsRemovedToTeachers++;
}
else
{
String msg = "NAO REMOVIDA - Unidade: " + ((CourseUnitImpl)cUNow).getSigesUniqueIdentifiers() + " - do docente: " + teacher.getSigesCode() + " - Associacao desapareceu do SIGES mas foi adicionada localmente";
serviceLogInfo(msg);
logger.info(msg);
unitsLocalAddedNotRemoved++;
}
}
}
}
}
 
 
}
catch (Exception e)
{
195,13 → 564,24
List<String> arguments = new ArrayList<String>();
String cause = e.getCause() == null ? "" : e.getCause().toString();
arguments.add((e.toString() + "\n" + cause).replace("\n","<br/>"));
Email email = new Email("Erro de importação de professores",emails,"baco@estgp.pt","messageToAdmin_pt.txt",arguments);
Email email = new Email("Erro de importa��o de professores",emails,"baco@estgp.pt","messageToAdmin_pt.txt",arguments);
new SendEmailService().sendEmail(email);
throw e;
}
 
}
 
@Override
protected void runJobServiceTask() throws Throwable {
 
String importYear = (String) getParametersMap().get(JOB_importYear_KEY).getObject();
run(importYear);
 
}
 
public static final String JOB_importYear_KEY = "JOB_importYear_KEY";
 
 
/**
* Testar por aqui poi requer Super Role e assim e' autmatico
*
210,7 → 590,7
*/
public static void main(String[] args) throws ServiceException
{
String year = DatesUtils.getImportYear();
String year = DaoFactory.getConfigurationDaoImpl().getImportsDefaultImportYearCreateTransaction();
if(args != null && args.length > 0)
year = args[0];
AbstractDao.getCurrentSession().beginTransaction();
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportCourseService.java
4,20 → 4,20
import org.apache.log4j.Logger;
import org.hibernate.NonUniqueResultException;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.services.email.SendEmailService;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.domain.Course;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.DomainObjectFactory;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.CourseView;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.courses.CoursesService;
import pt.estgp.estgweb.services.email.SendEmailService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.services.jobs.ServiceJob;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
import pt.estgp.estgweb.services.courses.CoursesService;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.utils.Email;
import pt.ipportalegre.siges.web.services.ArrayOfDisciplina;
import pt.ipportalegre.siges.web.services.Disciplina;
25,56 → 25,78
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import javax.xml.namespace.QName;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
import java.net.URL;
import java.net.MalformedURLException;
 
/**
* @author Jorge Machado
*/
public class ImportCourseService implements IService
public class ImportCourseService extends ServiceJob implements IService
{
private static final Logger logger = Logger.getLogger(ImportCourseService.class);
 
private CoursesService coursesService = new CoursesService();
 
int newUnits = 0;
int newCourses = 0;
public ILogMessages run(String year) throws ServiceException
{
String msgS = "STARTING COURSES IMPORT SERVICE FOR YEAR: " + year;
serviceLogInfo(msgS);
logger.info(msgS);
 
newUnits = 0;
newCourses = 0;
 
DefaultLogMessages logMessages = new DefaultLogMessages();
try
{
logMessages.addMessage(new DefaultLogMessage("import.semestre.separated", LogMessageTypeEnum.INFO, "instituicao " + Globals.SIGES_INSTITUTION_CODE));
logMessages.addMessage(new DefaultLogMessage("import.semestre.separated", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
serviceLogInfo(logMessages.getLastMessage());
 
HashMap<String, Disciplina> disciplinasMap = new HashMap<String, Disciplina>();
HashMap<String, Disciplina> disciplinasMapS1 = new HashMap<String, Disciplina>();
HashMap<String, Disciplina> disciplinasMapS2 = new HashMap<String, Disciplina>();
HashMap<String, Disciplina> disciplinasMapA = new HashMap<String, Disciplina>();
HashMap<String, Disciplina> disciplinasMapT1 = new HashMap<String, Disciplina>();
HashMap<String, Disciplina> disciplinasMapT2 = new HashMap<String, Disciplina>();
HashMap<String, Disciplina> disciplinasMapT3 = new HashMap<String, Disciplina>();
HashMap<String, Disciplina> disciplinasMapT4 = new HashMap<String, Disciplina>();
HashMap<String, Disciplina> cursosMap = new HashMap<String, Disciplina>();
 
/**
* Build Course Units Maps
*/
SiGesWEB service;
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
try
{
service = new SiGesWEB(new URL(Globals.SIGES_WEBSERVICE_WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
serviceLogInfo("STARTING WEB SERVICE AT " + WSDL);
service = new SiGesWEB(new URL(WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
}
catch (MalformedURLException e)
{
logger.fatal(e, e);
logMessages.addMessage(new DefaultLogMessage("import.error",e.toString(),"erro na configuracao do WEB Service", LogMessageTypeEnum.INFO));
serviceLogError(logMessages.getLastMessage(), e);
return logMessages;
}
 
importUnitsSemestre(service, "S1", year, disciplinasMap, disciplinasMapS1, cursosMap, logMessages);
importUnitsSemestre(service, "S2", year, disciplinasMap, disciplinasMapS2, cursosMap, logMessages);
importUnitsSemestre(service, "A", year, disciplinasMap, disciplinasMapA, cursosMap, logMessages);
importUnitsSemestre(service, "T1", year, disciplinasMap, disciplinasMapT1, cursosMap, logMessages);
importUnitsSemestre(service, "T2", year, disciplinasMap, disciplinasMapT2, cursosMap, logMessages);
importUnitsSemestre(service, "T3", year, disciplinasMap, disciplinasMapT3, cursosMap, logMessages);
importUnitsSemestre(service, "T4", year, disciplinasMap, disciplinasMapT4, cursosMap, logMessages);
 
/**
* Import Courses
*/
logMessages.addMessage(new DefaultLogMessage("import.semestre.updating.courses", LogMessageTypeEnum.INFO));
serviceLogInfo("updating courses");
logger.info("updating courses");
Set<Map.Entry<String, Disciplina>> set2 = cursosMap.entrySet();
for (Map.Entry<String, Disciplina> entry : set2)
86,6 → 108,8
if (c == null)
{
c = new CourseView();
newCourses++;
serviceLogInfo("New Course Found: (" + d.getCodigoCurso() + ") " + d.getNomeCurso());
// DaoFactory.getCourseDaoImpl().save(c);
}
c.setName(d.getNomeCurso());
104,24 → 128,81
updateCourseUnits(disciplinasMapS1, "S1",logMessages,year);
updateCourseUnits(disciplinasMapS2, "S2",logMessages,year);
updateCourseUnits(disciplinasMapA, "A",logMessages,year);
updateCourseUnits(disciplinasMapT1, "T1",logMessages,year);
updateCourseUnits(disciplinasMapT2, "T2",logMessages,year);
updateCourseUnits(disciplinasMapT3, "T3",logMessages,year);
updateCourseUnits(disciplinasMapT4, "T4",logMessages,year);
 
serviceLogInfo("######################################");
serviceLogInfo("######################################");
serviceLogInfo("#Courses Imported:" + cursosMap.size());
serviceLogInfo("#Units Imported S1:" + disciplinasMapS1.size());
serviceLogInfo("#Units Imported S2:" + disciplinasMapS2.size());
serviceLogInfo("#Units Imported A:" + disciplinasMapA.size());
serviceLogInfo("#Units Imported T1:" + disciplinasMapT1.size());
serviceLogInfo("#Units Imported T2:" + disciplinasMapT2.size());
serviceLogInfo("#Units Imported T3:" + disciplinasMapT3.size());
serviceLogInfo("#Units Imported T4:" + disciplinasMapT4.size());
serviceLogInfo("#New Courses Found:" + newCourses);
serviceLogInfo("#New Units Found:" + newUnits);
 
logger.info("######################################");
logger.info("######################################");
logger.info("#Courses Imported:" + cursosMap.size());
logger.info("#Units Imported S1:" + disciplinasMapS1.size());
logger.info("#Units Imported S2:" + disciplinasMapS2.size());
logger.info("#Units Imported A:" + disciplinasMapA.size());
logger.info("#Units Imported T1:" + disciplinasMapT1.size());
logger.info("#Units Imported T2:" + disciplinasMapT2.size());
logger.info("#Units Imported T3:" + disciplinasMapT3.size());
logger.info("#Units Imported T4:" + disciplinasMapT4.size());
logger.info("#New Courses Found:" + newCourses);
logger.info("#New Units Found:" + newUnits);
 
 
}
catch (Throwable e)
{
logger.error(e,e);
logMessages.addMessage(new DefaultLogMessage("import.error",e.toString(), "see log for details", LogMessageTypeEnum.ERROR));
List<String> emails = new ArrayList<String>();
emails.add(ConfigProperties.getProperty("admin.email"));
List<String> arguments = new ArrayList<String>();
serviceLogError(logMessages.getLastMessage(), e);
String cause = e.getCause() == null ? "" : e.getCause().toString();
arguments.add((e.toString() + "\n" + cause).replace("\n","<br/>"));
Email email = new Email("Erro de importação de cursos e unidades",emails,"baco@estgp.pt","messageToAdmin_pt.txt",arguments);
new SendEmailService().sendEmail(email);
sendNotificationAdmin("Erro na importacao de sumarios",cause);
}
logger.info("terminating course import");
serviceLogInfo("terminating course import");
logMessages.addMessage(new DefaultLogMessage("import.course.terminating", LogMessageTypeEnum.INFO));
setProgress(100);
return logMessages;
}
 
/**
* Envio de Notificação aos operadores do CI
* @param subject
* @param cause
*/
private void sendNotificationAdmin(String subject, String cause)
{
 
 
List<String> emails = ConfigProperties.getListValues("admin.email");
for(String email:emails)
{
serviceLogWarn(">>>>>>>>ENVIANDO NOTIFICACAO A ADMINISTRACAO: " + email);
logger.warn(">>>>>>>>ENVIANDO NOTIFICACAO A ADMINISTRACAO: " + email);
}
List<String> arguments = new ArrayList<String>();
arguments.add(cause.replace("\n","<br/>"));
Email email = new Email(subject,emails,Globals.SYSTEM_EMAIL_BOX,"messageToAdmin_pt.txt",arguments);
email.setHtml(true);
try {
new SendEmailService().sendEmail(email);
} catch (ServiceException e) {
e.printStackTrace();
}
 
}
 
private void importUnitsSemestre(SiGesWEB service,
String semestre,
String year,
131,14 → 212,16
DefaultLogMessages logMessages)
{
logMessages.addMessage(new DefaultLogMessage("import.semestre.course.units." + semestre, LogMessageTypeEnum.INFO));
serviceLogInfo("importing " + semestre + " course units");
logger.info("importing " + semestre + " course units");
ArrayOfDisciplina arrayOfDisciplina = service.getSiGesWEBSoap().getDisciplinasDaInstituicaoSemestre(Globals.SIGES_INSTITUTION_CODE, year, semestre);
ArrayOfDisciplina arrayOfDisciplina = service.getSiGesWEBSoap().getDisciplinasDaInstituicaoSemestre(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year, semestre);
List<Disciplina> disciplinas = arrayOfDisciplina.getDisciplina();
for (Disciplina d : disciplinas)
{
if (disciplinasMap.get(d.getCodigo().intValue() + ":" + d.getCodigoCurso() + ":" + semestre) != null)
{
logMessages.addMessage(new DefaultLogMessage("import.semestre.repeated." + semestre, "unit: " + d.getCodigo().intValue(), "", LogMessageTypeEnum.WARNING));
serviceLogWarn("repeated unit in " + semestre + ":" + d.getCodigo().intValue());
logger.warn("repeated unit in " + semestre + ":" + d.getCodigo().intValue());
}
disciplinasMap.put(d.getCodigo().intValue() + ":" + d.getCodigoCurso() + ":" + semestre, d);
151,6 → 234,7
{
logMessages.addMessage(new DefaultLogMessage("import.semestre.updating.course.units." + semestre, LogMessageTypeEnum.INFO));
logger.info("updating " + semestre + " course units");
serviceLogInfo("updating " + semestre + " course units");
Set<Map.Entry<String, Disciplina>> set = disciplinasMapS.entrySet();
for (Map.Entry<String, Disciplina> entry : set)
{
161,15 → 245,18
}catch(NonUniqueResultException e)
{
logger.fatal("Unidade Repetida: (" + d.getCodigo() + ") curso: " + d.getCodigoCurso() + " " + semestre + " " + year);
serviceLogFatal("Unidade Repetida: (" + d.getCodigo() + ") curso: " + d.getCodigoCurso() + " " + semestre + " " + year);
throw e;
}
if (c == null)
{
c = DomainObjectFactory.createCourseUnitImpl();
DaoFactory.getCourseUnitDaoImpl().save(c);
serviceLogInfo("New Unit Found: (" + d.getCodigo() + ") " + d.getNome() + " - curso (" + d.getNomeCurso() + ") " + d.getNomeCurso());
newUnits++;
}
c.setName(d.getNome());
c.setInstitutionCode("" + Globals.SIGES_INSTITUTION_CODE);
c.setInstitutionCode("" + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode());
c.setCode("" + d.getCodigo().intValue());
c.setCourseCode("" + d.getCodigoCurso());
c.setCourseName("" + d.getNomeCurso());
181,9 → 268,20
}
}
 
public static final String JOB_importYear_KEY = "JOB_importYear_KEY";
 
@Override
protected void runJobServiceTask() throws Throwable {
 
String importYear = (String) getParametersMap().get(JOB_importYear_KEY).getObject();
run(importYear);
 
}
 
 
public static void main(String[] args) throws ServiceException
{
String year = DatesUtils.getImportYear();
String year = DaoFactory.getConfigurationDaoImpl().getImportsDefaultImportYearCreateTransaction();
if(args != null && args.length > 0)
year = args[0];
AbstractDao.getCurrentSession().beginTransaction();
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportSumariesJson.java
New file
0,0 → 1,399
package pt.estgp.estgweb.services.sigesimports;
 
import jomm.dao.impl.AbstractDao;
import jomm.utils.FilesUtils;
import jomm.utils.PdfUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.fop.apps.FOPException;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.enums.LangEnum;
import pt.estgp.estgweb.services.courseunits.CreateCourseUnitXML;
import pt.estgp.estgweb.services.email.EMAILJob;
import pt.estgp.estgweb.services.email.SendEmailService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.services.jobs.JobScheduleService;
import pt.estgp.estgweb.services.jobs.ServiceJob;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
import pt.estgp.estgweb.utils.Dom4jUtil;
import pt.estgp.estgweb.web.FtpServer;
import pt.ipportalegre.siges.web.services.ArrayOfAula;
import pt.ipportalegre.siges.web.services.Aula;
import pt.ipportalegre.siges.web.services.SiGesWEB;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import javax.xml.namespace.QName;
import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
* @author Jorge Machado
* @date 11/May/2008
* @time 12:51:32
* @see pt.estgp.estgweb
*/
public class ImportSumariesJson extends ServiceJob implements IService
{
 
private static final Logger logger = Logger.getLogger(ImportSumariesJson.class);
 
private static final int MAX_COMMIT = 10;
 
 
public ILogMessages run(String year,String semestre) throws ServiceException
{
return run(year,semestre,true,true);
}
 
public ILogMessages run(String year,String semestre,boolean sendIONLINE,boolean sendEMAIL) throws ServiceException
{
String msgS = "STARTING SUMARIES IMPORT SERVICE FOR year: " + year + " semestre: " + semestre + " sendIONLINE: " + sendIONLINE + " sendEMAIL: " + sendEMAIL;
serviceLogInfo(msgS);
logger.info(msgS);
 
DefaultLogMessages logMessages = new DefaultLogMessages();
logMessages.addMessage(new DefaultLogMessage("import.summaries", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
serviceLogInfo(logMessages.getLastMessage());
 
 
int countUnits = 0;
int countUnitsOk = 0;
int countUnitsZeroSummaries = 0;
 
List<String> unitsZeroSummaries = new ArrayList<String>();
List<String> unitsFailed = new ArrayList<String>();
try
{
 
SiGesWEB service;
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
try
{
serviceLogInfo("STARTING WEB SERVICE AT " + WSDL);
service = new SiGesWEB(new URL(WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
}
catch (Throwable e)
{
logMessages.addMessage(new DefaultLogMessage("import.error",e.toString(),"erro na configuracao do WEB Service", LogMessageTypeEnum.INFO));
serviceLogInfo(logMessages.getLastMessage());
logger.fatal(e, e);
serviceLogError(e.toString(), e);
return logMessages;
}
 
int i = 0;
//List<Long> cUs = DaoFactory.getCourseUnitDaoImpl().loadIds(year,DatesUtils.getSemestre());
List<Long> cUs = DaoFactory.getCourseUnitDaoImpl().loadIds(year,semestre);
String nowCode = "";
for(Long cId: cUs)
{
nowCode = "BACO_ONLY_CODE" + cId;
countUnits++;
try
{
if (i++ > MAX_COMMIT)
{
i = 0;
setProgress((int) (((float)countUnits)/((float)cUs.size())*100.0f));
AbstractDao.getCurrentSession().getTransaction().commit();
AbstractDao.getCurrentSession().beginTransaction();
serviceLogInfo("Commiting database");
}
CourseUnit c = DaoFactory.getCourseUnitDaoImpl().load(cId);
nowCode = c.getCode();
logMessages.addMessage(new DefaultLogMessage("import.info","Importing Summaries to CourseUnit: " + c.getCode() + ": course: " + c.getCourse().getCode(),"", LogMessageTypeEnum.INFO));
logger.info("Importing Summaries to CourseUnit: " + c.getName() + " (" + c.getCode() + ") course " + c.getCourse().getName() + " (" + c.getCourse().getCode() + ")");
serviceLogInfo(logMessages.getLastMessage());
 
int tries = 3;
ArrayOfAula arrayOfAulas = null;
while(tries > 0)
{
//comentario de teste
try
{
arrayOfAulas = service.getSiGesWEBSoap().getAulas(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year,c.getCode(),semestre,c.getCourse().getCode());
break;
}
catch(Throwable t)
{
if(tries-- == 0)
{
logger.error("Giving up of courseUnit:" + cId + " ( " + c.getName() + " ) ",t);
serviceLogError("Giving up of courseUnit:" + cId + " ( " + c.getName() + " ) ",t);
break;
}
 
logger.error("WebService Fail, trying " + tries + " times sleeping a while");
serviceLogError("WebService Fail, trying " + tries + " times sleeping a while");
Thread.sleep(5000);
}
}
 
if(arrayOfAulas != null && arrayOfAulas.getAula() != null)
{
List<CourseUnitSummary> courseUnitSummaries = new ArrayList<CourseUnitSummary>();
 
//HashMap<String, CourseUnitSummary> map = new HashMap<String, CourseUnitSummary>();
/*if(c.getSummaries() != null && c.getSummaries().size() > 0)
for(CourseUnitSummary s: c.getSummaries())
map.put(s.getCodigoAula() + ":" + s.getCodigoSumario(),s);
else
c.setSummaries(new HashSet<CourseUnitSummary>());*/
JSONObject summariesJson = new JSONObject();
JSONArray summaries = new JSONArray();
summariesJson.put("summary",summaries);
for(Aula aula: arrayOfAulas.getAula())
{
 
//CourseUnitSummary s = map.get(aula.getSumNumeroAula() + ":" + aula.getCodigoSumario());
//if(s == null)
//{
CourseUnitSummaryImpl s = DomainObjectFactory.createCourseUnitSummaryImpl();
s.setCourseUnit(c);
//c.getSummaries().add(s);
//DaoFactory.getCourseUnitSummaryDaoImpl().save(s);
//summaries.add();
//}
s.setCodigoSumario(""+aula.getCodigoSumario().intValue());
s.setCodigoAula(""+aula.getSumNumeroAula().intValue());
s.setNumeroAula(aula.getSumNumeroAula().intValue());
s.setDataAula(aula.getData().toGregorianCalendar().getTime());
s.setTipoAula(aula.getSumTipoAula());
s.setCodigoSalaAula("" + aula.getAulaCodigoSalaAula().intValue());
s.setAlunosPresentes(aula.getSumNumeroAlunos().intValue());
s.setTitulo(aula.getSumTitulo());
s.setDescricao(aula.getSumDescricao());
s.setcEstado(""+aula.getSumCdEstado().intValue());
s.setNumeroHoras("" + aula.getNumeroCelulas().intValue());
summaries.put(s.getJson());
courseUnitSummaries.add(s);
}
if(courseUnitSummaries.size() == 0)
{
countUnitsZeroSummaries++;
unitsZeroSummaries.add(c.getCode());
}
else
{
countUnitsOk++;
}
c.setSummariesJson(summariesJson.toString());
 
if(sendIONLINE)
{
String path = generatePdf(c);
sendPdfFtpIonline(c,new ArrayList<String>(),null,path,null);
FilesUtils.delete(path);
}
if(sendEMAIL)
{
sendEmail(null, courseUnitSummaries,true);
}
}
else
{
countUnitsZeroSummaries++;
unitsZeroSummaries.add(c.getCode());
logger.error("Summaries come null in unit:" + c.getCode());
serviceLogError("Summaries come null in unit:" + c.getCode());
}
}
catch(Throwable e)
{
unitsFailed.add(nowCode);
logger.error(e,e);
serviceLogError(e.toString(),e);
}
}
 
setProgress(100);
serviceLogError("Finish commiting");
 
}
catch (Throwable e)
{
logger.error(e, e);
logMessages.addMessage(new DefaultLogMessage("import.error", e.toString(), "see log for details", LogMessageTypeEnum.ERROR));
serviceLogError(logMessages.getLastMessage(),e);
throw new ServiceException(e.toString(), e);
}
 
logMessages.addMessage(new DefaultLogMessage("import.summaries.terminating", LogMessageTypeEnum.INFO));
logger.info("terminating summaries import");
serviceLogInfo(logMessages.getLastMessage());
 
serviceLogInfo("#######################################");
serviceLogInfo("#######################################");
serviceLogInfo("UNITS PROCESSED: " + countUnits);
serviceLogInfo("UNITS FAILED: " + (countUnits - countUnitsZeroSummaries - countUnitsOk));
serviceLogInfo("UNITS IMPORT OK: " + countUnitsOk);
serviceLogInfo("UNITS ZERO SUMARIES: " + countUnitsZeroSummaries);
serviceLogInfo("#######################################");
 
logger.info("#######################################");
logger.info("#######################################");
logger.info("UNITS PROCESSED: " + countUnits);
logger.info("UNITS FAILED: " + (countUnits - countUnitsZeroSummaries - countUnitsOk));
logger.info("UNITS IMPORT OK: " + countUnitsOk);
logger.info("UNITS ZERO SUMARIES: " + countUnitsZeroSummaries);
logger.info("#######################################");
return logMessages;
}
 
 
public static SendEmailService sendEmailService = new SendEmailService();
 
private void sendEmail(UserSession userSession,List<CourseUnitSummary> summaries,boolean sendEmail)
{
if(Globals.EMAIL_SUMMARIES && summaries.size() > 0 && sendEmail)
{
// for(CourseUnitSummary summary: summaries)
// {
 
List<String> emails = DaoFactory.getCourseUnitSummaryDaoImpl().getStudentsEmails(summaries.get(0).getId());
if(emails == null)
logger.warn("No students emails in unit: code:" + summaries.get(0).getCourseUnit().getCode() + " " + summaries.get(0).getCourseUnit().getName());
EMAILJob emailJob = new EMAILJob(sendEmailService.getSummariesEmail(emails, summaries, summaries.get(0).getCourseUnit(), LangEnum.PORTUGUESE));
JobScheduleService.getInstance().scheduleNow(emailJob,"New Summary EMAIL from: " + summaries.get(0).getCourseUnit().getName() + " aula: " +summaries.get(summaries.size()-1).getNumeroAula() ,userSession);
// }
}
}
 
 
 
 
 
 
public static String generatePdf(CourseUnit c) throws IOException, TransformerException, FOPException {
Document dom = new CreateCourseUnitXML().run(c,null);
org.w3c.dom.Document dd = Dom4jUtil.toW3c(dom);
String path = Globals.TMP_DIR + File.separator + c.getCode() + "-" + c.getNormalizedName() + "-sumarios.pdf";
FileOutputStream out = new FileOutputStream(path);
Map<String,Object> params = new HashMap<String,Object>();
params.put("site", Globals.SITE_URL);
PdfUtils.createPdfFromXml(new DOMSource(dd), "pt/estgp/estgweb/services/courseunits/courseunitsummaries.fo.xsl", out, params);
out.flush();
out.close();
return path;
}
 
private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,String pdfPath,FTPClient client) throws IOException, TransformerException, FOPException {
 
FtpServer server = null;
if(client == null)
{
server = FtpServer.getNewServer(Globals.FTP_IONLINE_URL,Globals.FTP_IONLINE_USER,Globals.FTP_IONLINE_PASS);
client = server.getClient();
if(client == null)
{
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP - could be FTPTimeout: " + Globals.FTP_TIMEOUT_SECONDS);
errors.add("################### > CANT CONNECT FTP to send summaries " + ((CourseUnitImpl)cu).getSummariosPathIntranet());
return;
}
 
}
client.setFileType(FTP.BINARY_FILE_TYPE);
 
 
String pastaFichaCurricular = ((CourseUnitImpl)cu).getSummariosPathIntranet();
if(!client.changeWorkingDirectory(pastaFichaCurricular))
{
logger.error("FTP CANT CHANGE TO PATH: " + pastaFichaCurricular);
}
else
{
if(!client.storeFile(((CourseUnitImpl)cu).getSummariosFileNameIntranet(),new FileInputStream(pdfPath)))
{
String msgS = "CANT store file in given time, probably timeout at " + Globals.FTP_DATA_STORE_TIMEOUT_SECONDS;
logger.error(msgS);
serviceLogError(msgS);
}
if(server != null)
{
client.quit();
client.disconnect();
}
}
//
}
/**
* Testar por aqui poi requer Super Role e assim e' autmatico
*
*
* @param args of main
* @throws pt.estgp.estgweb.services.expceptions.ServiceException on error
*/
public static void main(String[] args) throws ServiceException, JSONException {
 
System.out.println("Syntax:");
System.out.println("year, semestre, sendIonline, sendEmail");
System.out.println("If no arguments wil user actual year import config in all semestres and true in email and ionline");
 
String year = DaoFactory.getConfigurationDaoImpl().getImportsDefaultImportYearCreateTransaction();
String semestre = null;
boolean sendIonline = true;
boolean sendEmail = true;
if(args != null && args.length > 0)
year = args[0];
 
if(args != null && args.length > 1)
semestre = args[1];
 
if(args != null && args.length > 2)
sendIonline = Boolean.parseBoolean(args[2]);
 
if(args != null && args.length > 3)
sendEmail = Boolean.parseBoolean(args[3]);
 
AbstractDao.getCurrentSession().beginTransaction();
if(semestre != null)
new ImportSumariesJson().run(year,semestre,sendIonline,sendEmail);
else
{
new ImportSumariesJson().run(year,"S1",sendIonline,sendEmail);
new ImportSumariesJson().run(year,"S2",sendIonline,sendEmail);
new ImportSumariesJson().run(year,"A",sendIonline,sendEmail);
}
AbstractDao.getCurrentSession().getTransaction().commit();
}
 
 
public static final String JOB_importYear_KEY = "JOB_importYear_KEY";
public static final String JOB_semestre_KEY = "JOB_semestre_KEY";
public static final String JOB_sendIonline_KEY = "JOB_sendIonline_KEY";
public static final String JOB_sendEmail_KEY = "JOB_sendEmail_KEY";
 
@Override
protected void runJobServiceTask() throws Throwable {
 
String importYear = (String) getParametersMap().get(JOB_importYear_KEY).getObject();
String semestre = (String) getParametersMap().get(JOB_semestre_KEY).getObject();
Boolean sendIonline = (Boolean) getParametersMap().get(JOB_sendIonline_KEY).getObject();
Boolean sendEmail = (Boolean) getParametersMap().get(JOB_sendEmail_KEY).getObject();
run(importYear,semestre,sendIonline,sendEmail);
 
}
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/services/common/LoadObjectService.java
New file
0,0 → 1,42
package pt.estgp.estgweb.services.common;
 
import jomm.dao.utils.HibernateUtils;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.views.CourseUnitView;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.io.Serializable;
import java.util.List;
 
/**
* @author Jorge Machado
* @date 22/Mai/2008
* @see pt.estgp.estgweb.services.common
*/
public class LoadObjectService implements IService
{
private static final Logger logger = Logger.getLogger(LoadObjectService.class);
 
public Object load(String className, Serializable id, UserSession userSession) throws ServiceException
{
try
{
Object obj = HibernateUtils.getCurrentSession().load(className,id);
if(obj instanceof CourseUnit)
return new CourseUnitView((CourseUnit) obj);
else
{
logger.info("Atention LoadObjectService Only implemented for CourseUnits");
return null;
}
}
catch (Throwable throwable)
{
logger.error(throwable,throwable);
throw new ServiceException("", throwable);
}
}
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/services/ftpservices/FtpService.java
1,34 → 1,21
package pt.estgp.estgweb.services.ftpservices;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.services.email.ReadEmailService;
import pt.estgp.estgweb.services.email.IPopEmail;
import pt.estgp.estgweb.services.email.IAddress;
import pt.estgp.estgweb.services.email.impl.DefaultPopEmail;
import pt.estgp.estgweb.services.email.impl.DefaultAddress;
import pt.estgp.estgweb.domain.*;
import jomm.utils.DesUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.CourseUnitImpl;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.UserSessionImpl;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.web.utils.DatesUtils;
import pt.estgp.estgweb.web.FtpServer;
import org.apache.log4j.Logger;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.fileupload.FileItem;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.List;
import java.util.Properties;
import java.util.Date;
import java.util.ArrayList;
import java.io.*;
import java.io.File;
import java.io.IOException;
 
import jomm.utils.DesUtils;
import jomm.utils.StringsUtils;
 
import javax.mail.*;
import javax.mail.internet.InternetAddress;
 
/**
* @author Jorge Machado
* @date 20/Mar/2008
40,12 → 27,12
 
private static final Logger logger = Logger.getLogger(FtpService.class);
 
private static final String FTP_PASSWORD = "pt.estgp.estgweb.services.ftpservices.FtpService.FTP_PASSWORD";
public static final String FTP_PASSWORD = "pt.estgp.estgweb.services.ftpservices.FtpService.FTP_PASSWORD";
 
 
public String run(FtpRequestForm ftpRequestForm, UserSession userSession) throws IOException
{
 
//userSession.getUser().get
boolean isStaticAccess = ConfigProperties.getBooleanProperty(ftpRequestForm.getServerConfName()+".use.default.credentials.to.updates.and.deletes");
String password = ftpRequestForm.getPassword();
String username = ftpRequestForm.getUsername();
72,8 → 59,12
{
((UserSessionImpl)userSession).put(FTP_PASSWORD,DesUtils.getInstance().encrypt(ftpRequestForm.getPassword()));
}
//ESTE CAMPO É COLOCADO EM MEMORIA LOGO NA AUTENTICACAO POR ISSO A POP3 PASS NAO CHEGA A SER USADA
//E A POP3PASS DAVA PROBLEMAS SE O USER ALGUMA VEZ A TINHA INICIADO
String passwordCode = (String) ((UserSessionImpl)userSession).get(FTP_PASSWORD);
 
//System.out.println("SAVEDCODE"+passwordCode);
 
if(password != null && password.trim().length() > 0)
{
 
82,6 → 73,7
{
logger.info("using saved password");
password = DesUtils.getInstance().decrypt(passwordCode);
//System.out.println("SAVEDPASS:" + password);
}
else if(userSession.getUser().getPop3password() != null && userSession.getUser().getPop3password().length() > 0)
{
99,6 → 91,13
}
FtpServer server = FtpServer.getNewServer(ftpRequestForm.getServerUrl(),username,password);
FTPClient client = server.getClient();
if(client == null)
{
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP");
return "errors.ftp.timeout";
}
 
String result = "ftp.operation.success";
client.setFileType(FTP.BINARY_FILE_TYPE);
client.changeWorkingDirectory(ftpRequestForm.getStartPath());
/impl/src/java/pt/estgp/estgweb/services/jobs/JobScheduleService.java
1,12 → 1,14
package pt.estgp.estgweb.services.jobs;
 
import jomm.dao.impl.AbstractDao;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.sigesimports.*;
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.domain.Job;
import pt.estgp.estgweb.domain.DomainObjectFactory;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.dao.DaoFactory;
 
import java.util.Date;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.*;
 
/**
* @author Jorge Machado
37,4 → 39,277
job.setJobHandler(handler);
DaoFactory.getJobDaoImpl().save(job);
}
 
/*
public void scheduleServiceTask(JobServiceTask job, String description, Date startDate, UserSession userSession)
{
//Job job = DomainObjectFactory.createJobImpl();
if(userSession != null && userSession.getUser() != null)
job.setOwner(userSession.getUser());
job.setDescription(description);
job.setStartDate(startDate);
//job.setJobHandler(); The handler is the specific Job
DaoFactory.getJobDaoImpl().save(job);
}
*/
public void createOrUpdateScheduleServiceTask(JobServiceTaskScheduler schedule, UserSession userSession)
{
if(schedule.getId() <= 0)
{
schedule.setCreatedBy(userSession.getUser());
//job.setJobHandler(); The handler is the specific Job
DaoFactory.getJobServiceTaskSchedulerDaoImpl().save(schedule);
for(JobServiceTaskSchedulerParameter param: schedule.getServiceTaskSchedulerParameters())
{
DaoFactory.getJobServiceTaskSchedulerParameterDaoImpl().save(param);
}
 
}
else
{
JobServiceTaskScheduler persistent = DaoFactory.getJobServiceTaskSchedulerDaoImpl().load(schedule.getId());
//delete old parameters
Iterator<JobServiceTaskSchedulerParameter> iter = persistent.getServiceTaskSchedulerParameters().iterator();
while(iter.hasNext())
{
JobServiceTaskSchedulerParameter param = iter.next();
iter.remove();
param.setJobServiceTaskScheduler(null);
DaoFactory.getJobServiceTaskSchedulerParameterDaoImpl().delete(param);
//DaoFactory.getJobServiceTaskSchedulerParameterDaoImpl().evict(param);
}
 
DaoFactory.getJobServiceTaskSchedulerDaoImpl().saveOrUpdate(persistent);
//set new ones
for(JobServiceTaskSchedulerParameter param: schedule.getServiceTaskSchedulerParameters())
{
persistent.getServiceTaskSchedulerParameters().add(param);
param.setJobServiceTaskScheduler(persistent);
DaoFactory.getJobServiceTaskSchedulerParameterDaoImpl().save(param);
}
persistent.setServiceTaskSchedulerParameters(schedule.getServiceTaskSchedulerParameters());
persistent.setNow(schedule.isNow());
persistent.setDaily(schedule.isDaily());
persistent.setWeekly(schedule.isWeekly());
persistent.setMonthly(schedule.isMonthly());
persistent.setWeekday(schedule.getWeekday());
persistent.setMonthday(schedule.getMonthday());
persistent.setHour(schedule.getHour());
persistent.setMinute(schedule.getMinute());
persistent.setSecond(schedule.getSecond());
persistent.setDescription(schedule.getDescription());
persistent.setTargetService(schedule.getTargetService());
DaoFactory.getJobServiceTaskSchedulerDaoImpl().saveOrUpdate(persistent);
}
}
 
public static void main(String[] args) throws SQLException
{
AbstractDao.getCurrentSession().beginTransaction();
scheduleImportStudents();
AbstractDao.getCurrentSession().getTransaction().commit();
}
 
public static void scheduleSincronizePrograms()
{
JobServiceTaskScheduler jobServiceTaskScheduler = DomainObjectFactory.createJobServiceTaskSchedulerImpl();
jobServiceTaskScheduler.setId(0);
JobServiceTaskSchedulerParameterImpl param1 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
JobServiceTaskSchedulerParameterImpl param2 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
JobServiceTaskSchedulerParameterImpl param3 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
JobServiceTaskSchedulerParameterImpl param4 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
param1.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param2.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param3.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param4.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param1.setName(SincronizeLastYearCourseUnitProgramsService.JOB_cloneOnlyNews_KEY);
param2.setName(SincronizeLastYearCourseUnitProgramsService.JOB_generateAllPdfs_KEY);
param3.setName(SincronizeLastYearCourseUnitProgramsService.JOB_importYear_KEY);
param4.setName(SincronizeLastYearCourseUnitProgramsService.JOB_validate_KEY);
param1.setDescription("desc1");
param2.setDescription("desc2");
param3.setDescription("desc3");
param4.setDescription("desc4");
param1.setObject(new Boolean(false));
param2.setObject(new Boolean(true));
param3.setObject("201415");
param4.setObject(new Boolean(true));
Set<JobServiceTaskSchedulerParameter> params = new HashSet<JobServiceTaskSchedulerParameter>();
params.add(param1);
params.add(param2);
params.add(param3);
params.add(param4);
jobServiceTaskScheduler.setServiceTaskSchedulerParameters(params);
 
jobServiceTaskScheduler.setDaily(true);
jobServiceTaskScheduler.setMonthday(GregorianCalendar.NOVEMBER);
jobServiceTaskScheduler.setWeekday(GregorianCalendar.MONDAY);
jobServiceTaskScheduler.setHour(01);
jobServiceTaskScheduler.setMinute(0);
jobServiceTaskScheduler.setSecond(0);
jobServiceTaskScheduler.setTargetService(SincronizeLastYearCourseUnitProgramsService.class.getName());
User u = (User) DaoFactory.getTeacherDaoImpl().findByEmail("jmachado@estgp.pt").get(0);
UserSession sess = new UserSession() {
@Override
public Serializable getSerializable() {
return null;
}
};
sess.setUser(u);
jobServiceTaskScheduler.setDescription("TESTE2");
new JobScheduleService().createOrUpdateScheduleServiceTask(jobServiceTaskScheduler,sess);
 
}
 
public static void scheduleImportSummaries()
{
JobServiceTaskScheduler jobServiceTaskScheduler = DomainObjectFactory.createJobServiceTaskSchedulerImpl();
jobServiceTaskScheduler.setId(0);
JobServiceTaskSchedulerParameterImpl param1 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
JobServiceTaskSchedulerParameterImpl param2 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
JobServiceTaskSchedulerParameterImpl param3 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
JobServiceTaskSchedulerParameterImpl param4 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
param1.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param2.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param3.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param4.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param1.setName(ImportSumariesJson.JOB_importYear_KEY);
param2.setName(ImportSumariesJson.JOB_semestre_KEY);
param3.setName(ImportSumariesJson.JOB_sendEmail_KEY);
param4.setName(ImportSumariesJson.JOB_sendIonline_KEY);
param1.setDescription("desc1");
param2.setDescription("desc2");
param3.setDescription("desc3");
param4.setDescription("desc4");
param1.setObject("201415");
param2.setObject("S1");
param3.setObject(new Boolean(false));
param4.setObject(new Boolean(false));
Set<JobServiceTaskSchedulerParameter> params = new HashSet<JobServiceTaskSchedulerParameter>();
params.add(param1);
params.add(param2);
params.add(param3);
params.add(param4);
jobServiceTaskScheduler.setServiceTaskSchedulerParameters(params);
 
jobServiceTaskScheduler.setDaily(true);
jobServiceTaskScheduler.setMonthday(GregorianCalendar.NOVEMBER);
jobServiceTaskScheduler.setWeekday(GregorianCalendar.MONDAY);
jobServiceTaskScheduler.setHour(01);
jobServiceTaskScheduler.setMinute(0);
jobServiceTaskScheduler.setSecond(0);
jobServiceTaskScheduler.setTargetService(ImportSumariesJson.class.getName());
User u = (User) DaoFactory.getTeacherDaoImpl().findByEmail("jmachado@estgp.pt").get(0);
UserSession sess = new UserSession() {
@Override
public Serializable getSerializable() {
return null;
}
};
sess.setUser(u);
jobServiceTaskScheduler.setDescription("TESTE Sumaries");
new JobScheduleService().createOrUpdateScheduleServiceTask(jobServiceTaskScheduler,sess);
 
}
 
public static void scheduleImportCourses()
{
JobServiceTaskScheduler jobServiceTaskScheduler = DomainObjectFactory.createJobServiceTaskSchedulerImpl();
jobServiceTaskScheduler.setId(0);
JobServiceTaskSchedulerParameterImpl param1 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
param1.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param1.setName(ImportCourseService.JOB_importYear_KEY);
param1.setDescription("desc1");
param1.setObject("201516");
Set<JobServiceTaskSchedulerParameter> params = new HashSet<JobServiceTaskSchedulerParameter>();
params.add(param1);
jobServiceTaskScheduler.setServiceTaskSchedulerParameters(params);
 
jobServiceTaskScheduler.setDaily(true);
jobServiceTaskScheduler.setMonthday(GregorianCalendar.NOVEMBER);
jobServiceTaskScheduler.setWeekday(GregorianCalendar.MONDAY);
jobServiceTaskScheduler.setHour(01);
jobServiceTaskScheduler.setMinute(0);
jobServiceTaskScheduler.setSecond(0);
jobServiceTaskScheduler.setTargetService(ImportCourseService.class.getName());
User u = (User) DaoFactory.getTeacherDaoImpl().findByEmail("jmachado@estgp.pt").get(0);
UserSession sess = new UserSession() {
@Override
public Serializable getSerializable() {
return null;
}
};
sess.setUser(u);
jobServiceTaskScheduler.setDescription("TESTE Courses");
new JobScheduleService().createOrUpdateScheduleServiceTask(jobServiceTaskScheduler,sess);
 
}
 
 
 
public static void scheduleImportStudents()
{
JobServiceTaskScheduler jobServiceTaskScheduler = DomainObjectFactory.createJobServiceTaskSchedulerImpl();
jobServiceTaskScheduler.setId(0);
JobServiceTaskSchedulerParameterImpl param1 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
param1.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param1.setName(ImportStudentsService.JOB_importYear_KEY);
param1.setDescription("desc1");
param1.setObject("201516");
Set<JobServiceTaskSchedulerParameter> params = new HashSet<JobServiceTaskSchedulerParameter>();
params.add(param1);
jobServiceTaskScheduler.setServiceTaskSchedulerParameters(params);
 
jobServiceTaskScheduler.setDaily(true);
jobServiceTaskScheduler.setMonthday(GregorianCalendar.NOVEMBER);
jobServiceTaskScheduler.setWeekday(GregorianCalendar.MONDAY);
jobServiceTaskScheduler.setHour(01);
jobServiceTaskScheduler.setMinute(0);
jobServiceTaskScheduler.setSecond(0);
jobServiceTaskScheduler.setTargetService(ImportStudentsService.class.getName());
User u = (User) DaoFactory.getTeacherDaoImpl().findByEmail("jmachado@estgp.pt").get(0);
UserSession sess = new UserSession() {
@Override
public Serializable getSerializable() {
return null;
}
};
sess.setUser(u);
jobServiceTaskScheduler.setDescription("TESTE Students");
new JobScheduleService().createOrUpdateScheduleServiceTask(jobServiceTaskScheduler,sess);
 
}
 
public static void scheduleImportTeachers()
{
JobServiceTaskScheduler jobServiceTaskScheduler = DomainObjectFactory.createJobServiceTaskSchedulerImpl();
jobServiceTaskScheduler.setId(0);
JobServiceTaskSchedulerParameterImpl param1 = DomainObjectFactory.createJobServiceTaskSchedulerParameterImpl();
param1.setJobServiceTaskScheduler(jobServiceTaskScheduler);
param1.setName(ImportTeachersService.JOB_importYear_KEY);
param1.setDescription("desc1");
param1.setObject("201516");
Set<JobServiceTaskSchedulerParameter> params = new HashSet<JobServiceTaskSchedulerParameter>();
params.add(param1);
jobServiceTaskScheduler.setServiceTaskSchedulerParameters(params);
 
jobServiceTaskScheduler.setDaily(true);
jobServiceTaskScheduler.setMonthday(GregorianCalendar.NOVEMBER);
jobServiceTaskScheduler.setWeekday(GregorianCalendar.MONDAY);
jobServiceTaskScheduler.setHour(01);
jobServiceTaskScheduler.setMinute(0);
jobServiceTaskScheduler.setSecond(0);
jobServiceTaskScheduler.setTargetService(ImportTeachersService.class.getName());
User u = (User) DaoFactory.getTeacherDaoImpl().findByEmail("jmachado@estgp.pt").get(0);
UserSession sess = new UserSession() {
@Override
public Serializable getSerializable() {
return null;
}
};
sess.setUser(u);
jobServiceTaskScheduler.setDescription("TESTE Teachers");
new JobScheduleService().createOrUpdateScheduleServiceTask(jobServiceTaskScheduler,sess);
 
}
}
/impl/src/java/pt/estgp/estgweb/services/jobs/SerializableNullJobHandler.java
New file
0,0 → 1,13
package pt.estgp.estgweb.services.jobs;
 
import java.io.Serializable;
 
/**
* Created by jorgemachado on 03/11/15.
*/
public class SerializableNullJobHandler implements Serializable, JobHandler {
@Override
public void runJob() {
 
}
}
/impl/src/java/pt/estgp/estgweb/services/jobs/ServiceJob.java
New file
0,0 → 1,129
package pt.estgp.estgweb.services.jobs;
 
import org.apache.log4j.FileAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.JobServiceTask;
import pt.estgp.estgweb.domain.JobServiceTaskImpl;
import pt.estgp.estgweb.domain.JobServiceTaskParameter;
 
import java.io.IOException;
import java.util.*;
 
/**
* Created by jorgemachado on 02/11/15.
*
* Todos os serviços podem correr em BackGround através da chamada ao JobRunner
* desde que implementem esta interface
*/
public abstract class ServiceJob implements JobHandler
{
 
/*Log for service run*/
protected final Logger serviceLog = Logger.getLogger(ServiceJob.class);
 
/*Class regular log*/
private static final Logger logger = Logger.getLogger("JobServiceTaskLog");
 
private Map<String,JobServiceTaskParameter> parameters = new HashMap<String, JobServiceTaskParameter>();
protected pt.estgp.estgweb.domain.JobServiceTaskImpl jobServiceTask = null; //to be used in subService in order to update log and check stopRequest
 
public ServiceJob()
{
 
}
 
public Collection<JobServiceTaskParameter> getParameters() { return parameters.values(); }
public Map<String,JobServiceTaskParameter> getParametersMap() { return parameters;}
public JobServiceTask getJobServiceTask() { return jobServiceTask; }
 
public void setParameters(Set<JobServiceTaskParameter> parameters)
{
this.parameters.clear();
for(JobServiceTaskParameter param: parameters)
{
this.parameters.put(param.getName(),param);
}
}
 
/**
* Inicialisation
* @param jobServiceTask
*/
public void setJobServiceTask(JobServiceTaskImpl jobServiceTask) {
this.jobServiceTask = jobServiceTask;
jobServiceTask.setProgress(0);
//Service Log initialization
logger.info("Defining service log " + jobServiceTask.getLogFilePath());
serviceLog.removeAllAppenders();
serviceLog.setLevel(org.apache.log4j.Level.INFO);
String logPath = Globals.JOB_SERVICES_LOG_DIR + java.io.File.separator + jobServiceTask.getLogFilePath();
java.io.File dirs = new java.io.File(logPath).getParentFile();
if(!dirs.exists())
dirs.mkdirs();
 
try {
serviceLog.addAppender(new FileAppender(new PatternLayout("%d (%F:%L) %-5r %-5p [%t] %c{2} - %m%n"), logPath));
} catch (IOException ex) {
logger.info("Error defining service log", ex);
}
serviceLog.setAdditivity(false);
serviceLog.info("STARTING INFO serviceLog FOR SERVICE " + jobServiceTask.getLogFilePath() + " LOG at " + jobServiceTask.getLogFilePath());
}
 
/**
* Run the job
* This method is called from JobDaemon is synchronous
*/
public void runJob()
{
if(jobServiceTask == null)
throw new RuntimeException("This Service as not been initialized to run as JobService");
 
serviceLog.info("STARTING SERVICE");
serviceLog.info("CLASS: " + jobServiceTask.getTargetService());
if(jobServiceTask.getCreatedBy() != null)
serviceLog.info("CREATED BY: " + jobServiceTask.getCreatedBy().getUsername() + " - " + jobServiceTask.getCreatedBy().getName());
else
serviceLog.info("CREATED BY: unknown");
for(JobServiceTaskParameter parameter: parameters.values())
{
serviceLog.info("PARAMETER: " + parameter.getName() + " : " + parameter.getObject().toString());
}
logger.info("Starting job service " + getClass().getName() + " more info in serviceLog " + jobServiceTask.getLogFilePath());
jobServiceTask.setProgress(0);
jobServiceTask.setThreadId(new Integer("" + Thread.currentThread().getId()));
jobServiceTask.setStatusEnum(JobServiceTaskImpl.JobStatus.STARTED);
jobServiceTask.setServiceStartDate(new Date());
jobServiceTask.setServiceLastUpdateDate(new Date());
try {
//call the implementation of service this will update serviceLog and progress
runJobServiceTask();
jobServiceTask.setStatusEnum(JobServiceTaskImpl.JobStatus.FINISHED);
jobServiceTask.setServiceLastUpdateDate(new Date());
jobServiceTask.setServiceFinishDate(new Date());
serviceLog.info("FINISHING SERVICE");
logger.info("Finishing job service " + getClass().getName() + " more info in serviceLog " + jobServiceTask.getLogFilePath());
} catch (Throwable throwable) {
jobServiceTask.setStatusEnum(JobServiceTaskImpl.JobStatus.FAILED);
jobServiceTask.setServiceLastUpdateDate(new Date());
jobServiceTask.setServiceFinishDate(new Date());
serviceLog.info("ERROR IN SERVICE", throwable);
logger.info("Error in job service " + getClass().getName() + " more info in serviceLog " + jobServiceTask.getLogFilePath());
}
}
 
public void setProgress(int progress){ if(jobServiceTask != null) jobServiceTask.setProgress(progress);}
public void serviceLogInfo(String str){ if(jobServiceTask != null) serviceLog.info(str);}
public void serviceLogWarn(String str){ if(jobServiceTask != null) serviceLog.warn(str);}
public void serviceLogError(String str){ if(jobServiceTask != null) serviceLog.error(str);}
public void serviceLogFatal(String str){ if(jobServiceTask != null) serviceLog.fatal(str);}
public void serviceLogInfo(String str, Throwable e){ if(jobServiceTask != null) serviceLog.info(str,e);}
public void serviceLogWarn(String str, Throwable e){ if(jobServiceTask != null) serviceLog.warn(str,e);}
public void serviceLogError(String str, Throwable e){ if(jobServiceTask != null) serviceLog.error(str,e);}
public void serviceLogFatal(String str, Throwable e){ if(jobServiceTask != null) serviceLog.fatal(str,e);}
 
//Implemented in SubService to run the Job
protected abstract void runJobServiceTask() throws Throwable;
}
/impl/src/java/pt/estgp/estgweb/services/jobs/JobDeamon.java
1,12 → 1,14
package pt.estgp.estgweb.services.jobs;
 
import jomm.dao.impl.AbstractDao;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.Job;
import pt.estgp.estgweb.Globals;
import jomm.dao.impl.AbstractDao;
import pt.estgp.estgweb.utils.DatesUtils;
 
import java.util.List;
import java.util.*;
 
/**
* @author Jorge Machado
23,23 → 25,63
{
try
{
logger.info("JobRunner: Waiking up");
logger.info("Jo bRunner: Waiking up");
AbstractDao.getCurrentSession().beginTransaction();
 
logger.info("JobRunner: Checking scheduler");
checkScheduler();
AbstractDao.getCurrentSession().flush();
AbstractDao.getCurrentSession().getTransaction().commit();
AbstractDao.getCurrentSession().beginTransaction();
logger.info("JobRunner: Checking jobs");
List<Job> jobs = DaoFactory.getJobDaoImpl().findExecutableJobs();
logger.info("JobRunner found: " + jobs.size() + " jobs");
for(Job j: jobs)
{
logger.info("JobRunner running job: " + j.getDescription());
JobRunner jobRunner = new JobRunner((JobHandler) j.getJobHandler());
jobRunner.run();
j.setExecuted(true);
DaoFactory.getJobDaoImpl().reattach(j);
try{
JobRunner jobRunner;
if(j instanceof JobServiceTaskImpl)
{
logger.info("JobRunner running jobServiceTask: " + j.getDescription());
jobRunner = new JobRunner((JobHandler) j);
}
else
{
logger.info("JobRunner running job: " + j.getDescription());
jobRunner = new JobRunner((JobHandler) j.getJobHandler());
}
 
jobRunner.run();
j.setExecuted(true);
DaoFactory.getJobDaoImpl().saveOrUpdate(j);
AbstractDao.getCurrentSession().flush();
AbstractDao.getCurrentSession().evict(j);
}
catch(Throwable e)
{
 
j.setExecuted(true);
DaoFactory.getJobDaoImpl().saveOrUpdate(j);
AbstractDao.getCurrentSession().flush();
AbstractDao.getCurrentSession().evict(j);
logger.error(e,e);
}
Thread.sleep(2000);
}
 
AbstractDao.getCurrentSession().flush();
AbstractDao.getCurrentSession().getTransaction().commit();
Thread.sleep(Globals.JOB_DEAMON_SLEEP_SECONDS*1000);
 
}
catch (InterruptedException e)
catch(HibernateException e)
{
AbstractDao.getCurrentSession().getTransaction().rollback();
logger.error("Need to Rolling back " + e.toString(),e);
}
catch (Throwable e)
{
logger.error(e,e);
try
{
55,6 → 97,96
}
}
}
 
private void checkScheduler()
{
List<JobServiceTaskScheduler> schedules = DaoFactory.getJobServiceTaskSchedulerDaoImpl().findAll();
for(JobServiceTaskScheduler schedule: schedules)
{
Date last = schedule.getLastScheduleDate();
 
if(isRunnableNow(schedule, last))
{
logger.info("Schedulling one job " + schedule.getTargetService() + " to run");
JobServiceTaskImpl jobServiceTask = DomainObjectFactory.createJobServiceTaskImpl();
DaoFactory.getJobServiceTaskDaoImpl().save(jobServiceTask);
jobServiceTask.setStartDate(new Date());
DaoFactory.getJobServiceTaskDaoImpl().flush();
jobServiceTask.setTargetService(schedule.getTargetService());
jobServiceTask.setCreatedBy(schedule.getCreatedBy());
jobServiceTask.setExecuted(false);
jobServiceTask.setDescription("Service:" + schedule.getDescription());
jobServiceTask.setServiceDescription(schedule.getDescription());
jobServiceTask.setSaveDate(new Date());
jobServiceTask.setStatusEnum(JobServiceTaskImpl.JobStatus.PENDING);
jobServiceTask.setRequestStop(false);
jobServiceTask.setOwner(schedule.getCreatedBy());
jobServiceTask.setJobHandler(new SerializableNullJobHandler());
try {
String filePath = Class.forName(schedule.getTargetService()).getSimpleName() + "-" + DatesUtils.getFormatedFileSystem(new Date());
jobServiceTask.setLogFilePath( filePath + ".log");
} catch (ClassNotFoundException e) {
logger.fatal(e,e);
continue;
}
Set<JobServiceTaskParameter> paramsJob = new HashSet<JobServiceTaskParameter>();
for(JobServiceTaskSchedulerParameter param : schedule.getServiceTaskSchedulerParameters())
{
JobServiceTaskParameterImpl paramJob = DomainObjectFactory.createJobServiceTaskParameterImpl();
paramJob.setName(param.getName());
paramJob.setDescription(param.getDescription());
paramJob.setObject(param.getObject());
paramsJob.add(paramJob);
paramJob.setJobServiceTask(jobServiceTask);
DaoFactory.getJobServiceTaskParameterDaoImpl().save(paramJob);
}
DaoFactory.getJobServiceTaskParameterDaoImpl().flush();
jobServiceTask.setServiceTaskParameters(paramsJob);
DaoFactory.getJobServiceTaskDaoImpl().saveOrUpdate(jobServiceTask);
 
//a last schedule date e a hora a que foi marcado para correr a ultima vez
//a partir do momento que e' agendado o trabalho ele vai correr portanto
//e' esta a hora que se considera para a corrida
schedule.setLastScheduleDate(new Date());
}
//Remove Now Schedules
if(schedule.isNow())
{
DaoFactory.getJobServiceTaskSchedulerDaoImpl().delete(schedule);
}
}
}
 
private boolean isRunnableNow(JobServiceTaskScheduler schedule,Date lastDate)
{
if(lastDate == null)
lastDate = new Date(0);
GregorianCalendar gC = new GregorianCalendar();
gC.setTime(lastDate);
GregorianCalendar gCNow = new GregorianCalendar();
gCNow.setTime(new Date());
 
if(schedule.isNow())
return true;
else if(schedule.isWeekly() && schedule.getWeekday() != gCNow.get(GregorianCalendar.DAY_OF_WEEK))
return false;
else if(schedule.isMonthly() && schedule.getMonthday() != gCNow.get(GregorianCalendar.DAY_OF_MONTH))
return false;
 
//Neste momento ou é da semana e estamos no dia da semana ou e do mes e estamos no dia do mes
//ou e' diario
//portanto o que interessa e' ver se ja correu hoje depois da hora que e' para correr
//se ainda nao correu hoje tem de correr
//Criar um gcRunTime com a hora de corrida de hoje ou seja ano, mes e dia de hoje hora minuto e segundo do schedulle
GregorianCalendar gCRunTime = new GregorianCalendar();
gCRunTime.set(gCNow.get(GregorianCalendar.YEAR),gCNow.get(GregorianCalendar.MONTH),gCNow.get(GregorianCalendar.DAY_OF_MONTH),
schedule.getHour(),schedule.getMinute(),schedule.getSecond());
//Ja estamos depois da runTime? now > runtime?
// e a ultima vez que correu está antes da RunTime de Hoje portanto ainda não correu depois desta runtime
//tem de correr
return gCNow.getTimeInMillis() > gCRunTime.getTimeInMillis() && lastDate.getTime() < gCRunTime.getTimeInMillis();
//assim funciona mesmo que mudem a runtime para depois mesmo que hoje ja tenha corrido e corre novamente
}
public static void main(String [] args)
{
new JobDeamon().run();
/impl/src/java/pt/estgp/estgweb/services/profile/CurriculumService.java
9,7 → 9,6
import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum;
import pt.estgp.estgweb.services.data.RepositoryService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.io.InputStream;
139,8 → 138,8
if(u instanceof Teacher)
{
Teacher teacher = (Teacher) u;
courseUnits = new HashSet<CourseUnit>(DaoFactory.getCourseUnitDaoImpl().loadTeachedImportYearUnits(teacher.getId(), DatesUtils.getImportYear()));
responsableCourseUnits = new HashSet<CourseUnit>(DaoFactory.getCourseUnitDaoImpl().loadResponsableImportYearUnits(teacher.getId(), DatesUtils.getImportYear()));
courseUnits = new HashSet<CourseUnit>(DaoFactory.getCourseUnitDaoImpl().loadTeachedImportYearUnits(teacher.getId(), DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()));
responsableCourseUnits = new HashSet<CourseUnit>(DaoFactory.getCourseUnitDaoImpl().loadResponsableImportYearUnits(teacher.getId(), DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()));
userView.setResponsableCourseUnits(new ArrayList<CourseUnitView>());
for(CourseUnit c: responsableCourseUnits)
{
/impl/src/java/pt/estgp/estgweb/services/users/LoadUsersService.java
9,7 → 9,6
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.UserView;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.ArrayList;
62,7 → 61,7
 
public List<UserView> loadTeachersWithUnits(String area) throws ServiceException
{
List<User> users = DaoFactory.getTeacherDaoImpl().loadByAreaWithUnitsInYear(area, DatesUtils.getImportYear());
List<User> users = DaoFactory.getTeacherDaoImpl().loadByAreaWithUnitsInYear(area, DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
if(users == null)
return null;
return UserView.getViews(users);
/impl/src/java/pt/estgp/estgweb/services/users/CreateUserService.java
2,6 → 2,7
 
import jomm.utils.BytesUtils;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.User;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.dao.DaoFactory;
50,8 → 51,10
 
//Advising CommonsServicesManager before change password
CommonServicesManager.getInstance().adviseNew(user);
 
user.setPassword(BytesUtils.getMD5(user.getPassword()));
if(!Globals.USE_LDAP || userSession.getUser().isSuperuserOrAdmin())
{
user.setPassword(BytesUtils.getMD5(user.getPassword()));
}
if (userSession.getUser() == null)
logger.info("Anonimous - Creating user:" + user.getId() + " " + user.getName());
else
/impl/src/java/pt/estgp/estgweb/services/sms/SmsService.java
1,5 → 1,6
package pt.estgp.estgweb.services.sms;
 
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.Globals;
26,9 → 27,10
try
{
SiGesWEB service;
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
try
{
service = new SiGesWEB(new URL(Globals.SIGES_WEBSERVICE_WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
service = new SiGesWEB(new URL(WSDL), new QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
}
catch (MalformedURLException e)
{
/impl/src/java/pt/estgp/estgweb/services/logresults/impl/DefaultLogMessage.java
35,11 → 35,11
 
 
 
public DefaultLogMessage(String messageKey, String errorMsg, String errorDetails, LogMessageTypeEnum type)
public DefaultLogMessage(String messageKey, String msg, String details, LogMessageTypeEnum type)
{
this.messageKey = messageKey;
this.msg = errorMsg;
this.details = errorDetails;
this.msg = msg;
this.details = details;
this.type = type;
}
 
82,4 → 82,5
{
this.msg = msg;
}
 
}
/impl/src/java/pt/estgp/estgweb/services/logresults/impl/DefaultLogMessages.java
1,5 → 1,6
package pt.estgp.estgweb.services.logresults.impl;
 
import pt.estgp.estgweb.domain.CourseUnitSummary;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.ILogMessage;
 
15,6 → 16,7
{
 
private List<ILogMessage> logMessages;
List<CourseUnitSummary> summaries;
 
 
public List<ILogMessage> getLogMessages()
33,4 → 35,16
logMessages = new ArrayList<ILogMessage>();
logMessages.add(message);
}
 
public List<CourseUnitSummary> getSummaries() {
return summaries;
}
 
public void setSummaries(List<CourseUnitSummary> summaries) {
this.summaries = summaries;
}
 
public String getLastMessage(){
return logMessages.get(logMessages.size()-1).getMsg() + " " + logMessages.get(logMessages.size()-1).getDetails();
}
}
/impl/src/java/pt/estgp/estgweb/services/logresults/ILogMessages.java
1,5 → 1,7
package pt.estgp.estgweb.services.logresults;
 
import pt.estgp.estgweb.domain.CourseUnitSummary;
 
import java.util.List;
 
/**
10,4 → 12,5
public interface ILogMessages
{
public List<ILogMessage> getLogMessages();
List<CourseUnitSummary> getSummaries();
}
/impl/src/java/pt/estgp/estgweb/services/blogs/LoadEditableBlogs.java
1,16 → 1,15
package pt.estgp.estgweb.services.blogs;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.domain.views.BlogView;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.BlogImpl;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.BlogImpl;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.BlogView;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.Globals;
import org.apache.log4j.Logger;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
 
/**
* @author Jorge Machado
34,4 → 33,18
}
return blogViews;
}
 
public List<BlogView> loadMax(Integer max,UserSession userSession) throws ServiceException
{
boolean internal = true;
if (userSession.getUser() == null)
internal = false;
List<BlogImpl> blogs = DaoFactory.getBlogDaoImpl().findBlogs(userSession.getUser().getRolesList(), internal,max);
List<BlogView> blogViews = new ArrayList<BlogView>();
for(BlogImpl b: blogs)
{
blogViews.add(new BlogView(b));
}
return blogViews;
}
}
/impl/src/java/pt/estgp/estgweb/services/blogs/LoadOwnerBlogs.java
30,4 → 30,14
}
return blogViews;
}
public List<BlogView> loadMax(Integer max, UserSession userSession) throws ServiceException
{
List<BlogImpl> blogs = DaoFactory.getBlogDaoImpl().loadOwnedBlogs(userSession.getUser().getId(),max);
List<BlogView> blogViews = new ArrayList<BlogView>();
for(BlogImpl b: blogs)
{
blogViews.add(new BlogView(b));
}
return blogViews;
}
}
/impl/src/java/pt/estgp/estgweb/services/blogs/LoadOwnerBlogPosts.java
1,17 → 1,15
package pt.estgp.estgweb.services.blogs;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.domain.views.BlogView;
import pt.estgp.estgweb.domain.views.BlogPostView;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.BlogPostImpl;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.BlogImpl;
import pt.estgp.estgweb.domain.BlogPostImpl;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.BlogPostView;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import org.apache.log4j.Logger;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
 
/**
* @author Jorge Machado
32,4 → 30,15
}
return blogViews;
}
 
public List<BlogPostView> loadMax(Integer max, UserSession userSession) throws ServiceException
{
List<BlogPostImpl> blogs = DaoFactory.getBlogPostDaoImpl().loadOwnedBlogPostsMax(userSession.getUser().getId(), max);
List<BlogPostView> blogViews = new ArrayList<BlogPostView>();
for(BlogPostImpl b: blogs)
{
blogViews.add(new BlogPostView(b));
}
return blogViews;
}
}
/impl/src/java/pt/estgp/estgweb/services/assessments/CreateEditAssessmentService.java
36,7 → 36,7
assessmentView.persistViewInObject(a);
a.setOwner(userSession.getUser());
a.setSemester(DatesUtils.getSemestre());
a.setYear(DatesUtils.getImportYear());
a.setYear(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());//nao e' usado este metodo
a.setSaveDate(new Date());
a.setStatusPercentage(0);
a.setStatus(SurveyStatusEnum.STATUS_STOPPED.getStatus());
/impl/src/java/pt/estgp/estgweb/services/announcements/LoadTypeMaxAnnouncementsService.java
1,5 → 1,6
package pt.estgp.estgweb.services.announcements;
 
import pt.estgp.estgweb.Globals;
import pt.utl.ist.berserk.logic.serviceManager.IService;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.domain.views.AnnouncementView;
22,6 → 23,7
{
private static final Logger logger = Logger.getLogger(LoadTypeMaxAnnouncementsService.class);
private static final int MAX_ANNOUNCEMENTS = ConfigProperties.getIntProperty("announcements.max.visible");
private static final int MAX_ANNOUNCEMENTS_NEWS = ConfigProperties.getIntProperty("announcements.max.news.visible");
 
public List<AnnouncementView> run(String type, String subTarget, UserSession userSession)
{
31,7 → 33,10
boolean internal = true;
if (userSession.getUser() == null)
internal = false;
List<Announcement> announcements = DaoFactory.getAnnouncementDaoImpl().findAnnouncements(MAX_ANNOUNCEMENTS,targetRoles,type,subTarget,internal);
int max = MAX_ANNOUNCEMENTS;
if(type != null && type.equals(Globals.ANNOUNCEMENT_TYPE_NEWS))
max = MAX_ANNOUNCEMENTS_NEWS;
List<Announcement> announcements = DaoFactory.getAnnouncementDaoImpl().findAnnouncements(max,targetRoles,type,subTarget,internal);
if(announcements == null)
return null;
List<AnnouncementView> announcementViews = new ArrayList<AnnouncementView>();
/impl/src/java/pt/estgp/estgweb/services/announcements/LoadOwnerAnnouncements.java
1,18 → 1,16
package pt.estgp.estgweb.services.announcements;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.AnnouncementImpl;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.AnnouncementView;
import pt.estgp.estgweb.services.blogs.LoadBlogService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.domain.views.BlogView;
import pt.estgp.estgweb.domain.views.AnnouncementView;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.BlogImpl;
import pt.estgp.estgweb.domain.AnnouncementImpl;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import org.apache.log4j.Logger;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
 
/**
* @author Jorge Machado
33,4 → 31,16
}
return announcementViews;
}
 
 
public List<AnnouncementView> loadMax(Integer max, UserSession userSession) throws ServiceException
{
List<AnnouncementImpl> announcements = DaoFactory.getAnnouncementDaoImpl().loadOwnedAnnouncements(userSession.getUser().getId(),max);
List<AnnouncementView> announcementViews = new ArrayList<AnnouncementView>();
for(AnnouncementImpl announcement: announcements)
{
announcementViews.add(new AnnouncementView(announcement));
}
return announcementViews;
}
}
/impl/src/java/pt/estgp/estgweb/services/authenticate/AuthenticateService.java
1,19 → 1,21
package pt.estgp.estgweb.services.authenticate;
 
import jomm.utils.DesUtils;
import openldap.ILdapManager;
import openldap.LdapManagerFactory;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.common.CommonServicesManager;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import pt.estgp.estgweb.services.common.CommonServicesManager;
import pt.estgp.estgweb.services.ftpservices.FtpService;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.utl.ist.berserk.logic.serviceManager.IService;
import openldap.ILdapManager;
import openldap.LdapManagerFactory;
 
import java.util.HashMap;
import java.util.Set;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
 
 
/*
70,6 → 72,9
 
if(u == null)
{
logger.warn("user:" + username + " does not exist");
throw new AuthenticateException(AuthenticateException.DOES_NOT_EXIST);
/*
u = getUserInfo(username);
u.setPassword(password);
//put password to be complete for advising
83,13 → 88,13
else if (u.getRoles().contains("student"))
{
 
}
}*/
}
else
{
// String passwordAux = u.getPassword();
u.setPassword(password);
//put password to be complete for advising
 
CommonServicesManager.getInstance().adviseUpdate(u);
// u.setPassword(passwordAux);
u.setPassword(jomm.utils.BytesUtils.getDigestMD5Hex(password));
108,7 → 113,15
}
 
logger.warn("user:" + username + " authenticated");
((UserSessionImpl)userSession).clearObjectsWithOpenTransaction();
 
//((UserSessionImpl)userSession).reset();
//((UserSessionImpl)userSession).clearObjectsWithOpenTransaction();
 
//DaoFactory.getUserSessionDaoImpl().flush();
 
//PASSWORD PARA SERVICOS FTP CLIENT
((UserSessionImpl) userSession).put(FtpService.FTP_PASSWORD, DesUtils.getInstance().encrypt(password));
//put password to be complete for advising
userSession.setName(u.getName());
userSession.setUsername(u.getUsername());
userSession.setUser(u);
/impl/src/java/pt/estgp/estgweb/services/authenticate/LogoutService.java
1,12 → 1,10
package pt.estgp.estgweb.services.authenticate;
 
import pt.utl.ist.berserk.logic.serviceManager.IService;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.User;
import pt.estgp.estgweb.domain.UserSessionImpl;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.expceptions.ServiceException;
import org.apache.log4j.Logger;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
/*
* @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt
30,6 → 28,8
{
logger.warn("user:" + userSession.getCookie() + " logout");
((UserSessionImpl)userSession).reset();
//TODO NOVO
((UserSessionImpl)userSession).clearObjectsWithOpenTransaction();
return userSession;
}
}
/impl/src/java/pt/estgp/estgweb/services/authenticate/AuthenticateException.java
6,6 → 6,7
{
public static final String ALREADY_AUTHENTICATED = "authenticate.already.authenticated";
public static final String FAIL_AUTHENTICATION = "fail.authenticate";
public static final String DOES_NOT_EXIST = "dontexist.authenticate";
public static final String BLOCKED = "authenticate.blocked";
 
public AuthenticateException()
/impl/src/java/pt/estgp/estgweb/domain/StudentImpl.java
7,7 → 7,9
import pt.utl.ist.berserk.logic.serviceManager.ServiceManager;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
* @author Jorge Machado
66,6 → 68,26
return getUnitsSemestre("A",getSubscribedUnitsView());
}
 
public List<CourseUnit> getSubscribedUnitsViewT1()
{
return getUnitsSemestre("T1",getSubscribedUnitsView());
}
 
public List<CourseUnit> getSubscribedUnitsViewT2()
{
return getUnitsSemestre("T2",getSubscribedUnitsView());
}
 
public List<CourseUnit> getSubscribedUnitsViewT3()
{
return getUnitsSemestre("T3",getSubscribedUnitsView());
}
 
public List<CourseUnit> getSubscribedUnitsViewT4()
{
return getUnitsSemestre("T4",getSubscribedUnitsView());
}
 
public List<CourseUnit> getSubscribedUnitsView()
{
if(subscribedUnitsView == null)
95,6 → 117,23
return subscribedUnitsView;
}
 
public List<CourseUnit> getSubscribedUnitsCurrentYearViewT1()
{
return getUnitsSemestre("T1",getSubscribedUnitsCurrentYearView());
}
public List<CourseUnit> getSubscribedUnitsCurrentYearViewT2()
{
return getUnitsSemestre("T2",getSubscribedUnitsCurrentYearView());
}
public List<CourseUnit> getSubscribedUnitsCurrentYearViewT3()
{
return getUnitsSemestre("T3",getSubscribedUnitsCurrentYearView());
}
public List<CourseUnit> getSubscribedUnitsCurrentYearViewT4()
{
return getUnitsSemestre("T4",getSubscribedUnitsCurrentYearView());
}
 
public List<CourseUnit> getSubscribedUnitsCurrentYearViewS1()
{
return getUnitsSemestre("S1",getSubscribedUnitsCurrentYearView());
137,6 → 176,61
return subscribedUnitsCurrentYearView;
}
 
Map<String,List<CourseUnit>> subscribedUnitsYear = new HashMap<String,List<CourseUnit>>();
 
public List<CourseUnit> getSubscribedUnitsView(String year)
{
List<CourseUnit> cuYear = subscribedUnitsYear.get(year);
if(cuYear == null)
{
try
{
IServiceManager sm = ServiceManager.getInstance();
String[] names = new String[]{"serializable","year"};
Object[] args = new Object[]{getId(),year};
cuYear = (List<CourseUnit>) sm.execute(null, "LoadSubscribedUnitsGivenYear", args, names);
 
for(CourseUnit c: cuYear)
{
cuYear.add(c);
}
}
catch (Throwable e)
{
logger.error(e,e);
}
}
return cuYear;
}
public List<CourseUnit> getSubscribedUnitsViewA(String year)
{
return getUnitsSemestre("A", getSubscribedUnitsView(year));
}
public List<CourseUnit> getSubscribedUnitsViewS1(String year)
{
return getUnitsSemestre("S1",getSubscribedUnitsView(year));
}
public List<CourseUnit> getSubscribedUnitsViewS2(String year)
{
return getUnitsSemestre("S2",getSubscribedUnitsView(year));
}
public List<CourseUnit> getSubscribedUnitsViewT1(String year)
{
return getUnitsSemestre("T1",getSubscribedUnitsView(year));
}
public List<CourseUnit> getSubscribedUnitsViewT2(String year)
{
return getUnitsSemestre("T2",getSubscribedUnitsView(year));
}
public List<CourseUnit> getSubscribedUnitsViewT3(String year)
{
return getUnitsSemestre("T3",getSubscribedUnitsView(year));
}
public List<CourseUnit> getSubscribedUnitsViewT4(String year)
{
return getUnitsSemestre("T4",getSubscribedUnitsView(year));
}
 
public List<CourseUnit> getSubscribedUnitsOldYearsViewS1()
{
return getUnitsSemestre("S1",getSubscribedUnitsOldYearsView());
249,4 → 343,6
}
 
 
 
 
}
/impl/src/java/pt/estgp/estgweb/domain/CourseUnitProgramImpl.java
5,10 → 5,8
import org.dom4j.*;
import org.hibernate.NonUniqueResultException;
import org.hibernate.Session;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.courseunits.SaveCourseUnitProgram;
import pt.estgp.estgweb.utils.DatesUtils;
 
import javax.xml.transform.TransformerException;
import java.io.File;
230,7 → 228,7
 
System.out.println("CONSISTING COURSE IDS in units:");
HibernateUtils.getCurrentSession().beginTransaction();
DaoFactory.getCourseUnitDaoImpl().consistCourseUnitCourseCodes(DatesUtils.getImportYear());
DaoFactory.getCourseUnitDaoImpl().consistCourseUnitCourseCodes(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
HibernateUtils.getCurrentSession().getTransaction().commit();
System.out.println("Done");
 
332,7 → 330,7
affectedRows.put((r-3),"AFFECTED");
if(index > i+1)
{
int indexHoles = index - 1 - i ; //porque o Index começa em 1
int indexHoles = index - 1 - i ; //porque o Index come�a em 1
for(int j=0; j < indexHoles;j++)
{
System.out.println("SPACES ###############################");
519,13 → 517,13
{
if(!setCourse(cu, line))
{
errors.add("Curso não encontrada: line.codigoSIGESUnidade,line.codigoCurso,line.semestre, importYear: " + line.codigoSIGESUnidade + ":" + line.codigoCurso + ":" + line.semestre + ":" + importYear );
errors.add("Curso n�o encontrada: line.codigoSIGESUnidade,line.codigoCurso,line.semestre, importYear: " + line.codigoSIGESUnidade + ":" + line.codigoCurso + ":" + line.semestre + ":" + importYear );
return;
}
}
else
{
errors.add("Unidade não encontrada: line.codigoSIGESUnidade,line.codigoCurso,line.semestre, importYear: " + line.codigoSIGESUnidade + ":" + line.codigoCurso + ":" + line.semestre + ":" + importYear );
errors.add("Unidade n�o encontrada: line.codigoSIGESUnidade,line.codigoCurso,line.semestre, importYear: " + line.codigoSIGESUnidade + ":" + line.codigoCurso + ":" + line.semestre + ":" + importYear );
// cu = createNewCourseUnit(cu,line,importYear);
return;
}
625,7 → 623,7
cu.setCode(line.codigoSIGESUnidade);
cu.setCourseCode(line.codigoCurso);
cu.setName(line.nomeUnidadeCurricular);
cu.setInstitutionCode("" + Globals.SIGES_INSTITUTION_CODE);
cu.setInstitutionCode("" + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode());
 
setCourse(cu, line);
DaoFactory.getCourseUnitDaoImpl().save(cu);
/impl/src/java/pt/estgp/estgweb/domain/ConfigurationGradesStatusEpocaImpl.java
New file
0,0 → 1,27
package pt.estgp.estgweb.domain;
 
import java.io.Serializable;
import java.util.Date;
 
/**
* Created by jorgemachado on 02/11/15.
*/
public class ConfigurationGradesStatusEpocaImpl extends ConfigurationGradesStatusEpoca {
 
public ConfigurationGradesStatusEpocaImpl()
{
}
@Override
public Serializable getSerializable() {
return getId();
}
 
public static ConfigurationGradesStatusEpocaImpl create(String status, String descricao)
{
ConfigurationGradesStatusEpocaImpl obj = DomainObjectFactory.createConfigurationGradesStatusEpocaImpl();
obj.setStatus(status);
obj.setDescricao(descricao);
obj.setSaveDate(new Date());
return obj;
}
}
/impl/src/java/pt/estgp/estgweb/domain/TeacherImpl.java
70,6 → 70,27
{
return getUnitsSemestre("A",getTeachedUnitsView());
}
 
public List<CourseUnit> getTeachedUnitsViewT1()
{
return getUnitsSemestre("T1",getTeachedUnitsView());
}
 
public List<CourseUnit> getTeachedUnitsViewT2()
{
return getUnitsSemestre("T2",getTeachedUnitsView());
}
 
public List<CourseUnit> getTeachedUnitsViewT3()
{
return getUnitsSemestre("T3",getTeachedUnitsView());
}
 
public List<CourseUnit> getTeachedUnitsViewT4()
{
return getUnitsSemestre("T4",getTeachedUnitsView());
}
 
public List<CourseUnit> getTeachedUnitsView()
{
if(teachedUnitsView == null)
112,8 → 133,28
return getUnitsSemestre("A",getTeachedUnitsCurrentYearView());
}
 
public List<CourseUnit> getTeachedUnitsCurrentYearViewT1()
{
return getUnitsSemestre("T1",getTeachedUnitsCurrentYearView());
}
 
public List<CourseUnit> getTeachedUnitsCurrentYearViewT2()
{
return getUnitsSemestre("T2",getTeachedUnitsCurrentYearView());
}
 
public List<CourseUnit> getTeachedUnitsCurrentYearViewT3()
{
return getUnitsSemestre("T3",getTeachedUnitsCurrentYearView());
}
 
public List<CourseUnit> getTeachedUnitsCurrentYearViewT4()
{
return getUnitsSemestre("T4",getTeachedUnitsCurrentYearView());
}
 
 
 
public List<CourseUnit> getTeachedUnitsViewS1(String year)
{
return getUnitsSemestre("S1",getTeachedUnitsView(year));
127,6 → 168,26
return getUnitsSemestre("A",getTeachedUnitsView(year));
}
 
public List<CourseUnit> getTeachedUnitsViewT1(String year)
{
return getUnitsSemestre("T1",getTeachedUnitsView(year));
}
 
public List<CourseUnit> getTeachedUnitsViewT2(String year)
{
return getUnitsSemestre("T2",getTeachedUnitsView(year));
}
 
public List<CourseUnit> getTeachedUnitsViewT3(String year)
{
return getUnitsSemestre("T3",getTeachedUnitsView(year));
}
 
public List<CourseUnit> getTeachedUnitsViewT4(String year)
{
return getUnitsSemestre("T4",getTeachedUnitsView(year));
}
 
Map<String,List<CourseUnit>> teachedUnitsYear = new HashMap<String,List<CourseUnit>>();
Map<String,List<Course>> teachedCourseYear = new HashMap<String,List<Course>>();
 
223,15 → 284,27
public void removeUnitLocaly(CourseUnit unit)
{
setLocalRemovedTeachedUnits(StringsUtils.addElement(getLocalRemovedTeachedUnits(),"" + unit.getId(),","));
 
//todo novo
setLocalTeachedUnits(StringsUtils.removeElement(getLocalTeachedUnits(),"" + unit.getId(),","));
}
 
public void addUnitLocaly(CourseUnit unit)
{
setLocalRemovedTeachedUnits(StringsUtils.removeElement(getLocalRemovedTeachedUnits(),"" + unit.getId(),","));
 
//todo novo
setLocalTeachedUnits(StringsUtils.removeElement(getLocalTeachedUnits(),"" + unit.getId(),","));
setLocalTeachedUnits(StringsUtils.addElement(getLocalTeachedUnits(),"" + unit.getId(),","));
}
 
public boolean isLocalRemovedUnit(CourseUnit unit)
{
return StringsUtils.hasElement(getLocalRemovedTeachedUnits(),"" + unit.getId(),",");
}
 
public boolean isLocalUnit(CourseUnit unit)
{
return StringsUtils.hasElement(getLocalTeachedUnits(),""+unit.getId(),",");
}
}
/impl/src/java/pt/estgp/estgweb/domain/CourseUnitSummaryImpl.java
1,14 → 1,14
package pt.estgp.estgweb.domain;
 
import org.apache.log4j.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.web.utils.DatesUtils;
 
import java.util.List;
import java.io.Serializable;
import java.util.Date;
import java.io.Serializable;
 
import pt.estgp.estgweb.domain.enums.AnnouncementStyleEnum;
import pt.estgp.estgweb.utils.RoleManager;
 
/**
* @author Jorge Machado
* @date 2/Mar/2008
25,4 → 25,106
{
return getId();
}
 
 
public String getTipoAulaDesc()
{
if(getTipoAula() == null)
return "Desconhecida";
String tipo = ConfigProperties.getProperty("netpa.tipo.aula." + getTipoAula().trim());
if(tipo == null)
return "Desconhecida";
else
return tipo;
}
 
public String getDataAulaDesc()
{
if(getDataAula() == null)
return "Desconhecida";
return DatesUtils.getStringFromDate(getDataAula());
}
 
public Date fromDataAulaDesc(String date)
{
if(date == null)
return new Date(0);
return DatesUtils.getDateFromString(date);
 
}
 
 
public JSONObject getJson() throws JSONException {
 
JSONObject jsonObject = new JSONObject();
 
jsonObject.put("id",getId());
jsonObject.put("updateDate",getUpdateDate());
jsonObject.put("saveDate", getSaveDate());
jsonObject.put("dataAula", getDataAulaDesc());
jsonObject.put("tipoAula", getTipoAulaDesc());
jsonObject.put("codigoAula", getCodigoAula());
jsonObject.put("codigoSumario", getCodigoSumario());
jsonObject.put("codigoSalaAula", getCodigoSalaAula());
jsonObject.put("alunosPresentes", getAlunosPresentes());
jsonObject.put("numeroAula", getNumeroAula());
jsonObject.put("titulo", getTitulo());
jsonObject.put("descricao", getDescricao());
jsonObject.put("cEstado", getcEstado());
jsonObject.put("numeroHoras", getNumeroHoras());
return jsonObject;
}
 
 
public boolean updateWithJson(JSONObject json)
{
try {
if(json.has("dataAula"))
setDataAula(fromDataAulaDesc(json.getString("dataAula")));
if(json.has("tipoAula"))
setTipoAula(json.getString("tipoAula"));
if(json.has("codigoAula"))
setCodigoAula(json.getString("codigoAula"));
if(json.has("codigoAula"))
setCodigoSumario(json.getString("codigoAula"));
if(json.has("codigoSalaAula"))
setCodigoSalaAula(json.getString("codigoSalaAula"));
if(json.has("alunosPresentes"))
setAlunosPresentes(json.getInt("alunosPresentes"));
if(json.has("numeroAula"))
setNumeroAula(json.getInt("numeroAula"));
if(json.has("titulo"))
setTitulo(json.getString("titulo"));
if(json.has("descricao"))
setDescricao(json.getString("descricao"));
if(json.has("cEstado"))
setcEstado(json.getString("cEstado"));
if(json.has("numeroHoras"))
setNumeroHoras(json.getString("numeroHoras"));
 
return json.has("titulo") || json.has("descricao");
} catch (JSONException e) {
logger.error(e,e);
}
return false;
}
 
public String toString() {
return "CourseUnitSummary{" +
"id=" + getId() +
", updateDate=" + getUpdateDate() +
", saveDate=" + getSaveDate() +
", dataAula=" + getDataAula() +
", tipoAula='" + getTipoAula() + '\'' +
", codigoAula='" + getCodigoAula() + '\'' +
", codigoSumario='" + getCodigoSumario() + '\'' +
", codigoSalaAula='" + getCodigoSalaAula() + '\'' +
", alunosPresentes=" + getAlunosPresentes() +
", numeroAula=" + getNumeroAula() +
", titulo='" + getTitulo() + '\'' +
", descricao='" + getDescricao() + '\'' +
", cEstado='" + getcEstado() + '\'' +
", numeroHoras=" + getNumeroHoras() +
'}';
}
}
/impl/src/java/pt/estgp/estgweb/domain/ProcessEventImpl.java
176,4 → 176,35
}
return false;
}
 
 
 
@Override
public String toString() {
return "ProcessEvent{" +
"id=" + getId() +
", updateDate=" + getUpdateDate() +
", openDate=" + getOpenDate() +
", acceptedDate=" + getAcceptedDate() +
", dispatchedDate=" + getDispatchedDate() +
", lastChangeDate=" + getLastChangeDate() +
", closeDate=" + getCloseDate() +
", nowState='" + getNowState() + '\'' +
", accepted=" + isAccepted() +
", destinationRole='" + getDestinationRole() + '\'' +
", notes='" + getNotes() + '\'' +
", notesAccessLevel='" + getNotesAccessLevel() + '\'' +
", notesAccessIdentifiers='" + getNotesAccessIdentifiers() + '\'' +
", notesAccessRoles='" + getNotesAccessRoles() + '\'' +
", notesToStarter='" + getNotesToStarter() + '\'' +
", process=" + getProcess().getId() +
", previousEvent=" + getPreviousEvent().getId() +
", nextEvent=" +
", owner=" + getOwner().getUsername() +
", files=" + getFiles() +
'}';
}
 
 
 
}
/impl/src/java/pt/estgp/estgweb/domain/views/CourseUnitSummaryView.java
4,6 → 4,7
import pt.estgp.estgweb.web.utils.DatesUtils;
 
import java.io.Serializable;
import java.util.Date;
 
/**
* @author Jorge Machado
22,10 → 23,17
private int number;
private String date;
private int students;
private String horas;
private String tipoAula;
private String codigoAula;
private String codigoSumario;
private String codigoSala;
private Date originalDate;
 
 
public CourseUnitSummaryView() {
}
 
 
public CourseUnitSummaryView(CourseUnitSummary summary)
{
super(summary);
38,8 → 46,15
this.title = summary.getTitulo();
this.description = summary.getDescricao();
this.date = DatesUtils.getStringFromDate(summary.getDataAula());
this.originalDate = summary.getDataAula();
this.number = summary.getNumeroAula();
this.students = summary.getAlunosPresentes();
this.horas = summary.getNumeroHoras();
this.tipoAula = summary.getTipoAula();
this.codigoAula = summary.getCodigoAula();
this.codigoSumario = summary.getCodigoSumario();
this.codigoSala = summary.getCodigoSalaAula();
 
}
 
// public void persistViewInObject(Announcement announcement)
83,8 → 98,32
return date;
}
 
public Date getOriginalDate() {
return originalDate;
}
 
public int getStudents()
{
return students;
}
 
public String getHoras() {
return horas;
}
 
public String getTipoAula() {
return tipoAula;
}
 
public String getCodigoAula() {
return codigoAula;
}
 
public String getCodigoSumario() {
return codigoSumario;
}
 
public String getCodigoSala() {
return codigoSala;
}
}
/impl/src/java/pt/estgp/estgweb/domain/views/CourseUnitEvaluationView.java
New file
0,0 → 1,86
package pt.estgp.estgweb.domain.views;
 
import pt.estgp.estgweb.domain.CourseUnitEvaluation;
import pt.estgp.estgweb.domain.CourseUnitEvaluationImpl;
 
import java.io.Serializable;
 
/**
* @author Jorge Machado
* @date 2/Mar/2008
* @time 19:34:49
* @see pt.estgp.estgweb.domain.views
*/
public class CourseUnitEvaluationView extends DomainObjectView
{
 
 
 
private CourseUnitEvaluation courseUnitEvaluation;
private boolean fechar = false;
private boolean teacherComplete = false;
 
public Class getReferenceClass()
{
return CourseUnitEvaluationImpl.class;
}
 
public Serializable getSerializable()
{
return courseUnitEvaluation.getId();
}
 
public CourseUnitEvaluationView()
{
}
 
public CourseUnitEvaluation getCourseUnitEvaluation() {
return courseUnitEvaluation;
}
 
public void setCourseUnitEvaluation(CourseUnitEvaluation courseUnitEvaluation) {
this.courseUnitEvaluation = courseUnitEvaluation;
}
 
public CourseUnitEvaluationView(CourseUnitEvaluation courseUnitEvaluation)
{
super(courseUnitEvaluation);
this.courseUnitEvaluation = courseUnitEvaluation;
}
 
public void persistViewInObjectTeacher(CourseUnitEvaluation c)
{
c.setNumAlunosAprov1013(courseUnitEvaluation.getNumAlunosAprov1013());
c.setNumAlunosAprov1416(courseUnitEvaluation.getNumAlunosAprov1416());
c.setNumAlunosAprov1720(courseUnitEvaluation.getNumAlunosAprov1720());
c.setNumAlunosAprovados(courseUnitEvaluation.getNumAlunosAprovados());
c.setNumAlunosAprovEspecial(courseUnitEvaluation.getNumAlunosAprovEspecial());
c.setNumAlunosAprovFrequencia(courseUnitEvaluation.getNumAlunosAprovFrequencia());
c.setNumAlunosAprovNormal(courseUnitEvaluation.getNumAlunosAprovNormal());
c.setNumAlunosAprovRecurso(courseUnitEvaluation.getNumAlunosAprovRecurso());
c.setNumAlunosAprovTotal(courseUnitEvaluation.getNumAlunosAprovTotal());
c.setNumAlunosInscritos(courseUnitEvaluation.getNumAlunosInscritos());
c.setNumAlunosReprovados(courseUnitEvaluation.getNumAlunosReprovados());
c.setNumAlunosSemElementosAvaliacao(courseUnitEvaluation.getNumAlunosSemElementosAvaliacao());
c.setQualApreciacaoCumprimentoPrograma(courseUnitEvaluation.getQualApreciacaoCumprimentoPrograma());
c.setQualApreciacaoQuantitivos(courseUnitEvaluation.getQualApreciacaoQuantitivos());
c.setQualApreciacaoUC(courseUnitEvaluation.getQualApreciacaoUC());
c.setQualConclusoes(courseUnitEvaluation.getQualConclusoes());
}
 
public boolean isFechar() {
return fechar;
}
 
public void setFechar(boolean fechar) {
this.fechar = fechar;
}
 
public boolean isTeacherComplete() {
return teacherComplete;
}
 
public void setTeacherComplete(boolean teacherComplete) {
this.teacherComplete = teacherComplete;
}
}
/impl/src/java/pt/estgp/estgweb/domain/views/ConfigurationGradesView.java
New file
0,0 → 1,64
package pt.estgp.estgweb.domain.views;
 
import pt.estgp.estgweb.domain.*;
 
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
 
/**
* Created by jorgemachado on 12/11/15.
*/
public class ConfigurationGradesView extends DomainObjectView {
 
long id;
List<ConfigurationGradesStatusEpoca> statusEpocas;
List<ConfigurationGradesEpocaAvaliacao> epocasAvaliacao;
 
@Override
public Class getReferenceClass() {
return ConfigurationGrades.class;
}
 
@Override
public Serializable getSerializable() {
return id;
}
 
public void init(ConfigurationGrades configurationGrades)
{
this.id = configurationGrades.getId();
statusEpocas = new ArrayList<ConfigurationGradesStatusEpoca>(configurationGrades.getStatusEpoca());
epocasAvaliacao = new ArrayList<ConfigurationGradesEpocaAvaliacao>(configurationGrades.getEpocasAvaliacao());
}
 
 
public long getId() {
return id;
}
 
public void setId(long id) {
this.id = id;
}
 
public List<ConfigurationGradesStatusEpoca> getStatusEpocas() {
return statusEpocas;
}
 
public void setStatusEpocas(List<ConfigurationGradesStatusEpoca> statusEpocas) {
this.statusEpocas = statusEpocas;
}
 
public List<ConfigurationGradesEpocaAvaliacao> getEpocasAvaliacao() {
return epocasAvaliacao;
}
 
public void setEpocasAvaliacao(List<ConfigurationGradesEpocaAvaliacao> epocasAvaliacao) {
this.epocasAvaliacao = epocasAvaliacao;
}
 
public void persist(ConfigurationGrades grades)
{
 
}
}
/impl/src/java/pt/estgp/estgweb/domain/views/CourseView.java
35,12 → 35,35
private UserView coordinator;
private UserView director;
private List<CourseUnitView> courseUnits;
 
private List<CourseUnitView> courseUnitsWithNoProgramA;
private List<CourseUnitView> courseUnitsWithProgramCheckedA;
private List<CourseUnitView> courseUnitsWithProgramNotCheckedA;
 
private List<CourseUnitView> courseUnitsWithNoProgramS1;
private List<CourseUnitView> courseUnitsWithProgramCheckedS1;
private List<CourseUnitView> courseUnitsWithProgramNotCheckedS1;
 
private List<CourseUnitView> courseUnitsWithNoProgramS2;
private List<CourseUnitView> courseUnitsWithProgramCheckedS2;
private List<CourseUnitView> courseUnitsWithProgramNotCheckedS2;
 
private List<CourseUnitView> courseUnitsWithNoProgramT1;
private List<CourseUnitView> courseUnitsWithProgramCheckedT1;
private List<CourseUnitView> courseUnitsWithProgramNotCheckedT1;
 
private List<CourseUnitView> courseUnitsWithNoProgramT2;
private List<CourseUnitView> courseUnitsWithProgramCheckedT2;
private List<CourseUnitView> courseUnitsWithProgramNotCheckedT2;
 
private List<CourseUnitView> courseUnitsWithNoProgramT3;
private List<CourseUnitView> courseUnitsWithProgramCheckedT3;
private List<CourseUnitView> courseUnitsWithProgramNotCheckedT3;
 
private List<CourseUnitView> courseUnitsWithNoProgramT4;
private List<CourseUnitView> courseUnitsWithProgramCheckedT4;
private List<CourseUnitView> courseUnitsWithProgramNotCheckedT4;
 
private String studiesPlanStreamId;
private RepositoryFileImpl studiesPlan;
private String htmlResult;
49,6 → 72,7
private String externalSitePath;
private String validationRole;
private boolean status;
private String userGroupStudents;
 
 
 
106,6 → 130,7
this.externalSitePath = course.getExternalSitePath();
this.externalSiteServer = course.getExternalSiteServer();
this.status = course.isStatus();
this.userGroupStudents = course.getUserGroupStudents();
if(course.getStudiesPlan() != null)
this.studiesPlanStreamId = course.getStudiesPlan();
if(course.getCoordinator() != null)
140,6 → 165,7
c.setExternalSiteServer(externalSiteServer);
c.setValidationRole(validationRole);
c.setStatus(status);
c.setUserGroupStudents(userGroupStudents);
if(coordinator != null && coordinator.getId() > 0)
{
Teacher u = DaoFactory.getTeacherDaoImpl().load(coordinator.getId());
377,10 → 403,28
}
 
 
public List<CourseUnitView> getCourseUnitsWithNoProgramS1()
public List<CourseUnitView> getCourseUnitsWithNoProgramA() { return courseUnitsWithNoProgramA; }
public List<CourseUnitView> getCourseUnitsWithNoProgramS1() { return courseUnitsWithNoProgramS1; }
public List<CourseUnitView> getCourseUnitsWithNoProgramS2()
{
return courseUnitsWithNoProgramS1;
return courseUnitsWithNoProgramS2;
}
public List<CourseUnitView> getCourseUnitsWithNoProgramT1()
{
return courseUnitsWithNoProgramT1;
}
public List<CourseUnitView> getCourseUnitsWithNoProgramT2()
{
return courseUnitsWithNoProgramT2;
}
public List<CourseUnitView> getCourseUnitsWithNoProgramT3()
{
return courseUnitsWithNoProgramT3;
}
public List<CourseUnitView> getCourseUnitsWithNoProgramT4()
{
return courseUnitsWithNoProgramT4;
}
 
 
public String getValidationRole() {
391,23 → 435,144
this.validationRole = validationRole;
}
 
public void setCourseUnitsWithNoProgramA(List<CourseUnitView> courseUnitsWithNoProgramA)
{
this.courseUnitsWithNoProgramA = courseUnitsWithNoProgramA;
}
public void setCourseUnitsWithNoProgramS1(List<CourseUnitView> courseUnitsWithNoProgramS1)
{
this.courseUnitsWithNoProgramS1 = courseUnitsWithNoProgramS1;
}
public void setCourseUnitsWithNoProgramS2(List<CourseUnitView> courseUnitsWithNoProgramS2)
{
this.courseUnitsWithNoProgramS2 = courseUnitsWithNoProgramS2;
}
public void setCourseUnitsWithNoProgramT1(List<CourseUnitView> courseUnitsWithNoProgramT1)
{
this.courseUnitsWithNoProgramT1 = courseUnitsWithNoProgramT1;
}
public void setCourseUnitsWithNoProgramT2(List<CourseUnitView> courseUnitsWithNoProgramT2)
{
this.courseUnitsWithNoProgramT2 = courseUnitsWithNoProgramT2;
}
public void setCourseUnitsWithNoProgramT3(List<CourseUnitView> courseUnitsWithNoProgramT3)
{
this.courseUnitsWithNoProgramT3 = courseUnitsWithNoProgramT3;
}
public void setCourseUnitsWithNoProgramT4(List<CourseUnitView> courseUnitsWithNoProgramT4)
{
this.courseUnitsWithNoProgramT4 = courseUnitsWithNoProgramT4;
}
 
public boolean getHasA() { return getHasCourseUnitsWithNoProgramA() || getHasCourseUnitsWithProgramCheckedA() || getHasCourseUnitsWithProgramNotCheckedA(); }
public boolean getHasS1() { return getHasCourseUnitsWithNoProgramS1() || getHasCourseUnitsWithProgramCheckedS1() || getHasCourseUnitsWithProgramNotCheckedS1(); }
public boolean getHasS2() { return getHasCourseUnitsWithNoProgramS2() || getHasCourseUnitsWithProgramCheckedS2() || getHasCourseUnitsWithProgramNotCheckedS2(); }
public boolean getHasT1() { return getHasCourseUnitsWithNoProgramT1() || getHasCourseUnitsWithProgramCheckedT1() || getHasCourseUnitsWithProgramNotCheckedT1(); }
public boolean getHasT2() { return getHasCourseUnitsWithNoProgramT2() || getHasCourseUnitsWithProgramCheckedT2() || getHasCourseUnitsWithProgramNotCheckedT2(); }
public boolean getHasT3() { return getHasCourseUnitsWithNoProgramT3() || getHasCourseUnitsWithProgramCheckedT3() || getHasCourseUnitsWithProgramNotCheckedT3(); }
public boolean getHasT4() { return getHasCourseUnitsWithNoProgramT4() || getHasCourseUnitsWithProgramCheckedT4() || getHasCourseUnitsWithProgramNotCheckedT4(); }
 
public boolean getHasCourseUnitsWithProgramCheckedA() { return courseUnitsWithProgramCheckedA!=null && courseUnitsWithProgramCheckedA.size() > 0; }
public boolean getHasCourseUnitsWithProgramCheckedS1() { return courseUnitsWithProgramCheckedS1!=null && courseUnitsWithProgramCheckedS1.size() > 0; }
public boolean getHasCourseUnitsWithProgramCheckedS2() { return courseUnitsWithProgramCheckedS2!=null && courseUnitsWithProgramCheckedS2.size() > 0; }
public boolean getHasCourseUnitsWithProgramCheckedT1() { return courseUnitsWithProgramCheckedT1!=null && courseUnitsWithProgramCheckedT1.size() > 0; }
public boolean getHasCourseUnitsWithProgramCheckedT2() { return courseUnitsWithProgramCheckedT2!=null && courseUnitsWithProgramCheckedT2.size() > 0; }
public boolean getHasCourseUnitsWithProgramCheckedT3() { return courseUnitsWithProgramCheckedT3!=null && courseUnitsWithProgramCheckedT3.size() > 0; }
public boolean getHasCourseUnitsWithProgramCheckedT4() { return courseUnitsWithProgramCheckedT4!=null && courseUnitsWithProgramCheckedT4.size() > 0; }
 
public boolean getHasCourseUnitsWithProgramNotCheckedA() { return courseUnitsWithProgramNotCheckedA!=null && courseUnitsWithProgramNotCheckedA.size() > 0; }
public boolean getHasCourseUnitsWithProgramNotCheckedS1() { return courseUnitsWithProgramNotCheckedS1!=null && courseUnitsWithProgramNotCheckedS1.size() > 0; }
public boolean getHasCourseUnitsWithProgramNotCheckedS2() { return courseUnitsWithProgramNotCheckedS2!=null && courseUnitsWithProgramNotCheckedS2.size() > 0; }
public boolean getHasCourseUnitsWithProgramNotCheckedT1() { return courseUnitsWithProgramNotCheckedT1!=null && courseUnitsWithProgramNotCheckedT1.size() > 0; }
public boolean getHasCourseUnitsWithProgramNotCheckedT2() { return courseUnitsWithProgramNotCheckedT2!=null && courseUnitsWithProgramNotCheckedT2.size() > 0; }
public boolean getHasCourseUnitsWithProgramNotCheckedT3() { return courseUnitsWithProgramNotCheckedT3!=null && courseUnitsWithProgramNotCheckedT3.size() > 0; }
public boolean getHasCourseUnitsWithProgramNotCheckedT4() { return courseUnitsWithProgramNotCheckedT4!=null && courseUnitsWithProgramNotCheckedT4.size() > 0; }
 
public boolean getHasCourseUnitsWithNoProgramA() { return courseUnitsWithNoProgramA!=null && courseUnitsWithNoProgramA.size() > 0; }
public boolean getHasCourseUnitsWithNoProgramS1() { return courseUnitsWithNoProgramS1!=null && courseUnitsWithNoProgramS1.size() > 0; }
public boolean getHasCourseUnitsWithNoProgramS2() { return courseUnitsWithNoProgramS2!=null && courseUnitsWithNoProgramS2.size() > 0; }
public boolean getHasCourseUnitsWithNoProgramT1() { return courseUnitsWithNoProgramT1!=null && courseUnitsWithNoProgramT1.size() > 0; }
public boolean getHasCourseUnitsWithNoProgramT2() { return courseUnitsWithNoProgramT2!=null && courseUnitsWithNoProgramT2.size() > 0; }
public boolean getHasCourseUnitsWithNoProgramT3() { return courseUnitsWithNoProgramT3!=null && courseUnitsWithNoProgramT3.size() > 0; }
public boolean getHasCourseUnitsWithNoProgramT4() { return courseUnitsWithNoProgramT4!=null && courseUnitsWithNoProgramT4.size() > 0; }
 
 
public List<CourseUnitView> getCourseUnitsWithProgramCheckedA()
{
if(courseUnitsWithProgramCheckedA==null)
courseUnitsWithProgramCheckedA = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramCheckedA;
}
public List<CourseUnitView> getCourseUnitsWithProgramCheckedS1()
{
if(courseUnitsWithProgramCheckedS1==null)
courseUnitsWithProgramCheckedS1 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramCheckedS1;
}
public List<CourseUnitView> getCourseUnitsWithProgramCheckedS2()
{
if(courseUnitsWithProgramCheckedS2==null)
courseUnitsWithProgramCheckedS2 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramCheckedS2;
}
public List<CourseUnitView> getCourseUnitsWithProgramCheckedT1()
{
if(courseUnitsWithProgramCheckedT1==null)
courseUnitsWithProgramCheckedT1 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramCheckedT1;
}
public List<CourseUnitView> getCourseUnitsWithProgramCheckedT2()
{
if(courseUnitsWithProgramCheckedT2==null)
courseUnitsWithProgramCheckedT2 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramCheckedT2;
}
public List<CourseUnitView> getCourseUnitsWithProgramCheckedT3()
{
if(courseUnitsWithProgramCheckedT3==null)
courseUnitsWithProgramCheckedT3 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramCheckedT3;
}
public List<CourseUnitView> getCourseUnitsWithProgramCheckedT4()
{
if(courseUnitsWithProgramCheckedT4==null)
courseUnitsWithProgramCheckedT4 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramCheckedT4;
}
 
public void setCourseUnitsWithProgramCheckedS1(List<CourseUnitView> courseUnitsWithProgramCheckedS1)
 
 
public void setCourseUnitsWithProgramCheckedA(List<CourseUnitView> courseUnitsWithProgramCheckedA) { this.courseUnitsWithProgramCheckedA = courseUnitsWithProgramCheckedA; }
public void setCourseUnitsWithProgramCheckedS1(List<CourseUnitView> courseUnitsWithProgramCheckedS1) { this.courseUnitsWithProgramCheckedS1 = courseUnitsWithProgramCheckedS1; }
public void setCourseUnitsWithProgramCheckedS2(List<CourseUnitView> courseUnitsWithProgramCheckedS2)
{
this.courseUnitsWithProgramCheckedS1 = courseUnitsWithProgramCheckedS1;
this.courseUnitsWithProgramCheckedS2 = courseUnitsWithProgramCheckedS2;
}
public void setCourseUnitsWithProgramCheckedT1(List<CourseUnitView> courseUnitsWithProgramCheckedT1)
{
this.courseUnitsWithProgramCheckedT1 = courseUnitsWithProgramCheckedT1;
}
public void setCourseUnitsWithProgramCheckedT2(List<CourseUnitView> courseUnitsWithProgramCheckedT2)
{
this.courseUnitsWithProgramCheckedT2 = courseUnitsWithProgramCheckedT2;
}
public void setCourseUnitsWithProgramCheckedT3(List<CourseUnitView> courseUnitsWithProgramCheckedT3)
{
this.courseUnitsWithProgramCheckedT3 = courseUnitsWithProgramCheckedT3;
}
public void setCourseUnitsWithProgramCheckedT4(List<CourseUnitView> courseUnitsWithProgramCheckedT4)
{
this.courseUnitsWithProgramCheckedT4 = courseUnitsWithProgramCheckedT4;
}
 
 
public List<CourseUnitView> getCourseUnitsWithProgramNotCheckedA()
{
if(courseUnitsWithProgramNotCheckedA==null)
courseUnitsWithProgramNotCheckedA = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramNotCheckedA;
}
 
public List<CourseUnitView> getCourseUnitsWithProgramNotCheckedS1()
{
if(courseUnitsWithProgramNotCheckedS1==null)
415,44 → 580,88
return courseUnitsWithProgramNotCheckedS1;
}
 
public void setCourseUnitsWithProgramNotCheckedS1(List<CourseUnitView> courseUnitsWithProgramNotCheckedS1)
public List<CourseUnitView> getCourseUnitsWithProgramNotCheckedS2()
{
this.courseUnitsWithProgramNotCheckedS1 = courseUnitsWithProgramNotCheckedS1;
if(courseUnitsWithProgramNotCheckedS2==null)
courseUnitsWithProgramNotCheckedS2 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramNotCheckedS2;
}
 
public List<CourseUnitView> getCourseUnitsWithNoProgramS2()
public List<CourseUnitView> getCourseUnitsWithProgramNotCheckedT1()
{
return courseUnitsWithNoProgramS2;
if(courseUnitsWithProgramNotCheckedT1==null)
courseUnitsWithProgramNotCheckedT1 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramNotCheckedT1;
}
 
public void setCourseUnitsWithNoProgramS2(List<CourseUnitView> courseUnitsWithNoProgramS2)
public List<CourseUnitView> getCourseUnitsWithProgramNotCheckedT2()
{
this.courseUnitsWithNoProgramS2 = courseUnitsWithNoProgramS2;
if(courseUnitsWithProgramNotCheckedT2==null)
courseUnitsWithProgramNotCheckedT2 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramNotCheckedT2;
}
 
public List<CourseUnitView> getCourseUnitsWithProgramCheckedS2()
public List<CourseUnitView> getCourseUnitsWithProgramNotCheckedT3()
{
if(courseUnitsWithProgramCheckedS2==null)
courseUnitsWithProgramCheckedS2 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramCheckedS2;
if(courseUnitsWithProgramNotCheckedT3==null)
courseUnitsWithProgramNotCheckedT3 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramNotCheckedT3;
}
 
public void setCourseUnitsWithProgramCheckedS2(List<CourseUnitView> courseUnitsWithProgramCheckedS2)
public List<CourseUnitView> getCourseUnitsWithProgramNotCheckedT4()
{
this.courseUnitsWithProgramCheckedS2 = courseUnitsWithProgramCheckedS2;
if(courseUnitsWithProgramNotCheckedT4==null)
courseUnitsWithProgramNotCheckedT4 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramNotCheckedT4;
}
 
public List<CourseUnitView> getCourseUnitsWithProgramNotCheckedS2()
 
 
public void setCourseUnitsWithProgramNotCheckedA(List<CourseUnitView> courseUnitsWithProgramNotCheckedA)
{
if(courseUnitsWithProgramNotCheckedS2==null)
courseUnitsWithProgramNotCheckedS2 = new AutoFillArrayList<CourseUnitView>(CourseUnitView.class);
return courseUnitsWithProgramNotCheckedS2;
this.courseUnitsWithProgramNotCheckedA = courseUnitsWithProgramNotCheckedA;
}
 
public void setCourseUnitsWithProgramNotCheckedS1(List<CourseUnitView> courseUnitsWithProgramNotCheckedS1)
{
this.courseUnitsWithProgramNotCheckedS1 = courseUnitsWithProgramNotCheckedS1;
}
public void setCourseUnitsWithProgramNotCheckedS2(List<CourseUnitView> courseUnitsWithProgramNotCheckedS2)
{
this.courseUnitsWithProgramNotCheckedS2 = courseUnitsWithProgramNotCheckedS2;
}
public void setCourseUnitsWithProgramNotCheckedT1(List<CourseUnitView> courseUnitsWithProgramNotCheckedT1)
{
this.courseUnitsWithProgramNotCheckedT1 = courseUnitsWithProgramNotCheckedT1;
}
public void setCourseUnitsWithProgramNotCheckedT2(List<CourseUnitView> courseUnitsWithProgramNotCheckedT2)
{
this.courseUnitsWithProgramNotCheckedT2 = courseUnitsWithProgramNotCheckedT2;
}
public void setCourseUnitsWithProgramNotCheckedT3(List<CourseUnitView> courseUnitsWithProgramNotCheckedT3)
{
this.courseUnitsWithProgramNotCheckedT3 = courseUnitsWithProgramNotCheckedT3;
}
public void setCourseUnitsWithProgramNotCheckedT4(List<CourseUnitView> courseUnitsWithProgramNotCheckedT4)
{
this.courseUnitsWithProgramNotCheckedT4 = courseUnitsWithProgramNotCheckedT4;
}
 
 
 
 
 
 
 
 
 
 
 
 
public String getUserGroupStudents() {
return userGroupStudents;
}
 
public void setUserGroupStudents(String userGroupStudents) {
this.userGroupStudents = userGroupStudents;
}
}
/impl/src/java/pt/estgp/estgweb/domain/views/CourseUnitView.java
2,6 → 2,9
 
import jomm.utils.StringsUtils;
import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.courseunits.LoadCourseUnitAnnouncements;
38,6 → 41,7
private String normalizedName;
private List<AnnouncementView> announcements;
private List<CourseUnitSummaryView> summaries;
private String summariesJson;
 
private CourseUnit courseUnit;
private UserView responsableTeacher;
48,11 → 52,14
 
private String objectives;
private String programStreamId;
private String evaluationStreamId;
private boolean validProgram;
private UserView validatorUser;
private boolean validEvaluation = false;
private int programSize;
private String extension;
private List<CourseUnitAssignementView> courseUnitAssignements;
private String sumariosPathFileIntranet;
 
private boolean notFound = false;
 
117,6 → 124,8
this.importYear = courseUnit.getImportYear();
this.semestre = courseUnit.getSemestre();
this.courseCode = courseUnit.getCourseCode();
this.summariesJson = courseUnit.getSummariesJson();
this.sumariosPathFileIntranet = ((CourseUnitImpl)courseUnit).getSummariosPathFileIntranet();
 
// this.objectives = courseUnit.getObjectives(); DEPRECATED
if(courseUnit.getCourseUnitProgram() !=null && courseUnit.getCourseUnitProgram().getCourseUnitProgramPart2() != null)
135,6 → 144,12
}
}
 
if(courseUnit.getEvaluationStreamId() != null)
{
evaluationStreamId = courseUnit.getEvaluationStreamId();
validEvaluation = courseUnit.getCourseUnitEvaluation().isClosed();
}
 
// if(courseUnit.getBlog() != null)
// this.blog = new BlogView(courseUnit.getBlog());
this.id = courseUnit.getId();
171,9 → 186,23
{
responsableId = courseUnit.getResponsableTeacher().getId();
}
courseView = new CourseView(courseUnit.getCourse(),false);
}
 
public String getEvaluationStreamId() {
return evaluationStreamId;
}
 
 
public String getSumariosPathFileIntranet() {
return sumariosPathFileIntranet;
}
 
public boolean isValidEvaluation() {
return validEvaluation;
}
 
 
public long getCoordinatorId() {
return coordinatorId;
}
443,6 → 472,83
return students;
}
 
public String getSummariesJson() {
return summariesJson;
}
 
List<CourseUnitSummaryView> summariesFromJson = null;
/**
*
* @return sumaries or null if there are no summaries in Json
*/
 
int lateSummaries = 0;
List<String> lateSummariesDates = new ArrayList<String>();
 
public synchronized List<CourseUnitSummaryView> getSummariesFromJson() {
if(summariesFromJson != null)
return summariesFromJson;
lateSummaries = 0;
summariesFromJson = new ArrayList<CourseUnitSummaryView>();
if(summariesJson != null && summariesJson.length() > 0)
{
try {
JSONObject jsonObject = new JSONObject(summariesJson);
JSONArray summaries = jsonObject.getJSONArray("summary");
for(int i = 0; i < summaries.length();i++)
{
JSONObject summary = summaries.getJSONObject(i);
CourseUnitSummaryImpl sum = DomainObjectFactory.createCourseUnitSummaryImpl();
 
if(sum.updateWithJson(summary)){
CourseUnitSummaryView view = new CourseUnitSummaryView(sum);
summariesFromJson.add(view);
}
else
{
CourseUnitSummaryView view = new CourseUnitSummaryView(sum);
if(view.getNumber() < 0 && view.getOriginalDate().getTime() < System.currentTimeMillis())
{
//System.out.println(view.getNumber() + " " + view.getDate() + " " + view.getOriginalDate());
lateSummaries++;
lateSummariesDates.add(view.getDate());
}
}
}
} catch (JSONException e) {
logger.error(e,e);
}
Collections.sort(summariesFromJson,new Comparator<CourseUnitSummaryView>() {
@Override
public int compare(CourseUnitSummaryView courseUnitSummaryView, CourseUnitSummaryView courseUnitSummaryView2) {
 
if(courseUnitSummaryView.getNumber() > courseUnitSummaryView2.getNumber())
return -1;
else if(courseUnitSummaryView.getNumber() < courseUnitSummaryView2.getNumber())
return 1;
return 0;
}
});
return summariesFromJson;
}
return null;
}
 
public List<String> getLateSummariesDates() {
return lateSummariesDates;
}
 
public int getLateSummaries()
{
getSummariesFromJson();
return lateSummaries;
 
}
 
public void setSummariesJson(String summariesJson) {
this.summariesJson = summariesJson;
}
 
public boolean isOwnedBy(GenericUser u)
{
return isOwnedBy(u, false);
458,6 → 564,7
return u != null && u instanceof TeacherImpl && ((TeacherImpl)u).hasCourseUnit(getId(), transaction);
}
 
 
/**
* Not implemented can be variuous teachers
* @return null
/impl/src/java/pt/estgp/estgweb/domain/views/serviceviews/CourseViewServ.java
New file
0,0 → 1,92
package pt.estgp.estgweb.domain.views.serviceviews;
 
import pt.estgp.estgweb.domain.views.CourseView;
 
/**
* Created by jorgemachado on 21/10/15.
*/
public class CourseViewServ
{
private CourseView courseView;
 
public CourseViewServ()
{
}
 
public CourseViewServ(CourseView courseView)
{
this.courseView = courseView;
}
 
public String getCode() {
return courseView.getCode();
}
 
public void setCode(String code) {
courseView.setCode(code);
}
 
public String getArea() {
return courseView.getArea();
}
 
public void setArea(String area) {
courseView.setArea(area);
}
 
public String getName() {
return courseView.getName();
}
 
public void setName(String name) {
courseView.setName(name);
}
 
public String getDegree() {
return courseView.getDegree();
}
 
public void setDegree(String degree) {
courseView.setDegree(degree);
}
 
public String getImportYear() {
return courseView.getImportYear();
}
 
public void setImportYear(String importYear) {
courseView.setImportYear(importYear);
}
 
public String getDescription() {
return courseView.getDescription();
}
 
public void setDescription(String description) {
courseView.setDescription(description);
}
 
public String getInstitutionalCode() {
return courseView.getInstitutionalCode();
}
 
public void setInstitutionalCode(String institutionalCode) {
courseView.setInstitutionalCode(institutionalCode);
}
 
public long getId() {
return courseView.getId();
}
 
public void setId(long id) {
courseView.setId(id);
}
 
public boolean isStatus() {
return courseView.isStatus();
}
 
public void setStatus(boolean status) {
courseView.setStatus(status);
}
}
/impl/src/java/pt/estgp/estgweb/domain/DomainObjectFactory.java
311,4 → 311,45
{
return new DigitalDeliveryTargetImpl();
}
 
public static CourseUnitEvaluationImpl createCourseUnitEvaluationImpl()
{
return new CourseUnitEvaluationImpl();
}
 
public static JobServiceTaskImpl createJobServiceTaskImpl()
{
return new JobServiceTaskImpl();
}
 
public static JobServiceTaskSchedulerImpl createJobServiceTaskSchedulerImpl()
{
return new JobServiceTaskSchedulerImpl();
}
 
 
public static JobServiceTaskParameterImpl createJobServiceTaskParameterImpl()
{
return new JobServiceTaskParameterImpl();
}
 
public static JobServiceTaskSchedulerParameterImpl createJobServiceTaskSchedulerParameterImpl()
{
return new JobServiceTaskSchedulerParameterImpl();
}
 
public static ConfigurationGradesImpl createConfigurationGradesImpl()
{
return new ConfigurationGradesImpl();
}
 
public static ConfigurationGradesStatusEpocaImpl createConfigurationGradesStatusEpocaImpl()
{
return new ConfigurationGradesStatusEpocaImpl();
}
 
public static ConfigurationGradesEpocaAvaliacaoImpl createConfigurationGradesEpocaAvaliacaoImpl()
{
return new ConfigurationGradesEpocaAvaliacaoImpl();
}
}
/impl/src/java/pt/estgp/estgweb/domain/UserImpl.java
1,11 → 1,5
package pt.estgp.estgweb.domain;
 
import jomm.dao.impl.AbstractDao;
 
import java.io.Serializable;
import java.util.Date;
import java.util.Set;
 
/**
* @author Jorge Machado
* @date 2/Mar/2008
111,4 → 105,9
}
return false;
}
 
/*public String getPop3PassDecrypted()
{
return DesUtils.getInstance().decrypt(getPop3password());
}*/
}
/impl/src/java/pt/estgp/estgweb/domain/JobServiceTaskImpl.java
New file
0,0 → 1,77
package pt.estgp.estgweb.domain;
 
import org.apache.log4j.Logger;
import pt.estgp.estgweb.services.jobs.JobHandler;
import pt.estgp.estgweb.services.jobs.ServiceJob;
 
import java.io.Serializable;
 
/**
* @author Jorge Machado
* @date 2/Mar/2008
* @time 10:27:25
* @see pt.estgp.estgweb.domain
*/
public class JobServiceTaskImpl extends JobServiceTask implements JobHandler
{
private static final Logger logger = Logger.getLogger(JobServiceTaskImpl.class);
 
public Serializable getSerializable()
{
return getId();
}
 
@Override
public void runJob()
{
try {
ServiceJob job = (ServiceJob) Class.forName(getTargetService()).newInstance();
job.setParameters(getServiceTaskParameters());
job.setJobServiceTask(this);
job.runJob();
} catch (InstantiationException e) {
logger.error(e,e);
} catch (IllegalAccessException e) {
logger.error(e,e);
} catch (ClassNotFoundException e) {
logger.error(e, e);
}
}
 
public static enum JobStatus
{
PENDING,
STARTED,
FINISHED,
FAILED,
UNKNOWN_ERROR;
 
public static JobStatus parse(String status)
{
if(status == null)
return PENDING;
if(status.equals(PENDING.name()))
return PENDING;
if(status.equals(STARTED.name()))
return STARTED;
if(status.equals(FINISHED.name()))
return FINISHED;
if(status.equals(FAILED.name()))
return FAILED;
return UNKNOWN_ERROR;
}
}
 
public JobStatus getStatusEnum()
{
return JobStatus.parse(getStatus());
}
 
public void setStatusEnum(JobStatus statusEnum)
{
if(statusEnum == null)
setStatus(JobStatus.UNKNOWN_ERROR.name());
setStatus(statusEnum.name());
}
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/domain/ProcessImpl.java
63,4 → 63,29
{
return user.isSuperuser() || user.hasRole(Globals.ROLE_PROCESSES_ADMIN) || user.getId() == getLastEvent().getOwner().getId();
}
 
public boolean canRemoveLastEvent(User user)
{
if(getLastEvent().getPreviousEvent() == null)
{
//cant delete first event
return false;
}
if(user.isSuperuserOrAdmin())
{
return true;
}
//check if this event starts in this user looking to previous event
else if(!getLastEvent().isAccepted() &&
getLastEvent().getPreviousEvent() != null &&
user.getId() == getLastEvent().getPreviousEvent().getOwner().getId())
{
return true;
}
else
{
return false;
}
}
 
}
/impl/src/java/pt/estgp/estgweb/domain/CourseUnitImpl.java
1,5 → 1,6
package pt.estgp.estgweb.domain;
 
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.enums.CourseUnitContentsGrants;
 
import java.io.Serializable;
102,6 → 103,42
 
}
 
/**
* Means that is teacher os responsable teacher or from course commission
* Only works in open transaction
*
* Needs Course and Responsable Teacher loaded
*/
public boolean isFromCourseUnitCommission(UserSession userSession)
{
return userSession.getUser()!= null &&
(((UserImpl) userSession.getUser()).isTeacherOfCourseUnit(getId(), true)
|| (getResponsableTeacher() != null && getResponsableTeacher().getId() == userSession.getUser().getId())
|| userSession.getUser().hasRole(getCourse().getValidationRole())
);
}
 
 
public String getSummariosPathIntranet()
{
return Globals.FTP_IONLINE_START_PATH + "/" + getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_Sumarios;
}
 
public String getSummariosPathFileIntranet()
{
return getSummariosPathIntranet() + "/" + getSummariosFileNameIntranet();
}
 
public String getSummariosFileNameIntranet(){
return getCode() + "_" + getNormalizedName() + "_sumarios.pdf";
}
 
 
public String getSigesUniqueIdentifiers()
{
return "SIGES:" + getCode() + ", COURSE: " + getCourseCode() +
", " + getSemestre() + " of " + getImportYear() + " - " + getName();
}
 
}
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/ConfigurationGradesStatusEpocaDaoImpl.java
New file
0,0 → 1,21
package pt.estgp.estgweb.domain.dao.impl;
 
/**
* @author Jorge Machado
* @date 28/Fev/2008
* @time 2:51:06
* @see pt.estgp.estgweb.domain.dao.impl
*/
public class ConfigurationGradesStatusEpocaDaoImpl extends ConfigurationGradesStatusEpocaDao
{
public static ConfigurationGradesStatusEpocaDaoImpl getInstance()
{
if (myInstance == null)
myInstance = new ConfigurationGradesStatusEpocaDaoImpl();
return (ConfigurationGradesStatusEpocaDaoImpl) myInstance;
}
 
 
 
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/JobServiceTaskDaoImpl.java
New file
0,0 → 1,21
package pt.estgp.estgweb.domain.dao.impl;
 
/**
* @author Jorge Machado
* @date 28/Fev/2008
* @time 2:51:06
* @see pt.estgp.estgweb.domain.dao.impl
*/
public class JobServiceTaskDaoImpl extends JobServiceTaskDao
{
public static JobServiceTaskDaoImpl getInstance()
{
if (myInstance == null)
myInstance = new JobServiceTaskDaoImpl();
return (JobServiceTaskDaoImpl) myInstance;
}
 
 
 
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/JobServiceTaskParameterDaoImpl.java
New file
0,0 → 1,21
package pt.estgp.estgweb.domain.dao.impl;
 
/**
* @author Jorge Machado
* @date 28/Fev/2008
* @time 2:51:06
* @see pt.estgp.estgweb.domain.dao.impl
*/
public class JobServiceTaskParameterDaoImpl extends JobServiceTaskParameterDao
{
public static JobServiceTaskParameterDaoImpl getInstance()
{
if (myInstance == null)
myInstance = new JobServiceTaskParameterDaoImpl();
return (JobServiceTaskParameterDaoImpl) myInstance;
}
 
 
 
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/CourseUnitQuestionDaoImpl.java
1,18 → 1,11
package pt.estgp.estgweb.domain.dao.impl;
 
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.CourseUnitQuestion;
import pt.estgp.estgweb.domain.dao.DaoUtils;
import pt.estgp.estgweb.services.common.SearchTypeEnum;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.domain.dao.DaoFactory;
 
import java.util.List;
 
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.hibernate.Criteria;
import static org.hibernate.criterion.Restrictions.*;
import static org.hibernate.criterion.Restrictions.eq;
/**
* @author Jorge Machado
* @date 28/Fev/2008
41,7 → 34,7
 
.createAlias("courseUnit","cu")
.createAlias("cu.teachers","th")
.add(eq("cu.importYear", DatesUtils.getImportYear()))
.add(eq("cu.importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.add(eq("answred",false))
.add(eq("th.id",teacherId))
.list();
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/BlogPostDaoImpl.java
1,23 → 1,20
package pt.estgp.estgweb.domain.dao.impl;
 
import pt.estgp.estgweb.domain.BlogImpl;
import jomm.utils.MyCalendar;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import pt.estgp.estgweb.domain.BlogPost;
import pt.estgp.estgweb.domain.BlogPostImpl;
import pt.estgp.estgweb.domain.Blog;
import pt.estgp.estgweb.domain.BlogPost;
import pt.estgp.estgweb.domain.dao.DaoUtils;
import pt.estgp.estgweb.services.common.SearchTypeEnum;
 
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Calendar;
import java.util.Iterator;
import java.util.ArrayList;
 
import static org.hibernate.criterion.Restrictions.*;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Criterion;
import org.hibernate.Query;
import org.hibernate.Criteria;
import jomm.utils.MyCalendar;
 
/**
* @author Jorge Machado
39,12 → 36,18
{
return createCriteria().add(eq("owner.id", ownerId)).list();
}
public List<BlogPostImpl> loadOwnedBlogPostsMax(long ownerId,int max)
{
return createCriteria().add(eq("owner.id", ownerId)).addOrder(Order.desc("updateDate")).setMaxResults(max).list();
}
 
public List<BlogPostImpl> loadOwnedBlogPosts(long ownerId, long blogId)
{
return createCriteria().add(eq("owner.id", ownerId)).add(eq("blog.id",blogId)).list();
}
 
 
 
public List<BlogPostImpl> loadBlogPosts(long blogId, int month, int year)
{
Calendar bottom = new MyCalendar(year,month,1);
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/ConfigurationGradesEpocaAvaliacaoDaoImpl.java
New file
0,0 → 1,21
package pt.estgp.estgweb.domain.dao.impl;
 
/**
* @author Jorge Machado
* @date 28/Fev/2008
* @time 2:51:06
* @see pt.estgp.estgweb.domain.dao.impl
*/
public class ConfigurationGradesEpocaAvaliacaoDaoImpl extends ConfigurationGradesEpocaAvaliacaoDao
{
public static ConfigurationGradesEpocaAvaliacaoDaoImpl getInstance()
{
if (myInstance == null)
myInstance = new ConfigurationGradesEpocaAvaliacaoDaoImpl();
return (ConfigurationGradesEpocaAvaliacaoDaoImpl) myInstance;
}
 
 
 
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/ConfigurationDaoImpl.java
New file
0,0 → 1,253
package pt.estgp.estgweb.domain.dao.impl;
 
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
 
import java.util.Date;
import java.util.List;
 
 
//TODO PRECISA DE CHAMAR UM SERVICO EM VEZ DE SER ASSIM porque esta a abrir transacoes por todo lado
//PRECISA DE SE FAZER UM CHECK A TODO O CODIGO QUE ABRE TRANSACOES FORA DOS SERVICOS
/**
* @author Jorge Machado
* @date 28/Fev/2008
* @time 2:51:06
* @see pt.estgp.estgweb.domain.dao.impl
*/
public class ConfigurationDaoImpl extends ConfigurationDao
{
public static ConfigurationDaoImpl getInstance()
{
if (myInstance == null)
myInstance = new ConfigurationDaoImpl();
return (ConfigurationDaoImpl) myInstance;
}
 
public Configuration load()
{
List<Configuration> configs = createCriteria().list();
Configuration config = null;
if(configs.size() == 0)
{
Configuration configuration = new ConfigurationImpl();
configuration.setInterfaceImportYear("201516");
configuration.setImportsDefaultImportYear("201516");
configuration.setImportsDefaultImportYear("http://172.20.100.5:8080/SigesWeb/SiGesWEB.asmx?wsdl");
configuration.setCourseUnitEvaluationActiveYear("201415");
configuration.setSaveDate(new Date());
configuration.setSigesInstitutionCode(1);
save(configuration);
config = configuration;
}
else
config = configs.get(0);
 
if(config.getConfigurationGrades() == null)
{
//init by default with ESTG values
ConfigurationGradesImpl grades = DomainObjectFactory.createConfigurationGradesImpl();
grades.create();
for(ConfigurationGradesEpocaAvaliacao epoca: grades.getEpocasAvaliacao())
DaoFactory.getConfigurationGradesEpocaAvaliacaoDaoImpl().save(epoca);
for(ConfigurationGradesStatusEpoca status: grades.getStatusEpoca())
DaoFactory.getConfigurationGradesStatusEpocaDaoImpl().save(status);
DaoFactory.getConfigurationGradesDaoImpl().save(grades);
config.setConfigurationGrades(grades);
}
return config;
}
 
public void updateInterfaceImportYearCreateTransaction(String importYear)
{
getCurrentSession().beginTransaction();
Configuration config = load();
config.setInterfaceImportYear(importYear);
getCurrentSession().getTransaction().commit();
}
public void updateInterfaceImportYear(String importYear)
{
Configuration config = load();
config.setInterfaceImportYear(importYear);
}
 
public void updateImportsDefaultImportYear(String importYear)
{
Configuration config = load();
config.setImportsDefaultImportYear(importYear);
}
 
public void updateImportsDefaultImportYearCreateTransaction(String importYear)
{
getCurrentSession().beginTransaction();
Configuration config = load();
config.setImportsDefaultImportYear(importYear);
getCurrentSession().getTransaction().commit();
}
 
public String getImportsDefaultImportYearCreateTransaction()
{
getCurrentSession().beginTransaction();
String importYear = load().getImportsDefaultImportYear();
getCurrentSession().getTransaction().commit();
return importYear;
}
 
 
public String getInterfaceImportYearCreateTransaction()
{
getCurrentSession().beginTransaction();
String importYear = load().getInterfaceImportYear();
getCurrentSession().getTransaction().commit();
return importYear;
}
 
 
public String getImportsDefaultImportYear()
{
String importYear = load().getImportsDefaultImportYear();
return importYear;
}
 
 
public String getInterfaceImportYear()
{
String importYear = load().getInterfaceImportYear();
return importYear;
}
 
public String getCourseUnitEvaluationActiveYear()
{
return load().getCourseUnitEvaluationActiveYear();
}
 
public String getCourseUnitEvaluationActiveYearCreateTransaction()
{
getCurrentSession().beginTransaction();
String activeYear = getCourseUnitEvaluationActiveYear();
getCurrentSession().getTransaction().commit();
return activeYear;
}
 
public void updateCourseUnitEvaluationActiveYear(String activeYear)
{
Configuration config = load();
config.setCourseUnitEvaluationActiveYear(activeYear);
}
 
public void updateCourseUnitEvaluationActiveYearCreateTransaction(String activeYear)
{
getCurrentSession().beginTransaction();
updateCourseUnitEvaluationActiveYear(activeYear);
getCurrentSession().getTransaction().commit();
}
 
 
 
public String getSigesWebServicesWsdl()
{
return load().getSigesWebServicesWsdl();
}
 
public String getSigesWebServicesWsdlCreateTransaction()
{
getCurrentSession().beginTransaction();
String wsdl = getSigesWebServicesWsdl();
getCurrentSession().getTransaction().commit();
return wsdl;
}
 
public void updateSigesWebServicesWsdl(String wsdl)
{
Configuration config = load();
config.setSigesWebServicesWsdl(wsdl);
}
 
public void updateSigesWebServicesWsdlCreateTransaction(String wsdl)
{
getCurrentSession().beginTransaction();
updateSigesWebServicesWsdl(wsdl);
getCurrentSession().getTransaction().commit();
}
 
 
 
public int getSigesInstitutionCode()
{
return load().getSigesInstitutionCode();
}
 
public int getInstitutionCodeCreateTransaction()
{
getCurrentSession().beginTransaction();
int code = getSigesInstitutionCode();
getCurrentSession().getTransaction().commit();
return code;
}
 
public void updateSigesInstitutionCode(int instCode)
{
Configuration config = load();
config.setSigesInstitutionCode(instCode);
}
 
public void updateSigesInstitutionCodeCreateTransaction(int instCode)
{
getCurrentSession().beginTransaction();
updateSigesInstitutionCode(instCode);
getCurrentSession().getTransaction().commit();
}
 
 
 
 
 
public int getNationalInstitutionCode()
{
return load().getNationalInstitutionCode();
}
 
/**
* This method only creates transaction if not already active
* @return
*/
public int getNationalInstitutionCodeCreateTransaction()
{
//boolean alreadyActive = getCurrentSession().getTransaction().isActive();
//if(!alreadyActive)
getCurrentSession().beginTransaction();
int code = getNationalInstitutionCode();
//if(!alreadyActive)
getCurrentSession().getTransaction().commit();
return code;
}
 
/**
* Not problematic update only for interfaces
* Will not work only in MultiWebServer environment
* in that case needs a restart
* @param instCode
*/
public void updateNationalInstitutionCode(int instCode)
{
Configuration config = load();
config.setNationalInstitutionCode(instCode);
//Globals.NATIONAL_INSTITUTION_CODE = new BigDecimal(instCode);
}
 
 
/**
* Not problematic update only for interfaces
* Will not work only in MultiWebServer environment
* in that case needs a restart
* @param instCode
*/
public void updateNationalInstitutionCodeCreateTransaction(int instCode)
{
getCurrentSession().beginTransaction();
updateNationalInstitutionCode(instCode);
//Globals.NATIONAL_INSTITUTION_CODE = new BigDecimal(instCode);
getCurrentSession().getTransaction().commit();
}
 
}
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/JobServiceTaskSchedulerParameterDaoImpl.java
New file
0,0 → 1,28
package pt.estgp.estgweb.domain.dao.impl;
 
import pt.estgp.estgweb.domain.JobServiceTaskSchedulerParameterImpl;
 
/**
* @author Jorge Machado
* @date 28/Fev/2008
* @time 2:51:06
* @see pt.estgp.estgweb.domain.dao.impl
*/
public class JobServiceTaskSchedulerParameterDaoImpl extends JobServiceTaskSchedulerParameterDao
{
public static JobServiceTaskSchedulerParameterDaoImpl getInstance()
{
if (myInstance == null)
myInstance = new JobServiceTaskSchedulerParameterDaoImpl();
return (JobServiceTaskSchedulerParameterDaoImpl) myInstance;
}
 
//NEED REIMPLEMENTARION HERE
protected Class getReferenceClass() {
return JobServiceTaskSchedulerParameterImpl.class;
}
 
 
 
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/CourseDaoImpl.java
9,13 → 9,14
import pt.estgp.estgweb.domain.Course;
import pt.estgp.estgweb.domain.CourseImpl;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.dao.DaoUtils;
import pt.estgp.estgweb.services.common.SearchTypeEnum;
import pt.estgp.estgweb.utils.DatesUtils;
 
import java.util.List;
 
import static org.hibernate.criterion.Restrictions.eq;
import static org.hibernate.criterion.Restrictions.not;
 
/**
* @author Jorge Machado
48,7 → 49,7
Criterion c = DaoUtils.createSearchQuery(query, searchType, "name", "description");
return createCriteria()
.add(c)
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.list().size();
}
 
57,7 → 58,7
Criterion c = DaoUtils.createSearchQuery(query, searchTypeEnum, "name", "description");
Criteria criteria = createCriteria();
criteria.add(c)
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.addOrder(Order.asc("name"))
.setMaxResults(max)
.setFirstResult(page * max);
186,6 → 187,12
.list();
}
 
public List<Course> findAllNotIn(String importYear)
{
return createCriteria().add(not(eq("importYear", importYear)))
.list();
}
 
 
// Duarte Santos
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/JobServiceTaskSchedulerDaoImpl.java
New file
0,0 → 1,21
package pt.estgp.estgweb.domain.dao.impl;
 
/**
* @author Jorge Machado
* @date 28/Fev/2008
* @time 2:51:06
* @see pt.estgp.estgweb.domain.dao.impl
*/
public class JobServiceTaskSchedulerDaoImpl extends JobServiceTaskSchedulerDao
{
public static JobServiceTaskSchedulerDaoImpl getInstance()
{
if (myInstance == null)
myInstance = new JobServiceTaskSchedulerDaoImpl();
return (JobServiceTaskSchedulerDaoImpl) myInstance;
}
 
 
 
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/BlogDaoImpl.java
1,23 → 1,17
package pt.estgp.estgweb.domain.dao.impl;
 
import pt.estgp.estgweb.domain.User;
import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import pt.estgp.estgweb.domain.Blog;
import pt.estgp.estgweb.domain.BlogImpl;
import pt.estgp.estgweb.domain.Blog;
import pt.estgp.estgweb.domain.Announcement;
import pt.estgp.estgweb.domain.dao.DaoUtils;
import pt.estgp.estgweb.services.common.SearchTypeEnum;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import java.util.ArrayList;
import java.io.Serializable;
 
import org.hibernate.HibernateException;
import org.hibernate.Criteria;
import static org.hibernate.criterion.Restrictions.*;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import jomm.dao.DaoException;
 
/**
* @author Jorge Machado
43,12 → 37,27
return createCriteria().add(eq("owner.id", ownerId)).list();
}
 
public List<BlogImpl> loadOwnedBlogs(long ownerId, int max)
{
return createCriteria().add(eq("owner.id", ownerId)).addOrder(Order.desc("updateDate")).setMaxResults(max).list();
}
 
public List<BlogImpl> findBlogs(List<String> roles, boolean internal)
{
return findBlogs(roles,internal,null);
}
public List<BlogImpl> findBlogs(List<String> roles, boolean internal, int max)
{
return findBlogs(roles,internal,null,max);
}
 
public List<BlogImpl> findBlogs(List<String> roles, boolean internal, String type)
{
return findBlogs(roles,internal,type,-1);
}
 
public List<BlogImpl> findBlogs(List<String> roles, boolean internal, String type, int max)
{
if (roles == null)
{
roles = new ArrayList<String>();
69,11 → 78,13
if (co != null)
criteria.add(co);
criteria.add(eq("status", true))
.addOrder(Order.desc("title"));
.addOrder(Order.desc("updateDate"));
if(type != null)
criteria.add(eq("type",type));
else
criteria.add(isNull("type"));
if(max > 0)
criteria.setMaxResults(max);
return criteria.list();
}
 
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/AnnouncementDaoImpl.java
67,6 → 67,10
usersC.createAlias("tU.course","tUC");
usersC.add(eq("tU.semestre",semestre))
.add(eq("tUC.id",courseId));
//NOVO
if(year != null && year.length() > 0)
usersC.add(eq("tU.importYear",year));
//NOVO
users.addAll(usersC.list());
}
if(target.isStudents())
77,6 → 81,8
usersC.createAlias("sU.course","sUC");
usersC.add(eq("sU.semestre",semestre))
.add(eq("sUC.id",courseId));
if(year != null && year.length() > 0)
usersC.add(eq("sU.importYear",year));
users.addAll(usersC.list());
}
}
366,8 → 372,13
return createCriteria().add(eq("owner.id", ownerId)).addOrder(Order.desc("updateDate")).list();
}
 
public List<AnnouncementImpl> loadOwnedAnnouncements(long ownerId, int size)
{
return createCriteria().add(eq("owner.id", ownerId)).setMaxResults(size).addOrder(Order.desc("updateDate")).list();
}
 
 
 
public List<Announcement> loadInvalidAnnouncements()
{
Criteria c = createCriteria()
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/ConfigurationGradesDaoImpl.java
New file
0,0 → 1,21
package pt.estgp.estgweb.domain.dao.impl;
 
/**
* @author Jorge Machado
* @date 28/Fev/2008
* @time 2:51:06
* @see pt.estgp.estgweb.domain.dao.impl
*/
public class ConfigurationGradesDaoImpl extends ConfigurationGradesDao
{
public static ConfigurationGradesDaoImpl getInstance()
{
if (myInstance == null)
myInstance = new ConfigurationGradesDaoImpl();
return (ConfigurationGradesDaoImpl) myInstance;
}
 
 
 
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/CourseUnitDaoImpl.java
6,13 → 6,13
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import org.hibernate.sql.JoinFragment;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.CourseUnitImpl;
import pt.estgp.estgweb.domain.Teacher;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.dao.DaoUtils;
import pt.estgp.estgweb.services.common.SearchTypeEnum;
import pt.estgp.estgweb.utils.DatesUtils;
 
import java.util.ArrayList;
import java.util.List;
 
import static org.hibernate.criterion.Restrictions.*;
70,6 → 70,14
return q.list();
}
 
public List<Long> loadIds(String importYear)
{
Query q = createQuery("select c.id from c in class " + CourseUnit.class.getName() + " where c.importYear = ?");
q.setString(0, importYear);
//q.setString(1, semestre);
return q.list();
}
 
public List<CourseUnit> loadSubscribedImportYearUnits(long studentId, String importYear)
{
return createCriteria().add(eq("importYear", importYear))
207,7 → 215,7
}
 
 
//TODO Na actualização de uma cadeira para o curso de TESTE mudar o coursecode para o o coursecode desse curso para nao deixar os dados duplicados e mal
//TODO Na actualiza��o de uma cadeira para o curso de TESTE mudar o coursecode para o o coursecode desse curso para nao deixar os dados duplicados e mal
//se nao a carregar unidades vai buscar a errada
public CourseUnit loadBySigesCodeUnique(String sigesCode, String courseCode, String semestre, String year)
{
220,8 → 228,26
.uniqueResult();
}
 
public List<CourseUnit> loadBySigesCodeUnique(String sigesCode, String courseCode, String year)
public CourseUnit loadBySigesCodeUniqueMostRecent(String sigesCode, String courseCode, String semestre)
{
return (CourseUnit)
createCriteria()
.add(eq("code", sigesCode))
.add(eq("courseCode", courseCode))
.add(eq("semestre", semestre))
.addOrder(Order.desc("importYear"))
.setMaxResults(1).list().get(0);
}
 
 
public CourseUnit loadBySigesCodeUniqueLastYear(String sigesCode, String courseCode, String semestre)
{
return loadBySigesCodeUniqueMostRecent(sigesCode,courseCode,semestre);
}
 
 
public List<CourseUnit> loadBySigesCodeUnique(String sigesCode, String courseCode, String year)
{
return createCriteria()
.add(eq("code", sigesCode))
.add(eq("courseCode", courseCode))
284,7 → 310,7
Criterion c = DaoUtils.createSearchQuery(query, searchType, "objectives", "name");
return createCriteria()
.add(c)
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.list().size();
}
 
293,7 → 319,7
Criterion c = DaoUtils.createSearchQuery(query, searchTypeEnum, "objectives", "name");
Criteria criteria = createCriteria();
criteria.add(c)
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.addOrder(Order.asc("name"))
.setMaxResults(maxUnits)
.setFirstResult(page * maxUnits);
304,7 → 330,7
{
//todo falta a projeccao do teacher id
return createCriteria()
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.add((or(isNull("objectives"), eq("objectives", ""))))
.createAlias("teachers", "th")
.add(eq("semestre", DatesUtils.getSemestre()))
316,7 → 342,7
{
//todo falta a projeccao do teacher id
return createCriteria()
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.add((or(isNull("programStreamId"), eq("programStreamId", ""))))
.createAlias("teachers", "th")
.add(eq("semestre", DatesUtils.getSemestre()))
328,7 → 354,7
{
//todo falta a projeccao do teacher id
Criteria c = createCriteria()
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.add(or(or(isNull("objectives"), eq("objectives", "")), or(isNull("programStreamId"), eq("programStreamId", ""))));
 
DatesUtils.SemestreModerate semestreModerate = DatesUtils.getSemestreModerate();
350,7 → 376,7
return createCriteria()
.createAlias("course", "c")
.add(eq("c.id", courseId))
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.add(eq("semestre", DatesUtils.getSemestre()))
.add((or(isNull("objectives"), eq("objectives", ""))))
.list();
361,7 → 387,7
return createCriteria()
.createAlias("course", "c")
.add(eq("c.id", courseId))
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.add(eq("semestre", DatesUtils.getSemestre()))
.add((or(isNull("programStreamId"), eq("programStreamId", ""))))
.list();
372,7 → 398,7
return createCriteria()
.createAlias("course", "c")
.add(eq("c.id", courseId))
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.add(eq("semestre", DatesUtils.getSemestre()))
.add((and(isNotNull("programStreamId"), not(eq("programStreamId", "")))))
.add((eq("validProgram", false)))
384,7 → 410,7
return createCriteria()
.createAlias("course", "c")
.add(eq("c.id", courseId))
.add(eq("importYear", DatesUtils.getImportYear()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear()))
.add(eq("semestre", DatesUtils.getSemestre()))
.add((or(or(isNull("objectives"), eq("objectives", "")), or(isNull("programStreamId"), eq("programStreamId", "")))))
.list();
411,4 → 437,199
q.setLong(0,unit);
return q.list();
}
 
public static class CourseMissingValidationProgram
{
public Course course;
public List<CourseUnit> courseUnits;
}
public List<CourseMissingValidationProgram> loadMissingProgramValidate(UserSession userSession)
{
List<CourseMissingValidationProgram> result = new ArrayList<CourseMissingValidationProgram>();
List<Course> courses = DaoFactory.getCourseDaoImpl().findAll(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
for(Course course: courses)
{
if(userSession.getUser().hasRole(course.getValidationRole()))
{
List<CourseUnit> courseUnits = loadMissingProgramValidateGivenCourse(course.getId());
if(courseUnits != null && courseUnits.size() > 0)
{
CourseMissingValidationProgram c = new CourseMissingValidationProgram();
c.course = course;
c.courseUnits = courseUnits;
result.add(c);
}
}
}
return result;
}
public List<CourseMissingValidationProgram> loadMissingPrograms(UserSession userSession)
{
List<CourseMissingValidationProgram> result = new ArrayList<CourseMissingValidationProgram>();
List<Course> courses = DaoFactory.getCourseDaoImpl().findAll(DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear());
for(Course course: courses)
{
if(userSession.getUser().hasRole(course.getValidationRole()))
{
List<CourseUnit> courseUnits = loadMissingProgramGivenCourse(course.getId());
if(courseUnits != null && courseUnits.size() > 0)
{
CourseMissingValidationProgram c = new CourseMissingValidationProgram();
c.course = course;
c.courseUnits = courseUnits;
result.add(c);
}
}
}
return result;
}
public static class CourseMissingValidationEvaluation
{
public Course course;
public List<CourseUnit> courseUnits;
}
 
public List<CourseMissingValidationEvaluation> loadMissingEvaluationValidate(UserSession userSession)
{
String activeYear = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear();
if(activeYear == null)
return new ArrayList<CourseMissingValidationEvaluation>();
List<CourseMissingValidationEvaluation> result = new ArrayList<CourseMissingValidationEvaluation>();
List<Course> courses = DaoFactory.getCourseDaoImpl().findAll();
for(Course course: courses)
{
if(userSession.getUser().hasRole(course.getValidationRole()))
{
List<CourseUnit> courseUnits = loadMissingEvaluationValidateGivenCourse(course.getId());
if(courseUnits != null && courseUnits.size() > 0)
{
CourseMissingValidationEvaluation c = new CourseMissingValidationEvaluation();
c.course = course;
c.courseUnits = courseUnits;
result.add(c);
}
}
}
return result;
}
 
/*
* Neste caso apenas se validam as do ano anterior*/
 
public List<CourseUnit> loadMissingEvaluationValidateGivenCourse(long courseId)
{
if(DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear()==null)
return new ArrayList<CourseUnit>();
 
return createCriteria()
.createAlias("course", "c")
.createAlias("courseUnitEvaluation", "ce")
.add(eq("c.id", courseId))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear()))
//.add(ge("importYear", "201415"))//FirstYear where there was configurations
.add((eq("ce.closed", false)))
.add((eq("ce.teacherComplete", true)))
.list();
}
 
public List<CourseUnit> loadTeacherUnitsMissingEvaluation(UserSession userSession)
{
String activeYear = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear();
if(activeYear == null)
return new ArrayList<CourseUnit>();
 
List<CourseUnit> nulls =
createCriteria()
.createAlias("teachers","t")
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear()))
//.add(not(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())))
//.add(ge("importYear", "201415" ))
//.add(isNull("courseUnitEvaluation"))
//todo novo testar
.add(eq("t.id", userSession.getUser().getId()))
.add(isNull("courseUnitEvaluation"))
.list();
 
List<CourseUnit> teacherCompleteFalse =
createCriteria()
.createAlias("courseUnitEvaluation", "ce")
.createAlias("teachers","t")
.add(eq("t.id", userSession.getUser().getId()))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear()))
//.add(not(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())))
//.add(ge("importYear", "201415" ))
//.add(isNull("courseUnitEvaluation"))
//todo novo testar
.add(eq("ce.teacherComplete",false))
.list();
teacherCompleteFalse.addAll(nulls);
return teacherCompleteFalse;
}
 
 
public List<CourseMissingValidationEvaluation> loadMissingEvaluation(UserSession userSession)
{
String activeYear = DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear();
if(activeYear == null)
return new ArrayList<CourseMissingValidationEvaluation>();
List<CourseMissingValidationEvaluation> result = new ArrayList<CourseMissingValidationEvaluation>();
List<Course> courses = DaoFactory.getCourseDaoImpl().findAll();
for(Course course: courses)
{
if(userSession.getUser().hasRole(course.getValidationRole()))
{
List<CourseUnit> courseUnits = loadMissingEvaluation(course.getId());
if(courseUnits != null && courseUnits.size() > 0)
{
CourseMissingValidationEvaluation c = new CourseMissingValidationEvaluation();
c.course = course;
c.courseUnits = courseUnits;
result.add(c);
}
}
}
return result;
}
 
public List<CourseUnit> loadMissingEvaluation(long courseId)
{
if(DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear()==null)
return new ArrayList<CourseUnit>();
 
List<CourseUnit> nulls =
createCriteria()
.createAlias("course", "c")
.add(eq("c.id", courseId))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear()))
//.add(not(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())))
//.add(ge("importYear", "201415" ))
//.add(isNull("courseUnitEvaluation"))
//todo novo testar
.add(isNull("courseUnitEvaluation"))
.list();
 
List<CourseUnit> teacherCompleteFalse =
createCriteria()
.createAlias("course", "c")
.createAlias("courseUnitEvaluation", "ce")
.add(eq("c.id", courseId))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear()))
//.add(not(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())))
//.add(ge("importYear", "201415" ))
//.add(isNull("courseUnitEvaluation"))
//todo novo testar
.add(eq("ce.teacherComplete", false))
.list();
teacherCompleteFalse.addAll(nulls);
return teacherCompleteFalse;
}
 
public CourseUnit loadByEvaluationStreamId(String identifier)
{
return
(CourseUnit)
createCriteria()
.add(eq("evaluationStreamId",identifier))
.uniqueResult();
}
}
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/CourseUnitEvaluationDaoImpl.java
New file
0,0 → 1,31
package pt.estgp.estgweb.domain.dao.impl;
 
import pt.estgp.estgweb.domain.CourseUnitQuestion;
import pt.estgp.estgweb.utils.DatesUtils;
 
import java.util.List;
 
import static org.hibernate.criterion.Restrictions.eq;
 
/**
* @author Jorge Machado
* @date 28/Fev/2008
* @time 2:51:06
* @see pt.estgp.estgweb.domain.dao.impl
*/
public class CourseUnitEvaluationDaoImpl extends CourseUnitEvaluationDao
{
 
 
private CourseUnitEvaluationDaoImpl()
{
}
 
public static CourseUnitEvaluationDaoImpl getInstance()
{
if (myInstance == null)
myInstance = new CourseUnitEvaluationDaoImpl();
return (CourseUnitEvaluationDaoImpl) myInstance;
}
 
}
/impl/src/java/pt/estgp/estgweb/domain/dao/DaoFactory.java
304,4 → 304,41
{
return DigitalDeliveryCategoryDaoImpl.getInstance();
}
public static CourseUnitEvaluationDaoImpl getCourseUnitEvaluationDaoImpl()
{
return CourseUnitEvaluationDaoImpl.getInstance();
}
 
 
public static JobServiceTaskDaoImpl getJobServiceTaskDaoImpl() {
return JobServiceTaskDaoImpl.getInstance();
}
public static JobServiceTaskSchedulerDaoImpl getJobServiceTaskSchedulerDaoImpl() {
return JobServiceTaskSchedulerDaoImpl.getInstance();
}
public static JobServiceTaskParameterDaoImpl getJobServiceTaskParameterDaoImpl() {
return JobServiceTaskParameterDaoImpl.getInstance();
}
public static JobServiceTaskSchedulerParameterDaoImpl getJobServiceTaskSchedulerParameterDaoImpl() {
return JobServiceTaskSchedulerParameterDaoImpl.getInstance();
}
 
public static ConfigurationDaoImpl getConfigurationDaoImpl() {
return ConfigurationDaoImpl.getInstance();
}
 
public static ConfigurationGradesDaoImpl getConfigurationGradesDaoImpl() {
return ConfigurationGradesDaoImpl.getInstance();
}
 
public static ConfigurationGradesEpocaAvaliacaoDaoImpl getConfigurationGradesEpocaAvaliacaoDaoImpl() {
return ConfigurationGradesEpocaAvaliacaoDaoImpl.getInstance();
}
 
public static ConfigurationGradesStatusEpocaDaoImpl getConfigurationGradesStatusEpocaDaoImpl() {
return ConfigurationGradesStatusEpocaDaoImpl.getInstance();
}
 
 
 
}
/impl/src/java/pt/estgp/estgweb/domain/ConfigurationGradesEpocaAvaliacaoImpl.java
New file
0,0 → 1,29
package pt.estgp.estgweb.domain;
 
import java.io.Serializable;
import java.util.Date;
 
/**
* Created by jorgemachado on 02/11/15.
*/
public class ConfigurationGradesEpocaAvaliacaoImpl extends ConfigurationGradesEpocaAvaliacao {
 
public ConfigurationGradesEpocaAvaliacaoImpl()
{
}
@Override
public Serializable getSerializable() {
return getId();
}
 
public static ConfigurationGradesEpocaAvaliacao create(String epoca, String momento, String descricao)
{
ConfigurationGradesEpocaAvaliacao obj = DomainObjectFactory.createConfigurationGradesEpocaAvaliacaoImpl();
obj.setCodigoMomento(momento);
obj.setCodigoEpoca(epoca);
obj.setDescricao(descricao);
obj.setSaveDate(new Date());
return obj;
}
 
}
/impl/src/java/pt/estgp/estgweb/domain/JobServiceTaskSchedulerImpl.java
New file
0,0 → 1,19
package pt.estgp.estgweb.domain;
 
import java.io.Serializable;
import java.util.Date;
 
/**
* Created by jorgemachado on 02/11/15.
*/
public class JobServiceTaskSchedulerImpl extends JobServiceTaskScheduler {
 
public JobServiceTaskSchedulerImpl()
{
setLastScheduleDate(new Date(0));
}
@Override
public Serializable getSerializable() {
return getId();
}
}
/impl/src/java/pt/estgp/estgweb/domain/JobServiceTaskSchedulerParameterImpl.java
New file
0,0 → 1,13
package pt.estgp.estgweb.domain;
 
import java.io.Serializable;
 
/**
* Created by jorgemachado on 02/11/15.
*/
public class JobServiceTaskSchedulerParameterImpl extends JobServiceTaskSchedulerParameter{
@Override
public Serializable getSerializable() {
return getId();
}
}
/impl/src/java/pt/estgp/estgweb/domain/JobServiceTaskParameterImpl.java
New file
0,0 → 1,22
package pt.estgp.estgweb.domain;
 
import org.apache.log4j.Logger;
 
import java.io.Serializable;
 
/**
* @author Jorge Machado
* @date 2/Mar/2008
* @time 10:27:25
* @see pt.estgp.estgweb.domain
*/
public class JobServiceTaskParameterImpl extends JobServiceTaskParameter
{
 
private static final Logger logger = Logger.getLogger(JobServiceTaskParameterImpl.class);
 
public Serializable getSerializable()
{
return getId();
}
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/domain/UserSessionImpl.java
1,22 → 1,18
package pt.estgp.estgweb.domain;
 
import org.apache.commons.io.output.ByteArrayOutputStream;
 
import java.io.Serializable;
import java.io.ByteArrayInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.util.*;
import java.beans.XMLEncoder;
import java.beans.XMLDecoder;
 
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.web.utils.RequestUtils;
import pt.utl.ist.berserk.logic.serviceManager.IServiceManager;
import pt.utl.ist.berserk.logic.serviceManager.ServiceManager;
import pt.estgp.estgweb.web.utils.RequestUtils;
import pt.estgp.estgweb.domain.dao.DaoFactory;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
 
/**
* @author Jorge Machado
119,22 → 115,30
 
public void clearObjects()
{
 
if (getObjects() == null || getObjects().size() == 0)
{
return;
}
System.out.println("Clearing session from " + getObjects().size() + " objects");
for(SessionObject obj: getObjects())
System.out.println(obj.getId().getKeyId());
if(removeList != null)
removeList.addAll(getObjects());
else
removeList = getObjects();
setObjects(null);
//todo NOVO Authenticate
getObjects().clear();
}
 
public void clearObjectsWithOpenTransaction()
{
clearObjects();
if(removeList != null && removeList.size() > 0)
{
DaoFactory.getSessionObjectDaoImpl().evictAndDelete(removeList);
 
}
}
 
 
200,7 → 204,7
* @param key
* @return
*/
private SessionObject getSessionObject(String key)
public SessionObject getSessionObject(String key)
{
if (getObjects() == null)
{
/impl/src/java/pt/estgp/estgweb/domain/CourseUnitEvaluationImpl.java
New file
0,0 → 1,216
package pt.estgp.estgweb.domain;
 
import org.apache.fop.apps.FOPException;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.dom.DOMDocumentFactory;
import pt.estgp.estgweb.services.courseunits.SaveCourseUnitEvaluation;
 
import javax.xml.transform.TransformerException;
import java.beans.ExceptionListener;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
 
/**
* Created by jorgemachado on 03/06/14.
*/
 
/**
 
 
 
 
 
 
 
 
 
 
 
 
private String qualConclusoes;
*/
public class CourseUnitEvaluationImpl extends CourseUnitEvaluation {
@Override
public Serializable getSerializable() {
return getId();
}
public CourseUnitEvaluationImpl() {
}
 
 
public Document getDom(CourseUnit cu){
Document dom = DOMDocumentFactory.getInstance().createDocument();
Element elemCourseUnitEvaluationImpl = dom.addElement("CourseUnitEvaluation");
 
Element anoLectivo = elemCourseUnitEvaluationImpl.addElement("anoLectivo");
anoLectivo.setText(cu.getImportYear());
 
Element curso = elemCourseUnitEvaluationImpl.addElement("curso");
Element nomeCur = curso.addElement("nome");
nomeCur.setText(cu.getCourseName());
Element codigoCur = curso.addElement("codigo");
codigoCur.setText(cu.getCourseCode());
 
 
Element unidadecurricular = elemCourseUnitEvaluationImpl.addElement("unidadecurricular");
Element nome = unidadecurricular.addElement("nome");
nome.setText(cu.getName());
Element codigo = unidadecurricular.addElement("codigo");
codigo.setText(cu.getCode());
 
if(cu.getResponsableTeacher() != null)
{
Element responsavel = elemCourseUnitEvaluationImpl.addElement("responsavel");
Element nomeRes = responsavel.addElement("nome");
nomeRes.setText(cu.getResponsableTeacher().getName());
Element emailRes = responsavel.addElement("email");
if(cu.getResponsableTeacher().getEmail()!= null)
emailRes.setText(cu.getResponsableTeacher().getEmail());
else
emailRes.setText("");
}
 
if(cu.getTeachers() != null && cu.getTeachers().size()>0)
{
for(Teacher t: cu.getTeachers())
{
Element docente = elemCourseUnitEvaluationImpl.addElement("docente");
Element nomeRes = docente.addElement("nome");
nomeRes.setText(t.getName());
Element emailRes = docente.addElement("email");
if(t.getEmail()!= null)
emailRes.setText(t.getEmail());
else
emailRes.setText("");
}
}
 
 
Element id = elemCourseUnitEvaluationImpl.addElement("id");
id.setText(getId()+"");
 
Element updateDate = elemCourseUnitEvaluationImpl.addElement("updateDate");
updateDate.setText(getUpdateDate()+"");
 
Element saveDate = elemCourseUnitEvaluationImpl.addElement("saveDate");
saveDate.setText(getSaveDate()+"");
 
Element closed = elemCourseUnitEvaluationImpl.addElement("closed");
closed.setText(isClosed()+"");
 
Element numAlunosInscritos = elemCourseUnitEvaluationImpl.addElement("numAlunosInscritos");
numAlunosInscritos.setText(getNumAlunosInscritos()+"");
 
Element numAlunosSemElementosAvaliacao = elemCourseUnitEvaluationImpl.addElement("numAlunosSemElementosAvaliacao");
numAlunosSemElementosAvaliacao.setText(getNumAlunosSemElementosAvaliacao()+"");
 
Element numAlunosAprovFrequencia = elemCourseUnitEvaluationImpl.addElement("numAlunosAprovFrequencia");
numAlunosAprovFrequencia.setText(getNumAlunosAprovFrequencia()+"");
 
Element numAlunosAprovNormal = elemCourseUnitEvaluationImpl.addElement("numAlunosAprovNormal");
numAlunosAprovNormal.setText(getNumAlunosAprovNormal()+"");
 
Element numAlunosAprovRecurso = elemCourseUnitEvaluationImpl.addElement("numAlunosAprovRecurso");
numAlunosAprovRecurso.setText(getNumAlunosAprovRecurso()+"");
 
Element numAlunosAprovEspecial = elemCourseUnitEvaluationImpl.addElement("numAlunosAprovEspecial");
numAlunosAprovEspecial.setText(getNumAlunosAprovEspecial()+"");
 
Element numAlunosAprovTotal = elemCourseUnitEvaluationImpl.addElement("numAlunosAprovTotal");
numAlunosAprovTotal.setText(getNumAlunosAprovTotal()+"");
 
Element numAlunosAprov1013 = elemCourseUnitEvaluationImpl.addElement("numAlunosAprov1013");
numAlunosAprov1013.setText(getNumAlunosAprov1013()+"");
 
Element numAlunosAprov1416 = elemCourseUnitEvaluationImpl.addElement("numAlunosAprov1416");
numAlunosAprov1416.setText(getNumAlunosAprov1416()+"");
 
Element numAlunosAprov1720 = elemCourseUnitEvaluationImpl.addElement("numAlunosAprov1720");
numAlunosAprov1720.setText(getNumAlunosAprov1720()+"");
 
Element numAlunosAprovados = elemCourseUnitEvaluationImpl.addElement("numAlunosAprovados");
numAlunosAprovados.setText(getNumAlunosAprovados()+"");
 
Element numAlunosReprovados = elemCourseUnitEvaluationImpl.addElement("numAlunosReprovados");
numAlunosReprovados.setText(getNumAlunosReprovados()+"");
 
Element qualApreciacaoQuantitivos = elemCourseUnitEvaluationImpl.addElement("qualApreciacaoQuantitivos");
qualApreciacaoQuantitivos.setText(getQualApreciacaoQuantitivos()+"");
 
Element qualApreciacaoUC = elemCourseUnitEvaluationImpl.addElement("qualApreciacaoUC");
qualApreciacaoUC.setText(getQualApreciacaoUC()+"");
 
Element qualApreciacaoCumprimentoPrograma = elemCourseUnitEvaluationImpl.addElement("qualApreciacaoCumprimentoPrograma");
qualApreciacaoCumprimentoPrograma.setText(getQualApreciacaoCumprimentoPrograma()+"");
 
Element qualConclusoes = elemCourseUnitEvaluationImpl.addElement("qualConclusoes");
qualConclusoes.setText(getQualConclusoes()+"");
 
return dom;
}
 
public String writeXml() throws FileNotFoundException {
StringOutputStream sout = new StringOutputStream();
java.beans.XMLEncoder xe1 = new java.beans.XMLEncoder(sout);
xe1.setExceptionListener(new ExceptionListener() {
@Override
public void exceptionThrown(Exception e) {
System.out.println("Exception:" + e.toString());
}
});
//ObjectOutputStream oos = new ObjectOutputStream( baos );
xe1.writeObject(this);
xe1.flush();
xe1.close();
 
return sout.getString();
}
 
public static class StringOutputStream extends OutputStream {
 
StringBuilder mBuf = new StringBuilder();
 
public void write(int c) throws IOException {
mBuf.append((char) c);
}
 
public String getString() {
return mBuf.toString();
}
}
 
public static class Teste
{
public Teste(){}
private String nome;
 
public String getNome() {
return nome;
}
 
public void setNome(String nome) {
this.nome = nome;
}
}
public static void main(String [] args) throws IOException, TransformerException, FOPException {
CourseUnitEvaluationImpl cuv = new CourseUnitEvaluationImpl() {
@Override
public Serializable getSerializable() {
return 1;
}
};
cuv.setClosed(true);
cuv.setNumAlunosAprov1013(12);
cuv.setNumAlunosInscritos("" + 20);
cuv.setQualConclusoes("conclusoes");
SaveCourseUnitEvaluation s = new SaveCourseUnitEvaluation();
CourseUnit cu = new CourseUnitImpl();
cu.setNormalizedName("teste");
cu.setCode("TESTE");
s.generatePdf(cuv,cu);
}
 
}
/impl/src/java/pt/estgp/estgweb/domain/ConfigurationGradesImpl.java
New file
0,0 → 1,63
package pt.estgp.estgweb.domain;
 
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
 
/**
* Created by jorgemachado on 02/11/15.
*/
public class ConfigurationGradesImpl extends ConfigurationGrades {
 
public ConfigurationGradesImpl()
{
}
@Override
public Serializable getSerializable() {
return getId();
}
 
 
 
public void create()
{
Set<ConfigurationGradesEpocaAvaliacao> epocas = new HashSet<ConfigurationGradesEpocaAvaliacao>();
epocas.add(ConfigurationGradesEpocaAvaliacaoImpl.create("7", "99", "Estatutos Especiais/Dirigente Associativo (ESTG)"));
epocas.add(ConfigurationGradesEpocaAvaliacaoImpl.create("12", "99", "Equivalência Vasco da Gama (ESTG)"));
epocas.add(ConfigurationGradesEpocaAvaliacaoImpl.create("13", "99", "Atleta de Alta Competição (ESTG)"));
epocas.add(ConfigurationGradesEpocaAvaliacaoImpl.create("20", "99", "Época Normal (ESTG)"));
epocas.add(ConfigurationGradesEpocaAvaliacaoImpl.create("22", "99", "Equivalência Erasmus (ESTG)"));
epocas.add(ConfigurationGradesEpocaAvaliacaoImpl.create("36", "99", "Época de Recurso (ESTG)"));
epocas.add(ConfigurationGradesEpocaAvaliacaoImpl.create("37", "99", "Época de Melhoria (ESTG)"));
epocas.add(ConfigurationGradesEpocaAvaliacaoImpl.create("38", "99", "Época Especial (ESTG)"));
setEpocasAvaliacao(epocas);
 
Set<ConfigurationGradesStatusEpoca> status = new HashSet<ConfigurationGradesStatusEpoca>();
status.add(ConfigurationGradesStatusEpocaImpl.create("1","Inscrito"));
status.add(ConfigurationGradesStatusEpocaImpl.create("2","Avaliado"));
status.add(ConfigurationGradesStatusEpocaImpl.create("19","A Terminar Posteriormente 6 A pagamento"));
status.add(ConfigurationGradesStatusEpocaImpl.create("5","Anulou"));
status.add(ConfigurationGradesStatusEpocaImpl.create("7","Faltou"));
status.add(ConfigurationGradesStatusEpocaImpl.create("8","Desistiu"));
status.add(ConfigurationGradesStatusEpocaImpl.create("9","Dispensado"));
status.add(ConfigurationGradesStatusEpocaImpl.create("3","Aprovado"));
status.add(ConfigurationGradesStatusEpocaImpl.create("4","Reprovado"));
status.add(ConfigurationGradesStatusEpocaImpl.create("10","Admitido a Exame"));
status.add(ConfigurationGradesStatusEpocaImpl.create("11","Não Admitido"));
status.add(ConfigurationGradesStatusEpocaImpl.create("12","Sem avaliação"));
status.add(ConfigurationGradesStatusEpocaImpl.create("13","Insc. Pendente"));
status.add(ConfigurationGradesStatusEpocaImpl.create("14","Sem elementos de avaliação"));
status.add(ConfigurationGradesStatusEpocaImpl.create("15","Reprovado por faltas"));
status.add(ConfigurationGradesStatusEpocaImpl.create("16","Não atingiu a nota minima"));
status.add(ConfigurationGradesStatusEpocaImpl.create("18","Aguarda Equivalência"));
status.add(ConfigurationGradesStatusEpocaImpl.create("17","Não cumpriu critérios de avaliação"));
status.add(ConfigurationGradesStatusEpocaImpl.create("20","Prova anulada"));
status.add(ConfigurationGradesStatusEpocaImpl.create("21","Não atingiu todas as competências da unidade"));
status.add(ConfigurationGradesStatusEpocaImpl.create("22","Sem Nota Lançada"));
status.add(ConfigurationGradesStatusEpocaImpl.create("23","Frequentou"));
status.add(ConfigurationGradesStatusEpocaImpl.create("24","Melhoria não Atribuida"));
setStatusEpoca(status);
}
 
 
}
/impl/src/java/pt/estgp/estgweb/domain/ConfigurationImpl.java
New file
0,0 → 1,18
package pt.estgp.estgweb.domain;
 
import java.io.Serializable;
 
/**
* @author Jorge Machado
* @date 2/Mar/2008
* @time 10:27:25
* @see pt.estgp.estgweb.domain
*/
public class ConfigurationImpl extends Configuration
{
 
public Serializable getSerializable()
{
return getId();
}
}
/impl/src/java/pt/estgp/estgweb/filters/chains/ResourceAccessControlEnum.java
16,7 → 16,9
superUserDomain("resource.access.superDomain",new ResourceAccessControlSuperDomainFilter()),
courseunitDeliverableDomain("resource.access.courseunitDeliverableDomain",new ResourceAccessControlCourseUnitDeliverableFilter()),
courseunitDomain("resource.access.courseunitDomain",new ResourceAccessControlCourseUnitFilter()),
// Duarte Santos
// Duarte Santos
courseunitEvaluationDomain("resource.access.courseunitEvaluationDomain",new ResourceAccessControlCourseUnitEvaluationFilter()),
 
surveyStatsDomain("resource.access.survey", new ResourceAccessControlSurvey()),
 
processDomain("resource.access.process", new ResourceAccessControlProcessDomainFilter());
/impl/src/java/pt/estgp/estgweb/filters/filters/ResourceAccessControlCourseUnitEvaluationFilter.java
New file
0,0 → 1,24
package pt.estgp.estgweb.filters.filters;
 
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.CourseUnitImpl;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.filters.chains.ResourceAccessControlFilter;
 
/**
* @author Jorge Machado
* @date 4/Jun/2008
* @see pt.estgp.estgweb.filters.filters
*/
public class ResourceAccessControlCourseUnitEvaluationFilter extends ResourceAccessControlFilter
{
 
private static final Logger logger = Logger.getLogger(ResourceAccessControlCourseUnitEvaluationFilter.class);
 
public boolean canAccessResource(UserSession userSession, String identifier)
{
CourseUnitImpl c = (CourseUnitImpl) DaoFactory.getCourseUnitDaoImpl().loadByEvaluationStreamId(identifier);
return c.isFromCourseUnitCommission(userSession);
}
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/web/tags/CanManageTag.java
70,8 → 70,8
 
 
IInternal iInternal = (IInternal) owned;
System.out.println("userSession: " + userSession);
System.out.println("iInternal: " + iInternal);
//System.out.println("userSession: " + userSession);
//System.out.println("iInternal: " + iInternal);
if((userSession==null || userSession.getUser() == null) && iInternal.isInternal())
{
return false;
/impl/src/java/pt/estgp/estgweb/web/tags/OwnerImageRoleTag.java
39,7 → 39,7
 
public int doStartTag() throws JspException {
HttpServletRequest hrequest = (HttpServletRequest) pageContext.getRequest();
Object bean = null;
Object bean = null;
if(name != null)
bean = RequestUtils.lookup(pageContext, name, property, null);
 
/impl/src/java/pt/estgp/estgweb/web/tags/Object2RequestTag.java
New file
0,0 → 1,120
package pt.estgp.estgweb.web.tags;
 
import jomm.utils.MessageResources;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.views.CourseUnitView;
import pt.estgp.estgweb.web.exceptions.NoCookiesException;
import pt.estgp.estgweb.web.utils.RequestUtils;
import pt.utl.ist.berserk.logic.filterManager.exceptions.*;
import pt.utl.ist.berserk.logic.serviceManager.IServiceManager;
import pt.utl.ist.berserk.logic.serviceManager.ServiceManager;
import pt.utl.ist.berserk.logic.serviceManager.exceptions.ServiceManagerException;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
 
public class Object2RequestTag extends TagSupport
{
 
private static final Logger logger = Logger.getLogger(Object2RequestTag.class);
 
private String beanIdName;
private String beanIdProperty;
private String classname;
private String useBean;
 
public String getUseBean() {
return useBean;
}
 
public void setUseBean(String useBean) {
this.useBean = useBean;
}
 
public String getClassname() {
return classname;
}
 
public void setClassname(String classname) {
this.classname = classname;
}
 
public String getBeanIdName() {
return beanIdName;
}
 
public void setBeanIdName(String beanIdName) {
this.beanIdName = beanIdName;
}
 
public String getBeanIdProperty() {
return beanIdProperty;
}
 
public void setBeanIdProperty(String beanIdProperty) {
this.beanIdProperty = beanIdProperty;
}
 
public int doStartTag() throws JspException
{
HttpServletRequest hrequest = (HttpServletRequest) pageContext.getRequest();
HttpServletResponse hresponse = (HttpServletResponse) pageContext.getResponse();
Object bean = null;
try{
if(beanIdName != null)
bean = org.apache.struts.util.RequestUtils.lookup(pageContext, beanIdName, beanIdProperty, null);
}catch(JspException e)
{
 
}
Long id;
if(bean == null)
bean = hrequest.getParameter(beanIdName);
if(bean == null)
{
logger.error("Cant find " + beanIdName + " in any scope neither in paramenters");
return (SKIP_BODY);
}
if(bean instanceof String)
id = Long.parseLong((String)bean);
else
id = (Long) bean;
 
 
 
try {
 
IServiceManager sm = ServiceManager.getInstance();
String[] names = new String[]{};
Object[] args = new Object[]{classname, id};
 
Object loaded = sm.execute(RequestUtils.getRequester(hrequest, hresponse), "LoadObjectService", args, names);
 
hrequest.setAttribute(useBean,loaded);
 
} catch (FilterRetrieveException e) {
e.printStackTrace();
} catch (InvalidFilterExpressionException e) {
e.printStackTrace();
} catch (InvalidFilterException e) {
e.printStackTrace();
} catch (ClassNotIFilterException e) {
e.printStackTrace();
} catch (IncompatibleFilterException e) {
e.printStackTrace();
} catch (ServiceManagerException e) {
e.printStackTrace();
} catch (NoCookiesException e) {
e.printStackTrace();
} catch (Throwable throwable) {
throwable.printStackTrace();
}
 
//JspWriter writer = pageContext.getOut();
 
return (SKIP_BODY);
}
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/web/DirWebProxy.java
1,36 → 1,36
package pt.estgp.estgweb.web;
 
import org.apache.log4j.Logger;
import jomm.web.ftp.FileType;
import jomm.web.ftp.IFile;
import jomm.web.ftp.impl.FtpFile;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTP;
import org.dom4j.*;
import org.dom4j.io.OutputFormat;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.utils.Dom4jUtil;
import pt.estgp.estgweb.web.exceptions.NotAuthorizedException;
 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.servlet.jsp.JspWriter;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.zip.ZipInputStream;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
import java.util.zip.ZipInputStream;
 
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.utils.Dom4jUtil;
import pt.estgp.estgweb.domain.UserSession;
import freemarker.template.utility.HtmlEscape;
import com.lowagie.text.html.HtmlEncoder;
import jomm.web.ftp.IFile;
import jomm.web.ftp.FileType;
import jomm.web.ftp.impl.FtpFile;
import jomm.web.utils.NavPlace;
import pt.estgp.estgweb.web.exceptions.NotAuthorizedException;
 
/**
* @author Jorge Machado
* @date 26/Fev/2008
99,12 → 99,14
 
logger.info("server:" + server);
logger.info("path:" + path);
logger.info("startPath:" + startPath);
logger.info("proxyKey:" + proxyKey);
logger.info("proxyHost:" + proxyHost);
logger.info("proxyPort:" + proxyPort);
logger.info("xml:" + xml);
logger.info("style:" + style);
logger.info("label:" + label);
logger.info("useOutputStream:" + useOutputStream);
 
if (path != null)
{
169,7 → 171,8
}
path = startPath + leafUrl + endPath;
}
extendDiretoryDocument(request, path, proxyKey, server, startPath + leafUrl, directoryDocument);
if(!extendDiretoryDocument(request, response, path, proxyKey, server, startPath + leafUrl, directoryDocument))
return;
styleDirectory(request, response);
}
178,7 → 181,7
{
UserSession userSession = UserSessionProxy.loadUserSessionFromRequest(request);
String username = userSession != null ? userSession.getUsername() : "UNKNOWN";
logger.warn(username + ":" + request.getRemoteAddr() + " cant access this area server:" + server + " and path:" + path + " " + request.getRemoteUser() + " " + request.getRequestURL() + " spath " + request.getServletPath() + " queryString " + request.getQueryString() );
logger.warn(username + ":" + request.getRemoteAddr() + " cant access this area server:" + server + " and path:" + path + " " + request.getRemoteUser() + " " + request.getRequestURL() + " spath " + request.getServletPath() + " queryString " + request.getQueryString() ,e);
response.sendError(401);
}
catch (FileNotFoundException e)
189,7 → 192,7
}
catch (Exception e)
{
logger.error(e,e);
logger.error(e, e);
throw new IOException(e.toString());
}
}
209,7 → 212,7
}
 
 
protected static void extendDiretoryDocument(HttpServletRequest request, String path, String serverStr, String server, String startPath, Document directoryDocument)
protected static boolean extendDiretoryDocument(HttpServletRequest request,HttpServletResponse response, String path, String serverStr, String server, String startPath, Document directoryDocument)
throws ServletException, IOException
{
 
223,6 → 226,13
 
FtpServer ftpServer = FtpServer.getServer(server, user, pass);
FTPClient client = ftpServer.getClient();
if(client == null)
{
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP");
response.sendError(408);
return false;
}
Element actualNode = (Element) request.getAttribute("actualNode");
 
378,6 → 388,7
throw (NotAuthorizedException)e;
logger.error(e, e);
}
return true;
}
 
 
449,6 → 460,7
String actualNodeId = (String) request.getAttribute("actualNodeId");
String actualRemoteNodeId = (String) request.getAttribute("ACTUAL_REMOTE_CHILD");
UserSession userSession = UserSessionProxy.loadUserSessionFromRequest(request);
System.out.println("Using stylesheet = " + stylesheet);
 
parameters.put("contextPath", request.getContextPath());
String username = "descolnhecido";
659,6 → 671,13
{
FtpServer server = FtpServer.getServer("ftp://www.global.estgp.pt","jmachado","linux5631");
FTPClient client = server.getClient();
if(client == null)
{
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP");
 
}
 
client.setFileType(FTP.BINARY_FILE_TYPE);
FileInputStream teste = new FileInputStream("D:\\resources.properties");
client.changeWorkingDirectory("/Engenharia.Informatica.9119/AnoLectivo.2008-2009/Semestre1/Engenharia.Do.Software");
/impl/src/java/pt/estgp/estgweb/web/WebProxy.java
1,9 → 1,11
package pt.estgp.estgweb.web;
 
import jomm.utils.StreamsUtils;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.utils.StringsUtils;
 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
195,6 → 197,44
String pathFinal = path.indexOf("?") >=0 ? URIUtil.encodePath(path.substring(0,path.indexOf("?")), "ISO-8859-1") + "?" +path.substring(path.indexOf("?")+1) : path;
System.out.println(pathFinal);
}
public static boolean checkExist( String server, String path)
{
 
String serverUrl = ConfigProperties.getProperty("server." + server);
String serverEncoding = ConfigProperties.getProperty(server + ".encoding");
String confStartPath = ConfigProperties.getProperty("server." + server + ".start.path");
if (confStartPath != null)
path = confStartPath + path;
 
 
try
{
 
String pathFinal = path.indexOf("?") >=0 ? URIUtil.encodePath(path.substring(0,path.indexOf("?")), "ISO-8859-1") + path.substring(path.indexOf("?")) : path;
System.out.println("Getting: " + serverUrl + pathFinal);
URL url = new URL(serverUrl + pathFinal);
 
 
URLConnection con = url.openConnection();
InputStream stream = con.getInputStream();
String out = StreamsUtils.readString(stream);
stream.close();
 
if(out.trim().length() == 0)
return false;
return true;
}
catch (FileNotFoundException e)
{
return false;
}
catch (Exception e)
{
return false;
}
 
}
 
public static void processHttpRequestService(JspWriter out, String server, String path) throws IOException, ServletException
{
 
/impl/src/java/pt/estgp/estgweb/web/FtpServer.java
3,10 → 3,11
import org.apache.commons.net.ftp.FTPClient;
import org.apache.log4j.Logger;
 
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
 
/**
* @author Jorge
42,10 → 43,42
this.password = password;
}
 
private static final int FTP_TIMEOUT_SECONDS = pt.estgp.estgweb.Globals.FTP_TIMEOUT_SECONDS;
public FTPClient getClient() throws IOException
{
FTPClient ftp = new FTPClient();
ftp.connect(host, port);
final FTPClient ftp = new MyFTPClient();
logger.info("CONNECTING... waiting " + FTP_TIMEOUT_SECONDS + " seconds");
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
ftp.connect(host, port);
} catch (IOException e) {
logger.error(e,e);
}
}
});
t.start();
try {
for(int i=0;i<FTP_TIMEOUT_SECONDS;i++)
{
Thread.sleep(1000);
if(!t.isAlive())
{
if(ftp.isConnected())
break;
}
}
if(!ftp.isConnected())
{
logger.info("Not Connected will interrupt");
t.interrupt();
return null;
}
} catch (InterruptedException e) {
logger.error(e,e);
}
 
if (username != null)
ftp.user(username);
if (password != null)
159,5 → 192,50
return null;
}
 
public static final int FTP_DATA_STORE_TIMEOUT_SECONDS = pt.estgp.estgweb.Globals.FTP_DATA_STORE_TIMEOUT_SECONDS;
public class MyFTPClient extends FTPClient implements Runnable
{
String remote = "";
InputStream local = null;
boolean storeResult = false;
 
public void run() {
try {
storeResult = super.storeFile(remote, local);
} catch (IOException e) {
logger.error(e,e);
}
}
@Override
public boolean storeFile(String remote, InputStream local) throws IOException
{
logger.info("FTP store Timeout protection of " + FTP_DATA_STORE_TIMEOUT_SECONDS + " seconds");
this.remote = remote;
this.local = local;
Thread t = new Thread(this);
t.start();
try {
for(int i=0;i<FTP_DATA_STORE_TIMEOUT_SECONDS;i++)
{
Thread.sleep(1000);
if(!t.isAlive())
{
break;
}
}
if(t.isAlive())
{
logger.info("Timeout expired will interrupt");
t.interrupt();
return false;
}
} catch (InterruptedException e) {
logger.error(e,e);
}
return storeResult;
}
}
 
 
 
}
/impl/src/java/pt/estgp/estgweb/web/LayoutController.java
1,5 → 1,6
package pt.estgp.estgweb.web;
 
import jomm.utils.DesUtils;
import jomm.web.ftp.IFile;
import jomm.web.ftp.impl.FtpFile;
import jomm.web.utils.NavPlace;
11,6 → 12,8
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.UserSessionImpl;
import pt.estgp.estgweb.services.ftpservices.FtpService;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.web.controllers.ApplicationDispatchController;
import pt.estgp.estgweb.web.exceptions.NotAuthorizedException;
130,17 → 133,40
UserSession userSession = UserSessionProxy.loadUserSessionFromRequest(request);
String username = userSession != null ? userSession.getUsername() : "UNKNOWN";
 
String user = ConfigProperties.getProperty(serverStr + ".user");
String pass = ConfigProperties.getProperty(serverStr + ".pass");
 
 
if (path != null)
{
 
FtpServer ftpServer = FtpServer.getServer(server, user, pass);
boolean isStaticAccess = ConfigProperties.getBooleanProperty(serverStr+".use.default.credentials.to.updates.and.deletes");
String user;
String pass;
 
if(isStaticAccess)
{
user = ConfigProperties.getProperty(serverStr + ".user");
pass = ConfigProperties.getProperty(serverStr + ".pass");
}
else
{
logger.warn("Will access using user and pass authnenticated to connect FTP " + serverStr);
user= username;
String passwordCode = (String) ((UserSessionImpl)userSession).get(FtpService.FTP_PASSWORD);
pass= DesUtils.getInstance().decrypt(passwordCode);
//pass= ((UserImpl)userSession.getUser()).getPop3PassDecrypted();
}
FtpServer ftpServer = FtpServer.getNewServer(server, user, pass);
FTPClient client = ftpServer.getClient();
if(client == null)
{
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP");
response.sendError(408);
return;
}
 
if(!client.changeWorkingDirectory(path))
{
logger.warn(username + ": " + request.getRemoteAddr() + "cant access this area server:" + server + " and path:" + path);
throw new NotAuthorizedException("nao pode aceder a esta area");
}
FTPFile[] files = client.listFiles();
/impl/src/java/pt/estgp/estgweb/web/soap/courses/CourseWS.java
New file
0,0 → 1,22
package pt.estgp.estgweb.web.soap.courses;
 
import pt.estgp.estgweb.domain.views.serviceviews.CourseViewServ;
 
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
 
/**
* Created by jorgemachado on 13/10/15.
* SOAP Tutorial
*/
//Service Endpoint Interface
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
//@ResponseWrapper(className="pt.estgp.estgweb.domain.views.CourseView");
public interface CourseWS {
@WebMethod
public CourseViewServ[] listCourses();
 
 
}
/impl/src/java/pt/estgp/estgweb/web/soap/courses/CourseWsImpl.java
New file
0,0 → 1,46
package pt.estgp.estgweb.web.soap.courses;
 
 
import jomm.dao.utils.HibernateUtils;
import pt.estgp.estgweb.domain.views.CourseView;
import pt.estgp.estgweb.domain.views.serviceviews.CourseViewServ;
import pt.estgp.estgweb.services.courses.CoursesService;
import pt.estgp.estgweb.services.expceptions.ServiceException;
 
import javax.jws.WebService;
import java.util.List;
 
/**
* SOAP Tutorial
*/
 
@WebService(endpointInterface = "pt.estgp.estgweb.web.soap.courses.CourseWS")
public class CourseWsImpl implements CourseWS{
 
@Override
public CourseViewServ[] listCourses()
{
HibernateUtils.getCurrentSession().beginTransaction();
 
List<CourseView> courses = null;
try {
courses = new CoursesService().loadCourses();
} catch (ServiceException e) {
e.printStackTrace();
return null;
}
 
CourseViewServ[] courseViews = new CourseViewServ[courses.size()];
int i = 0;
for(CourseView c:courses)
{
courseViews[i] = new CourseViewServ(c);
i++;
}
 
 
 
HibernateUtils.getCurrentSession().getTransaction().commit();
return courseViews;
}
}
/impl/src/java/pt/estgp/estgweb/web/soap/HelloWorld.java
New file
0,0 → 1,17
package pt.estgp.estgweb.web.soap;
 
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
 
/**
* Created by jorgemachado on 13/10/15.
* SOAP Tutorial
*/
//Service Endpoint Interface
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface HelloWorld {
@WebMethod
String getHelloWorldAsString();
}
/impl/src/java/pt/estgp/estgweb/web/soap/HelloWorldImpl.java
New file
0,0 → 1,17
package pt.estgp.estgweb.web.soap;
 
 
import javax.jws.WebService;
 
/**
* SOAP Tutorial
*/
 
@WebService(endpointInterface = "pt.estgp.estgweb.web.soap.HelloWorld")
public class HelloWorldImpl implements HelloWorld{
 
@Override
public String getHelloWorldAsString() {
return "Hello World JAX-WS";
}
}
/impl/src/java/pt/estgp/estgweb/web/form/courses/CourseForm.java
1,16 → 1,16
package pt.estgp.estgweb.web.form.courses;
 
import pt.estgp.estgweb.web.form.commons.TeachersForm;
import org.apache.struts.upload.FormFile;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.CourseView;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.services.courseunits.DirectedCoordinatedCourses;
import pt.estgp.estgweb.services.courseunits.DirectedCoordinatedUnitsService;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.web.form.commons.TeachersForm;
 
import java.util.List;
 
import org.apache.struts.upload.FormFile;
 
/**
* @author Jorge Machado
* @date 25/Jun/2008
22,7 → 22,7
private FormFile studiesPlan;
private DirectedCoordinatedCourses directedCoordinatedCourses = new DirectedCoordinatedCourses();
 
private String importYear = DatesUtils.getImportYear();
private String importYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYearCreateTransaction();
 
private String area;
 
/impl/src/java/pt/estgp/estgweb/web/form/courseunits/CourseUnitEvaluationForm.java
New file
0,0 → 1,64
package pt.estgp.estgweb.web.form.courseunits;
 
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.CourseUnitProgramImpl;
import pt.estgp.estgweb.domain.CourseUnitProgramPart2Impl;
import pt.estgp.estgweb.domain.DomainObjectFactory;
import pt.estgp.estgweb.domain.views.CourseUnitEvaluationView;
import pt.estgp.estgweb.domain.views.CourseUnitProgramView;
import pt.estgp.estgweb.domain.views.CourseUnitView;
 
/**
* @author Jorge Machado
* @date 2/Jun/2008
* @time 14:28:59
* @see pt.estgp.estgweb.web.form.blogs
*/
public class CourseUnitEvaluationForm extends CourseUnitsForm
{
private static final Logger logger = Logger.getLogger(CourseUnitEvaluationForm.class);
 
CourseUnitEvaluationView courseUnitEvaluationView = new CourseUnitEvaluationView();
 
long courseUnitId;
 
 
public CourseUnitEvaluationForm(CourseUnitEvaluationView courseUnitEvaluationView, CourseUnitView courseUnitView, long courseUnitId) {
this.courseUnitEvaluationView = courseUnitEvaluationView;
this.courseUnitView = courseUnitView;
this.courseUnitId = courseUnitId;
}
 
public CourseUnitEvaluationForm()
{
courseUnitEvaluationView.setCourseUnitEvaluation(DomainObjectFactory.createCourseUnitEvaluationImpl());
}
 
public CourseUnitEvaluationView getCourseUnitEvaluationView() {
return courseUnitEvaluationView;
}
 
public void setCourseUnitEvaluationView(CourseUnitEvaluationView courseUnitEvaluationView) {
this.courseUnitEvaluationView = courseUnitEvaluationView;
}
 
public CourseUnitView getCourseUnitView() {
return courseUnitView;
}
 
public void setCourseUnitView(CourseUnitView courseUnitView) {
this.courseUnitView = courseUnitView;
}
 
 
 
public long getCourseUnitId() {
return courseUnitId;
}
 
public void setCourseUnitId(long courseUnitId) {
this.courseUnitId = courseUnitId;
}
 
 
}
/impl/src/java/pt/estgp/estgweb/web/form/configuration/ConfigurationGradesForm.java
New file
0,0 → 1,60
package pt.estgp.estgweb.web.form.configuration;
 
import jomm.utils.AutoFillArrayList;
import pt.estgp.estgweb.domain.ConfigurationGradesEpocaAvaliacaoImpl;
import pt.estgp.estgweb.domain.ConfigurationGradesStatusEpocaImpl;
import pt.estgp.estgweb.domain.views.ConfigurationGradesView;
import pt.estgp.estgweb.web.form.ApplicationForm;
 
import java.util.List;
 
/**
* @author Jorge Machado
* @date 25/Jun/2008
* @see pt.estgp.estgweb.web.form.courses
*/
public class ConfigurationGradesForm extends ApplicationForm
{
 
private String dispatch;
private long id;
private ConfigurationGradesView configurationGrades;
 
 
public ConfigurationGradesForm()
{
 
}
 
public ConfigurationGradesView getConfigurationGrades() {
if(configurationGrades == null)
{
configurationGrades = new ConfigurationGradesView();
List o = new AutoFillArrayList<ConfigurationGradesEpocaAvaliacaoImpl>(ConfigurationGradesEpocaAvaliacaoImpl.class);
List o2 = new AutoFillArrayList<ConfigurationGradesStatusEpocaImpl>(ConfigurationGradesStatusEpocaImpl.class);
configurationGrades.setEpocasAvaliacao(o);
configurationGrades.setStatusEpocas(o2);
}
return configurationGrades;
}
 
public String getOp() {
return dispatch;
}
 
public void setOp(String dispatch) {
this.dispatch = dispatch;
}
 
public void setConfigurationGrades(ConfigurationGradesView configurationGrades) {
this.configurationGrades = configurationGrades;
}
 
public long getId() {
return id;
}
 
public void setId(long id) {
this.id = id;
}
}
/impl/src/java/pt/estgp/estgweb/web/form/announcements/MessagesForm.java
1,12 → 1,10
package pt.estgp.estgweb.web.form.announcements;
 
import pt.estgp.estgweb.web.form.commons.TeachersForm;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.views.CourseView;
import pt.estgp.estgweb.services.courseunits.DirectedCoordinatedCourses;
import pt.estgp.estgweb.services.courseunits.DirectedCoordinatedUnitsService;
import pt.estgp.estgweb.utils.DatesUtils;
import pt.estgp.estgweb.Globals;
import org.apache.struts.upload.FormFile;
import pt.estgp.estgweb.web.form.commons.TeachersForm;
 
import java.util.List;
 
18,7 → 16,7
public class MessagesForm extends TeachersForm {
 
 
private String importYear = DatesUtils.getImportYear();
private String importYear = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYearCreateTransaction();
 
private String fromRole;
private CourseView courseView;
/impl/src/java/pt/estgp/estgweb/web/controllers/courses/CoursesController.java
284,6 → 284,11
CourseForm cF = (CourseForm) form;
String importYear = cF.getImportYear();
long courseId = cF.getCourseId();
if(courseId <= 0)
{
addError(request,"courses.fill.course");
return mapping.findForward("load.courses.programs");
}
String semestre = cF.getSemestre();
String area = cF.getArea();
DirectedCoordinatedUnitsService.TeachersSituationEnum teachersSituationEnum = cF.getTeacherSituationEnum();
/impl/src/java/pt/estgp/estgweb/web/controllers/courseunits/CourseUnitsEvaluationController.java
New file
0,0 → 1,233
package pt.estgp.estgweb.web.controllers.courseunits;
 
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import pt.estgp.estgweb.domain.CourseUnitEvaluationImpl;
import pt.estgp.estgweb.domain.views.CourseUnitEvaluationView;
import pt.estgp.estgweb.domain.views.CourseUnitView;
import pt.estgp.estgweb.filters.exceptions.NotFoundException;
import pt.estgp.estgweb.web.form.courseunits.CourseUnitEvaluationForm;
import pt.estgp.estgweb.web.utils.RequestUtils;
import pt.utl.ist.berserk.logic.serviceManager.IServiceManager;
import pt.utl.ist.berserk.logic.serviceManager.ServiceManager;
import pt.utl.ist.berserk.logic.serviceManager.exceptions.FilterChainFailedException;
 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
 
/**
* @author Jorge Machado
* @author Fabio Velez
* @date 26/Fev/2008
* @time 18:01:54
* @see pt.estgp.estgweb.web
*/
public class CourseUnitsEvaluationController extends CourseUnitsController
{
private static final Logger logger = Logger.getLogger(CourseUnitsEvaluationController.class);
 
 
 
 
public ActionForward editEvaluation(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
try
{
CourseUnitEvaluationForm cUF = (CourseUnitEvaluationForm) form;
 
long id = cUF.getCourseUnitId();
if(id <= 0)
id = cUF.getCourseUnitView().getId();
 
 
CourseUnitView cV = loadCourseUnitViewAndCourse(id,true,false, mapping, request, response);
 
cUF.setCourseUnitView(cV);
request.setAttribute("CourseUnitView", cV);
CourseUnitEvaluationView cpv;
if(cV.getCourseUnit().getCourseUnitEvaluation() == null)
cpv = new CourseUnitEvaluationView(new CourseUnitEvaluationImpl());
else
cpv = new CourseUnitEvaluationView(cV.getCourseUnit().getCourseUnitEvaluation());
// request.setAttribute("CourseUnitProgramView", cpv);
 
 
cUF.setCourseUnitEvaluationView(cpv);
cUF.setCourseUnitView(cV);
return mapping.findForward("edit.evaluation");
}
catch (FilterChainFailedException e)
{
return mapping.findForward("error401");
}
catch (NotFoundException e)
{
return mapping.findForward("error404");
}
catch (Throwable e)
{
logger.error(e, e);
return mapping.findForward("error500");
}
}
 
public ActionForward saveEvaluation(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
try
{
CourseUnitEvaluationForm cUF = (CourseUnitEvaluationForm) form;
 
long id = cUF.getCourseUnitView().getId();
CourseUnitEvaluationView cuV = cUF.getCourseUnitEvaluationView();
 
IServiceManager sm = ServiceManager.getInstance();
Object[] args = new Object[]{cuV, id};
sm.execute(RequestUtils.getRequester(request, response), "SaveCourseUnitEvaluation", args);
CourseUnitView cV = loadCourseUnitView(id,true,false, mapping, request, response);
cUF.setCourseUnitView(cV);
request.setAttribute("CourseUnitView", cV);
addMessage(request,"courseunit.evaluation.success");
return mapping.findForward("load");
}
catch (FilterChainFailedException e)
{
return mapping.findForward("error401");
}
catch (NotFoundException e)
{
return mapping.findForward("error404");
}
catch (Throwable e)
{
logger.error(e, e);
return mapping.findForward("error500");
}
}
 
 
public ActionForward teacherCompleteEvaluation(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
try
{
CourseUnitEvaluationForm cUF = (CourseUnitEvaluationForm) form;
 
long id = cUF.getCourseUnitView().getId();
CourseUnitEvaluationView cuV = cUF.getCourseUnitEvaluationView();
cuV.setTeacherComplete(true);
 
IServiceManager sm = ServiceManager.getInstance();
Object[] args = new Object[]{cuV, id};
sm.execute(RequestUtils.getRequester(request, response), "SaveCourseUnitEvaluation", args);
CourseUnitView cV = loadCourseUnitView(id,true,false, mapping, request, response);
cUF.setCourseUnitView(cV);
request.setAttribute("CourseUnitView", cV);
addMessage(request,"courseunit.evaluation.success");
return mapping.findForward("load");
}
catch (FilterChainFailedException e)
{
return mapping.findForward("error401");
}
catch (NotFoundException e)
{
return mapping.findForward("error404");
}
catch (Throwable e)
{
logger.error(e, e);
return mapping.findForward("error500");
}
}
 
public ActionForward publishEvaluation(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
try
{
CourseUnitEvaluationForm cUF = (CourseUnitEvaluationForm) form;
 
long id = cUF.getCourseUnitView().getId();
CourseUnitEvaluationView cuV = cUF.getCourseUnitEvaluationView();
cuV.setFechar(true);
IServiceManager sm = ServiceManager.getInstance();
Object[] args = new Object[]{cuV, id};
sm.execute(RequestUtils.getRequester(request, response), "SaveCourseUnitEvaluation", args);
CourseUnitView cV = loadCourseUnitView(id,true,false, mapping, request, response);
cUF.setCourseUnitView(cV);
request.setAttribute("CourseUnitView", cV);
addMessage(request,"courseunit.evaluation.success");
return mapping.findForward("load");
}
catch (FilterChainFailedException e)
{
return mapping.findForward("error401");
}
catch (NotFoundException e)
{
return mapping.findForward("error404");
}
catch (Throwable e)
{
logger.error(e, e);
return mapping.findForward("error500");
}
}
 
 
 
public ActionForward openEvaluation(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
try
{
CourseUnitEvaluationForm cUF = (CourseUnitEvaluationForm) form;
 
long id = cUF.getCourseUnitView().getId();
IServiceManager sm = ServiceManager.getInstance();
Object[] args = new Object[]{id};
sm.execute(RequestUtils.getRequester(request, response), "OpenCourseUnitEvaluation", args);
CourseUnitView cV = loadCourseUnitView(id,true,false, mapping, request, response);
cUF.setCourseUnitView(cV);
request.setAttribute("CourseUnitView", cV);
addMessage(request,"courseunit.evaluation.success");
return mapping.findForward("load");
}
catch (FilterChainFailedException e)
{
return mapping.findForward("error401");
}
catch (NotFoundException e)
{
return mapping.findForward("error404");
}
catch (Throwable e)
{
logger.error(e, e);
return mapping.findForward("error500");
}
}
 
 
}
/impl/src/java/pt/estgp/estgweb/web/controllers/courseunits/CourseUnitsController.java
1,24 → 1,20
package pt.estgp.estgweb.web.controllers.courseunits;
 
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.*;
import org.apache.struts.upload.FormFile;
import org.hibernate.ObjectNotFoundException;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.CourseUnitProgram;
import pt.estgp.estgweb.domain.CourseUnitProgramImpl;
import pt.estgp.estgweb.domain.CourseUnitProgramPart2Impl;
import pt.estgp.estgweb.domain.views.*;
import pt.estgp.estgweb.domain.views.BlogView;
import pt.estgp.estgweb.domain.views.CourseUnitAssignementView;
import pt.estgp.estgweb.domain.views.CourseUnitView;
import pt.estgp.estgweb.domain.views.UserView;
import pt.estgp.estgweb.filters.exceptions.NotFoundException;
import pt.estgp.estgweb.web.controllers.ApplicationDispatchController;
import pt.estgp.estgweb.web.controllers.blogs.BlogsController;
import pt.estgp.estgweb.web.controllers.profile.ProfileController;
import pt.estgp.estgweb.web.exceptions.NoCookiesException;
import pt.estgp.estgweb.web.form.blogs.BlogForm;
import pt.estgp.estgweb.web.form.courseunits.CourseUnitProgramForm;
import pt.estgp.estgweb.web.form.courseunits.CourseUnitsForm;
import pt.estgp.estgweb.web.form.profile.ProfileForm;
import pt.estgp.estgweb.web.utils.RequestUtils;
194,6 → 190,74
}
}
 
 
public ActionForward loadCourseUnitWebSiteBySigesCodes(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Throwable, ServletException
{
try
{
CourseUnitsForm cUF = (CourseUnitsForm) form;
String unitCode = request.getParameter("unitCode");
String courseCode = request.getParameter("courseCode");
String semestre = request.getParameter("semestre");
 
 
IServiceManager sm = ServiceManager.getInstance();
String[] names = new String[]{};
Object[] args = new Object[]{unitCode,courseCode,semestre};
CourseUnitView cUV = (CourseUnitView) sm.execute(RequestUtils.getRequester(request, response), "LoadCourseUnitsBySigesCodesSemestreLastYear", args, names);
return loadCourseUnitAndForward(cUF,cUV.getId() ,true,false, mapping, request, response);
 
}
catch (FilterChainFailedException e)
{
return mapping.findForward("error401");
}
catch (Throwable e)
{
logger.error(e, e);
throw e;
}
}
 
 
public ActionForward loadCourseUnitProgramBySigesCodes(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Throwable, ServletException
{
try
{
String unitCode = request.getParameter("unitCode");
String courseCode = request.getParameter("courseCode");
String semestre = request.getParameter("semestre");
 
 
IServiceManager sm = ServiceManager.getInstance();
String[] names = new String[]{};
Object[] args = new Object[]{unitCode,courseCode,semestre};
CourseUnitView cUV = (CourseUnitView) sm.execute(RequestUtils.getRequester(request, response), "LoadCourseUnitsBySigesCodesSemestreLastYear", args, names);
 
ActionRedirect forward = new ActionRedirect();
forward.setPath("/repositoryStream/" + cUV.getProgramStreamId());
return forward;
 
}
catch (FilterChainFailedException e)
{
return mapping.findForward("error401");
}
catch (Throwable e)
{
logger.error(e, e);
throw e;
}
}
 
public ActionForward loadStudents(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
229,7 → 293,42
}
 
 
public ActionForward loadDossier(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
try
{
CourseUnitsForm cUF = (CourseUnitsForm) form;
long id;
if(request.getParameter("id")!=null)
id = Long.parseLong(request.getParameter("id"));
else
id = cUF.getCourseUnitView().getId();
CourseUnitView cV = loadCourseUnitView(id,false,false, mapping, request, response);
cUF.setCourseUnitView(cV);
request.setAttribute("CourseUnitView", cV);
return mapping.findForward("load.dossier");
}
catch (FilterChainFailedException e)
{
return mapping.findForward("error401");
}
catch (NotFoundException e)
{
return mapping.findForward("error404");
}
catch (Throwable e)
{
logger.error(e, e);
return mapping.findForward("error500");
}
}
 
 
 
public ActionForward loadTeacher(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
780,6 → 879,15
{
return loadCourseUnitIntranet(Globals.INTRANET_PRESENCES,"courseLayoutIOnlinePresences",mapping,form,request,response);
}
public ActionForward loadDtp(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Throwable, ServletException
{
return loadCourseUnitIntranet(Globals.INTRANET_DTP,"courseLayoutIOnlineDtp",mapping,form,request,response);
}
 
 
 
/impl/src/java/pt/estgp/estgweb/web/controllers/processes/ProcessEventController.java
247,8 → 247,57
}
}
 
public ActionForward deleteLastProcessEvent(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Throwable, ServletException
{
try
{
 
ProcessEventForm f = (ProcessEventForm)form;
HibernateUtils.getCurrentSession().beginTransaction();
Process process = DaoFactory.getProcessDaoImpl().load(Long.parseLong(request.getParameter("id")));
 
User nowUser = UserSessionProxy.loadUserSessionFromRequest(request).getUser();
 
ProcessEvent pLastEvent = process.getLastEvent();
//only Last Event
if(!((ProcessImpl)pLastEvent.getProcess()).canRemoveLastEvent(nowUser))
return mapping.findForward("error401");
 
Date now = new Date();
 
logger.warn("Deleting event: " + pLastEvent.toString());
 
pLastEvent.getProcess().setLastEvent(pLastEvent.getPreviousEvent());
pLastEvent.getPreviousEvent().setNextEvent(null);
pLastEvent.getProcess().getEvents().remove(pLastEvent);
pLastEvent.setProcess(null);
pLastEvent.getProcess().setLastChangeDate(now);
pLastEvent.getProcess().setNowState(ProcessImpl.ProcessState.TRANSITION.name());
pLastEvent.setNowState(ProcessEventImpl.ProcessEventState.ACCEPTED.name());
pLastEvent.setCloseDate(null);
pLastEvent.setDispatchedDate(null);
DaoFactory.getProcessEventDaoImpl().delete(pLastEvent);
 
logger.warn("DELETED event: " + pLastEvent.toString());
//importPossibleFile(request, f, p, now);
 
HibernateUtils.getCurrentSession().getTransaction().commit();
request.setAttribute("processId",f.getProcessEvent().getProcess().getId());
return mapping.getInputForward();
}
catch (Throwable e)
{
logger.error(e, e);
return mapping.findForward("error501");
}
}
 
 
 
public ActionForward reopenProcessEventPerson(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
/impl/src/java/pt/estgp/estgweb/web/controllers/configuration/GradesController.java
New file
0,0 → 1,103
package pt.estgp.estgweb.web.controllers.configuration;
 
import jomm.dao.impl.AbstractDao;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import pt.estgp.estgweb.domain.ConfigurationGradesEpocaAvaliacao;
import pt.estgp.estgweb.domain.ConfigurationGradesStatusEpoca;
import pt.estgp.estgweb.domain.DomainObjectFactory;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.web.controllers.ApplicationDispatchController;
import pt.estgp.estgweb.web.form.configuration.ConfigurationGradesForm;
 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
/**
* @author Jorge Machado
* @date 26/Fev/2008
* @time 18:01:54
* @see pt.estgp.estgweb.web
*/
public class GradesController extends ApplicationDispatchController
{
 
private static final Logger logger = Logger.getLogger(GradesController.class);
 
 
 
public ActionForward saveGrades(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
 
return mapping.findForward("save");
}
 
public ActionForward addEpocaAvaliacao(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
 
 
AbstractDao.getCurrentSession().beginTransaction();
ConfigurationGradesEpocaAvaliacao epoca = DomainObjectFactory.createConfigurationGradesEpocaAvaliacaoImpl();
DaoFactory.getConfigurationDaoImpl().load().getConfigurationGrades().getEpocasAvaliacao().add(epoca);
DaoFactory.getConfigurationGradesEpocaAvaliacaoDaoImpl().save(epoca);
AbstractDao.getCurrentSession().getTransaction().commit();
return mapping.findForward("grades");
}
 
public ActionForward addSatusEpoca(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
 
 
AbstractDao.getCurrentSession().beginTransaction();
ConfigurationGradesStatusEpoca status = DomainObjectFactory.createConfigurationGradesStatusEpocaImpl();
DaoFactory.getConfigurationDaoImpl().load().getConfigurationGrades().getStatusEpoca().add(status);
DaoFactory.getConfigurationGradesStatusEpocaDaoImpl().save(status);
AbstractDao.getCurrentSession().getTransaction().commit();
return mapping.findForward("grades");
}
 
public ActionForward deleteEpocaAvaliacao(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
 
ConfigurationGradesForm f = (ConfigurationGradesForm) form;
AbstractDao.getCurrentSession().beginTransaction();
DaoFactory.getConfigurationGradesEpocaAvaliacaoDaoImpl().delete(f.getId());
AbstractDao.getCurrentSession().getTransaction().commit();
return mapping.findForward("grades");
}
 
public ActionForward deleteStatusEpoca(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException
{
 
ConfigurationGradesForm f = (ConfigurationGradesForm) form;
 
AbstractDao.getCurrentSession().beginTransaction();
DaoFactory.getConfigurationGradesStatusEpocaDaoImpl().delete(f.getId());
AbstractDao.getCurrentSession().getTransaction().commit();
return mapping.findForward("grades");
}
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/web/FTPFileProxy.java
New file
0,0 → 1,154
package pt.estgp.estgweb.web;
 
import jomm.utils.DesUtils;
import jomm.utils.MimeTypeGuesser;
import jomm.utils.StreamsUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.UserSession;
import pt.estgp.estgweb.domain.UserSessionImpl;
import pt.estgp.estgweb.services.ftpservices.FtpService;
 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
 
/**
* @author Jorge Machado
* @date 26/Fev/2008
* @time 12:46:16
* @see pt.estgp.estgweb.web
*/
public class FTPFileProxy extends HttpServlet {
 
/** sss requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
private static final Logger logger = Logger.getLogger(FTPFileProxy.class);
 
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String objectRequired = request.getPathInfo();
objectRequired = objectRequired.substring(1);
String server = objectRequired.substring(0,objectRequired.indexOf("/"));
String path = objectRequired.substring(objectRequired.indexOf("/"));
 
 
 
UserSession userSession = UserSessionProxy.loadUserSessionFromRequest(request);
String username = userSession != null ? userSession.getUsername() : "UNKNOWN";
String passwordUserInSession = (String) ((UserSessionImpl)userSession).get(FtpService.FTP_PASSWORD);
logger.info("server:" + server);
logger.info("path:" + path);
if(username == null || passwordUserInSession == null)
{
response.sendError(401);
return;
}
passwordUserInSession = DesUtils.getInstance().decrypt(passwordUserInSession);
if(path != null)
{
server = pt.estgp.estgweb.utils.ConfigProperties.getProperty("server." + server);
String remoteName = path.substring(path.lastIndexOf("/")+1);
String remoteDirectory = path.substring(0,path.lastIndexOf("/"));
FtpServer ftpServer = FtpServer.getNewServer(server,username,passwordUserInSession);
FTPClient client = null;
try
{
client = ftpServer.getClient();
if(client == null)
{
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP");
response.sendError(408);
return;
}
 
 
client.changeWorkingDirectory(remoteDirectory);
 
 
FTPFile[] files = client.listFiles();
boolean found = false;
for (FTPFile file : files) {
if (!file.isFile() || !file.getName().equals(remoteName)) {
continue;
}
found = true;
client.setFileType(FTP.BINARY_FILE_TYPE);
InputStream stream = client.retrieveFileStream(file.getName());
response.setContentLength((int)file.getSize());
response.setContentType(MimeTypeGuesser.getInstance().guessMimeType(file.getName()));
response.setHeader("Content-disposition","inline; filename=" + file.getName());
StreamsUtils.inputStream2OutputStream(stream, response.getOutputStream());
stream.close();
 
}
logger.info("Quiting Proxy");
client.quit();
client.disconnect();
logger.info("Finnish Proxy");
if(!found)
{
response.sendError(404);
return;
}
 
}
catch(IOException e)
{
if(client != null && client.isConnected())
{
client.quit();
client.disconnect();
}
response.sendError(404);
return;
}
finally {
if(client != null && client.isConnected())
{
client.quit();
client.disconnect();
}
}
logger.info("Closing");
}
 
}
 
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
 
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
 
/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Proxy Servlet to get pages form static web page servers";
}
// </editor-fold>
 
 
}
Property changes:
Added: svn:executable
+ *
/impl/src/java/pt/estgp/estgweb/web/ImageStream.java
57,9 → 57,10
out.close();
 
}
catch (Exception e1)
catch (Throwable e1)
{
e1.printStackTrace();
logger.error(e1 );
response.sendError(404);
}
 
AbstractDao.getCurrentSession().getTransaction().commit();
/impl/src/java/pt/estgp/estgweb/examples/DBInit.java
39,6 → 39,9
announcement.setOwner(user);
announcement.setTitle("Titulo de Teste");
announcement.setText("Anuncio de Teste");
announcement.setPopupheightpx(0);
announcement.setPopupwidthpx(0);
announcement.setPosition(0);
announcement.setStatus(true);
announcement.setType(Globals.ANNOUNCEMENT_TYPE_TOP_FLASH_NEWS);
announcement.setTargetRoles("all");
51,6 → 54,9
announcement2.setText("Anuncio de Teste");
announcement2.setStatus(true);
announcement2.setType(Globals.ANNOUNCEMENT_TYPE_BOTTOM_FLASH_NEWS);
announcement2.setPopupheightpx(0);
announcement2.setPopupwidthpx(0);
announcement2.setPosition(0);
DaoFactory.getAnnouncementDaoImpl().save(announcement2);
 
AnnouncementImpl announcement3 = DomainObjectFactory.createAnnouncementImpl();
60,7 → 66,13
announcement3.setTargetRoles("all");
announcement3.setType(Globals.ANNOUNCEMENT_TYPE_NEWS);
announcement3.setStatus(true);
announcement3.setPopupheightpx(0);
announcement3.setPopupwidthpx(0);
announcement3.setPosition(0);
DaoFactory.getAnnouncementDaoImpl().save(announcement3);
 
 
 
AbstractDao.getCurrentSession().getTransaction().commit();
}
}
/impl/src/doc/Modelo_de_Dados_Siges11.zip
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+ application/octet-stream
/impl/src/doc/estgweb.eap
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/impl/src/doc/mysql/ConfigurarMysql.txt
New file
0,0 → 1,11
 
 
my.conf
 
[mysqld]
default-storage-engine = innodb
transaction-isolation = READ-COMMITTED
 
restart mysql
 
restart no mac /usr/local/mysql/support-files/mysql.server restart
/impl/src/doc/baco.ppt
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream