Commit c15b69e2 authored by Fabiano Sluzarski's avatar Fabiano Sluzarski
Browse files

Recommendation added. File upload on Subscription and Recommendation

created when a new Subscription is added.
parent dc9640bc
package br.ufpr.c3sl.sapos.models.scholar;
import javax.persistence.Column;
import javax.persistence.OneToOne;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
@RooJavaBean
@RooToString
@RooEntity
public class Recommendation {
private String name;
private String phone;
private String institution;
private String mailAddress;
private String email;
/* 1) Em que condição conheceu o candidato? (professor, orientador, chefe, etc) */
private String candidateOrigin;
/* 2) Como você qualificaria o desempenho do candidato na(s) atividade(s) descrita(s) na questão anterior? */
@Column(columnDefinition="text")
private String progress;
/* 3) O que você pode dizer sobre as qualificações do candidato para a Pós-Graduação (doutorado)? */
@Column(columnDefinition="text")
private String qualifications;
/* 4) Classifique o candidato nos quesitos abaixo de acordo com a escala de 0 a 10, onde 10 (dez) equivale a excelente e 0 (zero) a péssimo:
* Interesse:
* Persistência:
* Capacidade intelectual:
* Relacionamento com colegas e professores:
* Capacidade de expressão oral:
* Capacidade de expressão escrita: */
private String interest;
private String persistence;
private String intelectualCapability;
private String relationshipCoWorkers;
private String vocalExpression;
private String writingExpression;
/* 5) Descreva o potencial e a habilidade do candidato para uma carreira científica (uma descrição de pontos positivos e negativos é mais útil que comentários genéricos). */
@Column(columnDefinition="text")
private String potencialSkill;
@OneToOne (optional=true)
private Subscription subscription;
}
// 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 Recommendation_Roo_Configurable {
declare @type: Recommendation: @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 Recommendation_Roo_Entity {
declare @type: Recommendation: @Entity;
@PersistenceContext
transient EntityManager Recommendation.entityManager;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long Recommendation.id;
@Version
@Column(name = "version")
private Integer Recommendation.version;
public Long Recommendation.getId() {
return this.id;
}
public void Recommendation.setId(Long id) {
this.id = id;
}
public Integer Recommendation.getVersion() {
return this.version;
}
public void Recommendation.setVersion(Integer version) {
this.version = version;
}
@Transactional
public void Recommendation.persist() {
if (this.entityManager == null) this.entityManager = entityManager();
this.entityManager.persist(this);
}
@Transactional
public void Recommendation.remove() {
if (this.entityManager == null) this.entityManager = entityManager();
if (this.entityManager.contains(this)) {
this.entityManager.remove(this);
} else {
Recommendation attached = Recommendation.findRecommendation(this.id);
this.entityManager.remove(attached);
}
}
@Transactional
public void Recommendation.flush() {
if (this.entityManager == null) this.entityManager = entityManager();
this.entityManager.flush();
}
@Transactional
public void Recommendation.clear() {
if (this.entityManager == null) this.entityManager = entityManager();
this.entityManager.clear();
}
@Transactional
public Recommendation Recommendation.merge() {
if (this.entityManager == null) this.entityManager = entityManager();
Recommendation merged = this.entityManager.merge(this);
this.entityManager.flush();
return merged;
}
public static final EntityManager Recommendation.entityManager() {
EntityManager em = new Recommendation().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 Recommendation.countRecommendations() {
return entityManager().createQuery("SELECT COUNT(o) FROM Recommendation o", Long.class).getSingleResult();
}
public static List<Recommendation> Recommendation.findAllRecommendations() {
return entityManager().createQuery("SELECT o FROM Recommendation o", Recommendation.class).getResultList();
}
public static Recommendation Recommendation.findRecommendation(Long id) {
if (id == null) return null;
return entityManager().find(Recommendation.class, id);
}
public static List<Recommendation> Recommendation.findRecommendationEntries(int firstResult, int maxResults) {
return entityManager().createQuery("SELECT o FROM Recommendation o", Recommendation.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;
privileged aspect Recommendation_Roo_JavaBean {
public String Recommendation.getName() {
return this.name;
}
public void Recommendation.setName(String name) {
this.name = name;
}
public String Recommendation.getInstitution() {
return this.institution;
}
public void Recommendation.setInstitution(String institution) {
this.institution = institution;
}
public String Recommendation.getPhone() {
return this.phone;
}
public void Recommendation.setPhone(String phone) {
this.phone = phone;
}
public String Recommendation.getMailAddress() {
return this.mailAddress;
}
public void Recommendation.setMailAddress(String mailAddress) {
this.mailAddress = mailAddress;
}
public String Recommendation.getEmail() {
return this.email;
}
public void Recommendation.setEmail(String email) {
this.email = email;
}
public String Recommendation.getCandidateOrigin() {
return this.candidateOrigin;
}
public void Recommendation.setCandidateOrigin(String candidateOrigin) {
this.candidateOrigin = candidateOrigin;
}
public String Recommendation.getProgress() {
return this.progress;
}
public void Recommendation.setProgress(String progress) {
this.progress = progress;
}
public String Recommendation.getQualifications() {
return this.qualifications;
}
public void Recommendation.setQualifications(String qualifications) {
this.qualifications = qualifications;
}
public String Recommendation.getInterest() {
return this.interest;
}
public void Recommendation.setInterest(String interest) {
this.interest = interest;
}
public String Recommendation.getPersistence() {
return this.persistence;
}
public void Recommendation.setPersistence(String persistence) {
this.persistence = persistence;
}
public String Recommendation.getIntelectualCapability() {
return this.intelectualCapability;
}
public void Recommendation.setIntelectualCapability(String intelectualCapability) {
this.intelectualCapability = intelectualCapability;
}
public String Recommendation.getRelationshipCoWorkers() {
return this.relationshipCoWorkers;
}
public void Recommendation.setRelationshipCoWorkers(String relationshipCoWorkers) {
this.relationshipCoWorkers = relationshipCoWorkers;
}
public String Recommendation.getVocalExpression() {
return this.vocalExpression;
}
public void Recommendation.setVocalExpression(String vocalExpression) {
this.vocalExpression = vocalExpression;
}
public String Recommendation.getWritingExpression() {
return this.writingExpression;
}
public void Recommendation.setWritingExpression(String writingExpression) {
this.writingExpression = writingExpression;
}
public String Recommendation.getPotencialSkill() {
return this.potencialSkill;
}
public void Recommendation.setPotencialSkill(String potencialSkill) {
this.potencialSkill = potencialSkill;
}
public Subscription Recommendation.getSubscription() {
return this.subscription;
}
public void Recommendation.setSubscription(Subscription subscription) {
this.subscription = subscription;
}
}
// 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;
privileged aspect Recommendation_Roo_ToString {
public String Recommendation.toString() {
StringBuilder sb = new StringBuilder();
sb.append("Email: ").append(getEmail()).append(", ");
sb.append("Name: ").append(getName()).append(", ");
sb.append("MailAddress: ").append(getMailAddress()).append(", ");
sb.append("Phone: ").append(getPhone());
return sb.toString();
}
}
......@@ -115,7 +115,8 @@ public class Registration {
private String pageNumbers;
@Column(columnDefinition="alter table Registration change resume resume text")
//@Column(columnDefinition="alter table Registration change resume resume text")
@Column(columnDefinition="text")
private String resume;
private String jobKind;
......
......@@ -48,8 +48,10 @@ public class Subscription {
//@Lob
//@Basic(fetch = FetchType.LAZY)
//private byte[] files;
@OneToMany(cascade = CascadeType.ALL)
private Set<Document> documents = new HashSet<Document>();
//@OneToMany(cascade = CascadeType.ALL)
//private Set<Document> documents = new HashSet<Document>();
@OneToOne (optional=false)
private Document document;
//header
//1) Dados Pessoais
......@@ -157,7 +159,8 @@ public class Subscription {
private String professor3;
private String emailRec3;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "subscription")
private Set<Recommendation> recommendations = new HashSet<Recommendation>();
}
......@@ -4,6 +4,7 @@
package br.ufpr.c3sl.sapos.models.scholar;
import java.util.Date;
import java.util.Set;
import br.ufpr.c3sl.sapos.models.location.City;
import br.ufpr.c3sl.sapos.models.location.FederalState;
......@@ -56,13 +57,20 @@ privileged aspect Subscription_Roo_JavaBean {
}
//--
public java.util.Set<Document> Subscription.getDocuments() {
/*public java.util.Set<Document> Subscription.getDocuments() {
return this.documents;
}
public void Subscription.setDocuments(java.util.Set<Document> documents) {
this.documents = documents;
}
}*/
public Document Subscription.getDocument() {
return this.document;
}
public void Subscription.setDocument(Document document) {
this.document = document;
}
//---
public String Subscription.getName() {
......@@ -385,5 +393,13 @@ privileged aspect Subscription_Roo_JavaBean {
public void Subscription.setEmailRec3(String emailRec3) {
this.emailRec3 = emailRec3;
}
public Set<Recommendation> Subscription.getRecommendations() {
return this.recommendations;
}
public void Subscription.setRecommendations(Set<Recommendation> recommendations) {
this.recommendations = recommendations;
}
}
package br.ufpr.c3sl.sapos.web;
import org.springframework.roo.addon.web.mvc.controller.RooWebScaffold;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import br.ufpr.c3sl.sapos.models.scholar.Recommendation;
@RooWebScaffold(path = "recommendations", formBackingObject = Recommendation.class)
@RequestMapping("/recommendations")
@Controller
public class RecommendationController {
}
// 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 javax.validation.Valid;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.util.UriUtils;
import org.springframework.web.util.WebUtils;
import br.ufpr.c3sl.sapos.models.scholar.Recommendation;
privileged aspect RecommendationController_Roo_Controller {
@RequestMapping(method = RequestMethod.POST)
public String RecommendationController.create(@Valid Recommendation recommendation, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
if (bindingResult.hasErrors()) {
uiModel.addAttribute("recommendation", recommendation);
return "recommendations/create";
}
uiModel.asMap().clear();
recommendation.persist();
return "redirect:/recommendations/" + encodeUrlPathSegment(recommendation.getId().toString(), httpServletRequest);
}
@RequestMapping(params = "form", method = RequestMethod.GET)
public String RecommendationController.createForm(Model uiModel) {
uiModel.addAttribute("recommendation", new Recommendation());
return "recommendations/create";
}
@RequestMapping(method = RequestMethod.GET)
public String RecommendationController.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("recommendations", Recommendation.findRecommendationEntries(page == null ? 0 : (page.intValue() - 1) * sizeNo, sizeNo));
float nrOfPages = (float) Recommendation.countRecommendations() / sizeNo;
uiModel.addAttribute("maxPages", (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
} else {
uiModel.addAttribute("recommendations", Recommendation.findAllRecommendations());
}
return "recommendations/list";
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String RecommendationController.show(@PathVariable("id") Long id, Model uiModel) {
uiModel.addAttribute("recommendation", Recommendation.findRecommendation(id));
uiModel.addAttribute("itemId", id);
return "recommendations/show";
}
@RequestMapping(method = RequestMethod.PUT)
public String RecommendationController.update(@Valid Recommendation recommendation, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
if (bindingResult.hasErrors()) {
uiModel.addAttribute("recommendation", recommendation);
return "recommendations/update";
}
uiModel.asMap().clear();
recommendation.merge();
return "redirect:/recommendations/" + encodeUrlPathSegment(recommendation.getId().toString(), httpServletRequest);
}
@RequestMapping(value = "/{id}", params = "form", method = RequestMethod.GET)
public String RecommendationController.updateForm(@PathVariable("id") Long id, Model uiModel) {
uiModel.addAttribute("recommendation", Recommendation.findRecommendation(id));
return "recommendations/update";
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public String RecommendationController.delete(@PathVariable("id") Long id, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
Recommendation.findRecommendation(id).remove();
uiModel.asMap().clear();
uiModel.addAttribute("page", (page == null) ? "1" : page.toString());
uiModel.addAttribute("size", (size == null) ? "10" : size.toString());
return "redirect:/recommendations";
}
String RecommendationController.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;
}
}
package br.ufpr.c3sl.sapos.web;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.roo.addon.web.mvc.controller.RooWebScaffold;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;