Search in sources :

Example 1 with SnapshotSchema

use of org.apache.apex.malhar.lib.appdata.schemas.SnapshotSchema in project apex-malhar by apache.

the class DataQuerySnapshotValidator method validate.

@Override
public boolean validate(Message query, Object context) {
    DataQuerySnapshot gdqt = (DataQuerySnapshot) query;
    SnapshotSchema schema = (SnapshotSchema) ((SchemaRegistry) context).getSchema(gdqt.getSchemaKeys());
    Set<String> fields = schema.getValuesDescriptor().getFields().getFields();
    if (!fields.containsAll(gdqt.getFields().getFields())) {
        LOG.error("Some of the fields in the query {} are not one of the valid fields {}.", fields, gdqt.getFields().getFields());
        return false;
    }
    if (gdqt.getFields().getFields().isEmpty()) {
        gdqt.setFieldsVal(new Fields(fields));
    }
    return true;
}
Also used : Fields(org.apache.apex.malhar.lib.appdata.schemas.Fields) DataQuerySnapshot(org.apache.apex.malhar.lib.appdata.schemas.DataQuerySnapshot) SnapshotSchema(org.apache.apex.malhar.lib.appdata.schemas.SnapshotSchema)

Aggregations

DataQuerySnapshot (org.apache.apex.malhar.lib.appdata.schemas.DataQuerySnapshot)1 Fields (org.apache.apex.malhar.lib.appdata.schemas.Fields)1 SnapshotSchema (org.apache.apex.malhar.lib.appdata.schemas.SnapshotSchema)1