/impl/conf/template/sms/GradeUnit.txt |
---|
New file |
0,0 → 1,7 |
################################################## |
# Template de Messagem de novas Notas |
# 0: Unidade |
# 1: Nota |
################################################## |
{0}:{1}; |
/impl/conf/template/sms/GradesUnit.txt |
---|
New file |
0,0 → 1,8 |
################################################## |
# Template de Messagem de novas Notas |
# 0: Notas |
################################################## |
=TMN ESTG MESSAGE: POWERED BY TMN= |
Novas Notas lançadas: |
{0} |
/impl/src/java/pt/estgp/estgweb/Globals.java |
---|
150,6 → 150,8 |
public static final String TEMPLATE_ASSIGNEMENT_PATH = "/template/assignement"; |
public static final String TEMPLATE_SMS_PATH = "/template/sms"; |
public static final String TEMPLATE_SMS_COURSEUNIT_ANNOUNCMENT =TEMPLATE_SMS_PATH + "/CourseUnit.txt"; |
public static final String TEMPLATE_SMS_COURSEUNIT_ANNOUNCMENT = TEMPLATE_SMS_PATH + "/CourseUnit.txt"; |
public static final String TEMPLATE_SMS_NEW_GRADES = TEMPLATE_SMS_PATH + "/GradesUnit.txt"; |
public static final String TEMPLATE_SMS_NEW_GRADE = TEMPLATE_SMS_PATH + "/GradeUnit.txt"; |
} |
/impl/src/java/pt/estgp/estgweb/services/smsservice/SMSJob.java |
---|
33,7 → 33,7 |
StringBuilder phonesBuilder = new StringBuilder(); |
for(User u: userPhones) |
{ |
if(u.getPhonenumber() != null && u.getPhonenumber().length() == 9 && u.getPhonenumber().startsWith("9")) |
if(validPhoneNumber(u.getPhonenumber())) |
{ |
phonesBuilder.append(separator).append(u.getPhonenumber()); |
separator = separator2; |
44,12 → 44,26 |
this.message = TemplateUtils.formatMessageTemplate(template,args); |
} |
public SMSJob(User user, String[] args, String template) |
{ |
if(user != null) |
{ |
this.phones = user.getPhonenumber(); |
this.message = TemplateUtils.formatMessageTemplate(template,args); |
} |
} |
public SMSJob(String phones, String message) |
{ |
this.phones = phones; |
this.message = message; |
} |
public static boolean validPhoneNumber(String phoneNumber) |
{ |
return phoneNumber != null && phoneNumber.length() == 9 && phoneNumber.startsWith("9"); |
} |
public void runJob() |
{ |
try |
/impl/src/java/pt/estgp/estgweb/services/sigesimports/ImportGradesService.java |
---|
6,6 → 6,8 |
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.smsservice.SMSJob; |
import pt.estgp.estgweb.services.jobs.JobScheduleService; |
import pt.estgp.estgweb.Globals; |
import pt.estgp.estgweb.utils.DatesUtils; |
import pt.estgp.estgweb.domain.*; |
20,6 → 22,7 |
import java.util.*; |
import jomm.dao.impl.AbstractDao; |
import jomm.utils.TemplateUtils; |
/** |
* @author Jorge Machado |
34,7 → 37,7 |
private static final int MAX_COMMIT = 100; |
private List<Long> newGrades = new ArrayList<Long>(); |
private HashMap<Long,List<Long>> newGrades = new HashMap<Long,List<Long>>(); |
public ILogMessages run(String year) throws ServiceException |
{ |
70,6 → 73,7 |
int codAluno = nota.getCodigoAluno().intValue(); |
int codUnidade = nota.getCodigoDisciplina().intValue(); |
int codCurso = nota.getCodigoCurso().intValue(); |
String cdDuracao = nota.getCdDuracao(); |
int valor = nota.getNota().intValue(); |
int statusEpoca = nota.getStatusEpoca().intValue(); |
Date data = nota.getDataAvaliacao().toGregorianCalendar().getTime(); |
81,7 → 85,7 |
{ |
CourseUnit courseUnit; |
try{ |
courseUnit = DaoFactory.getCourseUnitDaoImpl().loadBySigesCodeUniqueSubscribed("" + codUnidade, "" + codCurso,s.getId()); |
courseUnit = DaoFactory.getCourseUnitDaoImpl().loadBySigesCodeUniqueSubscribed("" + codUnidade, year, "" + codCurso,s.getId(),cdDuracao); |
if(courseUnit != null) |
{ |
CourseUnitGrade grade = DaoFactory.getCourseUnitGradeDaoImpl().find(courseUnit.getId(),s.getId()); |
90,16 → 94,19 |
grade = DomainObjectFactory.createCourseUnitGradeImpl(); |
grade.setStudent(s); |
grade.setCourseUnit(courseUnit); |
grade.setNormalizedCourseUnitName(courseUnit.getNormalizedName()); |
grade.setImportYear(year); |
DaoFactory.getCourseUnitGradeDaoImpl().save(grade); |
newGrades.add(grade.getId()); |
if(grade.getGrade() > 0) |
addGrade(grade); |
} |
if(grade.getGrade() != valor || grade.getStatusEpoca() != statusEpoca || grade.getPublishDate().getTime() != data.getTime()) |
{ |
grade.setPublishDate(data); |
grade.setGrade(valor); |
grade.setStatusEpoca(statusEpoca); |
newGrades.add(grade.getId()); |
if(grade.getGrade() > 0) |
addGrade(grade); |
} |
} |
else |
109,7 → 116,7 |
} |
}catch(Exception e) |
{ |
logger.warn("Not unique : unit:" + codUnidade + " course:" + codCurso + " student:" + s.getId()); |
logger.warn("Error : unit:" + codUnidade + " course:" + codCurso + " student:" + s.getId(),e); |
} |
} |
120,6 → 127,7 |
} |
} |
sendSms(null); |
AbstractDao.getCurrentSession().getTransaction().commit(); |
} |
catch (Throwable e) |
134,6 → 142,43 |
return logMessages; |
} |
private void addGrade(CourseUnitGrade grade) |
{ |
List<Long> studentGrades = newGrades.get(grade.getStudent().getId()); |
if(studentGrades == null) |
{ |
studentGrades = new ArrayList<Long>(); |
newGrades.put(grade.getStudent().getId(),studentGrades); |
} |
studentGrades.add(grade.getId()); |
} |
private void sendSms(UserSession userSession) |
{ |
if(Globals.SMS_NEW_GRADES && newGrades.size() > 0) |
{ |
Set<Map.Entry<Long,List<Long>>> set = newGrades.entrySet(); |
for(Map.Entry<Long,List<Long>> entry: set) |
{ |
long studentId = entry.getKey(); |
List<Long> studentGrades = entry.getValue(); |
Student s = DaoFactory.getStudentDaoImpl().get(studentId); |
if(SMSJob.validPhoneNumber(s.getPhonenumber())) |
{ |
StringBuilder gradesBuilder = new StringBuilder(); |
for(long gradeId: studentGrades) |
{ |
CourseUnitGrade grade = DaoFactory.getCourseUnitGradeDaoImpl().get(gradeId); |
String gradeStr = TemplateUtils.formatMessageTemplate(Globals.TEMPLATE_SMS_NEW_GRADE,new String[]{grade.getNormalizedCourseUnitName(),""+grade.getGrade()}); |
gradesBuilder.append(gradeStr); |
} |
SMSJob smsJob = new SMSJob(s,new String[]{gradesBuilder.toString()},Globals.TEMPLATE_SMS_NEW_GRADES); |
JobScheduleService.getInstance().scheduleNow(smsJob,"New Grades SMS: to" + s.getUsername(),userSession); |
} |
} |
} |
} |
/** |
* Testar por aqui poi requer Super Role e assim e' autmatico |
* |
/impl/src/java/pt/estgp/estgweb/services/jobs/JobScheduleService.java |
---|
30,7 → 30,8 |
public void schedule(JobHandler handler, String description, Date startDate, UserSession userSession) |
{ |
Job job = DomainObjectFactory.createJobImpl(); |
job.setOwner(userSession.getUser()); |
if(userSession != null && userSession.getUser() != null) |
job.setOwner(userSession.getUser()); |
job.setDescription(description); |
job.setStartDate(startDate); |
job.setJobHandler(handler); |
/impl/src/java/pt/estgp/estgweb/domain/dao/impl/CourseUnitDaoImpl.java |
---|
71,11 → 71,13 |
return (CourseUnit) createCriteria().add(eq("code", sigesCode)).add(eq("courseCode", courseCode)).uniqueResult(); |
} |
public CourseUnit loadBySigesCodeUniqueSubscribed(String sigesCode, String courseCode, long studentId) |
public CourseUnit loadBySigesCodeUniqueSubscribed(String sigesCode, String year, String courseCode, long studentId, String semestre) |
{ |
List<CourseUnit> cus = createCriteria() |
.add(eq("code", sigesCode)) |
.add(eq("importYear", year)) |
.add(eq("courseCode", courseCode)) |
.add(eq("semestre", semestre)) |
.createAlias("students","st") |
.add(eq("st.id",studentId)) |
.list(); |
/impl/src/hbm/pt/estgp/estgweb/domain/CourseUnit.hbm.xml |
---|
123,6 → 123,7 |
<property name="saveDate" type="timestamp"/> |
<property name="publishDate" type="timestamp"/> |
<property name="grade" type="int" index="gradeIndex"/> |
<property name="normalizedCourseUnitName" type="string"/> |
<property name="statusEpoca" type="int" index="statusEpocaIndex"/> |
<property name="importYear" type="string" index="importYearIndex"/> |
<many-to-one name="courseUnit" class="pt.estgp.estgweb.domain.CourseUnit" lazy="false" outer-join="true"/> |
/impl/gen/java/pt/ipportalegre/siges/web/services/ObjectFactory.java |
---|
38,11 → 38,11 |
} |
/** |
* Create an instance of {@link Disciplina } |
* Create an instance of {@link GetDisciplinasDaInstituicao } |
* |
*/ |
public Disciplina createDisciplina() { |
return new Disciplina(); |
public GetDisciplinasDaInstituicao createGetDisciplinasDaInstituicao() { |
return new GetDisciplinasDaInstituicao(); |
} |
/** |
54,14 → 54,6 |
} |
/** |
* Create an instance of {@link Nota } |
* |
*/ |
public Nota createNota() { |
return new Nota(); |
} |
/** |
* Create an instance of {@link GetAulasResponse } |
* |
*/ |
94,27 → 86,27 |
} |
/** |
* Create an instance of {@link Aula } |
* Create an instance of {@link SendSmsSeparatedWithCommaResponse } |
* |
*/ |
public Aula createAula() { |
return new Aula(); |
public SendSmsSeparatedWithCommaResponse createSendSmsSeparatedWithCommaResponse() { |
return new SendSmsSeparatedWithCommaResponse(); |
} |
/** |
* Create an instance of {@link SendSmsSeparatedWithCommaResponse } |
* Create an instance of {@link Aula } |
* |
*/ |
public SendSmsSeparatedWithCommaResponse createSendSmsSeparatedWithCommaResponse() { |
return new SendSmsSeparatedWithCommaResponse(); |
public Aula createAula() { |
return new Aula(); |
} |
/** |
* Create an instance of {@link ArrayOfDisciplina } |
* Create an instance of {@link GetCodigosAlunosInscritosDaInstituicao } |
* |
*/ |
public ArrayOfDisciplina createArrayOfDisciplina() { |
return new ArrayOfDisciplina(); |
public GetCodigosAlunosInscritosDaInstituicao createGetCodigosAlunosInscritosDaInstituicao() { |
return new GetCodigosAlunosInscritosDaInstituicao(); |
} |
/** |
174,6 → 166,22 |
} |
/** |
* Create an instance of {@link GetDisciplinasDaInstituicaoSemestreResponse } |
* |
*/ |
public GetDisciplinasDaInstituicaoSemestreResponse createGetDisciplinasDaInstituicaoSemestreResponse() { |
return new GetDisciplinasDaInstituicaoSemestreResponse(); |
} |
/** |
* Create an instance of {@link Disciplina } |
* |
*/ |
public Disciplina createDisciplina() { |
return new Disciplina(); |
} |
/** |
* Create an instance of {@link SendSmsResponse } |
* |
*/ |
206,11 → 214,11 |
} |
/** |
* Create an instance of {@link GetCodigosAlunosInscritosDaInstituicao } |
* Create an instance of {@link Nota } |
* |
*/ |
public GetCodigosAlunosInscritosDaInstituicao createGetCodigosAlunosInscritosDaInstituicao() { |
return new GetCodigosAlunosInscritosDaInstituicao(); |
public Nota createNota() { |
return new Nota(); |
} |
/** |
230,6 → 238,14 |
} |
/** |
* Create an instance of {@link ArrayOfDisciplina } |
* |
*/ |
public ArrayOfDisciplina createArrayOfDisciplina() { |
return new ArrayOfDisciplina(); |
} |
/** |
* Create an instance of {@link GetDocenteResponse } |
* |
*/ |
262,14 → 278,6 |
} |
/** |
* Create an instance of {@link GetDisciplinasDaInstituicao } |
* |
*/ |
public GetDisciplinasDaInstituicao createGetDisciplinasDaInstituicao() { |
return new GetDisciplinasDaInstituicao(); |
} |
/** |
* Create an instance of {@link ArrayOfString } |
* |
*/ |
278,14 → 286,6 |
} |
/** |
* Create an instance of {@link GetDisciplinasDaInstituicaoSemestreResponse } |
* |
*/ |
public GetDisciplinasDaInstituicaoSemestreResponse createGetDisciplinasDaInstituicaoSemestreResponse() { |
return new GetDisciplinasDaInstituicaoSemestreResponse(); |
} |
/** |
* Create an instance of {@link Aluno } |
* |
*/ |
/impl/gen/java/pt/ipportalegre/siges/web/services/Nota.java |
---|
20,7 → 20,7 |
* <complexContent> |
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> |
* <sequence> |
* <element name="cd_duracao" type="{http://www.w3.org/2001/XMLSchema}decimal"/> |
* <element name="cd_duracao" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> |
* <element name="codigoInstituicao" type="{http://www.w3.org/2001/XMLSchema}decimal"/> |
* <element name="cd_lectivo" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> |
* <element name="codigo_disciplina" type="{http://www.w3.org/2001/XMLSchema}decimal"/> |
51,8 → 51,8 |
}) |
public class Nota { |
@XmlElement(name = "cd_duracao", required = true) |
protected BigDecimal cdDuracao; |
@XmlElement(name = "cd_duracao") |
protected String cdDuracao; |
@XmlElement(required = true) |
protected BigDecimal codigoInstituicao; |
@XmlElement(name = "cd_lectivo") |
76,10 → 76,10 |
* |
* @return |
* possible object is |
* {@link BigDecimal } |
* {@link String } |
* |
*/ |
public BigDecimal getCdDuracao() { |
public String getCdDuracao() { |
return cdDuracao; |
} |
88,10 → 88,10 |
* |
* @param value |
* allowed object is |
* {@link BigDecimal } |
* {@link String } |
* |
*/ |
public void setCdDuracao(BigDecimal value) { |
public void setCdDuracao(String value) { |
this.cdDuracao = value; |
} |