Commit b5599972 authored by didonet's avatar didonet

Included a new class and corresponding elements (applications, views,

i18n, etc.) for support students registration requests.
parent b90e1e91
......@@ -40,6 +40,9 @@ public class Configuration {
public static String VERIFY_TEACHING_PRACTICE = "verify.teaching.practice";
public static String TECHING_PRACTICE_COURSES = "teaching.practice.courses";
public static String ALLOWED_DUPLICATE_COURSE_CODE = "allowed.duplicate.course.codes";
public static String CURRENT_YEAR = "current.year";
public static String CURRENT_PERIOD = "current.period";
public static String MONTHS_DEFENSE_DATE_EXPIRES_PHD = "months.defense.date.expires.phd";
public static String MONTHS_PHD = "months.phd";
......
package br.ufpr.c3sl.sapos.models.scholar;
import java.util.Date;
import java.util.List;
import javax.persistence.ManyToOne;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.entity.RooJpaEntity;
import org.springframework.roo.addon.tostring.RooToString;
import br.ufpr.c3sl.sapos.models.customization.Configuration;
import br.ufpr.c3sl.sapos.models.scholar.enums.RegistrationKind;
@RooJavaBean
@RooToString
@RooJpaEntity
public class RegistrationRequest {
private Date requestDate;
private RegistrationKind requestKind;
private String name;
private String CPF;
private String phone;
private String email;
private Integer entryYear;
private Integer entryPeriod;
private Boolean isWritingThesis;
private Boolean scholarshipCandidate;
private Boolean isWorking;
private String PosComp;
private String observations;
@ManyToOne
private SectionPos sectionPos1;
@ManyToOne
private SectionPos sectionPos2;
@ManyToOne
private SectionPos sectionPos3;
@ManyToOne
private SectionPos sectionPos4;
@ManyToOne
private SectionPos sectionPos5;
public static List<RegistrationRequest> findRegistrationRequestByCPF(Long id, String CPF, Integer year, Integer period) {
String queryRequest = "SELECT * FROM registration_request " +
" where ";
if (id != null)
queryRequest += " id ="+id+" and ";
queryRequest +=
" cpf = trim('"+CPF+"') "+
" and entry_year = "+year+" and entry_period = "+period
+" order by request_date desc";
return entityManager().createNativeQuery(queryRequest, RegistrationRequest.class).getResultList();
}
}
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
// You may push code into the target .java compilation unit if you wish to edit any member(s).
package br.ufpr.c3sl.sapos.models.scholar;
import org.springframework.beans.factory.annotation.Configurable;
privileged aspect RegistrationRequest_Roo_Configurable {
declare @type: RegistrationRequest: @Configurable;
}
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
// You may push code into the target .java compilation unit if you wish to edit any member(s).
package br.ufpr.c3sl.sapos.models.scholar;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PersistenceContext;
import javax.persistence.Version;
import org.springframework.transaction.annotation.Transactional;
privileged aspect RegistrationRequest_Roo_Entity {
declare @type: RegistrationRequest: @Entity;
@PersistenceContext
transient EntityManager RegistrationRequest.entityManager;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long RegistrationRequest.id;
@Version
@Column(name = "version")
private Integer RegistrationRequest.version;
public Long RegistrationRequest.getId() {
return this.id;
}
public void RegistrationRequest.setId(Long id) {
this.id = id;
}
public Integer RegistrationRequest.getVersion() {
return this.version;
}
public void RegistrationRequest.setVersion(Integer version) {
this.version = version;
}
@Transactional
public void RegistrationRequest.persist() {
if (this.entityManager == null) this.entityManager = entityManager();
this.entityManager.persist(this);
}
@Transactional
public void RegistrationRequest.remove() {
if (this.entityManager == null) this.entityManager = entityManager();
if (this.entityManager.contains(this)) {
this.entityManager.remove(this);
} else {
Registration attached = Registration.findRegistration(this.id);
this.entityManager.remove(attached);
}
}
@Transactional
public void RegistrationRequest.flush() {
if (this.entityManager == null) this.entityManager = entityManager();
this.entityManager.flush();
}
@Transactional
public void RegistrationRequest.clear() {
if (this.entityManager == null) this.entityManager = entityManager();
this.entityManager.clear();
}
@Transactional
public RegistrationRequest RegistrationRequest.merge() {
if (this.entityManager == null) this.entityManager = entityManager();
RegistrationRequest merged = this.entityManager.merge(this);
this.entityManager.flush();
return merged;
}
public static final EntityManager RegistrationRequest.entityManager() {
EntityManager em = new RegistrationRequest().entityManager;
if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
return em;
}
public static long RegistrationRequest.countRegistrationRequests() {
return entityManager().createQuery("SELECT COUNT(o) FROM Registration o", Long.class).getSingleResult();
}
public static RegistrationRequest RegistrationRequest.findRegistrationRequest(Long id) {
if (id == null) return null;
return entityManager().find(RegistrationRequest.class, id);
}
public static List<RegistrationRequest> RegistrationRequest.findRegistrationRequestEntries(int firstResult, int maxResults) {
return entityManager().createQuery("SELECT o FROM Registration o", RegistrationRequest.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
}
}
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
// You may push code into the target .java compilation unit if you wish to edit any member(s).
package br.ufpr.c3sl.sapos.models.scholar;
import java.util.Date;
import br.ufpr.c3sl.sapos.models.scholar.enums.RegistrationKind;
privileged aspect RegistrationRequest_Roo_JavaBean {
public Date RegistrationRequest.getRequestDate() {
return this.requestDate;
}
public void RegistrationRequest.setRequestDate(Date requestDate) {
this.requestDate = requestDate;
}
public RegistrationKind RegistrationRequest.getRequestKind() {
return this.requestKind;
}
public void RegistrationRequest.setRequestKind(RegistrationKind requestKind) {
this.requestKind = requestKind;
}
public String RegistrationRequest.getName() {
return this.name;
}
public void RegistrationRequest.setName(String name) {
this.name = name;
}
public String RegistrationRequest.getCPF() {
return this.CPF;
}
public void RegistrationRequest.setCPF(String CPF) {
this.CPF = CPF;
}
public String RegistrationRequest.getPhone() {
return this.phone;
}
public void RegistrationRequest.setPhone(String phone) {
this.phone = phone;
}
public String RegistrationRequest.getEmail() {
return this.email;
}
public void RegistrationRequest.setEmail(String email) {
this.email = email;
}
public Integer RegistrationRequest.getEntryYear() {
return this.entryYear;
}
public void RegistrationRequest.setEntryYear(Integer entryYear) {
this.entryYear = entryYear;
}
public Integer RegistrationRequest.getEntryPeriod() {
return this.entryPeriod;
}
public void RegistrationRequest.setEntryPeriod(Integer entryPeriod) {
this.entryPeriod = entryPeriod;
}
public Boolean RegistrationRequest.getIsWritingThesis() {
return this.isWritingThesis;
}
public void RegistrationRequest.setIsWritingThesis(Boolean isWritingThesis) {
this.isWritingThesis = isWritingThesis;
}
// private String advisor;
public Boolean RegistrationRequest.getScholarshipCandidate() {
return this.scholarshipCandidate;
}
public void RegistrationRequest.setScholarshipCandidate(Boolean scholarshipCandidate) {
this.scholarshipCandidate = scholarshipCandidate;
}
public Boolean RegistrationRequest.getIsWorking() {
return this.isWorking;
}
public void RegistrationRequest.setIsWorking(Boolean isWorking) {
this.isWorking = isWorking;
}
public String RegistrationRequest.getPosComp() {
return this.PosComp;
}
public void RegistrationRequest.setPosComp(String PosComp) {
this.PosComp = PosComp;
}
public String RegistrationRequest.getObservations() {
return this.observations;
}
public void RegistrationRequest.setObservations(String observations) {
this.observations = observations;
}
public SectionPos RegistrationRequest.getSectionPos1() {
return this.sectionPos1;
}
public void RegistrationRequest.setSectionPos1(SectionPos sectionPos1) {
this.sectionPos1 = sectionPos1;
}
public SectionPos RegistrationRequest.getSectionPos2() {
return this.sectionPos2;
}
public void RegistrationRequest.setSectionPos2(SectionPos sectionPos2) {
this.sectionPos2 = sectionPos2;
}
public SectionPos RegistrationRequest.getSectionPos3() {
return this.sectionPos3;
}
public void RegistrationRequest.setSectionPos3(SectionPos sectionPos3) {
this.sectionPos3 = sectionPos3;
}
public SectionPos RegistrationRequest.getSectionPos4() {
return this.sectionPos4;
}
public void RegistrationRequest.setSectionPos4(SectionPos sectionPos4) {
this.sectionPos4 = sectionPos4;
}
public SectionPos RegistrationRequest.getSectionPos5() {
return this.sectionPos5;
}
public void RegistrationRequest.setSectionPos5(SectionPos sectionPos5) {
this.sectionPos5 = sectionPos5;
}
}
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
// You may push code into the target .java compilation unit if you wish to edit any member(s).
package br.ufpr.c3sl.sapos.models.scholar;
import java.lang.String;
privileged aspect RegistrationRequest_Roo_ToString {
public String RegistrationRequest.toString() {
StringBuilder sb = new StringBuilder();
return sb.toString();
}
}
package br.ufpr.c3sl.sapos.web;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.joda.time.format.DateTimeFormat;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import br.ufpr.c3sl.sapos.models.customization.Configuration;
import br.ufpr.c3sl.sapos.models.scholar.Registration;
import br.ufpr.c3sl.sapos.models.scholar.RegistrationRequest;
import br.ufpr.c3sl.sapos.models.scholar.SectionPos;
import br.ufpr.c3sl.sapos.models.scholar.enums.RegistrationKind;
@RooWebScaffold(path = "registrationrequests", formBackingObject = RegistrationRequest.class)
@RequestMapping("/registrationrequests")
@Controller
public class RegistrationRequestController {
@RequestMapping(method = RequestMethod.POST)
public String create(@Valid RegistrationRequest regRequest, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
if (!regRequest.getIsWritingThesis() &&
regRequest.getSectionPos1() == null && regRequest.getSectionPos2() == null && regRequest.getSectionPos3() == null &&
regRequest.getSectionPos5() == null && regRequest.getSectionPos5() == null) {
bindingResult.addError(new ObjectError("selection.invalid","Select at least one"));
}
if (bindingResult.hasErrors()) {
uiModel.addAttribute("registrationrequest", regRequest);
addDateTimeFormatPatterns(uiModel);
return "/registrationrequests?newrequest";
}
uiModel.asMap().clear();
regRequest.setRequestDate(Calendar.getInstance().getTime());
regRequest.setEntryPeriod(new Integer(Configuration.findConfigValueByName(Configuration.CURRENT_PERIOD)));
regRequest.setEntryYear(new Integer(Configuration.findConfigValueByName(Configuration.CURRENT_YEAR)));
regRequest.persist();
return "redirect:/registrationrequests/submitted?id=" + regRequest.getId().toString()+"&cpf="+regRequest.getCPF().toString();
}
@RequestMapping(value="list",method = RequestMethod.GET)
public String list(@RequestParam(value = "year", required = false) String year,
@RequestParam(value = "kind", required = false) String kind,
@RequestParam(value = "status", required = false) String status,
Model model) {
model.addAttribute("registrations", Registration.findRegistrations(year, kind, status));
return "registrations/list";
}
@RequestMapping(value = "submitted", method = RequestMethod.GET)
public String showrequest(
@RequestParam(value = "id", required = true) Long id,
@RequestParam(value = "cpf", required = true) String cpf,
Model uiModel
) {
addDateTimeFormatPatterns(uiModel);
uiModel.addAttribute("registrationrequest",
RegistrationRequest.findRegistrationRequestByCPF(id, cpf,
new Integer(Configuration.findConfigValueByName(Configuration.CURRENT_YEAR)),
new Integer(Configuration.findConfigValueByName(Configuration.CURRENT_PERIOD))).get(0)); //shows the first occurrence
if (RegistrationRequest.findRegistrationRequestByCPF(null, cpf,
new Integer(Configuration.findConfigValueByName(Configuration.CURRENT_YEAR)),
new Integer(Configuration.findConfigValueByName(Configuration.CURRENT_PERIOD))).size() > 1 ) {
uiModel.addAttribute("existing", "Existing value.");
}
return "registrationrequests/show";
}
@RequestMapping(params = "newrequest", method = RequestMethod.GET)
public String newRequestForm(Model uiModel) {
uiModel.addAttribute("registrationrequest", new RegistrationRequest());
addDateTimeFormatPatterns(uiModel);
return "registrationrequests/request"; // maps to create.jspx
}
@ModelAttribute("validsectionpos")
public java.util.Collection<SectionPos> populateSectionPoses() {
return (Collection<SectionPos>) SectionPos.findSectionPoses(
new Integer(Configuration.findConfigValueByName(Configuration.CURRENT_YEAR)) ,
new Integer(Configuration.findConfigValueByName(Configuration.CURRENT_PERIOD)), null);
}
@ModelAttribute("registrationkinds")
public java.util.Collection<RegistrationKind> populateRegistrationKinds() {
return Arrays.asList(RegistrationKind.class.getEnumConstants());
}
void addDateTimeFormatPatterns(Model uiModel) {
uiModel.addAttribute("registrationrequest_request_date_format", DateTimeFormat.patternForStyle("S-", LocaleContextHolder.getLocale()));
}
}
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
// You may push code into the target .java compilation unit if you wish to edit any member(s).
package br.ufpr.c3sl.sapos.web;
import java.io.UnsupportedEncodingException;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.util.UriUtils;
import org.springframework.web.util.WebUtils;
privileged aspect RegistrationRequestRequestController_Roo_Controller {
// @RequestMapping(params = "form", method = RequestMethod.GET)
// public String RegistrationRequestController.createForm(Model uiModel) {
// uiModel.addAttribute("registrationRequest", new RegistrationRequest());
// addDateTimeFormatPatterns(uiModel);
// return "RegistrationRequests/create";
// }
//
// @RequestMapping(method = RequestMethod.GET)
// public String RegistrationRequestController.list(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
// if (page != null || size != null) {
// int sizeNo = size == null ? 10 : size.intValue();
// uiModel.addAttribute("RegistrationRequests", RegistrationRequest.findRegistrationRequestEntries(page == null ? 0 : (page.intValue() - 1) * sizeNo, sizeNo));
// float nrOfPages = (float) RegistrationRequest.countRegistrationRequests() / sizeNo;
// uiModel.addAttribute("maxPages", (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
// } else {
// uiModel.addAttribute("RegistrationRequests", RegistrationRequest.findAllRegistrationRequests());
// }
// addDateTimeFormatPatterns(uiModel);
// return "RegistrationRequests/list";
// }
// @RequestMapping(method = RequestMethod.PUT)
// public String RegistrationRequestController.update(@Valid RegistrationRequest RegistrationRequest, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
// if (bindingResult.hasErrors()) {
// uiModel.addAttribute("RegistrationRequest", RegistrationRequest);
// addDateTimeFormatPatterns(uiModel);
// return "registrationrequests/update";
// }
// uiModel.asMap().clear();
// RegistrationRequest.merge();
// return "redirect:/registrationrequests/" + encodeUrlPathSegment(RegistrationRequest.getId().toString(), httpServletRequest);
// }
// @RequestMapping(value = "/{id}", params = "form", method = RequestMethod.GET)
// public String RegistrationRequestController.updateForm(@PathVariable("id") Long id, Model uiModel) {
// uiModel.addAttribute("RegistrationRequest", RegistrationRequest.findRegistrationRequest(id));
// addDateTimeFormatPatterns(uiModel);
// return "RegistrationRequests/update";
// }
//
// @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
// public String RegistrationRequestController.delete(@PathVariable("id") Long id, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
// RegistrationRequest.findRegistrationRequest(id).remove();
// uiModel.asMap().clear();
// uiModel.addAttribute("page", (page == null) ? "1" : page.toString());
// uiModel.addAttribute("size", (size == null) ? "10" : size.toString());
// return "redirect:/RegistrationRequests";
// }
// @ModelAttribute("RegistrationRequests")
// public java.util.Collection<RegistrationRequest> RegistrationRequestController.populateRegistrationRequests() {
// return RegistrationRequest.findAllRegistrationRequests();
// }
// @ModelAttribute("transcripts")
// public java.util.Collection<Transcript> RegistrationRequestController.populateTranscripts() {
// return Transcript.findAllTranscripts();
// }
// @ModelAttribute("languagekinds")
// public java.util.Collection<LanguageKind> RegistrationRequestController.populateLanguageKinds() {
// return Arrays.asList(LanguageKind.class.getEnumConstants());
// }
//
// @ModelAttribute("RegistrationRequestkinds")
// public java.util.Collection<RegistrationRequestKind> RegistrationRequestController.populateRegistrationRequestKinds() {
// return Arrays.asList(RegistrationRequestKind.class.getEnumConstants());
// }
String RegistrationRequestController.encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
String enc = httpServletRequest.getCharacterEncoding();
if (enc == null) {
enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
}
try {
pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
}
catch (UnsupportedEncodingException uee) {}
return pathSegment;
}
}
......@@ -17,6 +17,8 @@
<intercept-url pattern="/member/**" access="isAuthenticated()" />
<intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/login" access="permitAll" />
<!-- <intercept-url pattern="/index" access="permitAll" /> -->
<!-- <intercept-url pattern="/header**" access="permitAll" /> -->
......@@ -43,6 +45,7 @@
<intercept-url pattern="/organizations**" access="hasAnyRole('Administrador', 'Funcionario', 'Professor')" />
<intercept-url pattern="/grantkinds**" access="hasAnyRole('Administrador', 'Funcionario', 'Professor')" />
<intercept-url pattern="/configurations**" access="hasAnyRole('Administrador', 'Funcionario', 'Professor')" />
<intercept-url pattern="/registrationrequests**" access="hasAnyRole('Administrador', 'Funcionario', 'Professor')" />
<intercept-url pattern="/subscriptions**" access="permitAll" method="GET" />
<intercept-url pattern="/subscriptions**" access="permitAll" method="POST" />
......@@ -58,6 +61,9 @@
<intercept-url pattern="/**" access="isAuthenticated()" />
<intercept-url pattern="/registrationrequests**" access="permitAll" />
<intercept-url pattern="/registrationrequests/submitted**" access="permitAll" />
</http>
<!-- Configure Authentication mechanism -->
......
......@@ -343,6 +343,28 @@ label_br_ufpr_c3sl_sapos_models_scholar_registration_transcripts=Transcripts
label_br_ufpr_c3sl_sapos_models_scholar_registration_transfercredit=Transfer Credit
label_br_ufpr_c3sl_sapos_models_scholar_registration_version=Version
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest=Registration Request
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_id=Id
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_version=Version
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_name=Name
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_cpf=CPF
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_phone=Phone
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_email=Email
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_entryyear=Entry Year
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_entryperiod=Entry Period
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_requestkind=Request kind
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_requestdate=Request date
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_iswritingthesis=Is Writing Thesis
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_scholarshipcandidate=Scholarship Candidate
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_isworking=Is Working
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_poscomp=PSCOMP
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_observations=Observations
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_sectionpos1=Section 1
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_sectionpos2=Section 2
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_sectionpos3=Section 3
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_sectionpos4=Section 4
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest_sectionpos5=Section 5
label_br_ufpr_c3sl_sapos_models_scholar_subscription=Subscription
label_br_ufpr_c3sl_sapos_models_scholar_subscription_id=Id
label_br_ufpr_c3sl_sapos_models_scholar_subscription_plural=Subscriptions
......
......@@ -320,6 +320,30 @@ label_br_ufpr_c3sl_sapos_models_scholar_registration_student=Discente
label_br_ufpr_c3sl_sapos_models_scholar_registration_studentgrants=Bolsas Discentes
label_br_ufpr_c3sl_sapos_models_scholar_registration_transcripts=Avaliaes
label_br_ufpr_c3sl_sapos_models_scholar_registration_version=Version
label_br_ufpr_c3sl_sapos_models_scholar_registrationrequest=Requisio de matrcula