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