예제 #1
0
def _build_choice_list_indicator(spec, context):
    wrapped_spec = ChoiceListIndicatorSpec.wrap(spec)
    base_display_name = wrapped_spec.display_name

    def _construct_display(choice):
        return '{base} ({choice})'.format(base=base_display_name,
                                          choice=choice)

    def _construct_column(choice):
        return '{col}_{choice}'.format(col=spec['column_id'], choice=choice)

    choice_indicators = [
        BooleanIndicator(
            display_name=_construct_display(choice),
            column_id=_construct_column(choice),
            filter=SinglePropertyValueFilter(
                expression=wrapped_spec.getter,
                operator=wrapped_spec.get_operator(),
                reference_expression=ExpressionFactory.from_spec(choice),
            ),
            wrapped_spec=None,
        ) for choice in spec['choices']
    ]
    return CompoundIndicator(base_display_name, choice_indicators,
                             wrapped_spec)
예제 #2
0
파일: models.py 프로젝트: ekush/commcare-hq
    def indicators(self):
        default_indicators = [IndicatorFactory.from_spec({
            "column_id": "doc_id",
            "type": "expression",
            "display_name": "document id",
            "datatype": "string",
            "is_nullable": False,
            "is_primary_key": True,
            "expression": {
                "type": "root_doc",
                "expression": {
                    "type": "property_name",
                    "property_name": "_id"
                }
            }
        }, self.named_filter_objects)]

        default_indicators.append(IndicatorFactory.from_spec({
            "type": "inserted_at",
        }, self.named_filter_objects))

        if self.base_item_expression:
            default_indicators.append(IndicatorFactory.from_spec({
                "type": "repeat_iteration",
            }, self.named_filter_objects))
        return CompoundIndicator(
            self.display_name,
            default_indicators + [
                IndicatorFactory.from_spec(indicator, self.named_filter_objects)
                for indicator in self.configured_indicators
            ]
        )
예제 #3
0
    def indicators(self):

        return CompoundIndicator(
            self.display_name, self.default_indicators + [
                IndicatorFactory.from_spec(indicator,
                                           self._get_factory_context())
                for indicator in self.configured_indicators
            ])