semanticwfs  Version 0.1.0.0
WebService Class Reference

Implements OGC API Features and WFS webservice functionality. More...

Collaboration diagram for WebService:

Public Member Functions

 WebService () throws IOException
 Constructor for this class. More...
 
Response openapiJSON ()
 
Response openapiYAML ()
 
void generateOpenAPIDefinitions ()
 Generates OpenAPI definitions of the SemanticWFS services for the use with OGC API Features. More...
 
Response createExceptionResponse (Exception e, String format)
 Generates an exception response. More...
 
Response entryPointPOST ( @Parameter(description="Service type definition") @DefaultValue("WFS") @QueryParam("SERVICE") String service, @Parameter(description="Request definition") @DefaultValue("GetCapabilities") @QueryParam("REQUEST") String request, @Parameter(description="Version of the web service") @DefaultValue("2.0.0") @QueryParam("VERSION") String version, @Parameter(description="The feature type name to be queried") @DefaultValue("") @QueryParam("TYPENAME") String typename, @Parameter(description="The feature type(s) name(s) to be queried") @DefaultValue("") @QueryParam("TYPENAMES") String typenames, @Parameter(description="The name of the CRS to be returned") @DefaultValue("") @QueryParam("SRSNAME") String srsName, @DefaultValue("gml") @QueryParam("EXCEPTIONS") String exceptions, @Parameter(description="A bounding box used for filtering results") @DefaultValue("") @QueryParam("BBOX") String bbox, @DefaultValue("") @QueryParam("VALUEREFERENCE") String propertyname, @Parameter(description="Sorting order definition") @DefaultValue("ASC") @QueryParam("SORTBY") String sortBy, @DefaultValue("") @QueryParam("STYLES") String style, @DefaultValue("results") @QueryParam("RESULTTYPE") String resultType, @DefaultValue("") @QueryParam("RESOURCEID") String resourceids, @DefaultValue("") @QueryParam("GMLOBJECTID") String gmlobjectid, @DefaultValue("0") @QueryParam("STARTINDEX") String startindex, @DefaultValue("") @QueryParam("FILTER") String filter, @DefaultValue("") @QueryParam("FILTERLANGUAGE") String filterLanguage, @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String output, @DefaultValue("5") @QueryParam("COUNT") String count)
 Entrypoint implementation for OGC API Features for POST requests. More...
 
Response vectorTiles (@DefaultValue("CSW") @QueryParam("SERVICE") String service, @DefaultValue("GetCapabilities") @QueryParam("REQUEST") String request, @DefaultValue("2.0.2") @QueryParam("VERSION") String version, @DefaultValue("") @QueryParam("TYPENAME") String typename, @DefaultValue("") @QueryParam("TYPENAMES") String typenames, @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String output)
 Returns a vector tile representation of a given feature type. More...
 
Response style ( @Parameter(description="The service type which is addressed") @DefaultValue("WFS") @QueryParam("SERVICE") String service, @Parameter(description="Request type of this query") @DefaultValue("GetStyle") @QueryParam("REQUEST") String request, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAME") String typename, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAMES") String typenames, @Parameter(description="Outputformat of the style which is returned") @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String output)
 Returns a style information in a given format for a given featuretype and styleid. More...
 
Response getCollectionStyle ( @Parameter(description="Feature type name") @PathParam("collectionid") String collectionid, @Parameter(description="Style id") @PathParam("styleid") String styleid, @Parameter(description="Return format") @DefaultValue("html") @QueryParam("f") String format)
 Gets a style for a given featuretype with a given style identifier. More...
 
Response getCollectionStyles ( @Parameter(description="Feature type name") @PathParam("collectionid") String collectionid, @Parameter(description="Return type") @DefaultValue("html") @QueryParam("f") String format)
 Gets a list of all styles for a given featuretype. More...
 
Response entryPointCSW ( @Parameter(description="Service type") @DefaultValue("CSW") @QueryParam("SERVICE") String service, @Parameter(description="Request type") @DefaultValue("GetCapabilities") @QueryParam("REQUEST") String request, @Parameter(description="Version of the webservice") @DefaultValue("2.0.2") @QueryParam("VERSION") String version, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAME") String typename, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAMES") String typenames, @Parameter(description="Return type") @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String output)
 CSW endpoint implementation. More...
 
Response entryPointCSWPost (@DefaultValue("CSW") @QueryParam("SERVICE") String service, @DefaultValue("GetCapabilities") @QueryParam("REQUEST") String request, @DefaultValue("2.0.2") @QueryParam("VERSION") String version, @DefaultValue("") @QueryParam("TYPENAME") String typename, @DefaultValue("") @QueryParam("TYPENAMES") String typenames, @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String output)
 CSW endpoint implementation (POST version). More...
 
Response entryPoint ( @Parameter(description="Service type") @DefaultValue("WFS") @QueryParam("SERVICE") String service, @Parameter(description="Request type") @DefaultValue("GetCapabilities") @QueryParam("REQUEST") String request, @Parameter(description="Service version") @DefaultValue("2.0.0") @QueryParam("VERSION") String version, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAME") String typename, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAMES") String typenames, @Parameter(description="CRS type") @DefaultValue("") @QueryParam("SRSNAME") String srsName, @DefaultValue("gml") @QueryParam("EXCEPTIONS") String exceptions, @Parameter(description="Bounding box for filtering the results") @DefaultValue("") @QueryParam("BBOX") String bbox, @DefaultValue("") @QueryParam("VALUEREFERENCE") String propertyname, @Parameter(description="Sorting order") @DefaultValue("ASC") @QueryParam("SORTBY") String sortBy, @DefaultValue("") @QueryParam("STYLES") String style, @DefaultValue("results") @QueryParam("RESULTTYPE") String resultType, @DefaultValue("") @QueryParam("RESOURCEID") String resourceids, @DefaultValue("") @QueryParam("GMLOBJECTID") String gmlobjectid, @DefaultValue("0") @QueryParam("STARTINDEX") String startindex, @Parameter(description="Filter expression") @DefaultValue("") @QueryParam("FILTER") String filter, @Parameter(description="Filter query language") @DefaultValue("") @QueryParam("FILTERLANGUAGE") String filterLanguage, @Parameter(description="Return format") @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String output, @Parameter(description="Maximum amount of results to return") @DefaultValue("5") @QueryParam("COUNT") String count)
 WFS endpoint implementation. More...
 
Response docJSON ( @Parameter(description="Return format") @DefaultValue("json") @QueryParam("f") String format)
 
Response collectionsJSON ( @Parameter(description="Return format") @DefaultValue("json") @QueryParam("f") String format)
 
Response collectionsXML ( @Parameter(description="Return format") @DefaultValue("xml") @QueryParam("f") String format)
 
Response collectionsHTML ( @Parameter(description="Return format") @DefaultValue("html") @QueryParam("f") String format)
 
Response collections ( @Parameter(description="Return format", style=ParameterStyle.FORM) @DefaultValue("html") @QueryParam("f") String format)
 Returns a list of feature types/collections. More...
 
Response getFeatureByIdJSON ( @Parameter(description="The collection id") @PathParam("collectionid") String collectionid, @Parameter(description="The feature id") @PathParam("featureid") String featureid, @Parameter(description="The style to be applied") @DefaultValue("") @QueryParam("mapstyle") String style, @Parameter(description="The format to be returned") @DefaultValue("json") @QueryParam("f") String format)
 Returns a feature given its feature id. More...
 
Response getFeatureByIdXML ( @Parameter(description="The collection id") @PathParam("collectionid") String collectionid, @Parameter(description="The feature id") @PathParam("featureid") String featureid, @Parameter(description="The style to be applied") @DefaultValue("") @QueryParam("mapstyle") String style, @Parameter(description="The format to be returned") @DefaultValue("gml") @QueryParam("f") String format)
 Returns a feature given its feature id. More...
 
Response docCollectionItemJSON ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String collectionid, @Parameter(description="The id of the feature to be considered") @PathParam("ext") String ext, @Parameter(description="The id of the feature to be considered") @PathParam("featureid") String featureid, @Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("ldapi") @QueryParam("_format") String format, @Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("_pageSize") Integer limit, @Parameter(description="An optional where statement to be used in the SPARQL query", example="10") @DefaultValue("") @QueryParam("_select") String select, @Parameter(description="An optional where statement to be used in the SPARQL query", example="10") @DefaultValue("") @QueryParam("_where") String where, @Parameter(description="The page of the Linked Data API resource to return", example="1") @DefaultValue("1") @QueryParam("_page") Integer page, @Parameter(description="Detailed or minimized view to be returned") @DefaultValue("") @QueryParam("_view") String view, @Parameter(description="The sorting of the given results") @DefaultValue("") @QueryParam("_sort") String sort, @Parameter(description="An optional orderBy statement to be used in the SPARQL query") @DefaultValue("") @QueryParam("_orderBy") String orderBy, @Parameter(description="A subclass definition of the class defining the featurecollection") @DefaultValue("") @QueryParam("type") String type, @Parameter(description="Defines resources with a specified parameter value to be returned") @DefaultValue("") @QueryParam("param") List< String > paramval, @Parameter(description="Defines resources with a specified parameter value greater or equal the given value to be returned") @DefaultValue("") @QueryParam("max-param") String maxparamval, @Parameter(description="Defines resources with a specified parameter value smaller or equal the given value to be returned") @DefaultValue("") @QueryParam("min-param") String minparamval, @Parameter(description="Defines resources with a specified parameter value greater than the given value to be returned") @DefaultValue("") @QueryParam("maxEx-param") String maxExparamval, @Parameter(description="Defines resources with a specified parameter value smaller than the given value to be returned") @DefaultValue("") @QueryParam("minEx-param") String minExparamval, @Parameter(description="Returns only resources with the specified parameter") @QueryParam("exists-param") String existsparam, @Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String offset)
 
Response getFeatureByIdHTML ( @Parameter(description="The collection id") @PathParam("collectionid") String collectionid, @Parameter(description="The feature id") @PathParam("featureid") String featureid, @Parameter(description="The style to be applied") @DefaultValue("") @QueryParam("mapstyle") String style, @Parameter(description="The format to be returned") @DefaultValue("html") @QueryParam("f") String format)
 Returns a feature given its feature id. More...
 
Response getFeatureById ( @Parameter(description="The collection id") @PathParam("collectionid") String collectionid, @Parameter(description="The feature id") @PathParam("featureid") String featureid, @Parameter(description="The style to be applied") @DefaultValue("") @QueryParam("style") String style, @Parameter(description="The format to be returned") @DefaultValue("html") @QueryParam("f") String format)
 Returns a feature given its feature id. More...
 
Response queryables (@Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String collectionid, @Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("html") @QueryParam("f") String format)
 Returns information about the queryables of ths given feature type. More...
 
Response landingPageHTML (@Parameter(description="The format of the landingpage") @DefaultValue("html") @QueryParam("f") String format)
 
Response landingPageJSON (@Parameter(description="The format of the landingpage") @DefaultValue("json") @QueryParam("f") String format)
 
Response landingPageXML (@Parameter(description="The format of the landingpage") @DefaultValue("xml") @QueryParam("f") String format)
 
Response landingPage (@Parameter(description="The format of the landingpage") @DefaultValue("html") @QueryParam("f") String format)
 Returns the landing page of the OGC API Features service. More...
 
Response getCollectionsMetadata (@Parameter(description="The format of the collection page") @DefaultValue("html") @QueryParam("f") String format)
 Returns the metadata of collections registered in the SemanticWFS. More...
 
Response getCollectionMetadata (@PathParam("collectionid") String collectionid, @Parameter(description="The metadata schema to be used") @DefaultValue("gmd") @QueryParam("metadataformat") String mdformat, @Parameter(description="The format to downlift metadata") @DefaultValue("html") @QueryParam("f") String format, @DefaultValue("false") @QueryParam("collectioncall") String collectioncall)
 Gets metadata of a given collection. More...
 
Response collectionInformationJSON ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String collectionid, @Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("json") @QueryParam("f") String format, @Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("limit") String limit, @Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String offset, @Parameter(description="Defines a bounding box from which to return the given features") @QueryParam("bbox") String bbox)
 
Response collectionInformationXML ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String collectionid, @Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("xml") @QueryParam("f") String format, @Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("limit") String limit, @Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String offset, @Parameter(description="Defines a bounding box from which to return the given features") @QueryParam("bbox") String bbox)
 
Response collectionInformationHTML ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String collectionid, @Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("html") @QueryParam("f") String format, @Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("limit") String limit, @Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String offset, @Parameter(description="Defines a bounding box from which to return the given features") @QueryParam("bbox") String bbox)
 
Response docCollectionJSON ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String collectionid, @Parameter(description="The format if given as a file extension") @DefaultValue("") @PathParam("ext") String ext, @Parameter(description="The format in which the collection should be returned", example="ttl") @DefaultValue("ldapi") @QueryParam("_format") String format, @Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("_pageSize") Integer limit, @Parameter(description="An optional where statement to be used in the SPARQL query", example="10") @DefaultValue("") @QueryParam("_select") String select, @Parameter(description="An optional where statement to be used in the SPARQL query", example="10") @DefaultValue("") @QueryParam("_where") String where, @Parameter(description="The page of the Linked Data API resource to return", example="1") @DefaultValue("1") @QueryParam("_page") Integer page, @Parameter(description="Detailed or minimized view to be returned") @DefaultValue("") @QueryParam("_view") String view, @Parameter(description="The sorting of the given results") @DefaultValue("") @QueryParam("_sort") String sort, @Parameter(description="An optional orderBy statement to be used in the SPARQL query") @DefaultValue("") @QueryParam("_orderBy") String orderBy, @Parameter(description="A subclass definition of the class defining the featurecollection") @DefaultValue("") @QueryParam("type") String type, @Parameter(description="Defines resources with a specified parameter value to be returned") @DefaultValue("") @QueryParam("param") List< String > paramval, @Parameter(description="Defines resources with a specified parameter value greater or equal the given value to be returned") @DefaultValue("") @QueryParam("max-param") String maxparamval, @Parameter(description="Defines resources with a specified parameter value smaller or equal the given value to be returned") @DefaultValue("") @QueryParam("min-param") String minparamval, @Parameter(description="Defines resources with a specified parameter value greater than the given value to be returned") @DefaultValue("") @QueryParam("maxEx-param") String maxExparamval, @Parameter(description="Defines resources with a specified parameter value smaller than the given value to be returned") @DefaultValue("") @QueryParam("minEx-param") String minExparamval, @Parameter(description="Returns only resources with the specified parameter") @QueryParam("exists-param") String existsparam, @Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") Integer offset)
 
Response collectionInformation ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String collectionid, @Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("html") @QueryParam("f") String format, @Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("limit") String limit, @Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String offset, @Parameter(description="Defines a bounding box from which to return the given features") @QueryParam("bbox") String bbox)
 Returns a given collection description or parts of it. More...
 
Response getSchema ( @Parameter(description="The collection id for which to return the schema") @PathParam("collectionid") String collectionid, @Parameter(description="The format in which the schema should be returned", example="json") @DefaultValue("gml") @QueryParam("f") String format)
 Returns a schema of a given collection. More...
 
Response collectionItemsJSON (@Context HttpHeaders headers, @Parameter(description="The id of the collection") @PathParam("collectionid") String collectionid, @Parameter(description="The format of the result") @DefaultValue("json") @QueryParam("f") String format, @Parameter(description="The query limit", style=ParameterStyle.FORM) @DefaultValue("10") @QueryParam("limit") Integer limit, @Parameter(description="The offset to consider when fetching items") @DefaultValue("0") @QueryParam("offset") Integer offset, @Parameter(description="A bounding box", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("bbox") String bbox, @Parameter(description="The styling of the item when returned") @DefaultValue("") @QueryParam("style") String style, @Parameter(description="The crs of the data to be returned") @DefaultValue("EPSG:4326") @QueryParam("crs") String crs, @Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String bboxcrs, @Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String filter, @Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String filterlang, @Parameter(description="A temporal filter expression") @DefaultValue("") @QueryParam("datetime") String datetime)
 
Response collectionItemsXML (@Context HttpHeaders headers, @Parameter(description="The id of the collection") @PathParam("collectionid") String collectionid, @Parameter(description="The format of the result") @DefaultValue("gml") @QueryParam("f") String format, @Parameter(description="The query limit", style=ParameterStyle.FORM) @DefaultValue("10") @QueryParam("limit") Integer limit, @Parameter(description="The offset to consider when fetching items") @DefaultValue("0") @QueryParam("offset") Integer offset, @Parameter(description="A bounding box", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("bbox") String bbox, @Parameter(description="The styling of the item when returned") @DefaultValue("") @QueryParam("style") String style, @Parameter(description="The crs of the data to be returned") @DefaultValue("EPSG:4326") @QueryParam("crs") String crs, @Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String bboxcrs, @Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String filter, @Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String filterlang, @Parameter(description="A temporal filter expression") @DefaultValue("") @QueryParam("datetime") String datetime)
 
Response collectionItemsHTML (@Context HttpHeaders headers, @Parameter(description="The id of the collection") @PathParam("collectionid") String collectionid, @Parameter(description="The format of the result") @DefaultValue("html") @QueryParam("f") String format, @Parameter(description="The query limit", style=ParameterStyle.FORM) @DefaultValue("10") @QueryParam("limit") Integer limit, @Parameter(description="The offset to consider when fetching items") @DefaultValue("0") @QueryParam("offset") Integer offset, @Parameter(description="A bounding box", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("bbox") String bbox, @Parameter(description="The styling of the item when returned") @DefaultValue("") @QueryParam("style") String style, @Parameter(description="The crs of the data to be returned") @DefaultValue("") @QueryParam("crs") String crs, @Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String bboxcrs, @Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String filter, @Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String filterlang, @Parameter(description="A temporal filter expression") @DefaultValue("") @QueryParam("datetime") String datetime)
 
Response collectionItems (@Context HttpHeaders headers, @Parameter(description="The id of the collection") @PathParam("collectionid") String collectionid, @Parameter(description="The format of the result") @DefaultValue("html") @QueryParam("f") String format, @Parameter(description="The query limit", style=ParameterStyle.FORM) @DefaultValue("10") @QueryParam("limit") Integer limit, @Parameter(description="The offset to consider when fetching items") @DefaultValue("0") @QueryParam("offset") Integer offset, @Parameter(description="The boundingbox to used for querying", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("bbox") String bbox, @Parameter(description="The styling of the item when returned") @DefaultValue("") @QueryParam("mapstyle") String style, @Parameter(description="The crs of the data to be returned") @DefaultValue("EPSG:4326") @QueryParam("crs") String crs, @Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String bboxcrs, @Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String filter, @Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String filterlang, @Parameter(description="A temporal filter expression", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("datetime") String datetime)
 Returns a number of features from a given featuretype. More...
 
Response conformanceJSON (@Parameter(description="The format of the conformance page") @DefaultValue("json") @QueryParam("f") String format)
 
Response conformanceXML (@Parameter(description="The format of the conformance page") @DefaultValue("xml") @QueryParam("f") String format)
 
Response conformanceHTML (@Parameter(description="The format of the conformance page") @DefaultValue("html") @QueryParam("f") String format)
 
Response conformance (@Parameter(description="The format of the conformance page") @DefaultValue("html") @QueryParam("f") String format)
 Gets conformance information about the OGC API Features service. More...
 
Response constructCapabilitiesWFS10 (String version, String versionnamespace) throws XMLStreamException
 Constructs a capabilities document for a WFS in version 1.0 . More...
 
Response constructCapabilitiesCSW (String version, String versionnamespace) throws XMLStreamException
 Constructs a capabilities document for a CSW service . More...
 
Response constructCapabilities (String version, String versionnamespace) throws XMLStreamException
 Constructs a capabilities document for a WFS in version 1.1 . More...
 
void describeConformance (IndentingXMLStreamWriter writer, String versionnamespace, String namespace) throws XMLStreamException
 Describes the conformance part of a WFS webservices. More...
 
Response getCapabilities ( @Parameter(description="The version of the WFS service to target") @DefaultValue("2.0.0") @QueryParam("version") String version) throws XMLStreamException
 Returns the capabilities document for a WFS service. More...
 
void describeFeatureTypeWFS10 (XMLStreamWriter writer, JSONObject featuretype, String versionnamespace, String version) throws XMLStreamException
 Describes a feature type according to the WFS1.0 specification. More...
 
void describeFeatureType (XMLStreamWriter writer, JSONObject featuretype, String versionnamespace, String version) throws XMLStreamException
 Creates a feature type description. More...
 
void describeSpatialCapabilities (XMLStreamWriter writer, String versionnamespace, String namespace) throws XMLStreamException
 Writes the spatial capabilities part of the WFS document. More...
 
void describeSpatialCapabilitiesWFS10 (XMLStreamWriter writer, String versionnamespace, String namespace) throws XMLStreamException
 Creates the spatial capabilities document for a WFS in version 1.0. More...
 
void describeScalarCapabilities (XMLStreamWriter writer, String versionnamespace, String namespace) throws XMLStreamException
 Writes the scalar capabilities document for a WFS. More...
 
Response describeFeatureType ( @Parameter(description="The feature type name to describe") @QueryParam("typename") String typename, @Parameter(description="The version of the WFS service") @DefaultValue("version") @QueryParam("version") String version) throws XMLStreamException
 Describes a feature type as an answer to a WFS request. More...
 
Response describeFeatureTypeJSON ( @Parameter(description="The feature type to describe") @QueryParam("typename") String typename, @Parameter(description="The version of the WFS service") @DefaultValue("version") @QueryParam("version") String version)
 Describes a feature type in JSON. More...
 
Response getGeoClassesFromOntology ( @Parameter(description="The SPARQL endpoint to load classes from") @QueryParam("endpoint") String endpoint)
 Gets geospatial classes from a SPARQL endpoint. More...
 
Response getEndpoints ()
 Gets available SPARQL endpoitns from the triplestore configuration. More...
 
Response getPropertiesByClass ( @Parameter(description="The SPARQL endpoint to load properties from") @QueryParam("endpoint") String endpoint, @Parameter(description="The class from which properties should be loaded") @QueryParam("class") String classs)
 Gets available properties associated with a certain class. More...
 
Response getFeature (@QueryParam("typename") String typename, @Parameter(description="The output format of the WFS service request") @DefaultValue("json") @QueryParam("outputFormat") String output, @Parameter(description="The amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("count") String count, @Parameter(description="The starting index of the WFS request") @DefaultValue("0") @QueryParam("startindex") String startindex, @Parameter(description="The name of the CRS to be used") @DefaultValue("") @QueryParam("srsName") String srsName, @Parameter(description="Indicates the sorting order") @DefaultValue("ASC") @QueryParam("sortBy") String sortBy, @Parameter(description="The style to apply to the returned collection if any") @DefaultValue("") @QueryParam("mapstyles") String style, @Parameter(description="The version of the WFS", example="2.0.0") @DefaultValue("2.0.0") @QueryParam("version") String version, @Parameter(description="Indicates a specific resource id to be queried") @DefaultValue("") @QueryParam("resourceid") String resourceids, @Parameter(description="A WFS filter expression") @DefaultValue("") @QueryParam("filter") String filter, @Parameter(description="The filter language to be used in the filterExpression parameter") @DefaultValue("CQL") @QueryParam("filterLanguage") String filterLanguage, @Parameter(description="The result type to return") @DefaultValue("results") @QueryParam("resultType") String resultType) throws JSONException, XMLStreamException
 
Response getGmlObject (@QueryParam("typename") String typename, @QueryParam("GmlObjectId") String gmlobjectid, @DefaultValue("4") @QueryParam("traverseXlinkDepth") String traverseXlinkDepth, @DefaultValue("gml") @QueryParam("outputFormat") String output)
 
Response getPropertyValue ( @Parameter(description="Feature type to query") @QueryParam("typename") String typename, @QueryParam("valuereference") String propertyname, @DefaultValue("json") @QueryParam("outputFormat") String output, @DefaultValue("") @QueryParam("resourceids") String resourceids, @DefaultValue("") @QueryParam("filter") String filter, @DefaultValue("0") @QueryParam("count") String count, @DefaultValue("results") @QueryParam("resultType") String resultType)
 
Boolean addFeatureType ( @Parameter(description="The SPARQL query used to retrive the feature type") @QueryParam("query") String sparqlQuery, @Parameter(description="The featuretype name") @QueryParam("typename") String name, @Parameter(description="The variable indicating the individual in the query") @DefaultValue("item") @QueryParam("indvar") String indvar, @Parameter(description="The limit of the initial sample to retrieve") @DefaultValue("500") @QueryParam("bboxlimit") String bboxlimit, @Parameter(description="The class to query") @QueryParam("class") String classs, @Parameter(description="The service type which is queried") @DefaultValue("WFS") @QueryParam("type") String type, @Parameter(description="The feature type description") @DefaultValue("") @QueryParam("description") String description, @Parameter(description="The EPSG of the feature type to be added") @DefaultValue("EPSG:4326") @QueryParam("targetCRS") String targetCRS, @Parameter(description="The namespace used for the feature type") @QueryParam("namespace") String namespace, @Parameter(description="The triple store to query when loading the feature type") @QueryParam("triplestore") String triplestore, @Parameter(description="The username needed for authentication") @DefaultValue("") @QueryParam("username") String username, @Parameter(description="The password needed for authentication") @DefaultValue("") @QueryParam("password") String password, @Parameter(description="The authtoken for authentication") @DefaultValue("") @QueryParam("authtoken") String authtoken)
 Adds a feature type to the SemanticWFS. More...
 
Boolean addEndpoint (@Parameter(description="The name of the SPARQL endpoint to add") @QueryParam("name") String name, @Parameter(description="The address of the SPARQL endpoint") @QueryParam("endpoint") String endpoint, @Parameter(description="The type property used in this SPARQL endpoint") @QueryParam("typerel") String typerel, @Parameter(description="The geometry property used by this SPARQL endpoint") @QueryParam("georel") String georel, @Parameter(description="Username for authorization") @QueryParam("username") String username, @Parameter(description="Password for authorization") @QueryParam("password") String password, @Parameter(description="Authtoken if the user is already logged in") @DefaultValue("") @QueryParam("authtoken") String authtoken)
 Adds a SPARQL endpoint to the triplestoreconf configuration. More...
 
Boolean saveFeatureTypes ( @Parameter(description="JSON object containing feature types to be saved") @QueryParam("featjson") String featureTypesJSON, @Parameter(description="Authtoken for authorization") @DefaultValue("") @QueryParam("authtoken") String authtoken)
 Saves feature types in the SemanticWFS Service. More...
 
Response login (@Parameter(description="Username for authorization") @QueryParam("username") String username, @Parameter(description="Password for authorization") @QueryParam("password") String password)
 Performs a login returning an authtoken if successful. More...
 
String getFeatureTypes ()
 Returns featuretypes known by the SemanticWFS service. More...
 
String prefixes ()
 Returns prefixes known by the SemanticWFS service. More...
 
String addPrefixes (@QueryParam("query") String sparqlQuery, @QueryParam("typename") String name, @QueryParam("namespace") String namespace, @QueryParam("triplestore") String triplestore)
 
Response queryConfigs ()
 Returns the query configuration document. More...
 
String queryService ( @Parameter(description="SPARQL query to be resolved") @QueryParam("query") String query, @Parameter(description="SPARQL endpoint to query") @QueryParam("endpoint") String endpoint)
 Exposes a query service which returns a SPARQL query result as REST. More...
 
String queryService ( @Parameter(description="SPARQL query to be resolved") @QueryParam("query") String query, @Parameter(description="SPARQL endpoint to be queried") @QueryParam("endpoint") String endpoint, @Parameter(description="Indicates whether geojson should be returned to be shown in a map view") @QueryParam("geojson") String geojson)
 Exposes a query service which returns a SPARQL query result as REST. More...
 
String transaction ()
 Transaction method of the WFS specification. More...
 
String lockFeature ()
 Lock Feature method of the WFS specification. More...
 

Public Attributes

XMLStreamWriter xmlwriter
 
String SERVICETYPEVERSION = "2.0.0"
 
String SERVERURL = "http://localhost:8080/WFSGeoSPARQL/rest/wfs?"
 

Static Public Attributes

static JSONObject triplestoreconf = null
 
static JSONObject wfsconf = null
 
static final MediaType openapijson =new MediaType("application", "vnd.oai.openapi+json;version=3.0")
 
static Map< String, Map< String, String > > featureTypeCache = new TreeMap<>()
 
static Map< String, Map< String, String > > nameSpaceCache = new TreeMap<>()
 
static Map< String, Tuple< Date, String > > hitCache = new TreeMap<>()
 
static Map< String, Map< String, StyleObject > > styleCache = new TreeMap<>()
 
static Map< String, Double[]> bboxCache = new TreeMap<>()
 
static long milliesInDays = 24 * 60 * 60 * 1000
 

Package Attributes

String htmlHead
 

Detailed Description

Implements OGC API Features and WFS webservice functionality.

Constructor & Destructor Documentation

◆ WebService()

WebService ( ) throws IOException

Constructor for this class.

Loads configuration files and performs initializations.

Exceptions
IOExceptionon error
117  {
118  String currentWorkingDir = System.getProperty("user.dir");
119  System.out.println(currentWorkingDir);
120  System.out.println(Paths.get("triplestoreconf.json").toAbsolutePath());
121  if (triplestoreconf == null) {
122  triplestoreconf = new JSONObject(new String(Files.readAllBytes(Paths.get("triplestoreconf.json")), StandardCharsets.UTF_8));
123  System.out.println(triplestoreconf);
124  }
125  if (wfsconf == null) {
126  try {
127  System.out.println(new String(Files.readAllBytes(Paths.get("wfsconf.json")), StandardCharsets.UTF_8));
128  System.out.println(new JSONObject(new String(Files.readAllBytes(Paths.get("wfsconf.json")), StandardCharsets.UTF_8)));
129  wfsconf = new JSONObject(new String(Files.readAllBytes(Paths.get("wfsconf.json")), StandardCharsets.UTF_8));
130  }catch(Exception e) {
131  e.printStackTrace();
132  }
133  System.out.println(wfsconf);
134  System.out.println("in");
135  }
136  System.out.println("out");
137  /*
138  for (Integer i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
139  JSONObject featuretype = wfsconf.getJSONArray("datasets").getJSONObject(i);
140  System.out.println("Featuretype: "+featuretype);
141  if (featuretype.has("name") && !bboxCache.containsKey(featuretype.getString("name").toLowerCase())) {
142  try {
143  bboxCache.put(featuretype.getString("name").toLowerCase(),
144  TripleStoreConnector.getBoundingBoxFromTripleStoreData(featuretype.getString("triplestore"),
145  featuretype.getString("query")));
146  }catch(Exception e) {
147  e.printStackTrace();
148  }
149  }
150  }*/
151  htmlHead = "<html><head><link rel=\"stylesheet\" href=\"https://unpkg.com/leaflet@1.5.1/dist/leaflet.css\"\r\n"
152  + " integrity=\"sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==\"\r\n"
153  + " crossorigin=\"\"/>\r\n" + "<script src=\"" + wfsconf.getString("baseurl")
154  + "/config/js/proj4.js\"></script>" + "<script src=\"" + wfsconf.getString("baseurl")
155  + "/config/js/prefixes.js\"></script>"
156  + " <link rel=\"stylesheet\" href=\""+ wfsconf.getString("baseurl")+"/config/css/leaflet_legend.css\" />"
157  + " <link rel=\"stylesheet\" type=\"text/css\" href=\"https://unpkg.com/leaflet-coverage@0.7/leaflet-coverage.css\">\r\n"
158  + " <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css\" integrity=\"sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb\" crossorigin=\"anonymous\">"
159  + " <link rel=\"stylesheet\" href=\""+wfsconf.getString("baseurl")+"/config/css/style.css\">"
160  + "<script src=\"https://unpkg.com/leaflet@1.5.1/dist/leaflet.js\"\r\n"
161  + " integrity=\"sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og==\"\r\n"
162  + " crossorigin=\"\"></script><link rel=\"stylesheet\" href=\"https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css\"/>\r\n"
163  + "<script src=\"" + wfsconf.getString("baseurl") + "/config/js/leaflet.pattern.js\"></script>\r\n"
164  + "<script src=\"" + wfsconf.getString("baseurl")
165  + "/config/js/Leaflet.geojsoncss.min.js\"></script>\r\n"
166 
167  + "<script src=\"" + wfsconf.getString("baseurl")
168  + "/config/js/leaflet_legend.js\"></script>\r\n"
169  + "<script src=\"https://code.jquery.com/jquery-3.4.1.min.js\"></script>\r\n"
170  + "<script src=\"https://unpkg.com/covutils@0.6/covutils.min.js\"></script>\r\n"
171  + "<script src=\"https://unpkg.com/leaflet-coverage@0.7/leaflet-coverage.min.js\"></script>\r\n"
172  + "<script src=\"https://cdn.jsdelivr.net/covjson-reader/0.16/covjson-reader.min.js\"></script>\r\n"
173  + "<script src=\"https://unpkg.com/leaflet.vectorgrid@latest/dist/Leaflet.VectorGrid.bundled.js\"></script>\r\n"
174  + "<script src=\"https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js\"></script>\r\n"
175  + "<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js'></script>\r\n"
176  + "<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css' rel='stylesheet' /></head>";
177  }
static JSONObject wfsconf
Definition: WebService.java:92
String htmlHead
Definition: WebService.java:110
static JSONObject triplestoreconf
Definition: WebService.java:90

Member Function Documentation

◆ addEndpoint()

Boolean addEndpoint ( @Parameter(description="The name of the SPARQL endpoint to add") @QueryParam("name") String  name,
@Parameter(description="The address of the SPARQL endpoint") @QueryParam("endpoint") String  endpoint,
@Parameter(description="The type property used in this SPARQL endpoint") @QueryParam("typerel") String  typerel,
@Parameter(description="The geometry property used by this SPARQL endpoint") @QueryParam("georel") String  georel,
@Parameter(description="Username for authorization") @QueryParam("username") String  username,
@Parameter(description="Password for authorization") @QueryParam("password") String  password,
@Parameter(description="Authtoken if the user is already logged in") @DefaultValue("") @QueryParam("authtoken") String  authtoken 
)

Adds a SPARQL endpoint to the triplestoreconf configuration.

Parameters
nameThe name of the SPARQL endpoint
endpointThe SPARQL endpoint address
typerelThe type relation of the SPARQL endpoint
georelThe geometrical relation of the SPARQL endpoint
usernameA username required to save the configuration
passwordA password required to save the configuration
authtokenAn authtoken authorizing the configuration
Returns
True if the endpoint has been successfully added, false otherwise
4247  {
4248  User user=UserManagementConnection.getInstance().loginAuthToken(authtoken);
4249  System.out.println("Add Feature Type");
4250  if(true || name!=null && !name.isEmpty() && user!=null && (user.getUserlevel()==UserType.Configurer || user.getUserlevel()==UserType.Administrator)) {
4251  JSONArray datasets = wfsconf.getJSONArray("datasets");
4252  System.out.println(wfsconf);
4253  System.out.println(datasets);
4254  System.out.println("To add: "+name+" "+endpoint+" "+typerel+" "+georel);
4255  JSONObject toadd = new JSONObject();
4256  toadd.put("name", name);
4257  toadd.put("endpoint", endpoint);
4258  toadd.put("type", typerel);
4259  toadd.put("geo", new JSONArray());
4260  toadd.getJSONArray("geo").put(georel);
4261  System.out.println("Adding feature type: "+toadd);
4262  triplestoreconf.getJSONObject("endpoints").put(endpoint,toadd);
4263  return true;
4264  }
4265  return false;
4266  }

References UserType.Administrator, UserType.Configurer, UserManagementConnection.getInstance(), User.getUserlevel(), and UserManagementConnection.loginAuthToken().

◆ addFeatureType()

Boolean addFeatureType ( @Parameter(description="The SPARQL query used to retrive the feature type") @QueryParam("query") String  sparqlQuery,
@Parameter(description="The featuretype name") @QueryParam("typename") String  name,
@Parameter(description="The variable indicating the individual in the query") @DefaultValue("item") @QueryParam("indvar") String  indvar,
@Parameter(description="The limit of the initial sample to retrieve") @DefaultValue("500") @QueryParam("bboxlimit") String  bboxlimit,
@Parameter(description="The class to query") @QueryParam("class") String  classs,
@Parameter(description="The service type which is queried") @DefaultValue("WFS") @QueryParam("type") String  type,
@Parameter(description="The feature type description") @DefaultValue("") @QueryParam("description") String  description,
@Parameter(description="The EPSG of the feature type to be added") @DefaultValue("EPSG:4326") @QueryParam("targetCRS") String  targetCRS,
@Parameter(description="The namespace used for the feature type") @QueryParam("namespace") String  namespace,
@Parameter(description="The triple store to query when loading the feature type") @QueryParam("triplestore") String  triplestore,
@Parameter(description="The username needed for authentication") @DefaultValue("") @QueryParam("username") String  username,
@Parameter(description="The password needed for authentication") @DefaultValue("") @QueryParam("password") String  password,
@Parameter(description="The authtoken for authentication") @DefaultValue("") @QueryParam("authtoken") String  authtoken 
)

Adds a feature type to the SemanticWFS.

Parameters
sparqlQueryThe SPARQL query to be used by this feature type.
nameThe feature type name
indvarThe individual variable
bboxlimit
classs
type
description
targetCRS
namespace
triplestore
username
password
authtoken
Returns
4190  :4326") @QueryParam("targetCRS") String targetCRS,
4191  @Parameter(description="The namespace used for the feature type") @QueryParam("namespace") String namespace,
4192  @Parameter(description="The triple store to query when loading the feature type") @QueryParam("triplestore") String triplestore,
4193  @Parameter(description="The username needed for authentication") @DefaultValue("") @QueryParam("username") String username,
4194  @Parameter(description="The password needed for authentication") @DefaultValue("") @QueryParam("password") String password,
4195  @Parameter(description="The authtoken for authentication") @DefaultValue("") @QueryParam("authtoken") String authtoken) {
4196  User user=UserManagementConnection.getInstance().loginAuthToken(authtoken);
4197  System.out.println("Add Feature Type");
4198  if(name==null && classs!=null) {
4199  name=classs;
4200  }
4201  if(true || name!=null && !name.isEmpty() && user!=null && (user.getUserlevel()==UserType.Configurer || user.getUserlevel()==UserType.Administrator)) {
4202  JSONArray datasets = wfsconf.getJSONArray("datasets");
4203  System.out.println(wfsconf);
4204  System.out.println(datasets);
4205  System.out.println("To add: "+name+" "+namespace+" "+triplestore+" "+sparqlQuery);
4206  JSONObject toadd = new JSONObject();
4207  toadd.put("name", name);
4208  toadd.put("indvar", indvar);
4209  toadd.put("bboxlimit",bboxlimit);
4210  toadd.put("class", classs);
4211  toadd.put("type",type);
4212  toadd.put("description",description);
4213  toadd.put("targetCRS",targetCRS);
4214  toadd.put("namespace", namespace);
4215  toadd.put("triplestore", triplestore);
4216  toadd.put("query", sparqlQuery);
4217  System.out.println("Adding feature type: "+toadd);
4218  datasets.put(toadd);
4219  return true;
4220  }
4221  return false;
4222  }

References UserType.Administrator, UserType.Configurer, UserManagementConnection.getInstance(), User.getUserlevel(), and UserManagementConnection.loginAuthToken().

◆ addPrefixes()

String addPrefixes ( @QueryParam("query") String  sparqlQuery,
@QueryParam("typename") String  name,
@QueryParam("namespace") String  namespace,
@QueryParam("triplestore") String  triplestore 
)
4347  {
4348  return wfsconf.toString(2);
4349  }

◆ collectionInformation()

Response collectionInformation ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("html") @QueryParam("f") String  format,
@Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("limit") String  limit,
@Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String  offset,
@Parameter(description="Defines a bounding box from which to return the given features") @QueryParam("bbox") String  bbox 
)

Returns a given collection description or parts of it.

Parameters
collectionidThe id of the collection to be considered
formatThe format in which to return the collection
limitThe maximum amount of features to return
offsetThe offset from which to start returning features
bboxThe boundingbox in which the returned features should fit
Returns
The collection description as String
2032  {
2033  if (collectionid == null) {
2034  throw new NotFoundException();
2035  }
2036  JSONObject workingobj = null;
2037  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
2038  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
2039  if (curobj.getString("name").equalsIgnoreCase(collectionid)) {
2040  workingobj = curobj;
2041  break;
2042  }
2043  }
2044  if (workingobj == null) {
2045  throw new NotFoundException();
2046  }
2047  if (!featureTypeCache.containsKey(collectionid.toLowerCase())) {
2048  featureTypeCache.put(collectionid.toLowerCase(),
2049  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
2050  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
2051  }
2052  Map<String, String> mapping = featureTypeCache.get(collectionid.toLowerCase());
2053  if (format != null && format.contains("json")) {
2054  JSONObject result = new JSONObject();
2055  JSONArray resultlinks=new JSONArray();
2056  result.put("id", workingobj.getString("name"));
2057  result.put("name", workingobj.getString("name"));
2058  result.put("title", workingobj.getString("name"));
2059  if(workingobj.has("description")) {
2060  result.put("description", workingobj.getString("description"));
2061  }else {
2062  result.put("description", "");
2063  }
2064  result.put("links",resultlinks);
2065  /*JSONObject extent = new JSONObject();
2066  result.put("extent", extent);
2067  JSONArray spatial = new JSONArray();
2068  JSONArray temporal=new JSONArray();
2069  temporal.put("1970-01-01T00:00:00Z");
2070  temporal.put("2020-08-22T22:10:44Z");
2071  extent.put("spatial", spatial);
2072  extent.put("temporal",temporal);*/
2073  JSONArray crs = new JSONArray();
2074  crs.put("http://www.opengis.net/def/crs/EPSG/0/"+workingobj.getString("targetCRS").substring(workingobj.getString("targetCRS").indexOf(":")+1));
2075  result.put("storageCRS", "http://www.opengis.net/def/crs/EPSG/0/"+workingobj.getString("targetCRS").substring(workingobj.getString("targetCRS").indexOf(":")+1));
2076  result.put("crs", crs);
2077  JSONObject link = new JSONObject();
2078  link.put("href", wfsconf.getString("baseurl") + "/collections/"+collectionid+"?f=json");
2079  link.put("rel", "self");
2080  link.put("type", "application/json");
2081  link.put("title", "This document");
2082  resultlinks.put(link);
2083  link = new JSONObject();
2084  link.put("href", wfsconf.getString("baseurl") + "/collections/"+collectionid+"?f=xml");
2085  link.put("rel", "alternate");
2086  link.put("type", "application/xml");
2087  link.put("title", "This document as XML");
2088  resultlinks.put(link);
2089  link = new JSONObject();
2090  link.put("href", wfsconf.getString("baseurl") + "/collections/"+collectionid+"?f=html");
2091  link.put("rel", "alternate");
2092  link.put("type", "text/html");
2093  link.put("title", "This document as HTML");
2094  resultlinks.put(link);
2095  /*JSONArray collections=new JSONArray();
2096  result.put("collections",collections);
2097  JSONObject collectionentry=new JSONObject();
2098  collections.put(collectionentry);
2099  collectionentry.put("id", workingobj.getString("name"));
2100  collectionentry.put("title", workingobj.getString("name"));
2101  collectionentry.put("description", "");
2102 */
2103  JSONArray links = resultlinks;
2104  for (ResultFormatter formatter : ResultFormatter.resultMap.values()) {
2105  link = new JSONObject();
2106  if (formatter.exposedType.contains("geojson")) {
2107  link.put("rel", "item");
2108  } else {
2109  link.put("rel", "item");
2110  }
2111  link.put("href", wfsconf.getString("baseurl") + "/collections/" + collectionid + "/items" + "?f="
2112  + formatter.urlformat);
2113  link.put("type", formatter.exposedType);
2114  link.put("title", collectionid);
2115  links.put(link);
2116  }
2117  link = new JSONObject();
2118  link.put("rel", "describedBy");
2119  link.put("href", wfsconf.getString("baseurl") + "/collections/" + collectionid + "/schema/");
2120  link.put("type", "application/xml");
2121  link.put("title", collectionid + " Schema");
2122  links.put(link);
2123  return Response.ok(result.toString(2)).type(MediaType.APPLICATION_JSON).build();
2124  } else if (format != null && format.contains("gml")) {
2125  StringWriter strwriter = new StringWriter();
2126  XMLOutputFactory output = XMLOutputFactory.newInstance();
2127  XMLStreamWriter writer;
2128  try {
2129  writer = new IndentingXMLStreamWriter(output.createXMLStreamWriter(strwriter));
2130  writer.writeStartDocument();
2131  writer.setDefaultNamespace("http://www.opengis.net/ogcapi-features-1/1.0");
2132  writer.writeStartElement("Collection");
2133  writer.setPrefix("atom", "http://www.w3.org/2005/Atom");
2134  writer.writeAttribute("xmlns", "http://www.opengis.net/ogcapi-features-1/1.0");
2135  writer.writeAttribute("xmlns:atom", "http://www.w3.org/2005/Atom");
2136  writer.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
2137  writer.writeAttribute("xmlns:sf", "http://www.opengis.net/ogcapi-features-1/1.0/sf");
2138  writer.writeAttribute("xmlns:gml", "http://www.opengis.net/gml/3.2");
2139  writer.writeAttribute("service", "OGCAPI-FEATURES");
2140  writer.writeAttribute("version", "1.0.0");
2141  writer.writeStartElement("links");
2142  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
2143  writer.writeAttribute("rel", "self");
2144  writer.writeAttribute("title", "This document");
2145  writer.writeAttribute("type", "application/xml");
2146  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/collections/"+collectionid+"/?f=gml");
2147  writer.writeEndElement();
2148  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
2149  writer.writeAttribute("rel", "alternate");
2150  writer.writeAttribute("title", "This document as JSON");
2151  writer.writeAttribute("type", "application/json");
2152  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/collections/"+collectionid+ "/?f=json");
2153  writer.writeEndElement();
2154  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
2155  writer.writeAttribute("rel", "alternate");
2156  writer.writeAttribute("title", "This document as HTML");
2157  writer.writeAttribute("type", "text/html");
2158  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/collections/"+collectionid+ "/?f=html");
2159  writer.writeEndElement();
2160  writer.writeEndElement();
2161  writer.writeStartElement("collections");
2162  writer.writeStartElement(collectionid);
2163  writer.writeStartElement("Id");
2164  writer.writeCharacters(collectionid);
2165  writer.writeEndElement();
2166  writer.writeStartElement("Title");
2167  writer.writeCharacters(workingobj.getString("description"));
2168  writer.writeEndElement();
2169  for (ResultFormatter formatter : ResultFormatter.resultMap.values()) {
2170  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
2171  if (formatter.exposedType.contains("geojson")) {
2172  writer.writeAttribute("rel", "item");
2173  } else {
2174  writer.writeAttribute("rel", "item");
2175  }
2176  writer.writeAttribute("title", workingobj.getString("name"));
2177  writer.writeAttribute("type", formatter.exposedType);
2178  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/collections/"
2179  + workingobj.getString("name") + "/items?f=" + formatter.urlformat);
2180  writer.writeEndElement();
2181  }
2182  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
2183  writer.writeAttribute("rel", "describedBy");
2184  writer.writeAttribute("title", workingobj.getString("name"));
2185  writer.writeAttribute("type", "application/xml");
2186  writer.writeAttribute("href",
2187  wfsconf.getString("baseurl") + "/collections/" + workingobj.getString("name") + "/schema/");
2188  writer.writeEndElement();
2189  /*writer.writeStartElement("Extent");
2190  writer.writeStartElement("Spatial");
2191  writer.writeAttribute("crs", "http://www.opengis.net/def/crs/OGC/1.3/CRS84");
2192  writer.writeEndElement();
2193  writer.writeEndElement();*/
2194  writer.writeEndElement();
2195  writer.writeEndElement();
2196  writer.writeEndElement();
2197  writer.writeEndDocument();
2198  writer.flush();
2199  return Response.ok(strwriter.toString(),MediaType.APPLICATION_XML).build();
2200  } catch (XMLStreamException e) {
2201  e.printStackTrace();
2202  return this.createExceptionResponse(e, "");
2203  }
2204  } else if (format == null || format.contains("html")) {
2205  System.out.println("WorkingObject: "+workingobj);
2206  StringBuilder builder = new StringBuilder();
2207  JSONObject geojson = new JSONObject();
2208  JSONObject geometry = new JSONObject();
2209  JSONObject properties = new JSONObject();
2210  geojson.put("type", "Feature");
2211  geojson.put("id", collectionid);
2212  geojson.put("geometry", geometry);
2213  geojson.put("properties", properties);
2214  builder.append(htmlHead);
2215  builder.append("<script>");
2216  builder.append("var definitionlinks={");
2217  for (String key : ResultFormatter.labelMap.keySet()) {
2218  builder.append("\""+ResultFormatter.getFormatter(key).urlformat+"\":\""+ResultFormatter.getFormatter(key).definition+"\",\n");
2219  }
2220  builder.delete(builder.length()-1, builder.length());
2221  builder.append("};\n");
2222  builder.append("function changeDefLink(){$('#formatlink').attr('href',definitionlinks[$('#format').val()]);}");
2223  builder.append("function showCollections(link){window.open(link+\"?offset=\"+$('#offset').val()+\"&limit=\"+$('#limit').val()+\"&crs=\"+$('#crs').val()+\"&f=\"+$('#format').val(),'_blank');} var espg=\"" + (workingobj.has("targetCRS") ? workingobj.get("targetCRS") : "")
2224  + "\";</script><body><header id=\"header\"><h1 align=\"center\">");
2225  builder.append(
2226  (workingobj.getString("name") != null ? workingobj.getString("name") : collectionid));
2227  builder.append("</h1></header>");
2228  builder.append("<div class=\"sticky row crumbs\"><div class=\"col-sm-12 col-md-10 col-md-offset-1\">");
2229  builder.append("<a href=\""+wfsconf.getString("baseurl")+"\">Landingpage</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/\">Collections</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/"+collectionid+"\">"+workingobj.getString("name")+"</a>");
2230  builder.append("</div></div>");
2231  builder.append("<div class=\"container-fluid\" role=\"main\"><div class=\"row\"><section>");
2232  builder.append(workingobj.getString("description"));
2233  builder.append("<h3>Queryables</h3><ul><li>");
2234  builder.append("<a href=\""+wfsconf.getString("baseurl") + "/collections/"
2235  + workingobj.getString("name") + "/queryables?f=html\">Queryables of "+workingobj.getString("name")+"</a></li></ul>");
2236  builder.append("<h3>View</h3><ul>");
2237  builder.append("<li><a href=\"" + wfsconf.getString("baseurl")
2238  + "/collections/" + workingobj.getString("name") + "/items?f=html&limit=1&offset=" + (offset + 1)
2239  + "\">First item</a></li>");
2240  builder.append("<li><a href=\""+wfsconf.getString("baseurl") + "/collections/"
2241  + workingobj.getString("name") + "/items?f=html\">First 10 items</a></li>");
2242  builder.append("<li><a href=\"" + wfsconf.getString("baseurl")
2243  + "/collections/" + workingobj.getString("name") + "/items?f=html&limit=100&offset=" + (offset + 1)
2244  + "\">First 100 items</a></li>");
2245  builder.append("<li><a href=\"" + wfsconf.getString("baseurl")
2246  + "/collections/" + workingobj.getString("name") + "/items?f=html&limit=1000&offset=" + (offset + 1)
2247  + "\">First 1000 items</a></li>");
2248  builder.append("</ul><h3>Downloads</h3>Number of features:&nbsp;<input type=\"number\" min=\"1\" id=\"limit\" value=\"10\"/>&nbsp;Offset:&nbsp;<input type=\"number\" min=\"1\" id=\"offset\" value=\"0\"/>Format:<select id=\"format\" onchange=\"changeDefLink()\">");
2249  for (String key : ResultFormatter.labelMap.keySet()) {
2250  builder.append("<option value=\""+ResultFormatter.getFormatter(key).urlformat+"\">"+ResultFormatter.labelMap.get(key)+"</option>");
2251  }
2252  builder.append("</select><a id=\"formatlink\" href=\"#\" target=\"_blank\">");
2253  builder.append("<svg width=\"1em\" height=\"1em\" viewBox=\"0 0 16 16\" class=\"bi bi-info-circle-fill\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\"><path fill-rule=\"evenodd\" d=\"M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412l-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM8 5.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2z\"/></svg>");
2254  builder.append("</a>");
2255  builder.append("<br/>CRS:<select id=\"crs\"></select><button id=\"showfeaturebutton\" onclick=\"showCollections('"+wfsconf.getString("baseurl")+"/collections/" + workingobj.getString("name") + "/items')\"/>Show</button></section></div></div></div>");
2256  builder.append("<footer id=\"footer\"><table width=100%><tbody><tr><td><a href=\"" + wfsconf.getString("baseurl")
2257  + "/collections?f=html\">Back to Collections</a></td><td align=right>This page in <a href=\""
2258  + wfsconf.getString("baseurl") + "/collections/" + workingobj.getString("name")
2259  + "?f=gml\">[GML]</a> <a href=\"" + wfsconf.getString("baseurl") + "/collections/"
2260  + workingobj.getString("name") + "?f=geojson\">[JSON]</a></td></tr></tbody></table></footer><script> $.ajax({url:'../config/epsg.txt',success: function (data){$('#crs').html(data); $('#crs').val(\""+workingobj.getString("targetCRS")+"\");}});</script></body></html>");
2261  return Response.ok(builder.toString(),MediaType.TEXT_HTML).build();
2262  } else {
2263  throw new NotFoundException();
2264  }
2265  }
Response createExceptionResponse(Exception e, String format)
Generates an exception response.
Definition: WebService.java:255
static Map< String, Map< String, String > > featureTypeCache
Definition: WebService.java:96

References ResultFormatter.definition, TripleStoreConnector.getFeatureTypeInformation(), ResultFormatter.getFormatter(), ResultFormatter.labelMap, ResultFormatter.resultMap, and ResultFormatter.urlformat.

◆ collectionInformationHTML()

Response collectionInformationHTML ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("html") @QueryParam("f") String  format,
@Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("limit") String  limit,
@Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String  offset,
@Parameter(description="Defines a bounding box from which to return the given features") @QueryParam("bbox") String  bbox 
)
1898  {
1899  return collectionInformation(collectionid, format, limit, offset, bbox);
1900  }
Response collectionInformation( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String collectionid, @Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("html") @QueryParam("f") String format, @Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("limit") String limit, @Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String offset, @Parameter(description="Defines a bounding box from which to return the given features") @QueryParam("bbox") String bbox)
Returns a given collection description or parts of it.
Definition: WebService.java:2027

◆ collectionInformationJSON()

Response collectionInformationJSON ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("json") @QueryParam("f") String  format,
@Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("limit") String  limit,
@Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String  offset,
@Parameter(description="Defines a bounding box from which to return the given features") @QueryParam("bbox") String  bbox 
)
1868  {
1869  return collectionInformation(collectionid, format, limit, offset, bbox);
1870  }

◆ collectionInformationXML()

Response collectionInformationXML ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("xml") @QueryParam("f") String  format,
@Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("limit") String  limit,
@Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String  offset,
@Parameter(description="Defines a bounding box from which to return the given features") @QueryParam("bbox") String  bbox 
)
1883  {
1884  return collectionInformation(collectionid, format, limit, offset, bbox);
1885  }

◆ collectionItems()

Response collectionItems ( @Context HttpHeaders  headers,
@Parameter(description="The id of the collection") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format of the result") @DefaultValue("html") @QueryParam("f") String  format,
@Parameter(description="The query limit", style=ParameterStyle.FORM) @DefaultValue("10") @QueryParam("limit") Integer  limit,
@Parameter(description="The offset to consider when fetching items") @DefaultValue("0") @QueryParam("offset") Integer  offset,
@Parameter(description="The boundingbox to used for querying", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("bbox") String  bbox,
@Parameter(description="The styling of the item when returned") @DefaultValue("") @QueryParam("mapstyle") String  style,
@Parameter(description="The crs of the data to be returned") @DefaultValue("EPSG:4326") @QueryParam("crs") String  crs,
@Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String  bboxcrs,
@Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String  filter,
@Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String  filterlang,
@Parameter(description="A temporal filter expression", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("datetime") String  datetime 
)

Returns a number of features from a given featuretype.

Parameters
collectionidThe featuretype to return from
formatThe format of the result
limitThe maximum amount of features to return
offsetThe offset from which to return features
bboxThe bounding box in which features which should be returned are contained
styleThe style to apply
bboxcrsThe CRS of the boundingbox to apply
filterA filter expression
filterlangThe filter expression language
datetimeA time constraint
Returns
The query result as String
2386  :4326") @QueryParam("crs") String crs,
2387  @Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String bboxcrs,
2388  @Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String filter,
2389  @Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String filterlang,
2390  @Parameter(description="A temporal filter expression",style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("datetime") String datetime) {
2391  System.out.println("Limit: " + limit);
2392  System.out.println("FORMAT: "+format);
2393  if (collectionid == null) {
2394  throw new NotFoundException();
2395  }
2396  /*if(format.isEmpty() && headers.getAcceptableMediaTypes().isEmpty()) {
2397  format="html";
2398  }else if(format.isEmpty() && !headers.getAcceptableMediaTypes().isEmpty()) {
2399  for(MediaType mediatype:headers.getAcceptableMediaTypes()) {
2400  if(ResultFormatter.resultMap.containsKey(mediatype.toString())) {
2401  format=mediatype.toString();
2402  break;
2403  }
2404  }
2405  }*/
2406  System.out.println("FORMAT: "+format);
2407  JSONObject workingobj=null;
2408  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
2409  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
2410  if (curobj.getString("name").equalsIgnoreCase(collectionid)) {
2411  workingobj = curobj;
2412  break;
2413  }
2414  }
2415  if (workingobj == null) {
2416  throw new NotFoundException();
2417  }
2418  if (!workingobj.has("attcount") && !workingobj.getString("query").contains("?rel")
2419  && !workingobj.getString("query").contains("?val")) {
2420  featureTypeCache.put(collectionid.toLowerCase(),
2421  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
2422  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
2423  workingobj.put("attcount", 1);
2424  } else if (!workingobj.has("attcount")) {
2425  featureTypeCache.put(collectionid.toLowerCase(),
2426  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
2427  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
2428  }
2429  if (!workingobj.has("attcount") || workingobj.getInt("attcount") == 0)
2430  workingobj.put("attcount", 1);
2431  System.out.println("Attcount: " + workingobj.getInt("attcount"));
2432  System.out.println(limit);
2433 
2434  try {
2435  String res="";
2436 
2437  // System.out.println(res);
2438 
2439  // System.out.println(res);
2440  if (format != null && format.contains("json") && !format.contains("covjson") && !format.contains("jsonp") && !format.contains("seq") && !format.equalsIgnoreCase("rdfjson")) {
2441  res = TripleStoreConnector.executeQuery(workingobj.getString("query"),
2442  workingobj.getString("triplestore"), format,
2443  limit.toString(),
2444  offset.toString(), "sf:featureMember", collectionid,
2445  "", workingobj, filter, "", crs,bboxcrs, bbox,
2446  style,true,(workingobj.has("invertXY")?workingobj.getBoolean("invertXY"):false),null);
2447  if (res == null || res.isEmpty()) {
2448  System.out.println("RES: "+res);
2449  throw new NotFoundException();
2450  }
2451  JSONObject result = new JSONObject();
2452  JSONArray links = new JSONArray();
2453  for (ResultFormatter formatter : ResultFormatter.resultMap.values()) {
2454  JSONObject link = new JSONObject();
2455  if (formatter.exposedType.contains("geojson")) {
2456  link.put("rel", "self");
2457  JSONObject nextlink = new JSONObject();
2458  nextlink.put("rel", "next");
2459  nextlink.put("href", wfsconf.getString("baseurl") + "/collections/" + collectionid + "/items?offset="+(Integer.valueOf(offset)+Integer.valueOf(limit))+"&limit="+limit+"&f="
2460  + formatter.urlformat);
2461  nextlink.put("type", formatter.exposedType);
2462  nextlink.put("title", "next page");
2463  links.put(nextlink);
2464  } else {
2465  link.put("rel", "alternate");
2466  }
2467  link.put("href", wfsconf.getString("baseurl") + "/collections/" + collectionid + "/items?f="
2468  + formatter.urlformat);
2469  link.put("type", formatter.exposedType);
2470  link.put("title", collectionid);
2471  links.put(link);
2472  }
2473  if (ResultFormatter.getFormatter(format).mimeType.contains("jsonld")) {
2474  return Response.ok(res).type("text/plain").build();
2475  }
2476  JSONObject jsonresult = new JSONObject(res);
2477  JSONArray features = jsonresult.getJSONArray("features");
2478  if (jsonresult.has("@context")) {
2479  result.put("@context", jsonresult.getJSONObject("@context"));
2480  }
2481  result.put("type", "FeatureCollection");
2482  result.put("links", links);
2483  result.put("timeStamp", System.currentTimeMillis());
2484  result.put("numberMatched", features.length());
2485  result.put("numberReturned", features.length());
2486  result.put("features", features);
2487  return Response.ok(result.toString(2),ResultFormatter.getFormatter(format).mimeType).build();
2488  } else if (format != null && format.contains("gml")) {
2489  res = TripleStoreConnector.executeQuery(workingobj.getString("query"),
2490  workingobj.getString("triplestore"), format,
2491  limit.toString(),
2492  offset.toString(), "sf:featureMember", collectionid,
2493  "", workingobj, filter, "", crs,bboxcrs, bbox,
2494  style,true,(workingobj.has("invertXY")?workingobj.getBoolean("invertXY"):false),null);
2495  if (res == null || res.isEmpty()) {
2496  System.out.println("RES: "+res);
2497  throw new NotFoundException();
2498  }
2499  StringWriter strwriter = new StringWriter();
2500  XMLOutputFactory output = XMLOutputFactory.newInstance();
2501  XMLStreamWriter writer;
2502  System.out.println("GML RESULT!!!");
2503  try {
2504  writer = new IndentingXMLStreamWriter(output.createXMLStreamWriter(strwriter));
2505  writer.writeStartDocument();
2506  writer.writeStartElement("sf:FeatureCollection");
2507  writer.writeAttribute("xmlns", "http://www.opengis.net/ogcapi-features-1/1.0");
2508  writer.writeAttribute("xmlns:atom", "http://www.w3.org/2005/Atom");
2509  writer.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
2510  writer.writeAttribute("xmlns:sf", "http://www.opengis.net/ogcapi-features-1/1.0/sf");
2511  writer.writeAttribute("xmlns:gml", "http://www.opengis.net/gml/3.2");
2512  writer.setDefaultNamespace("http://www.opengis.net/ogcapi-features-1/1.0");
2513  for (String ns : WebService.nameSpaceCache.get(collectionid.toLowerCase()).keySet()) {
2514  writer.writeAttribute(
2515  "xmlns:" + WebService.nameSpaceCache.get(collectionid.toLowerCase()).get(ns), ns);
2516  }
2517  writer.setPrefix("atom", "http://www.w3.org/2005/Atom");
2518  writer.writeAttribute("service", "OGCAPI-FEATURES");
2519  writer.writeAttribute("version", "1.0.0");
2520  writer.writeStartElement("gml:boundedBy");
2521  writer.writeEndElement();
2522  writer.writeStartElement("Title");
2523  writer.writeCharacters(collectionid);
2524  writer.writeEndElement();
2525  writer.writeStartElement("Description");
2526  writer.writeCharacters(collectionid);
2527  writer.writeEndElement();
2528  for (ResultFormatter formatter : ResultFormatter.resultMap.values()) {
2529  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
2530  if (formatter.exposedType.contains("json")) {
2531  writer.writeAttribute("rel", "self");
2532  } else {
2533  writer.writeAttribute("rel", "alternate");
2534  }
2535  writer.writeAttribute("title", workingobj.getString("name"));
2536  writer.writeAttribute("type", formatter.exposedType);
2537  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/collections/"
2538  + workingobj.getString("name") + "/items?f=" + formatter.exposedType);
2539  writer.writeEndElement();
2540  }
2541  strwriter.append(res);
2542  writer.writeEndElement();
2543  writer.writeEndDocument();
2544  writer.flush();
2545  System.out.println("GML RESULT!");
2546  return Response.ok(strwriter.toString(),ResultFormatter.getFormatter(format).mimeType)
2547  .build();
2548  } catch (XMLStreamException e) {
2549  e.printStackTrace();
2550  // TODO Auto-generated catch block
2551  return this.createExceptionResponse(e, "");
2552  }
2553  } else if (format == null || format.contains("html")) {
2554  res = TripleStoreConnector.executeQuery(workingobj.getString("query"),
2555  workingobj.getString("triplestore"), format,
2556  limit.toString(),
2557  offset.toString(), "sf:featureMember", collectionid,
2558  "", workingobj, filter, "", crs,bboxcrs, bbox,
2559  style,true,(workingobj.has("invertXY")?workingobj.getBoolean("invertXY"):false),null);
2560  if (res == null || res.isEmpty()) {
2561  System.out.println("RES: "+res);
2562  throw new NotFoundException();
2563  }
2564  StringBuilder builder = new StringBuilder();
2565  builder.append(htmlHead);
2566  builder.append("<body><header id=\"header\"><h1 align=\"center\">");
2567  builder.append(collectionid);
2568  builder.append("</h1></header>");
2569  builder.append("<div class=\"sticky row crumbs\"><div class=\"col-sm-12 col-md-10 col-md-offset-1\">");
2570  builder.append("<a href=\""+wfsconf.getString("baseurl")+"\">Landingpage</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/\">Collections</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/"+collectionid+"\">"+workingobj.getString("name")+"</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/"+collectionid+"/items?f=html\">Items</a>");
2571  builder.append("</div></div>");
2572  builder.append("<div class=\"container-fluid\" role=\"main\"><div class=\"row\">");
2573  builder.append(res);
2574  // builder.append("<script>$( document ).ready(function()
2575  // {$('#queryres').DataTable({\"scrollX\":\"100%\",\"scrollCollapse\":
2576  // true});});</script>");
2577  if (Integer.valueOf(limit) == 1) {
2578  builder.append("<table width=100%><tr><td><a href=\"" + wfsconf.getString("baseurl")
2579  + "/collections/" + workingobj.getString("name") + "/items?f=html&limit=1&offset="
2580  + (Integer.valueOf(offset) != 0 ? (Integer.valueOf(offset) - 1) + "" : "0")
2581  + "\">[Previous]</a></td><td align=right><a href=\"" + wfsconf.getString("baseurl")
2582  + "/collections/" + workingobj.getString("name") + "/items?f=html&limit=1&offset="
2583  + (Integer.valueOf(offset) + 1) + "\">[Next]</a></td></tr></table></div></div></div>");
2584  }
2585  builder.append("</div><footer id=\"footer\"><table width=100%><tbody><tr><td><a href=\"" + wfsconf.getString("baseurl") + "/collections/"
2586  + collectionid + "?f=html\">Back to " + collectionid
2587  + " Collection</a></td><td align=right>This page in <a href=\"" + wfsconf.getString("baseurl")
2588  + "/collections/" + workingobj.getString("name") + "/items?f=gml&limit=" + limit + "&offset="
2589  + offset + "\">[GML]</a> <a href=\"" + wfsconf.getString("baseurl") + "/collections/"
2590  + workingobj.getString("name") + "/items?f=geojson&limit=" + limit + "&offset=" + offset
2591  + "\">[JSON]</a></td></tr></tbody></table></footer>");
2592  builder.append("</body></html>");
2593  return Response.ok(builder.toString(),ResultFormatter.getFormatter(format).mimeType).build();
2594  } else {
2595  final JSONObject wko2=workingobj;
2596  StreamingOutput stream = new StreamingOutput() {
2597  @Override
2598  public void write(OutputStream os) throws IOException,
2599  WebApplicationException {
2600  Writer writer = new BufferedWriter(new OutputStreamWriter(os));
2601  String res;
2602  try {
2603  res = TripleStoreConnector.executeQuery(wko2.getString("query"),
2604  wko2.getString("triplestore"), format,
2605  limit.toString(),
2606  offset.toString(), "sf:featureMember", collectionid,
2607  "", wko2, filter, "", crs,bboxcrs, bbox,
2608  style,true,(wko2.has("invertXY")?wko2.getBoolean("invertXY"):false),writer);
2609  if(res!=null && !res.isEmpty()) {
2610  writer.write(res);
2611  }
2612  } catch (JSONException | XMLStreamException | IOException e) {
2613  // TODO Auto-generated catch block
2614  e.printStackTrace();
2615  }
2616  writer.close();
2617  }
2618  };
2619  return Response.ok(stream,ResultFormatter.getFormatter(format).mimeType)
2620  .header("Content-Disposition", "attachment; filename*=UTF-8''" + collectionid+"_items."
2621  +ResultFormatter.getFormatter(format).fileextension)
2622  .build();
2623  }
2624  } catch (JSONException | XMLStreamException | IOException e1) {
2625  e1.printStackTrace();
2626  return Response.ok("",MediaType.TEXT_PLAIN).build();
2627  }
2628  }
WebService()
Constructor for this class.
Definition: WebService.java:117
Response collections( @Parameter(description="Return format", style=ParameterStyle.FORM) @DefaultValue("html") @QueryParam("f") String format)
Returns a list of feature types/collections.
Definition: WebService.java:716
Response style( @Parameter(description="The service type which is addressed") @DefaultValue("WFS") @QueryParam("SERVICE") String service, @Parameter(description="Request type of this query") @DefaultValue("GetStyle") @QueryParam("REQUEST") String request, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAME") String typename, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAMES") String typenames, @Parameter(description="Outputformat of the style which is returned") @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String output)
Returns a style information in a given format for a given featuretype and styleid.
Definition: WebService.java:376

References TripleStoreConnector.executeQuery(), ResultFormatter.fileextension, TripleStoreConnector.getFeatureTypeInformation(), ResultFormatter.getFormatter(), ResultFormatter.mimeType, WebService.nameSpaceCache, and ResultFormatter.resultMap.

◆ collectionItemsHTML()

Response collectionItemsHTML ( @Context HttpHeaders  headers,
@Parameter(description="The id of the collection") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format of the result") @DefaultValue("html") @QueryParam("f") String  format,
@Parameter(description="The query limit", style=ParameterStyle.FORM) @DefaultValue("10") @QueryParam("limit") Integer  limit,
@Parameter(description="The offset to consider when fetching items") @DefaultValue("0") @QueryParam("offset") Integer  offset,
@Parameter(description="A bounding box", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("bbox") String  bbox,
@Parameter(description="The styling of the item when returned") @DefaultValue("") @QueryParam("style") String  style,
@Parameter(description="The crs of the data to be returned") @DefaultValue("") @QueryParam("crs") String  crs,
@Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String  bboxcrs,
@Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String  filter,
@Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String  filterlang,
@Parameter(description="A temporal filter expression") @DefaultValue("") @QueryParam("datetime") String  datetime 
)
2354  {
2355  return collectionItems(headers,collectionid, format, limit, offset, bbox, style,crs, bboxcrs, filter, filterlang, datetime);
2356  }
Response collectionItems(@Context HttpHeaders headers, @Parameter(description="The id of the collection") @PathParam("collectionid") String collectionid, @Parameter(description="The format of the result") @DefaultValue("html") @QueryParam("f") String format, @Parameter(description="The query limit", style=ParameterStyle.FORM) @DefaultValue("10") @QueryParam("limit") Integer limit, @Parameter(description="The offset to consider when fetching items") @DefaultValue("0") @QueryParam("offset") Integer offset, @Parameter(description="The boundingbox to used for querying", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("bbox") String bbox, @Parameter(description="The styling of the item when returned") @DefaultValue("") @QueryParam("mapstyle") String style, @Parameter(description="The crs of the data to be returned") @DefaultValue("EPSG:4326") @QueryParam("crs") String crs, @Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String bboxcrs, @Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String filter, @Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String filterlang, @Parameter(description="A temporal filter expression", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("datetime") String datetime)
Returns a number of features from a given featuretype.
Definition: WebService.java:2379

◆ collectionItemsJSON()

Response collectionItemsJSON ( @Context HttpHeaders  headers,
@Parameter(description="The id of the collection") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format of the result") @DefaultValue("json") @QueryParam("f") String  format,
@Parameter(description="The query limit", style=ParameterStyle.FORM) @DefaultValue("10") @QueryParam("limit") Integer  limit,
@Parameter(description="The offset to consider when fetching items") @DefaultValue("0") @QueryParam("offset") Integer  offset,
@Parameter(description="A bounding box", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("bbox") String  bbox,
@Parameter(description="The styling of the item when returned") @DefaultValue("") @QueryParam("style") String  style,
@Parameter(description="The crs of the data to be returned") @DefaultValue("EPSG:4326") @QueryParam("crs") String  crs,
@Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String  bboxcrs,
@Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String  filter,
@Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String  filterlang,
@Parameter(description="A temporal filter expression") @DefaultValue("") @QueryParam("datetime") String  datetime 
)
2309  :4326") @QueryParam("crs") String crs,
2310  @Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String bboxcrs,
2311  @Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String filter,
2312  @Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String filterlang,
2313  @Parameter(description="A temporal filter expression") @DefaultValue("") @QueryParam("datetime") String datetime) {
2314  return collectionItems(headers,collectionid, format, limit, offset, bbox, style,crs, bboxcrs, filter, filterlang, datetime);
2315  }

◆ collectionItemsXML()

Response collectionItemsXML ( @Context HttpHeaders  headers,
@Parameter(description="The id of the collection") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format of the result") @DefaultValue("gml") @QueryParam("f") String  format,
@Parameter(description="The query limit", style=ParameterStyle.FORM) @DefaultValue("10") @QueryParam("limit") Integer  limit,
@Parameter(description="The offset to consider when fetching items") @DefaultValue("0") @QueryParam("offset") Integer  offset,
@Parameter(description="A bounding box", style=ParameterStyle.FORM) @DefaultValue("") @QueryParam("bbox") String  bbox,
@Parameter(description="The styling of the item when returned") @DefaultValue("") @QueryParam("style") String  style,
@Parameter(description="The crs of the data to be returned") @DefaultValue("EPSG:4326") @QueryParam("crs") String  crs,
@Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String  bboxcrs,
@Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String  filter,
@Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String  filterlang,
@Parameter(description="A temporal filter expression") @DefaultValue("") @QueryParam("datetime") String  datetime 
)
2330  :4326") @QueryParam("crs") String crs,
2331  @Parameter(description="The crs of a given bounding box") @DefaultValue("") @QueryParam("bbox-crs") String bboxcrs,
2332  @Parameter(description="A filter expression") @DefaultValue("") @QueryParam("filter") String filter,
2333  @Parameter(description="The language in which the filter expression is formulated") @DefaultValue("") @QueryParam("filter-lang") String filterlang,
2334  @Parameter(description="A temporal filter expression") @DefaultValue("") @QueryParam("datetime") String datetime) {
2335  return collectionItems(headers,collectionid, format, limit, offset, bbox, style,crs, bboxcrs, filter, filterlang, datetime);
2336  }

◆ collections()

Response collections ( @Parameter(description="Return format", style=ParameterStyle.FORM) @DefaultValue("html") @QueryParam("f") String  format)

Returns a list of feature types/collections.

Parameters
formatThe format in which the result is returned
Returns
The result as String
717  {
718  System.out.println(format);
719  if (format != null && format.contains("json")) {
720  JSONObject result = new JSONObject();
721  JSONArray links = new JSONArray();
722  JSONArray collections = new JSONArray();
723  JSONObject link = new JSONObject();
724  link.put("rel", "self");
725  link.put("title", "This document");
726  link.put("type", "application/json");
727  link.put("href", wfsconf.get("baseurl") + "/collections?f=json");
728  links.put(link);
729  link = new JSONObject();
730  link.put("rel", "alternate");
731  link.put("title", "This document as XML");
732  link.put("type", "text/xml");
733  link.put("href", wfsconf.get("baseurl") + "/collections?f=gml");
734  links.put(link);
735  link = new JSONObject();
736  link.put("rel", "alternate");
737  link.put("title", "This document as HTML");
738  link.put("type", "text/html");
739  link.put("href", wfsconf.get("baseurl") + "/collections?f=html");
740  links.put(link);
741  link = new JSONObject();
742  link.put("rel", "describedBy");
743  link.put("title", "XML Schema for this dataset");
744  link.put("type", "application/xml");
745  link.put("href", "http://www.acme.com/3.0/wfs/collections/schema");
746  links.put(link);
747  result.put("links", links);
748  result.put("collections", collections);
749  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
750  JSONObject coll = new JSONObject();
751  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
752  coll.put("id", curobj.getString("name"));
753  coll.put("name", curobj.getString("name"));
754  coll.put("title", curobj.getString("name"));
755  if(curobj.has("description"))
756  coll.put("description", curobj.getString("description"));
757  /*JSONObject extent = new JSONObject();
758  JSONArray spatial = new JSONArray();
759  JSONArray temporal=new JSONArray();
760  temporal.put("1970-01-01T00:00:00Z");
761  temporal.put("2020-08-22T22:10:44Z");*/
762  JSONArray crs=new JSONArray();
763  crs.put("http://www.opengis.net/def/crs/EPSG/0/"+curobj.getString("targetCRS").substring(curobj.getString("targetCRS").indexOf(":")+1));
764  coll.put("storageCRS", "http://www.opengis.net/def/crs/EPSG/0/"+curobj.getString("targetCRS").substring(curobj.getString("targetCRS").indexOf(":")+1));
765  coll.put("crs",crs);
766  /*coll.put("extent", extent);
767  extent.put("spatial", spatial);
768  extent.put("temporal", temporal);*/
769  JSONArray colinks = new JSONArray();
770  for (ResultFormatter formatter : ResultFormatter.resultMap.values()) {
771  link = new JSONObject();
772  link.put("rel", "item");
773  link.put("href", wfsconf.getString("baseurl") + "/collections/" + curobj.getString("name")
774  + "/items" + "?f=" + formatter.urlformat);
775  link.put("type", formatter.exposedType);
776  link.put("title", curobj.getString("name"));
777  colinks.put(link);
778  }
779  link.put("rel", "self");
780  link.put("title", "This document");
781  link.put("type", "application/json");
782  link.put("href", wfsconf.get("baseurl") + "/collections/"+curobj.getString("name")+"?f=json");
783  colinks.put(link);
784  link = new JSONObject();
785  link.put("rel", "alternate");
786  link.put("title", "This document as XML");
787  link.put("type", "text/xml");
788  link.put("href", wfsconf.get("baseurl") + "/collections/"+curobj.getString("name")+"?f=xml");
789  colinks.put(link);
790  link = new JSONObject();
791  link.put("rel", "alternate");
792  link.put("title", "This document as HTML");
793  link.put("type", "text/html");
794  link.put("href", wfsconf.get("baseurl") + "/collections/"+curobj.getString("name")+"?f=html");
795  colinks.put(link);
796  link = new JSONObject();
797  link.put("rel", "describedBy");
798  link.put("title", "XML Schema for this dataset");
799  link.put("type", "application/xml");
800  link.put("href", "http://www.acme.com/3.0/wfs/collections/"+curobj.getString("name")+"/schema");
801  colinks.put(link);
802  coll.put("links", colinks);
803  collections.put(coll);
804  }
805  return Response.ok(result.toString(2)).type(ResultFormatter.getFormatter(format).mimeType).build();
806  } else if (format != null && format.contains("xml")) {
807  StringWriter strwriter = new StringWriter();
808  XMLOutputFactory output = XMLOutputFactory.newInstance();
809  XMLStreamWriter writer;
810  try {
811  writer = new IndentingXMLStreamWriter(output.createXMLStreamWriter(strwriter));
812  writer.writeStartDocument();
813  writer.setDefaultNamespace("http://www.opengis.net/ogcapi-features-1/1.0");
814  writer.setPrefix("atom", "http://www.w3.org/2005/Atom");
815  writer.writeStartElement("Collections");
816  writer.writeAttribute("xmlns", "http://www.opengis.net/ogcapi-features-1/1.0");
817  writer.writeAttribute("xmlns:atom", "http://www.w3.org/2005/Atom");
818  writer.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
819  writer.writeAttribute("xmlns:sf", "http://www.opengis.net/ogcapi-features-1/1.0/sf");
820  writer.writeAttribute("xmlns:gml", "http://www.opengis.net/gml/3.2");
821  writer.writeAttribute("service", "OGCAPI-FEATURES");
822  writer.writeAttribute("version", "1.0.0");
823  writer.writeStartElement("Title");
824  writer.writeCharacters(wfsconf.getString("servicetitle"));
825  writer.writeEndElement();
826  writer.writeStartElement("Description");
827  writer.writeCharacters(" ");
828  writer.writeEndElement();
829  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
830  writer.writeAttribute("rel", "self");
831  writer.writeAttribute("title", "This document");
832  writer.writeAttribute("type", "text/xml");
833  writer.writeAttribute("href", wfsconf.get("baseurl") + "/collections?f=xml");
834  writer.writeEndElement();
835  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
836  writer.writeAttribute("rel", "alternate");
837  writer.writeAttribute("title", "This document as JSON");
838  writer.writeAttribute("type", "application/json");
839  writer.writeAttribute("href", wfsconf.get("baseurl") + "/collections?f=json");
840  writer.writeEndElement();
841  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
842  writer.writeAttribute("rel", "alternate");
843  writer.writeAttribute("title", "This document as HTML");
844  writer.writeAttribute("type", "application/json");
845  writer.writeAttribute("href", wfsconf.get("baseurl") + "/collections?f=html");
846  writer.writeEndElement();
847  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
848  writer.writeAttribute("rel", "describedBy");
849  writer.writeAttribute("title", "XML Schema for this dataset");
850  writer.writeAttribute("type", "application/xml");
851  writer.writeAttribute("href", "http://www.acme.com/3.0/wfs/collections/schema");
852  writer.writeEndElement();
853  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
854  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
855  writer.writeStartElement("Collection");
856  writer.writeStartElement("Id");
857  writer.writeCharacters(curobj.getString("name"));
858  writer.writeEndElement();
859  writer.writeStartElement("Title");
860  writer.writeCharacters(curobj.getString("name"));
861  writer.writeEndElement();
862  writer.writeStartElement("Description");
863  if(curobj.has("description"))
864  writer.writeCharacters(curobj.getString("description"));
865  else {
866  writer.writeCharacters("");
867  }
868  writer.writeEndElement();
869  for (ResultFormatter formatter : ResultFormatter.resultMap.values()) {
870  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
871  writer.writeAttribute("rel", "items");
872  writer.writeAttribute("title", curobj.getString("name"));
873  writer.writeAttribute("type", formatter.exposedType);
874  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/collections/"
875  + curobj.getString("name") + "/items?f=" + formatter.exposedType);
876  writer.writeEndElement();
877  }
878  writer.writeEndElement();
879  /*writer.writeStartElement("Extent");
880  writer.writeStartElement("Spatial");
881  writer.writeAttribute("crs", "http://www.opengis.net/def/crs/OGC/1.3/CRS84");
882  writer.writeEndElement();
883  writer.writeEndElement();*/
884  }
885  writer.writeEndElement();
886  writer.writeEndDocument();
887  writer.flush();
888  return Response.ok(strwriter.toString()).type(ResultFormatter.getFormatter(format).mimeType).build();
889  } catch (XMLStreamException e) {
890  // TODO Auto-generated catch block
891  e.printStackTrace();
892  return this.createExceptionResponse(e, "");
893  }
894  } else if (format == null || format.contains("html")) {
895  StringBuilder builder = new StringBuilder();
896  builder.append(htmlHead);
897  builder.append("<header id=\"header\"><div class=\"page-header\"><h1 align=center>");
898  builder.append("FeatureCollection View");
899  builder.append("</h1></div></header>");
900  builder.append("<div class=\"sticky row crumbs\"><div class=\"col-sm-12 col-md-10 col-md-offset-1\">");
901  builder.append("<a href=\""+wfsconf.getString("baseurl")+"\">Landingpage</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/\">Collections</a>");
902  builder.append("</div></div>");
903  builder.append(
904  "<div class=\"container-fluid\" role=\"main\"><div class=\"row\"><div class=\"col-sm-12\"><table class=\"description\" id=\"collectiontable\" width=100% border=1><thead><tr><th>Collection</th><th>Description</th><th>Schema</th></tr></thead><tbody>");
905  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
906  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
907  if(i%2==0){
908  builder.append("<tr class=\"even\">");
909  }else{
910  builder.append("<tr class=\"odd\">");
911  }
912  builder.append("<td align=center><a href=\"" + wfsconf.getString("baseurl") + "/collections/"
913  + wfsconf.getJSONArray("datasets").getJSONObject(i).get("name") + "?f=html\">"
914  + wfsconf.getJSONArray("datasets").getJSONObject(i).get("name") + "</a></td><td align=center>");
915  if (wfsconf.getJSONArray("datasets").getJSONObject(i).has("description")) {
916  builder.append(wfsconf.getJSONArray("datasets").getJSONObject(i).get("description"));
917  }
918  builder.append("</td><td align=center>");
919  if (wfsconf.getJSONArray("datasets").getJSONObject(i).has("schema")) {
920  builder.append("<a href=\"" + wfsconf.getJSONArray("datasets").getJSONObject(i).get("schema")
921  + "\" target=\"_blank\">[Schema]</a>");
922  } else {
923  builder.append("<a href=\"" + wfsconf.getString("baseurl") + "/collections/"
924  + curobj.getString("name") + "/schema\" target=\"_blank\">[XML Schema]</a><br/>");
925  builder.append("<a href=\"" + wfsconf.getString("baseurl") + "/collections/"
926  + curobj.getString("name") + "/schema?f=json\" target=\"_blank\">[JSON Schema]</a>");
927  }
928  /*builder.append("</td><td align=center>");
929  Integer counter = 0;
930  for (ResultFormatter formatter : ResultFormatter.resultMap.values()) {
931  if (counter % 4 == 0) {
932  builder.append("<br>");
933  }
934  builder.append("<a href=\"" + wfsconf.getString("baseurl") + "/collections/"
935  + curobj.getString("name") + "/items?f=" + formatter.exposedType + "\">["
936  + formatter.exposedType.toUpperCase() + "]</a>&nbsp;&nbsp;");
937  counter++;
938  }*/
939  builder.append("</td></tr>");
940  }
941  builder.append("</tbody></table>");
942  builder.append("</div></div></div><footer id=\"footer\"><table width=100%><tbody><tr><td><a href=\"" + wfsconf.getString("baseurl")
943  + "/?f=html\">Back to LandingPage</a></td><td align=right>This page in <a href=\""
944  + wfsconf.getString("baseurl") + "/collections?f=gml\">[XML]</a> <a href=\""
945  + wfsconf.getString("baseurl")
946  + "/collections?f=json\">[JSON]</a></td></tr></table></footer><script>$('#collectiontable').DataTable();</script></body></html>");
947  return Response.ok(builder.toString()).type(ResultFormatter.getFormatter(format).mimeType).build();
948  } else {
949  throw new NotFoundException();
950  }
951  }

References ResultFormatter.getFormatter(), ResultFormatter.mimeType, and ResultFormatter.resultMap.

◆ collectionsHTML()

Response collectionsHTML ( @Parameter(description="Return format") @DefaultValue("html") @QueryParam("f") String  format)
701  {
702  return collections(format);
703  }

◆ collectionsJSON()

Response collectionsJSON ( @Parameter(description="Return format") @DefaultValue("json") @QueryParam("f") String  format)
679  {
680  return collections(format);
681  }

◆ collectionsXML()

Response collectionsXML ( @Parameter(description="Return format") @DefaultValue("xml") @QueryParam("f") String  format)
690  {
691  return collections(format);
692  }

◆ conformance()

Response conformance ( @Parameter(description="The format of the conformance page") @DefaultValue("html") @QueryParam("f") String  format)

Gets conformance information about the OGC API Features service.

Parameters
formatThe return format for the conformance declaration
Returns
The conformance declaration as String
2672  {
2673  if (format != null && format.contains("json")) {
2674  JSONObject result = new JSONObject();
2675  JSONArray conforms = new JSONArray();
2676  conforms.put("http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core");
2677  conforms.put("http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30");
2678  conforms.put("http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/html");
2679  conforms.put("http://www.opengis.net/spec/ogcapi-features-2/1.0/conf/crs");
2680  conforms.put("http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson");
2681  conforms.put("http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/gmlsf0");
2682  result.put("conformsTo", conforms);
2683  return Response.ok(result.toString(2)).type(MediaType.APPLICATION_JSON).build();
2684  } else if (format != null && format.contains("xml")) {
2685  StringWriter strwriter = new StringWriter();
2686  XMLOutputFactory output = XMLOutputFactory.newInstance();
2687  XMLStreamWriter writer;
2688  try {
2689  writer = new IndentingXMLStreamWriter(output.createXMLStreamWriter(strwriter));
2690  writer.writeStartDocument();
2691  writer.setDefaultNamespace("http://www.opengis.net/ogcapi-features-1/1.0");
2692  writer.writeStartElement("ConformsTo");
2693  writer.writeAttribute("service", "OGCAPI-FEATURES");
2694  writer.writeAttribute("version", "1.0.0");
2695  writer.writeNamespace(null, "http://www.opengis.net/ogcapi-features-1/1.0");
2696  writer.writeNamespace("atom", "http://www.w3.org/2005/Atom");
2697  writer.writeNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
2698  writer.writeAttribute("xsi:schemaLocation",
2699  "http://www.opengis.net/ogcapi-features-1/1.0../../xml/core.xsd");
2700  writer.writeStartElement("atom:link");
2701  writer.writeAttribute("href", "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core");
2702  writer.writeEndElement();
2703  writer.writeStartElement("atom:link");
2704  writer.writeAttribute("href", "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30");
2705  writer.writeEndElement();
2706  writer.writeStartElement("atom:link");
2707  writer.writeAttribute("href", "http://www.opengis.net/spec/ogcapi-features-2/1.0/conf/crs");
2708  writer.writeEndElement();
2709  writer.writeStartElement("atom:link");
2710  writer.writeAttribute("href", "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/html");
2711  writer.writeEndElement();
2712  writer.writeStartElement("atom:link");
2713  writer.writeAttribute("href", "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson");
2714  writer.writeEndElement();
2715  writer.writeStartElement("atom:link");
2716  writer.writeAttribute("href", "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/gmlsf0");
2717  writer.writeEndElement();
2718  writer.writeEndElement();
2719  writer.writeEndDocument();
2720  writer.flush();
2721  return Response.ok(strwriter.toString()).type(MediaType.APPLICATION_XML).build();
2722  } catch (XMLStreamException e) {
2723  e.printStackTrace();
2724  return this.createExceptionResponse(e, "");
2725  }
2726  } else if (format == null || format.contains("html")) {
2727  StringBuilder builder = new StringBuilder();
2728  builder.append("<html><head>" + htmlHead
2729  + "</head><body><header id=\"header\"><h1 align=\"center\">Conformance</h1></header><div class=\"container-fluid\" role=\"main\"><div class=\"row\"><div class=\"col-sm-12\"><ul>");
2730  builder.append(
2731  "<li><a target=\"_blank\" href=\"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core\">Core</a></li>");
2732  builder.append(
2733  "<li><a target=\"_blank\" href=\"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30\">Oas30</a></li>");
2734  builder.append(
2735  "<li><a target=\"_blank\" href=\"http://www.opengis.net/spec/ogcapi-features-2/1.0/conf/crs\">Crs</a></li>");
2736  builder.append(
2737  "<li><a target=\"_blank\" href=\"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/html\">HTML</a></li>");
2738  builder.append(
2739  "<li><a target=\"_blank\" href=\"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson\">GeoJSON</a></li>");
2740  builder.append(
2741  "<li><a target=\"_blank\" href=\"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/gmlsf0\">GMLSf0</a></li>");
2742  builder.append("</ul></div></div></div><footer id=\"footer\"><table width=\"100%\"><tbody><tr><td><a href=\"" + wfsconf.getString("baseurl")
2743  + "/?f=html\">Back to LandingPage</a></td><td align=right>This page in <a href=\""
2744  + wfsconf.getString("baseurl") + "/conformance?f=gml\">[GML]</a> <a href=\"" + wfsconf.getString("baseurl")
2745  + "/conformance?f=geojson\">[JSON]</a></td></tr></tbody></table></footer></body></html>");
2746  return Response.ok(builder.toString()).type(MediaType.TEXT_HTML).build();
2747  } else {
2748  throw new NotFoundException();
2749  }
2750 
2751  }

◆ conformanceHTML()

Response conformanceHTML ( @Parameter(description="The format of the conformance page") @DefaultValue("html") @QueryParam("f") String  format)
2657  {
2658  return conformance(format);
2659  }
Response conformance(@Parameter(description="The format of the conformance page") @DefaultValue("html") @QueryParam("f") String format)
Gets conformance information about the OGC API Features service.
Definition: WebService.java:2672

◆ conformanceJSON()

Response conformanceJSON ( @Parameter(description="The format of the conformance page") @DefaultValue("json") @QueryParam("f") String  format)
2637  {
2638  return conformance(format);
2639  }

◆ conformanceXML()

Response conformanceXML ( @Parameter(description="The format of the conformance page") @DefaultValue("xml") @QueryParam("f") String  format)
2647  {
2648  return conformance(format);
2649  }

◆ constructCapabilities()

Response constructCapabilities ( String  version,
String  versionnamespace 
) throws XMLStreamException

Constructs a capabilities document for a WFS in version 1.1 .

Parameters
versionThe version of the WFS service
versionnamespaceThe namespace to use
Returns
The capabilities document as String
Exceptions
XMLStreamExceptionon error
3061  {
3062  String serviceType = "WFS";
3063  String owsns = "http://www.opengis.net/ows/1.1";
3064  if ("1.0.0".equals(version))
3065  return constructCapabilitiesWFS10(version, versionnamespace);
3066  if ("1.0.0".equals(version) || "1.1.0".equals(version)) {
3067  versionnamespace = "";
3068  } else {
3069  versionnamespace = "/" + versionnamespace;
3070  }
3071  XMLOutputFactory factory = XMLOutputFactory.newInstance();
3072  StringWriter strwriter = new StringWriter();
3073  XMLStreamWriter xmlwriter = factory.createXMLStreamWriter(strwriter);
3074  IndentingXMLStreamWriter writer = new IndentingXMLStreamWriter(xmlwriter);
3075  writer.writeStartDocument();
3076  writer.writeStartElement("WFS_Capabilities");
3077  writer.setPrefix("wfs", "http://www.opengis.net/wfs" + versionnamespace);
3078  writer.writeDefaultNamespace("http://www.opengis.net/wfs" + versionnamespace);
3079  writer.writeAttribute("version", version);
3080  writer.writeNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
3081  writer.writeNamespace("wfs", "http://www.opengis.net/wfs" + versionnamespace);
3082  writer.writeNamespace("ows", "http://www.opengis.net/ows/1.1");
3083  writer.writeNamespace("sf", "http://www.opengis.net/ogcapi-features-1/1.0/sf");
3084  writer.writeNamespace("ogc", "http://www.opengis.net/ogc");
3085  writer.writeNamespace("fes", "http://www.opengis.net/fes" + versionnamespace);
3086  writer.writeNamespace("gml", "http://www.opengis.net/gml");
3087  writer.writeNamespace("xlink", "http://www.w3.org/1999/xlink");
3088  writer.writeAttribute("xsi:schemaLocation", "http://www.opengis.net/wfs" + versionnamespace+" http://schemas.opengis.net/wfs/"+versionnamespace+"/wfs.xsd http://inspire.ec.europa.eu/schemas/inspire_dls/1.0 http://inspire.ec.europa.eu/schemas/inspire_dls/1.0/inspire_dls.xsd");
3089  // ServiceInformation
3090  writer.writeStartElement(owsns, "ServiceIdentification");
3091  writer.writeStartElement(owsns, "ServiceType");
3092  writer.writeAttribute("codeSpace", "OGC");
3093  writer.writeCharacters(serviceType);
3094  writer.writeEndElement();
3095  writer.writeStartElement(owsns, "ServiceTypeVersion");
3096  writer.writeCharacters(version);
3097  writer.writeEndElement();
3098  writer.writeStartElement(owsns, "Title");
3099  writer.writeCharacters(wfsconf.has("servicetitle") ? wfsconf.getString("servicetitle") : "");
3100  writer.writeEndElement();
3101  writer.writeStartElement(owsns, "Fees");
3102  writer.writeCharacters(wfsconf.has("fees") ? wfsconf.getString("fees") : "none");
3103  writer.writeEndElement();
3104  writer.writeStartElement(owsns, "Abstract");
3105  writer.writeCharacters(wfsconf.has("abstract") ? wfsconf.getString("abstract") : "");
3106  writer.writeEndElement();
3107  writer.writeEndElement();
3108  writer.writeStartElement(owsns, "OperationsMetadata");
3109  writer.writeStartElement(owsns, "Operation");
3110  writer.writeAttribute("name", "GetCapabilities");
3111  writer.writeStartElement(owsns, "DCP");
3112  writer.writeStartElement(owsns, "HTTP");
3113  writer.writeStartElement(owsns, "Get");
3114  writer.writeAttribute("xlink:type", "simple");
3115  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/wfs?");
3116  writer.writeEndElement();
3117  writer.writeStartElement(owsns, "Post");
3118  writer.writeAttribute("xlink:type", "simple");
3119  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/wfs");
3120  writer.writeEndElement();
3121  writer.writeEndElement();
3122  writer.writeStartElement(owsns, "Parameter");
3123  writer.writeAttribute("name", "AcceptVersions");
3124  writer.writeStartElement(owsns, "AllowedValues");
3125  writer.writeStartElement(owsns, "Value");
3126  writer.writeCharacters(version);
3127  writer.writeEndElement();
3128  writer.writeEndElement();
3129  writer.writeEndElement();
3130  writer.writeEndElement();
3131  writer.writeEndElement();
3132  writer.writeStartElement(owsns, "Operation");
3133  writer.writeAttribute("name", "GetPropertyValue");
3134  writer.writeStartElement(owsns, "DCP");
3135  writer.writeStartElement(owsns, "HTTP");
3136  writer.writeStartElement(owsns, "Get");
3137  writer.writeAttribute("xlink:type", "simple");
3138  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/wfs?");
3139  writer.writeEndElement();
3140  writer.writeStartElement(owsns, "Post");
3141  writer.writeAttribute("xlink:type", "simple");
3142  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/wfs");
3143  writer.writeEndElement();
3144  writer.writeEndElement();
3145  writer.writeEndElement();
3146  writer.writeEndElement();
3147  writer.writeStartElement(owsns, "Operation");
3148  writer.writeAttribute("name", "DescribeFeatureType");
3149  writer.writeStartElement(owsns, "DCP");
3150  writer.writeStartElement(owsns, "HTTP");
3151  writer.writeStartElement(owsns, "Get");
3152  writer.writeAttribute("xlink:type", "simple");
3153  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/wfs?");
3154  writer.writeEndElement();
3155  writer.writeStartElement(owsns, "Post");
3156  writer.writeAttribute("xlink:type", "simple");
3157  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/wfs");
3158  writer.writeEndElement();
3159  writer.writeEndElement();
3160  writer.writeEndElement();
3161  writer.writeEndElement();
3162  writer.writeStartElement(owsns, "Operation");
3163  writer.writeAttribute("name", "GetGmlObject");
3164  writer.writeStartElement(owsns, "DCP");
3165  writer.writeStartElement(owsns, "HTTP");
3166  writer.writeStartElement(owsns, "Get");
3167  writer.writeAttribute("xlink:type", "simple");
3168  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/wfs?");
3169  writer.writeEndElement();
3170  writer.writeStartElement(owsns, "Post");
3171  writer.writeAttribute("xlink:type", "simple");
3172  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/wfs");
3173  writer.writeEndElement();
3174  writer.writeEndElement();
3175  writer.writeEndElement();
3176  writer.writeEndElement();
3177  writer.writeStartElement(owsns, "Operation");
3178  writer.writeAttribute("name", "GetFeature");
3179  writer.writeStartElement(owsns, "DCP");
3180  writer.writeStartElement(owsns, "HTTP");
3181  writer.writeStartElement(owsns, "Get");
3182  writer.writeAttribute("xlink:type", "simple");
3183  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/wfs?");
3184  writer.writeEndElement();
3185  writer.writeStartElement(owsns, "Post");
3186  writer.writeAttribute("xlink:type", "simple");
3187  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/wfs");
3188  writer.writeEndElement();
3189  writer.writeEndElement();
3190  writer.writeStartElement(owsns, "Parameter");
3191  writer.writeAttribute("name", "AcceptVersions");
3192  writer.writeStartElement(owsns, "AllowedValues");
3193  writer.writeStartElement(owsns, "Value");
3194  writer.writeCharacters(version);
3195  writer.writeEndElement();
3196  writer.writeEndElement();
3197  writer.writeEndElement();
3198  writer.writeEndElement();
3199  writer.writeEndElement();
3200  writer.writeStartElement(owsns,"Constraint");
3201  writer.writeAttribute("name", "ImplementsBasicWFS");
3202  writer.writeStartElement(owsns,"DefaultValue");
3203  writer.writeCharacters("TRUE");
3204  writer.writeEndElement();
3205  writer.writeEndElement();
3206  writer.writeStartElement(owsns,"Constraint");
3207  writer.writeAttribute("name", "ImplementsTransactionalWFS");
3208  writer.writeStartElement(owsns,"DefaultValue");
3209  writer.writeCharacters("TRUE");
3210  writer.writeEndElement();
3211  writer.writeEndElement();
3212  writer.writeStartElement(owsns,"Constraint");
3213  writer.writeAttribute("name", "KVPEncoding");
3214  writer.writeStartElement(owsns,"DefaultValue");
3215  writer.writeCharacters("TRUE");
3216  writer.writeEndElement();
3217  writer.writeEndElement();
3218  writer.writeStartElement(owsns,"Constraint");
3219  writer.writeAttribute("name", "ImplementsAdHocQuery");
3220  writer.writeStartElement(owsns,"DefaultValue");
3221  writer.writeCharacters("TRUE");
3222  writer.writeEndElement();
3223  writer.writeEndElement();
3224  writer.writeStartElement(owsns,"Constraint");
3225  writer.writeAttribute("name", "ImplementsResourceId");
3226  writer.writeStartElement(owsns,"DefaultValue");
3227  writer.writeCharacters("TRUE");
3228  writer.writeEndElement();
3229  writer.writeEndElement();
3230  writer.writeStartElement(owsns,"Constraint");
3231  writer.writeAttribute("name", "ImplementsMinStandardFilter");
3232  writer.writeStartElement(owsns,"DefaultValue");
3233  writer.writeCharacters("TRUE");
3234  writer.writeEndElement();
3235  writer.writeEndElement();
3236  writer.writeStartElement(owsns,"Constraint");
3237  writer.writeAttribute("name", "ImplementsMinTemporalFilter");
3238  writer.writeStartElement(owsns,"DefaultValue");
3239  writer.writeCharacters("TRUE");
3240  writer.writeEndElement();
3241  writer.writeEndElement();
3242  writer.writeStartElement(owsns,"Constraint");
3243  writer.writeAttribute("name", "ImplementsMinimumXPath");
3244  writer.writeStartElement(owsns,"DefaultValue");
3245  writer.writeCharacters("TRUE");
3246  writer.writeEndElement();
3247  writer.writeEndElement();
3248  writer.writeStartElement(owsns,"Constraint");
3249  writer.writeAttribute("name", "ImplementsResultPaging");
3250  writer.writeStartElement(owsns,"DefaultValue");
3251  writer.writeCharacters("TRUE");
3252  writer.writeEndElement();
3253  writer.writeEndElement();
3254  writer.writeEndElement();
3255  writer.writeStartElement("http://www.opengis.net/wfs" + versionnamespace, "FeatureTypeList");
3256  writer.writeStartElement("http://www.opengis.net/wfs" + versionnamespace, "Operations");
3257  writer.writeStartElement("http://www.opengis.net/wfs" + versionnamespace, "Operation");
3258  writer.writeCharacters("Query");
3259  writer.writeEndElement();
3260  writer.writeEndElement();
3261  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
3262  describeFeatureType(writer, wfsconf.getJSONArray("datasets").getJSONObject(i), versionnamespace, version);
3263  }
3264  writer.writeEndElement();
3265  writer.writeStartElement("http://www.opengis.net/fes" + versionnamespace, "Filter_Capabilities");
3266  describeConformance(writer,versionnamespace,"http://www.opengis.net/fes"+versionnamespace);
3267  describeSpatialCapabilities(writer, versionnamespace, "http://www.opengis.net/fes" + versionnamespace);
3268  describeScalarCapabilities(writer, versionnamespace, "http://www.opengis.net/fes" + versionnamespace);
3269  writer.writeEndElement();
3270  writer.writeEndElement();
3271  writer.writeEndElement();
3272  writer.writeEndDocument();
3273  return Response.ok(strwriter.toString()).type(MediaType.APPLICATION_XML).build();
3274  }
Response constructCapabilitiesWFS10(String version, String versionnamespace)
Constructs a capabilities document for a WFS in version 1.0 .
Definition: WebService.java:2764
void describeFeatureType(XMLStreamWriter writer, JSONObject featuretype, String versionnamespace, String version)
Creates a feature type description.
Definition: WebService.java:3449
void describeConformance(IndentingXMLStreamWriter writer, String versionnamespace, String namespace)
Describes the conformance part of a WFS webservices.
Definition: WebService.java:3283
void describeScalarCapabilities(XMLStreamWriter writer, String versionnamespace, String namespace)
Writes the scalar capabilities document for a WFS.
Definition: WebService.java:3600
void describeSpatialCapabilities(XMLStreamWriter writer, String versionnamespace, String namespace)
Writes the spatial capabilities part of the WFS document.
Definition: WebService.java:3501
XMLStreamWriter xmlwriter
Definition: WebService.java:108

◆ constructCapabilitiesCSW()

Response constructCapabilitiesCSW ( String  version,
String  versionnamespace 
) throws XMLStreamException

Constructs a capabilities document for a CSW service .

Parameters
versionThe version of the WFS service
versionnamespaceThe namespace to use
Returns
The capabilities document as String
Exceptions
XMLStreamExceptionon error
2905  {
2906  String serviceType = "CSW";
2907  String owsns = "http://www.opengis.net/ows/1.1";
2908  XMLOutputFactory factory = XMLOutputFactory.newInstance();
2909  StringWriter strwriter = new StringWriter();
2910  XMLStreamWriter xmlwriter;
2911  xmlwriter = factory.createXMLStreamWriter(strwriter);
2912  IndentingXMLStreamWriter writer = new IndentingXMLStreamWriter(xmlwriter);
2913  writer.writeStartDocument();
2914  writer.setPrefix("csw", "http://www.opengis.net/cat/csw/" + versionnamespace);
2915  writer.writeStartElement("http://www.opengis.net/cat/csw/" + versionnamespace, "Capabilities");
2916  writer.writeDefaultNamespace("http://www.opengis.net/wfs" + versionnamespace);
2917  writer.writeAttribute("version", version);
2918  writer.writeNamespace("csw", "http://www.opengis.net/cat/csw/" + versionnamespace);
2919  writer.writeNamespace("wfs", "http://www.opengis.net/wfs" + versionnamespace);
2920  writer.writeNamespace("ows", "http://www.opengis.net/ows/1.1");
2921  writer.writeNamespace("sf", "http://www.opengis.net/ogcapi-features-1/1.0/sf");
2922  writer.writeNamespace("ogc", "http://www.opengis.net/ogc");
2923  writer.writeNamespace("fes", "http://www.opengis.net/fes" + versionnamespace);
2924  writer.writeNamespace("gml", "http://www.opengis.net/gml");
2925  writer.writeNamespace("xlink", "http://www.w3.org/1999/xlink");
2926  writer.writeStartElement(owsns, "ServiceIdentification");
2927  writer.writeStartElement(owsns, "ServiceType");
2928  writer.writeAttribute("codeSpace", "OGC");
2929  writer.writeCharacters(serviceType);
2930  writer.writeEndElement();
2931  writer.writeStartElement(owsns, "ServiceTypeVersion");
2932  writer.writeCharacters(version);
2933  writer.writeEndElement();
2934  writer.writeStartElement(owsns, "Title");
2935  writer.writeCharacters(
2936  wfsconf.has("servicetitle") ? wfsconf.getString("servicetitle").replace("WFS", "CSW") : "");
2937  writer.writeEndElement();
2938  writer.writeStartElement(owsns, "Fees");
2939  writer.writeCharacters(wfsconf.has("fees") ? wfsconf.getString("fees") : "none");
2940  writer.writeEndElement();
2941  writer.writeStartElement(owsns, "Abstract");
2942  writer.writeCharacters(wfsconf.has("abstract") ? wfsconf.getString("abstract") : "");
2943  writer.writeEndElement();
2944  writer.writeEndElement();
2945  writer.writeStartElement(owsns, "OperationsMetadata");
2946  writer.writeStartElement(owsns, "Operation");
2947  writer.writeAttribute("name", "GetCapabilities");
2948  writer.writeStartElement(owsns, "DCP");
2949  writer.writeStartElement(owsns, "HTTP");
2950  writer.writeStartElement(owsns, "Get");
2951  writer.writeAttribute("xlink:type", "simple");
2952  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/csw?");
2953  writer.writeEndElement();
2954  writer.writeStartElement(owsns, "Post");
2955  writer.writeAttribute("xlink:type", "simple");
2956  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/csw");
2957  writer.writeEndElement();
2958  writer.writeEndElement();
2959  writer.writeStartElement(owsns, "Parameter");
2960  writer.writeAttribute("name", "sections");
2961  writer.writeStartElement(owsns, "Value");
2962  writer.writeCharacters("ServiceIdentification");
2963  writer.writeEndElement();
2964  writer.writeStartElement(owsns, "Value");
2965  writer.writeCharacters("ServiceProvider");
2966  writer.writeEndElement();
2967  writer.writeStartElement(owsns, "Value");
2968  writer.writeCharacters("OperationsMetadata");
2969  writer.writeEndElement();
2970  writer.writeStartElement(owsns, "Value");
2971  writer.writeCharacters("Filter_Capabilities");
2972  writer.writeEndElement();
2973  writer.writeEndElement();
2974  writer.writeEndElement();
2975  writer.writeEndElement();
2976  writer.writeStartElement(owsns, "Operation");
2977  writer.writeAttribute("name", "DescribeRecord");
2978  writer.writeStartElement(owsns, "DCP");
2979  writer.writeStartElement(owsns, "HTTP");
2980  writer.writeStartElement(owsns, "Get");
2981  writer.writeAttribute("xlink:type", "simple");
2982  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/csw?");
2983  writer.writeEndElement();
2984  writer.writeStartElement(owsns, "Post");
2985  writer.writeAttribute("xlink:type", "simple");
2986  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/csw");
2987  writer.writeEndElement();
2988  writer.writeEndElement();
2989  writer.writeEndElement();
2990  writer.writeEndElement();
2991  writer.writeStartElement(owsns, "Operation");
2992  writer.writeAttribute("name", "GetRecords");
2993  writer.writeStartElement(owsns, "DCP");
2994  writer.writeStartElement(owsns, "HTTP");
2995  writer.writeStartElement(owsns, "Get");
2996  writer.writeAttribute("xlink:type", "simple");
2997  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/csw?");
2998  writer.writeEndElement();
2999  writer.writeStartElement(owsns, "Post");
3000  writer.writeAttribute("xlink:type", "simple");
3001  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/csw");
3002  writer.writeEndElement();
3003  writer.writeEndElement();
3004  writer.writeEndElement();
3005  writer.writeEndElement();
3006  writer.writeStartElement(owsns, "Operation");
3007  writer.writeAttribute("name", "GetRecordById");
3008  writer.writeStartElement(owsns, "DCP");
3009  writer.writeStartElement(owsns, "HTTP");
3010  writer.writeStartElement(owsns, "Get");
3011  writer.writeAttribute("xlink:type", "simple");
3012  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/csw?");
3013  writer.writeEndElement();
3014  writer.writeStartElement(owsns, "Post");
3015  writer.writeAttribute("xlink:type", "simple");
3016  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/csw");
3017  writer.writeEndElement();
3018  writer.writeEndElement();
3019  writer.writeEndElement();
3020  writer.writeEndElement();
3021  writer.writeStartElement(owsns, "Operation");
3022  writer.writeAttribute("name", "Harvest");
3023  writer.writeStartElement(owsns, "DCP");
3024  writer.writeStartElement(owsns, "HTTP");
3025  writer.writeStartElement(owsns, "Get");
3026  writer.writeAttribute("xlink:type", "simple");
3027  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/csw?");
3028  writer.writeEndElement();
3029  writer.writeStartElement(owsns, "Post");
3030  writer.writeAttribute("xlink:type", "simple");
3031  writer.writeAttribute("xlink:href", wfsconf.getString("baseurl") + "/csw");
3032  writer.writeEndElement();
3033  writer.writeEndElement();
3034  writer.writeStartElement(owsns, "Parameter");
3035  writer.writeAttribute("name", "AcceptVersions");
3036  writer.writeStartElement(owsns, "AllowedValues");
3037  writer.writeStartElement(owsns, "Value");
3038  writer.writeCharacters(version);
3039  writer.writeEndElement();
3040  writer.writeEndElement();
3041  writer.writeEndElement();
3042  writer.writeEndElement();
3043  writer.writeEndElement();
3044  writer.writeEndElement();
3045  writer.writeStartElement("http://www.opengis.net/fes" + versionnamespace, "Filter_Capabilities");
3046  describeConformance(writer, versionnamespace, "http://www.opengis.net/fes" + versionnamespace);
3047  describeSpatialCapabilities(writer, versionnamespace, "http://www.opengis.net/fes" + versionnamespace);
3048  describeScalarCapabilities(writer, versionnamespace, "http://www.opengis.net/fes" + versionnamespace);
3049  writer.writeEndElement();
3050  writer.writeEndDocument();
3051  return Response.ok(strwriter.toString()).type(MediaType.APPLICATION_XML).build();
3052  }

◆ constructCapabilitiesWFS10()

Response constructCapabilitiesWFS10 ( String  version,
String  versionnamespace 
) throws XMLStreamException

Constructs a capabilities document for a WFS in version 1.0 .

Parameters
versionThe version of the WFS service
versionnamespaceThe namespace to use
Returns
The capabilities document as String
Exceptions
XMLStreamExceptionon error
2764  {
2765  XMLOutputFactory factory = XMLOutputFactory.newInstance();
2766  StringWriter strwriter = new StringWriter();
2767  XMLStreamWriter xmlwriter = factory.createXMLStreamWriter(strwriter);
2768  IndentingXMLStreamWriter writer = new IndentingXMLStreamWriter(xmlwriter);
2769  writer.writeStartDocument();
2770  writer.writeStartElement("WFS_Capabilities");
2771  writer.setPrefix("wfs", "http://www.opengis.net/wfs");
2772  writer.writeDefaultNamespace("http://www.opengis.net/wfs");
2773  writer.writeAttribute("version", version);
2774  writer.writeNamespace("wfs", "http://www.opengis.net/wfs");
2775  writer.writeNamespace("ows", "http://www.opengis.net/ows/1.1");
2776  writer.writeNamespace("ogc", "http://www.opengis.net/ogc");
2777  writer.writeNamespace("gml", "http://www.opengis.net/gml");
2778  writer.writeNamespace("xlink", "http://www.w3.org/1999/xlink");
2779  writer.writeStartElement("Service");
2780  writer.writeStartElement("Name");
2781  writer.writeCharacters(wfsconf.has("servicetitle") ? wfsconf.getString("servicetitle") : "");
2782  writer.writeEndElement();
2783  writer.writeStartElement("Title");
2784  writer.writeCharacters(wfsconf.has("servicetitle") ? wfsconf.getString("servicetitle") : "");
2785  writer.writeEndElement();
2786  writer.writeStartElement("Abstract");
2787  writer.writeCharacters(wfsconf.has("abstract") ? wfsconf.getString("abstract") : "");
2788  writer.writeEndElement();
2789  writer.writeStartElement("Fees");
2790  writer.writeCharacters(wfsconf.has("fees") ? wfsconf.getString("fees") : "none");
2791  writer.writeEndElement();
2792  writer.writeStartElement("OnlineResource");
2793  writer.writeCharacters(wfsconf.has("baseurl") ? wfsconf.getString("baseurl") : "");
2794  writer.writeEndElement();
2795  writer.writeEndElement();
2796  writer.writeStartElement("Capability");
2797  writer.writeStartElement("Request");
2798  writer.writeStartElement("GetCapabilities");
2799  writer.writeStartElement("DCPType");
2800  writer.writeStartElement("HTTP");
2801  writer.writeStartElement("Get");
2802  writer.writeAttribute("onlineResource", wfsconf.getString("baseurl") + "/wfs?");
2803  writer.writeEndElement();
2804  writer.writeStartElement("Post");
2805  writer.writeAttribute("onlineResource", wfsconf.getString("baseurl") + "/wfs");
2806  writer.writeEndElement();
2807  writer.writeEndElement();
2808  writer.writeEndElement();
2809  writer.writeEndElement();
2810  writer.writeStartElement("GetGmlObject");
2811  writer.writeStartElement("DCPType");
2812  writer.writeStartElement("HTTP");
2813  writer.writeStartElement("Get");
2814  writer.writeAttribute("onlineResource", wfsconf.getString("baseurl") + "/wfs?");
2815  writer.writeEndElement();
2816  writer.writeStartElement("Post");
2817  writer.writeAttribute("onlineResource", wfsconf.getString("baseurl") + "/wfs");
2818  writer.writeEndElement();
2819  writer.writeEndElement();
2820  writer.writeEndElement();
2821  writer.writeEndElement();
2822  writer.writeStartElement("GetPropertyValue");
2823  writer.writeStartElement("DCPType");
2824  writer.writeStartElement("HTTP");
2825  writer.writeStartElement("Get");
2826  writer.writeAttribute("onlineResource", wfsconf.getString("baseurl") + "/wfs?");
2827  writer.writeEndElement();
2828  writer.writeStartElement("Post");
2829  writer.writeAttribute("onlineResource", wfsconf.getString("baseurl") + "/wfs");
2830  writer.writeEndElement();
2831  writer.writeEndElement();
2832  writer.writeEndElement();
2833  writer.writeEndElement();
2834  writer.writeStartElement("DescribeFeatureType");
2835  writer.writeStartElement("SchemaDescriptionLanguage");
2836  writer.writeStartElement("XMLSCHEMA");
2837  writer.writeEndElement();
2838  writer.writeEndElement();
2839  writer.writeStartElement("DCPType");
2840  writer.writeStartElement("HTTP");
2841  writer.writeStartElement("Get");
2842  writer.writeAttribute("onlineResource", wfsconf.getString("baseurl") + "/wfs?");
2843  writer.writeEndElement();
2844  writer.writeStartElement("Post");
2845  writer.writeAttribute("onlineResource", wfsconf.getString("baseurl") + "/wfs");
2846  writer.writeEndElement();
2847  writer.writeEndElement();
2848  writer.writeEndElement();
2849  writer.writeEndElement();
2850  writer.writeStartElement("GetFeature");
2851  writer.writeStartElement("ResultFormat");
2852  for (ResultFormatter format : ResultFormatter.resultMap.values()) {
2853  if (!format.exposedType.isEmpty()) {
2854  if (format.exposedType.contains("/")) {
2855  writer.writeStartElement(format.exposedType.substring(format.exposedType.lastIndexOf('/') + 1)
2856  .replace("+", "").toUpperCase());
2857  writer.writeEndElement();
2858  } else {
2859  writer.writeStartElement(format.exposedType.toUpperCase());
2860  writer.writeEndElement();
2861  }
2862  }
2863  }
2864  writer.writeEndElement();
2865  writer.writeStartElement("DCPType");
2866  writer.writeStartElement("HTTP");
2867  writer.writeStartElement("Get");
2868  writer.writeAttribute("onlineResource", wfsconf.getString("baseurl") + "/wfs?");
2869  writer.writeEndElement();
2870  writer.writeStartElement("Post");
2871  writer.writeAttribute("onlineResource", wfsconf.getString("baseurl") + "/wfs");
2872  writer.writeEndElement();
2873  writer.writeEndElement();
2874  writer.writeEndElement();
2875  writer.writeEndElement();
2876  writer.writeEndElement();
2877  writer.writeEndElement();
2878  writer.writeStartElement("FeatureTypeList");
2879  writer.writeStartElement("Operations");
2880  writer.writeStartElement("Query");
2881  writer.writeEndElement();
2882  writer.writeEndElement();
2883  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
2884  describeFeatureTypeWFS10(writer, wfsconf.getJSONArray("datasets").getJSONObject(i), versionnamespace,
2885  version);
2886  }
2887  writer.writeEndElement();
2888  writer.writeStartElement("http://www.opengis.net/ogc", "Filter_Capabilities");
2889  describeSpatialCapabilitiesWFS10(writer, versionnamespace, "http://www.opengis.net/ogc");
2890  writer.writeEndElement();
2891  writer.writeEndElement();
2892  writer.writeEndElement();
2893  writer.writeEndDocument();
2894  return Response.ok(strwriter.toString()).type(MediaType.APPLICATION_XML).build();
2895  }
void describeSpatialCapabilitiesWFS10(XMLStreamWriter writer, String versionnamespace, String namespace)
Creates the spatial capabilities document for a WFS in version 1.0.
Definition: WebService.java:3566
void describeFeatureTypeWFS10(XMLStreamWriter writer, JSONObject featuretype, String versionnamespace, String version)
Describes a feature type according to the WFS1.0 specification.
Definition: WebService.java:3404

References ResultFormatter.resultMap.

◆ createExceptionResponse()

Response createExceptionResponse ( Exception  e,
String  format 
)

Generates an exception response.

Parameters
eThe exception to get the message from
formatThe return format
Returns
The exception response
255  {
256  if (format == null || format.equals("gml")) {
257  StringWriter strwriter = new StringWriter();
258  XMLOutputFactory output = XMLOutputFactory.newInstance();
259  XMLStreamWriter writer;
260  try {
261  writer = new IndentingXMLStreamWriter(output.createXMLStreamWriter(strwriter));
262  writer.writeStartDocument();
263  writer.writeStartElement("ExceptionReport");
264  writer.setDefaultNamespace("http://www.opengis.net/ogc");
265  writer.writeNamespace("xsi", "https://www.w3.org/2001/XMLSchema-instance");
266 
267  writer.writeStartElement("Exception");
268 
269  writer.writeAttribute("locator", e.getStackTrace()[0].getClassName());
270  writer.writeStartElement("ExceptionText");
271  writer.writeCharacters(e.getMessage());
272  writer.writeEndElement();
273  writer.writeEndElement();
274  writer.writeEndDocument();
275  writer.flush();
276  } catch (XMLStreamException e1) {
277  // TODO Auto-generated catch block
278  e1.printStackTrace();
279  return Response.ok("").type(MediaType.APPLICATION_XML).build();
280  }
281  return Response.ok(strwriter.toString()).type(MediaType.APPLICATION_XML).build();
282  }
283  return Response.ok("").type(MediaType.APPLICATION_XML).build();
284  }

◆ describeConformance()

void describeConformance ( IndentingXMLStreamWriter  writer,
String  versionnamespace,
String  namespace 
) throws XMLStreamException

Describes the conformance part of a WFS webservices.

Parameters
writerThe XML writer
versionnamespaceThe versionnamespace
namespaceThe namespace to follow
Exceptions
XMLStreamExceptionon error
3283  {
3284  System.out.println(namespace);
3285  writer.writeStartElement(namespace,"Conformance");
3286  writer.writeStartElement(namespace,"Constraint");
3287  writer.writeAttribute("name","ImplementsQuery");
3288  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3289  writer.writeCharacters("TRUE");
3290  writer.writeEndElement();
3291  writer.writeEndElement();
3292  writer.writeStartElement(namespace,"Constraint");
3293  writer.writeAttribute("name","ImplementsAdHocQuery");
3294  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3295  writer.writeCharacters("TRUE");
3296  writer.writeEndElement();
3297  writer.writeEndElement();
3298  writer.writeStartElement(namespace,"Constraint");
3299  writer.writeAttribute("name","ImplementsFunctions");
3300  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3301  writer.writeCharacters("TRUE");
3302  writer.writeEndElement();
3303  writer.writeEndElement();
3304  writer.writeStartElement(namespace,"Constraint");
3305  writer.writeAttribute("name","ImplementsMinStandardFilter");
3306  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3307  writer.writeCharacters("TRUE");
3308  writer.writeEndElement();
3309  writer.writeEndElement();
3310  writer.writeStartElement(namespace,"Constraint");
3311  writer.writeAttribute("name","ImplementsMinSpatialFilter");
3312  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3313  writer.writeCharacters("TRUE");
3314  writer.writeEndElement();
3315  writer.writeEndElement();
3316  writer.writeStartElement(namespace,"Constraint");
3317  writer.writeAttribute("name","ImplementsSpatialFilter");
3318  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3319  writer.writeCharacters("TRUE");
3320  writer.writeEndElement();
3321  writer.writeEndElement();
3322  writer.writeStartElement(namespace,"Constraint");
3323  writer.writeAttribute("name","ImplementsMinTemporalFilter");
3324  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3325  writer.writeCharacters("TRUE");
3326  writer.writeEndElement();
3327  writer.writeEndElement();
3328  writer.writeStartElement(namespace,"Constraint");
3329  writer.writeAttribute("name","ImplementsResourceId");
3330  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3331  writer.writeCharacters("TRUE");
3332  writer.writeEndElement();
3333  writer.writeEndElement();
3334  writer.writeStartElement(namespace,"Constraint");
3335  writer.writeAttribute("name","ImplementsMinimumXPath");
3336  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3337  writer.writeCharacters("TRUE");
3338  writer.writeEndElement();
3339  writer.writeEndElement();
3340  writer.writeStartElement(namespace,"Constraint");
3341  writer.writeAttribute("name","ImplementsTemporalFilter");
3342  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3343  writer.writeCharacters("FALSE");
3344  writer.writeEndElement();
3345  writer.writeEndElement();
3346  writer.writeStartElement(namespace,"Constraint");
3347  writer.writeAttribute("name","ImplementsVersionNav");
3348  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3349  writer.writeCharacters("TRUE");
3350  writer.writeEndElement();
3351  writer.writeEndElement();
3352  writer.writeStartElement(namespace,"Constraint");
3353  writer.writeAttribute("name","ImplementsSorting");
3354  writer.writeStartElement("http://www.opengis.net/ows/1.1","AllowedValues");
3355  writer.writeStartElement("http://www.opengis.net/ows/1.1","Value");
3356  writer.writeCharacters("ASC");
3357  writer.writeEndElement();
3358  writer.writeStartElement("http://www.opengis.net/ows/1.1","Value");
3359  writer.writeCharacters("DESC");
3360  writer.writeEndElement();
3361  writer.writeEndElement();
3362  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3363  writer.writeCharacters("ASC");
3364  writer.writeEndElement();
3365  writer.writeEndElement();
3366  writer.writeStartElement(namespace,"Constraint");
3367  writer.writeAttribute("name","ImplementsExtendedOperators");
3368  writer.writeStartElement("http://www.opengis.net/ows/1.1","DefaultValue");
3369  writer.writeCharacters("FALSE");
3370  writer.writeEndElement();
3371  writer.writeEndElement();
3372  writer.writeEndElement();
3373  }

◆ describeFeatureType() [1/2]

Response describeFeatureType ( @Parameter(description="The feature type name to describe") @QueryParam("typename") String  typename,
@Parameter(description="The version of the WFS service") @DefaultValue("version") @QueryParam("version") String  version 
) throws XMLStreamException

Describes a feature type as an answer to a WFS request.

Parameters
typenameThe feature type to describe
versionThe version of the WFS
Returns
The feature type description document
Exceptions
XMLStreamExceptionon error
3650  {
3651  if (typename == null)
3652  throw new NotFoundException();
3653  JSONObject workingobj = null;
3654  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
3655  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
3656  if (curobj.getString("name").equalsIgnoreCase(typename)) {
3657  workingobj = curobj;
3658  break;
3659  }
3660  }
3661  if (workingobj == null)
3662  throw new NotFoundException();
3663  XMLOutputFactory factory = XMLOutputFactory.newInstance();
3664  StringWriter strwriter = new StringWriter();
3665  XMLStreamWriter xmlwriter = factory.createXMLStreamWriter(strwriter);
3666  IndentingXMLStreamWriter writer = new IndentingXMLStreamWriter(xmlwriter);
3667  String versionnamespace = version.substring(0, version.lastIndexOf('.'));
3668  if ("1.0.0".equals(version) || "1.1.0".equals(version)) {
3669  versionnamespace = "";
3670  } else {
3671  versionnamespace = "/" + versionnamespace;
3672  versionnamespace = versionnamespace.replace("//", "/");
3673  }
3674  writer.writeStartDocument();
3675  writer.writeStartElement("schema");
3676  // writer.writeAttribute("targetNamespace",(workingobj.has("namespace")?workingobj.getString("namespace"):wfsconf.getString("baseurl")));
3677  writer.writeDefaultNamespace("http://www.w3.org/2001/XMLSchema");
3678  writer.writeNamespace("app",
3679  (workingobj.has("namespace") ? workingobj.getString("namespace") : wfsconf.getString("baseurl")));
3680  writer.setPrefix("app",
3681  (workingobj.has("namespace") ? workingobj.getString("namespace") : wfsconf.getString("baseurl")));
3682  writer.writeNamespace("wfs", "http://www.opengis.net/wfs" + versionnamespace);
3683  writer.writeNamespace("ows", "http://www.opengis.net/ows/1.1");
3684  writer.writeNamespace("sf", "http://www.opengis.net/ogcapi-features-1/1.0/sf");
3685  writer.writeNamespace("ogc", "http://www.opengis.net/ogc");
3686  writer.writeNamespace("fes", "http://www.opengis.net/fes" + versionnamespace);
3687  writer.writeNamespace("gml", "http://www.opengis.net/gml");
3688  writer.writeNamespace("xlink", "http://www.w3.org/1999/xlink");
3689  writer.writeStartElement("element");
3690  writer.writeAttribute("name", typename);
3691  writer.writeAttribute("type", typename + "Type");
3692  writer.writeAttribute("substitutionGroup", "gml:_Feature");
3693  writer.writeEndElement();
3694  writer.writeStartElement("complexType");
3695  writer.writeAttribute("name", typename + "Type");
3696  writer.writeStartElement("complexContent");
3697  writer.writeStartElement("extension");
3698  writer.writeAttribute("base", "gml:AbstractFeatureType");
3699  writer.writeStartElement("all");
3700  if (!featureTypeCache.containsKey(typename.toLowerCase())) {
3701  featureTypeCache.put(typename.toLowerCase(),
3702  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
3703  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
3704  }
3705  writer.writeStartElement("element");
3706  writer.writeAttribute("name", "the_geom");
3707  writer.writeAttribute("minOccurs", "0");
3708  writer.writeAttribute("type",
3709  "gml:" + (workingobj.has("geometrytype") ? workingobj.getString("geometrytype") : "Geometry")
3710  + "PropertyType");
3711  writer.writeEndElement();
3712  Map<String, String> mapping = featureTypeCache.get(typename.toLowerCase());
3713  for (String elem : mapping.keySet()) {
3714  if (elem.equals("namespaces"))
3715  continue;
3716  writer.writeStartElement("element");
3717  if (elem.startsWith("http") && elem.contains("#")) {
3718  writer.writeAttribute("name", elem.substring(elem.lastIndexOf('#') + 1));
3719  } else if (elem.startsWith("http") && elem.contains("/")) {
3720  writer.writeAttribute("name", elem.substring(elem.lastIndexOf('/') + 1));
3721  } else {
3722  writer.writeAttribute("name", elem);
3723  }
3724  if (mapping.get(elem).contains("^^")) {
3725  writer.writeAttribute("type", mapping.get(elem).substring(mapping.get(elem).lastIndexOf("^^") + 2));
3726  } else if (mapping.get(elem).startsWith("http") || mapping.get(elem).startsWith("file:/")) {
3727  writer.writeAttribute("type", "string");
3728  } else {
3729  writer.writeAttribute("type", "string");
3730  }
3731  writer.writeAttribute("minOccurs", "0");
3732  writer.writeEndElement();
3733  }
3734  // writer.writeEndElement();
3735  // this.describeFeatureType(writer,
3736  // workingobj,version.substring(0,version.lastIndexOf('.')),version);
3737  writer.writeEndElement();
3738  writer.writeEndElement();
3739  writer.writeEndElement();
3740  writer.writeEndElement();
3741  writer.writeEndDocument();
3742  return Response.ok(strwriter.toString()).type(MediaType.APPLICATION_XML).build();
3743  }

References TripleStoreConnector.getFeatureTypeInformation().

◆ describeFeatureType() [2/2]

void describeFeatureType ( XMLStreamWriter  writer,
JSONObject  featuretype,
String  versionnamespace,
String  version 
) throws XMLStreamException

Creates a feature type description.

Parameters
writerthe XMLWriter for writing the feature type description
featuretypethe feature type to describe
versionnamespacethe versionnamespace to use
versionthe version to write
Exceptions
XMLStreamExceptionon error
3450  {
3451  if ("1.0.0".equals(version) || "1.1.0".equals(version)) {
3452  versionnamespace = "";
3453  } else {
3454  versionnamespace = "/" + versionnamespace;
3455  versionnamespace = versionnamespace.replace("//", "/");
3456  }
3457  writer.writeStartElement("http://www.opengis.net/wfs" + versionnamespace, "FeatureType");
3458  writer.writeStartElement("http://www.opengis.net/wfs" + versionnamespace, "Name");
3459  writer.writeCharacters(featuretype.getString("name"));
3460  writer.writeEndElement();
3461  writer.writeStartElement("http://www.opengis.net/wfs" + versionnamespace, "Title");
3462  writer.writeCharacters(featuretype.getString("name"));
3463  writer.writeEndElement();
3464  writer.writeStartElement("http://www.opengis.net/wfs" + versionnamespace, "DefaultCRS");
3465  writer.writeCharacters("urn:ogc:def:crs:EPSG::4326");
3466  writer.writeEndElement();
3467  writer.writeStartElement("http://www.opengis.net/wfs" + versionnamespace, "OutputFormats");
3468  for (ResultFormatter format : ResultFormatter.resultMap.values()) {
3469  if (!format.exposedType.isEmpty()) {
3470  writer.writeStartElement("http://www.opengis.net/wfs" + versionnamespace, "Format");
3471  writer.writeCharacters(format.exposedType);
3472  writer.writeEndElement();
3473  }
3474  }
3475  writer.writeEndElement();
3476  if (!bboxCache.containsKey(featuretype.getString("name").toLowerCase())) {
3477  bboxCache.put(featuretype.getString("name").toLowerCase(),
3478  TripleStoreConnector.getBoundingBoxFromTripleStoreData(featuretype.getString("triplestore"),
3479  featuretype.getString("query")));
3480  }
3481  Double[] bbox = bboxCache.get(featuretype.getString("name").toLowerCase());
3482  writer.writeStartElement("http://www.opengis.net/ows/1.1", "WGS84BoundingBox");
3483  writer.writeAttribute("dimensions", "2");
3484  writer.writeStartElement("http://www.opengis.net/ows/1.1", "lowerCorner");
3485  writer.writeCharacters(bbox[0] + " " + bbox[1]);
3486  writer.writeEndElement();
3487  writer.writeStartElement("http://www.opengis.net/ows/1.1", "upperCorner");
3488  writer.writeCharacters(bbox[2] + " " + bbox[3]);
3489  writer.writeEndElement();
3490  writer.writeEndElement();
3491  writer.writeEndElement();
3492  }
static Map< String, Double[]> bboxCache
Definition: WebService.java:104

References TripleStoreConnector.getBoundingBoxFromTripleStoreData(), and ResultFormatter.resultMap.

◆ describeFeatureTypeJSON()

Response describeFeatureTypeJSON ( @Parameter(description="The feature type to describe") @QueryParam("typename") String  typename,
@Parameter(description="The version of the WFS service") @DefaultValue("version") @QueryParam("version") String  version 
)

Describes a feature type in JSON.

Parameters
typenameThe type name to describe
versionThe version of the WFS
Returns
The JSON document to return
3759  {
3760  if (typename == null)
3761  throw new NotFoundException();
3762  JSONObject workingobj = null;
3763  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
3764  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
3765  if (curobj.getString("name").equalsIgnoreCase(typename)) {
3766  workingobj = curobj;
3767  break;
3768  }
3769  }
3770  if (workingobj == null)
3771  throw new NotFoundException();
3772  JSONObject schema = new JSONObject();
3773  JSONArray required = new JSONArray();
3774  schema.put("definitions", new JSONObject());
3775  schema.put("$schema", "http://json-schema.org/draft-07/schema#");
3776  schema.put("$id", wfsconf.getString("baseurl") + "/collections/" + typename + "/schema?f=json");
3777  schema.put("type", "object");
3778  schema.put("title", typename);
3779  schema.put("description", (workingobj.has("description") ? workingobj.getString("description") : ""));
3780  schema.put("readOnly", true);
3781  schema.put("writeOnly", false);
3782  schema.put("required", required);
3783  JSONObject properties = new JSONObject();
3784  schema.put("properties", properties);
3785  if (!featureTypeCache.containsKey(typename.toLowerCase())) {
3786  featureTypeCache.put(typename.toLowerCase(),
3787  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
3788  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
3789  }
3790  Map<String, String> mapping = featureTypeCache.get(typename.toLowerCase());
3791  for (String elem : mapping.keySet()) {
3792  if (elem.equals("namespaces"))
3793  continue;
3794  if (elem.startsWith("http") && elem.contains("#")) {
3795  required.put(elem.substring(elem.lastIndexOf('#') + 1));
3796  } else if (elem.startsWith("http") && elem.contains("/")) {
3797  required.put(elem.substring(elem.lastIndexOf('/') + 1));
3798  } else {
3799  required.put(elem);
3800  }
3801  }
3802  for (String elem : mapping.keySet()) {
3803  if (elem.equals("namespaces"))
3804  continue;
3805  JSONObject prop = new JSONObject();
3806  String curprop = "";
3807  if (elem.startsWith("http") && elem.contains("#")) {
3808  curprop = elem.substring(elem.lastIndexOf('#') + 1);
3809  properties.put(curprop, prop);
3810  } else if (elem.startsWith("http") && elem.contains("/")) {
3811  curprop = elem.substring(elem.lastIndexOf('/') + 1);
3812  properties.put(elem.substring(elem.lastIndexOf('/') + 1), prop);
3813  } else {
3814  curprop = elem;
3815  properties.put(elem, prop);
3816  }
3817  prop.put("$id", wfsconf.getString("baseurl") + "/collections/" + typename + "/" + curprop);
3818  if (mapping.get(elem).contains("^^")) {
3819  prop.put("type", mapping.get(elem).substring(mapping.get(elem).lastIndexOf("^^") + 2));
3820  } else if (mapping.get(elem).startsWith("http") || mapping.get(elem).startsWith("file:/")) {
3821  prop.put("type", "string");
3822  } else {
3823  prop.put("type", "string");
3824  }
3825  prop.put("title", curprop);
3826  prop.put("description", curprop + " Property");
3827  JSONArray examples = new JSONArray();
3828  prop.put("examples", examples);
3829  }
3830  return Response.ok(schema.toString(2)).type(MediaType.APPLICATION_JSON).build();
3831  }

References TripleStoreConnector.getFeatureTypeInformation().

◆ describeFeatureTypeWFS10()

void describeFeatureTypeWFS10 ( XMLStreamWriter  writer,
JSONObject  featuretype,
String  versionnamespace,
String  version 
) throws XMLStreamException

Describes a feature type according to the WFS1.0 specification.

Parameters
writerXMLWriter to write the specification
featuretypethe feature type to consider
versionnamespacethe versionnamespace to write
versionthe version to use
Exceptions
XMLStreamExceptionon error
3405  {
3406  writer.setPrefix("wfs", "http://www.opengis.net/wfs");
3407  writer.writeStartElement("http://www.opengis.net/wfs", "FeatureType");
3408  writer.writeStartElement("http://www.opengis.net/wfs", "Name");
3409  writer.writeCharacters(featuretype.getString("name"));
3410  writer.writeEndElement();
3411  writer.writeStartElement("http://www.opengis.net/wfs", "Title");
3412  writer.writeCharacters(featuretype.getString("name"));
3413  writer.writeEndElement();
3414  writer.writeStartElement("http://www.opengis.net/wfs", "SRS");
3415  writer.writeCharacters("urn:ogc:def:crs:EPSG::4326");
3416  writer.writeEndElement();
3417  writer.writeStartElement("http://www.opengis.net/wfs", "OutputFormats");
3418  for (ResultFormatter format : ResultFormatter.resultMap.values()) {
3419  if (!format.exposedType.isEmpty()) {
3420  writer.writeStartElement("http://www.opengis.net/wfs", "Format");
3421  writer.writeCharacters(format.exposedType);
3422  writer.writeEndElement();
3423  }
3424  }
3425  writer.writeEndElement();
3426  if (!bboxCache.containsKey(featuretype.getString("name").toLowerCase())) {
3427  bboxCache.put(featuretype.getString("name").toLowerCase(),
3428  TripleStoreConnector.getBoundingBoxFromTripleStoreData(featuretype.getString("triplestore"),
3429  featuretype.getString("query")));
3430  }
3431  Double[] bbox = bboxCache.get(featuretype.getString("name").toLowerCase());
3432  writer.writeStartElement("http://www.opengis.net/ows/1.1", "LatLongBoundingBox");
3433  writer.writeAttribute("minx", bbox[0] + "");
3434  writer.writeAttribute("miny", bbox[1] + "");
3435  writer.writeAttribute("maxx", bbox[2] + "");
3436  writer.writeAttribute("maxy", bbox[3] + "");
3437  writer.writeEndElement();
3438  writer.writeEndElement();
3439  }

References TripleStoreConnector.getBoundingBoxFromTripleStoreData(), and ResultFormatter.resultMap.

◆ describeScalarCapabilities()

void describeScalarCapabilities ( XMLStreamWriter  writer,
String  versionnamespace,
String  namespace 
) throws XMLStreamException

Writes the scalar capabilities document for a WFS.

Parameters
writerThe XMLStreamWriter to write the capabilities document with
versionnamespaceThe versionnamespace to use
namespaceThe namespace to use for writing
Exceptions
XMLStreamExceptionon error
3601  {
3602  writer.writeStartElement(namespace, "Scalar_Capabilities");
3603  writer.writeStartElement(namespace, "LogicalOperators");
3604  writer.writeEndElement();
3605  writer.writeStartElement(namespace, "ComparisonOperators");
3606  writer.writeStartElement(namespace, "ComparisonOperator");
3607  writer.writeCharacters("LessThan");
3608  writer.writeEndElement();
3609  writer.writeStartElement(namespace, "ComparisonOperator");
3610  writer.writeCharacters("GreaterThan");
3611  writer.writeEndElement();
3612  writer.writeStartElement(namespace, "ComparisonOperator");
3613  writer.writeCharacters("LessThanEqualTo");
3614  writer.writeEndElement();
3615  writer.writeStartElement(namespace, "ComparisonOperator");
3616  writer.writeCharacters("GreaterThanEqualTo");
3617  writer.writeEndElement();
3618  writer.writeStartElement(namespace, "ComparisonOperator");
3619  writer.writeCharacters("EqualTo");
3620  writer.writeEndElement();
3621  writer.writeStartElement(namespace, "ComparisonOperator");
3622  writer.writeCharacters("NotEqualTo");
3623  writer.writeEndElement();
3624  writer.writeStartElement(namespace, "ComparisonOperator");
3625  writer.writeCharacters("Like");
3626  writer.writeEndElement();
3627  writer.writeStartElement(namespace, "ComparisonOperator");
3628  writer.writeCharacters("Between");
3629  writer.writeEndElement();
3630  writer.writeStartElement(namespace, "ArithmeticOperators");
3631  writer.writeEndElement();
3632  writer.writeEndElement();
3633  }

◆ describeSpatialCapabilities()

void describeSpatialCapabilities ( XMLStreamWriter  writer,
String  versionnamespace,
String  namespace 
) throws XMLStreamException

Writes the spatial capabilities part of the WFS document.

Parameters
writerThe XMLWriter to write the document part
versionnamespaceThe versionnamespace to write
namespaceThe namespace to use
Exceptions
XMLStreamExceptionon error
3502  {
3503  writer.writeStartElement(namespace, "Spatial_Capabilities");
3504  writer.writeStartElement(namespace, "GeometryOperands");
3505  writer.writeStartElement(namespace, "GeometryOperand");
3506  writer.writeAttribute("name", "gml:Box");
3507  writer.writeEndElement();
3508  writer.writeStartElement(namespace, "GeometryOperand");
3509  writer.writeAttribute("name", "gml:Envelope");
3510  writer.writeEndElement();
3511  writer.writeStartElement(namespace, "GeometryOperand");
3512  writer.writeAttribute("name", "gml:Point");
3513  writer.writeEndElement();
3514  writer.writeStartElement(namespace, "GeometryOperand");
3515  writer.writeAttribute("name", "gml:LineString");
3516  writer.writeEndElement();
3517  writer.writeStartElement(namespace, "GeometryOperand");
3518  writer.writeAttribute("name", "gml:Curve");
3519  writer.writeEndElement();
3520  writer.writeStartElement(namespace, "GeometryOperand");
3521  writer.writeAttribute("name", "gml:Polygon");
3522  writer.writeEndElement();
3523  writer.writeEndElement();
3524  writer.writeStartElement(namespace, "SpatialOperators");
3525  writer.writeStartElement(namespace, "SpatialOperator");
3526  writer.writeAttribute("name", "BBOX");
3527  writer.writeEndElement();
3528  writer.writeStartElement(namespace, "SpatialOperator");
3529  writer.writeAttribute("name", "Intersects");
3530  writer.writeEndElement();
3531  writer.writeStartElement(namespace, "SpatialOperator");
3532  writer.writeAttribute("name", "Contains");
3533  writer.writeEndElement();
3534  writer.writeStartElement(namespace, "SpatialOperator");
3535  writer.writeAttribute("name", "Crosses");
3536  writer.writeEndElement();
3537  writer.writeStartElement(namespace, "SpatialOperator");
3538  writer.writeAttribute("name", "Touches");
3539  writer.writeEndElement();
3540  writer.writeStartElement(namespace, "SpatialOperator");
3541  writer.writeAttribute("name", "Within");
3542  writer.writeEndElement();
3543  writer.writeStartElement(namespace, "SpatialOperator");
3544  writer.writeAttribute("name", "Overlaps");
3545  writer.writeEndElement();
3546  writer.writeStartElement(namespace, "SpatialOperator");
3547  writer.writeAttribute("name", "Disjoint");
3548  writer.writeEndElement();
3549  writer.writeStartElement(namespace, "SpatialOperator");
3550  writer.writeAttribute("name", "Equals");
3551  writer.writeEndElement();
3552  writer.writeStartElement(namespace, "SpatialOperator");
3553  writer.writeAttribute("name", "DWithin");
3554  writer.writeEndElement();
3555  writer.writeEndElement();
3556  writer.writeEndElement();
3557  }

◆ describeSpatialCapabilitiesWFS10()

void describeSpatialCapabilitiesWFS10 ( XMLStreamWriter  writer,
String  versionnamespace,
String  namespace 
) throws XMLStreamException

Creates the spatial capabilities document for a WFS in version 1.0.

Parameters
writerThe XMLWriter to write the documentation with
versionnamespaceThe versionnamespace to use for writing
namespaceThe namespace to use
Exceptions
XMLStreamExceptionon error
3567  {
3568  writer.writeStartElement(namespace, "Spatial_Capabilities");
3569  writer.writeStartElement(namespace, "Spatial_Operators");
3570  writer.writeStartElement(namespace, "BBOX");
3571  writer.writeEndElement();
3572  writer.writeStartElement(namespace, "Intersects");
3573  writer.writeEndElement();
3574  writer.writeStartElement(namespace, "Contains");
3575  writer.writeEndElement();
3576  writer.writeStartElement(namespace, "Crosses");
3577  writer.writeEndElement();
3578  writer.writeStartElement(namespace, "Touches");
3579  writer.writeEndElement();
3580  writer.writeStartElement(namespace, "Within");
3581  writer.writeEndElement();
3582  writer.writeStartElement(namespace, "Overlaps");
3583  writer.writeEndElement();
3584  writer.writeStartElement(namespace, "Disjoint");
3585  writer.writeEndElement();
3586  writer.writeStartElement(namespace, "Equals");
3587  writer.writeEndElement();
3588  writer.writeStartElement(namespace, "DWithin");
3589  writer.writeEndElement();
3590  writer.writeEndElement();
3591  }

◆ docCollectionItemJSON()

Response docCollectionItemJSON ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String  collectionid,
@Parameter(description="The id of the feature to be considered") @PathParam("ext") String  ext,
@Parameter(description="The id of the feature to be considered") @PathParam("featureid") String  featureid,
@Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("ldapi") @QueryParam("_format") String  format,
@Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("_pageSize") Integer  limit,
@Parameter(description="An optional where statement to be used in the SPARQL query", example="10") @DefaultValue("") @QueryParam("_select") String  select,
@Parameter(description="An optional where statement to be used in the SPARQL query", example="10") @DefaultValue("") @QueryParam("_where") String  where,
@Parameter(description="The page of the Linked Data API resource to return", example="1") @DefaultValue("1") @QueryParam("_page") Integer  page,
@Parameter(description="Detailed or minimized view to be returned") @DefaultValue("") @QueryParam("_view") String  view,
@Parameter(description="The sorting of the given results") @DefaultValue("") @QueryParam("_sort") String  sort,
@Parameter(description="An optional orderBy statement to be used in the SPARQL query") @DefaultValue("") @QueryParam("_orderBy") String  orderBy,
@Parameter(description="A subclass definition of the class defining the featurecollection") @DefaultValue("") @QueryParam("type") String  type,
@Parameter(description="Defines resources with a specified parameter value to be returned") @DefaultValue("") @QueryParam("param") List< String >  paramval,
@Parameter(description="Defines resources with a specified parameter value greater or equal the given value to be returned") @DefaultValue("") @QueryParam("max-param") String  maxparamval,
@Parameter(description="Defines resources with a specified parameter value smaller or equal the given value to be returned") @DefaultValue("") @QueryParam("min-param") String  minparamval,
@Parameter(description="Defines resources with a specified parameter value greater than the given value to be returned") @DefaultValue("") @QueryParam("maxEx-param") String  maxExparamval,
@Parameter(description="Defines resources with a specified parameter value smaller than the given value to be returned") @DefaultValue("") @QueryParam("minEx-param") String  minExparamval,
@Parameter(description="Returns only resources with the specified parameter") @QueryParam("exists-param") String  existsparam,
@Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") String  offset 
)
1025  {
1026  String queryString="",additionalwhereclauses="";
1027  JSONObject workingobj=null;
1028  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
1029  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
1030  if (curobj.getString("name").equalsIgnoreCase(collectionid)) {
1031  workingobj = curobj;
1032  break;
1033  }
1034  }
1035  if (workingobj == null) {
1036  throw new NotFoundException();
1037  }
1038  if(!select.isEmpty()) {
1039  queryString=select;
1040  }else {
1041  queryString=workingobj.getString("query");
1042  }
1043  if(queryString.contains("WHERE {")) {
1044  queryString=queryString.replace("WHERE {", "WHERE {\n BIND( <"+workingobj.getString("namespace")+featureid+"> AS ?item)\n");
1045  }else if(queryString.contains("WHERE{")) {
1046  queryString=queryString.replace("WHERE{", "WHERE{\n BIND( <"+workingobj.getString("namespace")+featureid+"> AS ?item)\n");
1047  }
1048  if(!where.isEmpty() && select.isEmpty()) {
1049  queryString=queryString.substring(0,queryString.indexOf("WHERE"));
1050  queryString+="WHERE {\n"+where+"\n}";
1051  }
1052  Integer addvarcounter=0;
1053  /*if(existsparam!=null) {
1054  for(String str:existsparam) {
1055  additionalwhereclauses+=triplestoreconf.getJSONObject(collectionid.toLowerCase()).getString("indvar")+" "+str+" ?var"+addvarcounter+++System.lineSeparator();
1056  }
1057  }
1058  if(type!=null) {
1059  for(String str:type) {
1060  additionalwhereclauses+=triplestoreconf.getJSONObject(collectionid.toLowerCase()).getString("indvar")+" rdf:type "+str+System.lineSeparator();
1061  }
1062  }*/
1063  if(!orderBy.isEmpty()) {
1064  queryString+=System.lineSeparator()+orderBy;
1065  }
1066  queryString+=System.lineSeparator()+"LIMIT "+limit;
1067  if(page>1) {
1068  queryString+=System.lineSeparator()+"OFFSET "+page*limit;
1069  }
1070  if(collectionid.contains(".")) {
1071  if(format.isEmpty()) {
1072  format=collectionid.substring(collectionid.lastIndexOf('.')+1);
1073  }
1074  collectionid=collectionid.substring(0,collectionid.lastIndexOf('.'));
1075  }
1076 
1077  final String qs=queryString;
1078  final String formatt=format;
1079  final JSONObject workingobjj=workingobj;
1080  StreamingOutput stream = new StreamingOutput() {
1081  @Override
1082  public void write(OutputStream os) throws IOException,
1083  WebApplicationException {
1084  Writer writer = new BufferedWriter(new OutputStreamWriter(os));
1085  String res;
1086  try {
1087  res = TripleStoreConnector.executeLDAPIQuery(qs, formatt,null, workingobjj.getString("triplestore"), workingobjj,writer);
1088  if(res!=null && !res.isEmpty()) {
1089  writer.write(res);
1090  }
1091  } catch (JSONException | IOException e) {
1092  // TODO Auto-generated catch block
1093  e.printStackTrace();
1094  }
1095  writer.close();
1096  }
1097  };
1098  return Response.ok(stream,ResultFormatter.getFormatter(format).mimeType)
1099  .header("Content-Disposition", "attachment; filename*=UTF-8''" + collectionid+"_items."
1100  +ResultFormatter.getFormatter(format).fileextension)
1101  .build();
1102  }

References TripleStoreConnector.executeLDAPIQuery(), ResultFormatter.fileextension, ResultFormatter.getFormatter(), and ResultFormatter.mimeType.

◆ docCollectionJSON()

Response docCollectionJSON ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format if given as a file extension") @DefaultValue("") @PathParam("ext") String  ext,
@Parameter(description="The format in which the collection should be returned", example="ttl") @DefaultValue("ldapi") @QueryParam("_format") String  format,
@Parameter(description="The maximum amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("_pageSize") Integer  limit,
@Parameter(description="An optional where statement to be used in the SPARQL query", example="10") @DefaultValue("") @QueryParam("_select") String  select,
@Parameter(description="An optional where statement to be used in the SPARQL query", example="10") @DefaultValue("") @QueryParam("_where") String  where,
@Parameter(description="The page of the Linked Data API resource to return", example="1") @DefaultValue("1") @QueryParam("_page") Integer  page,
@Parameter(description="Detailed or minimized view to be returned") @DefaultValue("") @QueryParam("_view") String  view,
@Parameter(description="The sorting of the given results") @DefaultValue("") @QueryParam("_sort") String  sort,
@Parameter(description="An optional orderBy statement to be used in the SPARQL query") @DefaultValue("") @QueryParam("_orderBy") String  orderBy,
@Parameter(description="A subclass definition of the class defining the featurecollection") @DefaultValue("") @QueryParam("type") String  type,
@Parameter(description="Defines resources with a specified parameter value to be returned") @DefaultValue("") @QueryParam("param") List< String >  paramval,
@Parameter(description="Defines resources with a specified parameter value greater or equal the given value to be returned") @DefaultValue("") @QueryParam("max-param") String  maxparamval,
@Parameter(description="Defines resources with a specified parameter value smaller or equal the given value to be returned") @DefaultValue("") @QueryParam("min-param") String  minparamval,
@Parameter(description="Defines resources with a specified parameter value greater than the given value to be returned") @DefaultValue("") @QueryParam("maxEx-param") String  maxExparamval,
@Parameter(description="Defines resources with a specified parameter value smaller than the given value to be returned") @DefaultValue("") @QueryParam("minEx-param") String  minExparamval,
@Parameter(description="Returns only resources with the specified parameter") @QueryParam("exists-param") String  existsparam,
@Parameter(description="An offset to be considered when returning features", example="10") @DefaultValue("0") @QueryParam("offset") Integer  offset 
)
1926  {
1927  String queryString="",additionalwhereclauses="";
1928  JSONObject workingobj=null;
1929  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
1930  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
1931  if (curobj.getString("name").equalsIgnoreCase(collectionid)) {
1932  workingobj = curobj;
1933  break;
1934  }
1935  }
1936  if (workingobj == null) {
1937  throw new NotFoundException();
1938  }
1939  if(!select.isEmpty()) {
1940  queryString=select;
1941  }else {
1942  queryString=workingobj.getString("query");
1943  }
1944  if(limit>=1 || offset>0) {
1945  StringBuilder toreplace=new StringBuilder();
1946  toreplace.append("WHERE{ { SELECT ?"+workingobj.getString("indvar")+" WHERE { ?"+workingobj.getString("indvar")+" <"+WebService.triplestoreconf.getJSONObject("endpoints").getJSONObject(workingobj.getString("triplestore")).getString("type")+"> <"+workingobj.getString("class")+"> . }"+System.lineSeparator());
1947  if(limit>=1) {
1948  toreplace.append(" LIMIT "+limit+System.lineSeparator());
1949  }
1950  if(offset>0) {
1951  toreplace.append(" OFFSET "+offset+System.lineSeparator());
1952  }
1953  toreplace.append(" } "+System.lineSeparator());
1954  queryString=queryString.replace("WHERE{", toreplace);
1955  }
1956  if(!where.isEmpty() && select.isEmpty()) {
1957  queryString=queryString.substring(0,queryString.indexOf("WHERE"));
1958  queryString+="WHERE {\n"+where+"\n}";
1959  }
1960 
1961  Integer addvarcounter=0;
1962  /*if(existsparam!=null) {
1963  for(String str:existsparam) {
1964  additionalwhereclauses+=triplestoreconf.getJSONObject(collectionid.toLowerCase()).getString("indvar")+" "+str+" ?var"+addvarcounter+++System.lineSeparator();
1965  }
1966  }
1967  if(type!=null) {
1968  for(String str:type) {
1969  additionalwhereclauses+=triplestoreconf.getJSONObject(collectionid.toLowerCase()).getString("indvar")+" rdf:type "+str+System.lineSeparator();
1970  }
1971  }*/
1972  if(!orderBy.isEmpty()) {
1973  queryString+=System.lineSeparator()+orderBy;
1974  }
1975  /*queryString+=System.lineSeparator()+"LIMIT "+limit;
1976  if(page>1) {
1977  queryString+=System.lineSeparator()+"OFFSET "+page*limit;
1978  }*/
1979  if(!ext.isEmpty()) {
1980  if(format.isEmpty()) {
1981  format=ext;
1982  }
1983  collectionid=collectionid.substring(0,collectionid.lastIndexOf('.'));
1984  }
1985  final String qs=queryString;
1986  final String formatt=format;
1987  final JSONObject workingobjj=workingobj;
1988  StreamingOutput stream = new StreamingOutput() {
1989  @Override
1990  public void write(OutputStream os) throws IOException,
1991  WebApplicationException {
1992  Writer writer = new BufferedWriter(new OutputStreamWriter(os));
1993  String res;
1994  try {
1995  res = TripleStoreConnector.executeLDAPIQuery(qs, formatt,null, workingobjj.getString("triplestore"), workingobjj,writer);
1996  if(res!=null && !res.isEmpty()) {
1997  writer.write(res);
1998  }
1999  } catch (JSONException | IOException e) {
2000  // TODO Auto-generated catch block
2001  e.printStackTrace();
2002  }
2003  writer.close();
2004  }
2005  };
2006  return Response.ok(stream,ResultFormatter.getFormatter(format).mimeType)
2007  .header("Content-Disposition", "attachment; filename*=UTF-8''" + collectionid+"_items."
2008  +ResultFormatter.getFormatter(format).fileextension)
2009  .build();
2010  }

References TripleStoreConnector.executeLDAPIQuery(), ResultFormatter.fileextension, ResultFormatter.getFormatter(), ResultFormatter.mimeType, and WebService.triplestoreconf.

◆ docJSON()

Response docJSON ( @Parameter(description="Return format") @DefaultValue("json") @QueryParam("f") String  format)
668  {
669  return collections(format);
670  }

◆ entryPoint()

Response entryPoint ( @Parameter(description="Service type") @DefaultValue("WFS") @QueryParam("SERVICE") String  service,
@Parameter(description="Request type") @DefaultValue("GetCapabilities") @QueryParam("REQUEST") String  request,
@Parameter(description="Service version") @DefaultValue("2.0.0") @QueryParam("VERSION") String  version,
@Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAME") String  typename,
@Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAMES") String  typenames,
@Parameter(description="CRS type") @DefaultValue("") @QueryParam("SRSNAME") String  srsName,
@DefaultValue("gml") @QueryParam("EXCEPTIONS") String  exceptions,
@Parameter(description="Bounding box for filtering the results") @DefaultValue("") @QueryParam("BBOX") String  bbox,
@DefaultValue("") @QueryParam("VALUEREFERENCE") String  propertyname,
@Parameter(description="Sorting order") @DefaultValue("ASC") @QueryParam("SORTBY") String  sortBy,
@DefaultValue("") @QueryParam("STYLES") String  style,
@DefaultValue("results") @QueryParam("RESULTTYPE") String  resultType,
@DefaultValue("") @QueryParam("RESOURCEID") String  resourceids,
@DefaultValue("") @QueryParam("GMLOBJECTID") String  gmlobjectid,
@DefaultValue("0") @QueryParam("STARTINDEX") String  startindex,
@Parameter(description="Filter expression") @DefaultValue("") @QueryParam("FILTER") String  filter,
@Parameter(description="Filter query language") @DefaultValue("") @QueryParam("FILTERLANGUAGE") String  filterLanguage,
@Parameter(description="Return format") @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String  output,
@Parameter(description="Maximum amount of results to return") @DefaultValue("5") @QueryParam("COUNT") String  count 
)

WFS endpoint implementation.

Parameters
serviceThe service identifier
requestThe request identifier
versionThe service version
typenameThe feature type name to request
typenamesThe feature type name to request
srsName
exceptions
bbox
propertyname
sortBy
style
resultType
resourceids
gmlobjectid
startindex
filter
filterLanguage
output
count
Returns
619  {
620  System.out.println("Request: " + request);
621  System.out.println("ResultType: " + resultType);
622  if (typename.isEmpty() && !typenames.isEmpty()) {
623  typename = typenames;
624  }
625  if (service.equalsIgnoreCase("WFS")) {
626  if ("getCapabilities".equalsIgnoreCase(request)) {
627  try {
628  return this.constructCapabilities(version, version.substring(0, version.lastIndexOf('.')));
629  } catch (XMLStreamException e) {
630  e.printStackTrace();
631  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
632  }
633  }
634  if ("describeFeatureType".equalsIgnoreCase(request)) {
635  try {
636  return this.describeFeatureType(typename, version);
637  } catch (XMLStreamException e) {
638  e.printStackTrace();
639  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
640  }
641  }
642  if ("getFeature".equalsIgnoreCase(request)) {
643  try {
644  return this.getFeature(typename, output, count, startindex, srsName, sortBy, style, version,
645  resourceids, filter, filterLanguage, resultType);
646  } catch (XMLStreamException e) {
647  e.printStackTrace();
648  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
649  }
650  }
651  if ("getPropertyValue".equalsIgnoreCase(request)) {
652  return this.getPropertyValue(typename, propertyname, output, resourceids, filter, count, resultType);
653  }
654  if ("getGmlObject".equalsIgnoreCase(request)) {
655  return this.getGmlObject(typename, gmlobjectid, "4", output);
656  }
657  }
658  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
659  }
Response constructCapabilities(String version, String versionnamespace)
Constructs a capabilities document for a WFS in version 1.1 .
Definition: WebService.java:3061
Response getGmlObject(@QueryParam("typename") String typename, @QueryParam("GmlObjectId") String gmlobjectid, @DefaultValue("4") @QueryParam("traverseXlinkDepth") String traverseXlinkDepth, @DefaultValue("gml") @QueryParam("outputFormat") String output)
Definition: WebService.java:4058
Response getPropertyValue( @Parameter(description="Feature type to query") @QueryParam("typename") String typename, @QueryParam("valuereference") String propertyname, @DefaultValue("json") @QueryParam("outputFormat") String output, @DefaultValue("") @QueryParam("resourceids") String resourceids, @DefaultValue("") @QueryParam("filter") String filter, @DefaultValue("0") @QueryParam("count") String count, @DefaultValue("results") @QueryParam("resultType") String resultType)
Definition: WebService.java:4073
Response getFeature(@QueryParam("typename") String typename, @Parameter(description="The output format of the WFS service request") @DefaultValue("json") @QueryParam("outputFormat") String output, @Parameter(description="The amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("count") String count, @Parameter(description="The starting index of the WFS request") @DefaultValue("0") @QueryParam("startindex") String startindex, @Parameter(description="The name of the CRS to be used") @DefaultValue("") @QueryParam("srsName") String srsName, @Parameter(description="Indicates the sorting order") @DefaultValue("ASC") @QueryParam("sortBy") String sortBy, @Parameter(description="The style to apply to the returned collection if any") @DefaultValue("") @QueryParam("mapstyles") String style, @Parameter(description="The version of the WFS", example="2.0.0") @DefaultValue("2.0.0") @QueryParam("version") String version, @Parameter(description="Indicates a specific resource id to be queried") @DefaultValue("") @QueryParam("resourceid") String resourceids, @Parameter(description="A WFS filter expression") @DefaultValue("") @QueryParam("filter") String filter, @Parameter(description="The filter language to be used in the filterExpression parameter") @DefaultValue("CQL") @QueryParam("filterLanguage") String filterLanguage, @Parameter(description="The result type to return") @DefaultValue("results") @QueryParam("resultType") String resultType)
Definition: WebService.java:3903

◆ entryPointCSW()

Response entryPointCSW ( @Parameter(description="Service type") @DefaultValue("CSW") @QueryParam("SERVICE") String  service,
@Parameter(description="Request type") @DefaultValue("GetCapabilities") @QueryParam("REQUEST") String  request,
@Parameter(description="Version of the webservice") @DefaultValue("2.0.2") @QueryParam("VERSION") String  version,
@Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAME") String  typename,
@Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAMES") String  typenames,
@Parameter(description="Return type") @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String  output 
)

CSW endpoint implementation.

Parameters
serviceThe service identifier
requestThe request identifier
versionThe service version
typenameThe feature type name to request
typenamesThe feature type name to request
outputThe requested return format
Returns
The CSW service description as XML
519  {
520  if (service.equalsIgnoreCase("CSW")) {
521  if ("getCapabilities".equalsIgnoreCase(request)) {
522  try {
523  return this.constructCapabilitiesCSW(version, version.substring(0, version.lastIndexOf('.')));
524  } catch (XMLStreamException e) {
525  // TODO Auto-generated catch block
526  e.printStackTrace();
527  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
528  }
529  }
530  if ("describeRecord".equalsIgnoreCase(request)) {
531  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
532  }
533  if ("harvest".equalsIgnoreCase(request)) {
534  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
535  }
536  if ("getRecords".equalsIgnoreCase(request)) {
537  return this.getCollectionMetadata(typename, output, "false","");
538  }
539  if ("getRecordById".equalsIgnoreCase(request)) {
540  return this.getCollectionsMetadata(output);
541  }
542  }
543  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
544  }
Response getCollectionMetadata(@PathParam("collectionid") String collectionid, @Parameter(description="The metadata schema to be used") @DefaultValue("gmd") @QueryParam("metadataformat") String mdformat, @Parameter(description="The format to downlift metadata") @DefaultValue("html") @QueryParam("f") String format, @DefaultValue("false") @QueryParam("collectioncall") String collectioncall)
Gets metadata of a given collection.
Definition: WebService.java:1823
Response getCollectionsMetadata(@Parameter(description="The format of the collection page") @DefaultValue("html") @QueryParam("f") String format)
Returns the metadata of collections registered in the SemanticWFS.
Definition: WebService.java:1776
Response constructCapabilitiesCSW(String version, String versionnamespace)
Constructs a capabilities document for a CSW service .
Definition: WebService.java:2905

◆ entryPointCSWPost()

Response entryPointCSWPost ( @DefaultValue("CSW") @QueryParam("SERVICE") String  service,
@DefaultValue("GetCapabilities") @QueryParam("REQUEST") String  request,
@DefaultValue("2.0.2") @QueryParam("VERSION") String  version,
@DefaultValue("") @QueryParam("TYPENAME") String  typename,
@DefaultValue("") @QueryParam("TYPENAMES") String  typenames,
@DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String  output 
)

CSW endpoint implementation (POST version).

Parameters
serviceThe service identifier
requestThe request identifier
versionThe service version
typenameThe feature type name to request
typenamesThe feature type name to request
outputThe requested return format
Returns
The CSW service description as XML
567  {
568  return this.entryPointCSW(service, request, version, typename, typenames, output);
569  }
Response entryPointCSW( @Parameter(description="Service type") @DefaultValue("CSW") @QueryParam("SERVICE") String service, @Parameter(description="Request type") @DefaultValue("GetCapabilities") @QueryParam("REQUEST") String request, @Parameter(description="Version of the webservice") @DefaultValue("2.0.2") @QueryParam("VERSION") String version, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAME") String typename, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAMES") String typenames, @Parameter(description="Return type") @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String output)
CSW endpoint implementation.
Definition: WebService.java:513

◆ entryPointPOST()

Response entryPointPOST ( @Parameter(description="Service type definition") @DefaultValue("WFS") @QueryParam("SERVICE") String  service,
@Parameter(description="Request definition") @DefaultValue("GetCapabilities") @QueryParam("REQUEST") String  request,
@Parameter(description="Version of the web service") @DefaultValue("2.0.0") @QueryParam("VERSION") String  version,
@Parameter(description="The feature type name to be queried") @DefaultValue("") @QueryParam("TYPENAME") String  typename,
@Parameter(description="The feature type(s) name(s) to be queried") @DefaultValue("") @QueryParam("TYPENAMES") String  typenames,
@Parameter(description="The name of the CRS to be returned") @DefaultValue("") @QueryParam("SRSNAME") String  srsName,
@DefaultValue("gml") @QueryParam("EXCEPTIONS") String  exceptions,
@Parameter(description="A bounding box used for filtering results") @DefaultValue("") @QueryParam("BBOX") String  bbox,
@DefaultValue("") @QueryParam("VALUEREFERENCE") String  propertyname,
@Parameter(description="Sorting order definition") @DefaultValue("ASC") @QueryParam("SORTBY") String  sortBy,
@DefaultValue("") @QueryParam("STYLES") String  style,
@DefaultValue("results") @QueryParam("RESULTTYPE") String  resultType,
@DefaultValue("") @QueryParam("RESOURCEID") String  resourceids,
@DefaultValue("") @QueryParam("GMLOBJECTID") String  gmlobjectid,
@DefaultValue("0") @QueryParam("STARTINDEX") String  startindex,
@DefaultValue("") @QueryParam("FILTER") String  filter,
@DefaultValue("") @QueryParam("FILTERLANGUAGE") String  filterLanguage,
@DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String  output,
@DefaultValue("5") @QueryParam("COUNT") String  count 
)

Entrypoint implementation for OGC API Features for POST requests.

Parameters
service
request
version
typename
typenames
srsName
exceptions
bbox
propertyname
sortBy
style
resultType
resourceids
gmlobjectid
startindex
filter
filterLanguage
output
count
Returns
334  {
335  return entryPoint(service, request, version, typename, typenames, srsName, exceptions, bbox, propertyname,
336  sortBy, style, resultType, resourceids, gmlobjectid, startindex, filter, filterLanguage, output, count);
337  }
Response entryPoint( @Parameter(description="Service type") @DefaultValue("WFS") @QueryParam("SERVICE") String service, @Parameter(description="Request type") @DefaultValue("GetCapabilities") @QueryParam("REQUEST") String request, @Parameter(description="Service version") @DefaultValue("2.0.0") @QueryParam("VERSION") String version, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAME") String typename, @Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAMES") String typenames, @Parameter(description="CRS type") @DefaultValue("") @QueryParam("SRSNAME") String srsName, @DefaultValue("gml") @QueryParam("EXCEPTIONS") String exceptions, @Parameter(description="Bounding box for filtering the results") @DefaultValue("") @QueryParam("BBOX") String bbox, @DefaultValue("") @QueryParam("VALUEREFERENCE") String propertyname, @Parameter(description="Sorting order") @DefaultValue("ASC") @QueryParam("SORTBY") String sortBy, @DefaultValue("") @QueryParam("STYLES") String style, @DefaultValue("results") @QueryParam("RESULTTYPE") String resultType, @DefaultValue("") @QueryParam("RESOURCEID") String resourceids, @DefaultValue("") @QueryParam("GMLOBJECTID") String gmlobjectid, @DefaultValue("0") @QueryParam("STARTINDEX") String startindex, @Parameter(description="Filter expression") @DefaultValue("") @QueryParam("FILTER") String filter, @Parameter(description="Filter query language") @DefaultValue("") @QueryParam("FILTERLANGUAGE") String filterLanguage, @Parameter(description="Return format") @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String output, @Parameter(description="Maximum amount of results to return") @DefaultValue("5") @QueryParam("COUNT") String count)
WFS endpoint implementation.
Definition: WebService.java:600

◆ generateOpenAPIDefinitions()

void generateOpenAPIDefinitions ( )

Generates OpenAPI definitions of the SemanticWFS services for the use with OGC API Features.

232  {
233  JSONObject defs=new JSONObject();
234  for (Integer i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
235  JSONObject featuretype = wfsconf.getJSONArray("datasets").getJSONObject(i);
236  JSONObject curobj=new JSONObject();
237  defs.put("/collections/"+featuretype.getString("name"), curobj);
238  JSONObject get=new JSONObject();
239  curobj.put("get", get);
240  get.put("summary", featuretype.getString("description"));
241  get.put("description", featuretype.getString("description"));
242  get.put("operationId", featuretype.getString("name"));
243  JSONObject parameters=new JSONObject();
244  get.put("parameters", parameters);
245  }
246  }

◆ getCapabilities()

Response getCapabilities ( @Parameter(description="The version of the WFS service to target") @DefaultValue("2.0.0") @QueryParam("version") String  version) throws XMLStreamException

Returns the capabilities document for a WFS service.

Parameters
versionThe version of the WFS service to target
Returns
The capabilities document as String
Exceptions
XMLStreamExceptionon error
3389  {
3390  if (!version.equals("2.0.0") && !version.equals("1.1.0"))
3391  version = "2.0.0";
3392  return constructCapabilities(version, version.substring(0, version.lastIndexOf('.')));
3393  }

◆ getCollectionMetadata()

Response getCollectionMetadata ( @PathParam("collectionid") String  collectionid,
@Parameter(description="The metadata schema to be used") @DefaultValue("gmd") @QueryParam("metadataformat") String  mdformat,
@Parameter(description="The format to downlift metadata") @DefaultValue("html") @QueryParam("f") String  format,
@DefaultValue("false") @QueryParam("collectioncall") String  collectioncall 
)

Gets metadata of a given collection.

Parameters
collectionidThe feture type of the collection
mdformatThe metadata format to use
formatThe downlift format in which to return the metadata
collectioncallindicates whether this method has been called from a higher level method
Returns
The metadata as String
1826  {
1827  if (collectionid == null) {
1828  throw new NotFoundException();
1829  }
1830  JSONObject workingobj = null;
1831  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
1832  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
1833  if (curobj.getString("name").equalsIgnoreCase(collectionid)) {
1834  workingobj = curobj;
1835  break;
1836  }
1837  }
1838  if (workingobj == null) {
1839  throw new NotFoundException();
1840  }
1841  if (!featureTypeCache.containsKey(collectionid.toLowerCase())) {
1842  featureTypeCache.put(collectionid.toLowerCase(),
1843  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
1844  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
1845  }
1846  String collectionurl=wfsconf.getString("baseurl") + "/collections/" + collectionid;
1847  try {
1848  return Response.ok(ResultMetadataFormatter.getFormatter(mdformat)
1849  .formatter(collectionid, collectioncall, collectionurl, workingobj,format))
1850  .type(ResultMetadataFormatter.getFormatter(mdformat).mimeType).build();
1851  } catch (XMLStreamException e1) {
1852  e1.printStackTrace();
1853  return this.createExceptionResponse(e1, "");
1854  }
1855  }

References ResultMetadataFormatter.formatter(), TripleStoreConnector.getFeatureTypeInformation(), ResultMetadataFormatter.getFormatter(), and ResultMetadataFormatter.mimeType.

◆ getCollectionsMetadata()

Response getCollectionsMetadata ( @Parameter(description="The format of the collection page") @DefaultValue("html") @QueryParam("f") String  format)

Returns the metadata of collections registered in the SemanticWFS.

Parameters
formatThe metadataformat in which to return the results
Returns
The results as String
1776  {
1777  StringWriter strwriter = new StringWriter();
1778  XMLOutputFactory output = XMLOutputFactory.newInstance();
1779  XMLStreamWriter writer;
1780  try {
1781  writer = new IndentingXMLStreamWriter(output.createXMLStreamWriter(strwriter));
1782  writer.writeStartDocument();
1783  writer.setPrefix("gmd", "http://www.isotc211.org/2005/gmd");
1784  writer.setPrefix("gmx", "http://www.isotc211.org/2005/gmx");
1785  writer.setPrefix("gco", "http://www.isotc211.org/2005/gco");
1786  writer.setPrefix("csw", "http://www.opengis.net/cat/csw/2.0.2");
1787  writer.writeStartElement("http://www.opengis.net/cat/csw/2.0.2", "GetRecordsResponse");
1788  writer.writeNamespace("csw", "http://www.opengis.net/cat/csw/2.0.2");
1789  writer.writeStartElement("http://www.opengis.net/cat/csw/2.0.2", "SearchStatus");
1790  writer.writeAttribute("timestamp", new Date(System.currentTimeMillis()).toGMTString());
1791  writer.writeEndElement();
1792  writer.writeStartElement("http://www.opengis.net/cat/csw/2.0.2", "SearchResults");
1793  writer.flush();
1794  this.xmlwriter = writer;
1795  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
1796  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
1797  getCollectionMetadata(curobj.getString("name"), "gmd", "true","");
1798  }
1799  writer.writeEndElement();
1800  writer.writeEndDocument();
1801  writer.flush();
1802  return Response.ok(strwriter.toString()).type(MediaType.APPLICATION_XML).build();
1803  } catch (XMLStreamException e) {
1804  e.printStackTrace();
1805  return this.createExceptionResponse(e, "");
1806  }
1807  }

◆ getCollectionStyle()

Response getCollectionStyle ( @Parameter(description="Feature type name") @PathParam("collectionid") String  collectionid,
@Parameter(description="Style id") @PathParam("styleid") String  styleid,
@Parameter(description="Return format") @DefaultValue("html") @QueryParam("f") String  format 
)

Gets a style for a given featuretype with a given style identifier.

Parameters
collectionidthe featuretype name
styleidthe styleid
formatthe format in which the style is returned
Returns
The style as String
426  {
427  if (collectionid == null) {
428  throw new NotFoundException();
429  }
430  JSONObject workingobj = null;
431  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
432  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
433  if (curobj.getString("name").equalsIgnoreCase(collectionid)) {
434  workingobj = curobj;
435  break;
436  }
437  }
438  if (workingobj == null) {
439  throw new NotFoundException();
440  }
441  StyleObject obj = TripleStoreConnector.getStyle(collectionid, styleid, workingobj.getString("triplestore"),
442  workingobj.getString("namespace"));
443  if (obj == null) {
444  throw new NotFoundException();
445  }
446  if (format.contains("json")) {
447  return Response.ok(obj.toJSON()).type(MediaType.APPLICATION_JSON).build();
448  } else if (format.contains("xml")) {
449  return Response.ok(obj.toXML()).type(MediaType.APPLICATION_XML).build();
450  } else if (format.contains("html")) {
451  return Response.ok(obj.toHTML()).type(MediaType.TEXT_HTML).build();
452  }
453  return Response.ok(obj.toString()).type(MediaType.TEXT_PLAIN).build();
454  }

References TripleStoreConnector.getStyle(), StyleObject.toHTML(), StyleObject.toJSON(), StyleObject.toString(), and StyleObject.toXML().

◆ getCollectionStyles()

Response getCollectionStyles ( @Parameter(description="Feature type name") @PathParam("collectionid") String  collectionid,
@Parameter(description="Return type") @DefaultValue("html") @QueryParam("f") String  format 
)

Gets a list of all styles for a given featuretype.

Parameters
collectionidthe featuretype name
fthe format in which the style is returned
Returns
The style as String
470  {
471  if (collectionid == null) {
472  throw new NotFoundException();
473  }
474  JSONObject workingobj = null;
475  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
476  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
477  if (curobj.getString("name").equalsIgnoreCase(collectionid)) {
478  workingobj = curobj;
479  break;
480  }
481  }
482  if (workingobj == null) {
483  throw new NotFoundException();
484  }
485  if (format.contains("json")) {
486  return Response.ok(TripleStoreConnector.getStyleNames(wfsconf.getString("baseurl"), workingobj, format))
487  .type(MediaType.APPLICATION_JSON).build();
488  } else if (format.contains("html")) {
489  return Response.ok(TripleStoreConnector.getStyleNames(wfsconf.getString("baseurl"), workingobj, format))
490  .type(MediaType.TEXT_HTML).build();
491  }
492  return Response.ok(TripleStoreConnector.getStyleNames(wfsconf.getString("baseurl"), workingobj, format))
493  .type(MediaType.APPLICATION_XML).build();
494  }

References TripleStoreConnector.getStyleNames().

◆ getEndpoints()

Response getEndpoints ( )

Gets available SPARQL endpoitns from the triplestore configuration.

Returns
A JSON document containing SPARQL endpoint descriptions
3869  {
3870  return Response.ok(triplestoreconf.toString(2)).type(MediaType.APPLICATION_JSON).build();
3871  }

◆ getFeature()

Response getFeature ( @QueryParam("typename") String  typename,
@Parameter(description="The output format of the WFS service request") @DefaultValue("json") @QueryParam("outputFormat") String  output,
@Parameter(description="The amount of features to be returned", example="10") @DefaultValue("10") @QueryParam("count") String  count,
@Parameter(description="The starting index of the WFS request") @DefaultValue("0") @QueryParam("startindex") String  startindex,
@Parameter(description="The name of the CRS to be used") @DefaultValue("") @QueryParam("srsName") String  srsName,
@Parameter(description="Indicates the sorting order") @DefaultValue("ASC") @QueryParam("sortBy") String  sortBy,
@Parameter(description="The style to apply to the returned collection if any") @DefaultValue("") @QueryParam("mapstyles") String  style,
@Parameter(description="The version of the WFS", example="2.0.0") @DefaultValue("2.0.0") @QueryParam("version") String  version,
@Parameter(description="Indicates a specific resource id to be queried") @DefaultValue("") @QueryParam("resourceid") String  resourceids,
@Parameter(description="A WFS filter expression") @DefaultValue("") @QueryParam("filter") String  filter,
@Parameter(description="The filter language to be used in the filterExpression parameter") @DefaultValue("CQL") @QueryParam("filterLanguage") String  filterLanguage,
@Parameter(description="The result type to return") @DefaultValue("results") @QueryParam("resultType") String  resultType 
) throws JSONException, XMLStreamException
3915  {
3916  System.out.println(typename);
3917  if (typename == null) {
3918  throw new NotFoundException();
3919  }
3920  JSONObject workingobj = null;
3921  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
3922  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
3923  if (curobj.getString("name").equalsIgnoreCase(typename)) {
3924  workingobj = curobj;
3925  break;
3926  }
3927  }
3928  if (workingobj == null)
3929  throw new NotFoundException();
3930  String res = "";
3931  System.out.println(hitCache);
3932  if (resultType.equalsIgnoreCase("hits") && hitCache.containsKey(typename.toLowerCase())
3933  && (hitCache.get(typename.toLowerCase()).getOne().getTime() + milliesInDays) > System
3934  .currentTimeMillis()) {
3935  res = hitCache.get(typename.toLowerCase()).getTwo();
3936  } else {
3937  if (!workingobj.has("attcount") && !workingobj.getString("query").contains("?rel")
3938  && !workingobj.getString("query").contains("?val")) {
3939  featureTypeCache.put(typename.toLowerCase(),
3940  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
3941  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
3942  workingobj.put("attcount", 1);
3943  } else if (!workingobj.has("attcount")) {
3944  featureTypeCache.put(typename.toLowerCase(),
3945  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
3946  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
3947  }
3948  if (workingobj.getInt("attcount") == 0) {
3949  workingobj.put("attcount", 1);
3950  }
3951  try {
3952  res = TripleStoreConnector.executeQuery(workingobj.getString("query"),
3953  workingobj.getString("triplestore"), output,
3954  "" + count,
3955  "" + startindex, "gml:featureMember",
3956  typename, resourceids, workingobj, filter, resultType, srsName,"",
3957  "", style,false,
3958  (workingobj.has("invertXY")?workingobj.getBoolean("invertXY"):false),null);
3959  System.out.println(res);
3960  if (res==null || res.isEmpty()) {
3961  throw new NotFoundException();
3962  }
3963  if (resultType.equalsIgnoreCase("hits")) {
3964  hitCache.put(typename.toLowerCase(),
3965  new Tuple<Date, String>(new Date(System.currentTimeMillis()), res));
3966  }
3967  } catch (JSONException | XMLStreamException | IOException e1) {
3968  e1.printStackTrace();
3969  return this.createExceptionResponse(e1, "");
3970  }
3971  }
3972  System.out.println(output);
3973  if (output.contains("gml")) {
3974  StringWriter strwriter = new StringWriter();
3975  XMLOutputFactory outputf = XMLOutputFactory.newInstance();
3976  XMLStreamWriter writer;
3977  try {
3978  writer = new IndentingXMLStreamWriter(outputf.createXMLStreamWriter(strwriter));
3979  writer.writeStartDocument();
3980  writer.writeStartElement("wfs:FeatureCollection");
3981  writer.writeDefaultNamespace((wfsconf.getString("baseurl") + "/").replace("//", "/"));
3982  writer.writeNamespace("ows", "http://www.opengis.net/ows/1.1");
3983  writer.writeNamespace("sf", "http://www.opengis.net/ogcapi-features-1/1.0/sf");
3984  writer.writeNamespace("ogc", "http://www.opengis.net/ogc");
3985  writer.writeNamespace("gml", "http://www.opengis.net/gml");
3986  writer.writeNamespace("wfs", "http://www.opengis.net/wfs");
3987  writer.writeNamespace("xlink", "http://www.w3.org/1999/xlink");
3988  writer.setPrefix("gml", "http://www.opengis.net/gml");
3989  writer.setPrefix("wfs", "http://www.opengis.net/wfs");
3990 
3991  if (resultType.equalsIgnoreCase("hits")) {
3992  writer.writeAttribute("numberOfFeatures", res);
3993  } else {
3994  for (String ns : nameSpaceCache.get(typename.toLowerCase()).keySet()) {
3995  writer.setPrefix(nameSpaceCache.get(typename.toLowerCase()).get(ns), ns);
3996  writer.writeNamespace(nameSpaceCache.get(typename.toLowerCase()).get(ns), ns);
3997  }
3998  writer.writeCharacters("");
3999  writer.flush();
4000  strwriter.write(res);
4001  }
4002  writer.writeEndElement();
4003  writer.writeEndDocument();
4004  writer.flush();
4005  String result=strwriter.toString();
4006  String firstline=result.substring(0,result.indexOf(System.lineSeparator())).trim();
4007  if(firstline.isEmpty()) {
4008  return Response.ok(result.substring(result.indexOf(System.lineSeparator())+1)).type(MediaType.APPLICATION_XML).build();
4009  }else {
4010  return Response.ok(result).type(MediaType.APPLICATION_XML).build();
4011  }
4012  } catch (Exception e) {
4013  e.printStackTrace();
4014  return this.createExceptionResponse(e, "");
4015  }
4016  } else if (output.contains("json")) {
4017  JSONObject result = new JSONObject();
4018  JSONArray links = new JSONArray();
4019  JSONObject jsonresult = new JSONObject(res);
4020  JSONArray features = jsonresult.getJSONArray("features");
4021  if (jsonresult.has("@context")) {
4022  result.put("@context", jsonresult.getJSONObject("@context"));
4023  }
4024  result.put("type", "FeatureCollection");
4025  result.put("links", links);
4026  result.put("timeStamp", System.currentTimeMillis());
4027  if (resultType.equalsIgnoreCase("hits")) {
4028  result.put("numberMatched", res);
4029  } else {
4030  result.put("numberMatched", features.length());
4031  }
4032  result.put("numberReturned", features.length());
4033  result.put("features", features);
4034  System.out.println("EXPORT JSON: " + result.toString());
4035  return Response.ok(result.toString(2)).type(MediaType.APPLICATION_JSON).build();
4036  } else if (output.contains("html")) {
4037  StringBuilder builder = new StringBuilder();
4038  builder.append(htmlHead);
4039  builder.append("<body><header><h1 align=\"center\">");
4040  builder.append(typename);
4041  builder.append("</h1></header><div class=\"container-fluid\" role=\"main\"><div class=\"row\">");
4042  builder.append(res);
4043  // builder.append("<script>$( document ).ready(function()
4044  // {$('#queryres').DataTable({\"scrollX\":\"100%\",\"scrollCollapse\":
4045  // true});});</script></div></div></div></body></html>");
4046  return Response.ok(builder.toString()).type(MediaType.TEXT_HTML).build();
4047  } else if (output.contains("csv") || output.contains("geouri") || output.contains("geohash")) {
4048  return Response.ok(res).type(MediaType.TEXT_PLAIN).build();
4049  } else if (output.contains("gpx")) {
4050  return Response.ok(res).type(MediaType.TEXT_PLAIN).build();
4051  }
4052  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
4053  }
static long milliesInDays
Definition: WebService.java:106
static Map< String, Map< String, String > > nameSpaceCache
Definition: WebService.java:98
static Map< String, Tuple< Date, String > > hitCache
Definition: WebService.java:100

References TripleStoreConnector.executeQuery(), and TripleStoreConnector.getFeatureTypeInformation().

◆ getFeatureById()

Response getFeatureById ( @Parameter(description="The collection id") @PathParam("collectionid") String  collectionid,
@Parameter(description="The feature id") @PathParam("featureid") String  featureid,
@Parameter(description="The style to be applied") @DefaultValue("") @QueryParam("style") String  style,
@Parameter(description="The format to be returned") @DefaultValue("html") @QueryParam("f") String  format 
)

Returns a feature given its feature id.

Parameters
collectionidThe feature type
featureidThe feature id to return
styleThe style in which to style the feature
formatThe format in which to return the feature
Returns
The feature as String in the given format
1144  {
1145  System.out.println(collectionid + " - " + featureid + " - " + style);
1146  if (collectionid == null) {
1147  throw new NotFoundException();
1148  }
1149  JSONObject workingobj = null;
1150  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
1151  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
1152  if (curobj.getString("name").equalsIgnoreCase(collectionid)) {
1153  workingobj = curobj;
1154  break;
1155  }
1156  }
1157  if (workingobj == null) {
1158  throw new NotFoundException();
1159  }
1160  if (!workingobj.has("attcount") && !workingobj.getString("query").contains("?rel")
1161  && !workingobj.getString("query").contains("?val")) {
1162  workingobj.put("attcount", 1);
1163  } else if (!workingobj.has("attcount")) {
1164  featureTypeCache.put(collectionid.toLowerCase(),
1165  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
1166  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
1167  }
1168  String query = workingobj.getString("query");
1169  String res = "";
1170  try {
1171  res = TripleStoreConnector.executeQuery(query, workingobj.getString("triplestore"),
1172  format, "0", "0",
1173  "sf:featureMember", collectionid, featureid, workingobj,
1174  "", "", "","", "", style,false,
1175  (workingobj.has("invertXY")?workingobj.getBoolean("invertXY"):false),null);
1176  System.out.println(res);
1177  if (res == null || res.isEmpty()) {
1178  throw new NotFoundException();
1179  }
1180  } catch (JSONException | XMLStreamException | IOException e1) {
1181  // TODO Auto-generated catch block
1182  return this.createExceptionResponse(e1, "");
1183  }
1184 
1185  if (format != null && format.contains("json")) {
1186  JSONObject result = new JSONObject();
1187  JSONArray links = new JSONArray();
1188  result.put("links", links);
1189  for (ResultFormatter formatter : ResultFormatter.resultMap.values()) {
1190  JSONObject link = new JSONObject();
1191  if (formatter.exposedType.contains("geojson")) {
1192  link.put("rel", "self");
1193  } else {
1194  link.put("rel", "alternate");
1195  }
1196  link.put("href", wfsconf.getString("baseurl") + "/collections/" + collectionid + "/items/" + featureid
1197  + "?f=" + formatter.exposedType);
1198  link.put("type", formatter.exposedType);
1199  link.put("title", featureid);
1200  links.put(link);
1201  }
1202  result.put("id", featureid);
1203  JSONObject jsonresult = new JSONObject(res);
1204  JSONObject features = jsonresult.getJSONArray("features").getJSONObject(0);
1205  if (jsonresult.has("@context")) {
1206  result.put("@context", jsonresult.getJSONObject("@context"));
1207  }
1208  result.put("type", "Feature");
1209  result.put("links", links);
1210  result.put("timeStamp", System.currentTimeMillis());
1211  result.put("numberMatched", features.length());
1212  result.put("numberReturned", features.length());
1213  result.put("geometry", features.getJSONObject("geometry"));
1214  result.put("properties", features.getJSONObject("properties"));
1215  return Response.ok(result.toString(2)).type(MediaType.APPLICATION_JSON).build();
1216  } else if (format != null && format.contains("gml")) {
1217  StringWriter strwriter = new StringWriter();
1218  XMLOutputFactory output = XMLOutputFactory.newInstance();
1219  XMLStreamWriter writer;
1220  try {
1221  writer = new IndentingXMLStreamWriter(output.createXMLStreamWriter(strwriter));
1222  writer.writeStartDocument();
1223  writer.setDefaultNamespace("http://www.opengis.net/ogcapi-features-1/1.0");
1224  writer.setPrefix("atom", "http://www.w3.org/2005/Atom");
1225  writer.writeStartElement("sf:Feature");
1226  writer.writeAttribute("xmlns", "http://www.opengis.net/ogcapi-features-1/1.0");
1227  writer.writeAttribute("xmlns:atom", "http://www.w3.org/2005/Atom");
1228  writer.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
1229  writer.writeAttribute("xmlns:sf", "http://www.opengis.net/ogcapi-features-1/1.0/sf");
1230  writer.writeAttribute("xmlns:gml", "http://www.opengis.net/gml/3.2");
1231  writer.writeAttribute("service", "OGCAPI-FEATURES");
1232  writer.writeAttribute("version", "1.0.0");
1233  writer.writeStartElement("Title");
1234  writer.writeCharacters("");
1235  writer.writeEndElement();
1236  writer.writeStartElement("Description");
1237  writer.writeCharacters("");
1238  writer.writeEndElement();
1239  for (ResultFormatter formatter : ResultFormatter.resultMap.values()) {
1240  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1241  if (formatter.exposedType.contains("json")) {
1242  writer.writeAttribute("rel", "self");
1243  } else {
1244  writer.writeAttribute("rel", "alternate");
1245  }
1246  writer.writeAttribute("title", workingobj.getString("name"));
1247  writer.writeAttribute("type", formatter.exposedType);
1248  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/collections/"
1249  + workingobj.getString("name") + "/items/+" + featureid + "?f=" + formatter.exposedType);
1250  writer.writeEndElement();
1251  }
1252  strwriter.append(res);
1253  writer.writeEndElement();
1254  writer.writeEndDocument();
1255  writer.flush();
1256  return Response.ok(strwriter.toString()).type(MediaType.APPLICATION_XML).build();
1257  } catch (XMLStreamException e) {
1258  e.printStackTrace();
1259  return this.createExceptionResponse(e, "");
1260  }
1261  } else if (format == null || format.contains("html")) {
1262  StringBuilder builder = new StringBuilder();
1263  builder.append(htmlHead);
1264  builder.append("<body><header id=\"header\"><h1 align=\"center\">");
1265  builder.append(featureid);
1266  builder.append("</h1></header>");
1267  builder.append("<div class=\"sticky row crumbs\"><div class=\"col-sm-12 col-md-10 col-md-offset-1\">");
1268  builder.append("<a href=\""+wfsconf.getString("baseurl")+"\">Landingpage</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/\">Collections</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/"+collectionid+"\">"+workingobj.getString("name")+"</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/"+collectionid+"/items?f=html\">Items</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/"+collectionid+"/items/"+featureid+"?f=html\">"+featureid+"</a>");
1269  builder.append("</div></div>");
1270  builder.append("<div class=\"container-fluid\" role=\"main\"><div class=\"row\">");
1271  builder.append(res);
1272  builder.append("</div></div></div></div><footer id=\"footer\"><table width=100%><tbody><tr><td><a href=\"" + wfsconf.getString("baseurl") + "/collections/"
1273  + collectionid + "?f=html\">Back to " + collectionid
1274  + " Collection</a></td><td align=right>This page in <a href=\"" + wfsconf.getString("baseurl")
1275  + "/collections/" + workingobj.getString("name") + "/items/" + featureid
1276  + "?f=gml\">[GML]</a> <a href=\"" + wfsconf.getString("baseurl") + "/collections/"
1277  + workingobj.getString("name") + "/items/" + featureid + "?f=json\">[JSON]</a></td></tr></tbody></table>");
1278  builder.append("</footer></body></html>");
1279  return Response.ok(builder.toString()).type(MediaType.TEXT_HTML).build();
1280  } else {
1281  return Response.ok(res).type(MediaType.TEXT_PLAIN).build();
1282  }
1283  }

References TripleStoreConnector.executeQuery(), TripleStoreConnector.getFeatureTypeInformation(), and ResultFormatter.resultMap.

◆ getFeatureByIdHTML()

Response getFeatureByIdHTML ( @Parameter(description="The collection id") @PathParam("collectionid") String  collectionid,
@Parameter(description="The feature id") @PathParam("featureid") String  featureid,
@Parameter(description="The style to be applied") @DefaultValue("") @QueryParam("mapstyle") String  style,
@Parameter(description="The format to be returned") @DefaultValue("html") @QueryParam("f") String  format 
)

Returns a feature given its feature id.

Parameters
collectionidThe feature type
featureidThe feature id to return
styleThe style in which to style the feature
formatThe format in which to return the feature
Returns
The feature as String in the given format
1122  {
1123  return getFeatureById(collectionid, featureid, style, format);
1124  }
Response getFeatureById( @Parameter(description="The collection id") @PathParam("collectionid") String collectionid, @Parameter(description="The feature id") @PathParam("featureid") String featureid, @Parameter(description="The style to be applied") @DefaultValue("") @QueryParam("style") String style, @Parameter(description="The format to be returned") @DefaultValue("html") @QueryParam("f") String format)
Returns a feature given its feature id.
Definition: WebService.java:1140

◆ getFeatureByIdJSON()

Response getFeatureByIdJSON ( @Parameter(description="The collection id") @PathParam("collectionid") String  collectionid,
@Parameter(description="The feature id") @PathParam("featureid") String  featureid,
@Parameter(description="The style to be applied") @DefaultValue("") @QueryParam("mapstyle") String  style,
@Parameter(description="The format to be returned") @DefaultValue("json") @QueryParam("f") String  format 
)

Returns a feature given its feature id.

Parameters
collectionidThe feature type
featureidThe feature id to return
styleThe style in which to style the feature
formatThe format in which to return the feature
Returns
The feature as String in the given format
971  {
972  return getFeatureById(collectionid, featureid, style, format);
973  }

◆ getFeatureByIdXML()

Response getFeatureByIdXML ( @Parameter(description="The collection id") @PathParam("collectionid") String  collectionid,
@Parameter(description="The feature id") @PathParam("featureid") String  featureid,
@Parameter(description="The style to be applied") @DefaultValue("") @QueryParam("mapstyle") String  style,
@Parameter(description="The format to be returned") @DefaultValue("gml") @QueryParam("f") String  format 
)

Returns a feature given its feature id.

Parameters
collectionidThe feature type
featureidThe feature id to return
styleThe style in which to style the feature
formatThe format in which to return the feature
Returns
The feature as String in the given format
993  {
994  return getFeatureById(collectionid, featureid, style, format);
995  }

◆ getFeatureTypes()

String getFeatureTypes ( )

Returns featuretypes known by the SemanticWFS service.

Returns
The feature type document as JSON.
4324  {
4325  return wfsconf.toString(2);
4326  }

References User.toString().

◆ getGeoClassesFromOntology()

Response getGeoClassesFromOntology ( @Parameter(description="The SPARQL endpoint to load classes from") @QueryParam("endpoint") String  endpoint)

Gets geospatial classes from a SPARQL endpoint.

Parameters
endpointThe SPARQL endpoint
Returns
A JSON document containing class descriptions
3846  {
3847  if(triplestoreconf.getJSONObject("endpoints").has(endpoint)) {
3848  Map<String,String> classes=TripleStoreConnector.getClassesFromOntology(triplestoreconf.getJSONObject("endpoints").getJSONObject(endpoint));
3849  JSONObject result=new JSONObject();
3850  for(String cls:classes.keySet()) {
3851  result.put(cls, classes.get(cls));
3852  }
3853  return Response.ok(result.toString(2)).type(MediaType.APPLICATION_JSON).build();
3854  }else {
3855  return Response.ok("{}").type(MediaType.APPLICATION_JSON).build();
3856  }
3857  }

References TripleStoreConnector.getClassesFromOntology().

◆ getGmlObject()

Response getGmlObject ( @QueryParam("typename") String  typename,
@QueryParam("GmlObjectId") String  gmlobjectid,
@DefaultValue("4") @QueryParam("traverseXlinkDepth") String  traverseXlinkDepth,
@DefaultValue("gml") @QueryParam("outputFormat") String  output 
)
4060  {
4061  try {
4062  return this.getFeature(typename, output, "1", "0", "", "ASC", "", "2.0.0", gmlobjectid, "", "CQL", "");
4063  } catch (JSONException | XMLStreamException e) {
4064  // TODO Auto-generated catch block
4065  e.printStackTrace();
4066  return this.createExceptionResponse(e, "");
4067  }
4068  }

◆ getPropertiesByClass()

Response getPropertiesByClass ( @Parameter(description="The SPARQL endpoint to load properties from") @QueryParam("endpoint") String  endpoint,
@Parameter(description="The class from which properties should be loaded") @QueryParam("class") String  classs 
)

Gets available properties associated with a certain class.

Parameters
endpointThe SPARQL endpoint to query
classsThe class to use in the query
Returns
A JSON document containing the queried properties
3887  {
3888  Map<String, String> classes=TripleStoreConnector.getPropertiesByClass(endpoint, classs);
3889  JSONObject result=new JSONObject();
3890  for(String cls:classes.keySet()) {
3891  result.put(cls,classes.get(cls).toString());
3892  }
3893  return Response.ok(result.toString(2)).type(MediaType.APPLICATION_JSON).build();
3894  }

References TripleStoreConnector.getPropertiesByClass().

◆ getPropertyValue()

Response getPropertyValue ( @Parameter(description="Feature type to query") @QueryParam("typename") String  typename,
@QueryParam("valuereference") String  propertyname,
@DefaultValue("json") @QueryParam("outputFormat") String  output,
@DefaultValue("") @QueryParam("resourceids") String  resourceids,
@DefaultValue("") @QueryParam("filter") String  filter,
@DefaultValue("0") @QueryParam("count") String  count,
@DefaultValue("results") @QueryParam("resultType") String  resultType 
)
4079  {
4080  System.out.println(typename);
4081  System.out.println(propertyname);
4082  if (typename == null || propertyname == null) {
4083  throw new NotFoundException();
4084  }
4085  JSONObject workingobj = null;
4086  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
4087  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
4088  if (curobj.getString("name").equalsIgnoreCase(typename)) {
4089  workingobj = curobj;
4090  break;
4091  }
4092  }
4093  if (workingobj == null)
4094  throw new NotFoundException();
4095  if (!propertyname.startsWith("http")) {
4096  if (!featureTypeCache.containsKey(typename.toLowerCase())) {
4097  featureTypeCache.put(typename.toLowerCase(),
4098  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
4099  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
4100  }
4101  for (String key : featureTypeCache.get(typename.toLowerCase()).keySet()) {
4102  if (key.contains(propertyname)) {
4103  propertyname = key;
4104  break;
4105  }
4106  }
4107  }
4108  String res = "";
4109  try {
4110  res = TripleStoreConnector.executePropertyValueQuery(workingobj.getString("triplestore"), output,
4111  propertyname, "gml:featureMember", typename, resourceids, workingobj, filter, count, resultType,
4112  "",null);
4113  System.out.println(res);
4114  } catch (JSONException | XMLStreamException | IOException e1) {
4115  e1.printStackTrace();
4116  return this.createExceptionResponse(e1, "");
4117  }
4118  if (resultType.equalsIgnoreCase("hits")) {
4119  return Response.ok(res).type(MediaType.TEXT_PLAIN).build();
4120  }
4121  if (output != null && output.contains("json")) {
4122  return Response.ok(res).type(MediaType.APPLICATION_JSON).build();
4123  } else if (output != null && output.contains("gml")) {
4124  StringWriter strwriter = new StringWriter();
4125  XMLOutputFactory outputf = XMLOutputFactory.newInstance();
4126  XMLStreamWriter writer;
4127  try {
4128  writer = new IndentingXMLStreamWriter(outputf.createXMLStreamWriter(strwriter));
4129  writer.writeStartDocument();
4130  writer.writeStartElement("ValueCollection");
4131  writer.writeDefaultNamespace("http://www.opengis.net/wfs/2.0");
4132  writer.writeCharacters("");
4133  writer.flush();
4134  strwriter.write(res);
4135  writer.writeEndElement();
4136  writer.writeEndDocument();
4137  writer.flush();
4138  } catch (Exception e) {
4139  e.printStackTrace();
4140  return this.createExceptionResponse(e, "");
4141  }
4142  return Response.ok(strwriter.toString()).type(MediaType.APPLICATION_XML).build();
4143  } else if (output != null && output.contains("html")) {
4144  StringBuilder builder = new StringBuilder();
4145  builder.append("<html><head></head><body><header id=\"header\"><h1 align=center>PropertyRequest: " + typename + "["
4146  + propertyname
4147  + "]</h1></header><div class=\"container-fluid\" role=\"main\"><div class=\"row\"><div class=\"col-sm-12\">");
4148  builder.append(res);
4149  builder.append("</div></div></div><footer id=\"footer\"><a href=\"" + wfsconf.getString("baseurl")
4150  + "/?f=html\">Back to LandingPage</a></footer></body></html>");
4151  return Response.ok(builder.toString()).type(MediaType.TEXT_HTML).build();
4152  } else if (output != null) {
4153  return Response.ok(res).type(MediaType.TEXT_PLAIN).build();
4154  }
4155  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
4156  }

References TripleStoreConnector.executePropertyValueQuery(), and TripleStoreConnector.getFeatureTypeInformation().

◆ getSchema()

Response getSchema ( @Parameter(description="The collection id for which to return the schema") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format in which the schema should be returned", example="json") @DefaultValue("gml") @QueryParam("f") String  format 
)

Returns a schema of a given collection.

Parameters
collectionidThe feature collection id
formatThe format in which to return the collection
Returns
The returned collection as String
2281  {
2282  if (format.contains("json")) {
2283  return this.describeFeatureTypeJSON(collectionid, "1.0.0");
2284  } else {
2285  try {
2286  return this.describeFeatureType(collectionid, "2.0.0");
2287  } catch (XMLStreamException e) {
2288  // TODO Auto-generated catch block
2289  e.printStackTrace();
2290  throw new NotFoundException();
2291  }
2292  }
2293 
2294  }
Response describeFeatureTypeJSON( @Parameter(description="The feature type to describe") @QueryParam("typename") String typename, @Parameter(description="The version of the WFS service") @DefaultValue("version") @QueryParam("version") String version)
Describes a feature type in JSON.
Definition: WebService.java:3757

◆ landingPage()

Response landingPage ( @Parameter(description="The format of the landingpage") @DefaultValue("html") @QueryParam("f") String  format)

Returns the landing page of the OGC API Features service.

Parameters
formatThe format in which the page is to be returned
Returns
The landing page as String
1474  {
1475  if (format == null || format.contains("json")) {
1476  JSONObject result = new JSONObject();
1477  JSONArray links = new JSONArray();
1478  JSONObject link = new JSONObject();
1479  link.put("href", wfsconf.getString("baseurl") + "?f=json");
1480  link.put("rel", "self");
1481  link.put("type", "application/json");
1482  link.put("title", "This document");
1483  links.put(link);
1484  link = new JSONObject();
1485  link.put("href", wfsconf.getString("baseurl") + "?f=xml");
1486  link.put("rel", "alternate");
1487  link.put("type", "application/xml");
1488  link.put("title", "This document as XML");
1489  links.put(link);
1490  link = new JSONObject();
1491  link.put("href", wfsconf.getString("baseurl") + "?f=html");
1492  link.put("rel", "alternate");
1493  link.put("type", "text/html");
1494  link.put("title", "This document as HTML");
1495  links.put(link);
1496  link = new JSONObject();
1497  link.put("href", wfsconf.getString("baseurl") + "/openapi3");
1498  link.put("rel", "service-desc");
1499  link.put("type", "application/vnd.oai.openapi+json;version=3.0");
1500  link.put("title", "The API definition (JSON)");
1501  links.put(link);
1502  link = new JSONObject();
1503  link.put("href", wfsconf.getString("baseurl") + "/openapi3y");
1504  link.put("rel", "service-desc");
1505  link.put("type", "application/vnd.oai.openapi+yaml;version=3.0");
1506  link.put("title", "The API definition (YAML)");
1507  links.put(link);
1508  link = new JSONObject();
1509  link.put("href", wfsconf.getString("baseurl") + "/api/");
1510  link.put("rel", "service-doc");
1511  link.put("type", "text/html");
1512  link.put("title", "The API definition (HTML)");
1513  links.put(link);
1514  link = new JSONObject();
1515  link.put("href", wfsconf.getString("baseurl") + "/conformance?f=html");
1516  link.put("rel", "conformance");
1517  link.put("type", "text/html");
1518  link.put("title", "Conformance Declaration as HTML");
1519  links.put(link);
1520  link = new JSONObject();
1521  link.put("href", wfsconf.getString("baseurl") + "/conformance?f=xml");
1522  link.put("rel", "conformance");
1523  link.put("type", "application/xml");
1524  link.put("title", "Conformance Declaration as XML");
1525  links.put(link);
1526  link = new JSONObject();
1527  link.put("href", wfsconf.getString("baseurl") + "/conformance?f=json");
1528  link.put("rel", "conformance");
1529  link.put("type", "application/json");
1530  link.put("title", "Conformance Declaration as JSON");
1531  links.put(link);
1532  link = new JSONObject();
1533  link.put("href", wfsconf.getString("baseurl") + "/collections?f=json");
1534  link.put("rel", "data");
1535  link.put("type", "application/json");
1536  link.put("title", "Collections Metadata as JSON");
1537  links.put(link);
1538  link = new JSONObject();
1539  link.put("href", wfsconf.getString("baseurl") + "/collections?f=xml");
1540  link.put("rel", "data");
1541  link.put("type", "application/xml");
1542  link.put("title", "Collections Metadata as XML");
1543  links.put(link);
1544  link = new JSONObject();
1545  link.put("href", wfsconf.getString("baseurl") + "/collections?f=html");
1546  link.put("rel", "data");
1547  link.put("type", "text/html");
1548  link.put("title", "Collections Metadata as HTML");
1549  links.put(link);
1550  result.put("title", wfsconf.getString("servicetitle"));
1551  result.put("description", wfsconf.getString("servicedescription"));
1552  result.put("links", links);
1553  JSONArray collections=new JSONArray();
1554  result.put("collections", collections);
1555  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
1556  JSONObject coll = new JSONObject();
1557  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
1558  coll.put("id", curobj.getString("name"));
1559  coll.put("name", curobj.getString("name"));
1560  coll.put("title", curobj.getString("name"));
1561  if(curobj.has("description"))
1562  coll.put("description", curobj.getString("description"));
1563  /*JSONObject extent = new JSONObject();
1564  JSONArray spatial = new JSONArray();
1565  JSONArray temporal=new JSONArray();
1566  temporal.put("1970-01-01T00:00:00Z");
1567  temporal.put("2020-08-22T22:10:44Z");*/
1568  JSONArray crs = new JSONArray();
1569  crs.put("http://www.opengis.net/def/crs/EPSG/0/"+curobj.getString("targetCRS").substring(curobj.getString("targetCRS").indexOf(":")+1));
1570  coll.put("storageCRS", "http://www.opengis.net/def/crs/EPSG/0/"+curobj.getString("targetCRS").substring(curobj.getString("targetCRS").indexOf(":")+1));
1571  coll.put("crs", crs);
1572  //JSONArray crs = new JSONArray();
1573  //crs.put("http://www.opengis.net/def/crs/OGC/1.3/CRS84");
1574  //coll.put("crs", crs);
1575  /*coll.put("extent", extent);
1576  extent.put("spatial", spatial);
1577  extent.put("temporal", temporal);*/
1578  JSONArray colinks = new JSONArray();
1579  for (ResultFormatter formatter : ResultFormatter.resultMap.values()) {
1580  link = new JSONObject();
1581  link.put("rel", "item");
1582  link.put("href", wfsconf.getString("baseurl") + "/collections/" + curobj.getString("name")
1583  + "/items" + "?f=" + formatter.urlformat);
1584  link.put("type", formatter.exposedType);
1585  link.put("title", curobj.getString("name"));
1586  colinks.put(link);
1587  }
1588  link.put("rel", "self");
1589  link.put("title", "This document");
1590  link.put("type", "application/json");
1591  link.put("href", wfsconf.get("baseurl") + "/collections/"+curobj.getString("name")+"?f=json");
1592  colinks.put(link);
1593  link = new JSONObject();
1594  link.put("rel", "alternate");
1595  link.put("title", "This document as XML");
1596  link.put("type", "application/xml");
1597  link.put("href", wfsconf.get("baseurl") + "/collections/"+curobj.getString("name")+"?f=gml");
1598  colinks.put(link);
1599  link = new JSONObject();
1600  link.put("rel", "alternate");
1601  link.put("title", "This document as HTML");
1602  link.put("type", "text/html");
1603  link.put("href", wfsconf.get("baseurl") + "/collections/"+curobj.getString("name")+"?f=html");
1604  colinks.put(link);
1605  link = new JSONObject();
1606  link.put("rel", "describedBy");
1607  link.put("title", "XML Schema for this dataset");
1608  link.put("type", "application/xml");
1609  link.put("href", "http://www.acme.com/3.0/wfs/collections/"+curobj.getString("name")+"/schema");
1610  colinks.put(link);
1611  coll.put("links", colinks);
1612  collections.put(coll);
1613  }
1614  return Response.ok(result.toString(2)).type(MediaType.APPLICATION_JSON).build();
1615  } else if (format.contains("xml")) {
1616  StringWriter strwriter = new StringWriter();
1617  XMLOutputFactory output = XMLOutputFactory.newInstance();
1618  XMLStreamWriter writer;
1619  try {
1620  writer = new IndentingXMLStreamWriter(output.createXMLStreamWriter(strwriter));
1621  writer.writeStartDocument();
1622  writer.setDefaultNamespace("http://www.opengis.net/ogcapi-features-1/1.0");
1623  writer.writeStartElement("LandingPage");
1624  writer.setPrefix("atom", "http://www.w3.org/2005/Atom");
1625  writer.writeAttribute("xmlns:atom", "http://www.w3.org/2005/Atom");
1626  writer.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
1627  writer.writeAttribute("xmlns:sf", "http://www.opengis.net/ogcapi-features-1/1.0/sf");
1628  writer.writeAttribute("xmlns:gml", "http://www.opengis.net/gml/3.2");
1629  writer.writeAttribute("service", "OGCAPI-FEATURES");
1630  writer.writeAttribute("version", "1.0.0");
1631  writer.writeStartElement("Title");
1632  writer.writeCharacters(wfsconf.getString("servicetitle"));
1633  writer.writeEndElement();
1634  writer.writeStartElement("Description");
1635  writer.writeCharacters(wfsconf.getString("servicedescription"));
1636  writer.writeEndElement();
1637  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1638  writer.writeAttribute("rel", "self");
1639  writer.writeAttribute("title", "This document");
1640  writer.writeAttribute("type", "application/xml");
1641  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/?f=gml");
1642  writer.writeEndElement();
1643  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1644  writer.writeAttribute("rel", "alternate");
1645  writer.writeAttribute("title", "This document as JSON");
1646  writer.writeAttribute("type", "application/json");
1647  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/?f=json");
1648  writer.writeEndElement();
1649  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1650  writer.writeAttribute("rel", "alternate");
1651  writer.writeAttribute("title", "This document as HTML");
1652  writer.writeAttribute("type", "text/html");
1653  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/?f=html");
1654  writer.writeEndElement();
1655  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1656  writer.writeAttribute("rel", "service-doc");
1657  writer.writeAttribute("title", "The API definition (HTML)");
1658  writer.writeAttribute("type", "text/html");
1659  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/api/");
1660  writer.writeEndElement();
1661  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1662  writer.writeAttribute("rel", "service-desc");
1663  writer.writeAttribute("title", "The API definition (YAML)");
1664  writer.writeAttribute("type", "application/vnd.oai.openapi+yaml;version=3.0");
1665  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/openapi3y");
1666  writer.writeEndElement();
1667  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1668  writer.writeAttribute("rel", "service-desc");
1669  writer.writeAttribute("title", "The API defnition (JSON)");
1670  writer.writeAttribute("type", "application/vnd.oai.openapi+json;version=3.0");
1671  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/openapi3");
1672  writer.writeEndElement();
1673  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1674  writer.writeAttribute("rel", "conformance");
1675  writer.writeAttribute("title", "Conformance Declaration as JSON");
1676  writer.writeAttribute("type", "application/json");
1677  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/conformance?f=json");
1678  writer.writeEndElement();
1679  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1680  writer.writeAttribute("rel", "conformance");
1681  writer.writeAttribute("title", "Conformance Declaration as XML");
1682  writer.writeAttribute("type", "application/xml");
1683  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/conformance?f=gml");
1684  writer.writeEndElement();
1685  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1686  writer.writeAttribute("rel", "conformance");
1687  writer.writeAttribute("title", "Conformance Declaration as HTML");
1688  writer.writeAttribute("type", "text/html");
1689  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/conformance?f=html");
1690  writer.writeEndElement();
1691  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1692  writer.writeAttribute("rel", "data");
1693  writer.writeAttribute("title", "Collections Metadata as JSON");
1694  writer.writeAttribute("type", "application/json");
1695  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/collections?f=json");
1696  writer.writeEndElement();
1697  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1698  writer.writeAttribute("rel", "data");
1699  writer.writeAttribute("title", "Collections Metadata as XML");
1700  writer.writeAttribute("type", "application/xml");
1701  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/collections?f=gml");
1702  writer.writeEndElement();
1703  writer.writeStartElement("http://www.w3.org/2005/Atom", "link");
1704  writer.writeAttribute("rel", "data");
1705  writer.writeAttribute("title", "Collections Metadata as HTML");
1706  writer.writeAttribute("type", "text/html");
1707  writer.writeAttribute("href", wfsconf.getString("baseurl") + "/collections?f=html");
1708  writer.writeEndElement();
1709  writer.writeEndElement();
1710  writer.writeEndDocument();
1711  writer.flush();
1712  return Response.ok(strwriter.toString()).type(MediaType.APPLICATION_XML).build();
1713  } catch (XMLStreamException e) {
1714  // TODO Auto-generated catch block
1715  return this.createExceptionResponse(e, "");
1716  }
1717  } else if (format.contains("html")) {
1718  StringBuilder builder = new StringBuilder();
1719  builder.append(htmlHead);
1720  builder.append("<body><header id=\"header\"><h1 align=\"center\">LandingPage: " + wfsconf.getString("servicetitle"));
1721  builder.append("</h1></header>");
1722  builder.append("<div class=\"sticky row crumbs\"><div class=\"col-sm-12 col-md-10 col-md-offset-1\">");
1723  builder.append("<a href=\""+wfsconf.getString("baseurl")+"\">Landingpage</a>");
1724  builder.append("</div></div>");
1725  builder.append("<div class=\"container-fluid\" role=\"main\"><div class=\"row\"><div class=\"col-sm-12\"><p>"
1726  + wfsconf.getString("servicedescription") + "</p><ul>");
1727  builder.append("<li>API Documentation in <a href=\"" + wfsconf.getString("baseurl")
1728  + "/api/\">[HTML]</a>");
1729  builder.append(" <a href=\"" + wfsconf.getString("baseurl") + "/openapi.yaml\">[YAML]</a>");
1730  builder.append(" <a href=\"" + wfsconf.getString("baseurl") + "/openapi.json\">[JSON]</a></li>");
1731  builder.append("<li>Conformance Declaration in <a href=\"" + wfsconf.getString("baseurl")
1732  + "/conformance?f=html\">[HTML]</a>");
1733  builder.append(" <a href=\"" + wfsconf.getString("baseurl") + "/conformance?f=gml\">[XML]</a>");
1734  builder.append(" <a href=\"" + wfsconf.getString("baseurl") + "/conformance?f=json\">[JSON]</a></li>");
1735  builder.append("<li>Collections Metadata in <a href=\"" + wfsconf.getString("baseurl")
1736  + "/collections?f=html\">[HTML]</a>");
1737  builder.append(" <a href=\"" + wfsconf.getString("baseurl") + "/collections?f=gml\">[XML]</a>");
1738  builder.append(" <a href=\"" + wfsconf.getString("baseurl") + "/collections?f=json\">[JSON]</a></li></ul>");
1739  builder.append("This homepage also exposes a WFS 1.0.0, 1.1.0, 2.0.0 compatible Webservice:<ul>");
1740  builder.append("<li>GetCapabilities WFS 1.0.0 ");
1741  builder.append("<a href=\"" + wfsconf.getString("baseurl")
1742  + "/wfs?REQUEST=getCapabilities&VERSION=1.0.0\">[XML]</a><br/>");
1743  builder.append("</li><li>GetCapabilities WFS 1.1.0 ");
1744  builder.append("<a href=\"" + wfsconf.getString("baseurl")
1745  + "/wfs?REQUEST=getCapabilities&VERSION=1.1.0\">[XML]</a>");
1746  builder.append("</li><li>GetCapabilities WFS 2.0.0 ");
1747  builder.append("<a href=\"" + wfsconf.getString("baseurl")
1748  + "/wfs?REQUEST=getCapabilities&VERSION=2.0.0\">[XML]</a>");
1749  builder.append(
1750  "</li></ul>Local Options:<ul><li><a href=\""+ wfsconf.getString("baseurl")+"/config/geotreeview.html\">Ontology Browser</a></li>"
1751  + "<li><a href=\""+wfsconf.getString("baseurl")+"/config/queryinterface.html\">SPARQL Query Interface</a></li>"
1752  + "<li><a href=\""+ wfsconf.getString("baseurl")
1753  + "/config/configuration.html\">Semantic WFS Configuration</a></li><li><a href=\"../importer/\">Semantic Uplift Tools</a></li></ul></div></div></div><footer id=\"footer\"><table width=100%><tbody><tr><td><a href=\"" + wfsconf.getString("baseurl")
1754  + "/?f=html\">Back to LandingPage</a></td><td align=right>This page in <a href=\""
1755  + wfsconf.getString("baseurl") + "/?f=xml\">[XML]</a> <a href=\""
1756  + wfsconf.getString("baseurl")
1757  + "/?f=json\">[JSON]</a></td></tr></table></footer></body></html>");
1758  return Response.ok(builder.toString()).type(MediaType.TEXT_HTML).build();
1759  } else {
1760  throw new NotFoundException();
1761  }
1762  }

References ResultFormatter.resultMap.

◆ landingPageHTML()

Response landingPageHTML ( @Parameter(description="The format of the landingpage") @DefaultValue("html") @QueryParam("f") String  format)
1438  {
1439  return landingPage(format);
1440  }
Response landingPage(@Parameter(description="The format of the landingpage") @DefaultValue("html") @QueryParam("f") String format)
Returns the landing page of the OGC API Features service.
Definition: WebService.java:1474

◆ landingPageJSON()

Response landingPageJSON ( @Parameter(description="The format of the landingpage") @DefaultValue("json") @QueryParam("f") String  format)
1448  {
1449  return landingPage(format);
1450  }

◆ landingPageXML()

Response landingPageXML ( @Parameter(description="The format of the landingpage") @DefaultValue("xml") @QueryParam("f") String  format)
1458  {
1459  return landingPage(format);
1460  }

◆ lockFeature()

String lockFeature ( )

Lock Feature method of the WFS specification.

Returns
4438  {
4439  return null;
4440  }

◆ login()

Response login ( @Parameter(description="Username for authorization") @QueryParam("username") String  username,
@Parameter(description="Password for authorization") @QueryParam("password") String  password 
)

Performs a login returning an authtoken if successful.

Parameters
usernameThe username
passwordThe password
Returns
An authtoken if successful, an emptry String if not
4307  {
4308  final String dir = System.getProperty("user.dir");
4309  System.out.println("current dir = " + dir);
4310  User user=UserManagementConnection.getInstance().login(username, password);
4311  if(user!=null) {
4312  return Response.ok(user.authToken).type(MediaType.TEXT_PLAIN).build();
4313  }
4314  return Response.ok("").type(MediaType.TEXT_PLAIN).build();
4315  }

References User.authToken, UserManagementConnection.getInstance(), and UserManagementConnection.login().

◆ openapiJSON()

Response openapiJSON ( )
182  {
183  System.out.println("OpenAPI JSON");
184  CloseableHttpClient httpClient = HttpClients.createDefault();
185  HttpGet request = new HttpGet(wfsconf.get("baseurl")+"/openapi.json");
186  CloseableHttpResponse response;
187  try {
188  response = httpClient.execute(request);
189  HttpEntity entity = response.getEntity();
190  String result = EntityUtils.toString(entity);
191  System.out.println(result);
192  response.close();
193  httpClient.close();
194  Response res=Response.status(Response.Status.OK).entity(result).type(OpenAPIMediaType.OA3_TYPE).build();
195  return res;
196  } catch (IOException e) {
197  // TODO Auto-generated catch block
198  e.printStackTrace();
199  return Response.ok("",OpenAPIMediaType.OA3_TYPE).build();
200  }
201  }

References OpenAPIMediaType.OA3_TYPE.

◆ openapiYAML()

Response openapiYAML ( )
206  {
207  System.out.println("OpenAPI JSON");
208  CloseableHttpClient httpClient = HttpClients.createDefault();
209  HttpGet request = new HttpGet(wfsconf.get("baseurl")+"/openapi.yaml");
210  CloseableHttpResponse response;
211  try {
212  response = httpClient.execute(request);
213  HttpEntity entity = response.getEntity();
214  String result = EntityUtils.toString(entity);
215  System.out.println(result);
216  response.close();
217  httpClient.close();
218  Response res=Response.status(Response.Status.OK).entity(result).type("application/vnd.oai.openapi+yaml;version=3.0").build();
219  return res;
220  } catch (IOException e) {
221  // TODO Auto-generated catch block
222  e.printStackTrace();
223  return Response.ok("","application/vnd.oai.openapi+yaml;version=3.0").build();
224  }
225  }

◆ prefixes()

String prefixes ( )

Returns prefixes known by the SemanticWFS service.

Returns
The prefix document as JSON.
4338  {
4339  return TripleStoreConnector.prefixCollection;
4340  }

References TripleStoreConnector.prefixCollection.

◆ queryables()

Response queryables ( @Parameter(description="The id of the collection to be considered") @PathParam("collectionid") String  collectionid,
@Parameter(description="The format in which the collection should be returned", example="geojson") @DefaultValue("html") @QueryParam("f") String  format 
)

Returns information about the queryables of ths given feature type.

Parameters
collectionidThe feature type to retrieve information about
formatThe format in which to retrieve the information
Returns
The queryables as String
1298  {
1299  if (collectionid == null) {
1300  throw new NotFoundException();
1301  }
1302  JSONObject workingobj = null;
1303  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
1304  JSONObject curobj = wfsconf.getJSONArray("datasets").getJSONObject(i);
1305  if (curobj.getString("name").equalsIgnoreCase(collectionid)) {
1306  workingobj = curobj;
1307  break;
1308  }
1309  }
1310  if (workingobj == null) {
1311  throw new NotFoundException();
1312  }
1313  if (!featureTypeCache.containsKey(collectionid.toLowerCase())) {
1314  featureTypeCache.put(collectionid.toLowerCase(),
1315  TripleStoreConnector.getFeatureTypeInformation(workingobj.getString("query"),
1316  workingobj.getString("triplestore"), workingobj.getString("name"), workingobj));
1317  }
1318  Map<String, String> mapping = featureTypeCache.get(collectionid.toLowerCase());
1319  StringBuilder builder = new StringBuilder();
1320  StringBuilder builder2 = new StringBuilder();
1321  JSONObject geojson = new JSONObject();
1322  JSONObject geometry = new JSONObject();
1323  JSONObject properties = new JSONObject();
1324  geojson.put("type", "Feature");
1325  geojson.put("id", collectionid);
1326  geojson.put("geometry", geometry);
1327  geojson.put("properties", properties);
1328  builder.append(htmlHead);
1329  builder.append("<body><header id=\"header\"><h1 align=\"center\">");
1330  builder.append(collectionid+" Queryables");
1331  builder.append("</h1></header>");
1332  builder.append("<div class=\"sticky row crumbs\"><div class=\"col-sm-12 col-md-10 col-md-offset-1\">");
1333  builder.append("<a href=\""+wfsconf.getString("baseurl")+"\">Landingpage</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/\">Collections</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/"+collectionid+"\">"+workingobj.getString("name")+"</a> / <a href=\""+wfsconf.getString("baseurl")+"/collections/"+collectionid+"/queryables?f=html\">Queryables</a>");
1334  builder.append("</div></div>");
1335  builder.append("<div class=\"container-fluid\" role=\"main\"><div class=\"row\">");
1336  builder.append("<table width=100%><tr><td width=\"100%\" rowspan=2>");
1337  builder.append("<script>var overlayMaps={}; var overlayControl; var typeColumn=\""
1338  + (workingobj.has("typeColumn") ? workingobj.getString("typeColumn") : "")
1339  + "\"; var markercollection=[]; var epsg=\""
1340  + (workingobj.has("targetCRS") ? workingobj.getString("targetCRS") : "") + "\";");
1341  builder2.append(((HTMLFormatter) ResultFormatter.getFormatter("html")).htmlHeader2);
1342 
1343  builder2.append("</td><td>Contents:<table class=\"description\" border=\"1\"><tr><th>Value</th><th>Type</th>");
1344  String lon = null, lat = null;
1345  if (mapping != null) {
1346  for (String elem : mapping.keySet()) {
1347  if (!elem.equals("http://www.opengis.net/ont/geosparql#hasGeometry")
1348  && !elem.equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")) {
1349  if (elem.contains("http")) {
1350  if (elem.contains("#")) {
1351  builder2.append("<tr><td align=center><a href=\"" + elem + "\">"
1352  + elem.substring(elem.lastIndexOf('#') + 1) + "</a> ");
1353  } else {
1354  builder2.append("<tr><td align=center><a href=\"" + elem + "\">"
1355  + elem.substring(elem.lastIndexOf('/') + 1) + "</a> ");
1356  }
1357  } else {
1358  builder2.append("<tr><td align=center>" + elem);
1359  }
1360  if (mapping.get(elem).contains("^^")) {
1361  String type = mapping.get(elem).substring(mapping.get(elem).lastIndexOf("^^") + 2);
1362  builder2.append("</td><td align=center><a href=\"" + type + "\">"
1363  + type.substring(type.lastIndexOf('#') + 1) + "</a></td></tr>");
1364  } else {
1365  if ((mapping.get(elem).contains("http") || mapping.get(elem).contains("file:/"))
1366  && mapping.get(elem).contains("#")) {
1367  builder2.append("</td><td align=center><a href=\"" + mapping.get(elem) + "\">"
1368  + mapping.get(elem).substring(mapping.get(elem).lastIndexOf('#') + 1)
1369  + "</a></td></tr>");
1370  } else if ((mapping.get(elem).contains("http") || mapping.get(elem).contains("file:/"))
1371  && mapping.get(elem).contains("/")) {
1372  builder2.append("</td><td align=center><a href=\"" + mapping.get(elem) + "\">"
1373  + mapping.get(elem).substring(mapping.get(elem).lastIndexOf('/') + 1)
1374  + "</a></td></tr>");
1375  } else {
1376  builder2.append("</td><td align=center><a href=\"" + mapping.get(elem) + "\">"
1377  + mapping.get(elem) + "</a></td></tr>");
1378  }
1379  }
1380  if (elem.contains("http://www.opengis.net/ont/geosparql#asWKT")) {
1381  geometry.put("type", mapping.get(elem).substring(0, mapping.get(elem).indexOf('(')));
1382  String coords = mapping.get(elem).substring(mapping.get(elem).indexOf('(') + 1,
1383  mapping.get(elem).indexOf(')'));
1384  JSONArray arr = new JSONArray();
1385  geometry.put("coordinates", arr);
1386  if(!coords.contains(",")) {
1387  String[] commasplit = coords.split(" ");
1388  arr.put(Double.valueOf(commasplit[0]));
1389  arr.put(Double.valueOf(commasplit[1]));
1390  }else {
1391  for (String coord : coords.split(" ")) {
1392  if (coord.contains(",")) {
1393  String[] commasplit = coord.split(",");
1394  arr.put(Double.valueOf(commasplit[0]));
1395  arr.put(Double.valueOf(commasplit[1]));
1396  }
1397  }
1398  }
1399  }
1400  if (elem.contains("lat")) {
1401  lat = mapping.get(elem);
1402  }
1403  if (elem.contains("lon")) {
1404  lon = mapping.get(elem);
1405  }
1406  if (lat != null && lon != null) {
1407  geometry.put("type", "Point");
1408  JSONArray arr = new JSONArray();
1409  geometry.put("coordinates", arr);
1410  arr.put(lon);
1411  arr.put(lat);
1412  }
1413  properties.put(elem, mapping.get(elem));
1414  }
1415  }
1416  }
1417  builder2.append("</table><br/>Styles:"
1418  + TripleStoreConnector.getStyleNames(wfsconf.getString("baseurl"), workingobj, format));
1419  builder.append("var geojson=" + geojson.toString() + "</script>");
1420  builder.append(builder2.toString());
1421  builder.append("</td></tr></table>");
1422  builder.append("</div></div><footer id=\"footer\"><table width=100%><tbody><tr><td><a href=\"" + wfsconf.getString("baseurl")
1423  + "/collections/"+workingobj.getString("name")+"?f=html\">Back to Collections</a></td><td align=right>This page in <a href=\""
1424  + wfsconf.getString("baseurl") + "/collections/" + workingobj.getString("name")
1425  + "/queryables?f=gml\">[GML]</a> <a href=\"" + wfsconf.getString("baseurl") + "/collections/"
1426  + workingobj.getString("name") + "/queryables?f=geojson\">[JSON]</a></td></tr></tbody></table></footer></body></html>");
1427  return Response.ok(builder.toString()).type(MediaType.TEXT_HTML).build();
1428  }

References TripleStoreConnector.getFeatureTypeInformation(), ResultFormatter.getFormatter(), and TripleStoreConnector.getStyleNames().

◆ queryConfigs()

Response queryConfigs ( )

Returns the query configuration document.

Returns
The query configuration document as JSON.
4361  {
4362  JSONObject res = new JSONObject();
4363  for (int i = 0; i < wfsconf.getJSONArray("datasets").length(); i++) {
4364  JSONObject curjson = wfsconf.getJSONArray("datasets").getJSONObject(i);
4365  JSONObject instance = new JSONObject();
4366  if (!res.has(curjson.getString("triplestore"))) {
4367  res.put(curjson.getString("triplestore"), new JSONArray());
4368  }
4369  res.getJSONArray(curjson.getString("triplestore")).put(instance);
4370  instance.put("triplestore", curjson.getString("triplestore"));
4371  instance.put("query", curjson.getString("query"));
4372  instance.put("name", curjson.getString("name"));
4373  instance.put("class", curjson.getString("class"));
4374  }
4375  return Response.ok(res.toString(2)).type(MediaType.APPLICATION_JSON).build();
4376  }

◆ queryService() [1/2]

String queryService ( @Parameter(description="SPARQL query to be resolved") @QueryParam("query") String  query,
@Parameter(description="SPARQL endpoint to be queried") @QueryParam("endpoint") String  endpoint,
@Parameter(description="Indicates whether geojson should be returned to be shown in a map view") @QueryParam("geojson") String  geojson 
)

Exposes a query service which returns a SPARQL query result as REST.

Parameters
queryThe query to send
endpointThe endpoint to query
geojsonindicates whether to return an additional representation as GeoJSON for a map view
Returns
The query result
4414  {
4415  final String dir = System.getProperty("user.dir");
4416  System.out.println("current dir = " + dir);
4417  return TripleStoreConnector.executeQuery(query, endpoint, true);
4418  }

References TripleStoreConnector.executeQuery().

◆ queryService() [2/2]

String queryService ( @Parameter(description="SPARQL query to be resolved") @QueryParam("query") String  query,
@Parameter(description="SPARQL endpoint to query") @QueryParam("endpoint") String  endpoint 
)

Exposes a query service which returns a SPARQL query result as REST.

Parameters
queryThe query to send
endpointThe endpoint to query
Returns
The query result
4392  {
4393  final String dir = System.getProperty("user.dir");
4394  System.out.println("current dir = " + dir);
4395  return TripleStoreConnector.executeQuery(query, endpoint, false);
4396  }

References TripleStoreConnector.executeQuery().

◆ saveFeatureTypes()

Boolean saveFeatureTypes ( @Parameter(description="JSON object containing feature types to be saved") @QueryParam("featjson") String  featureTypesJSON,
@Parameter(description="Authtoken for authorization") @DefaultValue("") @QueryParam("authtoken") String  authtoken 
)

Saves feature types in the SemanticWFS Service.

Parameters
featureTypesJSONThe featuretype JSON to save
authtokenThe authtoken authorizing the save operation
Returns
True if successful, false otherwise
4283  {
4284  User user=UserManagementConnection.getInstance().loginAuthToken(authtoken);
4285  if(user!=null && (user.getUserlevel()==UserType.Configurer || user.getUserlevel()==UserType.Administrator)) {
4286  JSONArray datasets = wfsconf.getJSONArray("featjson");
4287  wfsconf.put("datasets", datasets);
4288  return true;
4289  }
4290  return false;
4291  }

References UserType.Administrator, UserType.Configurer, UserManagementConnection.getInstance(), User.getUserlevel(), and UserManagementConnection.loginAuthToken().

◆ style()

Response style ( @Parameter(description="The service type which is addressed") @DefaultValue("WFS") @QueryParam("SERVICE") String  service,
@Parameter(description="Request type of this query") @DefaultValue("GetStyle") @QueryParam("REQUEST") String  request,
@Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAME") String  typename,
@Parameter(description="Feature type names") @DefaultValue("") @QueryParam("TYPENAMES") String  typenames,
@Parameter(description="Outputformat of the style which is returned") @DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String  output 
)

Returns a style information in a given format for a given featuretype and styleid.

Parameters
serviceThe service descriptor
requestThe requset parameter
typename
typenames
output
Returns
381  {
382  if (output.contains("gml")) {
383  StringWriter strwriter = new StringWriter();
384  XMLOutputFactory outputt = XMLOutputFactory.newInstance();
385  XMLStreamWriter writer;
386  try {
387  writer = new IndentingXMLStreamWriter(outputt.createXMLStreamWriter(strwriter));
388  writer.writeStartDocument();
389  writer.writeAttribute("xmlns", "http://www.opengis.net/ogcapi-features-1/1.0");
390  writer.writeAttribute("xmlns:sld", "http://www.opengis.net/sld");
391  writer.writeAttribute("xmlns:ogc", "http://www.opengis.net/ogc");
392  writer.writeAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
393  writer.writeAttribute("xmlns:gml", "http://www.opengis.net/gml");
394  writer.writeAttribute("xmlns:xsi", "http://www.w3.org/1999/xlink");
395  writer.writeAttribute("version", "1.0.0");
396  writer.writeStartElement("sld:NamedLayer");
397  writer.writeStartElement("sld:Name");
398  writer.writeCharacters(typename);
399  writer.writeEndElement();
400  writer.writeStartElement("sld:StyledLayerDescriptor");
401  } catch (XMLStreamException e) {
402  // TODO Auto-generated catch block
403  e.printStackTrace();
404  }
405 
406  }
407  return null;
408  }

◆ transaction()

String transaction ( )

Transaction method of the WFS specification.

Returns
4427  {
4428  return null;
4429  }

◆ vectorTiles()

Response vectorTiles ( @DefaultValue("CSW") @QueryParam("SERVICE") String  service,
@DefaultValue("GetCapabilities") @QueryParam("REQUEST") String  request,
@DefaultValue("2.0.2") @QueryParam("VERSION") String  version,
@DefaultValue("") @QueryParam("TYPENAME") String  typename,
@DefaultValue("") @QueryParam("TYPENAMES") String  typenames,
@DefaultValue("gml") @QueryParam("OUTPUTFORMAT") String  output 
)

Returns a vector tile representation of a given feature type.

Parameters
service
request
version
typename
typenames
output
Returns
357  {
358  return null;
359  }

Member Data Documentation

◆ bboxCache

Map<String, Double[]> bboxCache = new TreeMap<>()
static

◆ featureTypeCache

Map<String, Map<String, String> > featureTypeCache = new TreeMap<>()
static

◆ hitCache

Map<String, Tuple<Date, String> > hitCache = new TreeMap<>()
static

◆ htmlHead

String htmlHead
package

◆ milliesInDays

long milliesInDays = 24 * 60 * 60 * 1000
static

◆ nameSpaceCache

◆ openapijson

final MediaType openapijson =new MediaType("application", "vnd.oai.openapi+json;version=3.0")
static

◆ SERVERURL

String SERVERURL = "http://localhost:8080/WFSGeoSPARQL/rest/wfs?"

◆ SERVICETYPEVERSION

String SERVICETYPEVERSION = "2.0.0"

◆ styleCache

Map<String, Map<String, StyleObject> > styleCache = new TreeMap<>()
static

◆ triplestoreconf

JSONObject triplestoreconf = null
static

◆ wfsconf

JSONObject wfsconf = null
static

◆ xmlwriter

XMLStreamWriter xmlwriter