|
| 1 | +# Metadata in Clowder |
| 2 | + |
| 3 | +In Clowder 2 we decide to continue supporting both user-defined and machine-defined metadata in a flexible |
| 4 | +representation based on JSON-LD. We enforce that, to register a new metadata, either the definition |
| 5 | +or a context URL that contains the schema of given vocabulary needs to be provided. Leveraging the |
| 6 | +React Component, we would like to explore dynamic rendering as well as the reusability of the metadata user interface. |
| 7 | +Our metadata definition are designed to facilitate that process. |
| 8 | + |
| 9 | + |
| 10 | +## Structure of Metadata Definition |
| 11 | +The structure of metadata definition looks like below: |
| 12 | +``` |
| 13 | +{ |
| 14 | + "name" : "Unit", |
| 15 | + "description" : "Unit", |
| 16 | + "context" : { |
| 17 | + "unit" : "https://schema.org/QuantitativeValue" |
| 18 | + }, |
| 19 | + "fields" : [ |
| 20 | + { |
| 21 | + "name" : "unit", |
| 22 | + "list" : false, |
| 23 | + "widgetType": "Select", |
| 24 | + "config": { |
| 25 | + "type" : "enum", |
| 26 | + "options": ["Ampere", "Kelvin", "Second"] |
| 27 | + }, |
| 28 | + "required" : true |
| 29 | + } |
| 30 | + ] |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +### Widget Type |
| 35 | +Each field corresponding to an individual widget on the frontend. `widgetType` is used to define its appearance at the |
| 36 | +user interface. Currently, we follow the name convention of [Material UI components](https://mui.com/components/) |
| 37 | +and we support dropdown(`Select`), input box (`TextField`), calendar (`DateTimePicker`). Here is an example of a Select |
| 38 | +widget: |
| 39 | + |
| 40 | + |
| 41 | +### Multiple Widgets |
| 42 | +A metadata entry could have multiple widgets (fields). For example: |
| 43 | +``` |
| 44 | +{ |
| 45 | + "name" : "LatLon", |
| 46 | + "description" : "A set of Latitude/Longitude coordinates", |
| 47 | + "context" : { |
| 48 | + "longitude" : "https://schema.org/longitude", |
| 49 | + "latitude" : "https://schema.org/latitude" |
| 50 | + }, |
| 51 | + "fields" : [ |
| 52 | + { |
| 53 | + "name" : "longitude", |
| 54 | + "list" : false, |
| 55 | + "widgetType": "TextField", |
| 56 | + "config": { |
| 57 | + "type" : "float" |
| 58 | + }, |
| 59 | + "required" : true |
| 60 | + }, |
| 61 | + { |
| 62 | + "name" : "latitude", |
| 63 | + "list" : false, |
| 64 | + "widgetType": "TextField", |
| 65 | + "config": { |
| 66 | + "type" : "float" |
| 67 | + }, |
| 68 | + "required" : true |
| 69 | + } |
| 70 | + ] |
| 71 | +} |
| 72 | +``` |
| 73 | +This corresponds to the Lat/Lon at the user interface:  |
| 74 | + |
| 75 | +### Configure widget |
| 76 | +The content of config field can be flexible. It will be used to hold information that populates the frontend |
| 77 | +appearances, as well as validate the posted values. For example: |
| 78 | +``` |
| 79 | + "config": { |
| 80 | + "type" : "enum", |
| 81 | + "options": ["Ampere", "Kelvin", "Second"] |
| 82 | + }, |
| 83 | +``` |
| 84 | + |
| 85 | +### List |
| 86 | +There will also be scenarios that a widget needs the input of "undetermined number of input values". For example, |
| 87 | +collecting as many data points on a map. The field `{"list": true}` is designed for that. For example: |
| 88 | +``` |
| 89 | +{ |
| 90 | + "name" : "Coordinates", |
| 91 | + "description" : "Any number ofof Latitude/Longitude coordinates", |
| 92 | + "context" : { |
| 93 | + "point": "https://schema.org/point" |
| 94 | + }, |
| 95 | + "fields" : [ |
| 96 | + { |
| 97 | + "name" : "point", |
| 98 | + "list" : true, |
| 99 | + "widgetType": "Map", |
| 100 | + "config": { |
| 101 | + "type" : "tuple" |
| 102 | + }, |
| 103 | + "required" : true |
| 104 | + } |
| 105 | + ] |
| 106 | +} |
| 107 | +``` |
| 108 | + |
| 109 | +The correspondent metadata entry could look like: |
| 110 | +``` |
| 111 | +{ |
| 112 | + ... |
| 113 | + "context" : null, |
| 114 | + "context_url" : null, |
| 115 | + "definition" : "Coordinates", |
| 116 | + "contents" : { |
| 117 | + "point" : [(111,112), (111, 113), (113, 114), (111, 115)] |
| 118 | + }, |
| 119 | + "resource" : { |
| 120 | + "collection" : "files", |
| 121 | + "resource_id" : ObjectId("62e16143e5f13ff2ff52f15d"), |
| 122 | + "version" : NumberInt(1) |
| 123 | + }, |
| 124 | + "agent" : { |
| 125 | + "id" : ObjectId("62e1614ce5f13ff2ff52f18a"), |
| 126 | + "creator" : { |
| 127 | + "id" : ObjectId("62a9ed5514cd9901fa1828cf"), |
| 128 | + |
| 129 | + "first_name" : "Chen", |
| 130 | + "last_name" : "Wang" |
| 131 | + }, |
| 132 | + "extractor" : null |
| 133 | + }, |
| 134 | + "created" : ISODate("2022-07-27T16:01:16.252+0000"), |
| 135 | + ... |
| 136 | +} |
| 137 | +``` |
0 commit comments