use of org.orcid.pojo.OrgDisambiguatedExternalIdentifiers in project ORCID-Source by ORCID.
the class OrgDisambiguatedManagerImpl method findInDB.
@Override
@Transactional
public OrgDisambiguated findInDB(Long id) {
OrgDisambiguatedEntity orgDisambiguatedEntity = orgDisambiguatedDaoReadOnly.find(id);
OrgDisambiguated org = new OrgDisambiguated();
org.setValue(orgDisambiguatedEntity.getName());
org.setCity(orgDisambiguatedEntity.getCity());
org.setRegion(orgDisambiguatedEntity.getRegion());
org.setCountry(orgDisambiguatedEntity.getCountry() != null ? orgDisambiguatedEntity.getCountry().value() : null);
org.setOrgType(orgDisambiguatedEntity.getOrgType());
org.setSourceId(orgDisambiguatedEntity.getSourceId());
org.setSourceType(orgDisambiguatedEntity.getSourceType());
org.setUrl(orgDisambiguatedEntity.getUrl());
Map<String, OrgDisambiguatedExternalIdentifiers> externalIdsMap = new HashMap<String, OrgDisambiguatedExternalIdentifiers>();
if (orgDisambiguatedEntity.getExternalIdentifiers() != null && !orgDisambiguatedEntity.getExternalIdentifiers().isEmpty()) {
for (OrgDisambiguatedExternalIdentifierEntity extIdEntity : orgDisambiguatedEntity.getExternalIdentifiers()) {
String type = extIdEntity.getIdentifierType();
String identifier = extIdEntity.getIdentifier();
Boolean preferred = extIdEntity.getPreferred();
OrgDisambiguatedExternalIdentifiers extId = null;
if (externalIdsMap.containsKey(type)) {
extId = externalIdsMap.get(type);
} else {
extId = new OrgDisambiguatedExternalIdentifiers();
extId.setIdentifierType(type);
externalIdsMap.put(type, extId);
}
if (preferred) {
extId.setPreferred(identifier);
}
extId.getAll().add(identifier);
}
if (!externalIdsMap.isEmpty()) {
List<OrgDisambiguatedExternalIdentifiers> extIds = new ArrayList<OrgDisambiguatedExternalIdentifiers>();
externalIdsMap.keySet().stream().sorted().collect(Collectors.toList()).forEach(k -> {
extIds.add(externalIdsMap.get(k));
});
org.setOrgDisambiguatedExternalIdentifiers(extIds);
}
}
return org;
}
Aggregations