Search in sources :

Example 26 with WorkTitle

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

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

the class WorkManagerTest method testCreateWorksWithBulkAllOK.

@Test
public void testCreateWorksWithBulkAllOK() {
    String orcid = "0000-0000-0000-0003";
    Long time = System.currentTimeMillis();
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    WorkBulk bulk = new WorkBulk();
    for (int i = 0; i < 5; i++) {
        Work work = new Work();
        WorkTitle title = new WorkTitle();
        title.setTitle(new Title("Bulk work " + i + " " + time));
        work.setWorkTitle(title);
        ExternalIDs extIds = new ExternalIDs();
        ExternalID extId = new ExternalID();
        extId.setRelationship(Relationship.SELF);
        extId.setType("doi");
        extId.setUrl(new Url("http://doi/" + i + "/" + time));
        extId.setValue("doi-" + i + "-" + time);
        extIds.getExternalIdentifier().add(extId);
        work.setWorkExternalIdentifiers(extIds);
        work.setWorkType(WorkType.BOOK);
        bulk.getBulk().add(work);
    }
    bulk = workManager.createWorks(orcid, bulk);
    assertNotNull(bulk);
    assertEquals(5, bulk.getBulk().size());
    for (int i = 0; i < 5; i++) {
        assertTrue(Work.class.isAssignableFrom(bulk.getBulk().get(i).getClass()));
        Work w = (Work) bulk.getBulk().get(i);
        assertNotNull(w.getPutCode());
        assertTrue(0L < w.getPutCode());
        assertEquals("Bulk work " + i + " " + time, w.getWorkTitle().getTitle().getContent());
        assertNotNull(w.getExternalIdentifiers().getExternalIdentifier());
        assertEquals("doi-" + i + "-" + time, w.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
        Work w1 = workManager.getWork(orcid, w.getPutCode());
        assertNotNull(w1);
        assertEquals("Bulk work " + i + " " + time, w1.getWorkTitle().getTitle().getContent());
        // Delete the work
        assertTrue(workManager.checkSourceAndRemoveWork(orcid, w1.getPutCode()));
    }
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) WorkBulk(org.orcid.jaxb.model.v3.dev1.record.WorkBulk) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Url(org.orcid.jaxb.model.v3.dev1.common.Url) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 28 with WorkTitle

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

the class WorkManagerTest method testCreateWorksWithBulk_OneSelfOnePartOf_NoDupError.

@Test
public void testCreateWorksWithBulk_OneSelfOnePartOf_NoDupError() {
    String orcid = "0000-0000-0000-0003";
    Long time = System.currentTimeMillis();
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    WorkBulk bulk = new WorkBulk();
    // Work # 1
    Work work1 = new Work();
    WorkTitle title1 = new WorkTitle();
    title1.setTitle(new Title("Work # 1"));
    work1.setWorkTitle(title1);
    ExternalIDs extIds1 = new ExternalIDs();
    ExternalID extId1 = new ExternalID();
    extId1.setRelationship(Relationship.SELF);
    extId1.setType("isbn");
    extId1.setUrl(new Url("http://isbn/1/" + time));
    extId1.setValue("isbn-1");
    extIds1.getExternalIdentifier().add(extId1);
    work1.setWorkExternalIdentifiers(extIds1);
    work1.setWorkType(WorkType.BOOK);
    bulk.getBulk().add(work1);
    // Work # 2
    Work work2 = new Work();
    WorkTitle title2 = new WorkTitle();
    title2.setTitle(new Title("Work # 2"));
    work2.setWorkTitle(title2);
    ExternalIDs extIds2 = new ExternalIDs();
    ExternalID extId2 = new ExternalID();
    extId2.setRelationship(Relationship.PART_OF);
    extId2.setType("isbn");
    extId2.setUrl(new Url("http://isbn/1/" + time));
    extId2.setValue("isbn-1");
    extIds2.getExternalIdentifier().add(extId2);
    work2.setWorkExternalIdentifiers(extIds2);
    work2.setWorkType(WorkType.BOOK);
    bulk.getBulk().add(work2);
    WorkBulk updatedBulk = workManager.createWorks(orcid, bulk);
    assertNotNull(updatedBulk);
    assertEquals(2, updatedBulk.getBulk().size());
    assertTrue(updatedBulk.getBulk().get(0) instanceof Work);
    assertNotNull(((Work) updatedBulk.getBulk().get(0)).getPutCode());
    assertEquals(Relationship.SELF, ((Work) updatedBulk.getBulk().get(0)).getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("isbn-1", ((Work) updatedBulk.getBulk().get(0)).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertTrue(updatedBulk.getBulk().get(1) instanceof Work);
    assertNotNull(((Work) updatedBulk.getBulk().get(1)).getPutCode());
    assertEquals(Relationship.PART_OF, ((Work) updatedBulk.getBulk().get(1)).getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("isbn-1", ((Work) updatedBulk.getBulk().get(1)).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    workManager.removeWorks(orcid, Arrays.asList(((Work) updatedBulk.getBulk().get(0)).getPutCode(), ((Work) updatedBulk.getBulk().get(1)).getPutCode()));
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) WorkBulk(org.orcid.jaxb.model.v3.dev1.record.WorkBulk) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Url(org.orcid.jaxb.model.v3.dev1.common.Url) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 29 with WorkTitle

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

the class WorkManagerTest method getWorkSummary.

private WorkSummary getWorkSummary(String titleValue, String extIdValue, Visibility visibility, String displayIndex) {
    WorkSummary summary = new WorkSummary();
    summary.setDisplayIndex(displayIndex);
    Title title = new Title(titleValue);
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(title);
    summary.setTitle(workTitle);
    summary.setType(WorkType.ARTISTIC_PERFORMANCE);
    summary.setVisibility(visibility);
    ExternalIDs extIds = new ExternalIDs();
    ExternalID extId = new ExternalID();
    extId.setRelationship(Relationship.SELF);
    extId.setType("doi");
    extId.setUrl(new Url("http://orcid.org"));
    extId.setValue(extIdValue);
    extIds.getExternalIdentifier().add(extId);
    summary.setExternalIdentifiers(extIds);
    return summary;
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Url(org.orcid.jaxb.model.v3.dev1.common.Url)

Example 30 with WorkTitle

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

the class WorkManagerTest method getWork.

private Work getWork(String extIdValue) {
    Work work = new Work();
    WorkTitle title = new WorkTitle();
    if (extIdValue == null) {
        title.setTitle(new Title("Work title"));
    } else {
        title.setTitle(new Title("Work title " + extIdValue));
    }
    work.setWorkTitle(title);
    work.setWorkType(WorkType.BOOK);
    ExternalIDs extIds = new ExternalIDs();
    ExternalID extId = new ExternalID();
    extId.setRelationship(Relationship.SELF);
    extId.setType("doi");
    extId.setUrl(new Url("http://orcid.org"));
    if (extIdValue == null) {
        extId.setValue("ext-id-value");
    } else {
        extId.setValue("ext-id-value-" + extIdValue);
    }
    extIds.getExternalIdentifier().add(extId);
    work.setWorkExternalIdentifiers(extIds);
    work.setVisibility(Visibility.PUBLIC);
    return work;
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Url(org.orcid.jaxb.model.v3.dev1.common.Url)

Aggregations

WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)30 Title (org.orcid.jaxb.model.v3.dev1.common.Title)29 Work (org.orcid.jaxb.model.v3.dev1.record.Work)21 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)19 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)18 Url (org.orcid.jaxb.model.v3.dev1.common.Url)14 Test (org.junit.Test)12 TranslatedTitle (org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle)9 Subtitle (org.orcid.jaxb.model.v3.dev1.common.Subtitle)7 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)7 WorkBulk (org.orcid.jaxb.model.v3.dev1.record.WorkBulk)7 BaseTest (org.orcid.core.BaseTest)6 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)6 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)5 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)5 DBUnitTest (org.orcid.test.DBUnitTest)5 Day (org.orcid.jaxb.model.v3.dev1.common.Day)4 Month (org.orcid.jaxb.model.v3.dev1.common.Month)4 Year (org.orcid.jaxb.model.v3.dev1.common.Year)4 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)4