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;
}
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;
}
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);
}
}
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());
}
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);
}
Aggregations