Merge pull request 'bug#al-3609' (!134) from AL3609 into master

Reviewed-on: adm/ModelWeb#134
Reviewed-by: pinheiro <valdevir@rjconsultores.com.br>
Reviewed-by: Gleison da Cruz <gleison.cruz@totvs.com.br>
master
Valdir Cordeiro 2024-01-11 18:37:47 +00:00
commit 04b0ee5dea
6 changed files with 307 additions and 1 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.rjconsultores</groupId>
<artifactId>ModelWeb</artifactId>
<version>1.30.0</version>
<version>1.31.0</version>
<distributionManagement>
<repository>

View File

@ -0,0 +1,14 @@
package com.rjconsultores.ventaboletos.dao;
import java.util.List;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.EmpresaPMArtespConfig;
public interface EmpresaPMArtespConfigDAO extends GenericDAO<EmpresaPMArtespConfig, Integer> {
public List<EmpresaPMArtespConfig> obtenerTodos();
public EmpresaPMArtespConfig buscarPorEmpresa(Empresa empresa);
}

View File

@ -0,0 +1,41 @@
package com.rjconsultores.ventaboletos.dao.hibernate;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import com.rjconsultores.ventaboletos.dao.EmpresaPMArtespConfigDAO;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.EmpresaPMArtespConfig;
@Repository("empresaPMArtespConfigDAO")
public class EmpresaPMArtespConfigHibernateDAO extends GenericHibernateDAO<EmpresaPMArtespConfig, Integer>
implements EmpresaPMArtespConfigDAO {
@Autowired
public EmpresaPMArtespConfigHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
@Override
public List<EmpresaPMArtespConfig> obtenerTodos() {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
return c.list();
}
@Override
public EmpresaPMArtespConfig buscarPorEmpresa(Empresa empresa) {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
c.add(Restrictions.eq("empresa", empresa));
return (EmpresaPMArtespConfig) c.uniqueResult();
}
}

View File

@ -0,0 +1,174 @@
package com.rjconsultores.ventaboletos.entidad;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@SequenceGenerator(name = "EMPRESA_PMARTESP_CONFIG_SEQ", sequenceName = "EMPRESA_PMARTESP_CONFIG_SEQ", allocationSize = 1)
@Table(name = "EMPRESA_PMARTESP_CONFIG")
public class EmpresaPMArtespConfig implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "EMPRESA_PMARTESP_CONFIG_SEQ")
@Column(name = "EMPRESAPMARTESPCONFIG_ID")
private Integer empresaPMArtespConfigId;
@OneToOne
@JoinColumn(name = "EMPRESA_ID")
private Empresa empresa;
@Column(name = "VALIDACAO_ATIVA")
private Boolean validacaoAtiva;
@Column(name = "URL_API")
private String urlApi;
@Column(name = "API_KEY")
private String apiKey;
@OneToOne
@JoinColumn(name = "ORGAOCONCEDENTE_ID")
private OrgaoConcedente orgaoConcedente;
@OneToOne
@JoinColumn(name = "CATEGORIA_ID")
private Categoria categoria;
@Column(name = "ACTIVO")
private Boolean activo;
@Column(name = "FECMODIF")
@Temporal(TemporalType.TIMESTAMP)
private Date fecmodif;
@Column(name = "USUARIO_ID")
private Integer usuarioId;
public Integer getEmpresaPMArtespConfigId() {
return empresaPMArtespConfigId;
}
public void setEmpresaPMArtespConfigId(Integer empresaPMArtespConfigId) {
this.empresaPMArtespConfigId = empresaPMArtespConfigId;
}
public Empresa getEmpresa() {
return empresa;
}
public void setEmpresa(Empresa empresa) {
this.empresa = empresa;
}
public Boolean getValidacaoAtiva() {
return validacaoAtiva == null ? false : validacaoAtiva;
}
public void setValidacaoAtiva(Boolean valida) {
this.validacaoAtiva = valida;
}
public String getUrlApi() {
return urlApi;
}
public void setUrlApi(String urlApi) {
this.urlApi = urlApi;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public OrgaoConcedente getOrgaoConcedente() {
return orgaoConcedente;
}
public void setOrgaoConcedente(OrgaoConcedente orgaoConcedente) {
this.orgaoConcedente = orgaoConcedente;
}
public Categoria getCategoria() {
return categoria;
}
public void setCategoria(Categoria categoria) {
this.categoria = categoria;
}
public Boolean getActivo() {
return activo;
}
public void setActivo(Boolean activo) {
this.activo = activo;
}
public Date getFecmodif() {
return fecmodif;
}
public void setFecmodif(Date fecmodif) {
this.fecmodif = fecmodif;
}
public Integer getUsuarioId() {
return usuarioId;
}
public void setUsuarioId(Integer usuarioId) {
this.usuarioId = usuarioId;
}
@Override
public int hashCode() {
return Objects.hash(activo, apiKey, categoria, empresa, empresaPMArtespConfigId, fecmodif, orgaoConcedente,
urlApi, usuarioId, validacaoAtiva);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EmpresaPMArtespConfig other = (EmpresaPMArtespConfig) obj;
return Objects.equals(activo, other.activo) && Objects.equals(apiKey, other.apiKey)
&& Objects.equals(categoria, other.categoria) && Objects.equals(empresa, other.empresa)
&& Objects.equals(empresaPMArtespConfigId, other.empresaPMArtespConfigId)
&& Objects.equals(fecmodif, other.fecmodif) && Objects.equals(orgaoConcedente, other.orgaoConcedente)
&& Objects.equals(urlApi, other.urlApi) && Objects.equals(usuarioId, other.usuarioId)
&& Objects.equals(validacaoAtiva, other.validacaoAtiva);
}
@Override
public String toString() {
return "EmpresaPMArtespConfig [empresaPMArtespConfigId=" + empresaPMArtespConfigId + ", empresa=" + empresa
+ ", validacaoAtiva=" + validacaoAtiva + ", urlApi=" + urlApi + ", apiKey=" + apiKey + ", orgaoConcedente="
+ orgaoConcedente + ", categoria=" + categoria + ", activo=" + activo + ", fecmodif=" + fecmodif
+ ", usuarioId=" + usuarioId + "]";
}
}

View File

@ -0,0 +1,9 @@
package com.rjconsultores.ventaboletos.service;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.EmpresaPMArtespConfig;
public interface EmpresaPMArtespConfigService extends GenericService<EmpresaPMArtespConfig, Integer> {
public EmpresaPMArtespConfig buscarPorEmpresa(Empresa empresa);
}

View File

@ -0,0 +1,68 @@
package com.rjconsultores.ventaboletos.service.impl;
import java.util.Calendar;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.rjconsultores.ventaboletos.dao.EmpresaPMArtespConfigDAO;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.EmpresaPMArtespConfig;
import com.rjconsultores.ventaboletos.service.EmpresaPMArtespConfigService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@Service("EmpresaPMArtespConfigService")
public class EmpresaPMArtespConfigServiceImpl implements EmpresaPMArtespConfigService {
@Autowired
private EmpresaPMArtespConfigDAO empresaPMArtespConfigDAO;
@Override
public List<EmpresaPMArtespConfig> obtenerTodos() {
return empresaPMArtespConfigDAO.obtenerTodos();
}
@Override
public EmpresaPMArtespConfig obtenerID(Integer id) {
return empresaPMArtespConfigDAO.obtenerID(id);
}
@Override
@Transactional
public EmpresaPMArtespConfig suscribir(EmpresaPMArtespConfig entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
return empresaPMArtespConfigDAO.suscribir(entidad);
}
@Override
@Transactional
public EmpresaPMArtespConfig actualizacion(EmpresaPMArtespConfig entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
return empresaPMArtespConfigDAO.actualizacion(entidad);
}
@Override
@Transactional
public void borrar(EmpresaPMArtespConfig entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.FALSE);
empresaPMArtespConfigDAO.actualizacion(entidad);
}
@Override
public EmpresaPMArtespConfig buscarPorEmpresa(Empresa empresa) {
return empresaPMArtespConfigDAO.buscarPorEmpresa(empresa);
}
}