Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 999 → Rev 1017

/impl/importRoutines.xml
7,20 → 7,22
 
 
 
<target name="courses">
<java classname="pt.estgp.estgweb.services.sigesimports.ImportCourseService" classpath="${build.dir.classes}" classpathref="pathToToolsLib">
<!--<arg value="201314"/>-->
<!--<arg value="201415"/>-->
<!-- CLONE PROGRAMS -->
<target name="sincronizeunits">
<java classname="pt.estgp.estgweb.services.sigesimports.SincronizeLastYearCourseUnitProgramsService" classpath="${build.dir.classes}" classpathref="pathToToolsLib">
<arg value="201516"/>
<arg value="true"/> <!-- Clone Only News -->
<arg value="false"/> <!-- Generate all pdfs -->
</java>
</target>
<target name="sincronizeunits">
<java classname="pt.estgp.estgweb.services.sigesimports.SincronizeLastYearCourseUnitProgramsService" classpath="${build.dir.classes}" classpathref="pathToToolsLib">
</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"/>
<arg value="true"/>
<arg value="false"/>
</java>
</target>
<target name="teachers">
28,7 → 30,6
<!--<arg value="201314"/>-->
<!--<arg value="201415"/>-->
<arg value="201516"/>
 
</java>
</target>
<target name="students">
36,17 → 37,33
<!--<arg value="201314"/>-->
<!--<arg value="201415"/>-->
<arg value="201516"/>
</java>
</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.ImportSumariesJson" 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>
/impl/conf/WEB-INF/struts/struts-default.xml
25,6 → 25,7
<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-->
48,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"/>
 
/impl/conf/WEB-INF/struts/tiles-default.xml
424,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/web.xml
387,6 → 387,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/app.properties
16,16 → 16,23
 
email.local.suffix=estgp.pt
email.server=smtp.gmail.com
email.user=
email.password=
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=993
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=
#########################
##
########################
104,6 → 111,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
228,7 → 240,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
448,9 → 460,9
siges.degree.4=M
siges.degree.8=C
 
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.
/impl/src/java/pt/estgp/estgweb/Globals.java
1,6 → 1,7
package pt.estgp.estgweb;
 
import pt.estgp.estgweb.domain.DirectoryImpl;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.directories.DirectoryService;
import pt.estgp.estgweb.utils.ConfigProperties;
 
79,6 → 80,9
}
 
 
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
159,9 → 163,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");
 
/impl/src/java/pt/estgp/estgweb/services/courseunits/SaveCourseUnitProgram.java
171,6 → 171,13
{
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);
 
181,7 → 188,10
}
else
{
client.storeFile(cu.getCode() + "_" + cu.getNormalizedName() + "_v" + sdf.format(versionDate) + ".pdf",new FileInputStream(pdfPath));
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)
{
403,6 → 413,12
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)
{
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP");
return;
}
while (cuIter.hasNext()) {
CourseUnit next = cuIter.next();
 
/impl/src/java/pt/estgp/estgweb/services/courseunits/SaveCourseUnitEvaluation.java
87,10 → 87,17
if(cupv.isFechar())
{
evaluation.setClosed(true);
evaluation.setTeacherComplete(true);
}
else if(cupv.isTeacherComplete())
{
evaluation.setTeacherComplete(true);
}
else
{
evaluation.setClosed(false);
//TODO TIRAR ISTO NO PROXIMO ANO
evaluation.setTeacherComplete(true);
}
 
createPdf(evaluation,c,usession,errors);
124,6 → 131,41
return cupv;
}
 
//TODO TEACHER COMPLETE OPEN
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 {
 
 
208,6 → 250,12
{
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);
 
/impl/src/java/pt/estgp/estgweb/services/courseunits/CreateCourseUnitAdminService.java
1,7 → 1,6
package pt.estgp.estgweb.services.courseunits;
 
import org.apache.log4j.Logger;
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.CourseUnit;
import pt.estgp.estgweb.domain.DomainObjectFactory;
import pt.estgp.estgweb.domain.UserSession;
49,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/sigesimports/ImportGradesService.java
22,6 → 22,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.*;
44,15 → 45,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();
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 → 62,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)
/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());
break;
}
catch(Throwable t)
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportStudentsService.java
70,15 → 70,16
logger.info(msgS);
 
DefaultLogMessages logMessages = new DefaultLogMessages();
logMessages.addMessage(new DefaultLogMessage("import.students", LogMessageTypeEnum.INFO, "instituicao " + Globals.SIGES_INSTITUTION_CODE));
logMessages.addMessage(new DefaultLogMessage("import.students", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
 
try
{
SiGesWEB service;
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
try
{
serviceLogInfo("STARTING WEB SERVICE AT " + Globals.SIGES_WEBSERVICE_WSDL);
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)
{
88,7 → 89,7
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;
 
103,7 → 104,7
AbstractDao.getCurrentSession().beginTransaction();
}
 
Aluno alunoSiges = service.getSiGesWEBSoap().getAlunoInscrito(c, Globals.SIGES_INSTITUTION_CODE, year);
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;
/impl/src/java/pt/estgp/estgweb/services/sigesimports/LoadSumariesToPDF.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;
66,7 → 67,7
}
AbstractDao.getCurrentSession().beginTransaction();
CourseUnit c = DaoFactory.getCourseUnitDaoImpl().get(courseUnitId);
ArrayOfAula arrayOfAulas = service.getSiGesWEBSoap().getAulas(Globals.SIGES_INSTITUTION_CODE, c.getImportYear(),c.getCode(),c.getSemestre());
ArrayOfAula arrayOfAulas = service.getSiGesWEBSoap().getAulas(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), c.getImportYear(),c.getCode(),c.getSemestre());
 
if(arrayOfAulas != null && arrayOfAulas.getAula() != null)
{
99,15 → 100,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)
{
137,7 → 139,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());
break;
}
catch(Throwable t)
/impl/src/java/pt/estgp/estgweb/services/sigesimports/SincronizeLastYearCourseUnitProgramsService.java
3,7 → 3,6
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;
77,7 → 76,7
DefaultLogMessages logMessages = new DefaultLogMessages();
try
{
logMessages.addMessage(new DefaultLogMessage("courseunitprograms.sincronization", LogMessageTypeEnum.INFO, "instituicao " + Globals.SIGES_INSTITUTION_CODE));
logMessages.addMessage(new DefaultLogMessage("courseunitprograms.sincronization", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
serviceLogInfo(logMessages.getLastMessage());
 
int i = 0;
134,9 → 133,14
updated++;
CourseUnitProgramImpl cProgram = (CourseUnitProgramImpl) DaoFactory.getCourseUnitProgramDaoImpl().narrow(cu.getCourseUnitProgram());
cProgram.cloneFrom(cuOld.getCourseUnitProgram());
//List<String> errors = new ArrayList<String>();
List<String> errors = new ArrayList<String>();
clonados.add(cu.getCode());
//todo JOBS service.createPdf(cu,errors);
service.createPdf(cu,errors);
if(errors.size() > 0)
{
for(String error:errors)
serviceLogError(error);
}
cu.setValidProgram(validate);
}
else
171,9 → 175,9
serviceLogInfo("Ficha nao alterada. razao: cloneOnlyNews=true");
if(generateAllPdfs)
{
//List<String> errors = new ArrayList<String>();
/*todo JOBS if(cu.getCourseUnitProgram() != n ull)
service.createPdf(cu,errors);*/
List<String> errors = new ArrayList<String>();
if(cu.getCourseUnitProgram() != null)
service.createPdf(cu,errors);
}
}
 
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportTeachersService.java
73,15 → 73,16
logger.info(msgS);
 
DefaultLogMessages logMessages = new DefaultLogMessages();
logMessages.addMessage(new DefaultLogMessage("import.teachers", LogMessageTypeEnum.INFO, "instituicao " + Globals.SIGES_INSTITUTION_CODE));
logMessages.addMessage(new DefaultLogMessage("import.teachers", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
 
try
{
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
SiGesWEB service;
try
{
serviceLogInfo("STARTING WEB SERVICE AT " + Globals.SIGES_WEBSERVICE_WSDL);
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)
{
90,7 → 91,7
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;
107,7 → 108,7
}
 
 
Docente d = service.getSiGesWEBSoap().getDocente(c, Globals.SIGES_INSTITUTION_CODE, year);
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());
159,7 → 160,7
AbstractDao.getCurrentSession().beginTransaction();
logger.error(e,e);
serviceLogError("Rolling back will lost previous updates: " + e.toString(),e);
sendNotificationAdmin("Erro de importacao de docenes",e.toString());
sendNotificationAdmin("Erro de importacao de docentes",e.toString());
}
catch(HibernateException e)
{
211,7 → 212,7
private void sendNotificationAdmin(String subject, String cause)
{
//todo JOB
/*
 
List<String> emails = ConfigProperties.getListValues("admin.email");
for(String email:emails)
{
226,7 → 227,7
} catch (ServiceException e) {
e.printStackTrace();
}
*/
 
}
 
/**
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportCourseService.java
25,6 → 25,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.*;
52,7 → 53,7
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>();
65,10 → 66,11
* Build Course Units Maps
*/
SiGesWEB service;
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
try
{
serviceLogInfo("STARTING WEB SERVICE AT " + Globals.SIGES_WEBSERVICE_WSDL);
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)
{
135,14 → 137,8
logger.error(e,e);
logMessages.addMessage(new DefaultLogMessage("import.error",e.toString(), "see log for details", LogMessageTypeEnum.ERROR));
serviceLogError(logMessages.getLastMessage(), e);
List<String> emails = new ArrayList<String>();
emails.add(ConfigProperties.getProperty("admin.email"));
List<String> arguments = new ArrayList<String>();
String cause = e.getCause() == null ? "" : e.getCause().toString();
arguments.add((e.toString() + "\n" + cause).replace("\n","<br/>"));
serviceLogWarn("Sending email to " + ConfigProperties.getProperty("admin.email"));
Email email = new Email("Erro de importacao 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");
151,6 → 147,32
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);
try {
new SendEmailService().sendEmail(email);
} catch (ServiceException e) {
e.printStackTrace();
}
 
}
 
private void importUnitsSemestre(SiGesWEB service,
String semestre,
String year,
162,7 → 184,7
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)
{
204,7 → 226,7
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());
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportSumariesJson.java
39,6 → 39,7
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;
71,7 → 72,7
logger.info(msgS);
 
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()));
serviceLogInfo(logMessages.getLastMessage());
 
 
85,10 → 86,11
{
 
SiGesWEB service;
String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
try
{
serviceLogInfo("STARTING WEB SERVICE AT " + Globals.SIGES_WEBSERVICE_WSDL);
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 (Throwable e)
{
130,7 → 132,7
//comentario de teste
try
{
arrayOfAulas = service.getSiGesWEBSoap().getAulas(Globals.SIGES_INSTITUTION_CODE, year,c.getCode(),semestre);
arrayOfAulas = service.getSiGesWEBSoap().getAulas(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year,c.getCode(),semestre);
break;
}
catch(Throwable t)
288,13 → 290,21
return path;
}
 
private static void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,String pdfPath,FTPClient client) throws IOException, TransformerException, FOPException {
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);
 
306,8 → 316,12
}
else
{
client.storeFile(((CourseUnitImpl)cu).getSummariosFileNameIntranet(),new FileInputStream(pdfPath));
 
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();
/impl/src/java/pt/estgp/estgweb/services/ftpservices/FtpService.java
91,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/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/domain/CourseUnitProgramImpl.java
5,7 → 5,6
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;
 
624,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/CourseUnitSummaryImpl.java
76,24 → 76,37
}
 
 
public void updateWithJson(JSONObject json)
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"));
 
try {
setDataAula(fromDataAulaDesc(json.getString("dataAula")));
setTipoAula(json.getString("tipoAula"));
setCodigoAula(json.getString("codigoAula"));
setCodigoSumario(json.getString("codigoAula"));
setCodigoSalaAula(json.getString("codigoSalaAula"));
setAlunosPresentes(json.getInt("alunosPresentes"));
setNumeroAula(json.getInt("numeroAula"));
setTitulo(json.getString("titulo"));
setDescricao(json.getString("descricao"));
setcEstado(json.getString("cEstado"));
setNumeroHoras(json.getString("numeroHoras"));
return json.has("titulo") || json.has("descricao");
} catch (JSONException e) {
logger.error(e,e);
}
return false;
}
 
public String toString() {
/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
27,6 → 28,7
private String codigoAula;
private String codigoSumario;
private String codigoSala;
private Date originalDate;
 
 
public CourseUnitSummaryView() {
44,6 → 46,7
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();
51,6 → 54,7
this.codigoAula = summary.getCodigoAula();
this.codigoSumario = summary.getCodigoSumario();
this.codigoSala = summary.getCodigoSalaAula();
 
}
 
// public void persistViewInObject(Announcement announcement)
94,6 → 98,10
return date;
}
 
public Date getOriginalDate() {
return originalDate;
}
 
public int getStudents()
{
return students;
/impl/src/java/pt/estgp/estgweb/domain/views/CourseUnitEvaluationView.java
18,6 → 18,7
 
private CourseUnitEvaluation courseUnitEvaluation;
private boolean fechar = false;
private boolean teacherComplete = false;
 
public Class getReferenceClass()
{
74,4 → 75,12
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/CourseUnitView.java
482,10 → 482,12
* @return sumaries or null if there are no summaries in Json
*/
 
int lateSummaries = 0;
 
public List<CourseUnitSummaryView> getSummariesFromJson() {
public synchronized List<CourseUnitSummaryView> getSummariesFromJson() {
if(summariesFromJson != null)
return summariesFromJson;
lateSummaries = 0;
summariesFromJson = new ArrayList<CourseUnitSummaryView>();
if(summariesJson != null && summariesJson.length() > 0)
{
496,9 → 498,20
{
JSONObject summary = summaries.getJSONObject(i);
CourseUnitSummaryImpl sum = DomainObjectFactory.createCourseUnitSummaryImpl();
sum.updateWithJson(summary);
CourseUnitSummaryView view = new CourseUnitSummaryView(sum);
summariesFromJson.add(view);
 
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++;
}
}
}
} catch (JSONException e) {
logger.error(e,e);
506,10 → 519,11
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;
else if(courseUnitSummaryView.getNumber() > courseUnitSummaryView2.getNumber())
return -1;
return 0;
}
});
518,6 → 532,13
return null;
}
 
public int getLateSummaries()
{
getSummariesFromJson();
return lateSummaries;
 
}
 
public void setSummariesJson(String summariesJson) {
this.summariesJson = summariesJson;
}
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/ConfigurationDaoImpl.java
1,8 → 1,10
package pt.estgp.estgweb.domain.dao.impl;
 
import pt.estgp.estgweb.Globals;
import pt.estgp.estgweb.domain.Configuration;
import pt.estgp.estgweb.domain.ConfigurationImpl;
 
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
 
29,7 → 31,10
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);
return configuration;
}
94,5 → 99,131
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();
}
 
public int getNationalInstitutionCodeCreateTransaction()
{
getCurrentSession().beginTransaction();
int code = getNationalInstitutionCode();
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/CourseUnitDaoImpl.java
495,13 → 495,17
 
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(not(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())))
.add(ge("importYear", "201415"))
.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();
}
 
528,12 → 532,18
 
public List<CourseUnit> loadMissingEvaluation(long courseId)
{
if(DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear()==null)
return new ArrayList<CourseUnit>();
 
return createCriteria()
.createAlias("course", "c")
.add(eq("c.id", courseId))
.add(not(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())))
.add(ge("importYear", "201415"))
.add(isNull("courseUnitEvaluation"))
.add(eq("importYear", DaoFactory.getConfigurationDaoImpl().getCourseUnitEvaluationActiveYear()))
//.add(not(eq("importYear", DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear())))
//.add(ge("importYear", "201415" ))
//.add(isNull("courseUnitEvaluation"))
//todo novo testar
.add(or(isNull("courseUnitEvaluation"),(eq("courseUnitEvaluation.teacherComplete", false))))
.list();
}
 
/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
171,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);
}
211,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
{
 
225,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");
 
380,6 → 388,7
throw (NotAuthorizedException)e;
logger.error(e, e);
}
return true;
}
 
 
662,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/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,41
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);
160,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
157,6 → 157,14
}
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))
{
throw new NotAuthorizedException("nao pode aceder a esta area");
/impl/src/java/pt/estgp/estgweb/web/FTPFileProxy.java
63,7 → 63,15
try
{
client = ftpServer.getClient();
if(client == null)
{
logger.warn("###################");
logger.warn("################### > CANT CONNECT FTP");
response.sendError(408);
return;
}
 
 
client.changeWorkingDirectory(remoteDirectory);
 
 
/impl/src/updates/version/release2015-11.txt
45,3 → 45,32
- todo tirar os todo job dos envios de emails e sends to ionline
 
- todo Configurações possiveis de ir para BD
 
 
 
- todo relembrar
AVALIACAO CURRICULAR
 
- ANO DE AVALIACAO CURRICULAR ATIVO
- FALTA METER OS IF NAS PAGINAS DE EDIÇAO PARA nao deixar ng mecher se o ano nao estiver ativo
- falta testar os DAO par as queries que mudaram para uso da variavel ano ativo
- Falta actualizar base de dados com o campo novo do ATIVO
- Falta meter a amarelo os relatorios do Ano Activo e meter qq coisa como so consulta nos nao ativos
- Falta meter IF's na home para não aparecer nada de trabalho relacionado com o s lembreter dos programas
 
-FALTA o SEMESTRE ACTIVO na avaliação que deverá ter TODOS, S1, S2, A, S1 A ou S2 A
 
 
- campo teacherComplete default TRUE não incfluencia as queries porque estará sempre a true e nunca e metido a false
a menos que seja a pedido especifico do DOCENTE frase no JSP CANCELAR ENTREGA MAS PARA JA BOTAO DESAPARECE e depois volta a ser aberto
-query de por validar obriga teacherComplete a ser true no CourseUnitDao
loadMissingEvaluationValidateGivenCourse
e na outra query loadMissingEvaluation
de não feitos passou a ser or NULL or teacherComplete = false neste momento falta testar o metodo onde a query hibernte
tem o seguinte:
.add(or(isNull("courseUnitEvaluation"),(eq("courseUnitEvaluation.teacherComplete", false))))
 
 
meter ftp server ionline configurável
 
ver o que fazer com o POP se vai ou nao ao gmail
/impl/src/hbm/pt/estgp/estgweb/domain/CourseUnit.hbm.xml
246,6 → 246,10
<timestamp source="db" name="updateDate" unsaved-value="null"/>
<property name="saveDate" type="timestamp"/>
<property name="closed" type="boolean"/>
<!-- todo update aos do ano anterior para meter todos os evaluations salvos com teacherComplete = true -->
<property name="teacherComplete" type="boolean">
<column name="teacherComplete" default="true"/>
</property>
<property name="numAlunosInscritos" type="text"/>
<property name="numAlunosSemElementosAvaliacao" type="integer"/>
 
/impl/src/hbm/pt/estgp/estgweb/domain/Configuration.hbm.xml
14,8 → 14,22
<timestamp source="db" name="updateDate" unsaved-value="null"/>
<property name="saveDate" type="timestamp"/>
<property name="interfaceImportYear" type="string"/>
 
<!-- IMPORTS CONFIGS -->
<property name="importsDefaultImportYear" type="string"/>
<property name="sigesWebServicesWsdl" type="string"/>
<property name="sigesWebServicesWsdl" type="string">
<column name="sigesWebServicesWsdl" default="http://172.20.100.5:8080/SigesWeb/SiGesWEB.asmx?wsdl"/>
</property>
<property name="sigesInstitutionCode" type="integer">
<column name="sigesInstitutionCode" default="1"/>
</property>
<property name="nationalInstitutionCode" type="integer">
<column name="nationalInstitutionCode" default="3122"/>
</property>
 
<!--CourseUnitEvaluation formatImportYear-->
<property name="courseUnitEvaluationActiveYear" type="string"/>
 
<subclass name="pt.estgp.estgweb.domain.ConfigurationImpl" discriminator-value="ConfigurationImpl"/>
</class>
</hibernate-mapping>
/impl/src/web/errors/408.jsp
New file
0,0 → 1,13
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%
response.sendError(404);
%>
<h3 class="statusWARNING"><bean:message key="error.404"/></h3>
<p><bean:message key="error.408.explain"/></p>
 
<p><bean:message key="admin.contact"/> ci [AT] estgp [DOT] pt</p>
Property changes:
Added: svn:executable
+ *
/impl/src/web/user/courseunits/courseunit.jsp
262,7 → 262,16
</div>
<div class="seccao">
<h2><bean:message key="courseunit.summaries"/></h2>
<p><a href="<%=request.getContextPath()%>/ftpProxyStream/ionline${CourseUnitView.sumariosPathFileIntranet}">Descarregar PDF</a></p>
<logic:notEmpty name="CourseUnitView" property="summariesFromJson">
<p><a href="<%=request.getContextPath()%>/ftpProxyStream/ionline${CourseUnitView.sumariosPathFileIntranet}">Descarregar PDF</a></p>
<logic:greaterThan value="0" name="CourseUnitView" property="lateSummaries">
<p style="background-color: yellow">Tem <bean:write name="CourseUnitView" property="lateSummaries"/>
<logic:equal name="CourseUnitView" property="lateSummaries" value="1">Sumário</logic:equal>
<logic:greaterThan name="CourseUnitView" property="lateSummaries" value="1">Sumários</logic:greaterThan>
por preencher.
<a target="_blank" href="http://netpa.ipportalegre.pt">Aceda ao NETPA para regularizar</a></p>
</logic:greaterThan>
</logic:notEmpty>
 
 
<logic:notEmpty name="CourseUnitView" property="summariesFromJson">
/impl/build-web-services.xml
14,48 → 14,48
<target name="ws.generate-siges-client" depends="initDirs">
<copy file="${ws.client.binding.dir}/${ws.siges.binding.file}" todir="${build.dir.ws}" overwrite="true"/>
<replace file="${build.dir.ws}/${ws.siges.binding.file}" encoding="UTF-8">
<replacefilter token="@wsdl.client@" value="${ws.siges.wsdl}"/>
<replacefilter token="@target.namespace@" value="${ws.siges.target.namespace}"/>
<replacefilter token="@ws.package@" value="${ws.siges.package}"/>
</replace>
<wsimport
debug="${ws.debug}"
verbose="${ws.verbose}"
keep="${ws.keep}"
extension="${ws.extension}"
destdir="${gen.dir.java}"
wsdl="${ws.siges.wsdl}">
<binding dir="${build.dir.ws}" includes="${ws.client.binding.file}"/>
</wsimport>
<delete>
<fileset dir="${gen.dir.java}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<replacefilter token="@wsdl.client@" value="${ws.siges.wsdl}"/>
<replacefilter token="@target.namespace@" value="${ws.siges.target.namespace}"/>
<replacefilter token="@ws.package@" value="${ws.siges.package}"/>
</replace>
<wsimport
debug="${ws.debug}"
verbose="${ws.verbose}"
keep="${ws.keep}"
extension="${ws.extension}"
destdir="${gen.dir.java}"
wsdl="${ws.siges.wsdl}">
<binding dir="${build.dir.ws}" includes="${ws.client.binding.file}"/>
</wsimport>
<delete>
<fileset dir="${gen.dir.java}">
<include name="**/*.class"/>
</fileset>
</delete>
</target>
 
<!-- <target name="ws.generate-google-client">
<property name="config_target" location="${ws.conf.dir}"/>
<copy file="${ws.conf.dir}/GoogleSearch-config.xml" tofile="${build.dir.ws}/GoogleSearch-config.xml" filtering="on" encoding="UTF-8" overwrite="true">
<filterset>
<filter token="CONFIG_ABSOLUTE_PATH" value="${config_target}"/>
<filter token="package" value="${ws.google.package}"/>
</filterset>
</copy>
<wscompile
verbose="true"
debug="true"
xPrintStackTrace="true"
xSerializable="true"
optimize="true"
fork="true"
keep="true"
client="true"
import="false"
base="${build.dir.classes}" sourceBase="${gen.dir.java}" mapping="${build.dir.ws}/GoogleSearch-mapping.xml" config="${build.dir.ws}/GoogleSearch-config.xml">
<classpath refid="pathToToolsLib"/>
</wscompile>
</target>-->
<property name="config_target" location="${ws.conf.dir}"/>
<copy file="${ws.conf.dir}/GoogleSearch-config.xml" tofile="${build.dir.ws}/GoogleSearch-config.xml" filtering="on" encoding="UTF-8" overwrite="true">
<filterset>
<filter token="CONFIG_ABSOLUTE_PATH" value="${config_target}"/>
<filter token="package" value="${ws.google.package}"/>
</filterset>
</copy>
<wscompile
verbose="true"
debug="true"
xPrintStackTrace="true"
xSerializable="true"
optimize="true"
fork="true"
keep="true"
client="true"
import="false"
base="${build.dir.classes}" sourceBase="${gen.dir.java}" mapping="${build.dir.ws}/GoogleSearch-mapping.xml" config="${build.dir.ws}/GoogleSearch-config.xml">
<classpath refid="pathToToolsLib"/>
</wscompile>
</target>-->
 
<target name="test">
<java classname="pt.ipp.siges.web.services.clients.Test" classpath="${build.dir.classes}" classpathref="pathToToolsLibRoutines"/>
/impl/build.properties
172,8 → 172,10
ws.client.features=explicitcontext,useonewayoperations
#Siges Service Specific Configuration
ws.siges.package=pt.ipp.siges.web.services.clients
#ws.siges.wsdl=http://172.20.100.5:8080/SigesWeb/SiGesWEB.asmx?wsdl
ws.siges.wsdl=http://localhost:8080/SigesWeb/SiGesWEB.asmx?wsdl
#DONT USE ANY MORE NOW IS IN CONFIGURATION DATABASE ONLY FOR BUILD WEB-SERVICES
ws.siges.wsdl=http://172.20.100.5:8080/SigesWeb/SiGesWEB.asmx?wsdl
#DONT USE ANY MORE NOW IS IN CONFIGURATION DATABASE
#ws.siges.wsdl=http://localhost:8080/SigesWeb/SiGesWEB.asmx?wsdl
ws.siges.target.namespace=http://www.ipportalegre.pt/siges/web/services
ws.siges.binding.file=siges-client.xml
 
/impl/build.xml
424,7 → 424,7
<replacefilter token="@email.templates.dir@" value="${email.templates.dir}"/>
<replacefilter token="@use.ldap@" value="${use.ldap}"/>
<replacefilter token="@site.url@" value="${site.url}"/>
<replacefilter token="@ws.siges.wsdl@" value="${ws.siges.wsdl}"/>
<!-- DONT USE ANY MORE NOW IS IN CONFIGURATION DAO <replacefilter token="@ws.siges.wsdl@" value="${ws.siges.wsdl}"/>-->
<replacefilter token="@ws.siges.target.namespace@" value="${ws.siges.target.namespace}"/>
<replacefilter token="@intranet.setup.folders.file@" value="${build.dir.relative.intranet.setup.folders.file}"/>
<replacefilter token="@intranet.setup.folders.filename@" value="${intranet.setup.folders.filename}"/>