Service - Stage Adjustment

From Izara Wiki
Jump to navigation Jump to search

Overview

Configuration of adjustments that are performed on a Unit when a StageStandard is applied to it. Adjustments affect unitTrackedProperty values for the Unit instance that is adjusted.

Repository

https://bitbucket.org/izara-supply-stages/izara-supply-stages-stage-adjustment

objectSchemas

{
	objectType: "stageAdjustment",
    belongTo: { // maybe in future when add RBAC to eg stages can make adjustments a child of Stage or StageStandard, like DeliveryMethod RateTable
		serviceTag: "iii",
		objectType: "jjj"
	},
	storageResources:{
		"xxx":{
			storageType: "graph",
			graphServerTag: "xx",
		}
	},
	fieldNames: {
		stageAdjustmentId: {
			type: "string",
            randomOnCreate: true
		},
		adjustmentType: { // "set"|"add"|"subtract"|"ifEmpty"|..
			type: "string",
			requiredOnCreate: true,
			validation: {
			  itemValidation:{} // restrict to acceptable list? "set"|"add"|"subtract"|"ifEmpty"|..
			},
		},
		adjustmentValue: {
			type: "string", // so can adjust any type of property, will need cast type in logic
			requiredOnCreate: true,
		},
		userInput: { // If true, when setting Units to this stage will need to set the value for the adjustment, adjustmentValue is default. If false adjustmentValue is fixed
			type: "boolean" ,
			requiredOnCreate: true,
		},
	},
	identifiers: [
		{
			fieldName: "stageAdjustmentId"
		},
	]
},
  • configuration for stages that are available to apply to Units
{
	objectType: "unitAdjustment",
	storageResources:{
		"xxx":{
			storageType: "graph",
			graphServerTag: "xx",
		}
	},
	fieldNames: {
		unitAdjustmentId: {
			type: "string",
            randomOnCreate: true
		},
	},
	identifiers: [
		{
			fieldName: "unitAdjustmentId"
		},
	]
},
  • each time a stage is applied that changes any unitTrackedProperty for a Unit this node is created that links to the Unit node and the before and after unitTrackedPropertys

relationshipSchemas

[
  {
    "hasStageAdjustment": {
      storageResources:{
		"xxx":{
			storageType: "graph",
			graphServerTag: "xx",
		}
      },
      links: [
        {
          storageResourceTags: ["xxx"],
          canDelete: true,
          from: {
            objType: {
              serviceTag: "stageStandard",
              objectType: "stageStandard"
            },
            linkType: "many",
          },
          to: {
            objType: {
              serviceTag: "stageAdjustment",
              objectType: "stageAdjustment"
            },
            linkType: "many",
          }
        }
      ]
    }
  }
]
  • A stageStandard can have many stageAdjustments, and a stageAdjustment can be linked to from many stageStandards
[
  {
    "disabledStageAdjustment": {
      storageResources:{
		"xxx":{
			storageType: "graph",
			graphServerTag: "xx",
		}
      },
      links: [
        {
          storageResourceTags: ["xxx"],
          canDelete: true,
          from: {
            objType: {
              serviceTag: "stageStandard",
              objectType: "stageStandard"
            },
            linkType: "many",
          },
          to: {
            objType: {
              serviceTag: "stageAdjustment",
              objectType: "stageAdjustment"
            },
            linkType: "many",
          }
        }
      ]
    }
  }
]
  • If a stageAdjustement is removed from a stageStandard the hasStageAdjustment relationship is removed and a disabledStageAdjustment relationship is created (with a timestamp)
  • A disabledStageAdjustment cannot be re-enabled
  • When a stageAdjustment is changed, what actually happens is the old hasStageAdjustment relationship is removed/set to disabledStageAdjustment, and a new stageAdjustment is created with hasStageAdjustment relationship, similar to versionedData
[
  {
    "adjustsUnitTypeTrackedProperty": {
      storageResources:{
		"xxx":{
			storageType: "graph",
			graphServerTag: "xx",
		}
      },
      links: [
        {
          storageResourceTags: ["xxx"],
          from: {
            objType: {
              serviceTag: "stageAdjustment",
              objectType: "stageAdjustment"
            },
            linkType: "one",
          },
          to: {
            objType: {
              serviceTag: "unitType",
              objectType: "unitTypeTrackedProperty"
            },
            linkType: "many",
          }
        }
      ]
    }
  }
]
  • connects stageAdjustment configuration node to what unitTypeTrackedProperty it adjusts
[
  {
    "hasUnitAdjustment": {
      storageResources:{
		"xxx":{
			storageType: "graph",
			graphServerTag: "xx",
		}
      },
      links: [
        {
          storageResourceTags: ["xxx"],
          from: {
            objType: {
              serviceTag: "unitManager",
              objectType: "unit"
            },
            linkType: "one",
          },
          to: {
            objType: {
              serviceTag: "stageAdjustment",
              objectType: "unitAdjustment"
            },
            linkType: "many",
          }
        }
      ]
    }
  }
]
  • when adjustment is made, connects Unit to newly created unitAdjustment
[
  {
    "oldAdjustmentUnitTrackedProperty": {
      storageResources:{
		"xxx":{
			storageType: "graph",
			graphServerTag: "xx",
		}
      },
      links: [
        {
          storageResourceTags: ["xxx"],
          from: {
            objType: {
              serviceTag: "stageAdjustment",
              objectType: "unitAdjustment"
            },
            linkType: "one",
          },
          to: {
            objType: {
              serviceTag: "unitType",
              objectType: "unitTrackedProperty"
            },
            linkType: "many",
          }
        }
      ]
    }
  }
]
[
  {
    "newAdjustmentUnitTrackedProperty": {
      storageResources:{
		"xxx":{
			storageType: "graph",
			graphServerTag: "xx",
		}
      },
		fieldNames: {
			adjustmentType: {
				type: "string",
				requiredOnCreate: true,
			},
			adjustmentValue: {
				type: "string", // so can adjust any type of property, will need cast type in logic
				requiredOnCreate: true,
			},
			userInput: { // stores whether was user inputted
				type: "boolean" ,
				requiredOnCreate: true,
			},
		},         
      links: [
        {
          storageResourceTags: ["xxx"],
          from: {
            objType: {
              serviceTag: "stageAdjustment",
              objectType: "unitAdjustment"
            },
            linkType: "one",
          },
          to: {
            objType: {
              serviceTag: "unitType",
              objectType: "unitTrackedProperty"
            },
            linkType: "many",
          }
        }
      ]
    }
  }
]
  • when adjustment is made, connects unitAdjustment to old and new unitTrackedProperty

Working documents

Stage Adjustment