Boolean isAdmin = false;
if (paramId != null)
{
id = Integer.parseInt(paramId);
}
ResearchObject entity = getApplicationService().get(ResearchObject.class,
id);
Context context = UIUtil.obtainContext(request);
if (!AuthorizeManager.isAdmin(context))
{
throw new AuthorizeException("Only system admin can edit");
}
else
{
isAdmin = true;
}
Integer areaId;
if (paramTabId == null)
{
if (paramFuzzyTabId == null)
{
List<EditTabDynamicObject> tabs = getApplicationService()
.<BoxDynamicObject, DynamicObjectType, DynamicPropertiesDefinition, TabDynamicObject, EditTabDynamicObject>getEditTabsByVisibilityAndType(EditTabDynamicObject.class,
isAdmin, entity.getTypo());
if (tabs.isEmpty())
{
throw new AuthorizeException("No tabs defined!!");
}
areaId = tabs.get(0).getId();
}
else
{
EditTabDynamicObject fuzzyEditTab = (EditTabDynamicObject) ((ApplicationService) getApplicationService())
.<BoxDynamicObject, TabDynamicObject, EditTabDynamicObject>getEditTabByDisplayTab(
Integer.parseInt(paramFuzzyTabId),
EditTabDynamicObject.class);
areaId = fuzzyEditTab.getId();
}
}
else
{
areaId = Integer.parseInt(paramTabId);
}
EditTabDynamicObject editT = getApplicationService().get(
EditTabDynamicObject.class, areaId);
List<BoxDynamicObject> propertyHolders = new LinkedList<BoxDynamicObject>();
if (editT.getDisplayTab() != null)
{
for (BoxDynamicObject box : editT.getDisplayTab().getMask())
{
propertyHolders.add(box);
}
}
else
{
propertyHolders = getApplicationService().findPropertyHolderInTab(
getClazzTab(), areaId);
}
List<IContainable> tipProprietaInArea = new LinkedList<IContainable>();
for (BoxDynamicObject iph : propertyHolders)
{
if (editT.getDisplayTab() != null)
{
tipProprietaInArea
.addAll(getApplicationService()
.<BoxDynamicObject, it.cilea.osd.jdyna.web.Tab<BoxDynamicObject>> findContainableInPropertyHolder(
BoxDynamicObject.class, iph.getId()));
}
else
{
tipProprietaInArea
.addAll(getApplicationService()
.<BoxDynamicObject, it.cilea.osd.jdyna.web.Tab<BoxDynamicObject>> findContainableInPropertyHolder(
getClazzBox(), iph.getId()));
}
}
DynamicAdditionalFieldStorage dynamicObject = entity.getDynamicField();
DynamicAnagraficaObjectDTO anagraficaObjectDTO = new DynamicAnagraficaObjectDTO(
entity);
anagraficaObjectDTO.setTabId(areaId);
anagraficaObjectDTO.setObjectId(entity.getId());
anagraficaObjectDTO.setParentId(entity.getId());
anagraficaObjectDTO.setTipologiaId(entity.getTypo().getId());
List<DynamicPropertiesDefinition> realTPS = new LinkedList<DynamicPropertiesDefinition>();
List<IContainable> structuralField = new LinkedList<IContainable>();
for (IContainable c : tipProprietaInArea)
{