use of org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositions in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewInvitedPositions.
@Override
public Response viewInvitedPositions(String orcid) {
List<InvitedPositionSummary> inivitedPositionsList = affiliationsManagerReadOnly.getInvitedPositionSummaryList(orcid);
// Lets copy the list so we don't modify the cached collection
List<InvitedPositionSummary> filteredList = null;
if (inivitedPositionsList != null) {
filteredList = new ArrayList<InvitedPositionSummary>(inivitedPositionsList);
}
inivitedPositionsList = filteredList;
orcidSecurityManager.checkAndFilter(orcid, inivitedPositionsList, ScopePathType.AFFILIATIONS_READ_LIMITED);
InvitedPositions inivitedPositions = new InvitedPositions(inivitedPositionsList);
ActivityUtils.setPathToAffiliations(inivitedPositions, orcid);
sourceUtils.setSourceName(inivitedPositions);
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(inivitedPositions);
return Response.ok(inivitedPositions).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositions in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testViewInvitedPositions.
@Test
public void testViewInvitedPositions() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewInvitedPositions(ORCID);
assertNotNull(r);
InvitedPositions invitedPositions = (InvitedPositions) r.getEntity();
assertNotNull(invitedPositions);
assertEquals("/0000-0000-0000-0003/invited-positions", invitedPositions.getPath());
Utils.verifyLastModified(invitedPositions.getLastModifiedDate());
assertNotNull(invitedPositions.getSummaries());
assertEquals(4, invitedPositions.getSummaries().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (InvitedPositionSummary summary : invitedPositions.getSummaries()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
if (Long.valueOf(32).equals(summary.getPutCode())) {
assertEquals("PUBLIC Department", summary.getDepartmentName());
found1 = true;
} else if (Long.valueOf(33).equals(summary.getPutCode())) {
assertEquals("LIMITED Department", summary.getDepartmentName());
found2 = true;
} else if (Long.valueOf(34).equals(summary.getPutCode())) {
assertEquals("PRIVATE Department", summary.getDepartmentName());
found3 = true;
} else if (Long.valueOf(35).equals(summary.getPutCode())) {
assertEquals("SELF LIMITED Department", summary.getDepartmentName());
found4 = true;
} else {
fail("Invalid invitedPosition found: " + summary.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositions in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testGetPublicInvitedPositionsUsingToken.
@Test
public void testGetPublicInvitedPositionsUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewInvitedPositions(ORCID);
assertNotNull(r);
InvitedPositions invitedPositions = (InvitedPositions) r.getEntity();
assertNotNull(invitedPositions);
assertNotNull(invitedPositions.getLastModifiedDate());
assertNotNull(invitedPositions.getLastModifiedDate().getValue());
assertNotNull(invitedPositions.getSummaries());
assertEquals(1, invitedPositions.getSummaries().size());
assertEquals(Long.valueOf(32), invitedPositions.getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, invitedPositions.getSummaries().get(0).getVisibility());
assertNotNull(invitedPositions.getSummaries().get(0).getLastModifiedDate());
assertNotNull(invitedPositions.getSummaries().get(0).getLastModifiedDate().getValue());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositions in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromMemberAPI.
@Test
public void testViewRecordFromMemberAPI() throws InterruptedException, JSONException {
String accessToken = getAccessToken();
assertNotNull(accessToken);
ClientResponse response = memberV3Dev1ApiClient.viewRecord(getUser1OrcidId(), accessToken);
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
// Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
// Distinctions
if (record.getActivitiesSummary().getDistinctions() != null) {
Distinctions e = record.getActivitiesSummary().getDistinctions();
if (e.getSummaries() != null) {
for (DistinctionSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// InvitedPositions
if (record.getActivitiesSummary().getInvitedPositions() != null) {
InvitedPositions e = record.getActivitiesSummary().getInvitedPositions();
if (e.getSummaries() != null) {
for (InvitedPositionSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Memberships
if (record.getActivitiesSummary().getMemberships() != null) {
Memberships e = record.getActivitiesSummary().getMemberships();
if (e.getSummaries() != null) {
for (MembershipSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Qualifications
if (record.getActivitiesSummary().getQualifications() != null) {
Qualifications e = record.getActivitiesSummary().getQualifications();
if (e.getSummaries() != null) {
for (QualificationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Services
if (record.getActivitiesSummary().getServices() != null) {
Services e = record.getActivitiesSummary().getServices();
if (e.getSummaries() != null) {
for (ServiceSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
// PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
// Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
}
// Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
// Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertNotNull(o.getVisibility());
Visibility v = o.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), o.getSource().retrieveSourcePath());
}
}
}
}
// Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
if (Visibility.PRIVATE.equals(b.getVisibility())) {
fail("Visibility is private");
}
}
}
// Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
fail("Email " + e.getEmail() + " is private");
}
}
}
}
// External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
if (Visibility.PRIVATE.equals(name.getVisibility())) {
fail("Name is private");
}
}
// Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
}
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositions in project ORCID-Source by ORCID.
the class ActivitiesSummaryManagerReadOnlyImpl method getActivitiesSummary.
public ActivitiesSummary getActivitiesSummary(String orcid, boolean justPublic) {
ActivitiesSummary activities = new ActivitiesSummary();
// Set distinctions
List<DistinctionSummary> distinctionsList = affiliationsManager.getDistinctionSummaryList(orcid);
Distinctions distinctions = new Distinctions();
for (DistinctionSummary summary : distinctionsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
distinctions.getSummaries().add(summary);
}
} else {
distinctions.getSummaries().add(summary);
}
}
activities.setDistinctions(distinctions);
// Set educations
List<EducationSummary> educationsList = affiliationsManager.getEducationSummaryList(orcid);
Educations educations = new Educations();
for (EducationSummary summary : educationsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
educations.getSummaries().add(summary);
}
} else {
educations.getSummaries().add(summary);
}
}
activities.setEducations(educations);
// Set employments
List<EmploymentSummary> employmentList = affiliationsManager.getEmploymentSummaryList(orcid);
Employments employments = new Employments();
for (EmploymentSummary summary : employmentList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
employments.getSummaries().add(summary);
}
} else {
employments.getSummaries().add(summary);
}
}
activities.setEmployments(employments);
// Set invited positions
List<InvitedPositionSummary> invitedPositionsList = affiliationsManager.getInvitedPositionSummaryList(orcid);
InvitedPositions invitedPositions = new InvitedPositions();
for (InvitedPositionSummary summary : invitedPositionsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
invitedPositions.getSummaries().add(summary);
}
} else {
invitedPositions.getSummaries().add(summary);
}
}
activities.setInvitedPositions(invitedPositions);
// Set memberships
List<MembershipSummary> membershipsList = affiliationsManager.getMembershipSummaryList(orcid);
Memberships memberships = new Memberships();
for (MembershipSummary summary : membershipsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
memberships.getSummaries().add(summary);
}
} else {
memberships.getSummaries().add(summary);
}
}
activities.setMemberships(memberships);
// Set qualifications
List<QualificationSummary> qualificationsList = affiliationsManager.getQualificationSummaryList(orcid);
Qualifications qualifications = new Qualifications();
for (QualificationSummary summary : qualificationsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
qualifications.getSummaries().add(summary);
}
} else {
qualifications.getSummaries().add(summary);
}
}
activities.setQualifications(qualifications);
// Set services
List<ServiceSummary> servicesList = affiliationsManager.getServiceSummaryList(orcid);
Services services = new Services();
for (ServiceSummary summary : servicesList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
services.getSummaries().add(summary);
}
} else {
services.getSummaries().add(summary);
}
}
activities.setServices(services);
// Set fundings
List<FundingSummary> fundingSummaries = fundingManager.getFundingSummaryList(orcid);
Fundings fundings = fundingManager.groupFundings(fundingSummaries, justPublic);
activities.setFundings(fundings);
// Set peer reviews
List<PeerReviewSummary> peerReviewSummaries = peerReviewManager.getPeerReviewSummaryList(orcid);
PeerReviews peerReviews = peerReviewManager.groupPeerReviews(peerReviewSummaries, justPublic);
activities.setPeerReviews(peerReviews);
// Set works
List<WorkSummary> workSummaries = workManager.getWorksSummaryList(orcid);
Works works = workManager.groupWorks(workSummaries, justPublic);
activities.setWorks(works);
return activities;
}
Aggregations