use of org.orcid.utils.solr.entities.OrcidSolrDocument in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method solrDocWithAdditionalSubtitles.
private OrcidSolrDocument solrDocWithAdditionalSubtitles() {
OrcidSolrDocument orcidSolrDocument = fullyPopulatedSolrDocumentForPersistence();
orcidSolrDocument.setWorkTitles(Arrays.asList(new String[] { "Work title 1", "Subtitle 1", "Work title 2", "Subtitle 2" }));
OrcidProfile orcidProfile = getOrcidWithSubtitledWork();
OrcidMessage orcidMessage = createFilteredOrcidMessage(orcidProfile);
orcidSolrDocument.setPublicProfileMessage(orcidMessage.toString());
return orcidSolrDocument;
}
use of org.orcid.utils.solr.entities.OrcidSolrDocument in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method mandatoryDBFieldsSolrDocumentForPersistence.
/**
* According to the current schema - these fields are required by the DB -
* they may or may not make it into SOLR due to visibility restrictions
*
* @return
*/
private OrcidSolrDocument mandatoryDBFieldsSolrDocumentForPersistence() {
OrcidSolrDocument orcidSolrDocument = new OrcidSolrDocument();
orcidSolrDocument.setOrcid("5678");
orcidSolrDocument.setFamilyName("Logan");
orcidSolrDocument.setGivenNames("Donald Edward");
// orcidSolrDocument.setAffiliatePrimaryInstitutionNames(Arrays.asList(new
// String[] { "University of Portsmouth" }));
OrcidProfile orcidProfile = getOrcidProfileMandatoryOnly();
OrcidMessage orcidMessage = createFilteredOrcidMessage(orcidProfile);
orcidSolrDocument.setPublicProfileMessage(orcidMessage.toString());
return orcidSolrDocument;
}
use of org.orcid.utils.solr.entities.OrcidSolrDocument 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;
}
use of org.orcid.utils.solr.entities.OrcidSolrDocument in project ORCID-Source by ORCID.
the class OrcidRecordToSolrDocumentTest method test12SameAs20.
@Test
public void test12SameAs20() throws IOException, SolrServerException, JAXBException {
OrcidProfileToSolrDocument v12 = new OrcidProfileToSolrDocument();
OrcidRecordToSolrDocument v20 = new OrcidRecordToSolrDocument(false);
Record record = getRecord("/v20record.xml");
OrcidMessage message = getOrcidMessage();
OrcidSolrDocument v12Doc = v12.convert(message.getOrcidProfile());
OrcidSolrDocument v20Doc = v20.convert(record, new ArrayList<Funding>());
Assert.assertEquals(v12Doc.getOrcid(), v20Doc.getOrcid());
Assert.assertEquals(v12Doc.getFamilyName(), v20Doc.getFamilyName());
Assert.assertEquals(v12Doc.getGivenNames(), v20Doc.getGivenNames());
Assert.assertEquals(v12Doc.getGivenAndFamilyNames(), v20Doc.getGivenAndFamilyNames());
Assert.assertTrue(v12Doc.getDigitalObjectIds().containsAll(v20Doc.getDigitalObjectIds()));
Assert.assertTrue(v20Doc.getDigitalObjectIds().containsAll(v12Doc.getDigitalObjectIds()));
Assert.assertTrue(v12Doc.getWorkTitles().containsAll(v20Doc.getWorkTitles()));
Assert.assertTrue(v20Doc.getWorkTitles().containsAll(v12Doc.getWorkTitles()));
Assert.assertTrue(v12Doc.getCit().containsAll(v20Doc.getCit()));
Assert.assertTrue(v20Doc.getCit().containsAll(v12Doc.getCit()));
Assert.assertTrue(v12Doc.getAgr().containsAll(v20Doc.getAgr()));
Assert.assertTrue(v20Doc.getAgr().containsAll(v12Doc.getAgr()));
Assert.assertEquals(v12Doc.getProfileLastModifiedDate(), v20Doc.getProfileLastModifiedDate());
Assert.assertEquals(v12Doc.getProfileSubmissionDate(), v20Doc.getProfileSubmissionDate());
}
use of org.orcid.utils.solr.entities.OrcidSolrDocument in project ORCID-Source by ORCID.
the class OrcidRecordToSolrDocumentTest method testOrgIDAndGrantNumber.
@Test
public void testOrgIDAndGrantNumber() throws JAXBException {
Record record = getRecord("/v20record.xml");
OrcidRecordToSolrDocument v20 = new OrcidRecordToSolrDocument(false);
OrcidSolrDocument v20Doc = v20.convert(record, new ArrayList<Funding>());
Assert.assertTrue(v20Doc.getOrganisationIds().containsKey("ringgold-org-id"));
Assert.assertTrue(v20Doc.getOrganisationIds().get("ringgold-org-id").contains("5488"));
Assert.assertTrue(v20Doc.getOrganisationIds().get("ringgold-org-id").contains("4925"));
Assert.assertTrue(v20Doc.getOrganisationNames().get("affiliation-org-name").contains("Open University"));
Assert.assertTrue(v20Doc.getOrganisationNames().get("affiliation-org-name").contains("British Library"));
/*
Assert.assertTrue(v20Doc.getOrganisationNames().get("funding-org-name").contains("THOR - Technical and Human Infrastructure for Open Research"));
Assert.assertTrue(v20Doc.getGrantNumbers().contains("H2020-EU.1.4.1.3."));
*/
}
Aggregations