Exemplo n.º 1
0
class FileIdAutoCompleteEntry(JsonObject):
    _id = StringProperty(name='id')
    dataType = StringProperty()
    donorId = ListProperty(StringProperty)
    fileBundleId = StringProperty()
    fileName = ListProperty(StringProperty)
    projectCode = ListProperty(StringProperty)
    _type = StringProperty(name='type', default='file')
Exemplo n.º 2
0
class PaginationObj(JsonObject):
    count = IntegerProperty()
    total = IntegerProperty()
    size = IntegerProperty()
    next = StringProperty()
    previous = StringProperty()
    sort = StringProperty()
    order = StringProperty(choices=['asc', 'desc'])
Exemplo n.º 3
0
class ShardMeta(JsonObject, LooslyEqualJsonObject):
    id = IntegerProperty()
    dbname = StringProperty()
    host = StringProperty()
    port = IntegerProperty()

    def get_server_option_string(self):
        return SHARD_OPTION_TEMPLATE.format(**self)
Exemplo n.º 4
0
    class PropertyDefinition(JsonObject):
        # The case property name
        name = StringProperty()

        # The type of the value property:
        #   VALUE_TYPE_EXACT means `value` is the exact value to set to the case property referred to by `name`.
        #   VALUE_TYPE_CASE_PROPERTY means `value` is a case property to resolve first and then set to the case
        #   property referred to by `name`.
        value_type = StringProperty()

        # Meaning depends on value_type, see above
        value = StringProperty()
Exemplo n.º 5
0
class FileTypeSummary(AzulJsonObject):
    format = StringProperty()
    fileSource = ListProperty()  # List could have string(s) and/or None
    count = IntegerProperty()
    totalSize = FloatProperty()
    matrixCellCount = FloatProperty()
    isIntermediate = BooleanProperty()
    contentDescription = ListProperty(
    )  # List could have string(s) and/or None

    @classmethod
    def for_bucket(cls, bucket: JSON) -> 'FileTypeSummary':
        self = cls()
        self.count = bucket['doc_count']
        self.totalSize = bucket['size_by_type']['value']
        self.matrixCellCount = bucket['matrix_cell_count_by_type']['value']
        self.format = bucket['key']
        return self

    @classmethod
    def for_aggregate(cls, aggregate_file: JSON) -> 'FileTypeSummary':
        self = cls()
        self.count = aggregate_file['count']
        self.fileSource = aggregate_file['file_source']
        self.totalSize = aggregate_file['size']
        self.matrixCellCount = aggregate_file['matrix_cell_count']
        self.format = aggregate_file['file_format']
        self.isIntermediate = aggregate_file['is_intermediate']
        self.contentDescription = aggregate_file['content_description']
        assert isinstance(self.format, str), type(str)
        assert self.format
        return self
Exemplo n.º 6
0
class CountCaseFormsWithXmlns(JsonObject):
    type = TypeProperty('count_case_forms_with_xmlns')
    xmlns = StringProperty(required=True)
    case_id_expression = DefaultProperty(required=True)

    def configure(self, case_id_expression):
        self._case_id_expression = case_id_expression

    def __call__(self, item, context=None):
        case_id = self._case_id_expression(item, context)

        if not case_id:
            return None

        assert context.root_doc['domain']
        return self._count_forms(case_id, context)

    def _count_forms(self, case_id, context):
        domain = context.root_doc['domain']

        cache_key = (self.__class__.__name__, case_id, self.xmlns)
        if context.get_cache_value(cache_key) is not None:
            return context.get_cache_value(cache_key)

        xforms = FormProcessorInterface(domain).get_case_forms(case_id)
        count = len([
            form for form in xforms
            if form.xmlns == self.xmlns and form.domain == domain
        ])
        context.set_cache_value(cache_key, count)
        return count
Exemplo n.º 7
0
    class SchedulerModuleInfo(JsonObject):
        # Set to True to enable setting the start date of any schedule instances
        # based on the visit scheduler info details below
        enabled = BooleanProperty(default=False)

        # The app that contains the visit scheduler form being referenced
        app_id = StringProperty()

        # The unique_id of the visit scheduler form in the above app
        form_unique_id = StringProperty()

        # The visit number from which to pull the start date for any schedule
        # instances; this should be the 0-based index in the FormSchedule.visits list
        visit_number = IntegerProperty()

        # VISIT_WINDOW_START - the start date used will be the first date in the window
        # VISIT_WINDOW_END - the start date used will be the last date in the window
        # VISIT_WINDOW_DUE_DATE - the start date used will be the due date of the visit
        window_position = StringProperty(choices=[
            VISIT_WINDOW_START, VISIT_WINDOW_END, VISIT_WINDOW_DUE_DATE
        ])
Exemplo n.º 8
0
class SummaryRepresentation(JsonObject):
    projectCount = IntegerProperty()
    specimenCount = IntegerProperty()
    speciesCount = IntegerProperty()
    fileCount = IntegerProperty()
    totalFileSize = FloatProperty()
    donorCount = IntegerProperty()
    labCount = IntegerProperty()
    totalCellCount = FloatProperty()
    organTypes = ListProperty(StringProperty(required=False))
    fileTypeSummaries = ListProperty(FileTypeSummary)
    cellCountSummaries = ListProperty(OrganCellCountSummary)
Exemplo n.º 9
0
class ConcatenateStrings(JsonObject):
    type = TypeProperty('concatenate_strings')
    expressions = ListProperty(required=True)
    separator = StringProperty(required=True)

    def configure(self, expressions):
        self._expression_fns = expressions

    def __call__(self, item, context=None):
        return self.separator.join([
            six.text_type(expression(item, context))
            for expression in self._expression_fns
            if expression(item, context)
        ])
Exemplo n.º 10
0
class ProcessInfo(JsonObject):
    host = StringProperty()  # not in the API
    name = StringProperty()
    group = StringProperty()
    start = IntegerProperty()
    stop = IntegerProperty()
    now = IntegerProperty()
    state = IntegerProperty()
    statename = StringProperty()
    spawnerr = StringProperty()
    exitstatus = IntegerProperty()
    stdout_logfile = StringProperty()
    stderr_logfile = StringProperty()
    pid = IntegerProperty()
Exemplo n.º 11
0
class FirstCaseFormWithXmlns(JsonObject):
    type = TypeProperty('first_case_form_with_xmlns')
    xmlns = StringProperty(required=True)
    case_id_expression = DefaultProperty(required=True)
    reverse = BooleanProperty(default=False)

    def configure(self, case_id_expression):
        self._case_id_expression = case_id_expression

    def __call__(self, item, context=None):
        case_id = self._case_id_expression(item, context)

        if not case_id:
            return None

        assert context.root_doc['domain']
        return self._get_forms(case_id, context)

    def _get_forms(self, case_id, context):
        domain = context.root_doc['domain']

        cache_key = (self.__class__.__name__, case_id, self.xmlns,
                     self.reverse)
        if context.get_cache_value(cache_key) is not None:
            return context.get_cache_value(cache_key)

        xforms = FormProcessorInterface(domain).get_case_forms(case_id)
        xforms = sorted([
            form for form in xforms
            if form.xmlns == self.xmlns and form.domain == domain
        ],
                        key=lambda x: x.received_on)
        if not xforms:
            form = None
        else:
            index = -1 if self.reverse else 0
            form = xforms[index].to_json()

        context.set_cache_value(cache_key, form)
        return form
Exemplo n.º 12
0
class FileTypeSummary(JsonObject):
    fileType = StringProperty()
    count = IntegerProperty()
    totalSize = IntegerProperty()

    @classmethod
    def for_bucket(cls, bucket: JSON) -> 'FileTypeSummary':
        self = cls()
        self.count = bucket['doc_count']
        self.totalSize = int(
            bucket['size_by_type']
            ['value'])  # Casting to integer since ES returns a double
        self.fileType = bucket['key']
        return self

    @classmethod
    def for_aggregate(cls, aggregate_file: JSON) -> 'FileTypeSummary':
        self = cls()
        self.count = aggregate_file['count']
        self.totalSize = aggregate_file['size']
        self.fileType = aggregate_file['file_format']
        assert isinstance(self.fileType, str)
        assert len(self.fileType)
        return self
Exemplo n.º 13
0
class Config(JsonObject):
    env_with_datadog_auth = StringProperty(required=True)
    catchall_alert_channel = StringProperty(required=True)
    env_notifications = DictProperty(required=True)
Exemplo n.º 14
0
class FacetObj(JsonObject):
    terms = ListProperty(AbstractTermObj)
    total = IntegerProperty()
    _type = StringProperty(name='type')
Exemplo n.º 15
0
class ValueAndUnitObj(JsonObject):
    value = StringProperty()
    unit = StringProperty()
Exemplo n.º 16
0
class TermObj(AbstractTermObj):
    term = StringProperty()
Exemplo n.º 17
0
def DataTypeProperty(**kwargs):
    """
    Shortcut for valid data types.
    """
    return StringProperty(choices=DATA_TYPE_CHOICES, **kwargs)