use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_AddressesTest method testUpdateAddress.
@Test
public void testUpdateAddress() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
assertNotNull(response);
Address address = (Address) response.getEntity();
assertNotNull(address);
Utils.verifyLastModified(address.getLastModifiedDate());
LastModifiedDate before = address.getLastModifiedDate();
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertEquals(Visibility.PUBLIC, address.getVisibility());
address.getCountry().setValue(Iso3166Country.PA);
response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
assertNotNull(response);
address = (Address) response.getEntity();
assertNotNull(address);
Utils.verifyLastModified(address.getLastModifiedDate());
LastModifiedDate after = address.getLastModifiedDate();
assertTrue(after.after(before));
assertEquals(Iso3166Country.PA, address.getCountry().getValue());
// Set it back to US again
address.getCountry().setValue(Iso3166Country.US);
response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
address = (Address) response.getEntity();
assertNotNull(address);
Utils.verifyLastModified(address.getLastModifiedDate());
assertNotNull(address.getLastModifiedDate());
assertTrue(address.getLastModifiedDate().after(after));
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertEquals(Visibility.PUBLIC, address.getVisibility());
}
use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EducationsTest method testUpdateEducation.
@Test
public void testUpdateEducation() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewEducation("4444-4444-4444-4443", 3L);
assertNotNull(response);
Education education = (Education) response.getEntity();
assertNotNull(education);
assertEquals("Another Department", education.getDepartmentName());
assertEquals("Student", education.getRoleTitle());
Utils.verifyLastModified(education.getLastModifiedDate());
LastModifiedDate before = education.getLastModifiedDate();
education.setDepartmentName("Updated department name");
education.setRoleTitle("The updated role title");
response = serviceDelegator.updateEducation("4444-4444-4444-4443", 3L, education);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewEducation("4444-4444-4444-4443", 3L);
assertNotNull(response);
education = (Education) response.getEntity();
assertNotNull(education);
Utils.verifyLastModified(education.getLastModifiedDate());
assertTrue(education.getLastModifiedDate().after(before));
assertEquals("Updated department name", education.getDepartmentName());
assertEquals("The updated role title", education.getRoleTitle());
// Rollback changes
education.setDepartmentName("Another Department");
education.setRoleTitle("Student");
response = serviceDelegator.updateEducation("4444-4444-4444-4443", 3L, education);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_FundingTest method testUpdateFunding.
@Test
public void testUpdateFunding() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewFunding("4444-4444-4444-4447", 6L);
assertNotNull(response);
Funding funding = (Funding) response.getEntity();
assertNotNull(funding);
assertEquals("Public Funding # 1", funding.getTitle().getTitle().getContent());
assertEquals("This is the description for funding with id 6", funding.getDescription());
LastModifiedDate before = funding.getLastModifiedDate();
funding.getTitle().getTitle().setContent("Updated funding title");
funding.setDescription("This is an updated description");
ExternalID fExtId = new ExternalID();
fExtId.setRelationship(Relationship.PART_OF);
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
fExtId.setUrl(new Url("http://fundingExtId.com"));
fExtId.setValue("new-funding-ext-id");
ExternalIDs fExtIds = new ExternalIDs();
fExtIds.getExternalIdentifier().add(fExtId);
funding.setExternalIdentifiers(fExtIds);
response = serviceDelegator.updateFunding("4444-4444-4444-4447", 6L, funding);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewFunding("4444-4444-4444-4447", 6L);
assertNotNull(response);
funding = (Funding) response.getEntity();
assertNotNull(funding);
Utils.verifyLastModified(funding.getLastModifiedDate());
assertTrue(funding.getLastModifiedDate().after(before));
assertEquals("Updated funding title", funding.getTitle().getTitle().getContent());
assertEquals("This is an updated description", funding.getDescription());
// Rollback changes
funding.getTitle().getTitle().setContent("Public Funding # 1");
funding.setDescription("This is the description for funding with id 6");
response = serviceDelegator.updateFunding("4444-4444-4444-4447", 6L, funding);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testUpdateKeyword.
@Test
public void testUpdateKeyword() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
assertNotNull(response);
Keyword keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
Utils.verifyLastModified(keyword.getLastModifiedDate());
LastModifiedDate before = keyword.getLastModifiedDate();
assertEquals("keyword-2", keyword.getContent());
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
keyword.setContent("Updated keyword");
response = serviceDelegator.updateKeyword("4444-4444-4444-4441", 6L, keyword);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewKeyword("4444-4444-4444-4441", 6L);
assertNotNull(response);
keyword = (Keyword) response.getEntity();
assertNotNull(keyword);
Utils.verifyLastModified(keyword.getLastModifiedDate());
assertTrue(keyword.getLastModifiedDate().after(before));
assertEquals("Updated keyword", keyword.getContent());
assertEquals(Visibility.PUBLIC, keyword.getVisibility());
}
use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.
the class PersonalDetailsManagerReadOnlyImpl method getPersonalDetails.
@Override
public PersonalDetails getPersonalDetails(String orcid) {
Date lastModified = getLastModifiedDate(orcid);
long lastModifiedTime = lastModified.getTime();
PersonalDetails personalDetails = new PersonalDetails();
Name name = recordNameManager.getRecordName(orcid, lastModifiedTime);
if (name != null) {
personalDetails.setName(name);
}
Biography bio = biographyManager.getBiography(orcid, lastModifiedTime);
if (bio != null) {
personalDetails.setBiography(bio);
}
OtherNames otherNames = otherNameManager.getOtherNames(orcid, lastModifiedTime);
OtherNames filteredOtherNames = new OtherNames();
personalDetails.setOtherNames(filteredOtherNames);
if (otherNames != null && otherNames.getOtherNames() != null && !otherNames.getOtherNames().isEmpty()) {
// Lets copy the list so we don't modify the cached collection
List<OtherName> filteredList = new ArrayList<OtherName>(otherNames.getOtherNames());
filteredOtherNames.setOtherNames(filteredList);
}
if (personalDetails.getLastModifiedDate() == null || personalDetails.getLastModifiedDate().getValue() == null) {
personalDetails.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(lastModified)));
}
return personalDetails;
}
Aggregations