Commit edbb8f33 authored by didonet's avatar didonet
Browse files

Corrected alert that calculates the registrations that have defense date

close to a given expiration period.
parent 322fcc0d
package br.ufpr.c3sl.sapos.models.customization;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.MailSender;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
......@@ -17,13 +16,15 @@ import br.ufpr.c3sl.sapos.models.scholar.Registration;
import br.ufpr.c3sl.sapos.models.scholar.StudentGrant;
import br.ufpr.c3sl.sapos.models.scholar.Transcript;
import br.ufpr.c3sl.sapos.models.scholar.TravelRequisition;
import br.ufpr.c3sl.sapos.models.util.PropertyUtil;
import br.ufpr.c3sl.sapos.models.scholar.enums.RegistrationKind;
import br.ufpr.c3sl.sapos.models.scholar.enums.RegistrationStatus;
@RooJavaBean
@RooToString
@RooEntity
public class Configuration {
@Autowired
public transient MailSender mailTemplate;
......@@ -36,6 +37,12 @@ public class Configuration {
public static String COURSE_INFO_FOOTER = "course.info.footer";
public static String VERIFY_TEACHING_PRACTICE = "verify.teaching.practice";
public static String TECHING_PRACTICE_COURSES = "teaching.practice.courses";
public static String MONTHS_DEFENSE_DATE_EXPIRES_PHD = "months.defense.date.expires.phd";
public static String MONTHS_DEFENSE_DATE_EXPIRES_MASTER = "months.defense.date.expires.master";
public static final String DAYS_TO_GRANT_EXPIRATION = "days.to.grant.expiration";
public static final String MONTHS_MASTER_SCHOLARSHIP_DURATION = "months.master.scholarship.duration";
public static final String MONTHS_PHD_SCHOLARSHIP_DURATION = "months.phd.scholarship.duration";
@NotNull
private String name;
......@@ -72,10 +79,24 @@ public class Configuration {
}
//- mostrar data de defesa maior que x meses
public static Object findLongTimeDefenseRegistration(){
public static Object findExpiredDefenseRegistration(){
return entityManager().createNativeQuery(
"select * from registration r where "+
"(r.defense_date - r.proposal_date)/30 > "+Configuration.findConfigValueByName("month.nb.defense.date.expiring"),Registration.class).getResultList();
// " (extract ( month from age (current_date, start_date)) + extract (year from age (current_date, start_date)) * 12) > "+
//(y2 - y1) * 12 + (m2 - m1) + 1;
" select * from registration where " +
" defense_date is null and reg_kind = '"+RegistrationKind.Mestrado+"' and reg_status = '"+RegistrationStatus.Ativa+"' and "+
" ( (date_part('year',current_date) - date_part('year',start_date)) * 12 + (date_part('month',current_date) - date_part('month',start_date)) +1) > "+
Configuration.findConfigValueByName(MONTHS_DEFENSE_DATE_EXPIRES_MASTER) +
" UNION "+
" select * from registration where " +
" defense_date is null and reg_kind = '"+RegistrationKind.Doutorado+"' and reg_status = '"+RegistrationStatus.Ativa+"' and "+
" ( (date_part('year',current_date) - date_part('year',start_date)) * 12 + (date_part('month',current_date) - date_part('month',start_date)) +1) > " +
Configuration.findConfigValueByName(MONTHS_DEFENSE_DATE_EXPIRES_PHD)
,
Registration.class).getResultList();
}
//- avisar que conceito do semestre anterior nao foram preenchidas
......@@ -98,18 +119,18 @@ public class Configuration {
}
//- alerta para requisicoes de viagem
public static Object findAllOpenTravelRequisitions(){
public static Object findAllOpenTravelRequisitions() {
return entityManager().createNativeQuery(
"select * from travel_requisition where request_status = 'Aberta' OR request_status = 'Confirmada'", TravelRequisition.class).getResultList();
}
//- mostrar perto da data final de bolsa
public static Object findNearEndGrants(){
public static Object findNearEndGrants() {
Integer phd, master, expiring;
phd = new Integer(Configuration.findConfigValueByName("months.phd.scholarship.duration"));
master = new Integer(Configuration.findConfigValueByName("months.master.scholarship.duration"));
expiring = new Integer(Configuration.findConfigValueByName("days.to.grant.expiration"));
phd = new Integer(Configuration.findConfigValueByName(MONTHS_PHD_SCHOLARSHIP_DURATION));
master = new Integer(Configuration.findConfigValueByName(MONTHS_MASTER_SCHOLARSHIP_DURATION));
expiring = new Integer(Configuration.findConfigValueByName(DAYS_TO_GRANT_EXPIRATION));
phd = phd * 30; //em dias
master = master * 30; //em dias
......@@ -121,10 +142,12 @@ public class Configuration {
" order by p.name", StudentGrant.class).getResultList();
/*"select * from student_grant sg where (CURRENT_DATE - (sg.start_date + integer '"+master+"')) <= '"+expiring+"'"*/
}
public static boolean checkTeachingPractice(String trim) {
// TODO Auto-generated method stub
return false;
// subtracts two dates and returns the difference between the number of months
public static int monthsSubtraction (Date initialDate, Date finalDate) {
//(y2 - y1) * 12 + (m2 - m1) + 1;
return (finalDate.getYear() - initialDate.getYear()) * 12 + (finalDate.getMonth() - initialDate.getMonth()) + 1;
}
}
\ No newline at end of file
......@@ -78,8 +78,7 @@ public class StudentGrant {
else
lastDate = studentGrant.endDate;
//(y2 - y1) * 12 + (m2 - m1) + 1;
nbMonths += (lastDate.getYear() - firstDate.getYear()) * 12 + (lastDate.getMonth() - firstDate.getMonth()) + 1;
nbMonths += Configuration.monthsSubtraction(firstDate, lastDate);
}
return nbMonths;
}
......
......@@ -35,7 +35,7 @@ public class ConfigurationController {
model.addAttribute("activePhd", cPhd);
model.addAttribute("irregularGrants", Configuration.findActiveStudentIrregularGrants());
model.addAttribute("irregularRegistrations", Configuration.findIrregularRegistration());
model.addAttribute("expiredDefense", Configuration.findLongTimeDefenseRegistration());
model.addAttribute("expiredDefense", Configuration.findExpiredDefenseRegistration());
model.addAttribute("endGrant", Configuration.findNearEndGrants());
model.addAttribute("gradeEmpty", Configuration.findLastPeriodBlankConcepts());
model.addAttribute("travelrequisition", Configuration.findAllOpenTravelRequisitions());
......
......@@ -36,7 +36,7 @@
</page:list>
<br/><br/>
<b>Aluno com duas reprovações</b>
<b>Aluno com duas reprovações e ativo</b>
<page:list id="pl_br_ufpr_c3sl_sapos_models_scholar_Registration" items="${irregularRegistrations}" emptyLabels="true" z="user-managed">
<table:table data="${irregularRegistrations}" id="l_br_ufpr_c3sl_sapos_models_scholar_Registration" path="/registrations" create="false" z="user-managed">
<table:column id="c_br_ufpr_c3sl_sapos_models_scholar_Registration_student" navigation="true" property="student" z="user-managed"/>
......@@ -51,7 +51,7 @@
</page:list>
<br/><br/>
<b>Data de defesa maior que o estipulado</b>
<b>Data de defesa maior que o estipulado (mestrado e doutorado)</b>
<page:list id="pl_br_ufpr_c3sl_sapos_models_scholar_SectionPos" items="${expiredDefense}" emptyLabels="true" z="user-managed">
<table:table data="${expiredDefense}" id="l_br_ufpr_c3sl_sapos_models_scholar_Registration" path="/registrations" create="false" z="user-managed">
<table:column id="c_br_ufpr_c3sl_sapos_models_scholar_Registration_student" navigation="true" property="student" z="user-managed"/>
......@@ -66,7 +66,7 @@
</page:list>
<br/><br/>
<b>Bolsas próximas a data de termino</b>
<b>Bolsas próximas a data de término </b>
<page:list id="pl_br_ufpr_c3sl_sapos_models_people_Staff" items="${endGrant}" emptyLabels="true" z="user-managed">
<table:table data="${endGrant}" id="l_br_ufpr_c3sl_sapos_models_scholar_StudentGrant" path="/studentgrants" create="false" z="user-managed">
<table:column id="c_br_ufpr_c3sl_sapos_models_people_Person_name" property="registration.student.name" z="user-managed" navigation="true"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment