Skip to content
Snippets Groups Projects
Commit c9c6f5e3 authored by Adam Laskowski's avatar Adam Laskowski
Browse files

SSDM-55: Fixed setting general object properties

parent 57836507
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
......@@ -71,28 +71,29 @@ class OpenBisObject:
# put the properties in the self.p namespace (without checking them)
if "properties" in data:
for key, value in data["properties"].items():
property_type = self.p._property_names[key.lower()]
data_type = property_type['dataType']
if "multiValue" in property_type:
if property_type['multiValue'] is True:
if type(value) is not list:
value = [value]
if data_type in (
"ARRAY_INTEGER", "ARRAY_REAL", "ARRAY_STRING", "ARRAY_TIMESTAMP"):
value = [self.formatter.to_array(data_type, x) for x in value]
if self.p.type:
property_type = self.p._property_names[key.lower()]
data_type = property_type['dataType']
if "multiValue" in property_type:
if property_type['multiValue'] is True:
if type(value) is not list:
value = [value]
if data_type in (
"ARRAY_INTEGER", "ARRAY_REAL", "ARRAY_STRING", "ARRAY_TIMESTAMP"):
value = [self.formatter.to_array(data_type, x) for x in value]
else:
value = self.formatter.to_array(data_type, value)
else:
value = self.formatter.to_array(data_type, value)
if type(value) is list and data_type not in (
"ARRAY_INTEGER", "ARRAY_REAL", "ARRAY_STRING", "ARRAY_TIMESTAMP"):
raise ValueError(
f'Property type {property_type} is not a multi-value property!')
if data_type in (
"ARRAY_INTEGER", "ARRAY_REAL", "ARRAY_STRING", "ARRAY_TIMESTAMP"):
value = self.formatter.to_array(data_type, value)
else:
if type(value) is list and data_type not in (
"ARRAY_INTEGER", "ARRAY_REAL", "ARRAY_STRING", "ARRAY_TIMESTAMP"):
raise ValueError(
f'Property type {property_type} is not a multi-value property!')
if data_type in (
"ARRAY_INTEGER", "ARRAY_REAL", "ARRAY_STRING", "ARRAY_TIMESTAMP"):
if data_type in ("ARRAY_INTEGER", "ARRAY_REAL", "ARRAY_STRING", "ARRAY_TIMESTAMP"):
value = self.formatter.to_array(data_type, value)
else:
if data_type in ("ARRAY_INTEGER", "ARRAY_REAL", "ARRAY_STRING", "ARRAY_TIMESTAMP"):
value = self.formatter.to_array(data_type, value)
self.p.__dict__[key.lower()] = value
# object is already saved to openBIS, so it is not new anymore
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment