How to use the pygw.base_models.PyGwJavaWrapper function in pygw

To help you get started, we’ve selected a few pygw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github locationtech / geowave / python / src / main / python / pygw / query.py View on Github external
qb.set_cql_constraint(cql_query)

        if index:
            qb.set_index(index)
        if auths:
            qb.set_auth(auths)
        if limit:
            qb.set_limit(limit)
        if type_names:
            qb.set_type_names(type_names)
        if which_fields:
            qb.set_fields(which_fields)

        return cls(qb.build())

class QueryBuilder(PyGwJavaWrapper):
    """
    [INTERNAL]
    Necessary for a query:
    - Constraints (default: Everything)
    - Index: either all or single (default: All)
    - Authorizations: string array (default: empty string array)
    - Limits (default: null)
    - Fields: all fields or a subset (only 1 type-name if subset; default all)
    - Type names: all or a subset (default: all)
    """
    def __init__(self):
        j_qbuilder = config.MODULE__core_store.QueryBuilder.newBuilder()
        super().__init__(config.GATEWAY, j_qbuilder)

    def set_type_names(self, type_names=None):
        if type_names:
github locationtech / geowave / python / src / main / python / pygw / query.py View on Github external
def __init__(self):
        j_vector_qbuilder = config.MODULE__geotime_query.VectorQueryBuilder.newBuilder()
        PyGwJavaWrapper.__init__(self, config.GATEWAY, j_vector_qbuilder)
github locationtech / geowave / python / src / main / python / pygw / geotools.py View on Github external
from pygw.config import config
from pygw.base_models import PyGwJavaWrapper, DataTypeAdapter
from enum import Enum

class SimpleFeature(PyGwJavaWrapper):
    """
    A Simple (Vector) Feature.
    """
    def __init__(self, type_, id, java_ref):
        assert isinstance(type_, SimpleFeatureType)
        self.type_ = type_
        self.id = id
        super().__init__(config.GATEWAY, java_ref)

class SimpleFeatureBuilder(PyGwJavaWrapper):
    """
    Builds SimpleFeature instances for a given SimpleFeatureType.
    """

    def __init__(self, type_):
        assert isinstance(type_, SimpleFeatureType)
github locationtech / geowave / python / src / main / python / pygw / geotools.py View on Github external
def get_name(self):
        return self.name
        
    def get_feature_builder(self):
        return self.feature_builder

    def get_type_adapter(self):
        return SimpleFeatureDataAdapter(self)

    def create_feature(self, id, **kwargs):
        for desc, val in kwargs.items():
            self.feature_builder.set_attr(desc, val)
        return self.feature_builder.build(id)

class SimpleFeatureTypeAttribute(PyGwJavaWrapper):
    def __init__(self, type_, is_nilable, descriptor):
        self.type_= type_
        self.is_nilable = is_nilable
        self.descriptor = descriptor
        j_builder = config.MODULE__feature.AttributeTypeBuilder()

        if not isinstance(type_, SimpleFeatureTypeAttribute.Type):
            raise SimpleFeatureTypeAttribute.UnknownTypeError("Invalid argument to `type_`. Must be one of defined types in FeatureTypeAttribute.Type")

        j_type_cls = config.reflection_util.classForName(type_.value)

        j_builder.binding(j_type_cls)
        j_builder.nillable(is_nilable)
        j_attribute = j_builder.buildDescriptor(descriptor)
        super().__init__(config.GATEWAY, j_attribute)
github locationtech / geowave / python / src / main / python / pygw / geotools.py View on Github external
from pygw.config import config
from pygw.base_models import PyGwJavaWrapper, DataTypeAdapter
from enum import Enum

class SimpleFeature(PyGwJavaWrapper):
    """
    A Simple (Vector) Feature.
    """
    def __init__(self, type_, id, java_ref):
        assert isinstance(type_, SimpleFeatureType)
        self.type_ = type_
        self.id = id
        super().__init__(config.GATEWAY, java_ref)

class SimpleFeatureBuilder(PyGwJavaWrapper):
    """
    Builds SimpleFeature instances for a given SimpleFeatureType.
    """

    def __init__(self, type_):
        assert isinstance(type_, SimpleFeatureType)
        self.type_ = type_
        self.attributes = { a.descriptor : a for a in type_.attributes }
        j_builder = config.MODULE__feature_simple.SimpleFeatureBuilder(type_._java_ref)
        super().__init__(config.GATEWAY, j_builder)

    def set_attr(self, descriptor, value):
        if descriptor not in self.attributes:
            raise SimpleFeatureBuilder.NoSuchAttributeInTypeError("No matching attribute for {}".format(descriptor))
        attr_switch = {
        # Defines a mapping from attribute type to function to set it
github locationtech / geowave / python / src / main / python / pygw / geotools.py View on Github external
raise Exception("Unsupported number of args to Coordinate")
        j_geom = config.MODULE__geotime_util.GeometryUtils.GEOMETRY_FACTORY.createPoint(j_coord)
        self._java_ref.set(attr.descriptor, j_geom)

    def _set_date(self, attr, value):
        # TODO
        # Thoughts for this: Python date -> String -> Java Date from String
        pass

    def build(self, id):
        j_feature = self._java_ref.buildFeature(str(id))
        return SimpleFeature(self.type_, id, j_feature)

    class NoSuchAttributeInTypeError(Exception): pass
    
class SimpleFeatureType(PyGwJavaWrapper):
    """
    Defines a Schema for a SimpleFeature / Vector Feature.
    """

    def __init__(self, feature_name, *attributes):
        j_builder = config.MODULE__feature_simple.SimpleFeatureTypeBuilder()
        j_builder.setName(feature_name)
        for a in attributes:
            assert isinstance(a, SimpleFeatureTypeAttribute)
            j_builder.add(a._java_ref)
        self.attributes = attributes
        self.name = feature_name
        j_feature_type = j_builder.buildFeatureType()
        super().__init__(config.GATEWAY, j_feature_type)
        self.feature_builder = SimpleFeatureBuilder(self)