Metadata
- class labstep.entities.metadata.model.Metadata(data, user)
Represents a single Metadata field attached to a Labstep Entity.
To see the attributes of the metsdata field run
print(my_metadata_field)
Specific attributes can be accessed via dot notation like so…
print(my_metadata_field.value) print(my_metadata_field.id)
- edit(fieldName=OPTIONAL, value=OPTIONAL, extraParams={})
Edit the value of an existing Metadata.
- Parameters:
fieldName (str) – The new name of the field.
value (str) – The new value of the Metadata.
- Returns:
An object representing the edited Metadata.
- Return type:
Example
metadata.edit(value='2.50')
- delete()
Delete an existing Metadata field.
Example
metadata.delete()
- getValue()
Returns the value of the metadata field.
- Return type:
Return type depends on the type of the metadata field
Example
metadataField = resource.getMetadata()[0] value = dataField.getValue()
- setValue(value)
Sets the value of the metadata field.
- Parameters:
value – The value to set, depends on the type of the metadata field.
- Return type:
Return type depends on the type of the metadata field
Example
metadataFields = experiment.getMetadata() textField = metadataFields.get('My text field') textField.setValue('Some String') numericField = metadataFields.get('My numeric field') numericField.setValue(56534) dateField = metadataFields.get('My date field') dateField.setValue('2021-10-28') singleOptionsField = metadataFields.get('My single options field') singleOptionsField.setValue('Option 1') multiOptionsField = metadataFields.get('My multi options field') multiOptionsField.setValue(['Option 1','Option 2']) fileField = metadataFields.get('My file field') file = user.newFile('/path/to/file') fileField.setValue(file)
- getNotificationAlert()
Retrieve the Notification Alert of a date type metadata field.
- Returns:
An object representing the notification alert of a metadata field of type Date or Date / Time.
- Return type:
notificationAlert
Example
- ::
resource_item = user.getResourceItem(17000) expiry_date = resource_item.getMetadata().get(‘Expiry Date’) notification_alert = expiry_date.getNotificationAlert()
- setNotificationAlert(message, minutes_before)
Set the Notification Alert of a date type metadata field.
- Returns:
An object representing the notification alert of a metadata field of type Date or Date / Time.
- Return type:
notificationAlert
Example
- ::
resource_item = user.getResourceItem(17000) expiry_date = resource_item.getMetadata().get(‘Expiry Date’) expiry_date.setNotificationAlert(message=’This item is expired’, minutes_before=0)