@Override
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object object, BindException errors)
throws Exception
{
OUAnagraficaObjectDTO anagraficaObjectDTO = (OUAnagraficaObjectDTO) object;
String exitPage = "redirect:/cris/tools/ou/editDynamicData.htm?id="
+ anagraficaObjectDTO.getParentId();
EditTabOrganizationUnit editT = getApplicationService().get(
EditTabOrganizationUnit.class, anagraficaObjectDTO.getTabId());
if (anagraficaObjectDTO.getNewTabId() != null)
{
exitPage += "&tabId=" + anagraficaObjectDTO.getNewTabId();
}
else
{
exitPage = "redirect:/cris/ou/"
+ ResearcherPageUtils.getPersistentIdentifier(anagraficaObjectDTO
.getParentId(), OrganizationUnit.class) + "/"
+ editT.getShortName().substring(4) + ".html";
}
if (request.getParameter("cancel") != null)
{
return new ModelAndView(exitPage);
}
OrganizationUnit grant = getApplicationService().get(OrganizationUnit.class,
anagraficaObjectDTO.getParentId());
OUAdditionalFieldStorage myObject = grant.getDynamicField();
List<BoxOrganizationUnit> propertyHolders = new LinkedList<BoxOrganizationUnit>();
if (editT.getDisplayTab() != null)
{
for (BoxOrganizationUnit box : editT.getDisplayTab().getMask())
{
propertyHolders.add(box);
}
}
else
{
propertyHolders = getApplicationService().findPropertyHolderInTab(
getClazzTab(), anagraficaObjectDTO.getTabId());
}
List<IContainable> tipProprietaInArea = new LinkedList<IContainable>();
for (BoxOrganizationUnit iph : propertyHolders)
{
tipProprietaInArea
.addAll(getApplicationService()
.<BoxOrganizationUnit, it.cilea.osd.jdyna.web.Tab<BoxOrganizationUnit>> findContainableInPropertyHolder(
getClazzBox(), iph.getId()));
}
List<OUPropertiesDefinition> realTPS = new LinkedList<OUPropertiesDefinition>();
List<IContainable> structuralField = new LinkedList<IContainable>();
for (IContainable c : tipProprietaInArea)
{
OUPropertiesDefinition rpPd = getApplicationService()
.findPropertiesDefinitionByShortName(
OUPropertiesDefinition.class, c.getShortName());
if (rpPd != null)
{
realTPS.add(rpPd);
}
else
{
structuralField.add(c);
}
}
AnagraficaUtils.reverseDTO(anagraficaObjectDTO, myObject, realTPS);
myObject.pulisciAnagrafica();
grant.setSourceID(anagraficaObjectDTO.getSourceID());
grant.setStatus(anagraficaObjectDTO.getStatus());
getApplicationService().saveOrUpdate(OrganizationUnit.class, grant);
EditTabOrganizationUnit area = getApplicationService().get(getClazzTab(),
anagraficaObjectDTO.getTabId());
final String areaTitle = area.getTitle();
saveMessage(
request,
getText("action.anagrafica.edited", new Object[] { areaTitle },
request.getLocale()));