.getObject());
Project rg = null;
// use dto to fill dynamic metadata
AnagraficaObjectDTO dtoRG = new AnagraficaObjectDTO();
AnagraficaObjectWithTypeDTO dtoNested = new AnagraficaObjectWithTypeDTO();
if (projectcode != null && !projectcode.isEmpty())
{
rg = applicationService
.getResearcherGrantByCode(projectcode
.trim());
}
else
{
log.error("Grant discarded ( projectCode not founded) [researcher: "
+ ResearcherPageUtils
.getPersistentIdentifier(rp) + "]");
discardImported++;
continue;
}
// skip if only new grants mode and rg is found
if (newly && rg != null)
{
skipImported++;
continue;
}
// create new grants
if (rg == null)
{
log.info("Create new GRANT with code "
+ projectcode);
rg = new Project();
rg.setSourceID(projectcode);
rg.setStatus(active);
newImported++;
}
else
{
log.info("Edit GRANT with code " + projectcode);
editImported++;
}
List<RPNestedPropertiesDefinition> subTps = nestedObject.getTypo().getMask();
AnagraficaUtils
.fillDTO(dtoNested, nestedObject, subTps);
List<ProjectPropertiesDefinition> rgTps = applicationService
.getList(ProjectPropertiesDefinition.class);
for (String key : dtoNested.getAnagraficaProperties()
.keySet())
{
dtoRG.getAnagraficaProperties().put(
key,
dtoNested.getAnagraficaProperties()
.get(key));
}
// get investigators/coninvestigator
List<ValoreDTO> investigatorDTO = dtoRG
.getAnagraficaProperties().get(
UtilsXML.GRANT_TAG_INVESTIGATOR);
for (ValoreDTO vv : investigatorDTO)
{
EmbeddedLinkValue link = (EmbeddedLinkValue) vv
.getObject();
if (link != null)
{
if (link.getValueLink() != null
&& !link.getValueLink().isEmpty())
{
dtoRG.getAnagraficaProperties()
.put("principalinvestigator",
dtoNested
.getAnagraficaProperties()
.get("principalinvestigator")
);
}
else
{
dtoRG.getAnagraficaProperties()
.put("extprincipalinvestigator",
dtoNested
.getAnagraficaProperties()
.get("extprincipalinvestigator")
);
}
}
}
List<ValoreDTO> coinvestigatorDTO = dtoRG
.getAnagraficaProperties().get(
UtilsXML.GRANT_TAG_COINVESTIGATOR);
for (ValoreDTO vv : coinvestigatorDTO)
{
EmbeddedLinkValue link = (EmbeddedLinkValue) vv
.getObject();
if (link != null)
{
if (link.getValueLink() != null
&& !link.getValueLink().isEmpty())
{
dtoRG.getAnagraficaProperties()
.put("coinvestigator",
dtoNested
.getAnagraficaProperties()
.get("coinvestigator")
);
}
else
{
dtoRG.getAnagraficaProperties()
.put("extcoinvestigator",
dtoNested
.getAnagraficaProperties()
.get("extcoinvestigator")
);
}