Skip to content

Recent Extensions

Phil Barber edited this page Nov 1, 2018 · 3 revisions

Data Sources Array

Data sources may now be specified as an array of either views or SPARQL queries. Note that the original method of specifying the view(s) is still valid.

Specification

The dataSources element should be at the top-level of a layer definition in the Service Descriptor. This should be used in place of the "schema", "view" and "joins" elements. It should be an array of dataSource objects describing each view or SPARQL query. Each dataSource object must include a "source" element with a value of either "view" or "sparql". Additionally, the first datasource should not contain a "joinOn" element, but each subsequent view/query must have a "joinOn" element.

Examples

- Single View

  "dataSources" : [
    {
      "source" : "view",
      "schema": "GDeltGKG",
      "view" : "Article"
    }
  ]

- Single SPARQL

  "dataSources" : [
    {
      "source" : "sparql",
      "query" : "select ?OBJECTID ?sparql_url ?DocId WHERE { ?OBJECTID <http://marklogic.com/objectid> ?sparql_url . ?OBJECTID <http://marklogic.com/uri> ?DocId }",
      "fields" : {
        "OBJECTID" : { "scalarType" : "long" },
        "sparql_url" : { "scalarType" : "string" },
        "DocId" : { "scalarType" : "string" }
      }
    }
  ]

- View + SPARQL

  "dataSources" : [
    {
      "source" : "view",
      "schema": "GDeltGKG",
      "view" : "Article"
    },
    {
      "source" : "sparql",
      "query" : "select ?OBJECT_ID ?sparql_url WHERE { ?OBJECT_ID <http://marklogic.com/objectid> ?sparql_url . }",
      "joinOn" : {
        "left" : "OBJECTID",
        "right" : "OBJECT_ID"
      },
      "fields" : {
        "OBJECT_ID" : { "scalarType" : "long" },
        "sparql_url" : { "scalarType" : "string" }
      }
    }
  ]

- SPARQL + View

  "dataSources" : [
    {
      "source" : "sparql",
      "query" : "select ?OBJECT_ID ?sparql_url ?DocId WHERE { ?OBJECT_ID <http://marklogic.com/objectid> ?sparql_url . ?OBJECT_ID <http://marklogic.com/uri> ?DocId }",
      "fields" : {
        "OBJECT_ID" : { "scalarType" : "long" },
        "sparql_url" : { "scalarType" : "string" },
        "DocId" : { "scalarType" : "string" }
      }
    },
    {
      "source": "view",
      "schema": "GDeltGKG",
      "view": "Article",
      "fields": {
        "OBJECTID": {
          "scalarType": "string"
        },
        "url": {
          "scalarType": "string"
        }
      },
      "joinOn" : {
        "left" : "OBJECT_ID",
        "right" : "OBJECTID"
      }
    }
  ]

SPARQL Queries

SPARQL queries may be used as data sources.

Specification

  • If it is the main dataSource, it must be in the "dataSources" array element.
  • The value of the "source" element must be "sparql".
  • It must contain a "query" element for which the value is the SPARQL query.
  • It must contain a "fields" element containing elements for each field to be returned.

Example - With a joinOn.

    {
      "source" : "sparql",
      "query" : "select ?OBJECT_ID ?sparql_url WHERE { ?OBJECT_ID <http://marklogic.com/objectid> ?sparql_url . }",
      "joinOn" : {
        "left" : "url",
        "right" : "sparql_url"
      },
      "fields" : {
        "OBJECT_ID" : { "scalarType" : "string" },
        "sparql_url" : { "scalarType" : "string" }
      }
    }

Add Alias Fields

An alias may be included in field definitions. The alias will then be included in the field descriptors of the results.

Example - In this example, the "alias" value of the field descriptions returned with the results will be updated for each of the fields except "OBJECTID".

      "fields": {
        "OBJECTID" : { "scalarType" : "string" },
        "urlpubtimedate" : {
          "scalarType" : "string",
          "alias": "pubtime"
        },
        "urlpubdate" : {
          "scalarType" : "string",
          "alias": "pubdate"
        },
        "name": {
          "scalarType": "string",
          "alias": "Location"
        },
        "url": {
          "scalarType": "string",
          "alias": "doc_url"
        }
      }

Example Result

    fields	
            0	
                    name	"OBJECTID"
                    type	"esriFieldTypeOID"
                    alias	"OBJECTID"
                    sqlType	"sqlTypeOther"
                    domain	null
                    defaultValue	null
                    length	8
            1	
                    name	"urlpubtimedate"
                    type	"esriFieldTypeDate"
                    alias	"pubtime"
                    sqlType	"sqlTypeOther"
                    domain	null
                    defaultValue	null
                    length	36

Included Fields

A subset of fields (per view) may be specified to limit the fields in the result set. If this element is included, only the fields listed in the array will be included in the results. If this element is not included, all fields will be included.

Example - In this example, the results will only include the "OBJECTID", "urlpubtimedate" fields from the "Article" view (other views/queries are unaffected).

    {
      "source": "view",
      "schema": "GDeltGKG",
      "view": "Article",
      "fields": {
        "OBJECTID" : { "scalarType" : "string" },
        "urlpubtimedate" : {
          "scalarType" : "string",
          "alias": "pubtime"
        },
        "urlpubdate" : {
          "scalarType" : "string",
          "alias": "pubdate"
        },
        "name": {
          "scalarType": "string",
          "alias": "Location"
        },
        "url": {
          "scalarType": "string",
          "alias": "doc_url"
        }
      },
      "includeFields": ["OBJECTID", "urlpubtimedate"]
    }

Role-Based Access Control

Default roles and users are created during configuration. These roles can grant the right to read the Service Descriptors and therefore to use the service and/or the right to update the Service Descriptors. It also makes the default collection for Service Descriptors ("http://marklogic.com/feature-services") a protected collection. Please see the page on Security for more information.

Protected Collection

Roles

  • esri-connector-reader - May read Service Descriptors and execute the service.
  • esri-connector-writer - May create and update Service Descriptors.

Currently Unused Roles - These are not currently used, but available for convenience and future use.

  • esri-connector-nobody
  • esri-connector-admin
  • esri-connector-internal

Users

  • esri-connector-reader - A default user with the "esri-connector-reader" role.
  • esri-connector-writer - A default user with the "esri-connector-writer" role.
  • esri-connector-admin - A default user with the "esri-connector-writer" role. Currently unused.

Basic Authentication Passthrough Switch

When Basic Authentication is used to send user credentials to the NodeJS service, that information may be forwarded to the MarkLogic application server by setting the "koopMlAuthenticationForwarding" property to true in your gradle-[env].properties file.

Example

    koopMlAuthenticationForwarding=true

MarkLogic Authentication Type Switch

By The type of authorization used to connect to MarkLogic may be specified with the "koopMlAuthenticationType" property in your gradle-[env].properties file.

Nota Bene

The gradle tasks are currently configured to use Digest authentication when connecting to MarkLogic. If you change the authentication of the MarkLogic application server, you will need to update your gradle files. For example, mlRestAuthentication=basic

Examples

    koopMlAuthenticationType=basic