use of org.orcid.pojo.DelegateForm in project ORCID-Source by ORCID.
the class GivenPermissionToManagerReadOnlyImpl method findByGiver.
@Override
@Cacheable(value = "delegates-by-giver", key = "#giverOrcid.concat('-').concat(#lastModified)")
public List<DelegateForm> findByGiver(String giverOrcid, long lastModified) {
List<DelegateForm> delegates = new ArrayList<DelegateForm>();
List<GivenPermissionToEntity> list = givenPermissionToDaoReadOnly.findByGiver(giverOrcid);
for (GivenPermissionToEntity element : list) {
DelegateForm form = new DelegateForm();
form.setApprovalDate(DateUtils.convertToXMLGregorianCalendar(element.getApprovalDate()));
form.setGiverOrcid(orcidIdentifierUtils.buildOrcidIdentifier(element.getGiver()));
form.setReceiverOrcid(orcidIdentifierUtils.buildOrcidIdentifier(element.getReceiver().getId()));
form.setReceiverName(Text.valueOf(element.getReceiver().getDisplayName()));
delegates.add(form);
}
return delegates;
}
use of org.orcid.pojo.DelegateForm in project ORCID-Source by ORCID.
the class ManageDelegatorsController method searchDelegators.
/**
* Search DB for disambiguated affiliations to suggest to user
*/
@RequestMapping(value = "/search/{query}", method = RequestMethod.GET)
@ResponseBody
public List<DelegateForm> searchDelegators(@PathVariable("query") String query, @RequestParam(value = "limit") int limit) {
Locale locale = getLocale();
query = query.toLowerCase(locale);
String realUserOrcid = getRealUserOrcid();
String currentOrcid = getEffectiveUserOrcid();
List<DelegateForm> delegates = givenPermissionToManagerReadOnly.findByReceiver(realUserOrcid, getLastModified(realUserOrcid));
List<DelegateForm> filtered = new ArrayList<DelegateForm>();
for (DelegateForm delegate : delegates) {
String name = delegate.getGiverName().getValue().toLowerCase(locale);
String orcidUri = delegate.getGiverOrcid().getUri();
String orcidPath = delegate.getGiverOrcid().getPath();
if ((name.contains(query) || orcidUri.contains(query)) && !(currentOrcid.equals(orcidPath))) {
filtered.add(delegate);
}
}
return filtered;
}
use of org.orcid.pojo.DelegateForm in project ORCID-Source by ORCID.
the class GivenPermissionToManagerTest method testFindByGiverAndReceiverOrcid.
@Test
public void testFindByGiverAndReceiverOrcid() {
DelegateForm form = givenPermissionToManagerReadOnly.findByGiverAndReceiverOrcid(GIVER, RECEIVER);
assertNotNull(form);
assertEquals(GIVER, form.getGiverOrcid().getPath());
assertEquals(RECEIVER, form.getReceiverOrcid().getPath());
}
use of org.orcid.pojo.DelegateForm in project ORCID-Source by ORCID.
the class GivenPermissionToManagerTest method testRemove.
@Test
public void testRemove() {
// Create one
givenPermissionToManager.create(RECEIVER, GIVER);
// Find it
DelegateForm form = givenPermissionToManagerReadOnly.findByGiverAndReceiverOrcid(RECEIVER, GIVER);
assertNotNull(form);
assertEquals(RECEIVER, form.getGiverOrcid().getPath());
assertEquals(GIVER, form.getReceiverOrcid().getPath());
Date rLastModifiedBefore = profileEntityManager.getLastModifiedDate(RECEIVER);
Date gLastModifiedBefore = profileEntityManager.getLastModifiedDate(GIVER);
// Delete it
givenPermissionToManager.remove(RECEIVER, GIVER);
// Verify it was deleted
form = givenPermissionToManagerReadOnly.findByGiverAndReceiverOrcid(RECEIVER, GIVER);
assertNull(form);
Date rLastModifiedAfter = profileEntityManager.getLastModifiedDate(RECEIVER);
Date gLastModifiedAfter = profileEntityManager.getLastModifiedDate(GIVER);
assertTrue(rLastModifiedAfter.after(rLastModifiedBefore));
assertTrue(gLastModifiedAfter.after(gLastModifiedBefore));
}
Aggregations