Skip to content

Add content-type endpoints for fetching template instances

Marcel Konrad requested to merge find-template-instance into master

Originally, we discussed template instances as a "list of statements". While developing the feature, it came apparent that this does not quite make sense:

  1. if there are no statements about the resource, then the list of statements is empty, resulting in no information about the resource itself for the client.
  2. if there are statements about the resource, the list of statements sent to the client would contain a lot of redundant information. For example, every statement contains the exact same resource representation for the subject. If a template property has a cardinality greater than one, it's also possible that the exact same predicate representation is present in multiple statements.

As a result, the template instance representation looks as follows (example):

{
  "root" : {
    "_class" : "resource",
    "classes" : [ "targetClass" ],
    "created_at" : "2023-10-06T11:28:14.613254+01:00",
    "created_by" : "00000000-0000-0000-0000-000000000000",
    "extraction_method" : "UNKNOWN",
    "featured" : false,
    "formatted_label" : null,
    "id" : "R54631",
    "label" : "Default Label",
    "observatory_id" : "00000000-0000-0000-0000-000000000000",
    "organization_id" : "00000000-0000-0000-0000-000000000000",
    "shared" : 0,
    "unlisted" : false,
    "verified" : false
  },
  "statements" : {
    "P24" : [ {
      "thing": {
        "_class" : "literal",
        "created_at" : "2023-10-03T14:31:17.365491+01:00",
        "created_by" : "679ad2bd-ceb3-4f26-80ec-b6eab7a5e8c1",
        "datatype" : "xsd:string",
        "id" : "L1",
        "label" : "Default Label"
      },
      "created_at" : "2023-10-03T14:31:17.365491+01:00",
      "created_by" : "679ad2bd-ceb3-4f26-80ec-b6eab7a5e8c1",
      "statements": {}
    } ],
    "P27" : [ {
      "thing": {
        "_class" : "resource",
        "classes" : [ "R28" ],
        "created_at" : "2023-10-06T11:28:14.613254+01:00",
        "created_by" : "00000000-0000-0000-0000-000000000000",
        "extraction_method" : "UNKNOWN",
        "featured" : false,
        "formatted_label" : null,
        "id" : "R1",
        "label" : "Default Label",
        "observatory_id" : "00000000-0000-0000-0000-000000000000",
        "organization_id" : "00000000-0000-0000-0000-000000000000",
        "shared" : 0,
        "unlisted" : false,
        "verified" : false
      },
      "created_at" : "2023-10-06T11:28:14.613254+01:00",
      "created_by" : "00000000-0000-0000-0000-000000000000",
      "statements": {}
    } ]
  }
}

However, it is debatable if this representation contains all required information. For example, the client does not receive any information about the predicates, besides the ids, and no metadata about the underlying statements. Also, the keys of the statements map are the predicates of the properties, which could be ambiguous if a predicate is allowed to be used in different properties of the same template (as discussed with @reddine, grouping by predicate id is the preferred method). Maybe @reddine and @YaserJaradeh could provide some feedback on this.

Edited by Marcel Konrad

Merge request reports