use of org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler in project geowave by locationtech.
the class MigrationTest method testLegacyFeatureDataAdapterMigration.
@Test
public void testLegacyFeatureDataAdapterMigration() {
final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
final AttributeTypeBuilder attributeTypeBuilder = new AttributeTypeBuilder();
builder.setName("testType");
builder.setNamespaceURI("geowave.namespace");
builder.add(attributeTypeBuilder.binding(String.class).nillable(true).buildDescriptor("strAttr"));
builder.add(attributeTypeBuilder.binding(Integer.class).nillable(true).buildDescriptor("intAttr"));
builder.add(attributeTypeBuilder.binding(Date.class).nillable(false).buildDescriptor("dateAttr"));
builder.add(attributeTypeBuilder.binding(Point.class).nillable(false).buildDescriptor("geom"));
builder.crs(GeometryUtils.getDefaultCRS());
final SimpleFeatureType featureType = builder.buildFeatureType();
final AttributeDescriptor stringAttr = featureType.getDescriptor("strAttr");
// Configure legacy visiblity
stringAttr.getUserData().put("visibility", Boolean.TRUE);
featureType.getUserData().put("visibilityManagerClass", "org.locationtech.geowave.adapter.vector.plugin.visibility.JsonDefinitionColumnVisibilityManagement");
LegacyFeatureDataAdapter adapter = new LegacyFeatureDataAdapter(featureType, "EPSG:3257");
final byte[] adapterBinary = PersistenceUtils.toBinary(adapter);
final Persistable persistableAdapter = PersistenceUtils.fromBinary(adapterBinary);
assertTrue(persistableAdapter instanceof LegacyFeatureDataAdapter);
adapter = (LegacyFeatureDataAdapter) persistableAdapter;
assertNotNull(adapter.getUpdatedAdapter());
final FeatureDataAdapter updatedAdapter = adapter.getUpdatedAdapter();
assertEquals(4, updatedAdapter.getFieldDescriptors().length);
assertEquals(String.class, updatedAdapter.getFieldDescriptor("strAttr").bindingClass());
assertEquals(Integer.class, updatedAdapter.getFieldDescriptor("intAttr").bindingClass());
assertTrue(TemporalFieldDescriptor.class.isAssignableFrom(updatedAdapter.getFieldDescriptor("dateAttr").getClass()));
final TemporalFieldDescriptor<?> temporalField = (TemporalFieldDescriptor<?>) updatedAdapter.getFieldDescriptor("dateAttr");
assertEquals(Date.class, temporalField.bindingClass());
assertTrue(temporalField.indexHints().contains(TimeField.TIME_DIMENSION_HINT));
assertTrue(SpatialFieldDescriptor.class.isAssignableFrom(updatedAdapter.getFieldDescriptor("geom").getClass()));
final SpatialFieldDescriptor<?> spatialField = (SpatialFieldDescriptor<?>) updatedAdapter.getFieldDescriptor("geom");
assertEquals(Point.class, spatialField.bindingClass());
assertEquals(GeometryUtils.getDefaultCRS(), spatialField.crs());
assertTrue(spatialField.indexHints().contains(SpatialField.LATITUDE_DIMENSION_HINT));
assertTrue(spatialField.indexHints().contains(SpatialField.LONGITUDE_DIMENSION_HINT));
assertEquals("testType", updatedAdapter.getTypeName());
assertEquals(SimpleFeature.class, updatedAdapter.getDataClass());
assertTrue(updatedAdapter.hasTemporalConstraints());
assertNotNull(adapter.getVisibilityHandler());
final VisibilityHandler visibilityHandler = adapter.getVisibilityHandler();
assertTrue(visibilityHandler instanceof JsonFieldLevelVisibilityHandler);
assertEquals("strAttr", ((JsonFieldLevelVisibilityHandler) visibilityHandler).getVisibilityAttribute());
}
use of org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler in project geowave by locationtech.
the class VisibilityOptions method getConfiguredVisibilityHandler.
public VisibilityHandler getConfiguredVisibilityHandler() {
final VisibilityHandler globalVisibilityHandler;
if (visibility != null && visibility.trim().length() > 0) {
globalVisibilityHandler = new GlobalVisibilityHandler(visibility.trim());
} else {
globalVisibilityHandler = null;
}
if (visibilityAttribute != null && visibilityAttribute.trim().length() > 0) {
if (jsonVisibilityAttribute) {
return new JsonFieldLevelVisibilityHandler(visibilityAttribute);
}
return new FieldLevelVisibilityHandler(visibilityAttribute);
}
final VisibilityHandler fieldVisibilityHandler = parseFieldVisibilities();
if (fieldVisibilityHandler == null) {
if (globalVisibilityHandler != null) {
return globalVisibilityHandler;
}
return null;
} else if (globalVisibilityHandler != null) {
return new FallbackVisibilityHandler(new VisibilityHandler[] { fieldVisibilityHandler, globalVisibilityHandler });
}
return fieldVisibilityHandler;
}
Aggregations