diff --git a/pybis/src/python/pybis/attribute.py b/pybis/src/python/pybis/attribute.py index 6e1befcc4ee4d24168b4275da1687d98fef0b790..c9c5fc7d94a34899d3a121796793cc89d8d04707 100644 --- a/pybis/src/python/pybis/attribute.py +++ b/pybis/src/python/pybis/attribute.py @@ -61,9 +61,15 @@ class AttrHolder(): if isinstance(self.__dict__['_' + attr], dict): self.__dict__['_' + attr].pop('@id') - elif attr == 'vocabularyCode': + elif attr in ['vocabularyCode']: self.__dict__['_'+attr] = data.get('permId', {}).get(attr, None) + elif attr in ['validationPlugin']: + d = data.get(attr, None) + if d is not None: + d = d['permId'] + self.__dict__['_' + attr] = d + elif attr in ["space"]: d = data.get(attr, None) if d is not None: @@ -237,9 +243,10 @@ class AttrHolder(): "@type": "as.dto.common.update.IdListUpdateValue" } - elif attr in 'description label official ordinal'.split(): + elif attr in 'description label official ordinal autoGeneratedCode subcodeUnique listable showContainer showParents showParentMetadata disallowDeletion validationPlugin'.split(): # alway update common fields - up_obj[attr] = { + key = attr2ids.get(attr, attr) + up_obj[key] = { "value": self.__dict__['_'+attr], "isModified": True, "@type": "as.dto.common.update.FieldUpdateValue" @@ -268,13 +275,8 @@ class AttrHolder(): if value is None: pass elif isinstance(value, bool): - # for boolean values no type is needed + # for boolean values where no type is needed up_obj[attr] = value - #{ - # "value": value, - # "isModified": True, - # "@type": "as.dto.common.update.FieldUpdateValue" - #} elif isinstance(value, dict) and len(value) == 0: # value is {}: it means that we want this attribute to be # deleted, not updated. @@ -325,6 +327,7 @@ class AttrHolder(): if name in name_map: name = name_map[name] + int_name = '_' + name if int_name in self.__dict__: if int_name == '_attachments': @@ -471,6 +474,14 @@ class AttrHolder(): "@type": "as.dto.vocabulary.id.VocabularyPermId", "permId": value.upper() } + elif name in ["validationPlugin"]: + if value is None or value == '': + self.__dict__['_validationPlugin'] = None + else: + self.__dict__['_validationPlugin'] = { + "@type": "as.dto.plugin.id.PluginPermId", + "permId": value + } elif name in ["materialType"]: self.__dict__['_materialType'] = {