use of org.apache.avro.generic.GenericData.Record in project components by Talend.
the class TableHelper method getRecord.
public static Record getRecord(int i) {
Record record = new GenericData.Record(getWriteSchema());
record.put("PartitionKey", "partition" + (i % 1000));
record.put("RowKey", "row" + i);
record.put("stringCol", "stringCol" + i);
record.put("booleanColTrue", true);
record.put("booleanColFalse", false);
record.put("doubleCol", 2.0d);
record.put("longCol", 3l);
record.put("integerCol", i);
record.put("byteCol", "imBytes".getBytes());
record.put("dateCol", new Date());
return record;
}
use of org.apache.avro.generic.GenericData.Record in project components by Talend.
the class GoogleDriveGetReader method start.
@Override
public boolean start() throws IOException {
super.start();
//
String resourceId = properties.fileAccessMethod.getValue().equals(AccessMethod.Id) ? properties.file.getValue() : utils.getFileId(properties.file.getValue());
Map<String, MimeType> mimes = GoogleDriveMimeTypes.newDefaultMimeTypesSupported();
mimes.put(MIME_TYPE_GOOGLE_DOCUMENT, properties.exportDocument.getValue());
mimes.put(MIME_TYPE_GOOGLE_DRAWING, properties.exportDrawing.getValue());
mimes.put(MIME_TYPE_GOOGLE_PRESENTATION, properties.exportPresentation.getValue());
mimes.put(MIME_TYPE_GOOGLE_SPREADSHEET, properties.exportSpreadsheet.getValue());
GoogleDriveGetParameters p = new GoogleDriveGetParameters(resourceId, mimes, properties.storeToLocal.getValue(), properties.outputFileName.getValue(), properties.setOutputExt.getValue());
//
GoogleDriveGetResult r = utils.getResource(p);
fileId = r.getId();
byte[] content = r.getContent();
record = new Record(properties.schemaMain.schema.getValue());
record.put(0, content);
result.totalCount++;
result.successCount++;
return true;
}
use of org.apache.avro.generic.GenericData.Record in project components by Talend.
the class MarketoLeadClient method convertLeadActivityRecords.
public List<IndexedRecord> convertLeadActivityRecords(List<LeadActivityRecord> recordList, Schema schema, Map<String, String> mappings) {
List<IndexedRecord> results = new ArrayList<>();
for (LeadActivityRecord input : recordList) {
IndexedRecord record = new Record(schema);
for (Field f : schema.getFields()) {
String col = mappings.get(f.name());
switch(col) {
case FIELD_ID:
record.put(f.pos(), input.getId());
break;
case FIELD_MARKETO_GUID:
record.put(f.pos(), input.getMarketoGUID());
break;
case FIELD_LEAD_ID:
record.put(f.pos(), input.getLeadId());
break;
case FIELD_ACTIVITY_DATE:
record.put(f.pos(), input.getActivityDate().getTime());
break;
case FIELD_ACTIVITY_TYPE_ID:
record.put(f.pos(), input.getActivityTypeId());
break;
case FIELD_ACTIVITY_TYPE_VALUE:
record.put(f.pos(), getActivityTypeNameById(input.getActivityTypeId()));
break;
case FIELD_PRIMARY_ATTRIBUTE_VALUE_ID:
record.put(f.pos(), input.getPrimaryAttributeValueId());
break;
case FIELD_PRIMARY_ATTRIBUTE_VALUE:
record.put(f.pos(), input.getPrimaryAttributeValue());
break;
case FIELD_CAMPAIGN_ID:
record.put(f.pos(), input.getCampaignId());
break;
default:
String attr = input.getMktoAttributes().get(col);
if (attr != null) {
record.put(f.pos(), attr);
}
}
}
results.add(record);
}
return results;
}
use of org.apache.avro.generic.GenericData.Record in project components by Talend.
the class MarketoLeadClient method convertLeadRecords.
public List<IndexedRecord> convertLeadRecords(List<Map<String, String>> records, Schema schema, Map<String, String> mappings) {
List<IndexedRecord> results = new ArrayList<>();
for (Map<String, String> input : records) {
IndexedRecord record = new Record(schema);
for (Field f : schema.getFields()) {
String col = mappings.get(f.name());
Object tmp = input.get(col);
if (col != null) {
record.put(f.pos(), getValueType(f, tmp));
}
}
results.add(record);
}
return results;
}
use of org.apache.avro.generic.GenericData.Record in project components by Talend.
the class MarketoLeadClient method convertLeadChangesRecords.
public List<IndexedRecord> convertLeadChangesRecords(List<LeadChangeRecord> recordList, Schema schema, Map<String, String> mappings) {
List<IndexedRecord> results = new ArrayList<>();
Gson gson = new Gson();
for (LeadChangeRecord input : recordList) {
IndexedRecord record = new Record(schema);
for (Field f : schema.getFields()) {
String col = mappings.get(f.name());
switch(col) {
case FIELD_ID:
record.put(f.pos(), input.getId());
break;
case FIELD_MARKETO_GUID:
record.put(f.pos(), input.getMarketoGUID());
break;
case FIELD_LEAD_ID:
record.put(f.pos(), input.getLeadId());
break;
case FIELD_ACTIVITY_DATE:
record.put(f.pos(), input.getActivityDate().getTime());
break;
case FIELD_ACTIVITY_TYPE_ID:
record.put(f.pos(), input.getActivityTypeId());
break;
case FIELD_ACTIVITY_TYPE_VALUE:
record.put(f.pos(), getActivityTypeNameById(input.getActivityTypeId()));
break;
case FIELD_FIELDS:
record.put(f.pos(), gson.toJson(input.getFields()));
break;
case FIELD_CAMPAIGN_ID:
record.put(f.pos(), input.getCampaignId());
break;
default:
String attr = input.getMktoAttributes().get(col);
if (attr != null) {
record.put(f.pos(), attr);
}
}
}
results.add(record);
}
return results;
}
Aggregations