Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ResponseBody
- @RequestMapping(value="/copiar/projeto", produces="application/json;charset=UTF-8")
- private ResponseEntity<?> copiarDados(Long originalId, Long novoId) {
- Projeto novoProjeto = projetoService.findById(novoId);
- //Copiar Associacoes/Config
- List<AssociacaoCategoriasProjetos> categoryToClone = associacaoCPService.findByProjetoId(originalId);
- List<AssociacaoCategoriasProjetos> categoryCloned = new ArrayList<AssociacaoCategoriasProjetos>();
- for (int i = 0; i < categoryToClone.size(); i ++) {
- AssociacaoCategoriasProjetos associacao = new AssociacaoCategoriasProjetos();
- associacao.setCategoria(categoryToClone.get(i).getCategoria());
- associacao.setAtivo(categoryToClone.get(i).isAtivo());
- associacao.setOculto(categoryToClone.get(i).isOculto());
- associacao.setProjeto(novoProjeto);
- categoryCloned.add(associacao);
- }
- associacaoCPService.salvar(categoryCloned);
- List<AssociacaoGruposProjetos> grupToClone = associacaoGPService.findByProjetoId(originalId);
- List<AssociacaoGruposProjetos> grupCloned = new ArrayList<AssociacaoGruposProjetos>();
- for (int i = 0; i < grupToClone.size(); i ++) {
- AssociacaoGruposProjetos associacao = new AssociacaoGruposProjetos();
- associacao.setGrupo(grupToClone.get(i).getGrupo());
- associacao.setAtivo(grupToClone.get(i).isAtivo());
- associacao.setOculto(grupToClone.get(i).isOculto());
- associacao.setProjeto(novoProjeto);
- associacao.setDimensionamentos(grupToClone.get(i).getDimensionamentos());
- associacao.setDimensionado(grupToClone.get(i).isDimensionado());
- associacao.setTemDimensionamento(grupToClone.get(i).isTemDimensionamento());
- grupCloned.add(associacao);
- }
- associacaoGPService.salvar(grupCloned);
- return super.responderSucesso();
- }
Add Comment
Please, Sign In to add comment