Search in sources :

Example 66 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.

the class OrcidJaxbCopyManagerImpl method copyActivitiesToExistingPreservingVisibility.

@SuppressWarnings({ "unchecked", "rawtypes" })
private void copyActivitiesToExistingPreservingVisibility(ActivitiesContainer existingActivities, ActivitiesContainer updatedActivities, Visibility defaultVisibility) {
    if (updatedActivities == null) {
        return;
    }
    if (existingActivities == null) {
        try {
            existingActivities = updatedActivities.getClass().newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    Map<String, ? extends Activity> updatedActivitiesMap = updatedActivities.retrieveActivitiesAsMap();
    Source targetSource = createSource();
    for (Iterator<? extends Activity> existingActivitiesIterator = existingActivities.retrieveActivities().iterator(); existingActivitiesIterator.hasNext(); ) {
        Activity existingActivity = existingActivitiesIterator.next();
        Activity updatedActivity = updatedActivitiesMap.get(existingActivity.getPutCode());
        if (updatedActivity == null) {
            if (!(Visibility.PRIVATE.equals(existingActivity.getVisibility()) || isFromDifferentSource(existingActivity))) {
                // Remove existing activities unless they are private (we
                // need to keep those because the API user won't even know
                // they are there) or they are from another source
                existingActivitiesIterator.remove();
            }
        } else {
            // Check the source of the existing activity is the same as
            // the current source
            checkSource(existingActivity);
            if (updatedActivity.getVisibility() == null || !updatedActivity.getVisibility().equals(existingActivity.getVisibility())) {
                // Keep the visibility from the existing activity unless
                // was set by API user
                updatedActivity.setVisibility(existingActivity.getVisibility());
            }
            addSourceToActivity(updatedActivity, targetSource);
            // Can remove existing object because will be replaced by
            // incoming
            existingActivitiesIterator.remove();
        }
    }
    for (Activity updatedActivity : updatedActivities.retrieveActivities()) {
        // Set default visibility for any remaining incoming affiliations
        if (updatedActivity.getVisibility() == null) {
            updatedActivity.setVisibility(defaultVisibility);
        }
        if (updatedActivity.getPutCode() == null) {
            // Check source is correct for any newly added activities, if
            // mentioned
            addSourceToActivity(updatedActivity, targetSource);
        }
        if (updatedActivity instanceof OrcidWork) {
            ((OrcidWork) updatedActivity).setModified(true);
        }
    }
    existingActivities.retrieveActivities().addAll((List) updatedActivities.retrieveActivities());
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Activity(org.orcid.jaxb.model.message.Activity) Source(org.orcid.jaxb.model.message.Source)

Example 67 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.

the class OrcidProfileManagerImpl method checkWorkExternalIdentifiersAreNotDuplicated.

/**
 * Checks if the list of updated works contains any duplicated external
 * identifier, if so, it will throw an exception The newOrcidWorksList MUST
 * be deduped before getting into this method
 *
 * @param updatedOrcidWorksList
 *            the deduped list of works
 * @throws IllegalArgumentException
 *             if there is a duplicated external identifier
 */
public void checkWorkExternalIdentifiersAreNotDuplicated(List<OrcidWork> newOrcidWorksList, List<OrcidWork> existingWorkList) {
    // from the same source, so, we can skip the work source comparison
    if (newOrcidWorksList != null) {
        for (int i = 0; i < newOrcidWorksList.size(); i++) {
            OrcidWork newWork = newOrcidWorksList.get(i);
            for (int j = 0; j < newOrcidWorksList.size(); j++) {
                // If they are not the same work
                if (i != j) {
                    OrcidWork newWorkToCompare = newOrcidWorksList.get(j);
                    // If newWork have external identifiers
                    if (newWork.getWorkExternalIdentifiers() != null && newWork.getWorkExternalIdentifiers().getWorkExternalIdentifier() != null && !newWork.getWorkExternalIdentifiers().getWorkExternalIdentifier().isEmpty()) {
                        // For each external id on the outer work
                        for (WorkExternalIdentifier workExtId : newWork.getWorkExternalIdentifiers().getWorkExternalIdentifier()) {
                            if (newWorkToCompare.getWorkExternalIdentifiers() != null && newWorkToCompare.getWorkExternalIdentifiers().getWorkExternalIdentifier() != null && !newWorkToCompare.getWorkExternalIdentifiers().getWorkExternalIdentifier().isEmpty()) {
                                // the inner work
                                for (WorkExternalIdentifier workExtIdToCompare : newWorkToCompare.getWorkExternalIdentifiers().getWorkExternalIdentifier()) {
                                    // If the ext ids are the same
                                    if (workExtId.equals(workExtIdToCompare)) {
                                        Title title = (newWork.getWorkTitle() == null || newWork.getWorkTitle().getTitle() == null) ? null : newWork.getWorkTitle().getTitle();
                                        Title titleToCompare = (newWorkToCompare.getWorkTitle() == null || newWorkToCompare.getWorkTitle().getTitle() == null) ? null : newWorkToCompare.getWorkTitle().getTitle();
                                        if (!isTheSameTitle(title, titleToCompare) && !areBothExtIdsPartOf(newWork.getWorkType(), workExtId, workExtIdToCompare)) {
                                            String extIdContent = (workExtId.getWorkExternalIdentifierId() == null || PojoUtil.isEmpty(workExtId.getWorkExternalIdentifierId().getContent())) ? "" : workExtId.getWorkExternalIdentifierId().getContent();
                                            String title1 = (title == null) ? "" : title.getContent();
                                            String title2 = (titleToCompare == null) ? "" : titleToCompare.getContent();
                                            String errorMessage = String.format("Works \"%s\" and \"%s\" have the same external id \"%s\"", title1, title2, extIdContent);
                                            throw new IllegalArgumentException(errorMessage);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // Then, if it already have works
    if (existingWorkList != null && existingWorkList.size() > 0) {
        // Check for duplicates between the existing works and the new works
        if (newOrcidWorksList != null) {
            for (OrcidWork orcidWork : newOrcidWorksList) {
                Source workSource = orcidWork.getSource();
                for (OrcidWork existingWork : existingWorkList) {
                    Source existingWorkSource = existingWork.getSource();
                    // If both works have the same source
                    if (isTheSameSource(workSource, existingWorkSource)) {
                        // If the new work have external identifiers
                        if (orcidWork.getWorkExternalIdentifiers() != null && orcidWork.getWorkExternalIdentifiers().getWorkExternalIdentifier() != null && !orcidWork.getWorkExternalIdentifiers().getWorkExternalIdentifier().isEmpty()) {
                            // For each external identifier in the new work
                            for (WorkExternalIdentifier newExternalIdentifier : orcidWork.getWorkExternalIdentifiers().getWorkExternalIdentifier()) {
                                if (existingWork.getWorkExternalIdentifiers() != null && existingWork.getWorkExternalIdentifiers().getWorkExternalIdentifier() != null && !existingWork.getWorkExternalIdentifiers().getWorkExternalIdentifier().isEmpty()) {
                                    // identifiers
                                    for (WorkExternalIdentifier existingExternalIdentifier : existingWork.getWorkExternalIdentifiers().getWorkExternalIdentifier()) {
                                        // If the ext ids are the same
                                        if (newExternalIdentifier.equals(existingExternalIdentifier)) {
                                            // Compare the titles, if they
                                            // are different, set it as
                                            // duplicated
                                            Title title = (orcidWork.getWorkTitle() == null || orcidWork.getWorkTitle().getTitle() == null) ? null : orcidWork.getWorkTitle().getTitle();
                                            Title titleToCompare = (existingWork.getWorkTitle() == null || existingWork.getWorkTitle().getTitle() == null) ? null : existingWork.getWorkTitle().getTitle();
                                            if (!isTheSameTitle(title, titleToCompare) && !areBothExtIdsPartOf(orcidWork.getWorkType(), existingExternalIdentifier, newExternalIdentifier)) {
                                                String extIdContent = (existingExternalIdentifier.getWorkExternalIdentifierId() == null || PojoUtil.isEmpty(existingExternalIdentifier.getWorkExternalIdentifierId().getContent())) ? "" : existingExternalIdentifier.getWorkExternalIdentifierId().getContent();
                                                String title1 = (title == null) ? "" : title.getContent();
                                                String title2 = (titleToCompare == null) ? "" : titleToCompare.getContent();
                                                String errorMessage = String.format("Works \"%s\" and \"%s\"(put-code '%s') have the same external id \"%s\"", title1, title2, existingWork.getPutCode(), extIdContent);
                                                throw new IllegalArgumentException(errorMessage);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Title(org.orcid.jaxb.model.message.Title) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) Source(org.orcid.jaxb.model.message.Source)

Example 68 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.

the class OrcidSearchManagerImpl method buildSearchResultsFromPublicProfile.

private List<OrcidSearchResult> buildSearchResultsFromPublicProfile(List<OrcidSolrResult> solrResults) {
    List<OrcidSearchResult> orcidSearchResults = new ArrayList<OrcidSearchResult>();
    for (OrcidSolrResult solrResult : solrResults) {
        OrcidMessage orcidMessage = null;
        String orcid = solrResult.getOrcid();
        try {
            orcidSecurityManager.checkProfile(orcid);
        } catch (DeactivatedException | LockedException | OrcidDeprecatedException x) {
            OrcidSearchResult orcidSearchResult = new OrcidSearchResult();
            RelevancyScore relevancyScore = new RelevancyScore();
            relevancyScore.setValue(solrResult.getRelevancyScore());
            orcidSearchResult.setRelevancyScore(relevancyScore);
            OrcidProfile orcidProfile = new OrcidProfile();
            orcidProfile.setOrcidIdentifier(new OrcidIdentifier(jpaJaxbAdapter.getOrcidIdBase(orcid)));
            OrcidHistory history = new OrcidHistory();
            Date recordLastModified = profileDaoReadOnly.retrieveLastModifiedDate(orcid);
            history.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(recordLastModified)));
            orcidProfile.setOrcidHistory(history);
            orcidSearchResult.setOrcidProfile(orcidProfile);
            orcidSearchResults.add(orcidSearchResult);
            continue;
        }
        if (cachingSource.equals(SOLR)) {
            try (Reader reader = solrDao.findByOrcidAsReader(orcid)) {
                if (reader != null) {
                    BufferedReader br = new BufferedReader(reader);
                    orcidMessage = OrcidMessage.unmarshall(br);
                }
            } catch (IOException e) {
                throw new OrcidSearchException("Error closing record stream from solr search results for orcid: " + orcid, e);
            }
        }
        OrcidProfile orcidProfile = null;
        if (orcidMessage == null) {
            // Fall back to DB
            orcidProfile = orcidProfileCacheManager.retrievePublicBio(orcid);
        } else {
            orcidProfile = orcidMessage.getOrcidProfile();
        }
        if (orcidProfile != null) {
            OrcidSearchResult orcidSearchResult = new OrcidSearchResult();
            RelevancyScore relevancyScore = new RelevancyScore();
            relevancyScore.setValue(solrResult.getRelevancyScore());
            orcidSearchResult.setRelevancyScore(relevancyScore);
            OrcidWorks orcidWorksTitlesOnly = new OrcidWorks();
            OrcidWorks fullOrcidWorks = orcidProfile.retrieveOrcidWorks();
            if (fullOrcidWorks != null && !fullOrcidWorks.getOrcidWork().isEmpty()) {
                for (OrcidWork fullOrcidWork : fullOrcidWorks.getOrcidWork()) {
                    OrcidWork orcidWorkSubset = new OrcidWork();
                    orcidWorkSubset.setVisibility(fullOrcidWork.getVisibility());
                    orcidWorkSubset.setWorkTitle(fullOrcidWork.getWorkTitle());
                    orcidWorkSubset.setWorkExternalIdentifiers(fullOrcidWork.getWorkExternalIdentifiers());
                    orcidWorksTitlesOnly.getOrcidWork().add(orcidWorkSubset);
                }
            }
            FundingList reducedFundings = new FundingList();
            FundingList fullOrcidFundings = orcidProfile.retrieveFundings();
            if (fullOrcidFundings != null && !fullOrcidFundings.getFundings().isEmpty()) {
                for (Funding fullOrcidFunding : fullOrcidFundings.getFundings()) {
                    Funding reducedFunding = new Funding();
                    reducedFunding.setVisibility(fullOrcidFunding.getVisibility());
                    reducedFunding.setDescription(fullOrcidFunding.getDescription());
                    reducedFunding.setTitle(fullOrcidFunding.getTitle());
                    reducedFundings.getFundings().add(reducedFunding);
                }
            }
            orcidProfile.setOrcidWorks(orcidWorksTitlesOnly);
            orcidProfile.setFundings(reducedFundings);
            orcidSearchResult.setOrcidProfile(orcidProfile);
            orcidSearchResults.add(orcidSearchResult);
        }
    }
    return orcidSearchResults;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.message.LastModifiedDate) LockedException(org.orcid.core.security.aop.LockedException) OrcidSearchException(org.orcid.core.exception.OrcidSearchException) Funding(org.orcid.jaxb.model.message.Funding) ArrayList(java.util.ArrayList) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Reader(java.io.Reader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) Date(java.util.Date) LastModifiedDate(org.orcid.jaxb.model.message.LastModifiedDate) DeactivatedException(org.orcid.core.exception.DeactivatedException) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) RelevancyScore(org.orcid.jaxb.model.message.RelevancyScore) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) FundingList(org.orcid.jaxb.model.message.FundingList) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) BufferedReader(java.io.BufferedReader)

Example 69 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.

the class Jpa2JaxbAdapterTest method checkSourceOnAllElements.

@Test
@Transactional
public void checkSourceOnAllElements() {
    ProfileEntity profileEntity = profileDao.find(userOrcid);
    assertNotNull(profileEntity);
    assertEquals(userOrcid, profileEntity.getId());
    OrcidProfile orcidProfile = adapter.toOrcidProfile(profileEntity, LoadOptions.ALL);
    assertNotNull(orcidProfile);
    testOrcidIdentifier(orcidProfile.getOrcidIdentifier());
    assertNotNull(orcidProfile.getOrcidActivities());
    // Check works
    OrcidWorks orcidWorks = orcidProfile.getOrcidActivities().getOrcidWorks();
    if (orcidWorks != null && orcidWorks.getOrcidWork() != null && !orcidWorks.getOrcidWork().isEmpty()) {
        for (OrcidWork work : orcidWorks.getOrcidWork()) {
            checkSource(work.getSource(), null);
        }
    }
    // Check affiliations
    Affiliations affiliations = orcidProfile.getOrcidActivities().getAffiliations();
    if (affiliations != null && affiliations.getAffiliation() != null && !affiliations.getAffiliation().isEmpty()) {
        for (Affiliation affiliation : affiliations.getAffiliation()) {
            checkSource(affiliation.getSource(), null);
        }
    }
    // Check fundings
    FundingList fundings = orcidProfile.getOrcidActivities().getFundings();
    if (fundings != null && fundings.getFundings() != null && !fundings.getFundings().isEmpty()) {
        for (Funding funding : fundings.getFundings()) {
            checkSource(funding.getSource(), null);
        }
    }
    assertNotNull(orcidProfile.getOrcidBio());
    // Check external identifiers
    ExternalIdentifiers extIds = orcidProfile.getOrcidBio().getExternalIdentifiers();
    if (extIds != null && extIds.getExternalIdentifier() != null && !extIds.getExternalIdentifier().isEmpty()) {
        for (ExternalIdentifier extId : extIds.getExternalIdentifier()) {
            checkSource(extId.getSource(), null);
        }
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) Affiliations(org.orcid.jaxb.model.message.Affiliations) Funding(org.orcid.jaxb.model.message.Funding) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 70 with OrcidWork

use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.

the class OrcidProfileToSolrDocument method convert.

@Deprecated
public OrcidSolrDocument convert(OrcidProfile profile) {
    // Check if the profile is locked
    if (profile.isLocked()) {
        profile.downgradeToOrcidIdentifierOnly();
    }
    OrcidSolrDocument profileIndexDocument = new OrcidSolrDocument();
    profileIndexDocument.setOrcid(profile.getOrcidIdentifier().getPath());
    OrcidDeprecated orcidDeprecated = profile.getOrcidDeprecated();
    if (orcidDeprecated != null) {
        profileIndexDocument.setPrimaryRecord(orcidDeprecated.getPrimaryRecord() != null ? orcidDeprecated.getPrimaryRecord().getOrcidIdentifier().getPath() : null);
    }
    OrcidBio orcidBio = profile.getOrcidBio();
    if (orcidBio != null) {
        PersonalDetails personalDetails = orcidBio.getPersonalDetails();
        boolean persistPersonalDetails = personalDetails != null;
        if (persistPersonalDetails) {
            profileIndexDocument.setFamilyName(personalDetails.getFamilyName() != null ? personalDetails.getFamilyName().getContent() : null);
            profileIndexDocument.setGivenNames(personalDetails.getGivenNames() != null ? personalDetails.getGivenNames().getContent() : null);
            profileIndexDocument.setCreditName(personalDetails.getCreditName() != null ? personalDetails.getCreditName().getContent() : null);
            List<OtherName> otherNames = personalDetails.getOtherNames() != null ? personalDetails.getOtherNames().getOtherName() : null;
            if (otherNames != null && !otherNames.isEmpty()) {
                List<String> names = new ArrayList<String>();
                for (OtherName otherName : otherNames) {
                    names.add(otherName.getContent());
                }
                profileIndexDocument.setOtherNames(names);
            }
        }
        ContactDetails contactDetails = orcidBio.getContactDetails();
        if (contactDetails != null) {
            for (Email email : contactDetails.getEmail()) {
                profileIndexDocument.addEmailAddress(email.getValue());
            }
        }
        ExternalIdentifiers externalIdentifiers = orcidBio.getExternalIdentifiers();
        if (externalIdentifiers != null) {
            List<String> extIdOrcids = new ArrayList<String>();
            List<String> extIdRefs = new ArrayList<String>();
            List<String> extIdOrcidsAndRefs = new ArrayList<String>();
            for (ExternalIdentifier externalIdentifier : externalIdentifiers.getExternalIdentifier()) {
                Source source = externalIdentifier.getSource();
                String sourcePath = null;
                if (source != null) {
                    sourcePath = source.retrieveSourcePath();
                    if (sourcePath != null) {
                        extIdOrcids.add(sourcePath);
                    }
                }
                ExternalIdReference externalIdReference = externalIdentifier.getExternalIdReference();
                if (externalIdReference != null) {
                    extIdRefs.add(externalIdReference.getContent());
                }
                if (NullUtils.noneNull(sourcePath, externalIdReference)) {
                    extIdOrcidsAndRefs.add(sourcePath + "=" + externalIdReference.getContent());
                }
            }
            if (!extIdOrcids.isEmpty()) {
                profileIndexDocument.setExternalIdSources(extIdOrcids);
            }
            if (!extIdRefs.isEmpty()) {
                profileIndexDocument.setExternalIdReferences(extIdRefs);
            }
            if (!extIdOrcidsAndRefs.isEmpty()) {
                profileIndexDocument.setExternalIdSourcesAndReferences(extIdOrcidsAndRefs);
            }
        }
        OrcidActivities orcidActivities = profile.getOrcidActivities();
        if (orcidActivities != null) {
            if (orcidBio != null && orcidBio.getKeywords() != null) {
                List<Keyword> keyWords = orcidBio.getKeywords().getKeyword();
                if (keyWords != null && keyWords.size() > 0) {
                    List<String> keywordValues = new ArrayList<String>();
                    for (Keyword keyword : keyWords) {
                        keywordValues.add(keyword.getContent());
                    }
                    profileIndexDocument.setKeywords(keywordValues);
                }
            }
        }
        List<OrcidWork> orcidWorks = profile.retrieveOrcidWorks() != null ? profile.retrieveOrcidWorks().getOrcidWork() : null;
        if (orcidWorks != null) {
            List<String> workTitles = new ArrayList<String>();
            Map<WorkExternalIdentifierType, List<String>> allExternalIdentifiers = new HashMap<WorkExternalIdentifierType, List<String>>();
            for (OrcidWork orcidWork : orcidWorks) {
                if (orcidWork.getWorkExternalIdentifiers() != null) {
                    for (WorkExternalIdentifier workExternalIdentifier : orcidWork.getWorkExternalIdentifiers().getWorkExternalIdentifier()) {
                        /**
                         * Creates a map that contains all different
                         * external identifiers for the current work
                         */
                        boolean nullSafeCheckForWorkExternalIdentifier = workExternalIdentifier.getWorkExternalIdentifierId() != null && !StringUtils.isBlank(workExternalIdentifier.getWorkExternalIdentifierId().getContent());
                        if (nullSafeCheckForWorkExternalIdentifier) {
                            WorkExternalIdentifierType type = workExternalIdentifier.getWorkExternalIdentifierType();
                            if (!allExternalIdentifiers.containsKey(type)) {
                                List<String> content = new ArrayList<String>();
                                content.add(workExternalIdentifier.getWorkExternalIdentifierId().getContent());
                                allExternalIdentifiers.put(type, content);
                            } else {
                                allExternalIdentifiers.get(type).add(workExternalIdentifier.getWorkExternalIdentifierId().getContent());
                            }
                        }
                    }
                }
                if (orcidWork.getWorkTitle() != null) {
                    Title workMainTitle = orcidWork.getWorkTitle().getTitle();
                    Subtitle worksubTitle = orcidWork.getWorkTitle().getSubtitle();
                    TranslatedTitle translatedTitle = orcidWork.getWorkTitle().getTranslatedTitle();
                    if (workMainTitle != null && !StringUtils.isBlank(workMainTitle.getContent())) {
                        workTitles.add(workMainTitle.getContent());
                    }
                    if (worksubTitle != null && !StringUtils.isBlank(worksubTitle.getContent())) {
                        workTitles.add(worksubTitle.getContent());
                    }
                    if (translatedTitle != null && !StringUtils.isBlank(translatedTitle.getContent())) {
                        workTitles.add(translatedTitle.getContent());
                    }
                }
            }
            profileIndexDocument.setWorkTitles(workTitles);
            // Set the list of external identifiers to the document list
            addExternalIdentifiersToIndexDocument(profileIndexDocument, allExternalIdentifiers);
        }
        List<Funding> orcidFundings = profile.retrieveFundings() != null ? profile.retrieveFundings().getFundings() : null;
        if (orcidFundings != null) {
            List<String> fundingTitle = new ArrayList<String>();
            for (Funding orcidFunding : orcidFundings) {
                FundingTitle title = orcidFunding.getTitle();
                if (title != null) {
                    if (title.getTitle() != null && !StringUtils.isBlank(title.getTitle().getContent())) {
                        fundingTitle.add(title.getTitle().getContent());
                    }
                    if (title.getTranslatedTitle() != null && StringUtils.isBlank(title.getTranslatedTitle().getContent())) {
                        fundingTitle.add(title.getTranslatedTitle().getContent());
                    }
                }
            }
            profileIndexDocument.setFundingTitles(fundingTitle);
        }
    }
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    orcidMessage.setOrcidProfile(profile);
    OrcidHistory orcidHistory = profile.getOrcidHistory();
    if (orcidHistory != null) {
        LastModifiedDate lastModifiedDate = orcidHistory.getLastModifiedDate();
        if (lastModifiedDate != null) {
            profileIndexDocument.setProfileLastModifiedDate(lastModifiedDate.getValue().toGregorianCalendar().getTime());
        }
        SubmissionDate submissionDate = orcidHistory.getSubmissionDate();
        if (submissionDate != null) {
            profileIndexDocument.setProfileSubmissionDate(submissionDate.getValue().toGregorianCalendar().getTime());
        }
    }
    return profileIndexDocument;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.message.LastModifiedDate) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) HashMap(java.util.HashMap) Funding(org.orcid.jaxb.model.message.Funding) ArrayList(java.util.ArrayList) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Source(org.orcid.jaxb.model.message.Source) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) ArrayList(java.util.ArrayList) List(java.util.List) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) WorkExternalIdentifierType(org.orcid.jaxb.model.message.WorkExternalIdentifierType) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) Keyword(org.orcid.jaxb.model.message.Keyword) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) OtherName(org.orcid.jaxb.model.message.OtherName) Title(org.orcid.jaxb.model.message.Title) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) TranslatedTitle(org.orcid.jaxb.model.message.TranslatedTitle) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Subtitle(org.orcid.jaxb.model.message.Subtitle) OrcidDeprecated(org.orcid.jaxb.model.message.OrcidDeprecated) TranslatedTitle(org.orcid.jaxb.model.message.TranslatedTitle) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) OrcidDeprecated(org.orcid.jaxb.model.message.OrcidDeprecated)

Aggregations

OrcidWork (org.orcid.jaxb.model.message.OrcidWork)81 Test (org.junit.Test)44 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)42 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)32 Transactional (org.springframework.transaction.annotation.Transactional)26 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)24 Title (org.orcid.jaxb.model.message.Title)23 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)20 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)18 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)16 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)16 Source (org.orcid.jaxb.model.message.Source)14 Rollback (org.springframework.test.annotation.Rollback)13 ArrayList (java.util.ArrayList)12 Funding (org.orcid.jaxb.model.message.Funding)12 WorkExternalIdentifierId (org.orcid.jaxb.model.message.WorkExternalIdentifierId)12 BaseTest (org.orcid.core.BaseTest)11 Contributor (org.orcid.jaxb.model.message.Contributor)11 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)11 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)10