Exemple #1
0
class PersonFacility(Record):
    """PersonFacility record model
    """
    person_id = dsl.Keyword()
    facility_id = dsl.Keyword()
    entry_date = dsl.Date()
    exit_date = dsl.Date()

    class Index:
        model = 'personfacility'
        name = f'{INDEX_PREFIX}personfacility'

    def __repr__(self):
        return f'<PersonFacility {self.person_id},{self.facility_id}>'
Exemple #2
0
class WraRecord(Record):
    """WraRecord model
    TODO review field types for aggs,filtering
    """
    wra_record_id = dsl.Keyword()
    facility = dsl.Keyword()
    lastname = dsl.Text()
    firstname = dsl.Text()
    middleinitial = dsl.Text()
    birthyear = dsl.Keyword()
    gender = dsl.Keyword()
    originalstate = dsl.Keyword()
    familyno = dsl.Keyword()
    individualno = dsl.Keyword()
    notes = dsl.Text()
    assemblycenter = dsl.Keyword()
    originaladdress = dsl.Keyword()
    birthcountry = dsl.Keyword()
    fatheroccupus = dsl.Keyword()
    fatheroccupabr = dsl.Keyword()
    yearsschooljapan = dsl.Keyword()
    gradejapan = dsl.Keyword()
    schooldegree = dsl.Keyword()
    yearofusarrival = dsl.Keyword()
    timeinjapan = dsl.Keyword()
    ageinjapan = dsl.Keyword()
    militaryservice = dsl.Keyword()
    maritalstatus = dsl.Keyword()
    ethnicity = dsl.Keyword()
    birthplace = dsl.Keyword()
    citizenshipstatus = dsl.Keyword()
    highestgrade = dsl.Keyword()
    language = dsl.Keyword()
    religion = dsl.Keyword()
    occupqual1 = dsl.Keyword()
    occupqual2 = dsl.Keyword()
    occupqual3 = dsl.Keyword()
    occupotn1 = dsl.Keyword()
    occupotn2 = dsl.Keyword()
    wra_filenumber = dsl.Keyword()
    person = dsl.Nested(NestedPerson)
    family = dsl.Nested(ListFamily)
    timestamp = dsl.Date()

    class Index:
        model = 'wrarecord'
        name = f'{INDEX_PREFIX}wrarecord'

    def __repr__(self):
        return f'<WraRecord {self.wra_record_id}>'

    @staticmethod
    def get(oid, request):
        """Get record for web app"""
        return docstore_object(request, 'wrarecord', oid)

    @staticmethod
    def from_dict(wra_record_id, data):
        """
        @param wra_record_id: str
        @param data: dict
        @returns: WraRecord
        """
        # exclude private fields
        fieldnames = [
            f for f in FIELDS_WRARECORD if f not in EXCLUDE_FIELDS_WRARECORD
        ]
        record = Record.from_dict(WraRecord, fieldnames, wra_record_id, data)
        assemble_fulltext(record, fieldnames)
        record.family = []
        if data.get('family'):
            record.family = [{
                'wra_record_id': person['wra_record_id'],
                'lastname': person['lastname'],
                'firstname': person['firstname'],
            } for person in data['family']]
        return record

    @staticmethod
    def from_hit(hit):
        """Build WraRecord object from Elasticsearch hit
        @param hit
        @returns: WraRecord
        """
        return Record.from_hit(WraRecord, hit)

    @staticmethod
    def field_values(field, es=None, index=None):
        """Returns unique values and counts for specified field.
        """
        return Record.field_values(WraRecord, field, es, index)
Exemple #3
0
class FarRecord(Record):
    """FarRecord model
    TODO review field types for aggs,filtering
    """
    far_record_id = dsl.Keyword()
    facility = dsl.Keyword()
    original_order = dsl.Keyword()
    family_number = dsl.Keyword()
    far_line_id = dsl.Keyword()
    last_name = dsl.Text()
    first_name = dsl.Text()
    other_names = dsl.Text()
    date_of_birth = dsl.Keyword()
    year_of_birth = dsl.Keyword()
    sex = dsl.Keyword()
    marital_status = dsl.Keyword()
    citizenship = dsl.Keyword()
    alien_registration = dsl.Keyword()
    entry_type_code = dsl.Keyword()
    entry_type = dsl.Keyword()
    entry_category = dsl.Keyword()
    entry_facility = dsl.Keyword()
    pre_evacuation_address = dsl.Keyword()
    pre_evacuation_state = dsl.Keyword()
    date_of_original_entry = dsl.Keyword()
    departure_type_code = dsl.Keyword()
    departure_type = dsl.Keyword()
    departure_category = dsl.Keyword()
    departure_facility = dsl.Keyword()
    departure_date = dsl.Keyword()
    departure_state = dsl.Keyword()
    camp_address_original = dsl.Keyword()
    camp_address_block = dsl.Keyword()
    camp_address_barracks = dsl.Keyword()
    camp_address_room = dsl.Keyword()
    reference = dsl.Keyword()
    original_notes = dsl.Text()
    person = dsl.Nested(NestedPerson)
    family = dsl.Nested(ListFamily)
    timestamp = dsl.Date()

    class Index:
        model = 'farrecord'
        name = f'{INDEX_PREFIX}farrecord'

    def __repr__(self):
        return f'<FarRecord {self.far_record_id}>'

    @staticmethod
    def get(oid, request):
        """Get record for web app"""
        return docstore_object(request, 'farrecord', oid)

    @staticmethod
    def from_dict(far_record_id, data):
        """
        @param far_record_id: str
        @param data: dict
        @returns: FarRecord
        """
        # exclude private fields
        fieldnames = [
            f for f in FIELDS_FARRECORD if f not in EXCLUDE_FIELDS_FARRECORD
        ]
        record = Record.from_dict(FarRecord, fieldnames, far_record_id, data)
        assemble_fulltext(record, fieldnames)
        record.family = []
        if data.get('family'):
            record.family = [{
                'far_record_id': person['far_record_id'],
                'last_name': person['last_name'],
                'first_name': person['first_name'],
            } for person in data['family']]
        return record

    @staticmethod
    def from_hit(hit):
        """Build FarRecord object from Elasticsearch hit
        @param hit
        @returns: FarRecord
        """
        return Record.from_hit(FarRecord, hit)

    @staticmethod
    def field_values(field, es=None, index=None):
        """Returns unique values and counts for specified field.
        """
        return Record.field_values(FarRecord, field, es, index)
Exemple #4
0
class Person(Record):
    """Person record model
    TODO review field types for aggs,filtering
    """
    nr_id = dsl.Keyword()
    family_name = dsl.Text()
    given_name = dsl.Text()
    given_name_alt = dsl.Text()
    other_names = dsl.Text()
    middle_name = dsl.Text()
    prefix_name = dsl.Text()
    suffix_name = dsl.Text()
    jp_name = dsl.Text()
    preferred_name = dsl.Text()
    birth_date = dsl.Date()
    birth_date_text = dsl.Text()
    birth_place = dsl.Text()
    death_date = dsl.Date()
    death_date_text = dsl.Text()
    wra_family_no = dsl.Text()
    wra_individual_no = dsl.Text()
    citizenship = dsl.Keyword()
    alien_registration_no = dsl.Text()
    gender = dsl.Keyword()
    preexclusion_residence_city = dsl.Keyword()
    preexclusion_residence_state = dsl.Keyword()
    postexclusion_residence_city = dsl.Keyword()
    postexclusion_residence_state = dsl.Keyword()
    exclusion_order_title = dsl.Keyword()
    exclusion_order_id = dsl.Keyword()
    timestamp = dsl.Date()
    facilities = dsl.Nested(ListFacility)
    far_records = dsl.Nested(ListFarRecord)
    wra_records = dsl.Nested(ListWraRecord)
    family = dsl.Nested(ListFamily)

    class Index:
        model = 'person'
        name = f'{INDEX_PREFIX}person'

    def __repr__(self):
        return f'<Person {self.nr_id}>'

    @staticmethod
    def get(oid, request):
        """Get record for web app"""
        return docstore_object(request, 'person', oid)

    @staticmethod
    def from_dict(nr_id, data):
        """
        @param nr_id: str
        @param data: dict
        @returns: Person
        """
        # exclude private fields
        fieldnames = [
            f for f in FIELDS_PERSON if f not in EXCLUDE_FIELDS_PERSON
        ]
        record = Record.from_dict(Person, fieldnames, nr_id, data)
        assemble_fulltext(record, fieldnames)
        record.family = []
        if data.get('family'):
            record.family = [{
                'nr_id': person['nr_id'],
                'preferred_name': person['preferred_name'],
            } for person in data['family']]
        return record

    @staticmethod
    def from_hit(hit):
        """Build Person object from Elasticsearch hit
        @param hit
        @returns: Person
        """
        return Record.from_hit(Person, hit)

    @staticmethod
    def from_id(nr_id):
        return Person.get(nr_id)

    @staticmethod
    def field_values(field, es=None, index=None):
        """Returns unique values and counts for specified field.
        """
        return Record.field_values(Person, field, es, index)
Exemple #5
0
class ListFacility(dsl.InnerDoc):
    person_nr_id = dsl.Keyword()
    facility_id = dsl.Keyword()
    entry_date = dsl.Date()
    exit_date = dsl.Date()