use of com.marketo.mktows.ActivityRecord in project components by Talend.
the class MarketoSOAPClientTest method getLeadActivityResult.
public SuccessGetLeadActivity getLeadActivityResult() throws Exception {
SuccessGetLeadActivity result = new SuccessGetLeadActivity();
LeadActivityList res = new LeadActivityList();
res.setReturnCount(1);
res.setRemainingCount(0);
StreamPosition sp = new StreamPosition();
sp.setOffset(objectFactory.createStreamPositionOffset(""));
res.setNewStartPosition(sp);
ArrayOfActivityRecord arecords = new ArrayOfActivityRecord();
//
ActivityRecord ar = new ActivityRecord();
ar.setId(objectFactory.createActivityRecordId(123456L));
ar.setMarketoGUID("ABC-123-DEF");
ar.setMktgAssetName("mktgAssetName");
ar.setActivityDateTime(factory.newXMLGregorianCalendar(gcDateTest));
ar.setActivityType("activityType");
ar.setCampaign(objectFactory.createActivityRecordCampaign("campaign"));
ar.setForeignSysId(objectFactory.createActivityRecordForeignSysId("foreignSysId"));
ar.setForeignSysOrgId(objectFactory.createActivityRecordForeignSysOrgId("foreignSysOrgId"));
ar.setMktPersonId("mktPersonId");
ar.setPersonName(objectFactory.createActivityRecordPersonName("personName"));
ar.setOrgName(objectFactory.createActivityRecordOrgName("orgName"));
ArrayOfAttribute aoa = objectFactory.createArrayOfAttribute();
Attribute attr = new Attribute();
attr.setAttrName("attrName");
attr.setAttrValue("attrValue");
aoa.getAttributes().add(attr);
ar.setActivityAttributes(objectFactory.createActivityRecordActivityAttributes(aoa));
//
arecords.getActivityRecords().add(ar);
res.setActivityRecordList(objectFactory.createLeadActivityListActivityRecordList(arecords));
result.setLeadActivityList(res);
return result;
}
use of com.marketo.mktows.ActivityRecord in project components by Talend.
the class MarketoSOAPClient method convertLeadActivityRecords.
private List<IndexedRecord> convertLeadActivityRecords(List<ActivityRecord> activityRecords, Schema schema, Map<String, String> mappings) {
List<IndexedRecord> results = new ArrayList<>();
for (ActivityRecord input : activityRecords) {
IndexedRecord record = new Record(schema);
for (Field f : schema.getFields()) {
// find matching marketo column name
String col = mappings.get(f.name());
if (col == null) {
LOG.warn("[convertLeadActivityRecords] Couldn't find mapping for column {}.", f.name());
continue;
}
switch(col) {
case FIELD_ID:
record.put(f.pos(), input.getId() != null ? input.getId().getValue() : null);
break;
case FIELD_MARKETO_GUID:
record.put(f.pos(), input.getMarketoGUID());
break;
case FIELD_ACTIVITY_DATE_TIME:
record.put(f.pos(), input.getActivityDateTime() != null ? input.getActivityDateTime().toGregorianCalendar().getTimeInMillis() : null);
break;
case FIELD_ACTIVITY_TYPE:
record.put(f.pos(), input.getActivityType());
break;
case FIELD_MKTG_ASSET_NAME:
record.put(f.pos(), input.getMktgAssetName());
break;
case FIELD_MKT_PERSON_ID:
record.put(f.pos(), input.getMktPersonId());
break;
case FIELD_CAMPAIGN:
record.put(f.pos(), input.getCampaign() != null ? input.getCampaign().getValue() : null);
break;
case FIELD_FOREIGN_SYS_ID:
record.put(f.pos(), input.getForeignSysId() != null ? input.getForeignSysId().getValue() : null);
break;
case FIELD_PERSON_NAME:
record.put(f.pos(), input.getPersonName() != null ? input.getPersonName().getValue() : null);
break;
case FIELD_ORG_NAME:
record.put(f.pos(), input.getOrgName() != null ? input.getOrgName().getValue() : null);
break;
case FIELD_FOREIGN_SYS_ORG_ID:
record.put(f.pos(), input.getForeignSysOrgId() != null ? input.getForeignSysOrgId().getValue() : null);
break;
default:
if (!input.getActivityAttributes().isNil()) {
for (Attribute attr : input.getActivityAttributes().getValue().getAttributes()) {
if (attr.getAttrName().equals(col)) {
record.put(f.pos(), attr.getAttrValue());
}
}
}
}
}
results.add(record);
}
return results;
}
Aggregations