Search in sources :

Example 11 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc1.GroupIdRecord in project ORCID-Source by ORCID.

the class BlackBoxBase method createGroupIds.

/**
     * Create group ids
     * */
public List<GroupIdRecord> createGroupIds() throws JSONException {
    //Use the existing ones
    if (groupRecords != null && !groupRecords.isEmpty())
        return groupRecords;
    groupRecords = new ArrayList<GroupIdRecord>();
    String token = getClientCredentialsAccessToken(ScopePathType.GROUP_ID_RECORD_UPDATE, getClient1ClientId(), getClient1ClientSecret(), APIRequestType.MEMBER);
    GroupIdRecord g1 = new GroupIdRecord();
    g1.setDescription("Description");
    g1.setGroupId("orcid-generated:01" + System.currentTimeMillis());
    g1.setName("Group # 1");
    g1.setType("publisher");
    GroupIdRecord g2 = new GroupIdRecord();
    g2.setDescription("Description");
    g2.setGroupId("orcid-generated:02" + System.currentTimeMillis());
    g2.setName("Group # 2");
    g2.setType("publisher");
    ClientResponse r1 = memberV2ApiClient.createGroupIdRecord(g1, token);
    String r1LocationPutCode = r1.getLocation().getPath().replace("/orcid-api-web/v2.0/group-id-record/", "");
    g1.setPutCode(Long.valueOf(r1LocationPutCode));
    groupRecords.add(g1);
    ClientResponse r2 = memberV2ApiClient.createGroupIdRecord(g2, token);
    String r2LocationPutCode = r2.getLocation().getPath().replace("/orcid-api-web/v2.0/group-id-record/", "");
    g2.setPutCode(Long.valueOf(r2LocationPutCode));
    groupRecords.add(g2);
    return groupRecords;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord)

Example 12 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc1.GroupIdRecord in project ORCID-Source by ORCID.

the class Utils method getGroupIdRecord.

public static GroupIdRecord getGroupIdRecord() {
    GroupIdRecord newRecord = new GroupIdRecord();
    newRecord.setGroupId("issn:0000006");
    newRecord.setName("TestGroup5");
    newRecord.setDescription("TestDescription5");
    newRecord.setType("publisher");
    return newRecord;
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord)

Example 13 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc1.GroupIdRecord in project ORCID-Source by ORCID.

the class Api2_0_rc3_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(GroupIdRecords groupIdRecords) {
    if (groupIdRecords != null && groupIdRecords.getGroupIdRecord() != null && !groupIdRecords.getGroupIdRecord().isEmpty()) {
        LastModifiedDate latest = null;
        for (GroupIdRecord groupid : groupIdRecords.getGroupIdRecord()) {
            if (groupid.getLastModifiedDate() != null && groupid.getLastModifiedDate().after(latest)) {
                latest = groupid.getLastModifiedDate();
            }
        }
        groupIdRecords.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc3.LastModifiedDate) GroupIdRecord(org.orcid.jaxb.model.groupid_rc3.GroupIdRecord)

Example 14 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc1.GroupIdRecord 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);
    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);
    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);
    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 15 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc1.GroupIdRecord in project ORCID-Source by ORCID.

the class GroupIdRecordManagerTest method testUpdateDuplicateGroupIdRecords.

@Test
public void testUpdateDuplicateGroupIdRecords() {
    String groupName = "Group # " + System.currentTimeMillis();
    GroupIdRecord g1 = new GroupIdRecord();
    g1.setDescription("Description");
    g1.setGroupId("orcid-generated:valid-group-id#1");
    g1.setName(groupName);
    g1.setType("publisher");
    //Create the first one
    g1 = groupIdRecordManager.createGroupIdRecord(g1);
    Long putCode1 = g1.getPutCode();
    assertNotNull(g1.getSource());
    assertNotNull(g1.getSource().getSourceClientId());
    assertEquals(CLIENT_ID, g1.getSource().getSourceClientId().getPath());
    //Create another one
    g1.setPutCode(null);
    g1.setGroupId("orcid-generated:valid-group-id#2");
    g1 = groupIdRecordManager.createGroupIdRecord(g1);
    Long putCode2 = g1.getPutCode();
    assertNotNull(g1.getSource());
    assertNotNull(g1.getSource().getSourceClientId());
    assertEquals(CLIENT_ID, g1.getSource().getSourceClientId().getPath());
    //Create another one
    g1.setPutCode(null);
    g1.setGroupId("orcid-generated:valid-group-id#3");
    g1 = groupIdRecordManager.createGroupIdRecord(g1);
    Long putCode3 = g1.getPutCode();
    assertNotNull(g1.getSource());
    assertNotNull(g1.getSource().getSourceClientId());
    assertEquals(CLIENT_ID, g1.getSource().getSourceClientId().getPath());
    //Update #1 with an existing group id
    try {
        GroupIdRecord existingOne = groupIdRecordManager.findByGroupId("orcid-generated:valid-group-id#1").get();
        existingOne.setGroupId("orcid-generated:valid-group-id#2");
        existingOne.setDescription("updated-description");
        groupIdRecordManager.updateGroupIdRecord(existingOne.getPutCode(), existingOne);
        fail();
    } catch (DuplicatedGroupIdRecordException e) {
    } catch (Exception e) {
        fail();
    }
    //Update #1 with an existing group id
    try {
        GroupIdRecord existingOne = groupIdRecordManager.findByGroupId("orcid-generated:valid-group-id#1").get();
        existingOne.setGroupId("orcid-generated:valid-group-id#3");
        existingOne.setDescription("updated-description");
        groupIdRecordManager.updateGroupIdRecord(existingOne.getPutCode(), existingOne);
        fail();
    } catch (DuplicatedGroupIdRecordException e) {
    } catch (Exception e) {
        fail();
    }
    //Update #1 with a new group id
    GroupIdRecord existingOne = groupIdRecordManager.findByGroupId("orcid-generated:valid-group-id#1").get();
    existingOne.setGroupId("orcid-generated:valid-group-id#1-updated");
    existingOne.setDescription("updated-description");
    existingOne = groupIdRecordManager.updateGroupIdRecord(existingOne.getPutCode(), existingOne);
    assertNotNull(existingOne);
    assertEquals(putCode1, existingOne.getPutCode());
    assertEquals("orcid-generated:valid-group-id#1-updated", existingOne.getGroupId());
    assertEquals("updated-description", existingOne.getDescription());
    assertEquals(groupName, existingOne.getName());
    assertNotNull(existingOne.getSource());
    assertNotNull(existingOne.getSource().getSourceClientId());
    assertEquals(CLIENT_ID, existingOne.getSource().getSourceClientId().getPath());
    //Delete them
    groupIdRecordManager.deleteGroupIdRecord(putCode1);
    groupIdRecordManager.deleteGroupIdRecord(putCode2);
    groupIdRecordManager.deleteGroupIdRecord(putCode3);
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) DuplicatedGroupIdRecordException(org.orcid.core.exception.DuplicatedGroupIdRecordException) InvalidPutCodeException(org.orcid.core.exception.InvalidPutCodeException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) DuplicatedGroupIdRecordException(org.orcid.core.exception.DuplicatedGroupIdRecordException) GroupIdRecordNotFoundException(org.orcid.core.exception.GroupIdRecordNotFoundException) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

GroupIdRecord (org.orcid.jaxb.model.groupid_v2.GroupIdRecord)22 Test (org.junit.Test)12 DBUnitTest (org.orcid.test.DBUnitTest)4 Response (javax.ws.rs.core.Response)3 BaseTest (org.orcid.core.BaseTest)3 DuplicatedGroupIdRecordException (org.orcid.core.exception.DuplicatedGroupIdRecordException)3 GroupIdRecordNotFoundException (org.orcid.core.exception.GroupIdRecordNotFoundException)3 InvalidPutCodeException (org.orcid.core.exception.InvalidPutCodeException)3 OrcidValidationException (org.orcid.core.exception.OrcidValidationException)3 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)3 GroupIdRecordEntity (org.orcid.persistence.jpa.entities.GroupIdRecordEntity)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)2 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)2 IOException (java.io.IOException)1 URI (java.net.URI)1 AccessControlException (java.security.AccessControlException)1