Search in sources :

Example 21 with Affiliation

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

the class PojoUtilTest method affiliationsCreateDateSortString_StartDate_NullMonthNullDayTest.

@Test
public void affiliationsCreateDateSortString_StartDate_NullMonthNullDayTest() {
    Affiliation aff = new Employment();
    FuzzyDate start = new FuzzyDate();
    start.setYear(new Year(2017));
    aff.setStartDate(start);
    String dateSortString = PojoUtil.createDateSortString(aff);
    assertEquals("Y-2017-00-00", dateSortString);
}
Also used : Year(org.orcid.jaxb.model.v3.dev1.common.Year) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) Test(org.junit.Test)

Example 22 with Affiliation

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

the class PojoUtilTest method affiliationsCreateDateSortString_EndDate_NullMonthNullDayTest.

@Test
public void affiliationsCreateDateSortString_EndDate_NullMonthNullDayTest() {
    Affiliation aff = new Employment();
    FuzzyDate end = new FuzzyDate();
    end.setYear(new Year(2017));
    aff.setEndDate(end);
    String dateSortString = PojoUtil.createDateSortString(aff);
    assertEquals("X-2017-00-00", dateSortString);
}
Also used : Year(org.orcid.jaxb.model.v3.dev1.common.Year) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation) Test(org.junit.Test)

Example 23 with Affiliation

use of org.orcid.jaxb.model.v3.dev1.record.Affiliation 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 24 with Affiliation

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

the class GetMyDataController method generateAffiliationsData.

private void generateAffiliationsData(String orcid, ZipOutputStream zip) throws JAXBException, IOException {
    List<Affiliation> affiliations = affiliationManagerReadOnly.getAffiliations(orcid);
    for (Affiliation affiliation : affiliations) {
        String elementName = null;
        if (affiliation instanceof Distinction) {
            elementName = DISTINCTIONS_DIR_NAME + '/' + affiliation.getPutCode() + ".xml";
        } else if (affiliation instanceof Education) {
            elementName = EDUCATIONS_DIR_NAME + '/' + affiliation.getPutCode() + ".xml";
        } else if (affiliation instanceof Employment) {
            elementName = EMPLOYMENTS_DIR_NAME + '/' + affiliation.getPutCode() + ".xml";
        } else if (affiliation instanceof InvitedPosition) {
            elementName = INVITED_POSITIONS_DIR_NAME + '/' + affiliation.getPutCode() + ".xml";
        } else if (affiliation instanceof Membership) {
            elementName = MEMBERSHIPS_DIR_NAME + '/' + affiliation.getPutCode() + ".xml";
        } else if (affiliation instanceof Qualification) {
            elementName = QUALIFICATIONS_DIR_NAME + '/' + affiliation.getPutCode() + ".xml";
        } else if (affiliation instanceof Service) {
            elementName = SERVICES_DIR_NAME + '/' + affiliation.getPutCode() + ".xml";
        } else {
            throw new IllegalArgumentException("Invalid affiliation type: " + affiliation.getClass().getName());
        }
        writeElement(toByteArray(affiliation), elementName, zip);
    }
}
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) 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) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation)

Example 25 with Affiliation

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

the class AffiliationsManagerTest method fillAffiliation.

private void fillAffiliation(Affiliation aff) {
    Organization org = new Organization();
    org.setName("org-name");
    OrganizationAddress address = new OrganizationAddress();
    address.setCity("city");
    address.setCountry(Iso3166Country.US);
    org.setAddress(address);
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("def456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    org.setDisambiguatedOrganization(disambiguatedOrg);
    aff.setOrganization(org);
    aff.setStartDate(new FuzzyDate(new Year(2016), new Month(3), new Day(29)));
    aff.setVisibility(Visibility.PUBLIC);
}
Also used : Month(org.orcid.jaxb.model.v3.dev1.common.Month) Organization(org.orcid.jaxb.model.v3.dev1.common.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) Year(org.orcid.jaxb.model.v3.dev1.common.Year) OrganizationAddress(org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Day(org.orcid.jaxb.model.v3.dev1.common.Day)

Aggregations

Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)22 Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)17 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)11 Test (org.junit.Test)10 Day (org.orcid.jaxb.model.v3.dev1.common.Day)8 Month (org.orcid.jaxb.model.v3.dev1.common.Month)8 Year (org.orcid.jaxb.model.v3.dev1.common.Year)8 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)7 Education (org.orcid.jaxb.model.v3.dev1.record.Education)7 InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)7 Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)7 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)7 Service (org.orcid.jaxb.model.v3.dev1.record.Service)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)3 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)3 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)3 OrganizationAddress (org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress)3 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)3 LinkedHashMap (java.util.LinkedHashMap)2