Search in sources :

Example 1 with GivenPermissionBy

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

use of org.orcid.jaxb.model.message.GivenPermissionBy 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)2 DelegationDetails (org.orcid.jaxb.model.message.DelegationDetails)2 GivenPermissionBy (org.orcid.jaxb.model.message.GivenPermissionBy)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 CreditName (org.orcid.jaxb.model.message.CreditName)1 Delegation (org.orcid.jaxb.model.message.Delegation)1 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)1