@JArchLogicCrud(nameSubPackage = "produto",
master = @JArchMaster(name = "Produto", tableName = "tb_produto",
fields = {
@JArchField(fieldName = "codigo", fieldTable = "cd_produto", description = "Código", type = FieldType.CODE, required = true, showDataTable = true, showSearch = true, spanSearch = 3),
@JArchField(fieldName = "descricao", fieldTable = "ds_produto", description = "Descrição", type = FieldType.DESCRIPTION, required = true, showDataTable = true, showSearch = true, columnSearch = 2, spanSearch = 6, rowDataXhtml = 2),
@JArchField(fieldName = "valor", fieldTable = "vl_produto", description = "Valor", type = FieldType.MONEY, required = true, showDataTable = true),
@JArchField(fieldName = "tipo", fieldTable = "tp_produto", description = "Tipo", type = FieldType.TYPE, required = true, showDataTable = true, showSearch = true, columnSearch = 3, spanSearch = 3, rowDataXhtml = 4)
}))
package br.com.jarch.arquitetura.crud;
import br.com.jarch.core.annotation.JArchField;
import br.com.jarch.core.annotation.JArchLogicCrud;
import br.com.jarch.core.annotation.JArchMaster;
import br.com.jarch.core.type.FieldType;
@JArchLogicMasterDetail(nameSubPackage = "banco",
master = @JArchMaster(name = "Banco", tableName = "tb_banco",
fields = {
@JArchField(fieldName = "codigo", fieldTable = "cd_banco", description = "Código", type = FieldType.CODE, required = true, showDataTable = true, showSearch = true),
@JArchField(fieldName = "nome", fieldTable = "nm_banco", description = "Nome", type = FieldType.NAME, required = true, showDataTable = true, showSearch = true, columnSearch = 2, rowDataXhtml = 2),
@JArchField(fieldName = "tipo", fieldTable = "tp_banco", description = "Tipo", type = FieldType.TYPE, required = true, showDataTable = true, showSearch = true, columnSearch = 3, rowDataXhtml = 3)
}),
details = {
@JArchDetail(name = "Agência", tableName = "tb_bancoagencia",
fields = {
@JArchField(fieldName = "codigo", fieldTable = "cd_agencia", description = "Código", type = FieldType.CODE, required = true, showDataTable = true),
@JArchField(fieldName = "nome", fieldTable = "nm_agencia", description = "Nome", type = FieldType.NAME, required = true, showDataTable = true, columnDataXhtml = 2)
})})
package br.com.jarch.arquitetura.crud;
import br.com.jarch.core.annotation.JArchDetail;
import br.com.jarch.core.annotation.JArchField;
import br.com.jarch.core.annotation.JArchLogicMasterDetail;
import br.com.jarch.core.annotation.JArchMaster;
import br.com.jarch.core.type.FieldType;
@JArchLogicMasterSubDetail(nameSubPackage = "marca", allowInsert = false, allowChange = false, allowClone = false, allowDelete = false,
master = @JArchMaster(name = "Marca", tableName = "tb_marca",
fields = {
@JArchField(fieldName = "codigo", fieldTable = "cd_marca", description = "Código", type = FieldType.CODE, required = true, showDataTable = true, showSearch = true),
@JArchField(fieldName = "nome", fieldTable = "nm_marca", description = "Nome", type = FieldType.NAME, required = true, showDataTable = true, showSearch = true, columnSearch = 2, rowDataXhtml = 2)
}),
details = {
@JArchDetailSubDetail(name = "Modelo", tableName = "tb_marca_modelo",
fields = {
@JArchField(fieldName = "codigo", fieldTable = "cd_modelo", description = "Código", type = FieldType.CODE, required = true, showDataTable = true, showSearch = true),
@JArchField(fieldName = "nome", fieldTable = "nm_modelo", description = "Nome", type = FieldType.NAME, required = true, showDataTable = true, showSearch = true, columnSearch = 2, rowDataXhtml = 2)
},
subDetails = {
@JArchSubDetail(name = "SubModelo", tableName = "tb_marca_modelo_submodelo",
fields = {
@JArchField(fieldName = "codigo", fieldTable = "cd_submodelo", description = "Código", type = FieldType.CODE, required = true, showDataTable = true, showSearch = true),
@JArchField(fieldName = "nome", fieldTable = "nm_submodelo", description = "Nome", type = FieldType.NAME, required = true, showDataTable = true, showSearch = true, columnSearch = 2, rowDataXhtml = 2)
})})})
package br.com.jarch.arquitetura.crud;
import br.com.jarch.core.annotation.JArchDetailSubDetail;
import br.com.jarch.core.annotation.JArchField;
import br.com.jarch.core.annotation.JArchLogicMasterSubDetail;
import br.com.jarch.core.annotation.JArchMaster;
import br.com.jarch.core.annotation.JArchSubDetail;
import br.com.jarch.core.type.FieldType;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://jarch.com.br/ui"
xmlns:e="a="http://jarch.com.br/ui"/ui/extension">
<ui:composition template="/paginas/templates/templateList.xhtml">
<ui:define name="panelBodyTemplateLista">
<e:form>
<e:panelTitle
title="#{e:bundle('label.lista')} - #{e:bundle('label.produto')}"
description="#{e:bundle('label.manter')} #{e:bundle('label.produto')}"/>
<e:panelListFilter
title="#{e:bundle('label.filtro')} - #{e:bundle('label.produto')}"
actionList="#{produtoListController}"
update="@form:listEntityDataTableProduto"/>
<e:panelListDatatable id="listEntityDataTableProduto"
title="#{e:bundle('label.lista')} - #{e:bundle('label.produto')}"
actionList="#{produtoListController}" />
</h:form>
</ui:define>
</ui:composition>
</html>
package br.com.jarch.arquitetura.crud.produto;
import br.com.jarch.core.annotation.JArchViewScoped;
import br.com.jarch.faces.controller.CrudListController;
@JArchViewScoped
public class ProdutoListController extends CrudListController<ProdutoEntity, ProdutoService> {
@Override
public String getPageData() {
return "produtoData.jsf";
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://jarch.com.br/ui"
xmlns:e="http://jarch.com.br/ui/ui/extension">
<ui:composition template="/paginas/templates/templateData.xhtml">
<ui:define name="panelBodyTemplateDados">
<e:form>
<e:panelTitle
title="#{e:bundle('label.produto')} - #{produtoDataController.labelAction}"
description="#{e:bundle('label.manter')} #{e:bundle('label.produto')}"/>
<e:panelDataMaster
title="#{e:bundle('label.produto')}"
actionData="#{produtoDataController}">
<a:panelGrid columns="1">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.codigo')}" for="idProdutoCodigo" />
<br/>
<a:inputText id="idProdutoCodigo" styleClass="input-code" disabled="#{produtoDataController.blockedMaster}" label="#{e:bundle('label.codigo')}" value="#{produtoDataController.entity.codigo}" required="true"/>
</h:panelGroup>
</a:panelGrid>
<a:panelGrid columns="2">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.descricao')}" for="idProdutoDescricao" />
<br/>
<a:inputText id="idProdutoDescricao" styleClass="input-description-large" disabled="#{produtoDataController.blockedMaster}" label="#{e:bundle('label.descricao')}" value="#{produtoDataController.entity.descricao}" required="true"/>
</h:panelGroup>
</a:panelGrid>
<a:panelGrid columns="3">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.valor')}" for="idProdutoValor" styleClass="outputlabel-inputnumber"/>
<br/>
<a:inputNumber id="idProdutoValor" inputStyleClass="input-decimal" decimalSeparator="," decimalPlaces="2" disabled="#{produtoDataController.blockedMaster}" label="#{e:bundle('label.valor')}" value="#{produtoDataController.entity.valor}" width="100" required="true"/>
</h:panelGroup>
</a:panelGrid>
<a:panelGrid columns="4">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.tipo')}" for="idProdutoTipo" />
<br/>
<a:selectOneMenu id="idProdutoTipo" disabled="#{produtoDataController.blockedMaster}" label="#{e:bundle('label.tipo')}" value="#{produtoDataController.entity.tipo}" required="true">
<f:selectItem itemLabel=""/>
<f:selectItems value="#{produtoDataController.entity.tipos}" var="item" itemLabel="#{item.descricao}" itemValue="#{item}"/>
</a:selectOneMenu>
</h:panelGroup>
</a:panelGrid>
</e:panelDataMaster>
</h:form>
</ui:define>
</ui:composition>
</html>
package br.com.jarch.arquitetura.crud.produto;
import br.com.jarch.core.annotation.JArchViewScoped;
import br.com.jarch.faces.controller.CrudDataController;
@JArchViewScoped
public class ProdutoDataController extends CrudDataController<ProdutoEntity, ProdutoService> {
@Override
public String getPageList() {
return "produtoList.jsf";
}
}
package br.com.jarch.arquitetura.crud.produto;
import javax.validation.constraints.Size;
import javax.persistence.GeneratedValue;
import javax.persistence.Column;
import java.math.BigDecimal;
import javax.persistence.GenerationType;
import br.com.jarch.core.annotation.JArchValidRequired;
import java.util.Collection;
import javax.persistence.Table;
import javax.persistence.SequenceGenerator;
import javax.persistence.Entity;
import org.hibernate.envers.Audited;
import br.com.jarch.core.crud.entity.CrudMultiTenantEntity;
import java.util.Set;
import javax.persistence.Id;
@Audited
@Table(name = "tb_produto")
@Entity(name = "produto")
@SequenceGenerator(name = "ProdutoIdSequence", sequenceName = "sq_idproduto", allocationSize = 1)
public class ProdutoEntity extends CrudMultiTenantEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ProdutoIdSequence")
@Column(name = "id_produto")
private Long id;
@Column(name = "cd_produto", nullable = false, length = 20)
@JArchValidRequired("label.codigo")
@Size(max = 20, message = "{message.maxSizeExceeded}")
private String codigo;
@Column(name = "ds_produto", nullable = false, length = 50)
@JArchValidRequired("label.descricao")
@Size(max = 50, message = "{message.maxSizeExceeded}")
private String descricao;
@Column(name = "vl_produto", nullable = false, scale = 2, precision = 12)
@JArchValidRequired("label.valor")
private BigDecimal valor;
@Column(name = "tp_produto", nullable = false, length = 3)
@JArchValidRequired("label.tipo")
private TipoType tipo;
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public String getCodigo() {
return codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public BigDecimal getValor() {
return valor;
}
public void setValor(BigDecimal valor) {
this.valor = valor;
}
public TipoType getTipo() {
return tipo;
}
public void setTipo(TipoType tipo) {
this.tipo = tipo;
}
public Collection<TipoType> getTipos() {
return TipoType.getCollection();
}
public String getTipoDescricao() {
return tipo == null ? "" : tipo.getDescricao();
}
}
package br.com.jarch.arquitetura.crud.produto;
import br.com.jarch.core.crud.service.CrudService;
@JArchService
public class ProdutoService extends CrudService<ProdutoEntity, IProdutoDao> {
}
package br.com.jarch.arquitetura.crud.produto;
import br.com.jarch.core.crud.repository.CrudRepository;
public interface IProdutoDao extends CrudRepository<ProdutoEntity> {
}
package br.com.jarch.arquitetura.crud.produto;
import br.com.jarch.core.crud.dao.CrudDao;
public class ProdutoDao extends CrudDao<ProdutoEntity> implements IProdutoDao {
}
package br.com.jarch.arquitetura.crud.produto;
import javax.enterprise.event.Observes;
import br.com.jarch.core.annotation.JArchEventInsert;
import br.com.jarch.core.annotation.JArchEventLoadCrud;
public class ProdutoObserver {
private void loadCrud(@Observes @JArchEventLoadCrud ProdutoEntity e) {
// Carregar relacionamentos LAZY
}
}
@JArchSearchTab(order = 1,
searchFields = {
@JArchSearchField(classEntity = ProdutoEntity.class, field = "codigo", label = "label.codigo", type = FieldType.CODE, row = 1, column = 1, span = 3),
@JArchSearchField(classEntity = ProdutoEntity.class, field = "descricao", label = "label.descricao", type = FieldType.DESCRIPTION, row = 1, column = 2, span = 6),
},
searchFieldComboboxes = {
@JArchSearchFieldCombobox(classEntity = ProdutoEntity.class, field = "tipo", label = "label.tipo", fieldItems = "tipos", fieldShow = "descricao", row = 1, column = 3, span = 3),
})
@JArchColumnDataTable(classEntity = ProdutoEntity.class, field = "codigo", title = "label.codigo", width = 100, type = FieldType.CODE)
@JArchColumnDataTable(classEntity = ProdutoEntity.class, field = "descricao", title = "label.descricao", type = FieldType.DESCRIPTION)
@JArchColumnDataTable(classEntity = ProdutoEntity.class, field = "valor", title = "label.valor", width = 100, type = FieldType.MONEY)
@JArchColumnDataTable(classEntity = ProdutoEntity.class, field = "tipoDescricao", title = "label.tipo", width = 200, type = FieldType.TYPE)
package br.com.jarch.arquitetura.crud.produto;
import br.com.jarch.core.annotation.JArchColumnDataTable;
import br.com.jarch.core.type.FieldType;
import br.com.jarch.core.annotation.JArchSearchField;
import br.com.jarch.core.annotation.JArchSearchFieldCombobox;
import br.com.jarch.core.annotation.JArchSearchTab;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://jarch.com.br/ui"
xmlns:e="http://jarch.com.br/ui/ui/extension">
<ui:composition template="/paginas/templates/templateList.xhtml">
<ui:define name="panelBodyTemplateLista">
<e:form>
<e:panelTitle
title="#{e:bundle('label.lista')} - #{e:bundle('label.banco')}"
description="#{e:bundle('label.manter')} #{e:bundle('label.banco')}"/>
<e:panelListFilter
title="#{e:bundle('label.filtro')} - #{e:bundle('label.banco')}"
actionList="#{bancoListController}"
update="@form:listEntityDataTableBanco"/>
<e:panelListDatatable id="listEntityDataTableBanco"
title="#{e:bundle('label.lista')} - #{e:bundle('label.banco')}"
actionList="#{bancoListController}" />
</h:form>
</ui:define>
</ui:composition>
</html>
package br.com.jarch.arquitetura.crud.banco;
import br.com.jarch.core.annotation.JArchViewScoped;
import br.com.jarch.faces.controller.CrudListController;
@JArchViewScoped
public class BancoListController extends CrudListController<BancoEntity, BancoService> {
@Override
public String getPageData() {
return "bancoData.jsf";
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://jarch.com.br/ui"
xmlns:e="http://jarch.com.br/ui/ui/extension">
<ui:composition template="/paginas/templates/templateData.xhtml">
<ui:define name="panelBodyTemplateDados">
<e:form>
<e:panelTitle
title="#{e:bundle('label.banco')} - #{bancoDataController.labelAction}"
description="#{e:bundle('label.manter')} #{e:bundle('label.banco')}"/>
<e:panelDataMaster
title="#{e:bundle('label.banco')}"
actionData="#{bancoDataController}">
<a:panelGrid columns="1">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.codigo')}" for="idBancoCodigo" />
<br/>
<a:inputText id="idBancoCodigo" styleClass="input-code" disabled="#{bancoDataController.blockedMaster}" label="#{e:bundle('label.codigo')}" value="#{bancoDataController.entity.codigo}" required="true"/>
</h:panelGroup>
</a:panelGrid>
<a:panelGrid columns="2">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.nome')}" for="idBancoNome" />
<br/>
<a:inputText id="idBancoNome" styleClass="input-description-large" disabled="#{bancoDataController.blockedMaster}" label="#{e:bundle('label.nome')}" value="#{bancoDataController.entity.nome}" required="true"/>
</h:panelGroup>
</a:panelGrid>
<a:panelGrid columns="3">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.tipo')}" for="idBancoTipo" />
<br/>
<a:selectOneMenu id="idBancoTipo" disabled="#{bancoDataController.blockedMaster}" label="#{e:bundle('label.tipo')}" value="#{bancoDataController.entity.tipo}" required="true">
<f:selectItem itemLabel=""/>
<f:selectItems value="#{bancoDataController.entity.tipos}" var="item" itemLabel="#{item.descricao}" itemValue="#{item}"/>
</a:selectOneMenu>
</h:panelGroup>
</a:panelGrid>
</e:panelDataMaster>
<f:validateBean disabled="true">
<e:panelDataDetail title="#{e:bundle('label.manutencaoDetalhe')}">
<a:tabView>
<a:tab id="tabAgencia">
<f:facet name="title">
<e:tabTitle title="#{e:bundle('label.agencia')}" entityParent="#{bancoDataController.entity}" dataDetail="#{bancoDataController.dataDetailAgencia}" idTab="tabAgencia" update="#{e:component('tagBodyAgencia')}" hideInsert="#{bancoDataController.blockedDetail}"/>
</f:facet>
<e:tabBody id="tagBodyAgencia" actionData="#{bancoDataController}" dataDetail="#{bancoDataController.dataDetailAgencia}" idTab="tabAgencia">
<a:panelGrid columns="1">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.codigo')}" for="idAgenciaCodigo" />
<br/>
<a:inputText id="idAgenciaCodigo" styleClass="input-code" disabled="#{bancoDataController.blockedMaster or bancoDataController.dataDetailAgencia.blockedDetail}" label="#{e:bundle('label.codigo')}" value="#{bancoDataController.dataDetailAgencia.entity.codigo}" required="#{bancoDataController.dataDetailAgencia.required}"/>
</h:panelGroup>
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.nome')}" for="idAgenciaNome" />
<br/>
<a:inputText id="idAgenciaNome" styleClass="input-description-large" disabled="#{bancoDataController.blockedMaster or bancoDataController.dataDetailAgencia.blockedDetail}" label="#{e:bundle('label.nome')}" value="#{bancoDataController.dataDetailAgencia.entity.nome}" required="#{bancoDataController.dataDetailAgencia.required}"/>
</h:panelGroup>
</a:panelGrid>
</e:tabBody>
</a:tab>
</a:tabView>
</e:panelDataDetail>
</f:validateBean>
</h:form>
</ui:define>
</ui:composition>
</html>
package br.com.jarch.arquitetura.crud.banco;
import br.com.jarch.core.annotation.JArchViewScoped;
import br.com.jarch.faces.controller.CrudDataController;
import br.com.jarch.faces.controller.CrudDataDetail;
import javax.inject.Inject;
@JArchViewScoped
public class BancoDataController extends CrudDataController<BancoEntity, BancoService> {
@Inject
private CrudDataDetail<AgenciaEntity> dataDetailAgencia;
@Override
public String getPageList() {
return "bancoList.jsf";
}
public CrudDataDetail<AgenciaEntity> getDataDetailAgencia() {
return dataDetailAgencia;
}
}
//************************************************************************************************************
// BancoEntity.java
//************************************************************************************************************
package br.com.jarch.arquitetura.crud.banco;
import org.hibernate.annotations.Filter;
import javax.validation.constraints.Size;
import javax.persistence.GeneratedValue;
import javax.persistence.Column;
import javax.persistence.GenerationType;
import javax.persistence.OneToMany;
import br.com.jarch.core.annotation.JArchNoCloneId;
import br.com.jarch.core.ConstantCore;
import br.com.jarch.core.annotation.JArchValidRequired;
import java.util.Collection;
import javax.persistence.Table;
import javax.persistence.SequenceGenerator;
import javax.persistence.Entity;
import org.hibernate.envers.Audited;
import javax.persistence.CascadeType;
import br.com.jarch.core.crud.entity.CrudMultiTenantEntity;
import java.util.Set;
import javax.persistence.Id;
@Audited
@Table(name = "tb_banco")
@Entity(name = "banco")
@SequenceGenerator(name = "BancoIdSequence", sequenceName = "sq_idbanco", allocationSize = 1)
public class BancoEntity extends CrudMultiTenantEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BancoIdSequence")
@Column(name = "id_banco")
private Long id;
@Column(name = "cd_banco", nullable = false, length = 20)
@JArchValidRequired("label.codigo")
@Size(max = 20, message = "{message.maxSizeExceeded}")
private String codigo;
@Column(name = "nm_banco", nullable = false, length = 50)
@JArchValidRequired("label.nome")
@Size(max = 50, message = "{message.maxSizeExceeded}")
private String nome;
@Column(name = "tp_banco", nullable = false, length = 3)
@JArchValidRequired("label.tipo")
private TipoType tipo;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "banco", orphanRemoval = true)
@JArchValidRequired("label.agencia")
@JArchNoCloneId
@Filter(name = ConstantCore.TENANT)
private Set<AgenciaEntity> listaAgencia;
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public String getCodigo() {
return codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public TipoType getTipo() {
return tipo;
}
public void setTipo(TipoType tipo) {
this.tipo = tipo;
}
public Set<AgenciaEntity> getListaAgencia() {
return listaAgencia;
}
public void setListaAgencia(Set<AgenciaEntity> listaAgencia) {
this.listaAgencia = listaAgencia;
}
public Collection<TipoType> getTipos() {
return TipoType.getCollection();
}
public String getTipoDescricao() {
return tipo == null ? "" : tipo.getDescricao();
}
}
//************************************************************************************************************
// AgenciaEntity.java
//************************************************************************************************************
package br.com.jarch.arquitetura.crud.banco;
import javax.persistence.JoinColumn;
import org.hibernate.annotations.Filter;
import javax.validation.constraints.Size;
import javax.persistence.GeneratedValue;
import javax.persistence.Column;
import javax.persistence.GenerationType;
import javax.persistence.ManyToOne;
import br.com.jarch.core.ConstantCore;
import br.com.jarch.core.annotation.JArchValidRequired;
import javax.persistence.Table;
import javax.persistence.SequenceGenerator;
import javax.persistence.Entity;
import org.hibernate.envers.Audited;
import br.com.jarch.core.crud.entity.CrudMultiTenantEntity;
import javax.persistence.Id;
@Audited
@Table(name = "tb_bancoagencia")
@Entity(name = "agencia")
@SequenceGenerator(name = "AgenciaIdSequence", sequenceName = "sq_idbancoagencia", allocationSize = 1)
public class AgenciaEntity extends CrudMultiTenantEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AgenciaIdSequence")
@Column(name = "id_bancoagencia")
private Long id;
@ManyToOne
@JoinColumn(name="id_banco")
@Filter(name = ConstantCore.TENANT)
private BancoEntity banco;
@Column(name = "cd_agencia", nullable = false, length = 20)
@JArchValidRequired("label.codigo")
@Size(max = 20, message = "{message.maxSizeExceeded}")
private String codigo;
@Column(name = "nm_agencia", nullable = false, length = 50)
@JArchValidRequired("label.nome")
@Size(max = 50, message = "{message.maxSizeExceeded}")
private String nome;
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public BancoEntity getBanco() {
return banco;
}
public void setBanco(BancoEntity banco) {
this.banco = banco;
}
public String getCodigo() {
return codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
package br.com.jarch.arquitetura.crud.banco;
import br.com.jarch.core.crud.service.CrudService;
@JArchService
public class BancoService extends CrudService<BancoEntity, IBancoDao> {
}
package br.com.jarch.arquitetura.crud.banco;
import br.com.jarch.core.crud.repository.CrudRepository;
public interface IBancoDao extends CrudRepository<BancoEntity> {
}
package br.com.jarch.arquitetura.crud.banco;
import br.com.jarch.core.crud.dao.CrudDao;
public class BancoDao extends CrudDao<BancoEntity> implements IBancoDao {
}
package br.com.jarch.arquitetura.crud.banco;
import br.com.jarch.core.annotation.JArchEventLoadCrud;
import br.com.jarch.core.util.JpaUtils;
import javax.enterprise.event.Observes;
public class BancoObserver {
private void loadCrud(@Observes @JArchEventLoadCrud BancoEntity entity) {
JpaUtils.initializeCollectionLazy(entity);
}
}
@JArchSearchTab(order = 1,
searchFields = {
@JArchSearchField(classEntity = BancoEntity.class, field = "codigo", label = "label.codigo", type = FieldType.CODE, row = 1, column = 1, span = 3),
@JArchSearchField(classEntity = BancoEntity.class, field = "nome", label = "label.nome", type = FieldType.NAME, row = 1, column = 2, span = 6),
},
searchFieldComboboxes = {
@JArchSearchFieldCombobox(classEntity = BancoEntity.class, field = "tipo", label = "label.tipo", fieldItems = "tipos", fieldShow = "descricao", row = 1, column = 3, span = 3),
})
@JArchColumnDataTable(classEntity = BancoEntity.class, field = "codigo", title = "label.codigo", width = 100, type = FieldType.CODE)
@JArchColumnDataTable(classEntity = BancoEntity.class, field = "nome", title = "label.nome", type = FieldType.NAME)
@JArchColumnDataTable(classEntity = BancoEntity.class, field = "tipoDescricao", title = "label.tipo", width = 200, type = FieldType.TYPE)
@JArchColumnDataTable(classEntity = AgenciaEntity.class, field = "codigo", title = "label.codigo", width = 100, type = FieldType.CODE)
@JArchColumnDataTable(classEntity = AgenciaEntity.class, field = "nome", title = "label.nome", type = FieldType.NAME)
package br.com.jarch.arquitetura.crud.banco;
import br.com.jarch.core.annotation.JArchColumnDataTable;
import br.com.jarch.core.type.FieldType;
import br.com.jarch.core.annotation.JArchSearchField;
import br.com.jarch.core.annotation.JArchSearchFieldCombobox;
import br.com.jarch.core.annotation.JArchSearchTab;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://jarch.com.br/ui"
xmlns:e="http://jarch.com.br/ui/ui/extension">
<ui:composition template="/paginas/templates/templateList.xhtml">
<ui:define name="panelBodyTemplateLista">
<e:form>
<e:panelTitle
title="#{e:bundle('label.lista')} - #{e:bundle('label.marca')}"
description="#{e:bundle('label.manter')} #{e:bundle('label.marca')}"/>
<e:panelListFilter
title="#{e:bundle('label.filtro')} - #{e:bundle('label.marca')}"
actionList="#[marcaListController}"
update="@form:listEntityDataTableMarca"/>
<e:panelListDatatable id="listEntityDataTableMarca"
title="#{e:bundle('label.lista')} - #{e:bundle('label.marca')}"
actionList="#[marcaListController}" hideInsert="true" hideClone="true" hideChange="true" hideDelete="true" />
</h:form>
</ui:define>
</ui:composition>
</html>
package br.com.jarch.arquitetura.crud.marca;
import br.com.jarch.core.annotation.JArchViewScoped;
import br.com.jarch.faces.controller.CrudListController;
@JArchViewScoped
public class MarcaListController extends CrudListController<MarcaEntity, MarcaService> {
@Override
public String getPageData() {
return "marcaData.jsf";
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:a="http://jarch.com.br/ui"
xmlns:e="http://jarch.com.br/ui/ui/extension">
<ui:composition template="/paginas/templates/templateData.xhtml">
<ui:define name="panelBodyTemplateDados">
<e:form>
<e:panelTitle
title="#{e:bundle('label.marca')} - #[marcaDataController.labelAction}"
description="#{e:bundle('label.manter')} #{e:bundle('label.marca')}"/>
<e:panelDataMaster
title="#{e:bundle('label.marca')}"
actionData="#[marcaDataController}">
<a:panelGrid columns="1">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.codigo')}" for="idMarcaCodigo" />
<br/>
<a:inputText id="idMarcaCodigo" styleClass="input-code" disabled="#[marcaDataController.blockedMaster}" label="#{e:bundle('label.codigo')}" value="#[marcaDataController.entity.codigo}" required="true"/>
</h:panelGroup>
</a:panelGrid>
<a:panelGrid columns="2">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.nome')}" for="idMarcaNome" />
<br/>
<a:inputText id="idMarcaNome" styleClass="input-description-large" disabled="#[marcaDataController.blockedMaster}" label="#{e:bundle('label.nome')}" value="#[marcaDataController.entity.nome}" required="true"/>
</h:panelGroup>
</a:panelGrid>
</e:panelDataMaster>
<f:validateBean disabled="true">
<e:panelDataDetail title="#{e:bundle('label.manutencaoDetalhe')}">
<a:tabView>
<a:tab id="tabModelo">
<f:facet name="title">
<e:tabTitle title="#{e:bundle('label.modelo')}" entityParent="#[marcaDataController.entity}" dataDetail="#[marcaDataController.dataDetailModelo}" idTab="tabModelo" update="#[e:component('tagBodyModelo')}" hideInsert="#[marcaDataController.blockedDetail}"/>
</f:facet>
<e:tabBody id="tagBodyModelo" actionData="#[marcaDataController}" dataDetail="#[marcaDataController.dataDetailModelo}" idTab="tabModelo">
<a:panelGrid columns="1">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.codigo')}" for="idModeloCodigo" />
<br/>
<a:inputText id="idModeloCodigo" styleClass="input-code" disabled="#[marcaDataController.blockedMaster or marcaDataController.dataDetailModelo.blockedDetail}" label="#{e:bundle('label.codigo')}" value="#[marcaDataController.dataDetailModelo.entity.codigo}" required="#[marcaDataController.dataDetailModelo.required}"/>
</h:panelGroup>
</a:panelGrid>
<a:panelGrid columns="2">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.nome')}" for="idModeloNome" />
<br/>
<a:inputText id="idModeloNome" styleClass="input-description-large" disabled="#[marcaDataController.blockedMaster or marcaDataController.dataDetailModelo.blockedDetail}" label="#{e:bundle('label.nome')}" value="#[marcaDataController.dataDetailModelo.entity.nome}" required="#[marcaDataController.dataDetailModelo.required}"/>
</h:panelGroup>
</a:panelGrid>
<a:panelGrid columns="1">
<a:tabView>
<a:tab id="tabSubModelo">
<f:facet name="title">
<e:tabTitle title="#{e:bundle('label.subModelo')}" entityParent="#[marcaDataController.dataDetailModelo.entity}" dataDetail="#[marcaDataController.dataDetailSubModelo}" idTab="tabSubModelo" update="#[e:component('tagBodySubModelo')}" hideInsert="#[marcaDataController.blockedDetail}"/>
</f:facet>
<e:tabBody id="tagBodySubModelo" actionData="#[marcaDataController}" dataDetail="#[marcaDataController.dataDetailSubModelo}" idTab="tabSubModelo" dataDetailParent="#[marcaDataController.dataDetailModelo}">
<a:panelGrid columns="1">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.codigo')}" for="idSubModeloCodigo" />
<br/>
<a:inputText id="idSubModeloCodigo" styleClass="input-code" disabled="#[marcaDataController.blockedMaster or marcaDataController.dataDetailSubModelo.blockedDetail}" label="#{e:bundle('label.codigo')}" value="#[marcaDataController.dataDetailSubModelo.entity.codigo}" required="#[marcaDataController.dataDetailSubModelo.required}"/>
</h:panelGroup>
</a:panelGrid>
<a:panelGrid columns="2">
<h:panelGroup>
<a:outputLabel value="#{e:bundle('label.nome')}" for="idSubModeloNome" />
<br/>
<a:inputText id="idSubModeloNome" styleClass="input-description-large" disabled="#[marcaDataController.blockedMaster or marcaDataController.dataDetailSubModelo.blockedDetail}" label="#{e:bundle('label.nome')}" value="#[marcaDataController.dataDetailSubModelo.entity.nome}" required="#[marcaDataController.dataDetailSubModelo.required}"/>
</h:panelGroup>
</a:panelGrid>
</e:tabBody>
</a:tab>
</a:tabView>
</a:panelGrid>
</e:tabBody>
</a:tab>
</a:tabView>
</e:panelDataDetail>
</f:validateBean>
</h:form>
</ui:define>
</ui:composition>
</html>
package br.com.jarch.arquitetura.crud.marca;
import br.com.jarch.core.annotation.JArchViewScoped;
import br.com.jarch.faces.controller.CrudDataController;
import br.com.jarch.faces.controller.CrudDataDetail;
import javax.inject.Inject;
@JArchViewScoped
public class MarcaDataController extends CrudDataController<MarcaEntity, MarcaService> {
@Inject
private CrudDataDetail<ModeloEntity> dataDetailModelo;
@Inject
private CrudDataDetail<SubModeloEntity> dataDetailSubModelo;
@Override
public String getPageList() {
return "marcaList.jsf";
}
public CrudDataDetail<ModeloEntity> getDataDetailModelo() {
return dataDetailModelo;
}
public CrudDataDetail<SubModeloEntity> getDataDetailSubModelo() {
return dataDetailSubModelo;
}
}
//************************************************************************************************************
// MarcaEntity.java
//************************************************************************************************************
package br.com.jarch.arquitetura.crud.marca;
import org.hibernate.annotations.Filter;
import javax.validation.constraints.Size;
import javax.persistence.GeneratedValue;
import javax.persistence.Column;
import javax.persistence.GenerationType;
import javax.persistence.OneToMany;
import br.com.jarch.core.annotation.JArchNoCloneId;
import br.com.jarch.core.ConstantCore;
import br.com.jarch.core.annotation.JArchValidRequired;
import javax.persistence.Table;
import javax.persistence.SequenceGenerator;
import javax.persistence.Entity;
import org.hibernate.envers.Audited;
import javax.persistence.CascadeType;
import br.com.jarch.core.crud.entity.CrudMultiTenantEntity;
import java.util.Set;
import javax.persistence.Id;
@Audited
@Table(name = "tb_marca")
@Entity(name = "marca")
@SequenceGenerator(name = "MarcaIdSequence", sequenceName = "sq_idmarca", allocationSize = 1)
public class MarcaEntity extends CrudMultiTenantEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "MarcaIdSequence")
@Column(name = "id_marca")
private Long id;
@Column(name = "cd_marca", nullable = false, length = 20)
@JArchValidRequired("label.codigo")
@Size(max = 20, message = "{message.maxSizeExceeded}")
private String codigo;
@Column(name = "nm_marca", nullable = false, length = 50)
@JArchValidRequired("label.nome")
@Size(max = 50, message = "{message.maxSizeExceeded}")
private String nome;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "marca", orphanRemoval = true)
@JArchValidRequired("label.modelo")
@JArchNoCloneId
@Filter(name = ConstantCore.TENANT)
private Set<ModeloEntity> listaModelo;
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public String getCodigo() {
return codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public Set<ModeloEntity> getListaModelo() {
return listaModelo;
}
public void setListaModelo(Set<ModeloEntity> listaModelo) {
this.listaModelo = listaModelo;
}
}
//************************************************************************************************************
// ModeloEntity.java
//************************************************************************************************************
package br.com.jarch.arquitetura.crud.marca;
import javax.persistence.JoinColumn;
import org.hibernate.annotations.Filter;
import javax.validation.constraints.Size;
import javax.persistence.GeneratedValue;
import javax.persistence.Column;
import javax.persistence.GenerationType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import br.com.jarch.core.annotation.JArchNoCloneId;
import br.com.jarch.core.ConstantCore;
import br.com.jarch.core.annotation.JArchValidRequired;
import javax.persistence.Table;
import javax.persistence.SequenceGenerator;
import javax.persistence.Entity;
import org.hibernate.envers.Audited;
import javax.persistence.CascadeType;
import br.com.jarch.core.crud.entity.CrudMultiTenantEntity;
import java.util.Set;
import javax.persistence.Id;
@Audited
@Table(name = "tb_marca_modelo")
@Entity(name = "modelo")
@SequenceGenerator(name = "ModeloIdSequence", sequenceName = "sq_idmarcamodelo", allocationSize = 1)
public class ModeloEntity extends CrudMultiTenantEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ModeloIdSequence")
@Column(name = "id_marcamodelo")
private Long id;
@ManyToOne
@JoinColumn(name="id_marca")
@Filter(name = ConstantCore.TENANT)
private MarcaEntity marca;
@Column(name = "cd_modelo", nullable = false, length = 20)
@JArchValidRequired("label.codigo")
@Size(max = 20, message = "{message.maxSizeExceeded}")
private String codigo;
@Column(name = "nm_modelo", nullable = false, length = 50)
@JArchValidRequired("label.nome")
@Size(max = 50, message = "{message.maxSizeExceeded}")
private String nome;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "modelo", orphanRemoval = true)
@JArchValidRequired("label.subModelo")
@JArchNoCloneId
@Filter(name = ConstantCore.TENANT)
private Set<SubModeloEntity> listaSubModelo;
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public MarcaEntity getMarca() {
return marca;
}
public void setMarca(MarcaEntity marca) {
this.marca = marca;
}
public String getCodigo() {
return codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public Set<SubModeloEntity> getListaSubModelo() {
return listaSubModelo;
}
public void setListaSubModelo(Set<SubModeloEntity> listaSubModelo) {
this.listaSubModelo = listaSubModelo;
}
}
//************************************************************************************************************
// SubModeloEntity.java
//************************************************************************************************************
package br.com.jarch.arquitetura.crud.marca;
import javax.persistence.JoinColumn;
import org.hibernate.annotations.Filter;
import javax.validation.constraints.Size;
import javax.persistence.GeneratedValue;
import javax.persistence.Column;
import javax.persistence.GenerationType;
import javax.persistence.ManyToOne;
import br.com.jarch.core.ConstantCore;
import br.com.jarch.core.annotation.JArchValidRequired;
import javax.persistence.Table;
import javax.persistence.SequenceGenerator;
import javax.persistence.Entity;
import org.hibernate.envers.Audited;
import br.com.jarch.core.crud.entity.CrudMultiTenantEntity;
import javax.persistence.Id;
@Audited
@Table(name = "tb_marca_modelo_submodelo")
@Entity(name = "subModelo")
@SequenceGenerator(name = "SubModeloIdSequence", sequenceName = "sq_idmarcamodelosubmodelo", allocationSize = 1)
public class SubModeloEntity extends CrudMultiTenantEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SubModeloIdSequence")
@Column(name = "id_marcamodelosubmodelo")
private Long id;
@ManyToOne
@JoinColumn(name="id_modelo")
@Filter(name = ConstantCore.TENANT)
private ModeloEntity modelo;
@Column(name = "cd_submodelo", nullable = false, length = 20)
@JArchValidRequired("label.codigo")
@Size(max = 20, message = "{message.maxSizeExceeded}")
private String codigo;
@Column(name = "nm_submodelo", nullable = false, length = 50)
@JArchValidRequired("label.nome")
@Size(max = 50, message = "{message.maxSizeExceeded}")
private String nome;
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public ModeloEntity getModelo() {
return modelo;
}
public void setModelo(ModeloEntity modelo) {
this.modelo = modelo;
}
public String getCodigo() {
return codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
package br.com.jarch.arquitetura.crud.marca;
import br.com.jarch.core.crud.service.CrudService;
@JArchService
public class MarcaService extends CrudService<MarcaEntity, IMarcaDao> {
}
package br.com.jarch.arquitetura.crud.marca;
import br.com.jarch.core.crud.repository.CrudRepository;
public interface IMarcaDao extends CrudRepository<MarcaEntity> {
}
package br.com.jarch.arquitetura.crud.marca;
import br.com.jarch.core.crud.dao.CrudDao;
public class MarcaDao extends CrudDao<MarcaEntity> implements IMarcaDao {
}
package br.com.jarch.arquitetura.crud.marca;
import br.com.jarch.core.annotation.JArchEventLoadCrud;
import br.com.jarch.core.util.JpaUtils;
import javax.enterprise.event.Observes;
public class MarcaObserver {
private void loadCrud(@Observes @JArchEventLoadCrud MarcaEntity entity) {
JpaUtils.initializeCollectionLazy(entity);
}
}
@JArchSearchTab(order = 1,
searchFields = {
@JArchSearchField(classEntity = MarcaEntity.class, field = "codigo", label = "label.codigo", type = FieldType.CODE, row = 1, column = 1, span = 3),
@JArchSearchField(classEntity = MarcaEntity.class, field = "nome", label = "label.nome", type = FieldType.NAME, row = 1, column = 2, span = 6),
})
@JArchColumnDataTable(classEntity = MarcaEntity.class, field = "codigo", title = "label.codigo", width = 100, type = FieldType.CODE)
@JArchColumnDataTable(classEntity = MarcaEntity.class, field = "nome", title = "label.nome", type = FieldType.NAME)
@JArchSearchTab(order = 1,
searchFields = {
@JArchSearchField(classEntity = ModeloEntity.class, field = "codigo", label = "label.codigo", type = FieldType.CODE, row = 1, column = 1, span = 3),
@JArchSearchField(classEntity = ModeloEntity.class, field = "nome", label = "label.nome", type = FieldType.NAME, row = 1, column = 2, span = 6),
})
@JArchColumnDataTable(classEntity = ModeloEntity.class, field = "codigo", title = "label.codigo", width = 100, type = FieldType.CODE)
@JArchColumnDataTable(classEntity = ModeloEntity.class, field = "nome", title = "label.nome", type = FieldType.NAME)
@JArchSearchTab(order = 1,
searchFields = {
@JArchSearchField(classEntity = SubModeloEntity.class, field = "codigo", label = "label.codigo", type = FieldType.CODE, row = 1, column = 1, span = 3),
@JArchSearchField(classEntity = SubModeloEntity.class, field = "nome", label = "label.nome", type = FieldType.NAME, row = 1, column = 2, span = 6),
})
@JArchColumnDataTable(classEntity = SubModeloEntity.class, field = "codigo", title = "label.codigo", width = 100, type = FieldType.CODE)
@JArchColumnDataTable(classEntity = SubModeloEntity.class, field = "nome", title = "label.nome", type = FieldType.NAME)
package br.com.jarch.arquitetura.crud.marca;
import br.com.jarch.core.annotation.JArchColumnDataTable;
import br.com.jarch.core.type.FieldType;
import br.com.jarch.core.annotation.JArchSearchField;
import br.com.jarch.core.annotation.JArchSearchTab;
...
...
<dependency>
<groupId>br.com.jarch</groupId>
<artifactId>jarch-core</artifactId>
<version>LATEST</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>br.com.jarch</groupId>
<artifactId>jarch-template</artifactId>
<version>LATEST</version>
<type>war</type>
</dependency>
...
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<overlays>
<overlay>
<groupId>br.com.jarch</groupId>
<artifactId>jarch-template</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>