Search in sources :

Example 6 with FamilyName

use of org.orcid.jaxb.model.v3.dev1.record.FamilyName in project ORCID-Source by ORCID.

the class JpaJaxbNameAdapterTest method fromNameToRecordNameEntityTest.

@Test
public void fromNameToRecordNameEntityTest() throws JAXBException {
    Name name = new Name();
    name.setCreditName(new CreditName("Credit Name"));
    name.setFamilyName(new FamilyName("Family Name"));
    name.setGivenNames(new GivenNames("Given Names"));
    name.setPath("0000-0000-0000-0000");
    name.setVisibility(Visibility.PUBLIC);
    name.setSource(new Source("0000-0000-0000-0000"));
    RecordNameEntity entity = adapter.toRecordNameEntity(name);
    assertNotNull(entity);
    assertEquals("Credit Name", entity.getCreditName());
    assertEquals("Family Name", entity.getFamilyName());
    assertEquals("Given Names", entity.getGivenNames());
    assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC, entity.getVisibility());
    assertNotNull(entity.getProfile());
    assertEquals("0000-0000-0000-0000", entity.getProfile().getId());
}
Also used : FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) GivenNames(org.orcid.jaxb.model.v3.dev1.record.GivenNames) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) Source(org.orcid.jaxb.model.v3.dev1.common.Source) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) Test(org.junit.Test)

Example 7 with FamilyName

use of org.orcid.jaxb.model.v3.dev1.record.FamilyName in project ORCID-Source by ORCID.

the class ProfileEntityManagerImpl method getMemberDisplayName.

private String getMemberDisplayName(ProfileEntity member) {
    RecordNameEntity recordName = member.getRecordNameEntity();
    if (recordName == null) {
        return StringUtils.EMPTY;
    }
    // If it is a member, return the credit name
    if (OrcidType.GROUP.equals(member.getOrcidType())) {
        return recordName.getCreditName();
    }
    Visibility namesVisibilty = Visibility.fromValue(recordName.getVisibility().value());
    if (Visibility.PUBLIC.equals(namesVisibilty)) {
        if (!PojoUtil.isEmpty(recordName.getCreditName())) {
            return recordName.getCreditName();
        } else {
            String displayName = recordName.getGivenNames();
            String familyName = recordName.getFamilyName();
            if (StringUtils.isNotBlank(familyName)) {
                displayName += " " + familyName;
            }
            return displayName;
        }
    }
    return StringUtils.EMPTY;
}
Also used : RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility)

Example 8 with FamilyName

use of org.orcid.jaxb.model.v3.dev1.record.FamilyName in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorImpl method viewWorkCitation.

@Override
public Response viewWorkCitation(String orcid, Long putCode) {
    Work w = (Work) this.viewWork(orcid, putCode).getEntity();
    ProfileEntity entity = profileEntityManagerReadOnly.findByOrcid(orcid);
    String creditName = null;
    RecordNameEntity recordNameEntity = entity.getRecordNameEntity();
    if (recordNameEntity != null) {
        if (!recordNameEntity.getVisibility().isMoreRestrictiveThan(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC)) {
            creditName = recordNameEntity.getCreditName();
            if (StringUtils.isBlank(creditName)) {
                creditName = recordNameEntity.getGivenNames();
                String familyName = recordNameEntity.getFamilyName();
                if (StringUtils.isNotBlank(familyName)) {
                    creditName += " " + familyName;
                }
            }
        }
    }
    V3WorkToCiteprocTranslator tran = new V3WorkToCiteprocTranslator();
    CSLItemData item = tran.toCiteproc(w, creditName, true);
    return Response.ok(item).build();
}
Also used : CSLItemData(de.undercouch.citeproc.csl.CSLItemData) Work(org.orcid.jaxb.model.v3.dev1.record.Work) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) V3WorkToCiteprocTranslator(org.orcid.api.common.writer.citeproc.V3WorkToCiteprocTranslator) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 9 with FamilyName

use of org.orcid.jaxb.model.v3.dev1.record.FamilyName in project ORCID-Source by ORCID.

the class GetMyDataControllerTest method before.

@Before
public void before() {
    MockitoAnnotations.initMocks(this);
    TargetProxyHelper.injectIntoProxy(getMyDataController, "batchSize", 50);
    TargetProxyHelper.injectIntoProxy(getMyDataController, "personDetailsManager", mockPersonDetailsManager);
    TargetProxyHelper.injectIntoProxy(getMyDataController, "workEntityCacheManager", mockWorkEntityCacheManager);
    TargetProxyHelper.injectIntoProxy(getMyDataController, "affiliationManagerReadOnly", mockAffiliationManagerReadOnly);
    TargetProxyHelper.injectIntoProxy(getMyDataController, "profileFundingManagerReadOnly", mockProfileFundingManagerReadOnly);
    TargetProxyHelper.injectIntoProxy(getMyDataController, "peerReviewManagerReadOnly", mockPeerReviewManagerReadOnly);
    TargetProxyHelper.injectIntoProxy(getMyDataController, "workManagerReadOnly", mockWorkManagerReadOnly);
    when(mockPersonDetailsManager.getPersonDetails(anyString())).thenAnswer(new Answer<Person>() {

        @Override
        public Person answer(InvocationOnMock invocation) throws Throwable {
            Person p = new Person();
            p.setBiography(new Biography("Biography", Visibility.LIMITED));
            Name name = new Name();
            name.setVisibility(Visibility.LIMITED);
            name.setFamilyName(new FamilyName("Family Name"));
            name.setGivenNames(new GivenNames("Given Names"));
            name.setCreditName(new CreditName("Credit Name"));
            p.setName(name);
            return p;
        }
    });
    when(mockAffiliationManagerReadOnly.getAffiliations(anyString())).thenAnswer(new Answer<List<Affiliation>>() {

        @Override
        public List<Affiliation> answer(InvocationOnMock invocation) throws Throwable {
            List<Affiliation> affs = new ArrayList<Affiliation>();
            FuzzyDate startDate = new FuzzyDate(new Year(2018), new Month(1), new Day(1));
            FuzzyDate endDate = new FuzzyDate(new Year(2018), new Month(12), new Day(31));
            Distinction d = new Distinction();
            d.setDepartmentName("distinction");
            d.setEndDate(endDate);
            d.setStartDate(startDate);
            d.setPutCode(1L);
            setOrg(d);
            affs.add(d);
            Education e = new Education();
            e.setDepartmentName("education");
            e.setEndDate(endDate);
            e.setStartDate(startDate);
            e.setPutCode(2L);
            setOrg(e);
            affs.add(e);
            Employment emp = new Employment();
            emp.setDepartmentName("employment");
            emp.setEndDate(endDate);
            emp.setStartDate(startDate);
            emp.setPutCode(3L);
            setOrg(emp);
            affs.add(emp);
            InvitedPosition i = new InvitedPosition();
            i.setDepartmentName("invited position");
            i.setEndDate(endDate);
            i.setStartDate(startDate);
            i.setPutCode(4L);
            setOrg(i);
            affs.add(i);
            Membership m = new Membership();
            m.setDepartmentName("membership");
            m.setEndDate(endDate);
            m.setStartDate(startDate);
            m.setPutCode(5L);
            setOrg(m);
            affs.add(m);
            Qualification q = new Qualification();
            q.setDepartmentName("qualification");
            q.setEndDate(endDate);
            q.setStartDate(startDate);
            q.setPutCode(6L);
            setOrg(q);
            affs.add(q);
            Service s = new Service();
            s.setDepartmentName("service");
            s.setEndDate(endDate);
            s.setStartDate(startDate);
            s.setPutCode(7L);
            setOrg(s);
            affs.add(s);
            return affs;
        }
    });
    when(mockProfileFundingManagerReadOnly.getFundingList(anyString())).thenAnswer(new Answer<List<Funding>>() {

        @Override
        public List<Funding> answer(InvocationOnMock invocation) throws Throwable {
            List<Funding> fundings = new ArrayList<Funding>();
            Funding f = new Funding();
            Amount a = new Amount();
            a.setContent("1000");
            a.setCurrencyCode("$");
            f.setAmount(a);
            FundingTitle t = new FundingTitle();
            t.setTitle(new Title("title"));
            f.setTitle(t);
            setOrg(f);
            f.setPutCode(1L);
            fundings.add(f);
            return fundings;
        }
    });
    when(mockPeerReviewManagerReadOnly.findPeerReviews(anyString())).thenAnswer(new Answer<List<PeerReview>>() {

        @Override
        public List<PeerReview> answer(InvocationOnMock invocation) throws Throwable {
            List<PeerReview> peerReviews = new ArrayList<PeerReview>();
            PeerReview p = new PeerReview();
            setOrg(p);
            p.setPutCode(1L);
            peerReviews.add(p);
            return peerReviews;
        }
    });
    when(mockWorkManagerReadOnly.findWorks(anyString(), any())).thenAnswer(new Answer<List<Work>>() {

        @Override
        public List<Work> answer(InvocationOnMock invocation) throws Throwable {
            List<Work> works = new ArrayList<Work>();
            Work w = new Work();
            WorkTitle t = new WorkTitle();
            t.setTitle(new Title("title"));
            w.setPutCode(1L);
            works.add(w);
            return works;
        }
    });
    when(mockWorkManagerReadOnly.getLastModified(anyString())).thenReturn(0L);
    when(mockWorkEntityCacheManager.retrieveWorkLastModifiedList(anyString(), anyLong())).thenAnswer(new Answer<List<WorkLastModifiedEntity>>() {

        @Override
        public List<WorkLastModifiedEntity> answer(InvocationOnMock invocation) throws Throwable {
            List<WorkLastModifiedEntity> works = new ArrayList<WorkLastModifiedEntity>();
            WorkLastModifiedEntity w = new WorkLastModifiedEntity();
            w.setId(1L);
            w.setOrcid(ORCID);
            w.setLastModified(new Date());
            works.add(w);
            return works;
        }
    });
}
Also used : FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) Month(org.orcid.jaxb.model.v3.dev1.common.Month) WorkLastModifiedEntity(org.orcid.persistence.jpa.entities.WorkLastModifiedEntity) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) GivenNames(org.orcid.jaxb.model.v3.dev1.record.GivenNames) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) List(java.util.List) ArrayList(java.util.ArrayList) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) Amount(org.orcid.jaxb.model.v3.dev1.common.Amount) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Service(org.orcid.jaxb.model.v3.dev1.record.Service) Title(org.orcid.jaxb.model.v3.dev1.common.Title) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Date(java.util.Date) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) Year(org.orcid.jaxb.model.v3.dev1.common.Year) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) InvocationOnMock(org.mockito.invocation.InvocationOnMock) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) Person(org.orcid.jaxb.model.v3.dev1.record.Person) Day(org.orcid.jaxb.model.v3.dev1.common.Day) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) Before(org.junit.Before)

Example 10 with FamilyName

use of org.orcid.jaxb.model.v3.dev1.record.FamilyName in project ORCID-Source by ORCID.

the class RecordNameManagerV3Test method testFailOnCreatingOnARecordThatAlreadyHaveRecordName.

@Test(expected = IllegalArgumentException.class)
public void testFailOnCreatingOnARecordThatAlreadyHaveRecordName() {
    Name name = new Name();
    long time = System.currentTimeMillis();
    name.setCreditName(new CreditName("Credit Name " + time));
    name.setFamilyName(new FamilyName("Family Name " + time));
    name.setGivenNames(new GivenNames("Given Names " + time));
    name.setVisibility(Visibility.PRIVATE);
    String orcid = "0000-0000-0000-0001";
    recordNameManager.createRecordName(orcid, name);
    fail();
}
Also used : FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) GivenNames(org.orcid.jaxb.model.v3.dev1.record.GivenNames) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

Name (org.orcid.jaxb.model.v3.dev1.record.Name)8 FamilyName (org.orcid.jaxb.model.v3.dev1.record.FamilyName)7 GivenNames (org.orcid.jaxb.model.v3.dev1.record.GivenNames)7 CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)6 Test (org.junit.Test)4 RecordNameEntity (org.orcid.persistence.jpa.entities.RecordNameEntity)4 BaseTest (org.orcid.core.BaseTest)2 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)2 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)2 Work (org.orcid.jaxb.model.v3.dev1.record.Work)2 CSLItemData (de.undercouch.citeproc.csl.CSLItemData)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 MapperFactory (ma.glasnost.orika.MapperFactory)1 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 V3WorkToCiteprocTranslator (org.orcid.api.common.writer.citeproc.V3WorkToCiteprocTranslator)1 RecordNameManager (org.orcid.core.manager.v3.RecordNameManager)1