Search in sources :

Example 26 with MembershipSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary in project ORCID-Source by ORCID.

the class JpaJaxbMembershipAdapterTest method fromOrgAffiliationRelationEntityToMembershipSummary.

@Test
public void fromOrgAffiliationRelationEntityToMembershipSummary() {
    OrgAffiliationRelationEntity entity = getEntity();
    assertNotNull(entity);
    MembershipSummary summary = adapter.toMembershipSummary(entity);
    assertNotNull(summary);
    assertEquals("membership:department", summary.getDepartmentName());
    assertEquals(Long.valueOf(123456), summary.getPutCode());
    assertEquals("membership:title", summary.getRoleTitle());
    assertEquals("private", summary.getVisibility().value());
    assertNotNull(summary.getStartDate());
    assertEquals("2000", summary.getStartDate().getYear().getValue());
    assertEquals("01", summary.getStartDate().getMonth().getValue());
    assertEquals("01", summary.getStartDate().getDay().getValue());
    assertEquals("2020", summary.getEndDate().getYear().getValue());
    assertEquals("02", summary.getEndDate().getMonth().getValue());
    assertEquals("02", summary.getEndDate().getDay().getValue());
    assertNotNull(summary.getSource());
    assertNotNull(summary.getSource().retrieveSourcePath());
    assertEquals("APP-000000001", summary.getSource().retrieveSourcePath());
}
Also used : OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary) Test(org.junit.Test)

Example 27 with MembershipSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_MembershipsTest method testAddMembership.

@Test
public void testAddMembership() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary originalSummary = (ActivitiesSummary) response.getEntity();
    assertNotNull(originalSummary);
    Utils.verifyLastModified(originalSummary.getLastModifiedDate());
    assertNotNull(originalSummary.getMemberships());
    Utils.verifyLastModified(originalSummary.getMemberships().getLastModifiedDate());
    assertNotNull(originalSummary.getMemberships().getSummaries());
    assertNotNull(originalSummary.getMemberships().getSummaries().get(0));
    Utils.verifyLastModified(originalSummary.getMemberships().getSummaries().get(0).getLastModifiedDate());
    assertEquals(4, originalSummary.getMemberships().getSummaries().size());
    response = serviceDelegator.createMembership(ORCID, (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP));
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary summaryWithNewElement = (ActivitiesSummary) response.getEntity();
    assertNotNull(summaryWithNewElement);
    Utils.verifyLastModified(summaryWithNewElement.getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getMemberships());
    Utils.verifyLastModified(summaryWithNewElement.getMemberships().getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getMemberships().getSummaries());
    assertEquals(5, summaryWithNewElement.getMemberships().getSummaries().size());
    boolean haveNew = false;
    for (MembershipSummary membershipSummary : summaryWithNewElement.getMemberships().getSummaries()) {
        assertNotNull(membershipSummary.getPutCode());
        Utils.verifyLastModified(membershipSummary.getLastModifiedDate());
        if (membershipSummary.getPutCode().equals(putCode)) {
            assertEquals("My department name", membershipSummary.getDepartmentName());
            haveNew = true;
        } else {
            assertTrue(originalSummary.getMemberships().getSummaries().contains(membershipSummary));
        }
    }
    assertTrue(haveNew);
    // Remove new element
    serviceDelegator.deleteAffiliation(ORCID, putCode);
}
Also used : Response(javax.ws.rs.core.Response) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) List(java.util.List) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 28 with MembershipSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testViewMemberships.

@Test
public void testViewMemberships() {
    Response response = serviceDelegator.viewMemberships(ORCID);
    assertNotNull(response);
    Memberships memberships = (Memberships) response.getEntity();
    assertNotNull(memberships);
    assertEquals("/0000-0000-0000-0003/memberships", memberships.getPath());
    assertNotNull(memberships.getLastModifiedDate());
    assertNotNull(memberships.getLastModifiedDate().getValue());
    assertEquals(1, memberships.getSummaries().size());
    MembershipSummary membership = memberships.getSummaries().get(0);
    assertEquals(Long.valueOf(37), membership.getPutCode());
    assertNotNull(membership.getLastModifiedDate());
    assertNotNull(membership.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/membership/37", membership.getPath());
    assertEquals("PUBLIC Department", membership.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), membership.getVisibility().value());
    assertEquals("APP-5555555555555555", membership.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Memberships(org.orcid.jaxb.model.v3.dev1.record.summary.Memberships) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 29 with MembershipSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorImpl method viewMemberships.

@Override
public Response viewMemberships(String orcid) {
    List<MembershipSummary> memberships = affiliationsManagerReadOnly.getMembershipSummaryList(orcid);
    Memberships publicMemberships = new Memberships();
    for (MembershipSummary summary : memberships) {
        if (Visibility.PUBLIC.equals(summary.getVisibility())) {
            ActivityUtils.setPathToActivity(summary, orcid);
            sourceUtilsReadOnly.setSourceName(summary);
            publicMemberships.getSummaries().add(summary);
        }
    }
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(publicMemberships);
    ActivityUtils.setPathToAffiliations(publicMemberships, orcid);
    return Response.ok(publicMemberships).build();
}
Also used : Memberships(org.orcid.jaxb.model.v3.dev1.record.summary.Memberships) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)

Example 30 with MembershipSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorImpl method viewMembershipSummary.

@Override
public Response viewMembershipSummary(String orcid, Long putCode) {
    MembershipSummary s = affiliationsManagerReadOnly.getMembershipSummary(orcid, putCode);
    publicAPISecurityManagerV3.checkIsPublic(s);
    ActivityUtils.setPathToActivity(s, orcid);
    sourceUtilsReadOnly.setSourceName(s);
    return Response.ok(s).build();
}
Also used : MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)

Aggregations

MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)49 Test (org.junit.Test)40 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)35 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)35 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)35 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)35 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)35 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)35 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)35 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)35 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)34 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)34 Address (org.orcid.jaxb.model.v3.dev1.record.Address)14 Email (org.orcid.jaxb.model.v3.dev1.record.Email)14 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)14 Name (org.orcid.jaxb.model.v3.dev1.record.Name)14 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)14 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)14 Record (org.orcid.jaxb.model.v3.dev1.record.Record)14 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)14