diff --git a/nb-configuration.xml b/nb-configuration.xml
index 1e8a087..5bf07d3 100644
--- a/nb-configuration.xml
+++ b/nb-configuration.xml
@@ -16,5 +16,7 @@ Any value defined here will override the pom.xml file value but is only applicab
JSPTomcattrue
+ /home/veneceo/Documents/sysgraph/LICENSE
+ Facelets
diff --git a/pom.xml b/pom.xml
index 26dcde5..9b39d54 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,12 +28,6 @@
2.5.2provided
-
-
- org.eclipse.persistence
- eclipselink
- 2.5.2-M1
- javaxjavaee-web-api
diff --git a/src/main/conf/persistence.xml b/src/main/conf/persistence.xml
index 5b1444a..0996757 100755
--- a/src/main/conf/persistence.xml
+++ b/src/main/conf/persistence.xml
@@ -1,10 +1,11 @@
-
+ org.eclipse.persistence.jpa.PersistenceProvider
+ com.github.viniciussoaresti.negocio.Clientefalse
-
+
diff --git a/src/main/java/com/github/viniciussoaresti/controladores/ClienteController.java b/src/main/java/com/github/viniciussoaresti/controladores/ClienteController.java
new file mode 100644
index 0000000..731dbdc
--- /dev/null
+++ b/src/main/java/com/github/viniciussoaresti/controladores/ClienteController.java
@@ -0,0 +1,101 @@
+/*MIT License
+
+Copyright (c) 2018 - SysGraph - Vinícius H., Matheus Dionísio, Pedro Barros e Tiago Eduardo
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.*/
+
+package com.github.viniciussoaresti.controladores;
+import com.github.viniciussoaresti.infraestrutura.repositorios.comportamentos.RepositorioGenerico;
+import com.github.viniciussoaresti.infraestrutura.repositorios.implementacoes.RepositorioClienteImplBD;
+import com.github.viniciussoaresti.negocio.Cliente;
+import java.util.List;
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.context.FacesContext;
+/**
+ *
+ * @author Vinícius Soares
+ */
+@ManagedBean
+@SessionScoped
+public class ClienteController {
+
+ private RepositorioGenerico repositorioCliente = null;
+ private Cliente clienteCadastro;
+ private Cliente selectedCliente;
+
+ public ClienteController(){
+ this.repositorioCliente = new RepositorioClienteImplBD();
+ this.clienteCadastro = new Cliente();
+ }
+
+ public void inserir(){
+
+ this.repositorioCliente.inserir(this.clienteCadastro);
+ this.clienteCadastro = new Cliente();
+
+ FacesContext.getCurrentInstance().addMessage(null,
+ new FacesMessage(FacesMessage.SEVERITY_INFO,"Sucesso!","O cliente foi cadastrado com sucesso!"));
+ }
+
+ public void alterar(Cliente c){
+ this.repositorioCliente.alterar(c);
+ FacesContext.getCurrentInstance().addMessage(null,
+ new FacesMessage(FacesMessage.SEVERITY_INFO,"Sucesso!","O cliente foi alterado com sucesso!"));
+ }
+
+ public Cliente recuperarCliente(String CPFCNPJ){
+ return this.repositorioCliente.recuperar(CPFCNPJ);
+ }
+
+ public void deletar(Cliente c){
+ this.repositorioCliente.deletar(c);
+ FacesContext.getCurrentInstance().addMessage(null,
+ new FacesMessage(FacesMessage.SEVERITY_INFO,"Sucesso!","O cliente foi deletado com sucesso!"));
+ }
+
+ public List recuperarTodosClientes(){
+ return this.repositorioCliente.recuperarTodos();
+ }
+
+ public Cliente getClienteCadastro() {
+ return clienteCadastro;
+ }
+
+ public void setClienteCadastro(Cliente clienteCadastro) {
+ this.clienteCadastro = clienteCadastro;
+ }
+
+ public Cliente getSelectedCliente() {
+ return selectedCliente;
+ }
+
+ public void setSelectedCliente(Cliente selectedCliente) {
+ this.selectedCliente = selectedCliente;
+ }
+
+ public RepositorioGenerico getRepositorioCliente() {
+ return repositorioCliente;
+ }
+
+ public void setRepositorioCliente(RepositorioGenerico repositorioCliente) {
+ this.repositorioCliente= repositorioCliente;
+ }
+}
diff --git a/src/main/java/com/github/viniciussoaresti/conversores/ClienteConverter.java b/src/main/java/com/github/viniciussoaresti/conversores/ClienteConverter.java
new file mode 100644
index 0000000..d96c154
--- /dev/null
+++ b/src/main/java/com/github/viniciussoaresti/conversores/ClienteConverter.java
@@ -0,0 +1,62 @@
+/*MIT License
+
+Copyright (c) 2018 - SysGraph - Vinícius H., Matheus Dionísio, Pedro Barros e Tiago Eduardo
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.*/
+
+package com.github.viniciussoaresti.conversores;
+import com.github.viniciussoaresti.controladores.ClienteController;
+import com.github.viniciussoaresti.negocio.Cliente;
+import java.lang.annotation.Annotation;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.FacesConverter;
+/**
+ *
+ * @author Vinícius Soares
+ */
+
+@FacesConverter("clienteConverter")
+public class ClienteConverter {
+ public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
+ if(value != null && value.trim().length() > 0) {
+ try {
+ ClienteController service = (ClienteController) fc.getExternalContext().getSessionMap().get("clienteController");
+ return service.recuperarCliente(value);
+ } catch(NumberFormatException e) {
+ throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error", "Not a valid theme."));
+ }
+ }
+ else {
+ return null;
+ }
+ }
+
+ public String getAsString(FacesContext fc, UIComponent uic, Object object) {
+ if(object != null) {
+ return String.valueOf(((Cliente) object).getCPFCNPJ());
+ }
+ else {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/com/github/viniciussoaresti/infraestrutura/dao/PersistenceDao.java b/src/main/java/com/github/viniciussoaresti/infraestrutura/dao/PersistenceDao.java
index 3a94531..3ba8691 100644
--- a/src/main/java/com/github/viniciussoaresti/infraestrutura/dao/PersistenceDao.java
+++ b/src/main/java/com/github/viniciussoaresti/infraestrutura/dao/PersistenceDao.java
@@ -91,4 +91,4 @@ public void delete(Object o){
em.getTransaction().commit();
em.close();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/github/viniciussoaresti/infraestrutura/repositorios/comportamentos/RepositorioGenerico.java b/src/main/java/com/github/viniciussoaresti/infraestrutura/repositorios/comportamentos/RepositorioGenerico.java
index 749ca04..8368443 100644
--- a/src/main/java/com/github/viniciussoaresti/infraestrutura/repositorios/comportamentos/RepositorioGenerico.java
+++ b/src/main/java/com/github/viniciussoaresti/infraestrutura/repositorios/comportamentos/RepositorioGenerico.java
@@ -28,9 +28,5 @@ public interface RepositorioGenerico {
public void alterar (T t);
public T recuperar (G codigo);
public void deletar (T t);
- public List recuperarTodos();
-
-
-
-
-}
\ No newline at end of file
+ public List recuperarTodos();
+}
diff --git a/src/main/java/com/github/viniciussoaresti/infraestrutura/repositorios/implementacoes/RepositorioCliente.java b/src/main/java/com/github/viniciussoaresti/infraestrutura/repositorios/implementacoes/RepositorioCliente.java
new file mode 100644
index 0000000..86351c1
--- /dev/null
+++ b/src/main/java/com/github/viniciussoaresti/infraestrutura/repositorios/implementacoes/RepositorioCliente.java
@@ -0,0 +1,78 @@
+/*MIT License
+
+Copyright (c) 2018 - SysGraph - Vinícius H., Matheus Dionísio, Pedro Barros e Tiago Eduardo
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.*/
+
+package com.github.viniciussoaresti.infraestrutura.repositorios.implementacoes;
+import com.github.viniciussoaresti.negocio.Cliente;
+import com.github.viniciussoaresti.infraestrutura.repositorios.comportamentos.RepositorioGenerico;
+import java.util.ArrayList;
+import java.util.List;
+/**
+ *
+ * @author Vinícius Soares
+ */
+public class RepositorioCliente implements RepositorioGenerico {
+ private List clientes = null;
+
+ public RepositorioCliente() {
+ this.clientes = new ArrayList<>();
+ }
+ @Override
+ public void inserir(Cliente t){
+ this.clientes.add(t);
+ }
+
+ @Override
+ public void alterar (Cliente t){
+ for (Cliente e : this.clientes){
+ if (e.getNome().equals( t.getNome())){
+ e.setCPFCNPJ(t.getCPFCNPJ());
+ e.setEmail(t.getEmail());
+ e.setIdade(t.getIdade());
+ e.setNome(t.getNome());
+ e.setTelefone(t.getTelefone());
+ return;
+ }
+ }
+ }
+
+ @Override
+ public Cliente recuperar(String CPFCNPJ){
+ for (Cliente e : this.clientes){
+ if(e.getCPFCNPJ().equals(CPFCNPJ) ){
+ return e;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void deletar(Cliente t){
+ this.clientes.remove(t);
+ }
+
+ @Override
+ public List recuperarTodos(){
+ return this.clientes;
+ }
+
+
+}
diff --git a/src/main/java/com/github/viniciussoaresti/infraestrutura/repositorios/implementacoes/RepositorioClienteImplBD.java b/src/main/java/com/github/viniciussoaresti/infraestrutura/repositorios/implementacoes/RepositorioClienteImplBD.java
new file mode 100644
index 0000000..01baeba
--- /dev/null
+++ b/src/main/java/com/github/viniciussoaresti/infraestrutura/repositorios/implementacoes/RepositorioClienteImplBD.java
@@ -0,0 +1,71 @@
+/*MIT License
+
+Copyright (c) 2018 - SysGraph - Vinícius H., Matheus Dionísio, Pedro Barros e Tiago Eduardo
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.*/
+package com.github.viniciussoaresti.infraestrutura.repositorios.implementacoes;
+import com.github.viniciussoaresti.infraestrutura.dao.PersistenceDao;
+import com.github.viniciussoaresti.infraestrutura.repositorios.comportamentos.RepositorioGenerico;
+import com.github.viniciussoaresti.negocio.Cliente;
+import java.util.List;
+import javax.persistence.Persistence;
+/**
+ *
+ * @author Vinícius Soares
+ */
+public class RepositorioClienteImplBD implements RepositorioGenerico{
+ @Override
+ public void inserir(Cliente t) {
+ PersistenceDao.getInstance().persist(t);
+ }
+
+ @Override
+ public void alterar(Cliente t) {
+ PersistenceDao.getInstance().update(t);
+ }
+
+ @Override
+ public Cliente recuperar(String CPFCNPJ) {
+ try{
+ return (Cliente)PersistenceDao.getInstance().read("select a from Cliente a where a.CPFCNPJ="+CPFCNPJ).get(0);
+ }catch(IndexOutOfBoundsException index){
+ return null;
+ }
+ }
+
+ @Override
+ public void deletar(Cliente t) {
+ PersistenceDao.getInstance().delete(t);
+
+ }
+
+ @Override
+ public List recuperarTodos() {
+ return PersistenceDao.getInstance().read("select a from Cliente a");
+
+ }
+ public Cliente recuperaLogin(String CPFCNPJ){
+ try{
+ return(Cliente)(PersistenceDao.getInstance().read("select a from Cliente a where a.CPFCNPJ='"+CPFCNPJ+"'").get(0));
+ }catch(IndexOutOfBoundsException index){
+ return null;
+ }
+ }
+
+}
diff --git a/src/main/java/com/github/viniciussoaresti/negocio/Cliente.java b/src/main/java/com/github/viniciussoaresti/negocio/Cliente.java
new file mode 100644
index 0000000..7c230ae
--- /dev/null
+++ b/src/main/java/com/github/viniciussoaresti/negocio/Cliente.java
@@ -0,0 +1,103 @@
+/*MIT License
+
+Copyright (c) 2018 - SysGraph - Vinícius H., Matheus Dionísio, Pedro Barros and Tiago Eduardo
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+and associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute,
+sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies
+or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
+THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.github.viniciussoaresti.negocio;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+/**
+ *
+ * @author Vinícius Soares
+ */
+@Entity
+public class Cliente {
+
+ @Column(length = 50)
+ private String nome;
+ @Id
+ @Column(length = 30)
+ private String CPFCNPJ;
+ @Column(length = 3)
+ private int idade;
+ @Column(length = 15)
+ private String telefone;
+ @Column(length = 35)
+ private String email;
+
+ public Cliente(String nome, String CPFCNPJ, int idade, String telefone, String email) {
+ this.nome = nome;
+ this.CPFCNPJ = CPFCNPJ;
+ this.idade = idade;
+ this.telefone = telefone;
+ this.email = email;
+ }
+
+ public Cliente() {
+
+ }
+
+ public String getNome() {
+ return nome;
+ }
+
+ public void setNome(String nome) {
+ this.nome = nome;
+ }
+
+ public String getCPFCNPJ() {
+ return CPFCNPJ;
+ }
+
+ public void setCPFCNPJ(String CPFCNPJ) {
+ this.CPFCNPJ = CPFCNPJ;
+ }
+
+ public int getIdade() {
+ return idade;
+ }
+
+ public void setIdade(int idade) {
+ this.idade = idade;
+ }
+
+ public String getTelefone() {
+ return telefone;
+ }
+
+ public void setTelefone(String telefone) {
+ this.telefone = telefone;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ return CPFCNPJ == ((Cliente) obj).getCPFCNPJ();
+ }
+
+}
diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml
index 8ae64c5..fddc856 100644
--- a/src/main/resources/META-INF/persistence.xml
+++ b/src/main/resources/META-INF/persistence.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index fb64a41..6f1ac8c 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -2,7 +2,7 @@
javax.faces.PROJECT_STAGE
- Development
+ ProductionFaces Servlet
diff --git a/src/main/webapp/bottom.xhtml b/src/main/webapp/bottom.xhtml
new file mode 100644
index 0000000..6ddfc95
--- /dev/null
+++ b/src/main/webapp/bottom.xhtml
@@ -0,0 +1,16 @@
+
+
+
+
+ Facelet Title
+
+
+ Software desenvolvido pela MVP Softwares ®
+
+
+
+
diff --git a/src/main/webapp/cliente.xhtml b/src/main/webapp/cliente.xhtml
new file mode 100644
index 0000000..eab0a77
--- /dev/null
+++ b/src/main/webapp/cliente.xhtml
@@ -0,0 +1,184 @@
+
+
+
+
+ Cliente
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Clientes Cadastrados
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/webapp/index.xhtml b/src/main/webapp/index.xhtml
index f12cc49..cc019f6 100644
--- a/src/main/webapp/index.xhtml
+++ b/src/main/webapp/index.xhtml
@@ -11,57 +11,33 @@
-
-
+
-