Search in sources :

Example 1 with OrgId

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

the class SalesForceAdapterTest method testCreateSalesForceRecordFromOrgId.

@Test
public void testCreateSalesForceRecordFromOrgId() {
    OrgId contact = new OrgId();
    contact.setAccountId("1234");
    JSONObject contactJson = salesForceAdapter.createSaleForceRecordFromOrgId(contact);
    assertEquals("{\"Organization__c\":\"1234\"}", contactJson.toString());
}
Also used : OrgId(org.orcid.core.salesforce.model.OrgId) JSONObject(org.codehaus.jettison.json.JSONObject) Test(org.junit.Test)

Example 2 with OrgId

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

the class SalesForceManagerImpl method createOrgId.

@Override
public void createOrgId(OrgId orgId) {
    String accountId = orgId.getAccountId();
    List<OrgId> existingOrgIds = salesForceDao.retrieveOrgIdsByAccountId(accountId);
    Optional<OrgId> existingOrgId = existingOrgIds.stream().filter(o -> {
        if (orgId.getOrgIdType().equals(o.getOrgIdType()) && orgId.getOrgIdValue().equals(o.getOrgIdValue())) {
            return true;
        }
        return false;
    }).findFirst();
    if (!existingOrgId.isPresent()) {
        salesForceDao.createOrgId(orgId);
    }
    salesForceContactsCache.remove(accountId);
}
Also used : SalesForceManager(org.orcid.core.manager.SalesForceManager) SalesForceConnectionDao(org.orcid.persistence.dao.SalesForceConnectionDao) URL(java.net.URL) Date(java.util.Date) Member(org.orcid.core.salesforce.model.Member) GenericCacheManager(org.orcid.core.cache.GenericCacheManager) EmailManager(org.orcid.core.manager.EmailManager) ContactPermission(org.orcid.core.salesforce.model.ContactPermission) 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) ArrayList(java.util.ArrayList) 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) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) Opportunity(org.orcid.core.salesforce.model.Opportunity) SlugUtils(org.orcid.core.salesforce.model.SlugUtils) Collectors(java.util.stream.Collectors) ObjectUtils(org.apache.commons.lang.ObjectUtils) Objects(java.util.Objects) List(java.util.List) MemberDetails(org.orcid.core.salesforce.model.MemberDetails) OrcidString(org.orcid.core.cache.OrcidString) SourceManager(org.orcid.core.manager.SourceManager) Consortium(org.orcid.core.salesforce.model.Consortium) Optional(java.util.Optional) Contact(org.orcid.core.salesforce.model.Contact) OrgId(org.orcid.core.salesforce.model.OrgId) OpportunityContactRole(org.orcid.core.salesforce.model.OpportunityContactRole) Email(org.orcid.jaxb.model.record_v2.Email) Pattern(java.util.regex.Pattern) 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) OrgId(org.orcid.core.salesforce.model.OrgId) OrcidString(org.orcid.core.cache.OrcidString)

Example 3 with OrgId

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

the class SalesForceAdapterTest method testCreateOrgIdsFromJson.

@Test
public void testCreateOrgIdsFromJson() throws IOException, JSONException {
    String inputString = IOUtils.toString(getClass().getResourceAsStream("/org/orcid/core/salesforce/salesforce_org_ids_list.json"));
    JSONObject inputObject = new JSONObject(inputString);
    List<OrgId> orgIdsList = salesForceAdapter.createOrgIdsFromJson(inputObject);
    assertEquals(2, orgIdsList.size());
    OrgId orgId = orgIdsList.get(0);
    assertEquals("abcd", orgId.getOrgIdValue());
    assertEquals("FundRef ID", orgId.getOrgIdType());
    assertFalse(orgId.getInactive());
}
Also used : OrgId(org.orcid.core.salesforce.model.OrgId) JSONObject(org.codehaus.jettison.json.JSONObject) Test(org.junit.Test)

Example 4 with OrgId

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

the class SalesForceAdapterTest method testCreateOrgIdFromJson.

@Test
public void testCreateOrgIdFromJson() throws IOException, JSONException {
    String inputString = IOUtils.toString(getClass().getResourceAsStream("/org/orcid/core/salesforce/salesforce_org_ids_list.json"));
    JSONObject inputObject = new JSONObject(inputString);
    JSONArray records = inputObject.getJSONArray("records");
    JSONObject record = records.getJSONObject(0);
    OrgId orgId = salesForceAdapter.createOrgIdFromJson(record);
    assertEquals("abcd", orgId.getOrgIdValue());
    assertEquals("FundRef ID", orgId.getOrgIdType());
    assertFalse(orgId.getInactive());
}
Also used : OrgId(org.orcid.core.salesforce.model.OrgId) JSONObject(org.codehaus.jettison.json.JSONObject) JSONArray(org.codehaus.jettison.json.JSONArray) Test(org.junit.Test)

Aggregations

OrgId (org.orcid.core.salesforce.model.OrgId)4 JSONObject (org.codehaus.jettison.json.JSONObject)3 Test (org.junit.Test)3 URL (java.net.URL)1 ArrayList (java.util.ArrayList)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 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Resource (javax.annotation.Resource)1 SelfPopulatingCache (net.sf.ehcache.constructs.blocking.SelfPopulatingCache)1 ObjectUtils (org.apache.commons.lang.ObjectUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 GenericCacheManager (org.orcid.core.cache.GenericCacheManager)1