Accelerate the Value of Data

Autogenerated IDs for simple and nested attributes

Learn about configuring reference attributes for auto-generated IDs.

To make attributes from a relation auto-generated, attributes from the appropriate relation type must be defined as auto-generated in the same way, as for simple and nested attributes of the entity. To make attributes from referenced entity auto-generated, attributes must be marked as auto-generated directly in the referenced type configuration.

Auto-generated IDs

Unique IDs for attributes can be generated automatically. The feature is available for simple and nested attributes. This section describes auto-generated IDs for simple and nested attributes.

Note: Changes to auto-generated IDs for reference attributes are not supported.

The following table describes how the Universal Unique Identifier (UUID) and sequential IDs are generated using the following properties:

Table 1. Properties
OptionApplies ToDescriptionDefault Value
autoGeneratedAttribute/SourceIf true, the value of the attribute/crosswalk is auto-generated. Use this to enable the feature.False
generateIfEmptyAttributeIf true, the value is generated only if a value is not sent in the request.
Note: You must send an empty string to generate a value. A null value is not considered an empty string and will not generate a value.
False
generateIfNotEmptyAttributeIf true, the value is generated even if a value is sent in the request.true
generatedValueUniqueForCrosswalkAttributeIf true and the object is already stored, the existing value by same crosswalk in the request is reused instead of generating a new one.False
generatorAttribute/sourceThe generator name.None
autoGenerationPatternSimple attribute/sourceTemplate for generating. The {value} is substituted by the generated value from the generator.None
autoGenerationNestedPatternNested attributeUsed to specify auto-generated patterns for simple sub-attributes.None
uniqueGeneratedValuePerEntityPerRequestEntityIf in the entity more than one auto-generated attribute/crosswalk are defined with the same generator and this property is set to true, only one value is generated for all those attributes per request.False
Note: To generate an ID for any attribute, its parent attribute must exist. If an attribute is at the first level of an entity/relation, it is always enabled for generation.

If you specify the value for any auto generated field in the above table as null, it is treated as not-empty. If you have specified the null value, but also want to auto-generate the value, ensure the generateIfNotEmpty field is true.

Simplified Algorithm of Generating Attributes

  1. Analyze generateIfEmpty and generateIfNotEmpty flags for a particular attribute.
  2. Compare the attribute state (exists or not) in the current request with the provided flags.
  3. Trigger the generation based on the flags and attribute state. If the generation is triggered, analyze the generatedValueUniqueForCrosswalk flag. If it is false, generate regardless of the stored object. When it's true, try to find the attribute in the saved object.
    1. If the found attribute belongs to the current crosswalk, the stored value of an attribute is reused.
    2. If attribute is not found or does not belong to the current crosswalk, a new value is generated.

Simple Attribute

For generating a simple attribute, the autoGenerationPattern property is required. If this property does not contain a {value}, it's considered as auto-generated with a fixed pattern (no generator is used for generating the value). The data type of a simple attribute must be consistent with the autoGenerationPattern property. For example, if the data type is Int, then autoGenerationPattern=idx_{value} is invalid because it produces a value that cannot be converted to Int.

Nested Attribute

For generating a nested attribute, the autoGenerationNestedPattern property is required.
"autoGenerationNestedPattern":{ 
                                "Type":"AUTO",
                                "ID":"{value}"
                               }

It generates the entire nested attribute with the sub-attributes, Type and ID.

Deepnested Attribute Structure Generation

You can generate a tree hierarchy attribute structure as follows:
{
  "attributes": [
    {
      "uri": "configuration/entityTypes/Object/attributes/Nested1",
      "name": "Nested1",
      "type": "Nested",
      "autoGenerated": true,
      "generateIfEmpty": true,
      "generateIfNotEmpty": true,
      "generator": "Seq_generator",
      "autoGenerationNestedPattern": {
        "ID1": "id1_{value}"
      },
      "attributes": [
        {
          "uri": "configuration/entityTypes/Object/attributes/Nested1/attributes/ID1",
          "name": "ID1",
          "type": "String"
        },
        {
          "uri": "configuration/entityTypes/Object/attributes/Nested1/attributes/Nested2",
          "name": "Nested2",
          "type": "Nested",
          "autoGenerated": true,
          "generateIfEmpty": true,
          "generateIfNotEmpty": true,
          "generator": "Seq_generator",
          "autoGenerationNestedPattern": {
            "ID2": "id2_{value}"
          },
          "attributes": [
            {
              "uri": "configuration/entityTypes/Object/attributes/Nested1/attributes/Nested2/attributes/ID2",
              "name": "ID2",
              "type": "String"
            }
          ]
        }
      ]
    }
  ]
}

Attribute at a Deeper Level of a Nest

If the simple or nested attribute is auto-generated and located inside some nested attribute, then:
  • All immediate parents of the auto-generated attribute are found in current request.
  • The auto-generated attribute is generated in each parent.
  • If the generatedValueUniqueForCrosswalk is true, it tries to find the parent in the stored object and reuse the value of its sub attribute only if the parent is at the current level.
Note: If the object has more than one crosswalk with dataProvider as true, only one value is generated for the auto-generated attribute. This value belongs to all the dataProvider crosswalks.

ID Generation Behavior for Attributes and Crosswalks

For Attributes

Note: If the object is sent with more than one crosswalk for which dataProvider=true, only one value is generated for the auto-generated attribute and this value belongs to all dataProvider crosswalks.

The behavior of the ID generation for attributes is as follows:

generatedValueUniqueForCrosswalk= True:,generateIfEmpty = True, and generateIfNotEmpty= True
Table 2. Behavior
Value was SentValue by Crosswalk ExistsReaction
YesYesReuse existing value.
NoGenerate new value and save it instead of the value that was sent.
NoYesReuse existing value.
NoGenerate new value.
generatedValueUniqueForCrosswalk= True:,generateIfEmpty = True, and generateIfNotEmpty= False
Table 3. Behavior
Value was SentValue by Crosswalk ExistsReaction
YesDoesn't matterNothing is generated - the value from the request is saved in the object.
NoYesReuse existing value.
NoGenerate new value
generatedValueUniqueForCrosswalk= True:,generateIfEmpty = False, and generateIfNotEmpty= True
Table 4. Behavior
Value was SentValue by Crosswalk ExistsReaction
YesYesReuse existing value.
NoGenerate new value and save it instead of the value that was sent.
NoDoesn't matterNothing is generated.
generatedValueUniqueForCrosswalk= True:,generateIfEmpty = False, and generateIfNotEmpty= False
Table 5. Behavior
Value was SentValue by Crosswalk ExistsReaction
Does not matterDoes not matterNothing is generated.
generatedValueUniqueForCrosswalk= False:,generateIfEmpty = True, and generateIfNotEmpty= True
Table 6. Behavior
Value was SentValue by Crosswalk ExistsReaction
YesDoes not matterGenerate new value and save it instead of the value that was sent.
NoGenerate a new value
generatedValueUniqueForCrosswalk= False:,generateIfEmpty = True, and generateIfNotEmpty= False
Table 7. Behavior
Value was SentValue by Crosswalk ExistsReaction
YesDoes not matterNothing is generated.
NoGenerate a new value
generatedValueUniqueForCrosswalk= False:,generateIfEmpty = False, and generateIfNotEmpty= True
Table 8. Behavior
Value was SentValue by Crosswalk ExistsReaction
YesDoes not matterGenerate new value and save it instead of the value that was sent.
NoNothing is generated.
generatedValueUniqueForCrosswalk= False:,generateIfEmpty = False, and generateIfNotEmpty= False
Table 9. Behavior
Value was SentValue by Crosswalk ExistsReaction
Does not matter Does not matterNothing is generated.

For Crosswalks

For crosswalks, the behavior depends on whether the value was sent or not.

Table 10. Behavior
Value was SentReaction
NoGenerate a new crosswalk value.
YesReuse the crosswalk value that was saved.
Note: If the send object does not exist, the value of the auto-generated crosswalk is generated. If the send object already exists, the value of the auto-generated crosswalk with the same source type is reused.

Creation of Auto-generated Simple Attributes

"attributes":[ 
            { 
               "uri":"configuration/entityTypes/Object/attributes/AutoGeneratedSimple",
               "name":"AutoGeneratedSimple",
               "label":"Auto-generated Simple",
               "type":"String",
               "autoGenerated":true,
               "generateIfEmpty":true,
               "generatedValueUniqueForCrosswalk":true,
               "generator":"UUID4_generator",
               "autoGenerationPattern":"Simple_{value}"
            },
...
]

Creation of Auto-generated Nested Attributes

"attributes":[ 
            { 
               "uri":"configuration/entityTypes/Object/attributes/AutoGeneratedNested",
               "name":"AutoGeneratedNested",
               "label":"Auto-generated Nested",
               "type":"Nested",
               "autoGenerated":true,
               "generateIfEmpty":true,
               "generatedValueUniqueForCrosswalk":true,
               "generator":"UUID4_generator",
               "autoGenerationNestedPattern":{ 
                  "Type":"AUTO",
                  "ID":"{value}"
               },
               "attributes":[ 
                  { 
                     "uri":"configuration/entityTypes/Object/attributes/AutoGeneratedForcedNested/attributes/Type",
                     "name":"Type",
                     "label":"Type",
                     "type":"String",
                     "description":""
                  },
                  { 
                     "uri":"configuration/entityTypes/Object/attributes/AutoGeneratedForcedNested/attributes/ID",
                     "name":"ID",
                     "label":"ID",
                     "type":"String",
                     "description":""
                  }
               ]
            },
        
...
]