public List<Name> getNames() throws IOException { return delegate.getNames(); }
List<Name> typeNames = dataAccess.getNames(); String nsURI = null; if (typeNames.size() > 0) {
public List getNames() throws IOException { return delegate.getNames(); }
/** * Return true if a type name is mapped in one of the registered data accesses. If the type * mapping has mappingName, then it will be the key that is matched in the search. If it * doesn't, then it will match the targetElementName. * * @param featureTypeName Feature type name * @return * @throws IOException */ public synchronized boolean hasAccessName(Name name) throws IOException { for (DataAccess<FeatureType, Feature> dataAccess : registry) { if (dataAccess.getNames().contains(name)) { return true; } } return false; }
@Override public String[] getTypeNames() throws IOException { List<Name> names = delegate.getNames(); String[] typeNames = names.stream() .map(name -> name.getLocalPart()) .distinct() .sorted() .toArray(String[]::new); return typeNames; }
/** * Throws data source exception if mapping is not found. * * @param featureTypeName Name of feature type * @throws IOException */ protected void throwDataSourceException(Name featureTypeName) throws IOException { List<Name> typeNames = new ArrayList<Name>(); for (Iterator<DataAccess<FeatureType, Feature>> dataAccessIterator = registry.iterator(); dataAccessIterator.hasNext(); ) { typeNames.addAll(dataAccessIterator.next().getNames()); } throw new DataSourceException( "Feature type " + featureTypeName + " not found." + " Has the data access been registered in DataAccessRegistry?" + " Available: " + typeNames.toString()); }
/** * Returns a qualified name from an unqualified type name. Ensures a single value is found. * * @param typeName * @return * @throws IOException */ private Name getNameFromLocal(String typeName) throws IOException { Name result = NAME_CACHE.get(typeName); if (result == null) { Stream<Name> stream = delegate.getNames().stream(); Set<Name> names = stream.filter(name -> typeName.equals(name.getLocalPart())) .collect(Collectors.toSet()); if (names.isEmpty()) { throw new IOException("Could not find a type name '" + typeName + "'"); } else if (names.size() > 1) { throw new IOException("Found multiple matches for '" + typeName + "': " + names); } else { result = names.iterator().next(); NAME_CACHE.put(typeName, result); } } return result; }
/** * Get a feature source for built features with supplied feature type name. * * @param featureTypeName * @return feature source * @throws IOException */ public synchronized FeatureSource<FeatureType, Feature> featureSource(Name name) throws IOException { for (DataAccess<FeatureType, Feature> dataAccess : registry) { if (dataAccess.getNames().contains(name)) { if (dataAccess instanceof AppSchemaDataAccess) { return ((AppSchemaDataAccess) dataAccess).getFeatureSourceByName(name); } else { return dataAccess.getFeatureSource(name); } } } throwDataSourceException(name); return null; }
/** * Tests that a {@link FeatureSource} can be obtained for all names returned by {@link * AppSchemaDataAccess#getNames()}. * * @throws Exception */ @Test public void testGetNamesAndFeatureSources() throws Exception { /* * Initiate data accesses and make sure they have the mappings */ final Map<String, Serializable> dsParams = new HashMap<String, Serializable>(); URL url = getClass().getResource(schemaBase + "GeologicUnit.xml"); assertNotNull(url); dsParams.put("dbtype", "app-schema"); dsParams.put("url", url.toExternalForm()); DataAccess<?, ?> guDataStore = DataAccessFinder.getDataStore(dsParams); assertNotNull(guDataStore); for (Name name : guDataStore.getNames()) { FeatureSource<?, ?> fs = guDataStore.getFeatureSource(name); assertNotNull(fs); } }
/** * Return true if a type name is mapped in one of the registered data accesses. If * the type mapping has mappingName, then it will be the key that is matched in the search. If * it doesn't, then it will match the targetElementName. * * @param featureTypeName * Feature type name * @return * @throws IOException */ public synchronized boolean hasAccessName(Name name) throws IOException { for (DataAccess<FeatureType, Feature> dataAccess : registry) { if (dataAccess.getNames().contains(name)) { return true; } } return false; }
/** * Throws data source exception if mapping is not found. * * @param featureTypeName * Name of feature type * @throws IOException */ protected void throwDataSourceException(Name featureTypeName) throws IOException { List<Name> typeNames = new ArrayList<Name>(); for (Iterator<DataAccess<FeatureType, Feature>> dataAccessIterator = registry.iterator(); dataAccessIterator.hasNext();) { typeNames.addAll(dataAccessIterator.next().getNames()); } throw new DataSourceException("Feature type " + featureTypeName + " not found." + " Has the data access been registered in DataAccessRegistry?" + " Available: " + typeNames.toString()); }
/** * Get a feature source for built features with supplied feature type name. * * @param featureTypeName * @return feature source * @throws IOException */ public synchronized FeatureSource<FeatureType, Feature> featureSource(Name name) throws IOException { for (DataAccess<FeatureType, Feature> dataAccess : registry) { if (dataAccess.getNames().contains(name)) { if (dataAccess instanceof AppSchemaDataAccess) { return ((AppSchemaDataAccess) dataAccess).getFeatureSourceByName(name); } else { return dataAccess.getFeatureSource(name); } } } throwDataSourceException(name); return null; }
List<Name> names = gtStore.getNames(); for (Name name : names)
List<Name> names = dstore.getDataStore(null).getNames(); for (Name name : names) { Catalog catalog = GeoServerApplication.get().getCatalog();
DataAccess store = storeInfo.getDataStore(null); assertThat(store, notNullValue()); List<Name> names = store.getNames(); assertThat(store, notNullValue());
List<Name> names = new ArrayList<Name>(da.getNames());
store.getNames(); store.dispose();
List<Name> names = expandedStore.getDataStore(null).getNames(); for (Name name : names) { FeatureTypeInfo fti =
@Test public void testDelete() throws Exception { FeatureTypeInfo featureType = catalog.getFeatureTypeByName("sf", "PrimitiveGeoFeature"); String featureTypeId = featureType.getId(); String dataStoreId = featureType.getStore().getId(); Name name = featureType.getFeatureType().getName(); assertNotNull("PrmitiveGeoFeature available", featureType); for (LayerInfo l : catalog.getLayers(featureType)) { catalog.remove(l); } assertEquals( 200, deleteAsServletResponse( BASEPATH + "/workspaces/sf/datastores/sf/featuretypes/PrimitiveGeoFeature") .getStatus()); assertNull(catalog.getFeatureTypeByName("sf", "PrimitiveGeoFeature")); if (catalog.getResourcePool().getFeatureTypeAttributeCache().containsKey(featureTypeId)) { List<AttributeTypeInfo> attributesList = catalog.getResourcePool().getFeatureTypeAttributeCache().get(featureTypeId); assertNull("attributes cleared", attributesList); } if (catalog.getResourcePool().getDataStoreCache().containsKey(dataStoreId)) { DataAccess dataStore = catalog.getResourcePool().getDataStoreCache().get(dataStoreId); List<Name> names = dataStore.getNames(); assertTrue(names.contains(name)); } }
@Test public void testDeleteWithoutStore() throws Exception { FeatureTypeInfo featureType = catalog.getFeatureTypeByName("sf", "PrimitiveGeoFeature"); String featureTypeId = featureType.getId(); String dataStoreId = featureType.getStore().getId(); Name name = featureType.getFeatureType().getName(); assertNotNull("PrmitiveGeoFeature available", featureType); for (LayerInfo l : catalog.getLayers(featureType)) { catalog.remove(l); } assertEquals( 200, deleteAsServletResponse( BASEPATH + "/workspaces/sf/featuretypes/PrimitiveGeoFeature") .getStatus()); assertNull(catalog.getFeatureTypeByName("sf", "PrimitiveGeoFeature")); if (catalog.getResourcePool().getFeatureTypeAttributeCache().containsKey(featureTypeId)) { List<AttributeTypeInfo> attributesList = catalog.getResourcePool().getFeatureTypeAttributeCache().get(featureTypeId); assertNull("attributes cleared", attributesList); } if (catalog.getResourcePool().getDataStoreCache().containsKey(dataStoreId)) { DataAccess dataStore = catalog.getResourcePool().getDataStoreCache().get(dataStoreId); List<Name> names = dataStore.getNames(); assertTrue(names.contains(name)); } }