@Test public void integrationTest() throws GeomajasException { WfsDescribeFeatureTypeRequest request = new WfsDescribeFeatureTypeRequest("http: "dov-pub-bodem:Bodemassociatiekaart"); WfsDescribeFeatureTypeResponse response = new WfsDescribeFeatureTypeResponse(); command.execute(request, response); WfsFeatureTypeDescriptionDto type = response.getFeatureTypeDescription(); Assert.assertEquals(5, type.getAttributeDescriptors().size()); AttributeDescriptor descriptor = type.getAttributeDescriptors().get(0); Assert.assertEquals("uidn", descriptor.getName()); Assert.assertTrue(descriptor.getType() instanceof PrimitiveAttributeType); Assert.assertEquals(Double.class, ((PrimitiveAttributeType) descriptor.getType()).getBinding()); descriptor = type.getAttributeDescriptors().get(1); Assert.assertEquals("oidn", descriptor.getName()); Assert.assertTrue(descriptor.getType() instanceof PrimitiveAttributeType); Assert.assertEquals(Double.class, ((PrimitiveAttributeType) descriptor.getType()).getBinding()); descriptor = type.getAttributeDescriptors().get(2); Assert.assertEquals("associatie", descriptor.getName()); Assert.assertTrue(descriptor.getType() instanceof PrimitiveAttributeType); Assert.assertEquals(Integer.class, ((PrimitiveAttributeType) descriptor.getType()).getBinding()); descriptor = type.getAttributeDescriptors().get(3); Assert.assertEquals("omschr", descriptor.getName()); Assert.assertTrue(descriptor.getType() instanceof PrimitiveAttributeType); Assert.assertEquals(String.class, ((PrimitiveAttributeType) descriptor.getType()).getBinding()); descriptor = type.getAttributeDescriptors().get(4); Assert.assertEquals("shape", descriptor.getName()); Assert.assertTrue(descriptor.getType() instanceof GeometryAttributeType); Assert.assertEquals(GeometryType.MULTIPOLYGON, ((GeometryAttributeType) descriptor.getType()).getGeometryType()); }
@Override public void execute(WfsDescribeFeatureTypeRequest request, WfsDescribeFeatureTypeResponse response) throws GeomajasException { SimpleFeatureType schema = null; try { String sourceUrl = request.getBaseUrl(); URL targetUrl = httpClientFactory.getTargetUrl(sourceUrl); URL url = URLBuilder.createWfsURL(targetUrl, request.getVersion(), "GetCapabilities"); String capa = url.toExternalForm(); Map<String, Serializable> connectionParameters = new HashMap<String, Serializable>(); connectionParameters.put(WFSDataStoreFactory.URL.key, capa); connectionParameters.put(WFSDataStoreFactory.TIMEOUT.key, 10000); if (request.getStrategy() != null) { connectionParameters.put(WFSDataStoreFactory.WFS_STRATEGY.key, request.getStrategy()); } WFSDataStore data = dataStoreFactory.createDataStore(connectionParameters, httpClientFactory.create(sourceUrl)); schema = data.getSchema(request.getTypeName().replace(":", "_")); } catch (Exception e) { log.error("DescribeFeatureType failed for " + request.getTypeName(), e); throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, e.getMessage()); } if (schema != null) { List<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor> descriptors = new ArrayList<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor>(); for (AttributeDescriptor attributeDescriptor : schema.getAttributeDescriptors()) { descriptors.add(createDescriptor(attributeDescriptor)); } WfsFeatureTypeDescriptionDto featureTypeDescriptionDto = new WfsFeatureTypeDescriptionDto(); featureTypeDescriptionDto.setBaseUrl(request.getBaseUrl()); featureTypeDescriptionDto.setTypeName(request.getTypeName()); featureTypeDescriptionDto.setAttributeDescriptors(descriptors); response.setFeatureTypeDescription(featureTypeDescriptionDto); } else { log.error("Missing type name on server: " + request.getTypeName()); throw new GeomajasException(ExceptionCode.PARAMETER_INVALID_VALUE, request.getTypeName()); } }
WfsDescribeFeatureTypeCommand implements
		CommandHasRequest<WfsDescribeFeatureTypeRequest, WfsDescribeFeatureTypeResponse> { @Override public void execute(WfsDescribeFeatureTypeRequest request, WfsDescribeFeatureTypeResponse response) throws GeomajasException { SimpleFeatureType schema = null; try { String sourceUrl = request.getBaseUrl(); URL targetUrl = httpClientFactory.getTargetUrl(sourceUrl); URL url = URLBuilder.createWfsURL(targetUrl, request.getVersion(), "GetCapabilities"); String capa = url.toExternalForm(); Map<String, Serializable> connectionParameters = new HashMap<String, Serializable>(); connectionParameters.put(WFSDataStoreFactory.URL.key, capa); connectionParameters.put(WFSDataStoreFactory.TIMEOUT.key, 10000); if (request.getStrategy() != null) { connectionParameters.put(WFSDataStoreFactory.WFS_STRATEGY.key, request.getStrategy()); } WFSDataStore data = dataStoreFactory.createDataStore(connectionParameters, httpClientFactory.create(sourceUrl)); schema = data.getSchema(request.getTypeName().replace(":", "_")); } catch (Exception e) { log.error("DescribeFeatureType failed for " + request.getTypeName(), e); throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, e.getMessage()); } if (schema != null) { List<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor> descriptors = new ArrayList<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor>(); for (AttributeDescriptor attributeDescriptor : schema.getAttributeDescriptors()) { descriptors.add(createDescriptor(attributeDescriptor)); } WfsFeatureTypeDescriptionDto featureTypeDescriptionDto = new WfsFeatureTypeDescriptionDto(); featureTypeDescriptionDto.setBaseUrl(request.getBaseUrl()); featureTypeDescriptionDto.setTypeName(request.getTypeName()); featureTypeDescriptionDto.setAttributeDescriptors(descriptors); response.setFeatureTypeDescription(featureTypeDescriptionDto); } else { log.error("Missing type name on server: " + request.getTypeName()); throw new GeomajasException(ExceptionCode.PARAMETER_INVALID_VALUE, request.getTypeName()); } } }
WfsDescribeFeatureTypeCommand implements
		CommandHasRequest<WfsDescribeFeatureTypeRequest, WfsDescribeFeatureTypeResponse> { @Override public void execute(WfsDescribeFeatureTypeRequest request, WfsDescribeFeatureTypeResponse response) throws GeomajasException { SimpleFeatureType schema = null; try { String sourceUrl = request.getBaseUrl(); URL targetUrl = httpClientFactory.getTargetUrl(sourceUrl); URL url = URLBuilder.createWfsURL(targetUrl, request.getVersion(), "GetCapabilities"); String capa = url.toExternalForm(); Map<String, Serializable> connectionParameters = new HashMap<String, Serializable>(); connectionParameters.put(WFSDataStoreFactory.URL.key, capa); connectionParameters.put(WFSDataStoreFactory.TIMEOUT.key, 10000); if (request.getStrategy() != null) { connectionParameters.put(WFSDataStoreFactory.WFS_STRATEGY.key, request.getStrategy()); } WFSDataStore data = dataStoreFactory.createDataStore(connectionParameters, httpClientFactory.create(sourceUrl)); schema = data.getSchema(request.getTypeName().replace(":", "_")); } catch (Exception e) { log.error("DescribeFeatureType failed for " + request.getTypeName(), e); throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, e.getMessage()); } if (schema != null) { List<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor> descriptors = new ArrayList<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor>(); for (AttributeDescriptor attributeDescriptor : schema.getAttributeDescriptors()) { descriptors.add(createDescriptor(attributeDescriptor)); } WfsFeatureTypeDescriptionDto featureTypeDescriptionDto = new WfsFeatureTypeDescriptionDto(); featureTypeDescriptionDto.setBaseUrl(request.getBaseUrl()); featureTypeDescriptionDto.setTypeName(request.getTypeName()); featureTypeDescriptionDto.setAttributeDescriptors(descriptors); response.setFeatureTypeDescription(featureTypeDescriptionDto); } else { log.error("Missing type name on server: " + request.getTypeName()); throw new GeomajasException(ExceptionCode.PARAMETER_INVALID_VALUE, request.getTypeName()); } } WfsDescribeFeatureTypeCommand(); }
WfsDescribeFeatureTypeCommand implements
		CommandHasRequest<WfsDescribeFeatureTypeRequest, WfsDescribeFeatureTypeResponse> { @Override public void execute(WfsDescribeFeatureTypeRequest request, WfsDescribeFeatureTypeResponse response) throws GeomajasException { SimpleFeatureType schema = null; try { String sourceUrl = request.getBaseUrl(); URL targetUrl = httpClientFactory.getTargetUrl(sourceUrl); URL url = URLBuilder.createWfsURL(targetUrl, request.getVersion(), "GetCapabilities"); String capa = url.toExternalForm(); Map<String, Serializable> connectionParameters = new HashMap<String, Serializable>(); connectionParameters.put(WFSDataStoreFactory.URL.key, capa); connectionParameters.put(WFSDataStoreFactory.TIMEOUT.key, 10000); if (request.getStrategy() != null) { connectionParameters.put(WFSDataStoreFactory.WFS_STRATEGY.key, request.getStrategy()); } WFSDataStore data = dataStoreFactory.createDataStore(connectionParameters, httpClientFactory.create(sourceUrl)); schema = data.getSchema(request.getTypeName().replace(":", "_")); } catch (Exception e) { log.error("DescribeFeatureType failed for " + request.getTypeName(), e); throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, e.getMessage()); } if (schema != null) { List<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor> descriptors = new ArrayList<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor>(); for (AttributeDescriptor attributeDescriptor : schema.getAttributeDescriptors()) { descriptors.add(createDescriptor(attributeDescriptor)); } WfsFeatureTypeDescriptionDto featureTypeDescriptionDto = new WfsFeatureTypeDescriptionDto(); featureTypeDescriptionDto.setBaseUrl(request.getBaseUrl()); featureTypeDescriptionDto.setTypeName(request.getTypeName()); featureTypeDescriptionDto.setAttributeDescriptors(descriptors); response.setFeatureTypeDescription(featureTypeDescriptionDto); } else { log.error("Missing type name on server: " + request.getTypeName()); throw new GeomajasException(ExceptionCode.PARAMETER_INVALID_VALUE, request.getTypeName()); } } WfsDescribeFeatureTypeCommand(); void setDataStoreFactory(WfsDataStoreFactory dataStoreFactory); void setHttpClientFactory(WfsHttpClientFactory httpClientFactory); @Override void execute(WfsDescribeFeatureTypeRequest request, WfsDescribeFeatureTypeResponse response); @Override WfsDescribeFeatureTypeRequest getEmptyCommandRequest(); @Override WfsDescribeFeatureTypeResponse getEmptyCommandResponse(); }
WfsDescribeFeatureTypeCommand implements
		CommandHasRequest<WfsDescribeFeatureTypeRequest, WfsDescribeFeatureTypeResponse> { @Override public void execute(WfsDescribeFeatureTypeRequest request, WfsDescribeFeatureTypeResponse response) throws GeomajasException { SimpleFeatureType schema = null; try { String sourceUrl = request.getBaseUrl(); URL targetUrl = httpClientFactory.getTargetUrl(sourceUrl); URL url = URLBuilder.createWfsURL(targetUrl, request.getVersion(), "GetCapabilities"); String capa = url.toExternalForm(); Map<String, Serializable> connectionParameters = new HashMap<String, Serializable>(); connectionParameters.put(WFSDataStoreFactory.URL.key, capa); connectionParameters.put(WFSDataStoreFactory.TIMEOUT.key, 10000); if (request.getStrategy() != null) { connectionParameters.put(WFSDataStoreFactory.WFS_STRATEGY.key, request.getStrategy()); } WFSDataStore data = dataStoreFactory.createDataStore(connectionParameters, httpClientFactory.create(sourceUrl)); schema = data.getSchema(request.getTypeName().replace(":", "_")); } catch (Exception e) { log.error("DescribeFeatureType failed for " + request.getTypeName(), e); throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, e.getMessage()); } if (schema != null) { List<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor> descriptors = new ArrayList<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor>(); for (AttributeDescriptor attributeDescriptor : schema.getAttributeDescriptors()) { descriptors.add(createDescriptor(attributeDescriptor)); } WfsFeatureTypeDescriptionDto featureTypeDescriptionDto = new WfsFeatureTypeDescriptionDto(); featureTypeDescriptionDto.setBaseUrl(request.getBaseUrl()); featureTypeDescriptionDto.setTypeName(request.getTypeName()); featureTypeDescriptionDto.setAttributeDescriptors(descriptors); response.setFeatureTypeDescription(featureTypeDescriptionDto); } else { log.error("Missing type name on server: " + request.getTypeName()); throw new GeomajasException(ExceptionCode.PARAMETER_INVALID_VALUE, request.getTypeName()); } } WfsDescribeFeatureTypeCommand(); void setDataStoreFactory(WfsDataStoreFactory dataStoreFactory); void setHttpClientFactory(WfsHttpClientFactory httpClientFactory); @Override void execute(WfsDescribeFeatureTypeRequest request, WfsDescribeFeatureTypeResponse response); @Override WfsDescribeFeatureTypeRequest getEmptyCommandRequest(); @Override WfsDescribeFeatureTypeResponse getEmptyCommandResponse();  }