Search in sources :

Example 1 with MemberDetails

use of org.orcid.core.salesforce.model.MemberDetails in project ORCID-Source by ORCID.

the class ManageConsortiumController method getConsortium.

@RequestMapping(value = "/get-consortium.json", method = RequestMethod.GET)
@ResponseBody
public ConsortiumForm getConsortium() {
    String accountId = salesForceManager.retrieveAccountIdByOrcid(getCurrentUserOrcid());
    MemberDetails memberDetails = salesForceManager.retrieveDetails(accountId);
    ConsortiumForm consortiumForm = ConsortiumForm.fromMemberDetails(memberDetails);
    return consortiumForm;
}
Also used : ConsortiumForm(org.orcid.pojo.ajaxForm.ConsortiumForm) MemberDetails(org.orcid.core.salesforce.model.MemberDetails) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with MemberDetails

use of org.orcid.core.salesforce.model.MemberDetails in project ORCID-Source by ORCID.

the class ResultContainer method findConsortium.

@RequestMapping(value = "/find-consortium.json", method = RequestMethod.GET)
@ResponseBody
public MemberDetailsForm findConsortium(@RequestParam("id") String id) {
    MemberDetails memberDetails = salesForceManager.retrieveFreshDetails(id);
    MemberDetailsForm consortiumForm = MemberDetailsForm.fromMemberDetails(memberDetails);
    List<Contact> contactsList = salesForceManager.retrieveFreshContactsByAccountId(id);
    salesForceManager.addOrcidsToContacts(contactsList);
    salesForceManager.addAccessInfoToContacts(contactsList, memberDetails.getMember().getId());
    consortiumForm.setContactsList(contactsList);
    consortiumForm.setRoleMap(generateSalesForceRoleMap());
    return consortiumForm;
}
Also used : MemberDetails(org.orcid.core.salesforce.model.MemberDetails) MemberDetailsForm(org.orcid.pojo.ajaxForm.MemberDetailsForm) Contact(org.orcid.core.salesforce.model.Contact) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with MemberDetails

use of org.orcid.core.salesforce.model.MemberDetails in project ORCID-Source by ORCID.

the class SelfServiceController method getConsortium.

@RequestMapping(value = "/get-member-details.json", method = RequestMethod.GET)
@ResponseBody
public MemberDetailsForm getConsortium(@RequestParam("accountId") String accountId) {
    checkAccess(accountId);
    MemberDetails memberDetails = salesForceManager.retrieveDetails(accountId);
    MemberDetailsForm consortiumForm = MemberDetailsForm.fromMemberDetails(memberDetails);
    consortiumForm.setAllowedFullAccess(isAllowedFullAccess(accountId));
    return consortiumForm;
}
Also used : MemberDetails(org.orcid.core.salesforce.model.MemberDetails) MemberDetailsForm(org.orcid.pojo.ajaxForm.MemberDetailsForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with MemberDetails

use of org.orcid.core.salesforce.model.MemberDetails in project ORCID-Source by ORCID.

the class SalesForceManagerImpl method retrieveDetails.

@Override
public MemberDetails retrieveDetails(String memberId, boolean publicOnly) {
    Member salesForceMember = retrieveMember(memberId);
    if (salesForceMember != null) {
        MemberDetails details = (MemberDetails) salesForceMemberDetailsCache.get(new MemberDetailsCacheKey(memberId, salesForceMember.getConsortiumLeadId(), releaseName)).getObjectValue();
        details.setMember(salesForceMember);
        List<SubMember> allSubMembers = findSubMembers(memberId);
        if (publicOnly) {
            details.setSubMembers(allSubMembers.stream().filter(m -> OPPORTUNITY_PUBLIC_STAGE_NAME.equals(m.getOpportunity().getStageName())).collect(Collectors.toList()));
        } else {
            details.setSubMembers(allSubMembers);
        }
        return details;
    }
    return null;
}
Also used : SubMember(org.orcid.core.salesforce.model.SubMember) MemberDetails(org.orcid.core.salesforce.model.MemberDetails) Member(org.orcid.core.salesforce.model.Member) SubMember(org.orcid.core.salesforce.model.SubMember) MemberDetailsCacheKey(org.orcid.core.salesforce.cache.MemberDetailsCacheKey)

Example 5 with MemberDetails

use of org.orcid.core.salesforce.model.MemberDetails in project ORCID-Source by ORCID.

the class ManageConsortiumController method updateConsortium.

@RequestMapping(value = "/update-consortium.json", method = RequestMethod.POST)
@ResponseBody
public ConsortiumForm updateConsortium(@RequestBody ConsortiumForm consortium) {
    MemberDetails memberDetails = consortium.toMemberDetails();
    String usersAuthorizedAccountId = salesForceManager.retrieveAccountIdByOrcid(getCurrentUserOrcid());
    Member member = memberDetails.getMember();
    if (!usersAuthorizedAccountId.equals(member.getId())) {
        throw new OrcidUnauthorizedException("You are not authorized for account ID = " + member.getId());
    }
    salesForceManager.updateMember(member);
    return consortium;
}
Also used : OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) MemberDetails(org.orcid.core.salesforce.model.MemberDetails) Member(org.orcid.core.salesforce.model.Member) SubMember(org.orcid.core.salesforce.model.SubMember) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

MemberDetails (org.orcid.core.salesforce.model.MemberDetails)15 Member (org.orcid.core.salesforce.model.Member)8 SubMember (org.orcid.core.salesforce.model.SubMember)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 URL (java.net.URL)4 OrcidUnauthorizedException (org.orcid.core.exception.OrcidUnauthorizedException)3 MemberDetailsCacheKey (org.orcid.core.salesforce.cache.MemberDetailsCacheKey)3 Contact (org.orcid.core.salesforce.model.Contact)3 Opportunity (org.orcid.core.salesforce.model.Opportunity)3 MalformedURLException (java.net.MalformedURLException)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Date (java.util.Date)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Resource (javax.annotation.Resource)2 SelfPopulatingCache (net.sf.ehcache.constructs.blocking.SelfPopulatingCache)2