Exemplo n.º 1
0
    def __init__(self, name, profile, supports_documents=True,
                 layer_display=''):
        Entity.__init__(self, name, profile,
                        supports_documents=supports_documents)

        self.user_editable = False

        self._party = None
        self._spatial_unit = None
        self._view_name = u'{0}_{1}'.format(
            self.profile.name.replace(' ', '_').lower(),
            SocialTenure.BASE_STR_VIEW
        )

        self.party_foreign_key = ForeignKeyColumn('party_id', self)
        self.spatial_unit_foreign_key = ForeignKeyColumn('spatial_unit_id',
                                                         self)
        self.tenure_type_lookup = LookupColumn('tenure_type', self)
        self.layer_display_name = layer_display
        self._value_list = self._prepare_tenure_type_value_list()

        #Add the value list to the table collection
        self.profile.add_entity(self._value_list)

        #Add columns to the collection
        self.add_column(self.party_foreign_key)
        self.add_column(self.spatial_unit_foreign_key)
        self.add_column(self.tenure_type_lookup)

        #Specify if a spatial unit should only be linked to one party
        self.multi_party = True

        LOGGER.debug('Social Tenure Relationship initialized for %s profile.',
                     self.profile.name)
Exemplo n.º 2
0
    def initialize_custom_attributes_entity(self, tenure_lookup):
        """
        Creates a custom user attributes entity and adds a foreign key 
        column for linking the two entities.
        .. versionadded:: 1.7
        :param tenure_lookup: Valuelist containing tenure types.
        :type tenure_lookup: str or ValueList
        :return: Returns the custom attributes entity. A new one is created 
        if did not exist otherwise the an existing one is returned. The 
        entity needs to be added manually to the registry.
        :rtype: Entity
        """
        tenure_lookup = self._obj_from_str(tenure_lookup)
        custom_ent_name = self._custom_attributes_entity_name(
            tenure_lookup.short_name)
        custom_ent = self.profile.entity(custom_ent_name)

        # Created only if it does not exist
        if custom_ent is None:
            custom_ent = Entity(custom_ent_name,
                                self.profile,
                                supports_documents=False)
            custom_ent.user_editable = False
            # Column for linking with primary tenure table
            str_col = ForeignKeyColumn('social_tenure_relationship_id',
                                       custom_ent)
            str_col.set_entity_relation_attr('parent', self)
            str_col.set_entity_relation_attr('parent_column', 'id')
            custom_ent.add_column(str_col)

        # Validate existence of dummy column
        self._validate_custom_attr_dummy_column(custom_ent)

        return custom_ent
Exemplo n.º 3
0
    def __init__(self, name, profile, **kwargs):
        Entity.__init__(self, name, profile, supports_documents=False)

        self.user_editable = False
        self.is_associative = True

        self.first_reference_column = None
        self.second_reference_column = None

        self.first_parent = kwargs.get('first_parent', None)
        self.second_parent = kwargs.get('second_parent', None)
Exemplo n.º 4
0
    def __init__(self, name, profile, **kwargs):
        Entity.__init__(self, name, profile, supports_documents=False)

        self.user_editable = False
        self.is_associative = True

        self.first_reference_column = None
        self.second_reference_column = None

        self.first_parent = kwargs.get('first_parent', None)
        self.second_parent = kwargs.get('second_parent', None)
Exemplo n.º 5
0
    def __init__(self, profile):
        Entity.__init__(self, 'auto_generate_code', profile,
                    is_global=False, is_proxy=False, supports_documents=False)

        self.user_editable = False

        self.auto_generate_code_name = VarCharColumn('code', self, maximum=50)

        LOGGER.debug('%s Auto Generate Code entity initialized.', self.name)

        # Add columns
        self.add_column(self.auto_generate_code_name)
Exemplo n.º 6
0
    def __init__(self,
                 name,
                 profile,
                 supports_documents=True,
                 layer_display=''):
        Entity.__init__(self,
                        name,
                        profile,
                        supports_documents=supports_documents)

        self.user_editable = False

        self._party = None
        self._spatial_unit = None
        self._view_name = None

        self.party_foreign_key = ForeignKeyColumn('party_id', self)
        self.spatial_unit_foreign_key = ForeignKeyColumn(
            'spatial_unit_id', self)
        self.tenure_type_lookup = LookupColumn('tenure_type', self)

        # Added in v1.5
        self.validity_start_column = DateColumn('validity_start',
                                                self,
                                                index=True)
        self.validity_end_column = DateColumn('validity_end', self, index=True)
        self.tenure_share_column = PercentColumn('tenure_share', self)

        self.layer_display_name = layer_display
        self._value_list = self._prepare_tenure_type_value_list()

        # Add the value list to the table collection
        self.profile.add_entity(self._value_list)

        # Add columns to the collection
        self.add_column(self.spatial_unit_foreign_key)
        self.add_column(self.tenure_type_lookup)
        self.add_column(self.validity_start_column)
        self.add_column(self.validity_end_column)
        self.add_column(self.tenure_share_column)

        # Added in v1.5
        self._party_fk_columns = OrderedDict()
        #Names of party entities that have been removed
        self.removed_parties = []

        # Specify if a spatial unit should only be linked to one party
        self.multi_party = True

        LOGGER.debug('Social Tenure Relationship initialized for %s profile.',
                     self.profile.name)
Exemplo n.º 7
0
    def __init__(self, profile):
        Entity.__init__(self,
                        'auto_generate_code',
                        profile,
                        is_global=False,
                        is_proxy=False,
                        supports_documents=False)

        self.user_editable = False

        self.auto_generate_code_name = VarCharColumn('code', self, maximum=50)

        LOGGER.debug('%s Auto Generate Code entity initialized.', self.name)

        # Add columns
        self.add_column(self.auto_generate_code_name)
Exemplo n.º 8
0
    def __init__(self, name, profile):
        #Assert if 'check' prefix has been appended.
        name = self._append_check(name)

        Entity.__init__(self, name, profile, supports_documents=False)

        self.user_editable = False

        self.code_column = VarCharColumn('code', self, minimum=0, maximum=5)
        self.value_column = VarCharColumn('value', self, minimum=2, maximum=50)
        self.values = OrderedDict()

        #Attach columns
        self.add_column(self.code_column)
        self.add_column(self.value_column)

        LOGGER.debug('%s ValueList initialized.', self.name)
Exemplo n.º 9
0
    def __init__(self, name, profile):
        # Assert if 'check' prefix has been appended.
        name = self._append_check(name)

        Entity.__init__(self, name, profile, supports_documents=False)

        self.user_editable = False

        self.code_column = VarCharColumn('code', self, minimum=0, maximum=5)
        self.value_column = VarCharColumn('value', self, minimum=2, maximum=50)
        self.values = OrderedDict()
        self._hash = hashlib

        # Attach columns
        self.add_column(self.code_column)
        self.add_column(self.value_column)

        LOGGER.debug('%s ValueList initialized.', self.name)
Exemplo n.º 10
0
    def __init__(self, profile):
        Entity.__init__(self,
                        'admin_spatial_unit_set',
                        profile,
                        is_global=True,
                        is_proxy=True,
                        supports_documents=False)

        self.user_editable = False

        self.admin_unit_name = VarCharColumn('name', self, maximum=70)
        self.admin_unit_code = VarCharColumn('code', self, maximum=10)

        LOGGER.debug('%s Administrative Spatial Unit set initialized.',
                     self.name)

        #Add columns
        self.add_column(self.admin_unit_name)
        self.add_column(self.admin_unit_code)
Exemplo n.º 11
0
    def __init__(self, profile):
        Entity.__init__(self, 'admin_spatial_unit_set', profile,
                    is_global=True, is_proxy=True, supports_documents=False)

        self.user_editable = False

        self.admin_unit_name = VarCharColumn('name', self, maximum=70)
        self.admin_unit_code = VarCharColumn('code', self, maximum=10)

        self.admin_parent_id = ForeignKeyColumn('parent_id', self)
        self.admin_parent_id.set_entity_relation_attr('parent', self)
        self.admin_parent_id.set_entity_relation_attr('parent_column', 'id')

        LOGGER.debug('%s Administrative Spatial Unit set initialized.', self.name)

        # Add columns
        self.add_column(self.admin_unit_name)
        self.add_column(self.admin_unit_code)
        self.add_column(self.admin_parent_id)
Exemplo n.º 12
0
    def __init__(self, profile):
        Entity.__init__(self, 'supporting_document', profile, supports_documents=False)

        self.user_editable = False

        self.creation_date = DateTimeColumn('creation_date', self)
        self.document_identifier = VarCharColumn('document_identifier',
                                                 self, maximum=50)
        self.document_type = VarCharColumn('source_entity', self, maximum=150)
        self.document_size = IntegerColumn('document_size', self)
        self.filename = VarCharColumn('filename', self, maximum=200)

        LOGGER.debug('%s supporting document initialized.', self.name)

        # Add columns to the entity
        self.add_column(self.creation_date)
        self.add_column(self.document_identifier)
        self.add_column(self.document_type)
        self.add_column(self.document_size)
        self.add_column(self.filename)
Exemplo n.º 13
0
    def __init__(self, profile):
        Entity.__init__(self,
                        'supporting_document',
                        profile,
                        supports_documents=False)

        self.user_editable = False

        self.creation_date = DateTimeColumn('creation_date', self)
        self.document_identifier = VarCharColumn('document_identifier',
                                                 self,
                                                 maximum=50)
        self.document_type = VarCharColumn('source_entity', self, maximum=150)
        self.document_size = IntegerColumn('document_size', self)
        self.filename = VarCharColumn('filename', self, maximum=200)

        LOGGER.debug('%s supporting document initialized.', self.name)

        # Add columns to the entity
        self.add_column(self.creation_date)
        self.add_column(self.document_identifier)
        self.add_column(self.document_type)
        self.add_column(self.document_size)
        self.add_column(self.filename)