Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calendario quinta (Cadastro de eventos Funcional) #5

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
19fc6d0
adicionado caminhos no git ignore
PablooHenrique Nov 23, 2016
40a8de9
Estrutura básica das views
Nov 23, 2016
a3e4974
Criado crud de Instituto, Regional, Categoria
PablooHenrique Nov 23, 2016
fa28a17
Task para execução do projeto
Nov 23, 2016
aefcffa
Inicializado mapeamento de evento, falta finalizar dois mapeamentos
PablooHenrique Nov 24, 2016
d572b76
Adicionado a pesquisa de todos os eventos, mapeamento many to many ai…
PablooHenrique Nov 24, 2016
c7ae289
Ajustado mensagens de validacoes com erro de encoding visualizado no …
PablooHenrique Nov 24, 2016
a9145a4
Ajustado o import do localDate, travis não esta lendo bibliotecas do …
PablooHenrique Nov 24, 2016
d67473a
Ajuste da biblioteca de data travis nao aceita função depreciada
PablooHenrique Nov 24, 2016
fe10d83
ajuste de import para build travis
PablooHenrique Nov 24, 2016
c7b00a7
Ajuste nos testes
PablooHenrique Nov 24, 2016
baa2651
Criado os testes referentes as classses de servico do calendario acad…
kaiqueorange Dec 1, 2016
0816c72
Finalizado classe de servico
PablooHenrique Dec 1, 2016
cb04d85
Merge branch 'pablo' of https://github.com/cleydsonjr/quinta-calendar…
PablooHenrique Dec 1, 2016
9fda037
Update .travis.yml
kaiqueorange Dec 1, 2016
6a5877b
Update hibernate.cfg.xml
PablooHenrique Dec 1, 2016
a841136
Ajustando merge da view
PablooHenrique Dec 1, 2016
4eea46b
Criado tela de regional, ajustado servico e bando para atender aos me…
PablooHenrique Dec 1, 2016
c915961
Merge branch 'pablo' of https://github.com/cleydsonjr/quinta-calendar…
PablooHenrique Dec 1, 2016
f192fa7
Ajustando o hibernate.cfg
PablooHenrique Dec 1, 2016
2be3fc2
Adicionado telas de categoria e Instituto
PablooHenrique Dec 1, 2016
43ad3df
adicionando arquivos
Dec 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
end_of_line = lf
insert_final_newline = false
charset = utf-8

[*.{java,gradle}]
indent_style = space
indent_size = 4
continuation_indent_size = 8

[*.{xml}]
indent_style = space
indent_size = 4
continuation_indent_size = 8
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

.project
.classpath
.settings/
.idea/
*.iml

# User-specific stuff:
.idea/*
.idea/workspace.xml
Expand Down Expand Up @@ -84,3 +90,4 @@ gradle-app.setting

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
/bin/
12 changes: 12 additions & 0 deletions .nb-gradle-properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gradle-project-properties>
<!--DO NOT EDIT THIS FILE! - Used by the Gradle plugin of NetBeans.-->
<source-encoding>UTF-8</source-encoding>
<target-platform-name>j2se</target-platform-name>
<target-platform>1.8</target-platform>
<source-level>1.8</source-level>
<script-platform>
<spec-name>j2se</spec-name>
<spec-version>1.8</spec-version>
</script-platform>
</gradle-project-properties>
Binary file not shown.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
language: java
language: java
jdk:
- oraclejdk8
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'org.hibernate:hibernate-core:5.2.4.Final'
compile 'com.h2database:h2:1.4.193'
compile 'commons-io:commons-io:2.4'

testCompile 'junit:junit:4.12'
}

task runApp(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath

main = 'br.ufg.inf.quintacalendario.main.Application'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package br.ufg.inf.quintacalendario.controller;

import java.util.List;

import org.hibernate.SessionFactory;

import br.ufg.inf.quintacalendario.main.Application;
import br.ufg.inf.quintacalendario.model.Categoria;
import br.ufg.inf.quintacalendario.service.CategoriaService;
import br.ufg.inf.quintacalendario.view.console.TelaCategoriaConsole;

public class CategoriaController {

private TelaCategoriaConsole tela;
private SessionFactory sessionFactory;

public CategoriaController() {
tela = new TelaCategoriaConsole(System.out);
sessionFactory = Application.getInstance().getSessionFactory();
}

public void exibaOpcoes() {
getTela().exibaOpcoes();
}

public boolean cadastrar(String nome) {
Categoria Categoria = new Categoria();
Categoria.setNome(nome);

CategoriaService service = new CategoriaService(getSessionFactory());
return service.salvar(Categoria);
}

public List<Categoria> listar(){
CategoriaService service = new CategoriaService(getSessionFactory());
return service.listar();
}

public List<Categoria> listar(String descricao){
CategoriaService service = new CategoriaService(getSessionFactory());
return service.listar(descricao);
}

public Categoria listarPorId(Integer codigo) {
CategoriaService service = new CategoriaService(getSessionFactory());
Categoria Categoria = service.listarPorId(codigo);
return Categoria;
}

public void editar(Integer codigo, String nome) {
CategoriaService service = new CategoriaService(getSessionFactory());
service.editar(codigo, nome);
}

public void remover(Integer codigo){
CategoriaService service = new CategoriaService(getSessionFactory());
Categoria Categoria = service.listarPorId(codigo);
if (Categoria==null) {
System.out.println("*******Codigo invalido*******");
System.out.println("");
getTela().remover();
}else{
service.remover(codigo);
}
}

public TelaCategoriaConsole getTela() {
return tela;
}

public void setTela(TelaCategoriaConsole tela) {
this.tela = tela;
}

public SessionFactory getSessionFactory() {
return sessionFactory;
}

public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package br.ufg.inf.quintacalendario.controller;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.hibernate.SessionFactory;

import br.ufg.inf.quintacalendario.main.Application;
import br.ufg.inf.quintacalendario.model.Evento;
import br.ufg.inf.quintacalendario.service.EventoService;
import br.ufg.inf.quintacalendario.view.console.TelaEventoConsole;

public class EventosController {


private TelaEventoConsole tela;
private SessionFactory sessionFactory;

public EventosController() {
setTela(new TelaEventoConsole(System.out));
setSessionFactory(Application.getInstance().getSessionFactory());
}

public void exibaOpcoes() {
getTela().exibaOpcoes();
}

public void cadastrar(String descricao, String titulo, String dataInicial, String dataFinal) {
Evento evento = new Evento();

evento.setDescricao(descricao);
evento.setTitulo(titulo);

Date data = converterStringParaDate(dataInicial);
evento.setDataInicial(data);

data = converterStringParaDate(dataFinal);
evento.setDataFinal(data);

EventoService service = new EventoService(getSessionFactory());
service.salvar(evento);
}

public Date converterStringParaDate(String pData){
if (pData == null || pData.equals("")) {
return null;
}

Date date = null;
try {
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
date = (java.util.Date) formatter.parse(pData);
} catch (ParseException e) {
// TODO: handle exception
}
return date;
}

public List<Evento> listar(){
EventoService service = new EventoService(getSessionFactory());
return service.listar();
}

public List<Evento> listar(String descricao){
EventoService service = new EventoService(getSessionFactory());
return service.listarPorDescricao(descricao);
}

public Evento listarPorId(Integer codigo){
EventoService service = new EventoService(getSessionFactory());
return service.listarPorId(codigo);
}

public SessionFactory getSessionFactory() {
return sessionFactory;
}

public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}

public TelaEventoConsole getTela() {
return tela;
}

public void setTela(TelaEventoConsole tela) {
this.tela = tela;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package br.ufg.inf.quintacalendario.controller;

import java.util.List;

import org.hibernate.SessionFactory;

import br.ufg.inf.quintacalendario.main.Application;
import br.ufg.inf.quintacalendario.model.Instituto;
import br.ufg.inf.quintacalendario.service.InstitutoService;
import br.ufg.inf.quintacalendario.view.console.TelaInstitutoConsole;

public class InstitutoController {

private TelaInstitutoConsole tela;
private SessionFactory sessionFactory;

public InstitutoController() {
setTela(new TelaInstitutoConsole(System.out));
setSessionFactory(Application.getInstance().getSessionFactory());
}

public void exibaOpcoes() {
getTela().exibaOpcoes();
}

public boolean cadastrar(String nome) {
Instituto instituto = new Instituto();
instituto.setNome(nome);

InstitutoService service = new InstitutoService(getSessionFactory());
return service.salvar(instituto);
}

public List<Instituto> listar(){
InstitutoService service = new InstitutoService(getSessionFactory());
return service.listar();
}

public List<Instituto> listar(String descricao){
InstitutoService service = new InstitutoService(getSessionFactory());
return service.listar(descricao);
}

public Instituto listarPorId(Integer codigo) {
InstitutoService service = new InstitutoService(getSessionFactory());
Instituto Instituto = service.listarPorId(codigo);
return Instituto;
}

public void editar(Integer codigo, String nome) {
InstitutoService service = new InstitutoService(getSessionFactory());
service.editar(codigo, nome);
}

public void remover(Integer codigo){
InstitutoService service = new InstitutoService(getSessionFactory());
Instituto Instituto = service.listarPorId(codigo);
if (Instituto==null) {
System.out.println("*******Codigo invalido*******");
System.out.println("");
getTela().remover();
}else{
service.remover(codigo);
}
}

public TelaInstitutoConsole getTela() {
return tela;
}

public void setTela(TelaInstitutoConsole tela) {
this.tela = tela;
}

public SessionFactory getSessionFactory() {
return sessionFactory;
}

public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
}
Loading