Search in sources :

Example 1 with FuzzyDate

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;
}
Also used : Month(org.orcid.jaxb.model.common_v2.Month) Organization(org.orcid.jaxb.model.common_v2.Organization) Year(org.orcid.jaxb.model.common_v2.Year) Education(org.orcid.jaxb.model.record_v2.Education) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) Day(org.orcid.jaxb.model.common_v2.Day)

Example 2 with FuzzyDate

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;
}
Also used : Month(org.orcid.jaxb.model.common_v2.Month) Organization(org.orcid.jaxb.model.common_v2.Organization) Year(org.orcid.jaxb.model.common_v2.Year) Employment(org.orcid.jaxb.model.record_v2.Employment) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) Day(org.orcid.jaxb.model.common_v2.Day)

Example 3 with FuzzyDate

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();
}
Also used : MappingContext(ma.glasnost.orika.MappingContext) EndDateEntity(org.orcid.persistence.jpa.entities.EndDateEntity) Month(org.orcid.jaxb.model.common_v2.Month) Year(org.orcid.jaxb.model.common_v2.Year) StartDateEntity(org.orcid.persistence.jpa.entities.StartDateEntity) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) CustomMapper(ma.glasnost.orika.CustomMapper) Day(org.orcid.jaxb.model.common_v2.Day)

Example 4 with FuzzyDate

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());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Organization(org.orcid.jaxb.model.common_v2.Organization) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate) URISyntaxException(java.net.URISyntaxException) JSONException(org.codehaus.jettison.json.JSONException) Month(org.orcid.jaxb.model.common_v2.Month) Year(org.orcid.jaxb.model.common_v2.Year) Day(org.orcid.jaxb.model.common_v2.Day) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 5 with FuzzyDate

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;
}
Also used : Year(org.orcid.jaxb.model.common_v2.Year) Employment(org.orcid.jaxb.model.record_v2.Employment) FuzzyDate(org.orcid.jaxb.model.common_v2.FuzzyDate)

Aggregations

FuzzyDate (org.orcid.jaxb.model.common_v2.FuzzyDate)6 Year (org.orcid.jaxb.model.common_v2.Year)6 Day (org.orcid.jaxb.model.common_v2.Day)5 Month (org.orcid.jaxb.model.common_v2.Month)5 Organization (org.orcid.jaxb.model.common_v2.Organization)3 OrganizationAddress (org.orcid.jaxb.model.common_v2.OrganizationAddress)3 Employment (org.orcid.jaxb.model.record_v2.Employment)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 URISyntaxException (java.net.URISyntaxException)1 CustomMapper (ma.glasnost.orika.CustomMapper)1 MappingContext (ma.glasnost.orika.MappingContext)1 JSONException (org.codehaus.jettison.json.JSONException)1 Test (org.junit.Test)1 GroupIdRecord (org.orcid.jaxb.model.groupid_v2.GroupIdRecord)1 Education (org.orcid.jaxb.model.record_v2.Education)1 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)1 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)1 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)1 EndDateEntity (org.orcid.persistence.jpa.entities.EndDateEntity)1 StartDateEntity (org.orcid.persistence.jpa.entities.StartDateEntity)1