Search in sources :

Example 6 with DelegateForm

use of org.orcid.pojo.DelegateForm in project ORCID-Source by ORCID.

the class NotificationManagerImpl method extractAmenderName.

private String extractAmenderName(String userOrcid, String amenderId) {
    DelegateForm delegateForm = givenPermissionToManagerReadOnly.findByGiverAndReceiverOrcid(userOrcid, amenderId);
    if (delegateForm != null && !PojoUtil.isEmpty(delegateForm.getReceiverName())) {
        return delegateForm.getReceiverName().getValue();
    }
    ClientDetailsEntity clientDetailsEntity = clientDetailsEntityCacheManager.retrieve(amenderId);
    if (clientDetailsEntity != null) {
        return clientDetailsEntity.getClientName();
    }
    return "";
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) DelegateForm(org.orcid.pojo.DelegateForm)

Example 7 with DelegateForm

use of org.orcid.pojo.DelegateForm in project ORCID-Source by ORCID.

the class GivenPermissionToManagerReadOnlyImpl method findByGiverAndReceiverOrcid.

@Override
public DelegateForm findByGiverAndReceiverOrcid(String giverOrcid, String receiverOrcid) {
    GivenPermissionToEntity entity = givenPermissionToDaoReadOnly.findByGiverAndReceiverOrcid(giverOrcid, receiverOrcid);
    if (entity != null) {
        DelegateForm form = new DelegateForm();
        form.setApprovalDate(DateUtils.convertToXMLGregorianCalendar(entity.getApprovalDate()));
        form.setGiverOrcid(orcidIdentifierUtils.buildOrcidIdentifier(entity.getGiver()));
        form.setReceiverOrcid(orcidIdentifierUtils.buildOrcidIdentifier(entity.getReceiver().getId()));
        form.setReceiverName(Text.valueOf(entity.getReceiver().getDisplayName()));
        return form;
    }
    return null;
}
Also used : GivenPermissionToEntity(org.orcid.persistence.jpa.entities.GivenPermissionToEntity) DelegateForm(org.orcid.pojo.DelegateForm)

Example 8 with DelegateForm

use of org.orcid.pojo.DelegateForm in project ORCID-Source by ORCID.

the class ManageProfileController method getDelegates.

@RequestMapping(value = "/delegates.json", method = RequestMethod.GET)
@ResponseBody
public List<DelegateForm> getDelegates() {
    String currentOrcid = getCurrentUserOrcid();
    ProfileEntity currentProfile = profileEntityCacheManager.retrieve(currentOrcid);
    List<DelegateForm> list = new ArrayList<DelegateForm>();
    if (currentProfile.getGivenPermissionTo() != null && !currentProfile.getGivenPermissionTo().isEmpty()) {
        for (GivenPermissionToEntity entity : currentProfile.getGivenPermissionTo()) {
            DelegateForm form = new DelegateForm();
            form.setGiverOrcid(Text.valueOf(currentOrcid));
            form.setReceiverOrcid(Text.valueOf(entity.getReceiver().getId()));
            form.setReceiverName(Text.valueOf(entity.getReceiver().getDisplayName()));
            form.setApprovalDate(DateUtils.convertToXMLGregorianCalendar(entity.getApprovalDate()));
            list.add(form);
        }
    }
    return list;
}
Also used : GivenPermissionToEntity(org.orcid.persistence.jpa.entities.GivenPermissionToEntity) DelegateForm(org.orcid.pojo.DelegateForm) ArrayList(java.util.ArrayList) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 9 with DelegateForm

use of org.orcid.pojo.DelegateForm in project ORCID-Source by ORCID.

the class NotificationManagerImpl method extractAmenderName.

private String extractAmenderName(String userOrcid, String amenderId) {
    DelegateForm delegateForm = givenPermissionToManagerReadOnly.findByGiverAndReceiverOrcid(userOrcid, amenderId);
    if (delegateForm != null && !PojoUtil.isEmpty(delegateForm.getReceiverName())) {
        return delegateForm.getReceiverName().getValue();
    }
    ClientDetailsEntity clientDetailsEntity = clientDetailsEntityCacheManager.retrieve(amenderId);
    if (clientDetailsEntity != null) {
        return clientDetailsEntity.getClientName();
    }
    return "";
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) DelegateForm(org.orcid.pojo.DelegateForm)

Example 10 with DelegateForm

use of org.orcid.pojo.DelegateForm in project ORCID-Source by ORCID.

the class GivenPermissionToManagerReadOnlyImpl method findByReceiver.

@Override
@Cacheable(value = "delegates-by-receiver", key = "#receiverOrcid.concat('-').concat(#lastModified)")
public List<DelegateForm> findByReceiver(String receiverOrcid, long lastModified) {
    List<DelegateForm> delegates = new ArrayList<DelegateForm>();
    List<GivenPermissionByEntity> list = givenPermissionToDaoReadOnly.findByReceiver(receiverOrcid);
    for (GivenPermissionByEntity element : list) {
        DelegateForm form = new DelegateForm();
        form.setApprovalDate(DateUtils.convertToXMLGregorianCalendar(element.getApprovalDate()));
        form.setLastModifiedDate(DateUtils.convertToXMLGregorianCalendar(element.getGiver().getLastModified()));
        form.setGiverName(Text.valueOf(element.getGiver().getDisplayName()));
        form.setGiverOrcid(orcidIdentifierUtils.buildOrcidIdentifier(element.getGiver().getId()));
        form.setReceiverOrcid(orcidIdentifierUtils.buildOrcidIdentifier(element.getReceiver()));
        delegates.add(form);
    }
    return delegates;
}
Also used : DelegateForm(org.orcid.pojo.DelegateForm) ArrayList(java.util.ArrayList) GivenPermissionByEntity(org.orcid.persistence.jpa.entities.GivenPermissionByEntity) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

DelegateForm (org.orcid.pojo.DelegateForm)14 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)5 GivenPermissionToEntity (org.orcid.persistence.jpa.entities.GivenPermissionToEntity)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 Date (java.util.Date)3 BaseTest (org.orcid.core.BaseTest)3 HashMap (java.util.HashMap)2 Locale (java.util.Locale)2 Cacheable (org.springframework.cache.annotation.Cacheable)2 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 IntStream (java.util.stream.IntStream)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Assert.assertEquals (org.junit.Assert.assertEquals)1