Shares

Share is a temporary metadata object that persists the state of the application when using the Share function.

How Share MD objects differ from other MD object types

  • Share MD object is a temporary object which is valid only until any change in correspondent metadata hierarchy is made and after that is invalidated and deleted. For more details refer to Shares invalidation section of this article.

  • Share MD objects can be considered internal i.e. these MD objects themselves are not exposed to a user in any way and are only used internally for computing shared versions of MD objects such as view, dashboards, etc

  • Share MD objects cannot be created, retrieved, modified or deleted using REST API for standard CRUD operations

  • Share MD objects cannot be dumped from a project using CleverMaps Shell

Life cycle of Share metadata objects

Creating shares

This function is available by clicking the Menu button () in the top left of the map window, and selecting Share. The state of the application (including all dashboard settings, filters, map position, visualizations and much more) is persisted and a link is generated. After clicking this link, anyone with access to the project will be able to recover the saved application state and see the exact view as the creator of the share link. The link looks like this:

1 https://secure.clevermaps.io/#/yufqzxkbiecj7jot/map/catchment_area_view?shareId=exb9g8wi9606ziyk

It's a link to a specific view in a specific CleverMaps project, followed by the ?shareId={shareId} parameter, which contains the ID of the share - exb9g8wi9606ziyk.

Each share link can reference multiple Share MD objects with the same shareId. Each of these Share MD objects represents persisted state of a single MD object of one of these MD object types:

NOTES:

  • There can be more than one indicator and more than one indicator drill. Or there can be no indicator or no dashboard. This depends on the settings of your dashboard

  • View MD object is the main MD object from which all subordinate MD objects (which are subjects to sharing) are referenced by (directly or associatively, refer to this article for details of MD objects hierarchy). This relation is used for determining whether share link is still valid; if a Share MD object exists for the view then the share link is valid, otherwise the share link is not valid. Following are the rules for creating and using share links which are the result of this design:

    • When creating a new share link

      • Share MD object must always be created for a View even though there would be no difference between original and shared view

      • Share MD object does not have to be created for MD object types other than View if there would be no difference between original and shared MD object

    • When opening a share link

      • in case of View

        • when Share MD object exists for a View then shared version of given view is returned from REST API

        • when Share MD object does not exist for a View then an error (404) is returned from REST API

      • in case of MD object types other than View

        • when Share MD object exists for MD object then shared version of given MD object is returned from REST API

        • when Share MD object does not exist for MD object then given MD object without any modifications is returned from REST API

Shares invalidation

A state of the application persisted using a share link is defined by configuration of View MD object and all subordinate MD objects referenced by it (directly or associatively) except for MD objects of types Dataset and Export, namely:

(Refer to this article for details of MD objects hierarchy.)

That being said a share link must be invalidated and all relevant Share MD objects must be deleted in case of any change (update or delete) of any MD object in the View hierarchy which is of one of MD object types listed above. This happens automatically in MD service when request for updating of deleting for such MD object is made.

Shares REST API

Share MD objects are stored in MD service but cannot be created, retrieved, updated nor deleted directly via REST API. Creating of Share MD objects is done using endpoints for updating individual MD object types while providing shareId request parameter. Getting of shared versions for MD objects is done using endpoints for getting individual MD object types while providing shareId request parameter.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 ### Create a Share [PUT /rest/projects/{projectId}/md/{mdObjectType}/{mdObjectId}?shareId={shareId}] Creates a new Share MD object for given MD object which represents its state in the moment of creation of the Share MD object. #### Response statuses * 200 - OK * 403 - Forbidden * 404 - Not Found + Parameters + projectId: `vb2b3d8v91jao331` (string) - ID of an actual project + mdObjectType: `view` (string) - Type of MD object to create share for + mdObjectId: `o31q6691gdtj3vng` - ID of MD object to create share for + shareId: `m1nfjgsglwlcxvlf` - ID of Share MD object to be created + Request + Headers Accept: application/json Authorization: Bearer {{accessToken}} + Body { "id": "td9uijp62o8sa27b", "name": "catchment_area_view", "type": "view", "title": "Catchment Area Analysis", "description": "Identify areas with the biggest and smallest shares of your customers. Find out what turnover these customers generate. Evaluate store rankings and identify the pick-up partners used by customers from different regions. You can also compare the catchment areas for two different stores.", "content": { "icon": "performance_method", "order": 1, "dashboard": "/rest/projects/qkn86k5upo4m9b27/md/dashboards?name=catchment_area_dashboard", "markerSelector": "/rest/projects/qkn86k5upo4m9b27/md/markerSelectors?name=shops_marker_selector", "defaultGranularity": "/rest/projects/qkn86k5upo4m9b27/md/datasets?name=ward", "defaultVisualization": "areas", "defaultCompareType": "dominance", "defaultSelected": { "dataset": "/rest/projects/$projectId/md/datasets?name=shops", "ids": [ 6 ] }, "filterGroup": [ { "type": "globalDate", "property": "baskets.date_iso", "defaultValues": { "startDate": { "value": "2019-02-03" }, "endDate": { "value": "2019-02-09" } } }, { "type": "histogram", "property": "baskets.amount", "format": { "type": "number", "fraction": 0, "symbol": "£" }, "defaultValues": { "values": [ 100.0, 500.0 ], "nullFiltered": true } }, { "type": "multiSelect", "property": "baskets.on_off_name", "orderBy": [ { "property": "baskets.on_off_name", "direction": "asc" } ] }, { "type": "multiSelect", "property": "baskets.courier", "orderBy": [ { "property": "baskets.courier", "direction": "asc" } ] }, { "type": "multiSelect", "property": "clients.sex_name", "orderBy": [ { "property": "clients.sex_name", "direction": "asc" } ] }, { "type": "multiSelect", "property": "clients.age_name", "orderBy": [ { "property": "clients.age_cat", "direction": "asc" } ] }, { "type": "multiSelect", "property": "dim_dates_day_of_week.day_of_week_name_en", "orderBy": [ { "property": "dim_dates_day_of_week.order_en", "direction": "asc" } ] }, { "type": "indicator", "indicator": "/rest/projects/qkn86k5upo4m9b27/md/indicators?name=turnover_indicator" }, { "type": "indicator", "indicator": "/rest/projects/qkn86k5upo4m9b27/md/indicators?name=customers_indicator" }, { "type": "indicator", "indicator": "/rest/projects/qkn86k5upo4m9b27/md/indicators?name=purchases_customer_indicator" } ], "mapOptions": { "center": { "lat": 52.42325659892287, "lng": -1.9569396972656254 }, "zoom": 12, "minZoom": 0, "maxZoom": 18, "tileLayer": "mapbox" }, "exports": [ { "export": "/rest/projects/qkn86k5upo4m9b27/md/exports?name=administrative_units_export" }, { "export": "/rest/projects/qkn86k5upo4m9b27/md/exports?name=customer_ids_export" }, { "export": "/rest/projects/qkn86k5upo4m9b27/md/exports?name=transaction_ids_export" }, { "export": "/rest/projects/qkn86k5upo4m9b27/md/exports?name=grid_export" } ], "excludeDatasets": [ "gb2_district", "gb2_ward", "gb2_postcodes_dwh", "gb2_msoas_dwh", "gb2_lsoas_dwh", "postcodes_dwh" ], "spatialQuery": { "profile": "air", "unit": "distance", "amount": 500 }, "measure": { "type": "isoline" } }, "accessInfo": { "createdAt": "2019-03-21T11:37:55Z", "modifiedAt": "2020-04-27T12:00:43Z", "createdBy": "/rest/accounts/00ufp0zalagOjXrmb0h7", "modifiedBy": "/rest/accounts/00ufp0zalagOjXrmb0h7" }, "version": 13, "links": [ { "rel": "self", "href": "/rest/projects/qkn86k5upo4m9b27/md/views/td9uijp62o8sa27b" } ] } + Response 200 (application/json) { "id": "m1nfjgsglwlcxvlf", "name": "catchment_area_view_m1nfjgsglwlcxvlf", "type": "share", "content": { "shareId": "m1nfjgsglwlcxvlf", "objectId": "o31q6691gdtj3vng", "objectName": "catchment_area_view", "diff": [ { "op": "add", "path": "/content/filterGroup/1/defaultValues", "value": { "values": [ 100, 500 ], "nullFiltered": true } }, { "op": "replace", "path": "/content/mapOptions/center/lat", "value": 52.42325659892287 }, { "op": "replace", "path": "/content/mapOptions/center/lng", "value": -1.9569396972656254 }, { "op": "replace", "path": "/content/mapOptions/zoom", "value": 12 }, { "op": "add", "path": "/content/defaultVisualization", "value": "areas" }, { "op": "add", "path": "/content/defaultCompareType", "value": "dominance" }, { "op": "add", "path": "/content/spatialQuery", "value": { "profile": "air", "unit": "distance", "amount": 500 } }, { "op": "add", "path": "/content/measure", "value": { "type": "isoline" } }, { "op": "add", "path": "/content/defaultSelected", "value": { "dataset": "/rest/projects/$projectId/md/datasets?name=shops", "ids": [ "6" ] } } ] } } ### Get shared version for MD object [GET /rest/projects/{projectId}/md/{mdObjectType}/{mdObjectId}?shareId={shareId}] Computes and returns share version for given MD object by share ID. #### Response statuses * 200 - OK * 404 - Not Found + Parameters + projectId: `vb2b3d8v91jao331` (string) - ID of an actual project + mdObjectType: `view` (string) - Type of MD object to compute and get shared version for + mdObjectId: `o31q6691gdtj3vng` - ID of MD object to compute and get shared version for + shareId: `m1nfjgsglwlcxvlf` - ID of Share MD object use for computing shared version for MD object + Request + Headers Accept: application/json Authorization: Bearer {{accessToken}} + Response 200 (application/json) { "id": "m1nfjgsglwlcxvlf", "name": "catchment_area_view_m1nfjgsglwlcxvlf", "type": "share", "content": { "shareId": "m1nfjgsglwlcxvlf", "objectId": "o31q6691gdtj3vng", "objectName": "catchment_area_view", "diff": [ { "op": "add", "path": "/content/filterGroup/1/defaultValues", "value": { "values": [ 100, 500 ], "nullFiltered": true } }, { "op": "replace", "path": "/content/mapOptions/center/lat", "value": 52.42325659892287 }, { "op": "replace", "path": "/content/mapOptions/center/lng", "value": -1.9569396972656254 }, { "op": "replace", "path": "/content/mapOptions/zoom", "value": 12 }, { "op": "add", "path": "/content/defaultVisualization", "value": "areas" }, { "op": "add", "path": "/content/defaultCompareType", "value": "dominance" }, { "op": "add", "path": "/content/spatialQuery", "value": { "profile": "air", "unit": "distance", "amount": 500 } }, { "op": "add", "path": "/content/measure", "value": { "type": "isoline" } }, { "op": "add", "path": "/content/defaultSelected", "value": { "dataset": "/rest/projects/$projectId/md/datasets?name=shops", "ids": [ "6" ] } } ] } }

Syntax

NOTE: As the first section of this article states Share MD objects are internal MD objects and thus are not exposed to a user in any way. That being said following syntax examples serves only as an illustration of how these MD objects look when being created or used by MD service.

This is a share object applied on catchment_area_view view of the Retail Solution Demo. The diff array contains these changes:

  1. it adds default values of (histogram) filter at index 1 to 100 and 500

  2. it sets the map window center to 52.42325659892287,-1.9569396972656254 and zoom to level 12

  3. it adds the default visualization setting - areas

  4. it adds the default compare type setting - dominance

  5. it sets default spatial query settings

  6. it adds default measure type - isoline

  7. it sets the defaultSelected property to the feature with id "6" from dataset shops

All these properties and paths are described in detail in the Views article.

Share object syntax
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 { "id": "m1nfjgsglwlcxvlf", "name": "catchment_area_view_m1nfjgsglwlcxvlf", "type": "share", "content": { "shareId": "m1nfjgsglwlcxvlf", "objectId": "o31q6691gdtj3vng", "objectName": "catchment_area_view", "diff": [ { "op": "add", "path": "/content/filterGroup/1/defaultValues", "value": { "values": [ 100, 500 ], "nullFiltered": true } }, { "op": "replace", "path": "/content/mapOptions/center/lat", "value": 52.42325659892287 }, { "op": "replace", "path": "/content/mapOptions/center/lng", "value": -1.9569396972656254 }, { "op": "replace", "path": "/content/mapOptions/zoom", "value": 12 }, { "op": "add", "path": "/content/defaultVisualization", "value": "areas" }, { "op": "add", "path": "/content/defaultCompareType", "value": "dominance" }, { "op": "add", "path": "/content/spatialQuery", "value": { "profile": "air", "unit": "distance", "amount": 500 } }, { "op": "add", "path": "/content/measure", "value": { "type": "isoline" } }, { "op": "add", "path": "/content/defaultSelected", "value": { "dataset": "/rest/projects/$projectId/md/datasets?name=shops", "ids": [ "6" ] } } ] } }

Additional syntax examples

Example of a share object on indicator drill
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 { "id": "exb9g8wi9606ziyk", "name": "turnover_indicator_drill_on_exb9g8wi9606ziyk", "type": "share", "content": { "shareId": "exb9g8wi9606ziyk", "objectId": "iir539klh29s9mvo", "objectName": "turnover_indicator_drill_on", "diff": [ { "op": "add", "path": "/content/blocks/3/visualized", "value": false }, { "op": "add", "path": "/content/blocks/3/displayValues", "value": [ "Offline" ] }, { "op": "add", "path": "/content/blocks/4/visualized", "value": false }, { "op": "add", "path": "/content/blocks/5/visualized", "value": false }, { "op": "add", "path": "/content/blocks/6/visualized", "value": false } ] } }

This share object is applied on indicator drill. You can see it contains explicit disabled visalization of drill blocks. But mainly, for block 3 (categories) there is an displayValues setting which means we selected "Offline" category from the block.

Example of a share object on marker selector
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 { "id": "exb9g8wi9606ziyk", "name": "shops_marker_selector_exb9g8wi9606ziyk", "type": "share", "content": { "shareId": "exb9g8wi9606ziyk", "objectId": "nl3porml3fmg4o0a", "objectName": "shops_marker_selector", "diff": [ { "op": "add", "path": "/content/keepFiltered", "value": { "granularity": false, "markers": true } }, { "op": "add", "path": "/content/showIndicatorValuesOnMap", "value": false }, { "op": "add", "path": "/content/clusterMarkers", "value": false } ] } }

This share object is applied on marker selector. You can see it contains three marker selector settings -  keepFilteredshowIndicatorValuesOnMap and clusterMarkers set to false.

Key description

content

Key

Type

Optionality

Description

Constraints

Key

Type

Optionality

Description

Constraints

shareId

string

required

id of the share (present in share link)

(a-z0-9)

objectId

string

optional

id of metadata object on which the share is applied

(a-z0-9)

objectName

string

required

name of metadata object on which the share is applied

(a-z0-9_-)

diff

array

required

list of changes applied on the metadata object



content.diff

Each diff array element follows the JSON Patch standard.

Key

Type

Optionality

Description

Constraints

Key

Type

Optionality

Description

Constraints

op

string

required

type of the operation

["add", "remove", "replace", "copy", "move"]

path

string

required

path in the json on which the operation is applied

(*)

value

string 

integer

number

boolean

optional

value applied to the path

value is polymorphic - it can be of any type available in the JSON standard



Visual representation

Shares themselves do not have a visual representation in the application. However, the Share function is available in Menu:

Then, a popup window with the generated link is shown: