Exemple #1
0
    def _get_submission_fields(self,
                               fields_definition,
                               fields,
                               parent_field_name=None):
        for field in fields:
            if isinstance(field, UniqueIdField):
                unique_id_field_name = es_questionnaire_field_name(
                    field.code, self.latest_form_model.id, parent_field_name)
                fields_definition.append(
                    get_field_definition(
                        field,
                        field_name=es_unique_id_code_field_name(
                            unique_id_field_name)))

            if isinstance(field, FieldSet):
                if field.is_group():
                    self._get_submission_fields(fields_definition,
                                                field.fields, field.code)
                else:
                    es_field_name = es_questionnaire_field_name(
                        field.code, self.latest_form_model.id,
                        parent_field_name)
                    fields_definition.append(
                        get_field_definition_with_binary_type(
                            field, field_name=es_field_name))
                continue
            fields_definition.append(
                get_field_definition(field,
                                     field_name=es_questionnaire_field_name(
                                         field.code, self.latest_form_model.id,
                                         parent_field_name)))
 def get_mappings(self):
     fields_definition = []
     fields_definition.extend(get_submission_meta_fields())
     for field in self.form_model.fields:
         fields_definition.append(
             get_field_definition(field, field_name=es_field_name(field.code, self.form_model.id)))
     mapping = self.get_fields_mapping_by_field_def(doc_type=self.form_model.id, fields_definition=fields_definition)
     return mapping
Exemple #3
0
def create_subject_mapping(dbm, form_model):
    es = get_elasticsearch_handle()
    fields_definition = []
    for field in form_model.fields:
        fields_definition.append(
            get_field_definition(field,
                                 field_name=es_field_name(
                                     field.code, form_model.id)))
    mapping = get_fields_mapping_by_field_def(
        doc_type=form_model.id, fields_definition=fields_definition)
    es.put_mapping(dbm.database_name, form_model.entity_type[0], mapping)
 def get_mappings(self):
     fields_definition = []
     fields_definition.extend(get_submission_meta_fields())
     for field in self.latest_form_model.fields:
         if isinstance(field, UniqueIdField):
             unique_id_field_name = es_field_name(field.code,
                                                  self.latest_form_model.id)
             fields_definition.append(
                 get_field_definition(
                     field,
                     field_name=es_unique_id_code_field_name(
                         unique_id_field_name)))
         fields_definition.append(
             get_field_definition(field,
                                  field_name=es_field_name(
                                      field.code,
                                      self.latest_form_model.id)))
     mapping = self.get_fields_mapping_by_field_def(
         doc_type=self.latest_form_model.id,
         fields_definition=fields_definition)
     return mapping