public String getName() { return delegate.getName(); }
tb.init(sft); tb.setName(info.getName()); tb.setNamespaceURI(info.getNamespace().getURI());
protected void dispose(String key, FeatureType featureType) { String id = key.substring(0, key.indexOf(PROJECTION_POLICY_SEPARATOR)); FeatureTypeInfo info = catalog.getFeatureType(id); if (info != null) { LOGGER.fine("Disposing feature type '" + info.getName() + "'/" + id); fireDisposed(info, featureType); if (null != featureTypeAttributeCache.remove(id)) { LOGGER.fine( "AttributeType cache cleared for feature type '" + info.getName() + "'/" + id + " as a side effect of its cache disposal"); } } } }
assertNotNull(ft); assertEquals("ft", ft.getName()); assertEquals(ds, ft.getStore()); assertEquals(ns, ft.getNamespace());
private void addFeatureType(FeatureTypeInfo ft) throws IOException { LOGGER.fine("Persisting feature type " + ft.getName()); Resource xml = dd.config(ft); persist(ft, xml); }
private void modifyFeatureType(FeatureTypeInfo ft) throws IOException { LOGGER.fine("Persisting feature type " + ft.getName()); Resource xml = dd.config(ft); persist(ft, xml); }
private void removeFeatureType(FeatureTypeInfo ft) throws IOException { LOGGER.fine("Removing feature type " + ft.getName()); Resource directory = dd.get(ft); rmRes(directory); }
Level.FINE, "Feature Type {0} cleared: Disposing DataStore {1} - {2}", new String[] {ft.getName(), ds.getName(), "Last Feature Type Disposed"}); clear(ds); } else { Level.FINE, "Feature Type {0} cleared from ContentDataStore {1}", new String[] {ft.getName(), ds.getName()}); Level.FINE, "Unable to clean up cached feature type {0} in data store {1} - not a ContentDataStore", new String[] {ft.getName(), ds.getName()});
LOGGER.log( Level.WARNING, "Error occured applying schema override for " + info.getName(), e);
ftinfo.setTitle(rinfo != null ? rinfo.getTitle() : ftinfo.getName());
@Override public boolean initialize( FeatureTypeInfo info, DataAccess<? extends FeatureType, ? extends Feature> dataAccess, Name temporaryName) throws IOException { StoredQueryConfiguration sqc = info.getMetadata() .get( FeatureTypeInfo.STORED_QUERY_CONFIGURATION, StoredQueryConfiguration.class); WFSDataStore wstore = (WFSDataStore) dataAccess; String localPart = info.getName(); boolean usesTemporary = false; if (temporaryName != null) { localPart = temporaryName.getLocalPart(); usesTemporary = true; } if (!wstore.getConfiguredStoredQueries().containsValue(localPart)) { wstore.addStoredQuery(localPart, sqc.getStoredQueryId()); } return usesTemporary; }
@Test public void testModifyFeatureType() { addFeatureType(); FeatureTypeInfo ft2 = catalog.getFeatureTypeByName(ft.getName()); ft2.setDescription("ft2Description"); ft2.getKeywords().add(new Keyword("ft2")); FeatureTypeInfo ft3 = catalog.getFeatureTypeByName(ft.getName()); assertEquals("ftName", ft3.getName()); assertEquals("ftDescription", ft3.getDescription()); assertTrue(ft3.getKeywords().isEmpty()); catalog.save(ft2); ft3 = catalog.getFeatureTypeByName(ft.getName()); assertEquals(ft2, ft3); assertEquals("ft2Description", ft3.getDescription()); assertEquals(1, ft3.getKeywords().size()); }
@Test public void testModifyDataLinks() { addFeatureType(); FeatureTypeInfo ft2 = catalog.getFeatureTypeByName(ft.getName()); DataLinkInfo ml = catalog.getFactory().createDataLink(); ml.setContent("http://www.geoserver.org/meta"); ml.setType("text/plain"); ft2.getDataLinks().clear(); ft2.getDataLinks().add(ml); catalog.save(ft2); FeatureTypeInfo ft3 = catalog.getFeatureTypeByName(ft.getName()); DataLinkInfo ml3 = ft3.getDataLinks().get(0); ml3.setType("application/json"); // do not save and grab another, the metadata link must not have been modified FeatureTypeInfo ft4 = catalog.getFeatureTypeByName(ft.getName()); DataLinkInfo ml4 = ft4.getDataLinks().get(0); assertEquals("text/plain", ml4.getType()); // now save and grab yet another, the modification must have happened catalog.save(ft3); FeatureTypeInfo ft5 = catalog.getFeatureTypeByName(ft.getName()); DataLinkInfo ml5 = ft5.getDataLinks().get(0); assertEquals("application/json", ml5.getType()); }
@Test public void testModifyMetadataLinks() { addFeatureType(); FeatureTypeInfo ft2 = catalog.getFeatureTypeByName(ft.getName()); MetadataLinkInfo ml = catalog.getFactory().createMetadataLink(); ml.setContent("http://www.geoserver.org/meta"); ml.setType("text/plain"); ml.setMetadataType("iso"); ft2.getMetadataLinks().clear(); ft2.getMetadataLinks().add(ml); catalog.save(ft2); FeatureTypeInfo ft3 = catalog.getFeatureTypeByName(ft.getName()); MetadataLinkInfo ml3 = ft3.getMetadataLinks().get(0); ml3.setType("application/json"); // do not save and grab another, the metadata link must not have been modified FeatureTypeInfo ft4 = catalog.getFeatureTypeByName(ft.getName()); MetadataLinkInfo ml4 = ft4.getMetadataLinks().get(0); assertEquals("text/plain", ml4.getType()); // now save and grab yet another, the modification must have happened catalog.save(ft3); FeatureTypeInfo ft5 = catalog.getFeatureTypeByName(ft.getName()); MetadataLinkInfo ml5 = ft5.getMetadataLinks().get(0); assertEquals("application/json", ml5.getType()); }
@Test public void testCreateInWorkspace() throws Exception { ResourcePool rp = createNiceMock(ResourcePool.class); Catalog cat = createNiceMock(Catalog.class); expect(cat.getFactory()).andReturn(new CatalogFactoryImpl(null)).anyTimes(); expect(cat.getResourcePool()).andReturn(rp).anyTimes(); WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class); FeatureTypeInfo ft = createNiceMock(FeatureTypeInfo.class); expect(ft.getName()).andReturn("foo").anyTimes(); replay(rp, ft, ws, cat); StyleGenerator gen = new StyleGenerator(cat); gen.setWorkspace(ws); SimpleFeatureType schema = DataUtilities.createType("foo", "geom:Point"); StyleInfo style = gen.createStyle(new SLDHandler(), ft, schema); assertNotNull(style); assertNotNull(style.getWorkspace()); }
@Test public void testProxyBehaviour() throws Exception { testAddLayer(); // l = catalog.getLayerByName( "layerName"); LayerInfo l = catalog.getLayerByName(ft.getName()); assertTrue(l instanceof Proxy); ResourceInfo r = l.getResource(); assertTrue(r instanceof Proxy); String oldName = ft.getName(); r.setName("changed"); catalog.save(r); assertNull(catalog.getLayerByName(oldName)); l = catalog.getLayerByName(r.getName()); assertNotNull(l); assertEquals("changed", l.getResource().getName()); }
@Test public void testGetFeatureTypeByName() { addFeatureType(); FeatureTypeInfo ft2 = catalog.getFeatureTypeByName(ft.getName()); assertNotNull(ft2); assertFalse(ft == ft2); assertEquals(ft, ft2); NamespaceInfo ns2 = catalog.getFactory().createNamespace(); ns2.setPrefix("ns2Prefix"); ns2.setURI("ns2URI"); catalog.add(ns2); FeatureTypeInfo ft3 = catalog.getFactory().createFeatureType(); ft3.setName("ft3Name"); ft3.setStore(ds); ft3.setNamespace(ns2); catalog.add(ft3); FeatureTypeInfo ft4 = catalog.getFeatureTypeByName(ns2.getPrefix(), ft3.getName()); assertNotNull(ft4); assertFalse(ft4 == ft3); assertEquals(ft3, ft4); ft4 = catalog.getFeatureTypeByName(ns2.getURI(), ft3.getName()); assertNotNull(ft4); assertFalse(ft4 == ft3); assertEquals(ft3, ft4); }
@Test public void testLayerGroupBounds() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getDataStoreByName(MockData.LINES.getPrefix())); FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.LINES)); cb.setupBounds(fti); LayerInfo layer = cat.getFactory().createLayer(); layer.setResource(fti); layer.setName(fti.getName()); layer.setEnabled(true); layer.setType(PublishedType.VECTOR); LayerGroupInfo group = cat.getFactory().createLayerGroup(); group.setName("group"); group.getLayers().add(layer); group.getStyles().add(null); assertNull(group.getBounds()); // force bounds computation cb.calculateLayerGroupBounds(group); assertNotNull(group.getBounds()); assertEquals(fti.getNativeBoundingBox(), group.getBounds()); }
@Test public void testModifyLayer() { addLayer(); LayerInfo l2 = catalog.getLayerByName(l.getName()); // l2.setName( null ); l2.setResource(null); LayerInfo l3 = catalog.getLayerByName(l.getName()); assertEquals(l.getName(), l3.getName()); // try { // catalog.save(l2); // fail( "setting name to null should throw exception"); // } // catch( Exception e ) {} // // l2.setName( "changed" ); try { catalog.save(l2); fail("setting resource to null should throw exception"); } catch (Exception e) { } l2.setResource(ft); catalog.save(l2); // TODO: reinstate with resource/publishing split done // l3 = catalog.getLayerByName( "changed" ); l3 = catalog.getLayerByName(ft.getName()); assertNotNull(l3); }
@Test public void testLayerGroupEoBounds() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getDataStoreByName(MockData.LINES.getPrefix())); FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.LINES)); cb.setupBounds(fti); LayerInfo layer = cat.getFactory().createLayer(); layer.setResource(fti); layer.setName(fti.getName()); layer.setEnabled(true); layer.setType(PublishedType.VECTOR); LayerGroupInfo group = cat.getFactory().createLayerGroup(); group.setMode(LayerGroupInfo.Mode.EO); group.setName("group_EO"); group.setRootLayer(layer); assertNull(group.getBounds()); // force bounds computation cb.calculateLayerGroupBounds(group); assertNotNull(group.getBounds()); assertEquals(fti.getNativeBoundingBox(), group.getBounds()); }