Search in sources :

Example 31 with LastModifiedDate

use of org.orcid.jaxb.model.common_rc4.LastModifiedDate in project ORCID-Source by ORCID.

the class WorkFormTest method getWorkForm.

private WorkForm getWorkForm() {
    WorkForm form = new WorkForm();
    form.setCitation(new Citation("Citation", "formatted-unspecified"));
    List<Contributor> çontributors = new ArrayList<Contributor>();
    Contributor contributor = new Contributor();
    contributor.setContributorRole(Text.valueOf("co_inventor"));
    contributor.setContributorSequence(Text.valueOf("first"));
    contributor.setCreditName(Text.valueOf("Contributor credit name"));
    contributor.setEmail(null);
    contributor.setOrcid(Text.valueOf("Contributor orcid"));
    contributor.setUri(Text.valueOf("Contributor uri"));
    çontributors.add(contributor);
    form.setContributors(çontributors);
    form.setCountryCode(Text.valueOf("US"));
    Date createdDate = new Date();
    createdDate.setDay("1");
    createdDate.setMonth("1");
    createdDate.setYear("2015");
    form.setCreatedDate(createdDate);
    form.setJournalTitle(Text.valueOf("Journal title"));
    form.setLanguageCode(Text.valueOf("en"));
    Date lastModifiedDate = new Date();
    lastModifiedDate.setDay("2");
    lastModifiedDate.setMonth("2");
    lastModifiedDate.setYear("2015");
    form.setLastModified(lastModifiedDate);
    Date publicationDate = new Date();
    publicationDate.setDay("03");
    publicationDate.setMonth("03");
    publicationDate.setYear("2015");
    form.setPublicationDate(publicationDate);
    form.setDateSortString(PojoUtil.createDateSortString(null, FuzzyDate.valueOf(2015, 3, 3)));
    form.setPutCode(Text.valueOf("1"));
    form.setShortDescription(Text.valueOf("Short description"));
    form.setSource("0000-0000-0000-0000");
    form.setSubtitle(Text.valueOf("Subtitle"));
    form.setTitle(Text.valueOf("Title"));
    form.setTranslatedTitle(new TranslatedTitleForm("Translated Title", "es"));
    form.setUrl(Text.valueOf("http://myurl.com"));
    form.setVisibility(Visibility.PUBLIC);
    List<WorkExternalIdentifier> extIds = new ArrayList<WorkExternalIdentifier>();
    WorkExternalIdentifier extId = new WorkExternalIdentifier();
    extId.setWorkExternalIdentifierId(Text.valueOf("External Identifier ID"));
    extId.setWorkExternalIdentifierType(Text.valueOf("asin"));
    extId.setRelationship(Text.valueOf(Relationship.SELF.value()));
    extIds.add(extId);
    form.setWorkExternalIdentifiers(extIds);
    form.setWorkType(Text.valueOf("artistic-performance"));
    WorkCategory category = WorkCategory.fromWorkType(WorkType.fromValue(form.getWorkType().getValue()));
    form.setWorkCategory(Text.valueOf(category.value()));
    return form;
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) ArrayList(java.util.ArrayList) Contributor(org.orcid.pojo.ajaxForm.Contributor) Citation(org.orcid.pojo.ajaxForm.Citation) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier) WorkCategory(org.orcid.jaxb.model.record_v2.WorkCategory) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) PublicationDate(org.orcid.jaxb.model.common_v2.PublicationDate) Date(org.orcid.pojo.ajaxForm.Date) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm)

Example 32 with LastModifiedDate

use of org.orcid.jaxb.model.common_rc4.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testUpdateExternalIdentifier.

@Test
public void testUpdateExternalIdentifier() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    Utils.verifyLastModified(extId.getLastModifiedDate());
    LastModifiedDate before = extId.getLastModifiedDate();
    assertEquals("Facebook", extId.getType());
    assertEquals("abc123", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://www.facebook.com/abc123", extId.getUrl().getValue());
    extId.setType("updated-common-name");
    extId.setValue("updated-reference");
    extId.setUrl(new Url("http://updatedUrl.com"));
    response = serviceDelegator.updateExternalIdentifier("4444-4444-4444-4442", 2L, extId);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier updatedExtId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(updatedExtId);
    Utils.verifyLastModified(updatedExtId.getLastModifiedDate());
    assertTrue(updatedExtId.getLastModifiedDate().after(before));
    assertEquals("updated-common-name", updatedExtId.getType());
    assertEquals("updated-reference", updatedExtId.getValue());
    assertNotNull(updatedExtId.getUrl());
    assertEquals("http://updatedUrl.com", updatedExtId.getUrl().getValue());
    // Revert changes so other tests still works
    extId.setType("Facebook");
    extId.setValue("abc123");
    extId.setUrl(new Url("http://www.facebook.com/abc123"));
    response = serviceDelegator.updateExternalIdentifier("4444-4444-4444-4442", 2L, extId);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 33 with LastModifiedDate

use of org.orcid.jaxb.model.common_rc4.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmploymentsTest method testUpdateEmployment.

@Test
public void testUpdateEmployment() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    assertEquals("Employment Dept # 1", employment.getDepartmentName());
    assertEquals("Researcher", employment.getRoleTitle());
    Utils.verifyLastModified(employment.getLastModifiedDate());
    LastModifiedDate before = employment.getLastModifiedDate();
    employment.setDepartmentName("Updated department name");
    employment.setRoleTitle("The updated role title");
    response = serviceDelegator.updateEmployment("4444-4444-4444-4446", 5L, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
    assertNotNull(response);
    employment = (Employment) response.getEntity();
    assertNotNull(employment);
    Utils.verifyLastModified(employment.getLastModifiedDate());
    assertTrue(employment.getLastModifiedDate().after(before));
    assertEquals("Updated department name", employment.getDepartmentName());
    assertEquals("The updated role title", employment.getRoleTitle());
    // Rollback changes
    employment.setDepartmentName("Employment Dept # 1");
    employment.setRoleTitle("Researcher");
    response = serviceDelegator.updateEmployment("4444-4444-4444-4446", 5L, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Employment(org.orcid.jaxb.model.record_v2.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 34 with LastModifiedDate

use of org.orcid.jaxb.model.common_rc4.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method testCleanEmptyFieldsOnWorks.

@Test
public void testCleanEmptyFieldsOnWorks() {
    LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
    Work work = new Work();
    work.setLastModifiedDate(lmd);
    work.setWorkCitation(new Citation("", CitationType.FORMATTED_UNSPECIFIED));
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title("My Work"));
    title.setSubtitle(new Subtitle("My subtitle"));
    title.setTranslatedTitle(new TranslatedTitle("", ""));
    work.setWorkTitle(title);
    ActivityUtils.cleanEmptyFields(work);
    assertNotNull(work);
    Utils.verifyLastModified(work.getLastModifiedDate());
    assertNotNull(work.getWorkTitle());
    assertNotNull(work.getWorkTitle().getTitle());
    assertNotNull(work.getWorkTitle().getSubtitle());
    assertEquals("My Work", work.getWorkTitle().getTitle().getContent());
    assertEquals("My subtitle", work.getWorkTitle().getSubtitle().getContent());
    assertNull(work.getWorkCitation());
    assertNull(work.getWorkTitle().getTranslatedTitle());
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Subtitle(org.orcid.jaxb.model.common_v2.Subtitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Work(org.orcid.jaxb.model.record_v2.Work) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) Title(org.orcid.jaxb.model.common_v2.Title) Citation(org.orcid.jaxb.model.record_v2.Citation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 35 with LastModifiedDate

use of org.orcid.jaxb.model.common_rc4.LastModifiedDate in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testUpdatePeerReview.

@Test
public void testUpdatePeerReview() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    Utils.verifyLastModified(peerReview.getLastModifiedDate());
    LastModifiedDate before = peerReview.getLastModifiedDate();
    peerReview.setUrl(new Url("http://updated.com/url"));
    peerReview.getSubjectName().getTitle().setContent("Updated Title");
    response = serviceDelegator.updatePeerReview("4444-4444-4444-4447", 6L, peerReview);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewPeerReview("4444-4444-4444-4447", 6L);
    PeerReview updatedPeerReview = (PeerReview) response.getEntity();
    assertNotNull(updatedPeerReview);
    Utils.verifyLastModified(updatedPeerReview.getLastModifiedDate());
    assertTrue(updatedPeerReview.getLastModifiedDate().after(before));
    assertEquals("http://updated.com/url", updatedPeerReview.getUrl().getValue());
    assertEquals("Updated Title", updatedPeerReview.getSubjectName().getTitle().getContent());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)34 Test (org.junit.Test)13 LastModifiedDate (org.orcid.jaxb.model.common_rc3.LastModifiedDate)13 LastModifiedDate (org.orcid.jaxb.model.common_rc4.LastModifiedDate)13 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)12 DBUnitTest (org.orcid.test.DBUnitTest)12 Date (java.util.Date)11 Response (javax.ws.rs.core.Response)10 LastModifiedDate (org.orcid.jaxb.model.common_rc2.LastModifiedDate)10 ArrayList (java.util.ArrayList)7 CreatedDate (org.orcid.jaxb.model.common_v2.CreatedDate)5 Url (org.orcid.jaxb.model.common_v2.Url)5 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)5 Title (org.orcid.jaxb.model.common_v2.Title)3 OtherName (org.orcid.jaxb.model.record_v2.OtherName)3 CreditName (org.orcid.jaxb.model.common_v2.CreditName)2 FuzzyDate (org.orcid.jaxb.model.common_v2.FuzzyDate)2 PublicationDate (org.orcid.jaxb.model.common_v2.PublicationDate)2 Source (org.orcid.jaxb.model.common_v2.Source)2 Subtitle (org.orcid.jaxb.model.common_v2.Subtitle)2