Search in sources :

Example 1 with DelegateSummary

use of org.orcid.jaxb.model.message.DelegateSummary 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 2 with DelegateSummary

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

the class ManageDelegatorsController method getDelegatorsPlusMeJson.

@RequestMapping(value = "/delegators-and-me.json", method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> getDelegatorsPlusMeJson() throws NoSuchRequestHandlingMethodException {
    Map<String, Object> map = new HashMap<>();
    OrcidProfile realProfile = getRealProfile();
    Delegation delegation = realProfile.getOrcidBio().getDelegation();
    if (delegation != null) {
        GivenPermissionBy givenPermissionBy = delegation.getGivenPermissionBy();
        String currentOrcid = getEffectiveUserOrcid();
        if (givenPermissionBy != null) {
            for (Iterator<DelegationDetails> delegationDetailsIterator = givenPermissionBy.getDelegationDetails().iterator(); delegationDetailsIterator.hasNext(); ) {
                if (currentOrcid.equals(delegationDetailsIterator.next().getDelegateSummary().getOrcidIdentifier().getPath())) {
                    delegationDetailsIterator.remove();
                }
            }
        }
        map.put("delegators", givenPermissionBy);
    }
    if (sourceManager.isInDelegationMode()) {
        // Add me, so I can switch back to me
        DelegationDetails details = new DelegationDetails();
        DelegateSummary summary = new DelegateSummary();
        details.setDelegateSummary(summary);
        String displayName = realProfile.getOrcidBio().getPersonalDetails().retrieveDisplayNameIgnoringVisibility();
        summary.setCreditName(new CreditName(displayName));
        summary.setOrcidIdentifier(realProfile.getOrcidIdentifier());
        map.put("me", details);
    }
    return map;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) GivenPermissionBy(org.orcid.jaxb.model.message.GivenPermissionBy) DelegateSummary(org.orcid.jaxb.model.message.DelegateSummary) HashMap(java.util.HashMap) CreditName(org.orcid.jaxb.model.message.CreditName) DelegationDetails(org.orcid.jaxb.model.message.DelegationDetails) Delegation(org.orcid.jaxb.model.message.Delegation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with DelegateSummary

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

the class ManageDelegatorsController method searchDelegatorsForData.

/**
     * Search delegators to suggest to user
     */
@RequestMapping(value = "/search-for-data/{query}", method = RequestMethod.GET)
@ResponseBody
public List<Map<String, Object>> searchDelegatorsForData(@PathVariable("query") String query, @RequestParam(value = "limit") int limit) {
    List<Map<String, Object>> datums = new ArrayList<>();
    Locale locale = getLocale();
    query = query.toLowerCase(locale);
    for (DelegationDetails delegationDetails : getRealProfile().getOrcidBio().getDelegation().getGivenPermissionBy().getDelegationDetails()) {
        DelegateSummary delegateSummary = delegationDetails.getDelegateSummary();
        String creditName = delegateSummary.getCreditName().getContent().toLowerCase(locale);
        String orcid = delegateSummary.getOrcidIdentifier().getUri();
        if (creditName.contains(query) || orcid.contains(query)) {
            Map<String, Object> datum = createDatumFromOrgDisambiguated(delegationDetails);
            datums.add(datum);
        }
    }
    if (datums.isEmpty()) {
        Map<String, Object> map = new HashMap<>();
        map.put("noResults", true);
        datums.add(map);
    }
    return datums;
}
Also used : Locale(java.util.Locale) DelegateSummary(org.orcid.jaxb.model.message.DelegateSummary) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DelegationDetails(org.orcid.jaxb.model.message.DelegationDetails) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with DelegateSummary

use of org.orcid.jaxb.model.message.DelegateSummary 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 5 with DelegateSummary

use of org.orcid.jaxb.model.message.DelegateSummary 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 GivenPermissionBy searchDelegators(@PathVariable("query") String query, @RequestParam(value = "limit") int limit) {
    Locale locale = getLocale();
    query = query.toLowerCase(locale);
    GivenPermissionBy result = new GivenPermissionBy();
    String currentOrcid = getEffectiveUserOrcid();
    for (DelegationDetails delegationDetails : getRealProfile().getOrcidBio().getDelegation().getGivenPermissionBy().getDelegationDetails()) {
        DelegateSummary delegateSummary = delegationDetails.getDelegateSummary();
        String creditName = delegateSummary.getCreditName().getContent().toLowerCase(locale);
        String orcidUri = delegateSummary.getOrcidIdentifier().getUri();
        String orcidPath = delegateSummary.getOrcidIdentifier().getPath();
        if (creditName.contains(query) || orcidUri.contains(query) && !(currentOrcid.equals(orcidPath))) {
            result.getDelegationDetails().add(delegationDetails);
        }
    }
    return result;
}
Also used : Locale(java.util.Locale) GivenPermissionBy(org.orcid.jaxb.model.message.GivenPermissionBy) DelegateSummary(org.orcid.jaxb.model.message.DelegateSummary) DelegationDetails(org.orcid.jaxb.model.message.DelegationDetails) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

DelegateSummary (org.orcid.jaxb.model.message.DelegateSummary)6 DelegationDetails (org.orcid.jaxb.model.message.DelegationDetails)6 Delegation (org.orcid.jaxb.model.message.Delegation)3 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)3 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 HashMap (java.util.HashMap)2 Locale (java.util.Locale)2 Test (org.junit.Test)2 CreditName (org.orcid.jaxb.model.message.CreditName)2 GivenPermissionBy (org.orcid.jaxb.model.message.GivenPermissionBy)2 GivenPermissionTo (org.orcid.jaxb.model.message.GivenPermissionTo)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 ApprovalDate (org.orcid.jaxb.model.message.ApprovalDate)1 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)1