private String getFeatureTypeInfoKey(FeatureTypeInfo info, boolean handleProjectionPolicy) { return info.getId() + PROJECTION_POLICY_SEPARATOR + handleProjectionPolicy; }
public String getId() { return delegate.getId(); }
/** * Clears a feature type resource from the cache. * * @param info The feature type metadata. */ public void clear(FeatureTypeInfo info) { featureTypeCache.remove(getFeatureTypeInfoKey(info, true)); featureTypeCache.remove(getFeatureTypeInfoKey(info, false)); featureTypeAttributeCache.remove(info.getId()); }
@Test public void testGetFeatureTypeById() { addFeatureType(); FeatureTypeInfo ft2 = catalog.getFeatureType(ft.getId()); assertNotNull(ft2); assertFalse(ft == ft2); assertEquals(ft, ft2); }
catalog.add(ft2 = newFeatureType("ft2", ds)); catalog.add(ft3 = newFeatureType("ft3", ds)); ft1 = catalog.getFeatureType(ft1.getId()); ft2 = catalog.getFeatureType(ft2.getId()); ft3 = catalog.getFeatureType(ft3.getId()); ft1.getKeywords().add(new Keyword("keyword1")); ft1.getKeywords().add(new Keyword("keyword2")); filter = factory.equal(factory.literal(ft1.getId()), factory.property("id"), true); expected = Sets.newHashSet(ft1); actual = Sets.newHashSet(catalog.list(ResourceInfo.class, filter));
/** * Returns transformations associated to a specific feature type * * @param featureType * @return */ public List<TransformInfo> getTypeTransforms(FeatureTypeInfo featureType) throws IOException { List<TransformInfo> allTransformations = getAllTransforms(); List<TransformInfo> result = new ArrayList<TransformInfo>(); for (TransformInfo ti : allTransformations) { if (ti.getFeatureType() != null && ti.getFeatureType().getId().equals(featureType.getId())) { result.add(ti); } } return result; }
@Override protected void onValidate(IValidatable validatable) { String vtName = (String) validatable.getValue(); final DataStoreInfo store = getCatalog().getStore(storeId, DataStoreInfo.class); List<FeatureTypeInfo> ftis = getCatalog().getResourcesByStore(store, FeatureTypeInfo.class); for (FeatureTypeInfo curr : ftis) { VirtualTable currvt = curr.getMetadata().get(FeatureTypeInfo.JDBC_VIRTUAL_TABLE, VirtualTable.class); if(currvt != null) { if(typeInfoId == null || !typeInfoId.equals(curr.getId())) { if(currvt.getName().equals(vtName)) { Map<String, String> map = new HashMap<String, String>(); map.put("name", vtName); map.put("typeName", curr.getName()); error(validatable, "duplicateSqlViewName", map); return; } } } } } }
@Override public void onClose(AjaxRequestTarget target) { if (_layerInfo != null) { GeoServerApplication app = (GeoServerApplication) getApplication(); FeatureTypeInfo ft = (FeatureTypeInfo) getResourceInfo(); // Override _isNew state, based on resource informations into catalog if (ft.getId() != null && app.getCatalog().getResource(ft.getId(), ResourceInfo.class) != null) { _isNew = false; } else { _isNew = true; } app.getCatalog().getResourcePool().clear(ft); app.getCatalog().getResourcePool().clear(ft.getStore()); setResponsePage(new ResourceConfigurationPage(_layerInfo, _isNew)); } } });
@Override public void validate(IValidatable<String> validatable) { String vtName = validatable.getValue(); final DataStoreInfo store = getCatalog().getStore(storeId, DataStoreInfo.class); List<FeatureTypeInfo> ftis = getCatalog().getResourcesByStore(store, FeatureTypeInfo.class); for (FeatureTypeInfo curr : ftis) { VirtualTable currvt = curr.getMetadata() .get(FeatureTypeInfo.JDBC_VIRTUAL_TABLE, VirtualTable.class); if (currvt != null) { if (typeInfoId == null || !typeInfoId.equals(curr.getId())) { if (currvt.getName().equals(vtName)) { IValidationError err = new ValidationError("duplicateSqlViewName") .addKey("duplicateSqlViewName") .setVariable("name", vtName) .setVariable("typeName", curr.getName()); validatable.error(err); return; } } } } } }
public DataPanel(String id, FeatureTypeInfo ft) { super(id, new Model<FeatureTypeInfo>(ft)); this.featureTypeId = ft.getId();
private void updateSolrConfiguration(FeatureTypeInfo ft, SolrLayerConfiguration slc) { // go directly to the resource pool to avoid security wrappers try { DataAccess<? extends FeatureType, ? extends Feature> dataStore = catalog.getResourcePool().getDataStore(ft.getStore()); if (dataStore instanceof SolrDataStore) { SolrDataStore solr = (SolrDataStore) dataStore; solr.getSolrConfigurations().remove(slc.getLayerName()); slc.setLayerName(ft.getName()); solr.setSolrConfigurations(slc); } } catch (IOException e) { throw new CatalogException("Failed to remove layer configuration from data store", e); } FeatureTypeInfo proxy = catalog.getFeatureType(ft.getId()); proxy.setNativeName(ft.getName()); proxy.getMetadata().put(SolrLayerConfiguration.KEY, slc); catalog.save(proxy); }
if (fti.getId() == null) { modal.add(new OpenWindowOnLoadBehavior());
@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)); } }
@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)); } }
@Override public void visit(FeatureTypeInfo featureType) { FeatureTypeInfo otherFeatureType = otherCatalog.getFeatureType(featureType.getId()); if (otherFeatureType != null) { otherFeatureType.setProjectionPolicy(featureType.getProjectionPolicy()); } if (!(Objects.equals(featureType, otherFeatureType) && checkEquals(featureType.getAttributes(), otherFeatureType.getAttributes()) && checkEquals(featureType.getResponseSRS(), otherFeatureType.getResponseSRS()) && checkEquals(featureType.getAlias(), otherFeatureType.getAlias()) && checkEquals(featureType.getKeywords(), otherFeatureType.getKeywords()) && checkEquals(featureType.getDataLinks(), otherFeatureType.getDataLinks()) && checkEquals(featureType.getMetadataLinks(), otherFeatureType.getMetadataLinks()) && checkEquals(featureType.getMetadata(), otherFeatureType.getMetadata()))) { differences.add(new InfoDiff(featureType, otherFeatureType)); } }
typeInfoId = fti.getId();