Search in sources :

Example 1 with MessageFormat

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);
}
Also used : FileEndpoint(org.apache.apex.malhar.sql.table.FileEndpoint) KafkaEndpoint(org.apache.apex.malhar.sql.table.KafkaEndpoint) Endpoint(org.apache.apex.malhar.sql.table.Endpoint) MessageFormat(org.apache.apex.malhar.sql.table.MessageFormat) CSVMessageFormat(org.apache.apex.malhar.sql.table.CSVMessageFormat) CSVMessageFormat(org.apache.apex.malhar.sql.table.CSVMessageFormat) KafkaEndpoint(org.apache.apex.malhar.sql.table.KafkaEndpoint) FileEndpoint(org.apache.apex.malhar.sql.table.FileEndpoint)

Aggregations

CSVMessageFormat (org.apache.apex.malhar.sql.table.CSVMessageFormat)1 Endpoint (org.apache.apex.malhar.sql.table.Endpoint)1 FileEndpoint (org.apache.apex.malhar.sql.table.FileEndpoint)1 KafkaEndpoint (org.apache.apex.malhar.sql.table.KafkaEndpoint)1 MessageFormat (org.apache.apex.malhar.sql.table.MessageFormat)1