Search in sources :

Example 1 with GetFeatureTypeResponse

use of org.polymap.core.data.feature.GetFeatureTypeResponse in project polymap4-core by Polymap4.

the class FeatureRenameProcessor method featureTypeResponse.

@Produces(GetFeatureTypeResponse.class)
public void featureTypeResponse(GetFeatureTypeResponse response, ProcessorContext context) throws Exception {
    assert this.srcSchema == null;
    this.srcSchema = response.getFeatureType();
    SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    builder.init((SimpleFeatureType) srcSchema);
    builder.setName(name);
    schema = builder.buildFeatureType();
    context.sendResponse(new GetFeatureTypeResponse(schema));
}
Also used : SimpleFeatureTypeBuilder(org.geotools.feature.simple.SimpleFeatureTypeBuilder) GetFeatureTypeResponse(org.polymap.core.data.feature.GetFeatureTypeResponse) Produces(org.polymap.core.data.pipeline.Produces)

Example 2 with GetFeatureTypeResponse

use of org.polymap.core.data.feature.GetFeatureTypeResponse in project polymap4-core by Polymap4.

the class PipelineFeatureSource method buildFeatureType.

@Override
protected SimpleFeatureType buildFeatureType() throws IOException {
    // FIXME caching schema is not allowed since the pipeline and/or processors
    // may change; maybe we could add a listener API to the pipeline
    // avoid synchronize; doing this in parallel is ok
    GetFeatureTypeRequest request = new GetFeatureTypeRequest();
    try {
        final FeatureType[] type = new FeatureType[1];
        newExecutor().execute(pipeline, request, (ProcessorResponse r) -> {
            GetFeatureTypeResponse response = (GetFeatureTypeResponse) r;
            type[0] = response.getFeatureType();
        });
        return (SimpleFeatureType) type[0];
    } catch (Exception e) {
        Throwables.propagateIfInstanceOf(e, IOException.class);
        throw Throwables.propagate(e);
    }
}
Also used : SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) FeatureType(org.opengis.feature.type.FeatureType) ProcessorResponse(org.polymap.core.data.pipeline.ProcessorResponse) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) GetFeatureTypeRequest(org.polymap.core.data.feature.GetFeatureTypeRequest) GetFeatureTypeResponse(org.polymap.core.data.feature.GetFeatureTypeResponse) IOException(java.io.IOException) IOException(java.io.IOException)

Example 3 with GetFeatureTypeResponse

use of org.polymap.core.data.feature.GetFeatureTypeResponse in project polymap4-core by Polymap4.

the class FeatureRenameProcessor method featureTypeRequest.

@Produces(GetFeatureTypeRequest.class)
public void featureTypeRequest(GetFeatureTypeRequest request, ProcessorContext context) throws Exception {
    // and init target schema on response
    if (schema == null) {
        context.sendRequest(request);
    } else {
        context.sendResponse(new GetFeatureTypeResponse(schema));
        context.sendResponse(ProcessorResponse.EOP);
    }
}
Also used : GetFeatureTypeResponse(org.polymap.core.data.feature.GetFeatureTypeResponse) Produces(org.polymap.core.data.pipeline.Produces)

Aggregations

GetFeatureTypeResponse (org.polymap.core.data.feature.GetFeatureTypeResponse)3 Produces (org.polymap.core.data.pipeline.Produces)2 IOException (java.io.IOException)1 SimpleFeatureTypeBuilder (org.geotools.feature.simple.SimpleFeatureTypeBuilder)1 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)1 FeatureType (org.opengis.feature.type.FeatureType)1 GetFeatureTypeRequest (org.polymap.core.data.feature.GetFeatureTypeRequest)1 ProcessorResponse (org.polymap.core.data.pipeline.ProcessorResponse)1