use of org.orcid.jaxb.model.common_v2.FuzzyDate in project ORCID-Source by ORCID.
the class AffiliationsManagerTest method getEducation.
private Education getEducation() {
Education education = new Education();
Organization org = new Organization();
org.setName("org-name");
OrganizationAddress address = new OrganizationAddress();
address.setCity("city");
address.setCountry(Iso3166Country.US);
org.setAddress(address);
education.setOrganization(org);
education.setStartDate(new FuzzyDate(new Year(2016), new Month(3), new Day(29)));
education.setVisibility(Visibility.PUBLIC);
return education;
}
use of org.orcid.jaxb.model.common_v2.FuzzyDate in project ORCID-Source by ORCID.
the class AffiliationsManagerTest method getEmployment.
private Employment getEmployment() {
Employment employment = new Employment();
Organization org = new Organization();
org.setName("org-name");
OrganizationAddress address = new OrganizationAddress();
address.setCity("city");
address.setCountry(Iso3166Country.US);
org.setAddress(address);
employment.setOrganization(org);
employment.setStartDate(new FuzzyDate(new Year(2016), new Month(3), new Day(29)));
employment.setVisibility(Visibility.PUBLIC);
return employment;
}
use of org.orcid.jaxb.model.common_v2.FuzzyDate in project ORCID-Source by ORCID.
the class MapperFacadeFactory method mapFuzzyDateToStartDateEntityAndEndDateEntity.
private void mapFuzzyDateToStartDateEntityAndEndDateEntity(MapperFactory mapperFactory) {
mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).customize(new CustomMapper<FuzzyDate, StartDateEntity>() {
@Override
public void mapAtoB(FuzzyDate fuzzyDate, StartDateEntity entity, MappingContext context) {
if (fuzzyDate.getYear() != null) {
entity.setYear(Integer.valueOf(fuzzyDate.getYear().getValue()));
} else {
entity.setYear(null);
}
if (fuzzyDate.getMonth() != null) {
entity.setMonth(Integer.valueOf(fuzzyDate.getMonth().getValue()));
} else {
entity.setMonth(null);
}
if (fuzzyDate.getDay() != null) {
entity.setDay(Integer.valueOf(fuzzyDate.getDay().getValue()));
} else {
entity.setDay(null);
}
}
@Override
public void mapBtoA(StartDateEntity entity, FuzzyDate fuzzyDate, MappingContext context) {
if (entity.getYear() != null) {
fuzzyDate.setYear(new Year(entity.getYear()));
} else {
fuzzyDate.setYear(null);
}
if (entity.getMonth() != null) {
fuzzyDate.setMonth(new Month(entity.getMonth()));
} else {
fuzzyDate.setMonth(null);
}
if (entity.getDay() != null) {
fuzzyDate.setDay(new Day(entity.getDay()));
} else {
fuzzyDate.setDay(null);
}
}
}).register();
mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).customize(new CustomMapper<FuzzyDate, EndDateEntity>() {
@Override
public void mapAtoB(FuzzyDate fuzzyDate, EndDateEntity entity, MappingContext context) {
if (fuzzyDate.getYear() != null) {
entity.setYear(Integer.valueOf(fuzzyDate.getYear().getValue()));
} else {
entity.setYear(null);
}
if (fuzzyDate.getMonth() != null) {
entity.setMonth(Integer.valueOf(fuzzyDate.getMonth().getValue()));
} else {
entity.setMonth(null);
}
if (fuzzyDate.getDay() != null) {
entity.setDay(Integer.valueOf(fuzzyDate.getDay().getValue()));
} else {
entity.setDay(null);
}
}
@Override
public void mapBtoA(EndDateEntity entity, FuzzyDate fuzzyDate, MappingContext context) {
if (entity.getYear() != null) {
fuzzyDate.setYear(new Year(entity.getYear()));
} else {
fuzzyDate.setYear(null);
}
if (entity.getMonth() != null) {
fuzzyDate.setMonth(new Month(entity.getMonth()));
} else {
fuzzyDate.setMonth(null);
}
if (entity.getDay() != null) {
fuzzyDate.setDay(new Day(entity.getDay()));
} else {
fuzzyDate.setDay(null);
}
}
}).register();
}
use of org.orcid.jaxb.model.common_v2.FuzzyDate in project ORCID-Source by ORCID.
the class PublicProfileVisibilityTest method peerReviewPrivacyTest.
@Test
public void peerReviewPrivacyTest() throws InterruptedException, JSONException, URISyntaxException {
// Create peer review group
String accessToken = getAccessToken(getScopes(ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE, ScopePathType.ACTIVITIES_READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE));
List<GroupIdRecord> groups = createGroupIds();
assertNotNull(groups);
assertTrue(groups.size() > 0);
GroupIdRecord g1 = groups.get(0);
// Create peer review
long time = System.currentTimeMillis();
PeerReview peerReview = new PeerReview();
peerReview.setGroupId(g1.getGroupId());
ExternalIDs extIds = new ExternalIDs();
peerReview.setExternalIdentifiers(extIds);
peerReview.getExternalIdentifiers().getExternalIdentifier().clear();
ExternalID wExtId = new ExternalID();
wExtId.setValue("Work Id " + time);
wExtId.setType(WorkExternalIdentifierType.AGR.value());
wExtId.setRelationship(Relationship.SELF);
peerReview.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
Organization organization = new Organization();
organization.setName("My org name " + System.currentTimeMillis());
OrganizationAddress address = new OrganizationAddress();
address.setCity("Imagination city");
address.setCountry(Iso3166Country.US);
organization.setAddress(address);
peerReview.setOrganization(organization);
peerReview.setRole(Role.CHAIR);
peerReview.setType(PeerReviewType.EVALUATION);
peerReview.setCompletionDate(new FuzzyDate(new Year(2016), new Month(1), new Day(1)));
ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(this.getUser1OrcidId(), peerReview, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
peerReview = getResponse.getEntity(PeerReview.class);
showMyOrcidPage();
changePeerReviewVisibility(g1.getName(), Visibility.PRIVATE.name());
try {
// Verify it doesn't appear in the public page
showPublicProfilePage(getUser1OrcidId());
peerReviewAppearsInPublicPage(g1.getName());
fail();
} catch (Exception e) {
}
showMyOrcidPage();
changePeerReviewVisibility(g1.getName(), Visibility.LIMITED.name());
try {
// Verify it doesn't appear in the public page
showPublicProfilePage(getUser1OrcidId());
peerReviewAppearsInPublicPage(g1.getName());
fail();
} catch (Exception e) {
}
showMyOrcidPage();
changePeerReviewVisibility(g1.getName(), Visibility.PUBLIC.name());
showPublicProfilePage(getUser1OrcidId());
peerReviewAppearsInPublicPage(g1.getName());
// Rollback
ClientResponse deleteResponse = memberV2ApiClient.deletePeerReviewXml(this.getUser1OrcidId(), peerReview.getPutCode(), accessToken);
assertNotNull(deleteResponse);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
use of org.orcid.jaxb.model.common_v2.FuzzyDate in project ORCID-Source by ORCID.
the class JpaJaxbEmploymentAdapterTest method getEmploymentWithDatesWithNullMonthAndDay.
private Employment getEmploymentWithDatesWithNullMonthAndDay() {
Employment employment = new Employment();
employment.setRoleTitle("role title");
FuzzyDate startDate = new FuzzyDate(new Year(2017), null, null);
FuzzyDate endDate = new FuzzyDate(new Year(2017), null, null);
employment.setStartDate(startDate);
employment.setEndDate(endDate);
return employment;
}
Aggregations