Skip to content
Snippets Groups Projects
Commit 34dac94b authored by Fabiano Sluzarski's avatar Fabiano Sluzarski
Browse files

arrumado bug onde o formulario nao atualizava correta na volta da componente de multipla selecao

parent d1914376
Branches
No related tags found
No related merge requests found
......@@ -37,18 +37,31 @@ import br.ufpr.c3sl.estacaojuventude.enums.TipoStatus;
public class OcorrenciaMunicipalController {
OcorrenciaMunicipal ocorrenciaMunicipalGlobal;
private Set<OrgaoExecutor> copySetOrgaoExecutor(Set<OrgaoExecutor> old) {
Set<OrgaoExecutor> orgaosExecutoresNovo = new HashSet<OrgaoExecutor>();
Set<OrgaoExecutor> orgaosExecutores = old;
private void refreshRelations() {
if (ocorrenciaMunicipalGlobal.getProgramaVinculado() != null)
ocorrenciaMunicipalGlobal.setProgramaVinculado(Programa.findPrograma(ocorrenciaMunicipalGlobal.getProgramaVinculado().getId()));
if (ocorrenciaMunicipalGlobal.getMunicipio() != null)
ocorrenciaMunicipalGlobal.setMunicipio(Municipio.findMunicipio(ocorrenciaMunicipalGlobal.getMunicipio().getId()));
if (ocorrenciaMunicipalGlobal.getOrgaosExecutores() != null) {
Set<OrgaoExecutor> orgaosExecutoresNovo = new HashSet<OrgaoExecutor>();
Set<OrgaoExecutor> orgaosExecutores = ocorrenciaMunicipalGlobal.getOrgaosExecutores();
for (Iterator<OrgaoExecutor> o = orgaosExecutores.iterator(); o.hasNext();)
orgaosExecutoresNovo.add(OrgaoExecutor.findOrgaoExecutor(o.next().getId()));
ocorrenciaMunicipalGlobal.setOrgaosExecutores(orgaosExecutoresNovo);
}
if (ocorrenciaMunicipalGlobal.getId() != null)
ocorrenciaMunicipalGlobal.setLocalizacoes(OcorrenciaMunicipal.findOcorrenciaMunicipal(ocorrenciaMunicipalGlobal.getId()).getLocalizacoes());
return orgaosExecutoresNovo;
if (ocorrenciaMunicipalGlobal.getUsuario() != null)
ocorrenciaMunicipalGlobal.setUsuario(Usuario.findUsuario(ocorrenciaMunicipalGlobal.getUsuario().getId()));
}
@RequestMapping(value = "/form/{id}", produces = "text/html")
public String addSelected(@PathVariable("id") Long id, Model uiModel, HttpServletRequest httpServletRequest) {
public String treatSelected(@PathVariable("id") Long id, Model uiModel, HttpServletRequest httpServletRequest) {
refreshRelations();
if (OrgaoExecutor.findOrgaoExecutor(id) != null) {
if (ocorrenciaMunicipalGlobal.getOrgaosExecutores() == null) {
Set<OrgaoExecutor> orgaosExecutores = new HashSet<OrgaoExecutor>();
......@@ -57,7 +70,7 @@ public class OcorrenciaMunicipalController {
ocorrenciaMunicipalGlobal.setOrgaosExecutores(orgaosExecutores);
}
else {
Set<OrgaoExecutor> orgaosExecutoresNovo = copySetOrgaoExecutor(ocorrenciaMunicipalGlobal.getOrgaosExecutores());
Set<OrgaoExecutor> orgaosExecutoresNovo = ocorrenciaMunicipalGlobal.getOrgaosExecutores();
if (orgaosExecutoresNovo.contains(OrgaoExecutor.findOrgaoExecutor(id)))
orgaosExecutoresNovo.remove(OrgaoExecutor.findOrgaoExecutor(id));
else
......@@ -65,10 +78,6 @@ public class OcorrenciaMunicipalController {
ocorrenciaMunicipalGlobal.setOrgaosExecutores(orgaosExecutoresNovo);
}
}
if (ocorrenciaMunicipalGlobal.getOrgaosExecutores() != null) {
Set<OrgaoExecutor> orgaosExecutoresNovo = copySetOrgaoExecutor(ocorrenciaMunicipalGlobal.getOrgaosExecutores());
ocorrenciaMunicipalGlobal.setOrgaosExecutores(orgaosExecutoresNovo);
}
populateEditForm(uiModel, ocorrenciaMunicipalGlobal);
if (ocorrenciaMunicipalGlobal.getId() == null) {
ocorrenciaMunicipalGlobal = null;
......
......@@ -38,28 +38,36 @@ import br.ufpr.c3sl.estacaojuventude.enums.TipoTemporalidade;
public class ProgramaController {
private Programa programaGlobal;
private Set<Tematica> copySetTematica(Set<Tematica> old) {
Set<Tematica> tematicasNova = new HashSet<Tematica>();
Set<Tematica> tematicas = old;
private void refreshRelations() {
if (programaGlobal.getProgramaVinculado() != null)
programaGlobal.setProgramaVinculado(Programa.findPrograma(programaGlobal.getProgramaVinculado().getId()));
if (programaGlobal.getTematicas() != null) {
Set<Tematica> tematicasNova = new HashSet<Tematica>();
Set<Tematica> tematicas = programaGlobal.getTematicas();
for (Iterator<Tematica> t = tematicas.iterator(); t.hasNext();)
tematicasNova.add(Tematica.findTematica(t.next().getId()));
return tematicasNova;
programaGlobal.setTematicas(tematicasNova);
}
private Set<OrgaoExecutor> copySetOrgaoExecutor(Set<OrgaoExecutor> old) {
if (programaGlobal.getOrgaosExecutores() != null) {
Set<OrgaoExecutor> orgaosExecutoresNovo = new HashSet<OrgaoExecutor>();
Set<OrgaoExecutor> orgaosExecutores = old;
Set<OrgaoExecutor> orgaosExecutores = programaGlobal.getOrgaosExecutores();
for (Iterator<OrgaoExecutor> o = orgaosExecutores.iterator(); o.hasNext();)
orgaosExecutoresNovo.add(OrgaoExecutor.findOrgaoExecutor(o.next().getId()));
programaGlobal.setOrgaosExecutores(orgaosExecutoresNovo);
}
if (programaGlobal.getId() != null)
programaGlobal.setOcorrencias(Programa.findPrograma(programaGlobal.getId()).getOcorrencias());
return orgaosExecutoresNovo;
if (programaGlobal.getUsuario() != null)
programaGlobal.setUsuario(Usuario.findUsuario(programaGlobal.getUsuario().getId()));
}
@RequestMapping(value = "/form/{id}", produces = "text/html")
public String addSelected(@PathVariable("id") Long id, Model uiModel, HttpServletRequest httpServletRequest) {
public String treatSelected(@PathVariable("id") Long id, Model uiModel, HttpServletRequest httpServletRequest) {
refreshRelations();
if (Tematica.findTematica(id) != null) {
if (programaGlobal.getTematicas() == null) {
Set<Tematica> tematicas = new HashSet<Tematica>();
......@@ -68,7 +76,7 @@ public class ProgramaController {
programaGlobal.setTematicas(tematicas);
}
else {
Set<Tematica> tematicasNova = copySetTematica(programaGlobal.getTematicas());
Set<Tematica> tematicasNova = programaGlobal.getTematicas();
if (tematicasNova.contains(Tematica.findTematica(id)))
tematicasNova.remove(Tematica.findTematica(id));
else
......@@ -84,7 +92,7 @@ public class ProgramaController {
programaGlobal.setOrgaosExecutores(orgaosExecutores);
}
else {
Set<OrgaoExecutor> orgaosExecutoresNovo = copySetOrgaoExecutor(programaGlobal.getOrgaosExecutores());
Set<OrgaoExecutor> orgaosExecutoresNovo = programaGlobal.getOrgaosExecutores();
if (orgaosExecutoresNovo.contains(OrgaoExecutor.findOrgaoExecutor(id)))
orgaosExecutoresNovo.remove(OrgaoExecutor.findOrgaoExecutor(id));
else
......@@ -92,14 +100,6 @@ public class ProgramaController {
programaGlobal.setOrgaosExecutores(orgaosExecutoresNovo);
}
}
if (programaGlobal.getTematicas() != null) {
Set<Tematica> tematicasNova = copySetTematica(programaGlobal.getTematicas());
programaGlobal.setTematicas(tematicasNova);
}
if (programaGlobal.getOrgaosExecutores() != null) {
Set<OrgaoExecutor> orgaosExecutoresNovo = copySetOrgaoExecutor(programaGlobal.getOrgaosExecutores());
programaGlobal.setOrgaosExecutores(orgaosExecutoresNovo);
}
populateEditForm(uiModel, programaGlobal);
if (programaGlobal.getId() == null) {
programaGlobal = null;
......@@ -112,7 +112,7 @@ public class ProgramaController {
}
@RequestMapping(value = "selecionar", method = {RequestMethod.POST, RequestMethod.PUT}, produces = "text/html")
public String createSelectForm(@Valid Programa programa, @RequestParam(value = "tipo", required = false) String type, @RequestParam(value = "op", required = false) Integer op, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
public String selectForm(@Valid Programa programa, @RequestParam(value = "tipo", required = false) String type, @RequestParam(value = "op", required = false) Integer op, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
programaGlobal = programa;
if (op == 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment