From b04d88934a67b16e62274eacb12e57732e7e3d27 Mon Sep 17 00:00:00 2001 From: vermeul <swen@ethz.ch> Date: Thu, 8 Aug 2019 13:50:25 +0200 Subject: [PATCH] added all sorts of entity types --- pybis/src/python/pybis/definitions.py | 98 +++++++++++++++++++++++++-- pybis/src/python/pybis/sample_type.py | 54 --------------- 2 files changed, 92 insertions(+), 60 deletions(-) delete mode 100644 pybis/src/python/pybis/sample_type.py diff --git a/pybis/src/python/pybis/definitions.py b/pybis/src/python/pybis/definitions.py index cabfa20ea61..baa0cf8f57c 100644 --- a/pybis/src/python/pybis/definitions.py +++ b/pybis/src/python/pybis/definitions.py @@ -54,10 +54,22 @@ def openbis_definitions(entity): "multi": "parents children components tags attachments".split(), }, "sampleType": { - "attrs_new": "code autoGeneratedCode generatedCodePrefix subcodeUnique description listable showContainer showParents showParentMetadata".split(), - "attrs_up": "autoGeneratedCode generatedCodePrefix subcodeUnique description listable showContainer showParents showParentMetadata".split(), - "attrs": "code autoGeneratedCode generatedCodePrefix subcodeUnique description listable showContainer showParents showParentMetadata".split(), - + "attrs_new": "code description autoGeneratedCode generatedCodePrefix subcodeUnique listable showContainer showParents showParentMetadata".split(), + "attrs_up": "description autoGeneratedCode generatedCodePrefix subcodeUnique listable showContainer showParents showParentMetadata".split(), + "attrs": "permId code description autoGeneratedCode generatedCodePrefix subcodeUnique listable showContainer showParents showParentMetadata modificationDate".split(), + "default_attribute_values": { + "autoGeneratedCode" : False, + "generatedCodePrefix" : "S", + "subcodeUnique" : False, + "description" : "", + "listable" : True, + "showContainer" : False, + "showParents" : True, + "showParentMetadata" : False + }, + "search": { + "@type": "as.dto.sample.search.SampleTypeSearchCriteria" + }, "create": { "@type": "as.dto.sample.create.SampleTypeCreation" }, @@ -67,11 +79,78 @@ def openbis_definitions(entity): "delete": { "@type": "as.dto.sample.delete.SampleTypeDeletionOptions" }, + "identifier": "typeId", + }, + "materialType": { + "attrs_new": "code description validationPluginId".split(), + "attrs_up": "description validationPluginId".split(), + "attrs": "permId code description validationPlugin".split(), + "search": { + "@type": "as.dto.material.search.MaterialTypeSearchCriteria" + }, + "fetch": { + "@type": "as.dto.material.fetchoptions.MaterialTypeFetchOptions" + }, + "create": { + "@type": "as.dto.material.create.MaterialTypeCreation" + }, + "update": { + "@type": "as.dto.material.update.MaterialTypeUpdate" + }, + "delete": { + "@type": "as.dto.material.delete.MaterialTypeDeletionOptions" + }, + "identifier": "typeId", + }, + "dataSetType": { + "attrs_new": "code description mainDataSetPattern mainDataSetPath disallowDeletion validationPluginId".split(), + "attrs_up": "description mainDataSetPattern mainDataSetPath disallowDeletion validationPluginId".split(), + "attrs": "permId code description mainDataSetPattern mainDataSetPath disallowDeletion modificationDate validationPlugin".split(), + "search": { + "@type": "as.dto.dataset.search.DataSetTypeSearchCriteria" + }, + "fetch": { + "@type": "as.dto.dataset.fetchoptions.DataSetTypeFetchOptions" + }, + "create": { + "@type": "as.dto.dataset.create.DataSetTypeCreation" + }, + "update": { + "@type": "as.dto.dataset.update.DataSetTypeUpdate" + }, + "delete": { + "@type": "as.dto.dataset.delete.DataSetTypeDeletionOptions" + }, + "identifier": "typeId", + }, + "experimentType": { + "attrs_new": "code description modificationDate validationPluginId".split(), + "attrs_up": "description modificationDate validationPluginId".split(), + "attrs": "permId code description modificationDate validationPlugin".split(), + "search": { + "@type": "as.dto.experiment.search.ExperimentTypeSearchCriteria" + }, + "fetch": { + "@type": "as.dto.experiment.fetchoptions.ExperimentTypeFetchOptions" + }, + "create": { + "@type": "as.dto.experiment.create.ExperimentTypeCreation" + }, + "update": { + "@type": "as.dto.experiment.create.ExperimentTypeUpdate" + }, + "delete": { + "@type": "as.dto.experiment.delete.ExperimentTypeDeletionOptions" + }, + "identifier": "typeId", }, "propertyType": { "attrs": "code label description managedInternally internalNameSpace dataType vocabulary materialType schema transformation semanticAnnotations registrator registrationDate".split(), "attrs_new": "code label description managedInternally internalNameSpace dataType vocabularyId materialTypeId schema transformation metaData".split(), "attrs_up": "label description schema transformation metaData".split(), + "search": { + "@type": "as.dto.property.search.PropertyTypeSearchCriteria" + }, "create": { "@type": "as.dto.property.create.PropertyTypeCreation" }, @@ -81,6 +160,11 @@ def openbis_definitions(entity): "delete": { "@type": "as.dto.property.delete.PropertyTypeDeletionOptions" }, + "dataType": [ + "INTEGER", "VARCHAR", "MULTILINE_VARCHAR", + "REAL", "TIMESTAMP", "BOOLEAN", "CONTROLLEDVOCABULARY", + "MATERIAL", "HYPERLINK", "XML" + ], "identifier": "typeId", }, "SemanticAnnotation": { @@ -200,6 +284,7 @@ def openbis_definitions(entity): "users": "userIds", "description": "description", "vocabulary": "vocabularyId", + "validationPlugin": "validationPluginId", }, "ids2type": { 'spaceId': {'permId': {'@type': 'as.dto.space.id.SpacePermId'}}, @@ -314,7 +399,7 @@ def get_fetchoption_for_entity(entity): return {} def get_type_for_entity(entity, action): - if action not in "create update delete fetch".split(): + if action not in "create update delete search".split(): raise ValueError('unknown action: {}'.format(action)) definition = openbis_definitions(entity) @@ -327,8 +412,9 @@ def get_type_for_entity(entity, action): "create": "Creation", "update": "Update", "delete": "DeletionOptions", - "fetch" : "FetchOptions" + "search": "SearchCriteria", } + return { "@type": "as.dto.{}.{}.{}{}" .format(entity.lower(), action, cap_entity, noun[action]) diff --git a/pybis/src/python/pybis/sample_type.py b/pybis/src/python/pybis/sample_type.py deleted file mode 100644 index b64b584700c..00000000000 --- a/pybis/src/python/pybis/sample_type.py +++ /dev/null @@ -1,54 +0,0 @@ -from .property_assignment import PropertyAssignments -from .semantic_annotation import SemanticAnnotation -from .attribute import AttrHolder -#from .entity_type import EntityType -from .openbis_object import OpenBisObject - -class SampleType( - OpenBisObject, - entity='sampleType', - single_item_method_name='get_sample_type' -): - """ Helper class for sample types, adding functionality. - """ - def __init_old__(self, openbis_obj, data=None, **kwargs): - - # call __init__ of EntityType parent class - super().__init__(openbis_obj, data) - - self.__dict__['a'] = AttrHolder(openbis_obj, 'SampleType') - if data is not None: - self._set_data(data) - - self.__dict__['openbis'] = openbis_obj - - defaults = { - "autoGeneratedCode" : False, - "generatedCodePrefix" : "S", - "subcodeUnique" : False, - "description" : "", - "listable" : True, - "showContainer" : False, - "showParents" : True, - "showParentMetadata" : False - } - - - def _set_data(self, data): - # assign the attribute data to self.a by calling it - # (invoking the AttrHolder.__call__ function) - self.a(data) - self.__dict__['data'] = data - - - def add_semantic_annotation(self, **kwargs): - semantic_annotation = SemanticAnnotation( - openbis_obj=self.openbis, isNew=True, - entityType=self.code, **kwargs - ) - semantic_annotation.save() - return semantic_annotation - - def get_semantic_annotations(self): - return self.openbis.search_semantic_annotations(entityType=self.code) - -- GitLab