Exemplo n.º 1
0
    def _create_tenure_type_lookup_column(self, tenure_vl):
        # Returns a lookup column whose parent is the given tenure value list.
        col_name = tenure_vl.short_name.replace('check_',
                                                '').replace(' ', '_').lower()
        tenure_lookup_col = LookupColumn(col_name, self)
        tenure_lookup_col.value_list = tenure_vl

        return tenure_lookup_col
Exemplo n.º 2
0
def append_person_columns(entity):
    household_id = IntegerColumn('household_id', entity)
    first_name = VarCharColumn('first_name', entity, maximum=30)
    last_name = VarCharColumn('last_name', entity, maximum=30)

    # Create gender lookup column and attach value list
    gender = LookupColumn('gender', entity)
    gender_value_list = create_gender_lookup(entity)
    gender.value_list = gender_value_list

    entity.add_column(household_id)
    entity.add_column(first_name)
    entity.add_column(last_name)
    entity.add_column(gender)
Exemplo n.º 3
0
Arquivo: utils.py Projeto: gltn/stdm
def append_person_columns(entity):
    household_id = IntegerColumn('household_id', entity)
    first_name = VarCharColumn('first_name', entity, maximum=30)
    last_name = VarCharColumn('last_name', entity, maximum=30)

    #Create gender lookup column and attach value list
    gender = LookupColumn('gender', entity)
    gender_value_list = create_gender_lookup(entity)
    gender.value_list = gender_value_list

    entity.add_column(household_id)
    entity.add_column(first_name)
    entity.add_column(last_name)
    entity.add_column(gender)
Exemplo n.º 4
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.º 5
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.º 6
0
    def __init__(self, profile, parent_entity):
        self.parent_entity = parent_entity

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

        self.user_editable = False

        # Supporting document ref column
        self.document_reference = ForeignKeyColumn('supporting_doc_id', self)

        normalize_name = self.parent_entity.short_name.replace(
            ' ',
            '_'
        ).lower()

        # Entity reference column
        entity_ref_name = '{0}_{1}'.format(normalize_name, 'id')
        self.entity_reference = ForeignKeyColumn(entity_ref_name, self)

        # Document types
        vl_name = self._doc_type_name(normalize_name)

        self._doc_types_value_list = self._doc_type_vl(vl_name)

        if self._doc_types_value_list is None:
            self._doc_types_value_list = self.profile.create_value_list(
                vl_name
            )
            self.profile.add_entity(self._doc_types_value_list)

            # Add a default type
            self._doc_types_value_list.add_value(self.tr('General'))

        # Document type column
        self.doc_type = LookupColumn('document_type', self)
        self.doc_type.value_list = self._doc_types_value_list

        # Append columns
        self.add_column(self.document_reference)
        self.add_column(self.entity_reference)
        self.add_column(self.doc_type)

        LOGGER.debug('Updating foreign key references in %s entity.',
                     self.name)

        # Update foreign key references
        self._update_fk_references()

        LOGGER.debug('%s entity successfully initialized', self.name)