Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • The superset of all the fields for a JSON structure needs to be known
  • The type definition id needs to be provided for each sub-element within the JSON structure
  • If the type definition id is not provided the type definition generator will behave the same way it currently does. For every provided JSON document the system might potentially generate a new type definition.
  • All clients need to know the registered definitions and id's in order to provide the correct id for any given structure within the JSON document

Type Registry Service

Types can be defined in the following manner:

  • Using the Java API to load type definition from an external file
  • Using GFSH to load the type definitions from an external file
    • Upon the server start up
    • At runtime whilst the cluster is already running

Types can only be registered after the servers have started and the current type registry has started and validated itself. This is because consistency is valued above the load time preferences.

Whilst the type definitions are being loaded from the file, the following process is followed:

  1. Read definition from the file.
  2. Check if definition already defined by checking if typeId already exist
  3. If typeId already exist, validate that the structure being loaded is the same as the already defined type
    1. If type definitions are different throw TypeDefinitionAlreadyDefinedException
    2. If type not defined confirm that all referenced subTypes exist within existing type registry or within the current type definition file. If all types are correctly defined and validated, then load type definition into the type registry.

Type Registry Service API

The type registry service has to provide the following services:

 

 

Proposed Type Definition Format

In the below section the type definition format is described. 

Code Block
languagetext
titleType Definition Spec
{
  "@type" : "JSON_Document" | Fully qualified className,  <-- The name of the object type being defined
  "@typeId" : ,  <-- A numberic field which would uniquely identify the type
  "fields":[   <-- A collection of fields
    {
      "fieldName" :  ,  <-- The name of the field
      "dataType" : "String" | "Integer" | "Double" | "Date" | Object (defdefault),  <-- The data type of the field (Not required when using @refTypeId)
      "@refTypeId" : ,  <-- The reference to an already defined type
      	  "format" : "MM/dd/yyyy hh:mm:ss:SSS " | "#0.00" <-- Optional field to provide a format when dealing with dates of doubles	
      "@refTypeId" : ,  <-- The reference to an already defined type
    },
    {
      "fieldName" :  ,  <-- The name of the field
      "dataType" : "List",  <-- Indicates data type is a list/array
      "@refTypeId" : ,  <-- Numeric reference to an already defined type, which will be populated in the list
    },
    {
      "fieldName": , <-- The name of the field
      "dataType": "List", <-- Indicates data type is a list/array
      "subType": "String" | "Integer" | "Double" | "Date" | Object (default) <-- The data type of the elements of a List
      "format": "MM/dd/yyyy hh:mm:ss:SSS " | "#0.00" <-- Optional field to provide a format when dealing with dates of doubles
    }
}

 

In the below example it shows how to define the type definition for a domain object.

 

Code Block
languagetext
titleExample Type Definitioncollapsetrue
[
  {
    "@type": "JSON_Document",
    "@typeId": 1,
    "fields": [
      {
        "fieldName": "firstName",
        "dataType": "String"
      },
      {
        "fieldName": "lastName",
        "dataType": "String"
      },
      {
        "fieldName": "age",
        "dataType": "Integer"
      },
      {
        "fieldName": "currentAddress",
        "@refTypeId": 2
      },
      {
        "fieldName": "previousAddresses",
        "dataType": "List",
        "@refTypeId": 2
      },
      {
        "fieldName": "luckyNumber",
        "dataType": "List"
      },
      {
        "fieldName": "dateOfBirth",
        "dataType": "Date",
        "format": "MM/dd/yyyy"
      },
      {
        "fieldName": "lastUpdated",
        "dataType": "Date",
        "format": "MM/dd/yyyy hh:mm:ss:SSS"
      }
    ]
  },
  {
    "@type": "JSON_Document",
    "@typeId": 2,
    "fields": [
      {
        "fieldName": "addressLine1",
        "dataType": "String"
      },
      {
        "fieldName": "addressLine2",
        "dataType": "String"
      },
      {
        "fieldName": "addressLine3",
        "dataType": "String"
      },
      {
        "fieldName": "state",
        "dataType": "String"
      },
      {
        "fieldName": "zipCode",
        "dataType": "String"
      },
      {
        "fieldName": "country",
        "dataType": "String"
      }
    ]
  }
]

...