use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_GeneralTest method testOrcidProfileCreateCanViewAndCreateGroupIds.
@Test
public void testOrcidProfileCreateCanViewAndCreateGroupIds() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
try {
serviceDelegator.viewGroupIdRecord(1L);
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewGroupIdRecords("10", "1");
} catch (Exception e) {
fail();
}
GroupIdRecord groupIdRecord = Utils.getGroupIdRecord();
try {
serviceDelegator.createGroupIdRecord(groupIdRecord);
} catch (Exception e) {
fail();
}
GroupIdRecordEntity toDelete = groupIdRecordDao.findByGroupId(groupIdRecord.getGroupId());
groupIdRecordDao.remove(toDelete.getId());
}
use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_GroupIdTest method testUpdateGroupIdRecord.
@Test
public void testUpdateGroupIdRecord() {
SecurityContextTestUtils.setUpSecurityContextForGroupIdClientOnly();
Response response = serviceDelegator.viewGroupIdRecord(Long.valueOf("3"));
assertNotNull(response);
GroupIdRecord groupIdRecord = (GroupIdRecord) response.getEntity();
assertNotNull(groupIdRecord);
Utils.verifyLastModified(groupIdRecord.getLastModifiedDate());
LastModifiedDate before = groupIdRecord.getLastModifiedDate();
// Verify the name
assertEquals(groupIdRecord.getName(), "TestGroup3");
// Set a new name for update
groupIdRecord.setName("TestGroup33");
serviceDelegator.updateGroupIdRecord(groupIdRecord, Long.valueOf("3"));
// Get the entity again and verify the name
response = serviceDelegator.viewGroupIdRecord(Long.valueOf("3"));
assertNotNull(response);
GroupIdRecord groupIdRecordNew = (GroupIdRecord) response.getEntity();
assertNotNull(groupIdRecordNew);
Utils.verifyLastModified(groupIdRecordNew.getLastModifiedDate());
assertTrue(groupIdRecordNew.getLastModifiedDate().after(before));
// Verify the name
assertEquals(groupIdRecordNew.getName(), "TestGroup33");
}
use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord in project ORCID-Source by ORCID.
the class PeerReviewsController method createPeerReviewIdList.
/**
* Create a funding id list and sorts a map associated with the list in in
* the session
*/
private List<String> createPeerReviewIdList(HttpServletRequest request) {
String orcid = getCurrentUserOrcid();
List<PeerReview> peerReviews = peerReviewManager.findPeerReviews(orcid);
Map<String, String> languages = lm.buildLanguageMap(getUserLocale(), false);
HashMap<Long, PeerReviewForm> peerReviewMap = new HashMap<>();
List<String> peerReviewIds = new ArrayList<String>();
if (peerReviews != null) {
for (PeerReview peerReview : peerReviews) {
try {
PeerReviewForm form = PeerReviewForm.valueOf(peerReview);
if (form.getExternalIdentifiers() != null && !form.getExternalIdentifiers().isEmpty()) {
for (WorkExternalIdentifier wExtId : form.getExternalIdentifiers()) {
if (PojoUtil.isEmpty(wExtId.getRelationship())) {
wExtId.setRelationship(Text.valueOf(Relationship.SELF.value()));
}
}
}
if (form.getTranslatedSubjectName() != null) {
// Set translated title language name
if (!(form.getTranslatedSubjectName() == null) && !StringUtils.isEmpty(form.getTranslatedSubjectName().getLanguageCode())) {
String languageName = languages.get(form.getTranslatedSubjectName().getLanguageCode());
form.getTranslatedSubjectName().setLanguageName(languageName);
}
}
form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, peerReview.getOrganization().getAddress().getCountry().name())));
// Set the numeric id (the table id in the group_id_record table) of the group id
if (form.getGroupId() != null && !PojoUtil.isEmpty(form.getGroupId().getValue())) {
GroupIdRecord groupId = groupIdRecordManager.findByGroupId(form.getGroupId().getValue()).get();
form.setGroupIdPutCode(Text.valueOf(groupId.getPutCode()));
}
peerReviewMap.put(peerReview.getPutCode(), form);
peerReviewIds.add(String.valueOf(peerReview.getPutCode()));
} catch (Exception e) {
LOGGER.error("Failed to parse as PeerReview. Put code" + peerReview.getPutCode(), e);
}
}
request.getSession().setAttribute(PEER_REVIEW_MAP, peerReviewMap);
}
return peerReviewIds;
}
use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getGroupIdRecordMapperFacade.
public MapperFacade getGroupIdRecordMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<GroupIdRecord, GroupIdRecordEntity> classMap = mapperFactory.classMap(GroupIdRecord.class, GroupIdRecordEntity.class);
addV3CommonFields(classMap);
registerSourceConverters(mapperFactory, classMap);
classMap.field("name", "groupName");
classMap.field("groupId", "groupId");
classMap.field("description", "groupDescription");
classMap.field("type", "groupType");
classMap.register();
return mapperFactory.getMapperFacade();
}
use of org.orcid.jaxb.model.v3.dev1.groupid.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