use of org.orcid.jaxb.model.common_rc3.LastModifiedDate in project ORCID-Source by ORCID.
the class KeywordForm method toKeyword.
public Keyword toKeyword() {
Keyword keyword = new Keyword();
if (!PojoUtil.isEmpty(putCode)) {
keyword.setPutCode(Long.valueOf(putCode));
}
if (!PojoUtil.isEmpty(content)) {
keyword.setContent(content);
}
if (visibility != null && visibility.getVisibility() != null) {
keyword.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(visibility.getVisibility().value()));
} else {
keyword.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.KEYWORD_DEFAULT.getVisibility().value()));
}
if (createdDate != null) {
keyword.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(createdDate.toCalendar())));
}
if (lastModified != null) {
keyword.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(lastModified.toCalendar())));
}
if (displayIndex != null) {
keyword.setDisplayIndex(displayIndex);
} else {
keyword.setDisplayIndex(0L);
}
keyword.setSource(new Source(source));
return keyword;
}
use of org.orcid.jaxb.model.common_rc3.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());
}
use of org.orcid.jaxb.model.common_rc3.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());
}
use of org.orcid.jaxb.model.common_rc3.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());
}
use of org.orcid.jaxb.model.common_rc3.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());
}
Aggregations