Search in sources :

Example 1 with ActivityRecord

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;
}
Also used : ArrayOfActivityRecord(com.marketo.mktows.ArrayOfActivityRecord) ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) Attribute(com.marketo.mktows.Attribute) SuccessGetLeadActivity(com.marketo.mktows.SuccessGetLeadActivity) StreamPosition(com.marketo.mktows.StreamPosition) ArrayOfActivityRecord(com.marketo.mktows.ArrayOfActivityRecord) ActivityRecord(com.marketo.mktows.ActivityRecord) LeadActivityList(com.marketo.mktows.LeadActivityList)

Example 2 with ActivityRecord

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;
}
Also used : Field(org.apache.avro.Schema.Field) IndexedRecord(org.apache.avro.generic.IndexedRecord) ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) Attribute(com.marketo.mktows.Attribute) ArrayList(java.util.ArrayList) ActivityRecord(com.marketo.mktows.ActivityRecord) Record(org.apache.avro.generic.GenericData.Record) ActivityRecord(com.marketo.mktows.ActivityRecord) LeadChangeRecord(com.marketo.mktows.LeadChangeRecord) ArrayOfLeadRecord(com.marketo.mktows.ArrayOfLeadRecord) IndexedRecord(org.apache.avro.generic.IndexedRecord) LeadRecord(com.marketo.mktows.LeadRecord) ArrayOfString(com.marketo.mktows.ArrayOfString)

Aggregations

ActivityRecord (com.marketo.mktows.ActivityRecord)2 ArrayOfAttribute (com.marketo.mktows.ArrayOfAttribute)2 Attribute (com.marketo.mktows.Attribute)2 ArrayOfActivityRecord (com.marketo.mktows.ArrayOfActivityRecord)1 ArrayOfLeadRecord (com.marketo.mktows.ArrayOfLeadRecord)1 ArrayOfString (com.marketo.mktows.ArrayOfString)1 LeadActivityList (com.marketo.mktows.LeadActivityList)1 LeadChangeRecord (com.marketo.mktows.LeadChangeRecord)1 LeadRecord (com.marketo.mktows.LeadRecord)1 StreamPosition (com.marketo.mktows.StreamPosition)1 SuccessGetLeadActivity (com.marketo.mktows.SuccessGetLeadActivity)1 ArrayList (java.util.ArrayList)1 Field (org.apache.avro.Schema.Field)1 Record (org.apache.avro.generic.GenericData.Record)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1