Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.gov.al.saude.srv.model; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 4 | import java.util.Date; |
||
| 5 | import java.util.HashSet; |
||
| 6 | import java.util.Set; |
||
| 7 | |||
| 8 | import javax.persistence.CascadeType; |
||
| 9 | import javax.persistence.Column; |
||
| 10 | import javax.persistence.Entity; |
||
| 11 | import javax.persistence.GeneratedValue; |
||
| 12 | import javax.persistence.GenerationType; |
||
| 13 | import javax.persistence.Id; |
||
| 14 | import javax.persistence.Inheritance; |
||
| 15 | import javax.persistence.InheritanceType; |
||
| 16 | import javax.persistence.JoinColumn; |
||
| 17 | import javax.persistence.ManyToOne; |
||
| 18 | import javax.persistence.OneToMany; |
||
| 19 | import javax.persistence.OneToOne; |
||
| 20 | import javax.persistence.SequenceGenerator; |
||
| 21 | import javax.persistence.Table; |
||
| 22 | import javax.persistence.Temporal; |
||
| 23 | import javax.persistence.TemporalType; |
||
| 24 | import javax.persistence.Transient; |
||
| 25 | import javax.validation.Valid; |
||
| 26 | import javax.validation.constraints.NotNull; |
||
| 27 | import org.hibernate.envers.AuditTable; |
||
| 28 | import org.hibernate.envers.Audited; |
||
| 29 | import org.hibernate.envers.RelationTargetAuditMode; |
||
| 30 | import br.gov.al.saude.framework.core.generic.identidade.Identidade; |
||
| 31 | import br.gov.al.saude.framework.core.interfaces.Alterar; |
||
| 32 | import br.gov.al.saude.framework.core.interfaces.Cadastrar; |
||
| 33 | import br.gov.al.saude.framework.model.SetorView; |
||
| 34 | |||
| 35 | @Audited |
||
| 36 | @AuditTable(value="srv_hist_servidor_dadofuncional", schema="sc_srv") |
||
| 37 | @Entity |
||
| 38 | @Table(name = "srv_servidor_dadofuncional", schema = "sc_srv") |
||
| 39 | @Inheritance(strategy=InheritanceType.JOINED) |
||
| 40 | public class ServidorDadoFuncional implements Serializable, Identidade, Comparable<ServidorDadoFuncional> { |
||
| 41 | private static final long serialVersionUID = 1L; |
||
| 42 | |||
| 43 | private Long sequencial; |
||
| 44 | private FormaIngresso formaIngresso; |
||
| 45 | private Date dataInicio; |
||
| 46 | private Integer cargaHoraria; |
||
| 47 | private Orgao orgaoLotacao; |
||
| 48 | private Unidade unidadeLotacao; |
||
| 49 | private Servidor servidor; |
||
| 50 | private Especialidade especialidade; |
||
| 51 | private SetorView setorView; |
||
| 52 | private ServidorDadoFuncionalConselho servidorDadoFuncionalConselho; |
||
| 53 | private Set<EventoServidorDadoFuncional> eventosServidorDadoFuncional = new HashSet<EventoServidorDadoFuncional>(); |
||
| 54 | |||
| 55 | public ServidorDadoFuncional() {} |
||
| 56 | |||
| 57 | public ServidorDadoFuncional(Servidor servidor) { |
||
| 58 | this.servidor = servidor; |
||
| 59 | } |
||
| 60 | |||
| 61 | @Id |
||
| 62 | @Column(name="seq_servidor_dadofuncional", nullable=false) |
||
| 63 | @GeneratedValue(generator = "SERVIDOR_DADO_FUNCIONAL_GENERATOR", strategy = GenerationType.SEQUENCE) |
||
| 64 | @SequenceGenerator(name = "SERVIDOR_DADO_FUNCIONAL_GENERATOR", sequenceName = "sc_srv.sq_servdadofunc", initialValue = 1, allocationSize = 1) |
||
| 65 | public Long getSequencial() { |
||
| 66 | return sequencial; |
||
| 67 | } |
||
| 68 | public void setSequencial(Long sequencial) { |
||
| 69 | this.sequencial = sequencial; |
||
| 70 | } |
||
| 71 | |||
| 72 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 73 | @ManyToOne |
||
| 74 | @JoinColumn(name="cod_forma_ingresso", referencedColumnName="cod_forma_ingresso", nullable=false) |
||
| 75 | @NotNull(message="Obrigatório informar a forma de ingresso.", groups={Cadastrar.class, Alterar.class}) |
||
| 76 | public FormaIngresso getFormaIngresso() { |
||
| 77 | return formaIngresso; |
||
| 78 | } |
||
| 79 | public void setFormaIngresso(FormaIngresso formaIngresso) { |
||
| 80 | this.formaIngresso = formaIngresso; |
||
| 81 | } |
||
| 82 | |||
| 83 | @Temporal(TemporalType.DATE) |
||
| 84 | @Column(name="dat_inicio", nullable=false) |
||
| 85 | @NotNull(message="Obrigatório informar a data de início (data de admissão).", groups={Cadastrar.class, Alterar.class}) |
||
| 86 | public Date getDataInicio() { |
||
| 87 | return dataInicio; |
||
| 88 | } |
||
| 89 | public void setDataInicio(Date dataInicio) { |
||
| 90 | this.dataInicio = dataInicio; |
||
| 91 | } |
||
| 92 | |||
| 93 | @Column(name="num_carga_horaria", nullable=false, length=2) |
||
| 94 | @NotNull(message="Obrigatório informar a carga horária.", groups={Cadastrar.class, Alterar.class}) |
||
| 95 | public Integer getCargaHoraria() { |
||
| 96 | return cargaHoraria; |
||
| 97 | } |
||
| 98 | public void setCargaHoraria(Integer cargaHoraria) { |
||
| 99 | this.cargaHoraria = cargaHoraria; |
||
| 100 | } |
||
| 101 | |||
| 102 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 103 | @ManyToOne |
||
| 104 | @JoinColumn(name="seq_orgao_lotacao", referencedColumnName="seq_orgao", nullable=false) |
||
| 105 | @NotNull(message="Obrigatório informar o órgão de lotação.", groups={Cadastrar.class, Alterar.class}) |
||
| 106 | public Orgao getOrgaoLotacao() { |
||
| 107 | return orgaoLotacao; |
||
| 108 | } |
||
| 109 | public void setOrgaoLotacao(Orgao orgaoLotacao) { |
||
| 110 | this.orgaoLotacao = orgaoLotacao; |
||
| 111 | } |
||
| 112 | |||
| 113 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 114 | @ManyToOne |
||
| 115 | @JoinColumn(name="cod_unidade_lotacao", referencedColumnName="cod_unidade", nullable=false) |
||
| 116 | @NotNull(message="Obrigatório informar a unidade de lotação.", groups={Cadastrar.class, Alterar.class}) |
||
| 117 | public Unidade getUnidadeLotacao() { |
||
| 118 | return unidadeLotacao; |
||
| 119 | } |
||
| 120 | public void setUnidadeLotacao(Unidade unidadeLotacao) { |
||
| 121 | this.unidadeLotacao = unidadeLotacao; |
||
| 122 | } |
||
| 123 | |||
| 124 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 125 | @ManyToOne |
||
| 126 | @JoinColumn(name="cod_especialidade", referencedColumnName="cod_especialidade") |
||
| 127 | public Especialidade getEspecialidade() { |
||
| 128 | return especialidade; |
||
| 129 | } |
||
| 130 | public void setEspecialidade(Especialidade especialidade) { |
||
| 131 | this.especialidade = especialidade; |
||
| 132 | } |
||
| 133 | |||
| 134 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 135 | @ManyToOne |
||
| 136 | @JoinColumn(name="cod_localidade_setor", referencedColumnName="cod_localidade") |
||
| 137 | public SetorView getSetorView() { |
||
| 138 | return setorView; |
||
| 139 | } |
||
| 140 | public void setSetorView(SetorView setorView) { |
||
| 141 | this.setorView = setorView; |
||
| 142 | } |
||
| 143 | |||
| 144 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 145 | @Valid |
||
| 146 | @OneToOne(mappedBy="servidorDadoFuncional", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 147 | public ServidorDadoFuncionalConselho getServidorDadoFuncionalConselho() { |
||
| 148 | return servidorDadoFuncionalConselho; |
||
| 149 | } |
||
| 150 | |||
| 151 | public void setServidorDadoFuncionalConselho(ServidorDadoFuncionalConselho servidorDadoFuncionalConselho) { |
||
| 152 | this.servidorDadoFuncionalConselho = servidorDadoFuncionalConselho; |
||
| 153 | } |
||
| 154 | |||
| 155 | @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) |
||
| 156 | @ManyToOne |
||
| 157 | @JoinColumn(name="seq_pessoa_servidor", referencedColumnName="seq_pessoa_servidor", nullable=false) |
||
| 158 | public Servidor getServidor() { |
||
| 159 | return servidor; |
||
| 160 | } |
||
| 161 | public void setServidor(Servidor servidor) { |
||
| 162 | this.servidor = servidor; |
||
| 163 | } |
||
| 164 | |||
| 165 | @OneToMany(mappedBy="servidorDadoFuncional", cascade=CascadeType.ALL, orphanRemoval=true) |
||
| 166 | public Set<EventoServidorDadoFuncional> getEventosServidorDadoFuncional() { |
||
| 167 | return eventosServidorDadoFuncional; |
||
| 168 | } |
||
| 169 | |||
| 170 | public void setEventosServidorDadoFuncional(Set<EventoServidorDadoFuncional> eventosServidorDadoFuncional) { |
||
| 171 | this.eventosServidorDadoFuncional = eventosServidorDadoFuncional; |
||
| 172 | } |
||
| 173 | |||
| 174 | @Transient |
||
| 175 | @Override |
||
| 176 | public Object getId() { |
||
| 177 | return this.sequencial; |
||
| 178 | } |
||
| 179 | @Override |
||
| 180 | public void setId(Object id) { |
||
| 181 | this.sequencial = (Long) id; |
||
| 182 | } |
||
| 183 | |||
| 184 | @Override |
||
| 185 | public int hashCode() { |
||
| 186 | final int prime = 31; |
||
| 187 | int result = 1; |
||
| 188 | result = prime * result |
||
| 189 | + ((sequencial == null) ? 0 : sequencial.hashCode()); |
||
| 190 | result = prime * result |
||
| 191 | + ((servidor == null) ? 0 : servidor.hashCode()); |
||
| 192 | return result; |
||
| 193 | } |
||
| 194 | |||
| 195 | @Override |
||
| 196 | public boolean equals(Object obj) { |
||
| 197 | if (this == obj) |
||
| 198 | return true; |
||
| 199 | if (obj == null) |
||
| 200 | return false; |
||
| 201 | if (!(obj instanceof ServidorDadoFuncional)) |
||
| 202 | return false; |
||
| 203 | ServidorDadoFuncional other = (ServidorDadoFuncional) obj; |
||
| 204 | if (sequencial == null) { |
||
| 205 | if (other.sequencial != null) |
||
| 206 | return false; |
||
| 207 | } else if (!sequencial.equals(other.sequencial)) |
||
| 208 | return false; |
||
| 209 | if (servidor == null) { |
||
| 210 | if (other.servidor != null) |
||
| 211 | return false; |
||
| 212 | } else if (!servidor.equals(other.servidor)) |
||
| 213 | return false; |
||
| 214 | return true; |
||
| 215 | } |
||
| 216 | |||
| 217 | @Override |
||
| 218 | public int compareTo(ServidorDadoFuncional sdf) { |
||
| 219 | return getSequencial().compareTo(sdf.getSequencial()); |
||
| 220 | } |
||
| 221 | |||
| 222 | } |