Boolean isAdmin = false;
if (paramId != null)
{
id = Integer.parseInt(paramId);
}
OrganizationUnit grant = getApplicationService().get(OrganizationUnit.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<EditTabOrganizationUnit> tabs = getApplicationService()
.getTabsByVisibility(EditTabOrganizationUnit.class, isAdmin);
if (tabs.isEmpty())
{
throw new AuthorizeException("No tabs defined!!");
}
areaId = tabs.get(0).getId();
}
else
{
EditTabOrganizationUnit fuzzyEditTab = (EditTabOrganizationUnit) ((ApplicationService) getApplicationService())
.<BoxOrganizationUnit, TabOrganizationUnit, EditTabOrganizationUnit>getEditTabByDisplayTab(
Integer.parseInt(paramFuzzyTabId),
EditTabOrganizationUnit.class);
areaId = fuzzyEditTab.getId();
}
}
else
{
areaId = Integer.parseInt(paramTabId);
}
EditTabOrganizationUnit editT = getApplicationService().get(
EditTabOrganizationUnit.class, areaId);
List<BoxOrganizationUnit> propertyHolders = new LinkedList<BoxOrganizationUnit>();
if (editT.getDisplayTab() != null)
{
for (BoxOrganizationUnit box : editT.getDisplayTab().getMask())
{
propertyHolders.add(box);
}
}
else
{
propertyHolders = getApplicationService().findPropertyHolderInTab(
getClazzTab(), areaId);
}
List<IContainable> tipProprietaInArea = new LinkedList<IContainable>();
for (BoxOrganizationUnit iph : propertyHolders)
{
if (editT.getDisplayTab() != null)
{
tipProprietaInArea
.addAll(getApplicationService()
.<BoxOrganizationUnit, it.cilea.osd.jdyna.web.Tab<BoxOrganizationUnit>> findContainableInPropertyHolder(
BoxOrganizationUnit.class, iph.getId()));
}
else
{
tipProprietaInArea
.addAll(getApplicationService()
.<BoxOrganizationUnit, it.cilea.osd.jdyna.web.Tab<BoxOrganizationUnit>> findContainableInPropertyHolder(
getClazzBox(), iph.getId()));
}
}
OUAdditionalFieldStorage dynamicObject = grant.getDynamicField();
OUAnagraficaObjectDTO anagraficaObjectDTO = new OUAnagraficaObjectDTO(
grant);
anagraficaObjectDTO.setTabId(areaId);
anagraficaObjectDTO.setObjectId(grant.getId());
anagraficaObjectDTO.setParentId(grant.getId());
List<OUPropertiesDefinition> realTPS = new LinkedList<OUPropertiesDefinition>();
List<IContainable> structuralField = new LinkedList<IContainable>();
for (IContainable c : tipProprietaInArea)