NPM module - Izara Core - Property Node

From Izara Wiki
Jump to navigation Jump to search

Overview

Shared code for property nodes that have translations, eg:

  • properties of a Product Attribute
  • properties of a Sell Offer Term
  • properties of a Media object
  • properties of a Media Link

Repository

https://bitbucket.org/izara-core-libraries/izara-core-library-property-nodes/src/master/

Concepts

  • a Property only ever connects to one Subject, it is not shared across multiple Subjects, this is so each subject has it's own unique properties that can be updated independently from other Subjects
  • expect less filtering by property values
  • property filters need to filter the translation text to find multiple matching property results, unlike attribute tree nodes which can filter by attributeTagId to find all links
  • unlike attributes in an attribute tree properties are not tied strongly to their values and can change easily, properties are a loose method of making notes about something without the strong link
  • property Labels can be shared across many Properties for many Subjects
  • we could change this design in the future to have shared property nodes and a link node if optimizes queries

DataSchemaLib

Sets up standard schema for property node system

Nodes

{
	nodeLabel: "{subjectTag}PropertyLabel",
	schema: {
		identifier: true,
		restrictProperties: true,
		restrictRelationships: true,
		properties: {
			propertyLabelId: {
				identifier: true, // create unique id from request details
			},
		},
	}
}
{
	nodeLabel: "{subjectTag}Property",
	schema: {
		identifier: true,
		restrictProperties: true,
		restrictRelationships: true,
		properties: {
			propertyId: {
				identifier: true, // create unique id from request details
			},
			propertyLabelId: { // points to the identifier id of this properties propertyLabel node
				immutable: true,
			},
		},
	}
}

Relationships

{
	relationshipType: "has_{subjectTag}Property",
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
{
	relationshipType: "disabled_{subjectTag}Property",
	schema: {
		elementCanBeRemoved: true,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • links a parent node to a Property
{
	relationshipType: "is_{subjectTag}PropertyLabel",
	schema: {
		elementCanBeRemoved: false,
		allPropertiesImmutable: true,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • links one {subjectTag}Property to one {subjectTag}PropertyLabel
{
	relationshipType: "propertyIs_unitOfMeasure",
	schema: {
		elementCanBeRemoved: false,
		allPropertiesImmutable: false,
		restrictProperties: true,
		properties: {
			originTimestamp: //timestamp the request to create/change this relationship was sent
		},
	}
}
  • (probably not needed, use Service - Transform Units calculatedProperties if making changes during Supply Stages)
  • links a property value to a unit of measurement

BasicNodeSchemaLib

Creates the schema for basic nodes created by services in their initial setup

{
	nodeLabel: "{subjectTag}PropertyLabel",
	schema: {
		identifier: true,
		restrictProperties: true,
		restrictRelationships: true,
		properties: {
			propertyLabelId: {
				identifier: true,
			},
		},
	}
}
{
	nodeLabel: "{subjectTag}Property",
	schema: {
		identifier: true,
		restrictProperties: true,
		restrictRelationships: true,
		properties: {
			propertyId: {
				identifier: true, //(random uuid)
			},
		},
	}
}

Complex Filter requests

{
	filterType: "{subjectTag}Property",  //unique id is propertyId
	type: "group",
	elements: 
	[
		{
			// find all propertyIds that link to a specific propertyLabelId
			type: "logical",
			logicalTag: "propertyLabelId",
			comparison: "equals",
			value: "lksdflkfldfgldfkgjldfg"
		},
	]
}
{
	filterType: "{subjectTag}PropertyTranslation" //unique id is propertyId
	type: "group",
	elements: 
	[
		{
			// find all propertyIds that have current translation that matches text
			// see [[Service - Translations|Complex Filter requests]]
			type: "logical",
			logicalTag: "textTag_languageId_text",
			resultType: "sellOfferTermProperty",
			textTag: "sellOfferTermPropertyValue",
			languageId: "en",
			text: "Is a great term",
			subjectIdentifierPropertyName: "propertyId",
			caseSensitive: true
		},
	]
}
  • is sent directly to translation service that manages propertyNode translations

Working documents

Working_documents - NPM module - Izara Core - Property Node