MetadataRegionDAO extends RegionsDAO { @Override public Geometry getGeom(ServiceContext context, String id, boolean simplified, CoordinateReferenceSystem projection) throws Exception { MetadataRegion region = (MetadataRegion) createSearchRequest(context).id(id).get(); if (region != null) { return region.getGeometry(projection); } else { return null; } }  @Override Collection<String> getRegionCategoryIds(ServiceContext context); @Override Request createSearchRequest(ServiceContext context); @Override Geometry getGeom(ServiceContext context, String id, boolean simplified, CoordinateReferenceSystem projection); @Override boolean includeInListing(); static final String CATEGORY_NAME; }
@Test public void testGetGeomEditId() throws Exception { final Element metadata = dataManager.getMetadata(this.context, "" + this.metadataId, true, false, false); final Element extentEl = Xml.selectElement(metadata, "* final String geomRefId = extentEl.getAttributeValue("ref"); Geometry geom = regionDAO.getGeom(this.context, "metadata:@id" + this.metadataId + ":" + geomRefId, false, "EPSG:4326"); assertNotNull(geom); geom = regionDAO.getGeom(this.context, "metadata:@id" + this.metadataId + ":920934802934809238", false, "EPSG:4326"); assertNull(geom); }
@Test public void testGetGeomUUID() throws Exception { final Element metadata = dataManager.getMetadata(this.context, "" + this.metadataId, true, false, false); final Element extentEl = Xml.selectElement(metadata, "* final String geomRefId = extentEl.getAttributeValue("ref"); String uuid = dataManager.getMetadataUuid(String.valueOf(this.metadataId)); Geometry geom = regionDAO.getGeom(this.context, "metadata:@uuid" + uuid + ":" + geomRefId, false, "EPSG:4326"); assertNotNull(geom); geom = regionDAO.getGeom(this.context, "metadata:@uuid" + uuid + ":920934802934809238", false, "EPSG:4326"); assertNull(geom); }
@Test public void testGetGeomGmlId() throws Exception { final Element metadata = dataManager.getMetadata(this.context, "" + this.metadataId, true, false, false); final Element extentEl = Xml.selectElement(metadata, "* final String geomRefId = extentEl.getAttributeValue("id", metadata.getNamespace("gml")); Geometry geom = regionDAO.getGeom(this.context, "metadata:@id" + this.metadataId + ":@gml" + geomRefId, false, "EPSG:4326"); assertNotNull(geom); geom = regionDAO.getGeom(this.context, "metadata:@id" + this.metadataId + ":@gml920934802934809238", false, "EPSG:4326"); assertNull(geom); }
@Test public void testGetGeomXPath() throws Exception { final Element metadata = dataManager.getMetadata(this.context, "" + this.metadataId, true, false, false); final Element extentEl = Xml.selectElement(metadata, "* final String xpath = Xml.getXPathExpr(extentEl); Geometry geom = regionDAO.getGeom(this.context, "metadata:@id" + this.metadataId + ":@xpath" + xpath, false, "EPSG:4326"); assertNotNull(geom); geom = regionDAO.getGeom(this.context, "metadata:@id" + this.metadataId + ":@xpath920934802934809238", false, "EPSG:4326"); assertNull(geom); }
@Test public void testWrongMetadataId() throws Exception { final Element metadata = dataManager.getMetadata(this.context, "" + this.metadataId, true, false, false); final Element extentEl = Xml.selectElement(metadata, "* final String geomRefId = extentEl.getAttributeValue("ref"); Geometry geom = regionDAO.getGeom(this.context, "metadata:@id32342389:" + geomRefId, false, "EPSG:4326"); assertNull(geom); geom = regionDAO.getGeom(this.context, "metadata:@uuid323423898023432:" + geomRefId, false, "EPSG:4326"); assertNull(geom); geom = regionDAO.getGeom(this.context, "metadata:@fileId323423898023432:" + geomRefId, false, "EPSG:4326"); assertNull(geom); geom = regionDAO.getGeom(this.context, "metadata:@fileId323423898023432", false, "EPSG:4326"); assertNull(geom); geom = regionDAO.getGeom(this.context, "metadata:@id323423898023432", false, "EPSG:4326"); assertNull(geom); geom = regionDAO.getGeom(this.context, "metadata:@uuid323423898023432", false, "EPSG:4326"); assertNull(geom); }