use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class Jaxb2JpaAdapterImpl method getWorkEntities.
private SortedSet<WorkEntity> getWorkEntities(ProfileEntity profileEntity, OrcidWorks orcidWorks) {
SortedSet<WorkEntity> existingWorkEntities = profileEntity.getWorks();
Map<String, WorkEntity> existingWorkEntitiesMap = createWorkEntitiesMap(existingWorkEntities);
SortedSet<WorkEntity> workEntities = null;
if (existingWorkEntities == null) {
workEntities = new TreeSet<WorkEntity>();
} else {
// To allow for orphan deletion
existingWorkEntities.clear();
workEntities = existingWorkEntities;
}
if (orcidWorks != null && orcidWorks.getOrcidWork() != null && !orcidWorks.getOrcidWork().isEmpty()) {
List<OrcidWork> orcidWorkList = orcidWorks.getOrcidWork();
for (OrcidWork orcidWork : orcidWorkList) {
WorkEntity workEntity = getWorkEntity(orcidWork, existingWorkEntitiesMap.get(orcidWork.getPutCode()));
if (workEntity != null) {
workEntity.setProfile(profileEntity);
workEntities.add(workEntity);
}
}
}
return workEntities;
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method checkForAlreadyExistingWorks.
private void checkForAlreadyExistingWorks(OrcidWorks existingOrcidWorks, List<OrcidWork> updatedOrcidWorksList) {
if (existingOrcidWorks != null) {
Set<OrcidWork> existingOrcidWorksSet = new HashSet<>();
for (OrcidWork existingWork : existingOrcidWorks.getOrcidWork()) {
existingOrcidWorksSet.add(existingWork);
}
for (Iterator<OrcidWork> updatedWorkIterator = updatedOrcidWorksList.iterator(); updatedWorkIterator.hasNext(); ) {
OrcidWork updatedWork = updatedWorkIterator.next();
for (OrcidWork orcidWork : existingOrcidWorksSet) {
if (orcidWork.isDuplicated(updatedWork)) {
// Update the existing work
long workId = Long.valueOf(orcidWork.getPutCode());
WorkEntity workEntity = workDao.find(workId);
workEntity.clean();
workEntity = jaxb2JpaAdapter.getWorkEntity(updatedWork, workEntity);
workDao.persist(workEntity);
// Since it was already updated, remove it from the list
// of updated works
updatedWorkIterator.remove();
break;
}
}
}
}
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidMessageUtil method setSourceName.
public void setSourceName(OrcidProfile orcidProfile) {
if (orcidProfile != null) {
if (orcidProfile.getOrcidActivities() != null) {
OrcidActivities orcidActivities = orcidProfile.getOrcidActivities();
if (orcidActivities.getAffiliations() != null) {
Affiliations affs = orcidActivities.getAffiliations();
List<Affiliation> affList = affs.getAffiliation();
if (affList != null) {
for (Affiliation aff : affList) {
setSourceName(aff);
}
}
}
if (orcidActivities.getFundings() != null) {
FundingList fundingList = orcidActivities.getFundings();
List<Funding> fundings = fundingList.getFundings();
if (fundings != null) {
for (Funding funding : fundings) {
setSourceName(funding);
}
}
}
if (orcidActivities.getOrcidWorks() != null) {
OrcidWorks orcidWorks = orcidActivities.getOrcidWorks();
List<OrcidWork> works = orcidWorks.getOrcidWork();
if (works != null) {
for (OrcidWork work : works) {
setSourceName(work);
}
}
}
}
if (orcidProfile.getOrcidBio() != null) {
OrcidBio orcidBio = orcidProfile.getOrcidBio();
if (orcidBio.getContactDetails() != null) {
Address address = orcidBio.getContactDetails().getAddress();
if (address != null) {
setSourceName(address);
}
}
if (orcidBio.getExternalIdentifiers() != null) {
ExternalIdentifiers extIds = orcidBio.getExternalIdentifiers();
List<ExternalIdentifier> extIdsList = extIds.getExternalIdentifier();
if (extIdsList != null) {
for (ExternalIdentifier extId : extIdsList) {
setSourceName(extId);
}
}
}
if (orcidBio.getKeywords() != null) {
Keywords keywords = orcidBio.getKeywords();
List<Keyword> keywordList = keywords.getKeyword();
if (keywordList != null) {
for (Keyword keyword : keywordList) {
setSourceName(keyword);
}
}
}
if (orcidBio.getPersonalDetails() != null) {
OtherNames otherNames = orcidBio.getPersonalDetails().getOtherNames();
if (otherNames != null) {
List<OtherName> otherNameList = otherNames.getOtherName();
if (otherNameList != null) {
for (OtherName otherName : otherNameList) {
setSourceName(otherName);
}
}
}
}
if (orcidBio.getResearcherUrls() != null) {
ResearcherUrls rUrls = orcidBio.getResearcherUrls();
List<ResearcherUrl> rUrlList = rUrls.getResearcherUrl();
if (rUrlList != null) {
for (ResearcherUrl rUrl : rUrlList) {
setSourceName(rUrl);
}
}
}
}
}
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class JpaJaxbEntityAdapterToProfileEntityTest method testReligiousTextConvertedFromBible.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Rollback(true)
public void testReligiousTextConvertedFromBible() throws Exception {
OrcidMessage orcidMessage = getOrcidMessage(ORCID_INTERNAL_FULL_XML);
List<OrcidWork> currentOrcidWorks = orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork();
assertTrue(currentOrcidWorks.size() == 1);
currentOrcidWorks.get(0).setWorkType(WorkType.DATA_SET);
ProfileEntity profileEntity = adapter.toProfileEntity(orcidMessage.getOrcidProfile());
List<WorkEntity> works = new ArrayList<WorkEntity>(profileEntity.getWorks());
assertEquals(1, works.size());
assertTrue(works.get(0).getWorkType().equals(org.orcid.jaxb.model.record_v2.WorkType.DATA_SET));
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class ValidationManagerImpl method doWorkTypeValidation.
private void doWorkTypeValidation(OrcidMessage orcidMessage) {
if (orcidMessage == null || orcidMessage.getOrcidProfile() == null || orcidMessage.getOrcidProfile().getOrcidActivities() == null || orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks() == null || orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork() == null || orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().isEmpty())
return;
List<OrcidWork> works = orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork();
for (OrcidWork work : works) {
if (work.getWorkType() == null)
if (work.getWorkTitle() != null && work.getWorkTitle().getTitle() != null && !PojoUtil.isEmpty(work.getWorkTitle().getTitle().getContent()))
handleError("work-type is missing or invalid for work: '" + work.getWorkTitle().getTitle().getContent() + "'");
else
handleError("work-type is missing or invalid");
}
}
Aggregations