nosi.webapps.igrp.dao.CLob Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of igrp-core Show documentation
Show all versions of igrp-core Show documentation
IGRP Framework is a powerful and highly customizable platform developed by the Operational Nucleus for the Information Society (NOSi) to create web applications, it provides out of box, several modules to make easy to create stand-alone, production-grade web applications: authentication and access-control, business processes automation, reporting, page builder with automatic code generation and incorporation of the Once-Only-Principle, written in Java. IGRP Framework WAR - Contains some keys resources that give UI to IGRP Framework and others supports files.
package nosi.webapps.igrp.dao;
/*
@author: Emanuel Pereira
* 29 Jun 2017
*/
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.UpdateTimestamp;
import nosi.core.webapp.Core;
@Entity
@Table(name="tbl_clob")
public class CLob extends IGRPBaseActiveRecord implements Serializable{
/**
*
*/
private static final long serialVersionUID = -8421542320870086918L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
private String name;
private String mime_type;
@Column(nullable=false)
@Lob
@Type(type="org.hibernate.type.BinaryType")
private byte[] c_lob_content;
@Temporal(TemporalType.DATE)
@Column(nullable=false)
private Date dt_created;
@CreationTimestamp
private LocalDateTime createDateTime;
@ManyToOne
@JoinColumn(name="env_fk",foreignKey=@ForeignKey(name="CLOB_ENV_FK"),nullable=true)
private Application application;
@ManyToOne
@JoinColumn(name="env_updated_fk",foreignKey=@ForeignKey(name="CLOB_ENV_UPDATED_FK"),nullable=true)
private Application application_updated;
@Temporal(TemporalType.DATE)
private Date dt_updated;
@UpdateTimestamp
private LocalDateTime updateDateTime;
@ManyToOne
@JoinColumn(name="user_created_fk",foreignKey=@ForeignKey(name="CLOB_USER_CREATED_FK"),nullable=true)
private User user = Core.isNotNull(Core.getCurrentUser())?Core.getCurrentUser():null;
private String estado = "A"; // A -> Ativo; I -> InAtivo; AP -> Ativo e publico
private String uuid;
public CLob(){super();}
public CLob(String name, String mime_type, byte[] c_lob_content, Date dt_created,Application application) {
this();
this.name = name;
this.mime_type = mime_type;
this.c_lob_content = c_lob_content;
this.dt_created = dt_created;
this.application = application;
}
public CLob(String name, String mime_type, byte[] c_lob_content, Date dt_created, Application application, String uuid) {
this(name, mime_type, c_lob_content, dt_created, application);
this.uuid = uuid;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMime_type() {
return mime_type;
}
public void setMime_type(String mime_type) {
this.mime_type = mime_type;
}
public byte[] getC_lob_content() {
return c_lob_content;
}
public void setC_lob_content(byte[] c_lob_content) {
this.c_lob_content = c_lob_content;
}
public Date getDt_created() {
return dt_created;
}
public void setDt_created(Date dt_created) {
this.dt_created = dt_created;
}
public Application getApplication() {
return application;
}
public void setApplication(Application application) {
this.application = application;
}
public Application getApplication_updated() {
return application_updated;
}
public void setApplication_updated(Application application_updated) {
this.application_updated = application_updated;
}
public Date getDt_updated() {
return dt_updated;
}
public void setDt_updated(Date dt_updated) {
this.dt_updated = dt_updated;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getEstado() {
return estado;
}
public void setEstado(String estado) {
this.estado = estado;
}
public void generateUid() {
this.uuid = java.util.UUID.randomUUID().toString().replaceAll("-", "");
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
@Override
public String toString() {
return "CLob [id=" + id + ", name=" + name + ", mime_type=" + mime_type + ", c_lob_content="
+ Arrays.toString(c_lob_content) + ", dt_created=" + dt_created + ", application=" + application
+ ", application_updated=" + application_updated + ", dt_updated=" + dt_updated + ", user=" + user
+ ", estado=" + estado + ", uuid=" + uuid + "]";
}
public void invalidate() {
if(!this.estado.equals("I"))
this.estado = "I";
}
}