Search in sources :

Example 6 with MemberDetails

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

the class MemberDetailsCacheEntryFactory method createEntry.

@Override
public Object createEntry(Object key) throws Exception {
    MemberDetailsCacheKey detailsCacheKey = (MemberDetailsCacheKey) key;
    MemberDetails details = salesForceDao.retrieveDetails(detailsCacheKey.getMemberId(), detailsCacheKey.getConsotiumLeadId());
    return details;
}
Also used : MemberDetails(org.orcid.core.salesforce.model.MemberDetails)

Example 7 with MemberDetails

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

the class SalesForceDaoImpl method retrieveDetailsFromSalesForce.

/**
     * 
     * @throws SalesForceUnauthorizedException
     *             If the status code from SalesForce is 401, e.g. access token
     *             expired.
     * 
     */
private MemberDetails retrieveDetailsFromSalesForce(String accessToken, String memberId, String consortiumLeadId) throws SalesForceUnauthorizedException {
    MemberDetails details = new MemberDetails();
    String parentOrgName = retrieveParentOrgNameFromSalesForce(accessToken, consortiumLeadId);
    details.setParentOrgName(parentOrgName);
    details.setParentOrgSlug(SlugUtils.createSlug(consortiumLeadId, parentOrgName));
    details.setIntegrations(retrieveIntegrationsFromSalesForce(accessToken, memberId));
    return details;
}
Also used : MemberDetails(org.orcid.core.salesforce.model.MemberDetails)

Example 8 with MemberDetails

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

the class SalesForceManagerImpl method flagOpportunityAsClosed.

@Override
public void flagOpportunityAsClosed(String opportunityId) {
    String accountId = retrieveAccountIdByOrcid(sourceManager.retrieveRealUserOrcid());
    MemberDetails memberDetails = retrieveDetails(accountId);
    boolean authorized = memberDetails.getSubMembers().stream().anyMatch(s -> opportunityId.equals(s.getOpportunity().getId()));
    if (authorized) {
        Opportunity opportunity = new Opportunity();
        opportunity.setId(opportunityId);
        opportunity.setStageName(OPPORTUNITY_CLOSED_LOST);
        salesForceDao.updateOpportunity(opportunity);
    }
    // Need to make more granular!
    evictAll();
}
Also used : Opportunity(org.orcid.core.salesforce.model.Opportunity) MemberDetails(org.orcid.core.salesforce.model.MemberDetails)

Example 9 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) {
    List<Member> members = retrieveMembers();
    Optional<Member> match = members.stream().filter(e -> {
        String id = e.getId();
        String legacyId = id.substring(0, 15);
        return memberId.equalsIgnoreCase(id) || memberId.equals(legacyId);
    }).findFirst();
    if (match.isPresent()) {
        Member salesForceMember = match.get();
        MemberDetails details = (MemberDetails) salesForceMemberDetailsCache.get(new MemberDetailsCacheKey(memberId, salesForceMember.getConsortiumLeadId(), releaseName)).getObjectValue();
        details.setMember(salesForceMember);
        details.setSubMembers(findSubMembers(memberId));
        return details;
    }
    throw new IllegalArgumentException("No member details found for " + memberId);
}
Also used : SalesForceManager(org.orcid.core.manager.SalesForceManager) SalesForceConnectionDao(org.orcid.persistence.dao.SalesForceConnectionDao) Date(java.util.Date) Member(org.orcid.core.salesforce.model.Member) EmailManager(org.orcid.core.manager.EmailManager) DateUtils(org.orcid.utils.DateUtils) MemberDetailsCacheKey(org.orcid.core.salesforce.cache.MemberDetailsCacheKey) StringUtils(org.apache.commons.lang3.StringUtils) ManagerReadOnlyBaseImpl(org.orcid.core.manager.read_only.impl.ManagerReadOnlyBaseImpl) Calendar(java.util.Calendar) SalesForceConnectionEntity(org.orcid.persistence.jpa.entities.SalesForceConnectionEntity) Map(java.util.Map) ContactRole(org.orcid.core.salesforce.model.ContactRole) SelfPopulatingCache(net.sf.ehcache.constructs.blocking.SelfPopulatingCache) Collection(java.util.Collection) Resource(javax.annotation.Resource) Opportunity(org.orcid.core.salesforce.model.Opportunity) SlugUtils(org.orcid.core.salesforce.model.SlugUtils) Collectors(java.util.stream.Collectors) List(java.util.List) MemberDetails(org.orcid.core.salesforce.model.MemberDetails) SourceManager(org.orcid.core.manager.SourceManager) Consortium(org.orcid.core.salesforce.model.Consortium) Optional(java.util.Optional) Contact(org.orcid.core.salesforce.model.Contact) Email(org.orcid.jaxb.model.record_v2.Email) ContactRoleType(org.orcid.core.salesforce.model.ContactRoleType) SubMember(org.orcid.core.salesforce.model.SubMember) ReleaseNameUtils(org.orcid.utils.ReleaseNameUtils) Collections(java.util.Collections) SalesForceDao(org.orcid.core.salesforce.dao.SalesForceDao) 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)

Aggregations

MemberDetails (org.orcid.core.salesforce.model.MemberDetails)9 Member (org.orcid.core.salesforce.model.Member)4 SubMember (org.orcid.core.salesforce.model.SubMember)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 URL (java.net.URL)2 Contact (org.orcid.core.salesforce.model.Contact)2 Opportunity (org.orcid.core.salesforce.model.Opportunity)2 ConsortiumForm (org.orcid.pojo.ajaxForm.ConsortiumForm)2 MalformedURLException (java.net.MalformedURLException)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Resource (javax.annotation.Resource)1 SelfPopulatingCache (net.sf.ehcache.constructs.blocking.SelfPopulatingCache)1