Search in sources :

Example 1 with ComponentProperties

use of org.talend.dataprep.parameters.jsonschema.ComponentProperties in project data-prep by Talend.

the class DataSetService method getDataStoreParameters.

@RequestMapping(value = "/datasets/{id}/datastore/properties", method = GET)
@ApiOperation(value = "Get the dataset import parameters", notes = "This list can be used by user to change dataset encoding.")
@Timed
public // ComponentProperties
Object getDataStoreParameters(@PathVariable("id") final String dataSetId) {
    DataSetMetadata dataSetMetadata = dataSetMetadataRepository.get(dataSetId);
    Object parametersToReturn = null;
    if (dataSetMetadata != null) {
        DataSetLocation matchingDatasetLocation = locationsService.findLocation(dataSetMetadata.getLocation().getLocationType());
        if (matchingDatasetLocation == null) {
            parametersToReturn = emptyList();
        } else {
            if (matchingDatasetLocation.isSchemaOriented()) {
                ComponentProperties parametersAsSchema = matchingDatasetLocation.getParametersAsSchema(getLocale());
                parametersAsSchema.setProperties(dataSetMetadata.getLocation().getParametersAsSchema(getLocale()).getProperties());
                parametersToReturn = parametersAsSchema;
            } else {
                parametersToReturn = matchingDatasetLocation.getParameters(getLocale());
            }
        }
    }
    return parametersToReturn;
}
Also used : DataSetLocation(org.talend.dataprep.api.dataset.DataSetLocation) ComponentProperties(org.talend.dataprep.parameters.jsonschema.ComponentProperties) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Timed(org.talend.dataprep.metrics.Timed) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 DataSetLocation (org.talend.dataprep.api.dataset.DataSetLocation)1 DataSetMetadata (org.talend.dataprep.api.dataset.DataSetMetadata)1 Timed (org.talend.dataprep.metrics.Timed)1 ComponentProperties (org.talend.dataprep.parameters.jsonschema.ComponentProperties)1