Search in sources :

Example 1 with LeadChangeRecord

use of com.marketo.mktows.LeadChangeRecord in project components by Talend.

the class MarketoSOAPClient method convertLeadChangeRecords.

private List<IndexedRecord> convertLeadChangeRecords(List<LeadChangeRecord> value, Schema schema, Map<String, String> mappings) {
    List<IndexedRecord> results = new ArrayList<>();
    for (LeadChangeRecord input : value) {
        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("[convertLeadChangeRecords] Couldn't find mapping for column {}.", f.name());
                continue;
            }
            switch(col) {
                case FIELD_ID:
                    record.put(f.pos(), input.getId().getValue());
                    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() != null ? input.getMktgAssetName().getValue() : null);
                    break;
                case FIELD_MKT_PERSON_ID:
                    record.put(f.pos(), input.getMktPersonId());
                    break;
                case FIELD_CAMPAIGN:
                    record.put(f.pos(), input.getCampaign());
                    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) 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) LeadChangeRecord(com.marketo.mktows.LeadChangeRecord)

Example 2 with LeadChangeRecord

use of com.marketo.mktows.LeadChangeRecord in project components by Talend.

the class MarketoSOAPClientTest method getLeadChangeResult.

public SuccessGetLeadChanges getLeadChangeResult() {
    SuccessGetLeadChanges result = new SuccessGetLeadChanges();
    ResultGetLeadChanges res = new ResultGetLeadChanges();
    res.setReturnCount(1);
    res.setRemainingCount(0);
    StreamPosition sp = new StreamPosition();
    sp.setOffset(objectFactory.createStreamPositionOffset(""));
    res.setNewStartPosition(sp);
    // 
    ArrayOfLeadChangeRecord lcr = new ArrayOfLeadChangeRecord();
    LeadChangeRecord lc = new LeadChangeRecord();
    lc.setId(objectFactory.createLeadChangeRecordId(123456L));
    lc.setMarketoGUID("ABC-123-DEF");
    lc.setMktgAssetName(objectFactory.createLeadChangeRecordMktgAssetName("mktgAssetName"));
    lc.setActivityDateTime(factory.newXMLGregorianCalendar(gcDateTest));
    lc.setActivityType("activityType");
    lc.setCampaign("campaign");
    lc.setMktPersonId("mktPersonId");
    ArrayOfAttribute aoa = objectFactory.createArrayOfAttribute();
    Attribute attr = new Attribute();
    attr.setAttrName("attrName");
    attr.setAttrValue("attrValue");
    aoa.getAttributes().add(attr);
    lc.setActivityAttributes(objectFactory.createActivityRecordActivityAttributes(aoa));
    lcr.getLeadChangeRecords().add(lc);
    // 
    res.setLeadChangeRecordList(objectFactory.createResultGetLeadChangesLeadChangeRecordList(lcr));
    result.setResult(res);
    return result;
}
Also used : ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) ArrayOfAttribute(com.marketo.mktows.ArrayOfAttribute) Attribute(com.marketo.mktows.Attribute) SuccessGetLeadChanges(com.marketo.mktows.SuccessGetLeadChanges) ResultGetLeadChanges(com.marketo.mktows.ResultGetLeadChanges) StreamPosition(com.marketo.mktows.StreamPosition) ArrayOfLeadChangeRecord(com.marketo.mktows.ArrayOfLeadChangeRecord) ArrayOfLeadChangeRecord(com.marketo.mktows.ArrayOfLeadChangeRecord) LeadChangeRecord(com.marketo.mktows.LeadChangeRecord)

Aggregations

ArrayOfAttribute (com.marketo.mktows.ArrayOfAttribute)2 Attribute (com.marketo.mktows.Attribute)2 LeadChangeRecord (com.marketo.mktows.LeadChangeRecord)2 ActivityRecord (com.marketo.mktows.ActivityRecord)1 ArrayOfLeadChangeRecord (com.marketo.mktows.ArrayOfLeadChangeRecord)1 ArrayOfLeadRecord (com.marketo.mktows.ArrayOfLeadRecord)1 ArrayOfString (com.marketo.mktows.ArrayOfString)1 LeadRecord (com.marketo.mktows.LeadRecord)1 ResultGetLeadChanges (com.marketo.mktows.ResultGetLeadChanges)1 StreamPosition (com.marketo.mktows.StreamPosition)1 SuccessGetLeadChanges (com.marketo.mktows.SuccessGetLeadChanges)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