use of org.apache.apex.malhar.sql.table.MessageFormat in project apex-malhar by apache.
the class ApexSQLTableFactory method create.
@SuppressWarnings("unchecked")
@Override
public Table create(SchemaPlus schemaPlus, String name, Map<String, Object> operands, RelDataType rowType) {
Endpoint endpoint;
String endpointSystemType = (String) operands.get(Endpoint.ENDPOINT);
if (endpointSystemType.equalsIgnoreCase(Endpoint.EndpointType.FILE.name())) {
endpoint = new FileEndpoint();
} else if (endpointSystemType.equalsIgnoreCase(Endpoint.EndpointType.KAFKA.name())) {
endpoint = new KafkaEndpoint();
} else {
throw new RuntimeException("Cannot find endpoint");
}
endpoint.setEndpointOperands((Map<String, Object>) operands.get(Endpoint.SYSTEM_OPERANDS));
MessageFormat mf;
String messageFormat = (String) operands.get(MessageFormat.MESSAGE_FORMAT);
if (messageFormat.equalsIgnoreCase(MessageFormat.MessageFormatType.CSV.name())) {
mf = new CSVMessageFormat();
} else {
throw new RuntimeException("Cannot find message format");
}
mf.setMessageFormatOperands((Map<String, Object>) operands.get(MessageFormat.MESSAGE_FORMAT_OPERANDS));
endpoint.setMessageFormat(mf);
return new ApexSQLTable(schemaPlus, name, operands, rowType, endpoint);
}
Aggregations