Oms API Read Run Microdata value Ids - openmpp/openmpp.github.io GitHub Wiki

Read a "page" of microdata values from model run.

Page is part of microdata values defined by zero-based "start" row number and row count. If row count <= 0 then all rows below start row number returned.

Enum-based microdata attributes returned as enum id, not enum codes.

Method verb must be POST and Content-Type header "application/json". JSON body POSTed to specify microdata name, page size, row count, filters and row order. It is expected to be JSON representation of db.ReadLayout structure from Go library.

Method:

POST /api/model/:model/run/:run/microdata/value-id

For example:

curl -v -X POST -H "Content-Type: application/json" http://localhost:4040/api/model/modelOne/run/Microdata%20in%20database/microdata/value-id -d @test.json
curl -v -X POST -H "Content-Type: application/json" http://localhost:4040/api/model/modelOne/run/2016_08_17_21_07_55_123/microdata/value-id -d @test.json

Arguments:

:model - (required) model digest or model name

Model can be identified by digest or by model name. It is recommended to use digest because it is uniquely identifies model. It is possible to use model name, which is more human readable than digest, but if there are multiple models with same name in database than result is undefined.

:run - (required) model run digest, run stamp or run name

Model run can be identified by run digest, run stamp or run name. It is recommended to use digest because it is uniquely identifies model run. Run stamp, if not explicitly specified as model run option, automatically generated as timestamp string, ex.: 2016_08_17_21_07_55_123. It is also possible to use name, which is more human readable than digest, but if there are multiple runs with same name in database than result is undefined.

JSON body arguments:

For example:

{
  "Name": "Person",
  "Offset": 8,
  "Size": 16,
  "IsFullPage": true,
  "FilterById": [{
      "Name": "AgeGroup",
      "Op": "IN",
      "EnumIds": [20, 40]
    }, {
      "Name": "Sex",
      "Op": "=",
      "EnumIds": [1]
    }
  ],
  "OrderBy": [{
      "IndexOne": 5
    }, {
      "IndexOne": 6,
      "IsDesc": true
    }
  ]
}
Name       - (required) microdata name
Offset     - (optional) zero-based start row to select microdata values
Size       - (optional) max row count to select microdata values, if size <= 0 then all rows selected
IsFullPage - (optional) if true then always return non-empty last page of data.
FilterById - (optional) conditions to filter  attribute values, if attribute is enum-based then filter by enum id(s).
OrderBy    - (optional) list of columns indexes (one based) to order by

Filter conditions joined by AND and can have following operations:

=       - value equal to:         Age = 20
!=      - value not equal to:     Age <> 20
>       - value greater than:     Age > 20
>=      - value greater or equal: Age >= 20
<       - value less than:        Age < 20
<=      - value less or equal:    Age <= 20
IN      - in the list of id's:    Age IN (20, 30, 40)
BETWEEN - between min and max:    Age BETWEEN 20 AND 40
IN_AUTO - automatically choose most suitable: = or != or IN or BETWEEN

Order by specified by one-based column(s) index(es) in result. In case of microdata columns are:

  SELECT entity_key, attr0, attr1, ..., value FROM microdataTable ORDER BY 1, 2,...

For enum-based attribute column always contain enum id's, not enum codes and therefore result ordered by id's

JSON response:

{
  Layout: {
    Offset:     actual first row number of the page data (zero-base),
    Size:       actual data page row count,
    IsLastPage: true if this is last page of data
  },
  Page: [....page of data...]
}

Example 1:

JSON body:

{
  "Name": "Other",
  "Offset": 8,
  "Size": 2
}

Result:

< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Fri, 13 Jan 2023 22:41:11 GMT
< Content-Length: 279
<
{
    "Page": [{
            "Key": 8,
            "Attr": [{
                    "IsNull": false,
                    "Value": 39
                }, {
                    "IsNull": false,
                    "Value": 30
                }, {
                    "IsNull": false,
                    "Value": 237539
                }
            ]
        }, {
            "Key": 9,
            "Attr": [{
                    "IsNull": false,
                    "Value": 30
                }, {
                    "IsNull": false,
                    "Value": 30
                }, {
                    "IsNull": false,
                    "Value": 245730
                }
            ]
        }
    ],
    "Layout": {
        "Offset": 8,
        "Size": 2,
        "IsFullPage":false,
        "IsLastPage": false
    }
}

Example 2:

JSON body:

{
  "Name": "Person",
  "Offset": 0,
  "Size": 3,
  "FilterById": [{
      "Name": "AgeGroup",
      "Op": "IN",
      "EnumIds": [20, 40]
    }, {
      "Name": "Sex",
      "Op": "=",
      "EnumIds": [1]
    }
  ],
  "OrderBy": [{
      "IndexOne": 5
    }, {
      "IndexOne": 6,
      "IsDesc": true
    }
  ]
}

Result:

< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Fri, 13 Jan 2023 22:52:12 GMT
< Content-Length: 943
<
{
    "Page": [{
            "Key": 844424930131977,
            "Attr": [{
                    "IsNull": false,
                    "Value": 83
                }, {
                    "IsNull": false,
                    "Value": 40
                }, {
                    "IsNull": false,
                    "Value": 1
                }, {
                    "IsNull": false,
                    "Value": 23000
                }, {
                    "IsNull": false,
                    "Value": 0
                }, {
                    "IsNull": false,
                    "Value": 100
                }, {
                    "IsNull": false,
                    "Value": 33
                }, {
                    "IsNull": false,
                    "Value": true
                }, {
                    "IsNull": false,
                    "Value": 23000
                }
            ]
        }, {
            "Key": 562949953421322,
            "Attr": [{
                    "IsNull": false,
                    "Value": 83
                }, {
                    "IsNull": false,
                    "Value": 40
                }, {
                    "IsNull": false,
                    "Value": 1
                }, {
                    "IsNull": false,
                    "Value": 23000
                }, {
                    "IsNull": false,
                    "Value": 0
                }, {
                    "IsNull": false,
                    "Value": 100
                }, {
                    "IsNull": false,
                    "Value": 33
                }, {
                    "IsNull": false,
                    "Value": true
                }, {
                    "IsNull": false,
                    "Value": 23000
                }
            ]
        }, {
            "Key": 281474976710667,
            "Attr": [{
                    "IsNull": false,
                    "Value": 83
                }, {
                    "IsNull": false,
                    "Value": 40
                }, {
                    "IsNull": false,
                    "Value": 1
                }, {
                    "IsNull": false,
                    "Value": 23000
                }, {
                    "IsNull": false,
                    "Value": 0
                }, {
                    "IsNull": false,
                    "Value": 100
                }, {
                    "IsNull": false,
                    "Value": 33
                }, {
                    "IsNull": false,
                    "Value": true
                }, {
                    "IsNull": false,
                    "Value": 23000
                }
            ]
        }
    ],
    "Layout": {
        "Offset": 0,
        "Size": 3,
        "IsFullPage":false,
        "IsLastPage": false
    }
}
⚠️ **GitHub.com Fallback** ⚠️