Search in sources :

Example 26 with OrcidSolrDocument

use of org.orcid.utils.solr.entities.OrcidSolrDocument in project ORCID-Source by ORCID.

the class SolrDaoTest method buildSupplementaryOrcid.

private OrcidSolrDocument buildSupplementaryOrcid() {
    OrcidSolrDocument secondOrcidDoc = new OrcidSolrDocument();
    secondOrcidDoc.setCreditName("Credit Name");
    secondOrcidDoc.addEmailAddress("stan@ficitional.co.uk");
    secondOrcidDoc.setFamilyName("Family Name");
    secondOrcidDoc.setGivenNames("Given Names");
    secondOrcidDoc.setDigitalObjectIds(Arrays.asList(new String[] { "id1", "id2" }));
    secondOrcidDoc.setOtherNames(Arrays.asList(new String[] { "Other Name 1", "Other Name 2" }));
    secondOrcidDoc.setWorkTitles(Arrays.asList(new String[] { "Work Title 1", "Work Title 2" }));
    secondOrcidDoc.setGrantNumbers(Arrays.asList(new String[] { "Grant-number02X:" }));
    return secondOrcidDoc;
}
Also used : OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument)

Example 27 with OrcidSolrDocument

use of org.orcid.utils.solr.entities.OrcidSolrDocument in project ORCID-Source by ORCID.

the class SolrDaoTest method queryFieldWithBoost.

@Test
public void queryFieldWithBoost() throws Exception {
    OrcidSolrDocument firstOrcidDoc = buildFirstOrcid();
    firstOrcidDoc.setOrcid(firstOrcid);
    firstOrcidDoc.setFamilyName("James");
    OrcidSolrDocument secondOrcidDoc = buildSupplementaryOrcid();
    secondOrcidDoc.setOrcid(secondOrcid);
    secondOrcidDoc.setGivenNames("James");
    solrDao.persist(firstOrcidDoc);
    solrDao.persist(secondOrcidDoc);
    String familyNameGivenNameQuery = "{!edismax qf='family-name^1.0 given-names^2.0'}James";
    List<OrcidSolrResult> solrResults = solrDao.findByDocumentCriteria(familyNameGivenNameQuery, null, null).getResults();
    assertTrue(solrResults.size() == 2);
    assertTrue(solrResults.get(0).getOrcid().equals(secondOrcid));
    assertTrue(solrResults.get(1).getOrcid().equals(firstOrcid));
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) Test(org.junit.Test)

Example 28 with OrcidSolrDocument

use of org.orcid.utils.solr.entities.OrcidSolrDocument in project ORCID-Source by ORCID.

the class SolrDaoTest method buildAndPersistFirstOrcid.

private OrcidSolrDocument buildAndPersistFirstOrcid() {
    OrcidSolrDocument firstDocument = buildFirstOrcid();
    firstDocument.setOrcid(firstOrcid);
    persistOrcid(firstDocument);
    return firstDocument;
}
Also used : OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument)

Example 29 with OrcidSolrDocument

use of org.orcid.utils.solr.entities.OrcidSolrDocument in project ORCID-Source by ORCID.

the class SolrDaoTest method queryFieldWithKeyword.

@Test
public void queryFieldWithKeyword() throws Exception {
    buildAndPersistFirstOrcid();
    OrcidSolrDocument secondDoc = buildSupplementaryOrcid();
    String subjectKeyword1 = "Advanced Muppetry";
    String subjectKeyword2 = "Basic Muppetry";
    secondDoc.setOrcid(secondOrcid);
    secondDoc.setKeywords(Arrays.asList(subjectKeyword1, subjectKeyword2));
    persistOrcid(secondDoc);
    String familyNameKeywordsQueryString = "given-names:given AND keyword:basic";
    List<OrcidSolrResult> solrResults = solrDao.findByDocumentCriteria(familyNameKeywordsQueryString, null, null).getResults();
    assertTrue(solrResults.size() == 1);
    OrcidSolrResult result = solrResults.get(0);
    assertEquals(secondOrcid, result.getOrcid());
    familyNameKeywordsQueryString = "given-names:given AND keyword:advanced";
    solrResults = solrDao.findByDocumentCriteria(familyNameKeywordsQueryString, null, null).getResults();
    assertTrue(solrResults.size() == 1);
    result = solrResults.get(0);
    assertEquals(secondOrcid, result.getOrcid());
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) Test(org.junit.Test)

Example 30 with OrcidSolrDocument

use of org.orcid.utils.solr.entities.OrcidSolrDocument in project ORCID-Source by ORCID.

the class SolrDaoTest method queryFieldWeyword.

@Test
public void queryFieldWeyword() throws Exception {
    buildAndPersistFirstOrcid();
    OrcidSolrDocument secondDoc = buildSupplementaryOrcid();
    String subjectKeyword1 = "Advanced Muppetry";
    String subjectKeyword2 = "Basic Muppetry";
    secondDoc.setOrcid(secondOrcid);
    secondDoc.setKeywords(Arrays.asList(subjectKeyword1, subjectKeyword2));
    persistOrcid(secondDoc);
    String familyNameKeywordsQueryString = "given-names:given AND keyword:basic";
    List<OrcidSolrResult> solrResults = solrDao.findByDocumentCriteria(familyNameKeywordsQueryString, null, null).getResults();
    assertTrue(solrResults.size() == 1);
    OrcidSolrResult result = solrResults.get(0);
    assertEquals(secondOrcid, result.getOrcid());
    familyNameKeywordsQueryString = "given-names:given AND keyword:advanced";
    solrResults = solrDao.findByDocumentCriteria(familyNameKeywordsQueryString, null, null).getResults();
    assertTrue(solrResults.size() == 1);
    result = solrResults.get(0);
    assertEquals(secondOrcid, result.getOrcid());
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) Test(org.junit.Test)

Aggregations

OrcidSolrDocument (org.orcid.utils.solr.entities.OrcidSolrDocument)31 Test (org.junit.Test)16 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)12 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)11 OrcidSolrResult (org.orcid.utils.solr.entities.OrcidSolrResult)9 ArrayList (java.util.ArrayList)4 BaseTest (org.orcid.core.BaseTest)4 Funding (org.orcid.jaxb.model.record_v2.Funding)4 Rollback (org.springframework.test.annotation.Rollback)4 HashMap (java.util.HashMap)3 List (java.util.List)3 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)3 Record (org.orcid.jaxb.model.record_v2.Record)3 OrcidRecordToSolrDocument (org.orcid.listener.solr.OrcidRecordToSolrDocument)3 OrcidSolrResults (org.orcid.utils.solr.entities.OrcidSolrResults)3 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)2 Email (org.orcid.jaxb.model.message.Email)2 ExternalIdReference (org.orcid.jaxb.model.message.ExternalIdReference)2 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)2 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)2