ContratoEventoController.java
3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package br.com.centralit.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import br.com.centralit.api.model.ContratoEvento;
import br.com.centralit.api.service.ContratoEmpenhoService;
import br.com.centralit.api.service.ContratoEventoService;
import br.com.centralit.api.service.ContratoService;
import br.com.centralit.api.viewHelper.ContratoEventosVH;
import br.com.centralit.api.viewHelper.ViewsContrato;
import br.com.centralit.framework.controller.GenericController;
import br.com.centralit.framework.json.ResponseBodyWrapper;
/**
*
* <p><img src="http://centralit.com.br/images/logo_central.png"></p>
*
* <p><b>Company: </b> Central IT - Governança Corporativa - </p>
*
* <p><b>Title: </b></p>
*
* <p><b>Description: </b></p>
*
* <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p>
*
* <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p>
*
* @since 09/03/2016 - 11:36:22
*
* @version 1.0.0
*
* @author geovane.filho
*
*/
@Controller
@RequestMapping("/rest/contratoEvento")
public class ContratoEventoController extends GenericController<ContratoEvento> {
@Autowired
private ContratoService contratoService;
@Autowired
private ContratoEventoService contratoEventoService;
@Autowired
private ContratoEmpenhoService contratoEmpenhoService;
/**
* Responsável pela criação de novas instâncias desta classe.
*
* @param contratoService
*/
@Autowired
public ContratoEventoController( ContratoEventoService contratoEventoService ) {
super(contratoEventoService);
this.contratoEventoService = contratoEventoService;
}
/**
* {@inheritDoc}
*/
@Override
public Class<ViewsContrato.ContratoEventoListView> getListView() {
return ViewsContrato.ContratoEventoListView.class;
}
/**
* {@inheritDoc}
*/
@Override
public Class<ViewsContrato.ContratoEventoEditView> getEditView() {
return ViewsContrato.ContratoEventoEditView.class;
}
@RequestMapping(value = "/buscaEventosContrato", method = RequestMethod.POST)
@ResponseBody
public ResponseBodyWrapper buscaOcorrenciasContrato(@RequestBody Long contratoId) {
ContratoEventosVH ocorrenciaContratoVH = new ContratoEventosVH();
ocorrenciaContratoVH.setContrato(this.contratoService.find(contratoId));
ocorrenciaContratoVH.setOcorrencias(this.contratoEventoService.findAllByContrato(contratoId));
ocorrenciaContratoVH.setEmpenhos(this.contratoEmpenhoService.findAllByContrato(contratoId));
ResponseBodyWrapper responseBody = new ResponseBodyWrapper(ocorrenciaContratoVH, ViewsContrato.ContratoEventoEditView.class);
return responseBody;
}
@RequestMapping(value = "/removeEventoContrato", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public Boolean removeEventoContrato(@RequestParam(value = "justificativaRemocao") String justificativaRemocao, @RequestParam(value = "idEvento") Long idEvento) {
return this.contratoEventoService.removeEventoContrato(justificativaRemocao, idEvento);
}
@RequestMapping(value = "/buscaEventosContratoPorTipo", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public ResponseBodyWrapper buscaEventosContratoPorTipo(@RequestParam(value = "contratoId") Long contratoId, @RequestParam(value = "tipoEvento") String tipoEvento) {
ResponseBodyWrapper responseBody = new ResponseBodyWrapper(contratoEventoService.findAllByContratoTipoEvento(contratoId, tipoEvento), ViewsContrato.TermoEventoContrato.class);
return responseBody;
}
}