Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.edu.cesmac.sic.core.domain.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.HashSet; |
||
| 5 | import java.util.Set; |
||
| 6 | |||
| 7 | import javax.persistence.CascadeType; |
||
| 8 | import javax.persistence.Column; |
||
| 9 | import javax.persistence.Entity; |
||
| 10 | import javax.persistence.GeneratedValue; |
||
| 11 | import javax.persistence.GenerationType; |
||
| 12 | import javax.persistence.Id; |
||
| 13 | import javax.persistence.JoinColumn; |
||
| 14 | import javax.persistence.ManyToOne; |
||
| 15 | import javax.persistence.OneToMany; |
||
| 16 | import javax.persistence.Table; |
||
| 17 | import javax.persistence.Transient; |
||
| 18 | import javax.validation.Valid; |
||
| 19 | import javax.validation.constraints.NotNull; |
||
| 20 | |||
| 21 | import org.hibernate.envers.AuditTable; |
||
| 22 | import org.hibernate.envers.Audited; |
||
| 23 | import org.hibernate.envers.RelationTargetAuditMode; |
||
| 24 | import org.hibernate.validator.constraints.NotEmpty; |
||
| 25 | |||
| 26 | import br.edu.cesmac.core.interfaces.Alterar; |
||
| 27 | import br.edu.cesmac.core.interfaces.Cadastrar; |
||
| 28 | import br.edu.cesmac.core.util.StringUtil; |
||
| 29 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 30 | import br.edu.cesmac.sac.shared.views.CursoView; |
||
| 31 | import br.edu.cesmac.sca.shared.views.UsuarioView; |
||
| 32 | import br.edu.cesmac.sic.core.domain.model.tipo.TipoDocumentoProjeto; |
||
| 33 | import br.edu.cesmac.sic.core.domain.model.tipo.TipoSituacaoInscricao; |
||
| 34 | |||
| 35 | @Audited |
||
| 36 | @AuditTable(value="sic_aud_projeto_pesquisa", schema="admsic001") |
||
| 37 | @Entity |
||
| 38 | @Table(name="sic_projeto_pesquisa", schema="admsic001") |
||
| 39 | public class ProjetoPesquisa implements Serializable { |
||
| 40 | |||
| 41 | private static final long serialVersionUID = 1L; |
||
| 42 | |||
| 43 | private Long sequencial; |
||
| 44 | private ProcessoSeletivo processoSeletivo; |
||
| 45 | private String titulo; |
||
| 46 | private CursoView curso; |
||
| 47 | private Area area; |
||
| 48 | private Set<ProjetoPesquisaAluno> discentes = new HashSet<ProjetoPesquisaAluno>(); |
||
| 49 | private Set<ProjetoPesquisaOrientador> orientadores = new HashSet<ProjetoPesquisaOrientador>(); |
||
| 50 | private Set<ProjetoPesquisaAvaliador> avaliadores = new HashSet<ProjetoPesquisaAvaliador>(); |
||
| 51 | private Set<ArquivoProjeto> arquivos = new HashSet<ArquivoProjeto>(); |
||
| 52 | private String emailContato; |
||
| 53 | private String observacao; |
||
| 54 | private String tipoSituacaoInscricao; |
||
| 55 | private Boolean indicadorProjetoCienciaTecnologia; |
||
| 56 | private Boolean indicadorAprovado; |
||
| 57 | |||
| 58 | @Id |
||
| 59 | @GeneratedValue(strategy=GenerationType.AUTO) |
||
| 60 | @Column(name="seq_projeto_pesquisa", nullable=false) |
||
| 61 | public Long getSequencial() { |
||
| 62 | return sequencial; |
||
| 63 | } |
||
| 64 | |||
| 65 | public void setSequencial(Long sequencial) { |
||
| 66 | this.sequencial = sequencial; |
||
| 67 | } |
||
| 68 | |||
| 69 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 70 | @ManyToOne |
||
| 71 | @NotNull(message="Obrigatório informar o processo seletivo", groups={Cadastrar.class, Alterar.class}) |
||
| 72 | @JoinColumn(name="seq_processo_seletivo", referencedColumnName="seq_processo_seletivo", nullable=false) |
||
| 73 | public ProcessoSeletivo getProcessoSeletivo() { |
||
| 74 | return processoSeletivo; |
||
| 75 | } |
||
| 76 | |||
| 77 | public void setProcessoSeletivo(ProcessoSeletivo processoSeletivo) { |
||
| 78 | this.processoSeletivo = processoSeletivo; |
||
| 79 | } |
||
| 80 | |||
| 81 | @NotNull(message="Obrigatório informar o título", groups={Cadastrar.class, Alterar.class}) |
||
| 82 | @NotEmpty(message="Obrigatório informar o título", groups={Cadastrar.class, Alterar.class}) |
||
| 83 | @Column(name="dsc_titulo", nullable=false) |
||
| 84 | public String getTitulo() { |
||
| 85 | return titulo; |
||
| 86 | } |
||
| 87 | |||
| 88 | public void setTitulo(String titulo) { |
||
| 89 | this.titulo = StringUtil.setarUpperCase(titulo); |
||
| 90 | } |
||
| 91 | |||
| 92 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 93 | @ManyToOne |
||
| 94 | @NotNull(message="Obrigatório informar o curso", groups={Cadastrar.class, Alterar.class}) |
||
| 95 | @JoinColumn(name="seq_curso", referencedColumnName="seq_curso") |
||
| 96 | public CursoView getCurso() { |
||
| 97 | return curso; |
||
| 98 | } |
||
| 99 | |||
| 100 | public void setCurso(CursoView curso) { |
||
| 101 | this.curso = curso; |
||
| 102 | } |
||
| 103 | |||
| 104 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 105 | @ManyToOne |
||
| 106 | @NotNull(message="Obrigatório informar a área", groups={Cadastrar.class, Alterar.class}) |
||
| 107 | @JoinColumn(name="cod_area", referencedColumnName="cod_area") |
||
| 108 | public Area getArea() { |
||
| 109 | return area; |
||
| 110 | } |
||
| 111 | |||
| 112 | public void setArea(Area area) { |
||
| 113 | this.area = area; |
||
| 114 | } |
||
| 115 | |||
| 116 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 117 | @Valid |
||
| 118 | @OneToMany(mappedBy="projetoPesquisa", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 119 | public Set<ProjetoPesquisaAluno> getDiscentes() { |
||
| 120 | return discentes; |
||
| 121 | } |
||
| 122 | |||
| 123 | public void setDiscentes(Set<ProjetoPesquisaAluno> discentes) { |
||
| 124 | this.discentes = discentes; |
||
| 125 | } |
||
| 126 | |||
| 127 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 128 | @Valid |
||
| 129 | @OneToMany(mappedBy="projetoPesquisa", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 130 | public Set<ProjetoPesquisaOrientador> getOrientadores() { |
||
| 131 | return orientadores; |
||
| 132 | } |
||
| 133 | |||
| 134 | public void setOrientadores(Set<ProjetoPesquisaOrientador> orientadores) { |
||
| 135 | this.orientadores = orientadores; |
||
| 136 | } |
||
| 137 | |||
| 138 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 139 | @Valid |
||
| 140 | @OneToMany(mappedBy="projetoPesquisa", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 141 | public Set<ProjetoPesquisaAvaliador> getAvaliadores() { |
||
| 142 | return avaliadores; |
||
| 143 | } |
||
| 144 | |||
| 145 | public void setAvaliadores(Set<ProjetoPesquisaAvaliador> avaliadores) { |
||
| 146 | this.avaliadores = avaliadores; |
||
| 147 | } |
||
| 148 | |||
| 149 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 150 | @Valid |
||
| 151 | @OneToMany(mappedBy="projetoPesquisa", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 152 | public Set<ArquivoProjeto> getArquivos() { |
||
| 153 | return arquivos; |
||
| 154 | } |
||
| 155 | |||
| 156 | public void setArquivos(Set<ArquivoProjeto> arquivos) { |
||
| 157 | this.arquivos = arquivos; |
||
| 158 | } |
||
| 159 | |||
| 160 | @NotNull(message="Obrigatório informar o email para contato", groups={Cadastrar.class, Alterar.class}) |
||
| 161 | @NotEmpty(message="Obrigatório informar o email para contato", groups={Cadastrar.class, Alterar.class}) |
||
| 162 | @Column(name="dsc_email_contato", nullable=false) |
||
| 163 | public String getEmailContato() { |
||
| 164 | return emailContato; |
||
| 165 | } |
||
| 166 | |||
| 167 | public void setEmailContato(String emailContato) { |
||
| 168 | this.emailContato = emailContato; |
||
| 169 | } |
||
| 170 | |||
| 171 | @Column(name="dsc_observacao") |
||
| 172 | public String getObservacao() { |
||
| 173 | return observacao; |
||
| 174 | } |
||
| 175 | |||
| 176 | public void setObservacao(String observacao) { |
||
| 177 | this.observacao = StringUtil.setarUpperCase(observacao); |
||
| 178 | } |
||
| 179 | |||
| 180 | @NotNull(message="Obrigatório informar a situação da inscrição", groups={Cadastrar.class, Alterar.class}) |
||
| 181 | @NotEmpty(message="Obrigatório informar a situação da inscrição", groups={Cadastrar.class, Alterar.class}) |
||
| 182 | @Column(name="tip_situacao_inscricao") |
||
| 183 | public String getTipoSituacaoInscricao() { |
||
| 184 | return tipoSituacaoInscricao; |
||
| 185 | } |
||
| 186 | |||
| 187 | public void setTipoSituacaoInscricao(String tipoSituacaoInscricao) { |
||
| 188 | this.tipoSituacaoInscricao = tipoSituacaoInscricao; |
||
| 189 | } |
||
| 190 | |||
| 191 | @NotNull(message="Obrigatório informar o indicador de Projeto de Ciência e Tecnologia", groups={Cadastrar.class, Alterar.class}) |
||
| 192 | @Column(name="ind_projcienciastec", nullable=false) |
||
| 193 | public Boolean getIndicadorProjetoCienciaTecnologia() { |
||
| 194 | return indicadorProjetoCienciaTecnologia; |
||
| 195 | } |
||
| 196 | |||
| 197 | public void setIndicadorProjetoCienciaTecnologia(Boolean indicadorProjetoCienciaTecnologia) { |
||
| 198 | this.indicadorProjetoCienciaTecnologia = indicadorProjetoCienciaTecnologia; |
||
| 199 | } |
||
| 200 | |||
| 201 | @Column(name="ind_aprovado") |
||
| 202 | public Boolean getIndicadorAprovado() { |
||
| 203 | return indicadorAprovado; |
||
| 204 | } |
||
| 205 | |||
| 206 | public void setIndicadorAprovado(Boolean indicadorAprovado) { |
||
| 207 | this.indicadorAprovado = indicadorAprovado; |
||
| 208 | } |
||
| 209 | |||
| 210 | @Override |
||
| 211 | public int hashCode() { |
||
| 212 | final int prime = 31; |
||
| 213 | int result = 1; |
||
| 214 | result = prime * result + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 215 | return result; |
||
| 216 | } |
||
| 217 | |||
| 218 | @Override |
||
| 219 | public boolean equals(Object obj) { |
||
| 220 | if (this == obj) |
||
| 221 | return true; |
||
| 222 | if (obj == null) |
||
| 223 | return false; |
||
| 224 | if (getClass() != obj.getClass()) |
||
| 225 | return false; |
||
| 226 | ProjetoPesquisa other = (ProjetoPesquisa) obj; |
||
| 227 | if (sequencial == null) { |
||
| 228 | if (other.sequencial != null) |
||
| 229 | return false; |
||
| 230 | } else if (!sequencial.equals(other.sequencial)) |
||
| 231 | return false; |
||
| 232 | return true; |
||
| 233 | } |
||
| 234 | |||
| 235 | @Transient |
||
| 236 | public Long getSequencialDoProcessoSeletivo() { |
||
| 237 | return VerificadorUtil.naoEstaNulo(processoSeletivo)? getProcessoSeletivo().getSequencial() : null; |
||
| 238 | } |
||
| 239 | |||
| 240 | @Transient |
||
| 241 | public String getDescricaoDoProcessoSeletivo() { |
||
| 242 | return VerificadorUtil.naoEstaNulo(processoSeletivo)? getProcessoSeletivo().getDescricao() : null; |
||
| 243 | } |
||
| 244 | |||
| 245 | @Transient |
||
| 246 | public ArquivoProjeto getArquivoProjeto() { |
||
| 247 | if (VerificadorUtil.naoEstaNuloOuVazio(getArquivos())) { |
||
| 248 | for(ArquivoProjeto arquivo : getArquivos()) { |
||
| 249 | if (arquivo.getTipoDocumentoProjeto().equals(TipoDocumentoProjeto.PROJETO.getValue())) { |
||
| 250 | return arquivo; |
||
| 251 | } |
||
| 252 | } |
||
| 253 | } |
||
| 254 | return null; |
||
| 255 | } |
||
| 256 | |||
| 257 | @Transient |
||
| 258 | public ArquivoProjeto getArquivoProjetoParaAvaliador() { |
||
| 259 | if (VerificadorUtil.naoEstaNuloOuVazio(getArquivos())) { |
||
| 260 | for(ArquivoProjeto arquivo : getArquivos()) { |
||
| 261 | if (arquivo.getTipoDocumentoProjeto().equals(TipoDocumentoProjeto.PROJETO_AVALIACAO.getValue())) { |
||
| 262 | return arquivo; |
||
| 263 | } |
||
| 264 | } |
||
| 265 | } |
||
| 266 | return null; |
||
| 267 | } |
||
| 268 | |||
| 269 | @Transient |
||
| 270 | public ProjetoPesquisaOrientador getOrientador() { |
||
| 271 | if (VerificadorUtil.naoEstaNuloOuVazio(getOrientadores())) { |
||
| 272 | for (ProjetoPesquisaOrientador orientador : getOrientadores()) { |
||
| 273 | if (!orientador.getIndicadorCoorientador()) { |
||
| 274 | return orientador; |
||
| 275 | } |
||
| 276 | } |
||
| 277 | } |
||
| 278 | return null; |
||
| 279 | } |
||
| 280 | |||
| 281 | @Transient |
||
| 282 | public ProjetoPesquisaOrientador getCoorientador() { |
||
| 283 | if (VerificadorUtil.naoEstaNuloOuVazio(getOrientadores())) { |
||
| 284 | for (ProjetoPesquisaOrientador orientador : getOrientadores()) { |
||
| 285 | if (orientador.getIndicadorCoorientador()) { |
||
| 286 | return orientador; |
||
| 287 | } |
||
| 288 | } |
||
| 289 | } |
||
| 290 | return null; |
||
| 291 | } |
||
| 292 | |||
| 293 | @Transient |
||
| 294 | public ProjetoPesquisaAluno getDiscenteBolsista() { |
||
| 295 | if (VerificadorUtil.naoEstaNuloOuVazio(getDiscentes())) { |
||
| 296 | for (ProjetoPesquisaAluno discente : getDiscentes()) { |
||
| 297 | if (discente.getIndicadorBolsista()) { |
||
| 298 | return discente; |
||
| 299 | } |
||
| 300 | } |
||
| 301 | } |
||
| 302 | return null; |
||
| 303 | } |
||
| 304 | |||
| 305 | @Transient |
||
| 306 | public String getDescricaoDoCurso() { |
||
| 307 | return VerificadorUtil.naoEstaNulo(getCurso())? getCurso().getDescricao(): null; |
||
| 308 | } |
||
| 309 | |||
| 310 | @Transient |
||
| 311 | public Boolean tipoSituacaoInscricaoEmAnalise() { |
||
| 312 | return getTipoSituacaoInscricao().equals(TipoSituacaoInscricao.ANALISE.getValue()); |
||
| 313 | } |
||
| 314 | |||
| 315 | @Transient |
||
| 316 | public Boolean tipoSituacaoInscricaoConfirmada() { |
||
| 317 | return getTipoSituacaoInscricao().equals(TipoSituacaoInscricao.CONFIRMADA.getValue()); |
||
| 318 | } |
||
| 319 | |||
| 320 | @Transient |
||
| 321 | public Boolean tipoSituacaoInscricaoComPendencia() { |
||
| 322 | return getTipoSituacaoInscricao().equals(TipoSituacaoInscricao.PENDENCIA.getValue()); |
||
| 323 | } |
||
| 324 | |||
| 325 | @Transient |
||
| 326 | public String getDescricaoDoTipoSituacaoInscricao() { |
||
| 327 | return TipoSituacaoInscricao.parse(getTipoSituacaoInscricao()).getDescricao(); |
||
| 328 | } |
||
| 329 | |||
| 330 | @Transient |
||
| 331 | public Boolean usuarioEhAvaliador(UsuarioView usuario) { |
||
| 332 | for (ProjetoPesquisaAvaliador avaliador : getAvaliadores()) { |
||
| 333 | if (avaliador.getSequencialDoAvaliador().equals(usuario.getPessoa().getSequencial())) { |
||
| 334 | return true; |
||
| 335 | } |
||
| 336 | } |
||
| 337 | return false; |
||
| 338 | } |
||
| 339 | |||
| 340 | @Transient |
||
| 341 | public Boolean aprovador() { |
||
| 342 | return VerificadorUtil.naoEstaNulo(getIndicadorAprovado())? getIndicadorAprovado() : false; |
||
| 343 | } |
||
| 344 | |||
| 345 | @Transient |
||
| 346 | public String getDescricaoDaArea() { |
||
| 347 | return VerificadorUtil.naoEstaNulo(getArea())? getArea().getDescricao() : null; |
||
| 348 | } |
||
| 349 | |||
| 350 | } |