Search in sources :

Example 1 with Delegation

use of org.orcid.jaxb.model.message.Delegation in project ORCID-Source by ORCID.

the class AddDelegateForm method getOrcidProfile.

public OrcidProfile getOrcidProfile(String orcid) {
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier(orcid);
    OrcidBio orcidBio = new OrcidBio();
    orcidProfile.setOrcidBio(orcidBio);
    Delegation delegation = new Delegation();
    orcidBio.setDelegation(delegation);
    GivenPermissionTo givenPermissionTo = new GivenPermissionTo();
    delegation.setGivenPermissionTo(givenPermissionTo);
    DelegationDetails delegationDetails = new DelegationDetails();
    givenPermissionTo.getDelegationDetails().add(delegationDetails);
    DelegateSummary delegateSummary = new DelegateSummary(new OrcidIdentifier(delegateOrcid));
    delegationDetails.setDelegateSummary(delegateSummary);
    return orcidProfile;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) GivenPermissionTo(org.orcid.jaxb.model.message.GivenPermissionTo) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) DelegateSummary(org.orcid.jaxb.model.message.DelegateSummary) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) DelegationDetails(org.orcid.jaxb.model.message.DelegationDetails) Delegation(org.orcid.jaxb.model.message.Delegation)

Example 2 with Delegation

use of org.orcid.jaxb.model.message.Delegation in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method testRevokeDelegate.

@Test
@Transactional
@Rollback(true)
public void testRevokeDelegate() {
    OrcidProfile profile1 = createBasicProfile();
    Delegation delegation = new Delegation();
    profile1.getOrcidBio().setDelegation(delegation);
    GivenPermissionTo givenPermissionTo = new GivenPermissionTo();
    delegation.setGivenPermissionTo(givenPermissionTo);
    DelegationDetails delegationDetails = new DelegationDetails();
    delegationDetails.setApprovalDate(new ApprovalDate(DateUtils.convertToXMLGregorianCalendar("2011-03-14T02:34:16")));
    DelegateSummary profileSummary = new DelegateSummary(new OrcidIdentifier(DELEGATE_ORCID));
    delegationDetails.setDelegateSummary(profileSummary);
    givenPermissionTo.getDelegationDetails().add(delegationDetails);
    orcidProfileManager.createOrcidProfile(profile1, false, false);
    orcidProfileManager.revokeDelegate(TEST_ORCID, DELEGATE_ORCID);
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    assertNull(retrievedProfile.getOrcidBio().getDelegation());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) GivenPermissionTo(org.orcid.jaxb.model.message.GivenPermissionTo) DelegateSummary(org.orcid.jaxb.model.message.DelegateSummary) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) DelegationDetails(org.orcid.jaxb.model.message.DelegationDetails) Delegation(org.orcid.jaxb.model.message.Delegation) ApprovalDate(org.orcid.jaxb.model.message.ApprovalDate) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Delegation

use of org.orcid.jaxb.model.message.Delegation in project ORCID-Source by ORCID.

the class ManageDelegatorsController method getDelegatesJson.

@RequestMapping(value = "/delegation.json", method = RequestMethod.GET)
@ResponseBody
public Delegation getDelegatesJson() throws NoSuchRequestHandlingMethodException {
    OrcidProfile realProfile = getRealProfile();
    Delegation delegation = realProfile.getOrcidBio().getDelegation();
    return delegation;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Delegation(org.orcid.jaxb.model.message.Delegation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with Delegation

use of org.orcid.jaxb.model.message.Delegation in project ORCID-Source by ORCID.

the class NotificationManagerImpl method extractAmenderName.

private String extractAmenderName(OrcidProfile orcidProfile, String amenderId) {
    Delegation delegation = orcidProfile.getOrcidBio().getDelegation();
    if (delegation != null && delegation.getGivenPermissionTo() != null && !delegation.getGivenPermissionTo().getDelegationDetails().isEmpty()) {
        for (DelegationDetails delegationDetails : delegation.getGivenPermissionTo().getDelegationDetails()) {
            if (amenderId.equals(delegationDetails.getDelegateSummary().getOrcidIdentifier().getPath())) {
                return delegationDetails.getDelegateSummary().getCreditName().getContent();
            }
        }
    }
    ClientDetailsEntity clientDetailsEntity = clientDetailsEntityCacheManager.retrieve(amenderId);
    if (clientDetailsEntity != null) {
        return clientDetailsEntity.getClientName();
    }
    return "";
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) DelegationDetails(org.orcid.jaxb.model.message.DelegationDetails) Delegation(org.orcid.jaxb.model.message.Delegation)

Aggregations

Delegation (org.orcid.jaxb.model.message.Delegation)4 DelegationDetails (org.orcid.jaxb.model.message.DelegationDetails)3 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)3 DelegateSummary (org.orcid.jaxb.model.message.DelegateSummary)2 GivenPermissionTo (org.orcid.jaxb.model.message.GivenPermissionTo)2 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)2 Test (org.junit.Test)1 ApprovalDate (org.orcid.jaxb.model.message.ApprovalDate)1 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)1 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)1 Rollback (org.springframework.test.annotation.Rollback)1 Transactional (org.springframework.transaction.annotation.Transactional)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1