Search in sources :

Example 1 with SchemaParserAnnotationTransformer

use of com.thinkbiganalytics.discovery.rest.controller.SchemaParserAnnotationTransformer in project kylo by Teradata.

the class FileParserFactory method getSparkSchemaParserDescriptors.

/**
 * Returns the list of Schema Parsers transformed for the UI that support Spark
 * @return
 */
public List<SchemaParserDescriptor> getSparkSchemaParserDescriptors() {
    List<FileSchemaParser> parsers = FileParserFactory.instance().listSchemaParsers();
    SchemaParserAnnotationTransformer transformer = new SchemaParserAnnotationTransformer();
    List<SchemaParserDescriptor> list = parsers.stream().map(parser -> transformer.toUIModel(parser)).sorted(SchemaParserDescriptorUtil.compareByNameThenSpark()).collect(Collectors.toList());
    list = SchemaParserDescriptorUtil.keepFirstByName(list);
    return list;
}
Also used : SchemaParserAnnotationTransformer(com.thinkbiganalytics.discovery.rest.controller.SchemaParserAnnotationTransformer) FileSchemaParser(com.thinkbiganalytics.discovery.parser.FileSchemaParser) SchemaParserDescriptor(com.thinkbiganalytics.discovery.model.SchemaParserDescriptor)

Example 2 with SchemaParserAnnotationTransformer

use of com.thinkbiganalytics.discovery.rest.controller.SchemaParserAnnotationTransformer in project kylo by Teradata.

the class FileMetadataResultModifier method fileSchemaParser.

private Optional<FileSchemaParser> fileSchemaParser(SchemaParserDescriptor descriptor) {
    try {
        SchemaParserAnnotationTransformer transformer = new SchemaParserAnnotationTransformer();
        FileSchemaParser p = transformer.fromUiModel(descriptor);
        if (p instanceof SparkFileSchemaParser) {
            SparkFileSchemaParser sparkFileSchemaParser = (SparkFileSchemaParser) p;
            sparkFileSchemaParser.setDataFrameVariable("df");
            sparkFileSchemaParser.setLimit(-1);
        }
        return Optional.of(p);
    } catch (Exception e) {
        return Optional.empty();
    }
}
Also used : SparkFileSchemaParser(com.thinkbiganalytics.discovery.parser.SparkFileSchemaParser) SchemaParserAnnotationTransformer(com.thinkbiganalytics.discovery.rest.controller.SchemaParserAnnotationTransformer) SparkFileSchemaParser(com.thinkbiganalytics.discovery.parser.SparkFileSchemaParser) FileSchemaParser(com.thinkbiganalytics.discovery.parser.FileSchemaParser)

Example 3 with SchemaParserAnnotationTransformer

use of com.thinkbiganalytics.discovery.rest.controller.SchemaParserAnnotationTransformer in project kylo by Teradata.

the class FileMetadataTransformResponseModifier method fileSchemaParser.

private Optional<FileSchemaParser> fileSchemaParser(SchemaParserDescriptor descriptor) {
    try {
        SchemaParserAnnotationTransformer transformer = new SchemaParserAnnotationTransformer();
        FileSchemaParser p = transformer.fromUiModel(descriptor);
        if (p instanceof SparkFileSchemaParser) {
            SparkFileSchemaParser sparkFileSchemaParser = (SparkFileSchemaParser) p;
            sparkFileSchemaParser.setDataFrameVariable("df");
            sparkFileSchemaParser.setLimit(-1);
        }
        return Optional.of(p);
    } catch (Exception e) {
        return Optional.empty();
    }
}
Also used : SparkFileSchemaParser(com.thinkbiganalytics.discovery.parser.SparkFileSchemaParser) SchemaParserAnnotationTransformer(com.thinkbiganalytics.discovery.rest.controller.SchemaParserAnnotationTransformer) SparkFileSchemaParser(com.thinkbiganalytics.discovery.parser.SparkFileSchemaParser) FileSchemaParser(com.thinkbiganalytics.discovery.parser.FileSchemaParser)

Aggregations

FileSchemaParser (com.thinkbiganalytics.discovery.parser.FileSchemaParser)3 SchemaParserAnnotationTransformer (com.thinkbiganalytics.discovery.rest.controller.SchemaParserAnnotationTransformer)3 SparkFileSchemaParser (com.thinkbiganalytics.discovery.parser.SparkFileSchemaParser)2 SchemaParserDescriptor (com.thinkbiganalytics.discovery.model.SchemaParserDescriptor)1