Boolean isAdmin = false;
if (paramId != null)
{
id = Integer.parseInt(paramId);
}
ResearcherPage researcher = getApplicationService().get(
ResearcherPage.class, id);
Context context = UIUtil.obtainContext(request);
EPerson currentUser = context.getCurrentUser();
if ((currentUser==null || (researcher.getEpersonID()!=null && currentUser.getID()!=researcher.getEpersonID()))
&& !AuthorizeManager.isAdmin(context))
{
throw new AuthorizeException(
"Only system admin can edit not personal researcher page");
}
if (AuthorizeManager.isAdmin(context))
{
isAdmin = true;
}
Integer areaId;
if (paramTabId == null)
{
if (paramFuzzyTabId == null)
{
List<EditTabResearcherPage> tabs = getApplicationService()
.getTabsByVisibility(
EditTabResearcherPage.class, isAdmin);
if (tabs.isEmpty())
{
throw new AuthorizeException("No tabs defined!!");
}
areaId = tabs.get(0).getId();
}
else
{
EditTabResearcherPage fuzzyEditTab = (EditTabResearcherPage)((ApplicationService)getApplicationService()).<BoxResearcherPage, TabResearcherPage, EditTabResearcherPage>getEditTabByDisplayTab(Integer.parseInt(paramFuzzyTabId),EditTabResearcherPage.class);
areaId = fuzzyEditTab.getId();
}
}
else
{
areaId = Integer.parseInt(paramTabId);
}
EditTabResearcherPage editT = getApplicationService().get(
EditTabResearcherPage.class, areaId);
List<BoxResearcherPage> propertyHolders = new LinkedList<BoxResearcherPage>();
if (editT.getDisplayTab() != null)
{
for (BoxResearcherPage box : editT.getDisplayTab()
.getMask())
{
propertyHolders.add(box);
}
}
else
{
propertyHolders = getApplicationService().findPropertyHolderInTab(
getClazzTab(), areaId);
}
List<IContainable> tipProprietaInArea = new LinkedList<IContainable>();
for (BoxResearcherPage iph : propertyHolders)
{
if (editT.getDisplayTab() != null)
{
tipProprietaInArea
.addAll(getApplicationService()
.<BoxResearcherPage, it.cilea.osd.jdyna.web.Tab<BoxResearcherPage>> findContainableInPropertyHolder(
BoxResearcherPage.class,
iph.getId()));
}
else
{
tipProprietaInArea
.addAll(getApplicationService()
.<BoxResearcherPage, it.cilea.osd.jdyna.web.Tab<BoxResearcherPage>> findContainableInPropertyHolder(
getClazzBox(), iph.getId()));
}
}
RPAdditionalFieldStorage dynamicObject = researcher.getDynamicField();
RPAnagraficaObjectDTO anagraficaObjectDTO = new RPAnagraficaObjectDTO(
researcher);
anagraficaObjectDTO.setTabId(areaId);
anagraficaObjectDTO.setObjectId(dynamicObject.getId());
anagraficaObjectDTO.setParentId(researcher.getId());
List<RPPropertiesDefinition> realTPS = new LinkedList<RPPropertiesDefinition>();
List<IContainable> structuralField = new LinkedList<IContainable>();
for (IContainable c : tipProprietaInArea)
{