use of org.orcid.core.salesforce.model.Consortium in project ORCID-Source by ORCID.
the class GetConsortiumFromSalesForceById method main.
@SuppressWarnings("resource")
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("orcid-core-context.xml");
SalesForceManager salesForceManager = (SalesForceManager) context.getBean("salesForceManager");
Consortium consortium = salesForceManager.retrieveConsortium(args[0]);
System.out.println(consortium);
System.exit(0);
}
use of org.orcid.core.salesforce.model.Consortium in project ORCID-Source by ORCID.
the class SalesForceAdapter method createConsortiumFromJson.
public Consortium createConsortiumFromJson(JSONObject results) {
try {
int numFound = JsonUtils.extractInt(results, "totalSize");
if (numFound == 0) {
return null;
}
Consortium consortium = new Consortium();
List<Opportunity> opportunityList = new ArrayList<>();
consortium.setOpportunities(opportunityList);
JSONArray records = results.getJSONArray("records");
JSONObject firstRecord = records.getJSONObject(0);
JSONObject opportunities = extractObject(firstRecord, "ConsortiaOpportunities__r");
if (opportunities != null) {
JSONArray opportunityRecords = opportunities.getJSONArray("records");
for (int i = 0; i < opportunityRecords.length(); i++) {
Opportunity salesForceOpportunity = new Opportunity();
JSONObject opportunity = opportunityRecords.getJSONObject(i);
salesForceOpportunity.setId(extractOpportunityId(opportunity));
JSONObject account = extractObject(opportunity, "Account");
salesForceOpportunity.setTargetAccountId(extractAccountId(account));
// salesForceOpportunity.setAccountName(JsonUtils.extractString(account,
// "Name"));
salesForceOpportunity.setAccountName(JsonUtils.extractString(account, "Public_Display_Name__c"));
opportunityList.add(salesForceOpportunity);
}
return consortium;
}
} catch (JSONException e) {
throw new RuntimeException("Error getting consortium record from SalesForce JSON", e);
}
return null;
}
Aggregations