Search in sources :

Example 1 with Integration

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

the class SalesForceAdapter method createIntegrationFromSalesForceRecord.

private Integration createIntegrationFromSalesForceRecord(JSONObject integrationRecord) throws JSONException {
    Integration integration = new Integration();
    String name = extractString(integrationRecord, "Name");
    integration.setName(name);
    integration.setDescription(extractString(integrationRecord, "Description__c"));
    integration.setStage(extractString(integrationRecord, "Integration_Stage__c"));
    try {
        integration.setResourceUrl(extractURL(integrationRecord, "Integration_URL__c"));
    } catch (MalformedURLException e) {
        LOGGER.info("Malformed resource URL for member: {}", name, e);
    }
    return integration;
}
Also used : Integration(org.orcid.core.salesforce.model.Integration) MalformedURLException(java.net.MalformedURLException) JsonUtils.extractString(org.orcid.core.utils.JsonUtils.extractString)

Example 2 with Integration

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

the class SalesForceAdapter method createIntegrationsListFromJson.

public List<Integration> createIntegrationsListFromJson(JSONObject results) {
    List<Integration> integrations = new ArrayList<>();
    try {
        JSONArray records = results.getJSONArray("records");
        if (records.length() > 0) {
            JSONObject firstRecord = records.getJSONObject(0);
            JSONObject integrationsObject = extractObject(firstRecord, "Integrations__r");
            if (integrationsObject != null) {
                JSONArray integrationRecords = integrationsObject.getJSONArray("records");
                for (int i = 0; i < integrationRecords.length(); i++) {
                    integrations.add(createIntegrationFromSalesForceRecord(integrationRecords.getJSONObject(i)));
                }
            }
        }
    } catch (JSONException e) {
        throw new RuntimeException("Error getting integrations records from SalesForce JSON", e);
    }
    return integrations;
}
Also used : Integration(org.orcid.core.salesforce.model.Integration) JSONObject(org.codehaus.jettison.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(org.codehaus.jettison.json.JSONArray) JSONException(org.codehaus.jettison.json.JSONException)

Aggregations

Integration (org.orcid.core.salesforce.model.Integration)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 JSONException (org.codehaus.jettison.json.JSONException)1 JSONObject (org.codehaus.jettison.json.JSONObject)1 JsonUtils.extractString (org.orcid.core.utils.JsonUtils.extractString)1