- Governança-TIC
- 01. Estrutura do DTIC e Comitês
- 02. Estratégia de TIC
-
02. Plano Capacitação TIC
-
02. Plano Contratações TIC
- 02. Plano Diretor TIC
-
02. Plano Riscos TIC
-
02. Plano Transformação Digital
- 03. iGovTIC-JUD
- 03. Indicadores TIC
- 03. Pesquisa Satisfação TIC
-
04. Processos de TIC
-
1.01. Contratação de STIC
-
1.02. Processo do PETIC
-
1.03. Processo do PDTIC
-
1.04. Capacitação de TIC
-
1.05. Processo do PAT
-
1.06. Orçamentos de TIC
- 2.01. Gestão de Demandas TIC
-
2.02. Gestão de Projetos TIC
-
2.03. Gestão de Contratos TIC
-
3.01. Gestão de Riscos TIC
-
3.02. Continuidade de Serviços TIC
-
3.04. Processo de Backup / Restore
-
4.02. Sustentação de Software
-
5.01. Central de Serviços TIC
-
6.01. Pesquisa Satisfação Usuários de TIC
-
1.01. Contratação de STIC
- 05. Segurança de TIC
- 06. Portfólio de TIC
- Atendimento a Usuários
-
BI e Relatórios TIC
-
Catálogo de Serviços de TIC
- Modelos e sobre TI
- Normativos TIC
-
Rede sem fio (Wi-Fi)
- Videoconferência
As entidades de negócio serão representadas pelos JavaBeans simplesmente com as variáveis e seus acessores (propriedades).
As regras de negócio como contraints sobre os valores dos campos não devem ser posicionadas ao nível das entidades mas nos serviços das camadas de serviço e enterprise para que os objetos de negócio sejam o mais simples possível. De fato, o posicionamento de constraints poderá obstruir o mecanismo de persistência.
O métodos sob as entidades não realizarão tratamento algum. A única exceção aceita seria a presença de acessores de leitura correspondentes à atributos derivados, que correspondem aos valores calculados à partir dos verdadeiros atributos. Neste caso, os cálculos deverão continuar simples. Para casos específicos de formatação e/ou operações simples também podemos utilizar o padrão Decorator GoF sobre os JavaBeans.
Os métodos sob as entidade não deverão lançar exceção.
Implementação
Entidade de negócio
Abaixo um exemplo do código para uma classe JavaBean que será persistida (utilizando as anotações da persistência seguindo o padrão de persistência Java – JPA
package gov.tjpr.example.entity.bean;
import gov.tjpr.entity.PersistableEntity;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
/**
* Classe que representa a entidade persistente de um Example Bean
* Esta classe possui as anotações necessárias para que a JPA
* saiba como esta entidade deverá ser persistida no repositório.
* @author Luiz Henrique Grossl
* @version 1.0.0
* @since 03-aug-2006
* @see gov.tjpr.entity.PersistableEntity
*/
@Entity
@Table(name="TB001EXAMPLE_BEAN")
@SequenceGenerator(name="sequence", sequenceName="TB001_SEQUENCE")
//gov.tjpr.hibernate.id.StoredProcedureGenerator
public class ExampleBean implements PersistableEntity<Integer> {
// the date format conversion pattern
public static final DateFormat _DATE_FORMAT =
SimpleDateFormat.getDateInstance(DateFormat.SHORT);
private static final long serialVersionUID = 1L;
// the bean unique identificator
@Id @Column(name="TB001_ID")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="sequence")
private Integer id;
// the bean name
@Column(name="TB001_NAME", nullable=false)
private String name;
// the bean value
@Column(name="TB001_VALUE", nullable=false)
private String value;
// the bean creator e-mail
@Column(name="TB001_MAIL", nullable=false)
private String creatorMail;
// the bean edition date
@Column(name="TB001_DT_EDITION", nullable=false)
private Date editionDate = Calendar.getInstance().getTime();
// the bean cretion date
@Column(name="TB001_DT_CREATION", nullable=false)
private Date creationDate = Calendar.getInstance().getTime();
// the bean deploy date
@Column(name="TB001_DT_DEPLOYMENT", nullable=false)
private Date deploymentDate = Calendar.getInstance().getTime();
/**
* get DeploymentDate property value
* @return java.util.Date
*/
public Date getDeploymentDate() {
return this.deploymentDate;
}
/**
* set the deployment date with the last time of the day for comparisons
* of the actual edition date with the deployment date last time of day
* @param deploymentDate
*/
public void setDeploymentDate(Date deploymentDate) {
// set date with last time of the day for comparisons
Calendar calendar = Calendar.getInstance();
calendar.setTime(deploymentDate);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
this.deploymentDate = calendar.getTime();
}
/**
* auxiliary method for parsing the formatted deployment date, if
* date format is wrong get the actual date time
* @param deploymentDateFormatted
* @see SimpleDateFormat
* @see DateFormat.SHORT
*/
public void setDeploymentDateFormatted(String deploymentDateFormatted) {
try{
this.setDeploymentDate(_DATE_FORMAT.parse(deploymentDateFormatted));
}catch(ParseException pex){
// data has wrong format set as actual date;
this.setDeploymentDate(Calendar.getInstance().getTime());
}
}
/**
* get CreationDate property value
* @return java.util.Date
*/
public Date getCreationDate() {
return this.creationDate;
}
/**
* set CreationDate property value
* @param java.util.Date
*/
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
/**
* auxiliary method for parsing the formatted creation date, if
* date format is wrong get the actual date time
* @param creationDateFormatted
* @see SimpleDateFormat
* @see DateFormat.SHORT
*/
public void setCreationDateFormatted(String creationDateFormatted) {
try{
this.setCreationDate(_DATE_FORMAT.parse(creationDateFormatted));
}catch(ParseException pex){
// data has wrong format set as actual date;
this.setCreationDate(Calendar.getInstance().getTime());
}
}
/**
* set EditionDate property value
* @param java.util.Date
*/
public void setEditionDate(Date editionDate) {
this.editionDate = editionDate;
}
/**
* get EditionDate property value
* @return java.util.Date
*/
public Date getEditionDate() {
return this.editionDate;
}
/**
* get id property value
* @return java.lang.Integer
*/
public Integer getId() {
return this.id;
}
/**
* set id property value
* @param java.lang.Integer
*/
public void setId(Integer id) {
this.id = id;
}
/**
* get name property value
* @return java.lang.String
*/
public String getName() {
return this.name;
}
/**
* set name property value
* @param java.lang.String
*/
public void setName(String name) {
this.name = name;
}
/**
* get value property value
* @return java.lang.String
*/
public String getValue() {
return this.value;
}
/**
* set value property value
* @param java.lang.String
*/
public void setValue(String value) {
this.value = value;
}
/**
* get creatorMail property value
* @return java.lang.String
*/
public String getCreatorMail() {
return this.creatorMail;
}
/**
* set creatorMail property value
* @param java.lang.String
*/
public void setCreatorMail(String creatorMail) {
this.creatorMail = creatorMail;
}
@Override
public boolean equals(Object arg0) {
if(arg0 == null){
return false;
}
return new EqualsBuilder()
.append(true, arg0 instanceof PersistableEntity)
.append(this.getId(), ((PersistableEntity)arg0).getId())
.isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder()
.append(this.getId())
.toHashCode();
}
}