Search in sources :

Example 16 with Result

use of org.orcid.jaxb.model.v3.dev1.search.Result in project ORCID-Source by ORCID.

the class GroupIdRecordTest method testCreateAndView.

@Test
public void testCreateAndView() throws JSONException, InterruptedException, URISyntaxException, UnsupportedEncodingException {
    String token = oauthHelper.getClientCredentialsAccessToken(this.getClient1ClientId(), this.getClient1ClientSecret(), ScopePathType.GROUP_ID_RECORD_UPDATE);
    String groupId = "orcid-generated:test#" + System.currentTimeMillis();
    org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord g1 = new org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord();
    g1.setDescription("Description");
    g1.setGroupId(groupId);
    g1.setName(groupId);
    g1.setType("publisher");
    ClientResponse r1 = memberV3Dev1ApiClient.createGroupIdRecord(g1, token);
    assertEquals(ClientResponse.Status.CREATED.getStatusCode(), r1.getStatus());
    String r1LocationPutCode = r1.getLocation().getPath().replace("/orcid-api-web/v3.0_dev1/group-id-record/", "");
    Long putCode = Long.valueOf(r1LocationPutCode);
    ClientResponse result = memberV3Dev1ApiClient.getGroupIdRecord(putCode, token);
    assertEquals(Response.Status.OK.getStatusCode(), result.getStatus());
    org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord v3_0_dev1 = result.getEntity(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord.class);
    assertEquals(putCode, v3_0_dev1.getPutCode());
    assertEquals("publisher", v3_0_dev1.getType());
    assertEquals("Description", v3_0_dev1.getDescription());
    assertEquals(groupId, v3_0_dev1.getGroupId());
    assertEquals(groupId, v3_0_dev1.getName());
    assertNotNull(v3_0_dev1.getSource());
    assertEquals(this.getClient1ClientId(), v3_0_dev1.retrieveSourcePath());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) BlackBoxBaseV3_0_dev1(org.orcid.integration.blackbox.api.v3.dev1.BlackBoxBaseV3_0_dev1) Test(org.junit.Test)

Example 17 with Result

use of org.orcid.jaxb.model.v3.dev1.search.Result in project ORCID-Source by ORCID.

the class OrcidSearchManagerImpl method findOrcidIds.

@Override
public Search findOrcidIds(Map<String, List<String>> queryParameters) {
    Search search = new Search();
    OrcidSolrResults orcidSolrResults = solrDao.findByDocumentCriteria(queryParameters);
    if (orcidSolrResults != null && orcidSolrResults.getResults() != null) {
        List<Result> orcidIdList = orcidSolrResults.getResults().stream().map(r -> {
            Result result = new Result();
            result.setOrcidIdentifier(recordManagerReadOnly.getOrcidIdentifier(r.getOrcid()));
            return result;
        }).collect(Collectors.toList());
        search.getResults().addAll(orcidIdList);
        search.setNumFound(orcidSolrResults.getNumFound());
    } else {
        search.setNumFound(0L);
    }
    return search;
}
Also used : OrcidProfileCacheManager(org.orcid.core.manager.OrcidProfileCacheManager) OrcidSearchManager(org.orcid.core.manager.v3.OrcidSearchManager) Arrays(java.util.Arrays) Date(java.util.Date) NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) DateUtils(org.orcid.utils.DateUtils) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) OrcidSecurityManager(org.orcid.core.manager.OrcidSecurityManager) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) ProfileDao(org.orcid.persistence.dao.ProfileDao) Map(java.util.Map) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) Result(org.orcid.jaxb.model.v3.dev1.search.Result) OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) Search(org.orcid.jaxb.model.v3.dev1.search.Search) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidSearchException(org.orcid.core.exception.OrcidSearchException) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) Jpa2JaxbAdapter(org.orcid.core.adapter.Jpa2JaxbAdapter) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) RecordManagerReadOnly(org.orcid.core.manager.v3.read_only.RecordManagerReadOnly) Resource(javax.annotation.Resource) FundingList(org.orcid.jaxb.model.message.FundingList) IOException(java.io.IOException) Reader(java.io.Reader) Collectors(java.util.stream.Collectors) DeactivatedException(org.orcid.core.exception.DeactivatedException) OrcidSearchResults(org.orcid.jaxb.model.message.OrcidSearchResults) List(java.util.List) LockedException(org.orcid.core.security.aop.LockedException) Funding(org.orcid.jaxb.model.message.Funding) RelevancyScore(org.orcid.jaxb.model.message.RelevancyScore) BufferedReader(java.io.BufferedReader) SolrDao(org.orcid.persistence.dao.SolrDao) Required(org.springframework.beans.factory.annotation.Required) LastModifiedDate(org.orcid.jaxb.model.message.LastModifiedDate) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Search(org.orcid.jaxb.model.v3.dev1.search.Search) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) Result(org.orcid.jaxb.model.v3.dev1.search.Result) OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult)

Example 18 with Result

use of org.orcid.jaxb.model.v3.dev1.search.Result in project ORCID-Source by ORCID.

the class AffiliationsManagerImpl method createAffiliation.

private Affiliation createAffiliation(String orcid, Affiliation affiliation, boolean isApiRequest, AffiliationType type) {
    SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
    activityValidator.validateAffiliation(affiliation, sourceEntity, true, isApiRequest, null);
    if (isApiRequest) {
        checkAffiliationExternalIDsForDuplicates(orcid, affiliation, sourceEntity);
    }
    OrgAffiliationRelationEntity entity = null;
    switch(type) {
        case DISTINCTION:
            entity = jpaJaxbDistinctionAdapter.toOrgAffiliationRelationEntity((Distinction) affiliation);
            break;
        case EDUCATION:
            entity = jpaJaxbEducationAdapter.toOrgAffiliationRelationEntity((Education) affiliation);
            break;
        case EMPLOYMENT:
            entity = jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity((Employment) affiliation);
            break;
        case INVITED_POSITION:
            entity = jpaJaxbInvitedPositionAdapter.toOrgAffiliationRelationEntity((InvitedPosition) affiliation);
            break;
        case MEMBERSHIP:
            entity = jpaJaxbMembershipAdapter.toOrgAffiliationRelationEntity((Membership) affiliation);
            break;
        case QUALIFICATION:
            entity = jpaJaxbQualificationAdapter.toOrgAffiliationRelationEntity((Qualification) affiliation);
            break;
        case SERVICE:
            entity = jpaJaxbServiceAdapter.toOrgAffiliationRelationEntity((Service) affiliation);
            break;
    }
    // Updates the give organization with the latest organization from
    // database
    OrgEntity updatedOrganization = orgManager.getOrgEntity(affiliation);
    entity.setOrg(updatedOrganization);
    // Set source id
    if (sourceEntity.getSourceProfile() != null) {
        entity.setSourceId(sourceEntity.getSourceProfile().getId());
    }
    if (sourceEntity.getSourceClient() != null) {
        entity.setClientSourceId(sourceEntity.getSourceClient().getId());
    }
    ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
    entity.setProfile(profile);
    setIncomingWorkPrivacy(entity, profile);
    entity.setAffiliationType(type);
    orgAffiliationRelationDao.persist(entity);
    orgAffiliationRelationDao.flush();
    Affiliation result = null;
    switch(type) {
        case DISTINCTION:
            notificationManager.sendAmendEmail(orcid, AmendedSection.DISTINCTION, createItemList(entity));
            result = jpaJaxbDistinctionAdapter.toDistinction(entity);
            break;
        case EDUCATION:
            notificationManager.sendAmendEmail(orcid, AmendedSection.EDUCATION, createItemList(entity));
            result = jpaJaxbEducationAdapter.toEducation(entity);
            break;
        case EMPLOYMENT:
            notificationManager.sendAmendEmail(orcid, AmendedSection.EMPLOYMENT, createItemList(entity));
            result = jpaJaxbEmploymentAdapter.toEmployment(entity);
            break;
        case INVITED_POSITION:
            notificationManager.sendAmendEmail(orcid, AmendedSection.INVITED_POSITION, createItemList(entity));
            result = jpaJaxbInvitedPositionAdapter.toInvitedPosition(entity);
            break;
        case MEMBERSHIP:
            notificationManager.sendAmendEmail(orcid, AmendedSection.MEMBERSHIP, createItemList(entity));
            result = jpaJaxbMembershipAdapter.toMembership(entity);
            break;
        case QUALIFICATION:
            notificationManager.sendAmendEmail(orcid, AmendedSection.QUALIFICATION, createItemList(entity));
            result = jpaJaxbQualificationAdapter.toQualification(entity);
            break;
        case SERVICE:
            notificationManager.sendAmendEmail(orcid, AmendedSection.SERVICE, createItemList(entity));
            result = jpaJaxbServiceAdapter.toService(entity);
            break;
    }
    return result;
}
Also used : Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) Service(org.orcid.jaxb.model.v3.dev1.record.Service) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation)

Example 19 with Result

use of org.orcid.jaxb.model.v3.dev1.search.Result in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method unmarshallFromPath.

private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type, schemaPath);
        Object result = null;
        if (ResearcherUrls.class.equals(type)) {
            result = (ResearcherUrls) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (PersonExternalIdentifiers.class.equals(type)) {
            result = (PersonExternalIdentifiers) obj;
        } else if (Biography.class.equals(type)) {
            result = (Biography) obj;
        } else if (Name.class.equals(type)) {
            result = (Name) obj;
        } else if (CreditName.class.equals(type)) {
            result = (CreditName) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (OtherNames.class.equals(type)) {
            result = (OtherNames) obj;
        } else if (Keywords.class.equals(type)) {
            result = (Keywords) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Addresses.class.equals(type)) {
            result = (Addresses) obj;
        } else if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Emails.class.equals(type)) {
            result = (Emails) obj;
        } else if (Email.class.equals(type)) {
            result = (Email) obj;
        } else if (Person.class.equals(type)) {
            result = (Person) obj;
        } else if (Deprecated.class.equals(type)) {
            result = (Deprecated) obj;
        } else if (Preferences.class.equals(type)) {
            result = (Preferences) obj;
        } else if (History.class.equals(type)) {
            result = (History) obj;
        } else if (Record.class.equals(type)) {
            result = (Record) obj;
        } else if (ActivitiesSummary.class.equals(type)) {
            result = (ActivitiesSummary) obj;
        } else if (Works.class.equals(type)) {
            result = (Works) obj;
        } else if (Education.class.equals(type)) {
            result = (Education) obj;
        } else if (Educations.class.equals(type)) {
            result = (Educations) obj;
        } else if (Employment.class.equals(type)) {
            result = (Employment) obj;
        } else if (Employments.class.equals(type)) {
            result = (Employments) obj;
        } else if (Distinction.class.equals(type)) {
            result = (Distinction) obj;
        } else if (Distinctions.class.equals(type)) {
            result = (Distinctions) obj;
        } else if (InvitedPosition.class.equals(type)) {
            result = (InvitedPosition) obj;
        } else if (InvitedPositions.class.equals(type)) {
            result = (InvitedPositions) obj;
        } else if (Membership.class.equals(type)) {
            result = (Membership) obj;
        } else if (Memberships.class.equals(type)) {
            result = (Memberships) obj;
        } else if (Qualification.class.equals(type)) {
            result = (Qualification) obj;
        } else if (Qualifications.class.equals(type)) {
            result = (Qualifications) obj;
        } else if (Service.class.equals(type)) {
            result = (Service) obj;
        } else if (Services.class.equals(type)) {
            result = (Services) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) Address(org.orcid.jaxb.model.v3.dev1.record.Address) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) CreditName(org.orcid.jaxb.model.v3.dev1.record.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Service(org.orcid.jaxb.model.v3.dev1.record.Service) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) History(org.orcid.jaxb.model.v3.dev1.record.History) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) Deprecated(org.orcid.jaxb.model.v3.dev1.record.Deprecated) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction)

Example 20 with Result

use of org.orcid.jaxb.model.v3.dev1.search.Result in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testSearchByQuery.

@Test
public void testSearchByQuery() {
    Search search = new Search();
    Result result = new Result();
    result.setOrcidIdentifier(new OrcidIdentifier("some-orcid-id"));
    search.getResults().add(result);
    OrcidSearchManager orcidSearchManager = Mockito.mock(OrcidSearchManagerImpl.class);
    Mockito.when(orcidSearchManager.findOrcidIds(Matchers.<Map<String, List<String>>>any())).thenReturn(search);
    PublicV3ApiServiceDelegatorImpl delegator = new PublicV3ApiServiceDelegatorImpl();
    ReflectionTestUtils.setField(delegator, "orcidSearchManager", orcidSearchManager);
    OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
    Mockito.when(orcidSecurityManager.getClientIdFromAPIRequest()).thenReturn(null);
    ReflectionTestUtils.setField(delegator, "orcidSecurityManager", orcidSecurityManager);
    Response response = delegator.searchByQuery(new HashMap<String, List<String>>());
    assertNotNull(response);
    assertNotNull(response.getEntity());
    assertTrue(response.getEntity() instanceof Search);
    assertEquals(1, ((Search) response.getEntity()).getResults().size());
    assertEquals("some-orcid-id", ((Search) response.getEntity()).getResults().get(0).getOrcidIdentifier().getPath());
}
Also used : Response(javax.ws.rs.core.Response) OrcidIdentifier(org.orcid.jaxb.model.v3.dev1.common.OrcidIdentifier) PublicV3ApiServiceDelegatorImpl(org.orcid.api.publicV3.server.delegator.impl.PublicV3ApiServiceDelegatorImpl) Search(org.orcid.jaxb.model.v3.dev1.search.Search) OrcidSecurityManager(org.orcid.core.manager.v3.OrcidSecurityManager) ArrayList(java.util.ArrayList) List(java.util.List) OrcidSearchManager(org.orcid.core.manager.v3.OrcidSearchManager) Result(org.orcid.jaxb.model.v3.dev1.search.Result) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)7 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)7 Test (org.junit.Test)6 List (java.util.List)4 IOException (java.io.IOException)3 Reader (java.io.Reader)3 OrcidSecurityManager (org.orcid.core.manager.v3.OrcidSecurityManager)3 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 InputStreamReader (java.io.InputStreamReader)2 Arrays (java.util.Arrays)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Response (javax.ws.rs.core.Response)2 OrcidSearchManager (org.orcid.core.manager.v3.OrcidSearchManager)2 ActivitiesGroup (org.orcid.core.utils.v3.activities.ActivitiesGroup)2 ActivitiesGroupGenerator (org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator)2 GroupableActivityComparator (org.orcid.core.utils.v3.activities.GroupableActivityComparator)2 OrcidIdentifier (org.orcid.jaxb.model.v3.dev1.common.OrcidIdentifier)2 Title (org.orcid.jaxb.model.v3.dev1.common.Title)2