use of org.orcid.jaxb.model.common_rc4.Year 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_rc4.Year in project ORCID-Source by ORCID.
the class PublicV2Test method createActivities.
private void createActivities() throws JSONException, InterruptedException, URISyntaxException {
String accessToken = getAccessToken();
long time = System.currentTimeMillis();
Work workToCreate = (Work) unmarshallFromPath("/record_2.0_rc1/samples/work-2.0_rc1.xml", Work.class);
for (int i = 0; i < 4; i++) {
workToCreate.setPutCode(null);
workToCreate.getWorkTitle().getTitle().setContent("Work # " + i);
workToCreate.getExternalIdentifiers().getExternalIdentifier().clear();
WorkExternalIdentifier wExtId = new WorkExternalIdentifier();
wExtId.setWorkExternalIdentifierId(new WorkExternalIdentifierId(time + " Work Id " + i));
wExtId.setWorkExternalIdentifierType(WorkExternalIdentifierType.AGR);
wExtId.setRelationship(Relationship.SELF);
workToCreate.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
if (i == 0 || i == 3)
workToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
else if (i == 1)
workToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.LIMITED);
else
workToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PRIVATE);
ClientResponse postResponse = memberV2ApiClient.createWorkXml(getUser1OrcidId(), workToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
}
Funding fundingToCreate = (Funding) unmarshallFromPath("/record_2.0_rc1/samples/funding-2.0_rc1.xml", Funding.class);
for (int i = 0; i < 4; i++) {
fundingToCreate.setPutCode(null);
fundingToCreate.getTitle().getTitle().setContent("Funding # " + i);
fundingToCreate.getExternalIdentifiers().getExternalIdentifier().clear();
FundingExternalIdentifier fExtId = new FundingExternalIdentifier();
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER);
fExtId.setValue(time + " funding Id " + i);
fExtId.setRelationship(Relationship.SELF);
fundingToCreate.getExternalIdentifiers().getExternalIdentifier().add(fExtId);
if (i == 0 || i == 3)
fundingToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
else if (i == 1)
fundingToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.LIMITED);
else
fundingToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PRIVATE);
ClientResponse postResponse = memberV2ApiClient.createFundingXml(getUser1OrcidId(), fundingToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
}
Employment employmentToCreate = (Employment) unmarshallFromPath("/record_2.0_rc1/samples/employment-2.0_rc1.xml", Employment.class);
for (int i = 0; i < 4; i++) {
employmentToCreate.setPutCode(null);
employmentToCreate.setRoleTitle("Employment # " + i);
if (i == 0 || i == 3)
employmentToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
else if (i == 1)
employmentToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.LIMITED);
else
employmentToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PRIVATE);
ClientResponse postResponse = memberV2ApiClient.createEmploymentXml(getUser1OrcidId(), employmentToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
}
Education educationToCreate = (Education) unmarshallFromPath("/record_2.0_rc1/samples/education-2.0_rc1.xml", Education.class);
for (int i = 0; i < 4; i++) {
educationToCreate.setPutCode(null);
educationToCreate.setRoleTitle("Education # " + i);
if (i == 0 || i == 3)
educationToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
else if (i == 1)
educationToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.LIMITED);
else
educationToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PRIVATE);
ClientResponse postResponse = memberV2ApiClient.createEducationXml(getUser1OrcidId(), educationToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
}
PeerReview peerReviewToCreate = (PeerReview) unmarshallFromPath("/record_2.0_rc1/samples/peer-review-2.0_rc1.xml", PeerReview.class);
for (int i = 0; i < 4; i++) {
peerReviewToCreate.setPutCode(null);
peerReviewToCreate.setGroupId(groupRecords.get(0).getGroupId());
peerReviewToCreate.getSubjectName().getTitle().setContent("PeerReview # " + i);
peerReviewToCreate.getCompletionDate().setDay(new Day(i + 1));
peerReviewToCreate.getCompletionDate().setMonth(new Month(i + 1));
peerReviewToCreate.getCompletionDate().setYear(new Year((i + 1) * 1000));
peerReviewToCreate.getExternalIdentifiers().getExternalIdentifier().get(0).getWorkExternalIdentifierId().setContent("extId-" + (i + 1));
if (i == 0 || i == 3) {
peerReviewToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
} else if (i == 1) {
peerReviewToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.LIMITED);
} else {
peerReviewToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PRIVATE);
}
ClientResponse postResponse = memberV2ApiClient.createPeerReviewXml(getUser1OrcidId(), peerReviewToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
}
}
use of org.orcid.jaxb.model.common_rc4.Year 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_rc4.Year 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;
}
use of org.orcid.jaxb.model.common_rc4.Year in project ORCID-Source by ORCID.
the class JpaJaxbEmploymentAdapterTest method getEmploymentWithDates.
private Employment getEmploymentWithDates() {
Employment employment = new Employment();
employment.setRoleTitle("role title");
FuzzyDate startDate = new FuzzyDate(new Year(2017), new Month(1), new Day(1));
FuzzyDate endDate = new FuzzyDate(new Year(2017), new Month(3), new Day(1));
employment.setStartDate(startDate);
employment.setEndDate(endDate);
return employment;
}
Aggregations