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;
}
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;
}
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();
}
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);
}
Aggregations