def parse_field(fieldlist):
    """
       Traitement particulier pour les champs de type field :
       Chargement des listes de valeurs de nomenclature
    """
    for field in fieldlist:
        if "options" not in field:
            field["options"] = {}
        if "thesaurus_code_type" in field:
            field["options"]["choices"] = format_nomenclature_list({
                "code_type":
                field["thesaurus_code_type"],
                "regne":
                field.get("regne"),
                "group2_inpn":
                field.get("group2_inpn"),
            })
            if "default" in field:
                field["options"]["default"] = get_nomenclature_id_term(
                    str(field["thesaurus_code_type"]), str(field["default"]),
                    False)

        if "thesaurusHierarchyID" in field:
            field["options"]["choices"] = format_nomenclature_list({
                "code_type":
                field["thesaurus_code_type"],
                "hierarchy":
                field["thesaurusHierarchyID"],
            })
        if "attached_table_location" in field["options"]:
            (schema_name,
             table_name) = field["options"]["attached_table_location"].split(
                 ".")  # noqa
            field["options"]["id_table_location"] = get_table_location_id(
                schema_name, table_name)

        if "fields" in field:
            field["fields"] = parse_field(field["fields"])

    return fieldlist
Example #2
0
def parse_field(fieldlist):
    '''
       Traitement particulier pour les champs de type field :
       Chargement des listes de valeurs de nomenclature
    '''
    for field in fieldlist:
        if 'options' not in field:
            field['options'] = {}
        if 'thesaurus_code_type' in field:
            field['options']['choices'] = format_nomenclature_list({
                'code_type':
                field['thesaurus_code_type'],
                'regne':
                field.get('regne'),
                'group2_inpn':
                field.get('group2_inpn'),
            })
            if 'default' in field:
                field['options']['default'] = get_nomenclature_id_term(
                    str(field['thesaurus_code_type']), str(field['default']),
                    False)

        if 'thesaurusHierarchyID' in field:
            field['options']['choices'] = format_nomenclature_list({
                'code_type':
                field['thesaurus_code_type'],
                'hierarchy':
                field['thesaurusHierarchyID']
            })
        if 'attached_table_location' in field['options']:
            (schema_name,
             table_name) = field['options']['attached_table_location'].split(
                 '.')  # noqa
            field['options']['id_table_location'] = (get_table_location_id(
                schema_name, table_name))

        if 'fields' in field:
            field['fields'] = parse_field(field['fields'])

    return fieldlist
Example #3
0
voc_util = {
    "STADE_VIE": {
        "indetermine": "1",
        "adulte": "2",
        "juvenile": "3"
    },
    "SEXE": {
        "indetermine": "1",
        "femelle": "2",
        "male": "3"
    },
    "OBJ_DENBR": {
        "individu": "IND"
    },
    "TYP_DENBR": {
        "Compté": "Co"
    }
}

COR_COUNTING_VALUE = {}

for cd_type in voc_util:
    for k, cd_term in voc_util[cd_type].items():
        value = get_nomenclature_id_term(
            cd_type=cd_type, cd_term=cd_term
        )
        if cd_type not in COR_COUNTING_VALUE:
            COR_COUNTING_VALUE[cd_type] = {}

        COR_COUNTING_VALUE[cd_type][k] = value[0]