Ejemplo n.º 1
0
 def indicators(self):
     """
     Return all the dict data source indicator configurations that could be
     used by a report that uses the same case type/form as this DataSourceConfiguration.
     """
     ret = []
     for prop in self.data_source_properties.values():
         if prop.type == 'meta':
             ret.append(make_form_meta_block_indicator(
                 prop.source, prop.column_id
             ))
         elif prop.type == "question":
             ret.append(make_form_question_indicator(
                 prop.source, prop.column_id
             ))
         elif prop.type == 'case_property' and prop.source == 'computed/owner_name':
             ret.append(make_owner_name_indicator(prop.column_id))
         elif prop.type == 'case_property':
             ret.append(make_case_property_indicator(
                 prop.source, prop.column_id
             ))
     ret.append({
         "display_name": "Count",
         "type": "count",
         "column_id": "count"
     })
     return ret
Ejemplo n.º 2
0
 def indicators(self):
     """
     Return all the dict data source indicator configurations that could be
     used by a report that uses the same case type/form as this DataSourceConfiguration.
     """
     ret = []
     for prop in self.data_source_properties.values():
         if prop['type'] == 'meta':
             ret.append(
                 make_form_meta_block_indicator(prop['source'],
                                                prop['column_id']))
         elif prop['type'] == "question":
             ret.append(
                 make_form_question_indicator(prop['source'],
                                              prop['column_id']))
         elif prop['type'] == 'case_property' and prop[
                 'source'] == 'computed/owner_name':
             ret.append(make_owner_name_indicator(prop['column_id']))
         elif prop['type'] == 'case_property':
             ret.append(
                 make_case_property_indicator(prop['source'],
                                              prop['column_id']))
     ret.append({
         "display_name": "Count",
         "type": "count",
         "column_id": "count"
     })
     return ret
Ejemplo n.º 3
0
 def get_indicator(self, aggregation, is_multiselect_chart_report=False):
     # aggregation parameter is never used because we need not infer the data type
     # self._question_source is a tuple of (identifier, datatype)
     identifier = self._meta_property_spec[0]
     if isinstance(identifier, basestring):
         identifier = [identifier]
     identifier = "/".join(identifier)
     column_id = get_column_name(identifier.strip("/"))
     return make_form_meta_block_indicator(
         self._meta_property_spec, column_id, root_doc=is_multiselect_chart_report
     )
Ejemplo n.º 4
0
def get_form_data_source(app, form):
    xform = XForm(form.source)
    form_name = form.default_name()
    questions = xform.get_questions([])

    return DataSourceConfiguration(
        domain=app.domain,
        referenced_doc_type="XFormInstance",
        table_id=_clean_table_name(app.domain, form_name),
        display_name=form_name,
        configured_filter=make_form_data_source_filter(xform.data_node.tag_xmlns),
        configured_indicators=[
            make_form_question_indicator(q, column_id=get_column_name(q["value"])) for q in questions
        ]
        + [make_form_meta_block_indicator(field) for field in FORM_METADATA_PROPERTIES],
    )
Ejemplo n.º 5
0
def get_form_data_source(app, form):
    xform = XForm(form.source)
    form_name = form.default_name()
    questions = xform.get_questions([])

    return DataSourceConfiguration(
        domain=app.domain,
        referenced_doc_type='XFormInstance',
        table_id=_clean_table_name(app.domain, form_name),
        display_name=form_name,
        configured_filter=make_form_data_source_filter(xform.data_node.tag_xmlns),
        configured_indicators=[
            make_form_question_indicator(q, column_id=get_column_name(q['value']))
            for q in questions
        ] + [
            make_form_meta_block_indicator(field)
            for field in FORM_METADATA_PROPERTIES
        ],
    )