コード例 #1
0
ファイル: copo_da.py プロジェクト: ISA-tools/COPO
    def get_schema(self):
        schema_base = DataSchemas("COPO").get_ui_template().get("copo")
        x = data_utils.json_to_object(schema_base.get(self.component, dict()))

        return dict(schema_dict=schema_base.get(self.component, dict()).get("fields", list()),
                    schema=x.fields
                    )
コード例 #2
0
    def get_schema(self):
        schema_base = DataSchemas("COPO").get_ui_template().get("copo")
        x = data_utils.json_to_object(schema_base.get(self.component, dict()))

        return dict(schema_dict=schema_base.get(self.component,
                                                dict()).get("fields", list()),
                    schema=x.fields)
コード例 #3
0
def get_copo_schema(component, as_object=False):
    """
    function retrieves a required UI schema from the DB.
    :param component: a key in the schema_dict to be retrieved
    :param as_object: True returns the schema as an object whose element can be accessed using the '.' notation. False
            for the traditional python dictionary access
    :return:
    """
    from dal.copo_base_da import DataSchemas
    schema_base = DataSchemas("COPO").get_ui_template().get("copo")

    schema_dict = dict(
        publication=schema_base.get("publication").get("fields", list()),
        person=schema_base.get("person").get("fields", list()),
        datafile=schema_base.get("datafile").get("fields", list()),
        sample=schema_base.get("sample").get("fields", list()),
        source=schema_base.get("source").get("fields", list()),
        ontology_annotation=schema_base.get("ontology_annotation").get(
            "fields", list()),
        comment=schema_base.get("comment").get("fields", list()),
        material_attribute_value=schema_base.get(
            "material_attribute_value").get("fields", list()),
        duration=schema_base.get("duration").get("fields", list()),
        miappe_rooting_greenhouse=schema_base.get('miappe').get('rooting').get(
            'greenhouse').get("fields", list()),
        miappe_rooting_field=schema_base.get('miappe').get('rooting').get(
            'field').get("fields", list()),
        hydroponics=schema_base.get('miappe').get('nutrients').get(
            'hydroponics').get('fields', list()),
        soil=schema_base.get('miappe').get('nutrients').get('soil').get(
            'fields', list()),
        phenotypic_variables=schema_base.get("miappe").get(
            "phenotypic_variables").get("fields", list()),
        environment_variables=schema_base.get("miappe").get(
            "environment_variables").get("fields", list()),
        metadata_template=schema_base.get("metadata_template").get(
            "fields", list()))

    schema = schema_dict.get(component, list())

    if schema and as_object:
        schema = json_to_object(dict(fields=schema)).fields

    return schema