String exitPage = "redirect:/cris/tools/project/editDynamicData.htm?id="
+ anagraficaObjectDTO.getParentId();
EditTabProject editT = getApplicationService().get(
EditTabProject.class, anagraficaObjectDTO.getTabId());
if (anagraficaObjectDTO.getNewTabId() != null)
{
exitPage += "&tabId=" + anagraficaObjectDTO.getNewTabId();
}
else
{
exitPage = "redirect:/cris/project/"
+ ResearcherPageUtils.getPersistentIdentifier(anagraficaObjectDTO
.getParentId(), Project.class) + "/"
+ editT.getShortName().substring(4) + ".html";
}
if (request.getParameter("cancel") != null)
{
return new ModelAndView(exitPage);
}
Project grant = getApplicationService().get(Project.class,
anagraficaObjectDTO.getParentId());
ProjectAdditionalFieldStorage myObject = grant.getDynamicField();
List<BoxProject> propertyHolders = new LinkedList<BoxProject>();
if (editT.getDisplayTab() != null)
{
for (BoxProject box : editT.getDisplayTab().getMask())
{
propertyHolders.add(box);
}
}
else
{
propertyHolders = getApplicationService().findPropertyHolderInTab(
getClazzTab(), anagraficaObjectDTO.getTabId());
}
List<IContainable> tipProprietaInArea = new LinkedList<IContainable>();
for (BoxProject iph : propertyHolders)
{
tipProprietaInArea
.addAll(getApplicationService()
.<BoxProject, it.cilea.osd.jdyna.web.Tab<BoxProject>> findContainableInPropertyHolder(
getClazzBox(), iph.getId()));
}
List<ProjectPropertiesDefinition> realTPS = new LinkedList<ProjectPropertiesDefinition>();
List<IContainable> structuralField = new LinkedList<IContainable>();
for (IContainable c : tipProprietaInArea)
{
ProjectPropertiesDefinition rpPd = getApplicationService()
.findPropertiesDefinitionByShortName(
ProjectPropertiesDefinition.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(Project.class, grant);
EditTabProject area = getApplicationService().get(getClazzTab(),
anagraficaObjectDTO.getTabId());
final String areaTitle = area.getTitle();
saveMessage(
request,
getText("action.anagrafica.edited", new Object[] { areaTitle },
request.getLocale()));