Search in sources :

Example 1 with JsonFieldLevelVisibilityHandler

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());
}
Also used : SimpleFeatureTypeBuilder(org.geotools.feature.simple.SimpleFeatureTypeBuilder) LegacyFeatureDataAdapter(org.locationtech.geowave.migration.legacy.adapter.vector.LegacyFeatureDataAdapter) Persistable(org.locationtech.geowave.core.index.persist.Persistable) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) Point(org.locationtech.jts.geom.Point) Date(java.util.Date) AttributeTypeBuilder(org.geotools.feature.AttributeTypeBuilder) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) SpatialFieldDescriptor(org.locationtech.geowave.core.geotime.adapter.SpatialFieldDescriptor) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) JsonFieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler) JsonFieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler) TemporalFieldDescriptor(org.locationtech.geowave.core.geotime.adapter.TemporalFieldDescriptor) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) LegacyFeatureDataAdapter(org.locationtech.geowave.migration.legacy.adapter.vector.LegacyFeatureDataAdapter) Test(org.junit.Test)

Example 2 with JsonFieldLevelVisibilityHandler

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;
}
Also used : FieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.FieldLevelVisibilityHandler) JsonFieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler) FallbackVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.FallbackVisibilityHandler) GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler) FieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.FieldLevelVisibilityHandler) FallbackVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.FallbackVisibilityHandler) VisibilityHandler(org.locationtech.geowave.core.store.api.VisibilityHandler) FieldMappedVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.FieldMappedVisibilityHandler) JsonFieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler) JsonFieldLevelVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler) GlobalVisibilityHandler(org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler)

Aggregations

VisibilityHandler (org.locationtech.geowave.core.store.api.VisibilityHandler)2 JsonFieldLevelVisibilityHandler (org.locationtech.geowave.core.store.data.visibility.JsonFieldLevelVisibilityHandler)2 Date (java.util.Date)1 AttributeTypeBuilder (org.geotools.feature.AttributeTypeBuilder)1 SimpleFeatureTypeBuilder (org.geotools.feature.simple.SimpleFeatureTypeBuilder)1 Test (org.junit.Test)1 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)1 SpatialFieldDescriptor (org.locationtech.geowave.core.geotime.adapter.SpatialFieldDescriptor)1 TemporalFieldDescriptor (org.locationtech.geowave.core.geotime.adapter.TemporalFieldDescriptor)1 Persistable (org.locationtech.geowave.core.index.persist.Persistable)1 FallbackVisibilityHandler (org.locationtech.geowave.core.store.data.visibility.FallbackVisibilityHandler)1 FieldLevelVisibilityHandler (org.locationtech.geowave.core.store.data.visibility.FieldLevelVisibilityHandler)1 FieldMappedVisibilityHandler (org.locationtech.geowave.core.store.data.visibility.FieldMappedVisibilityHandler)1 GlobalVisibilityHandler (org.locationtech.geowave.core.store.data.visibility.GlobalVisibilityHandler)1 LegacyFeatureDataAdapter (org.locationtech.geowave.migration.legacy.adapter.vector.LegacyFeatureDataAdapter)1 Point (org.locationtech.jts.geom.Point)1 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)1 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)1