/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package maissocial.controle;
import maissocial.exception.UssJaCadastradaException;
import maissocial.exception.BairroJaCadastradaException;
import java.util.List;
import maissocial.repositorio.UssRepositorio;
/**
*
* @author luciano
*/
public class UssControle {
private UssRepositorio ussRep;
public UssControle(){
this.ussRep = new UssRepositorio();
}
public void salvarUss(Uss uss) throws Exception, UssJaCadastradaException{
if( uss == null || uss.getNome() == null || uss.getNome().equals("") || uss.getStatus() == 0){
throw new Exception("Parâmetros Inválidos!");
}
Uss uss2 = this.ussRep.pesquisarUssPorNome(uss.getNome());
if(uss2 == null){
this.ussRep.salvarUss(uss);
}else{
throw new BairroJaCadastradaException("Usuario de Servico Social já cadastrado!");
}
}
public void deletarUssPorObj(Uss uss){
this.ussRep.deletarUssPorObj(uss);
}
public void deletarUss(int cod){
this.ussRep.deletarUss(cod);
}
public void alterarUss(Uss uss) throws Exception, UssJaCadastradaException{
if( uss == null || uss.getNome() == null || uss.getNome().equals("") || uss.getStatus() == 0){
throw new Exception("Parâmetros Inválidos!");
}
Uss uss2 = this.ussRep.pesquisarUssPorNome(uss.getNome());
if(uss2 == null){
this.ussRep.alterarUss(uss);
}else{
throw new UssJaCadastradaException("Usuario de Servico Social já cadastrado!");
}
}
public Uss pesquisarUssPorCodigo(int cod){
Uss uss = this.ussRep.pesquisarUssPorCodigo(cod);
return uss;
}
public Uss pesquisarUssPorNome(String nome){
Uss uss = this.ussRep.pesquisarUssPorNome(nome);
return uss;
}
public Uss pesquisarUssPorCpf(String cpf){
Uss uss = this.ussRep.pesquisarUssPorCpf(cpf);
return uss;
}
public List pesquisarUssTodos(){
List uss = this.ussRep.pesquisarUssTodos();
return uss;
}
}