Loading Colors¶
If you have not reviewed the Getting Started page, please do so to understand the fundamentals of loading data.
The Color entity stores a representation of RGB or Hex Code values for a color. When creating a color, if red, green, and blue values are provided, the equivalent hexadecimal color code is generated. Else, the hexadecimal code must be provided to the hex property.
Required Config Properties¶
loadType:['COLOR']typePath: Must be set tocolor(via a conditional column, federated mapping, or CSV column)federatedIdnamehexand/orred,green,blue
hex and RGB Priority
If the Loader detects values for red, green, and blue columns, they will be used in the load and the hex value will be ignored. The system will auto-generate an equivalent hex code based on the RGB values. When both are present, a warning is recorded: "hex and rgb(red, green, blue) values detected. hex will be ignored and rgb values will be used."
typePath is required
Every color load requires typePath to be set to "color". The simplest way is with a conditional column:
{ "toProperty": "typePath", "default": "color" }
Hex Value Formatting¶
The Loader automatically strips the leading # from hex values. You can include or omit it in your CSV -- both #008000 and 008000 will work.
Load Example¶
CSV Data File¶
This example loads three colors. One with hex and RGB values, one with only hex values, and the other with only RGB.
- green: its RGB values will be used because they are complete.
- beige: its hex values will be used because its RGB values are incomplete or missing.
- black: its RGB values will be used because they are complete.
federatedId,name,Hex,R,G,B
green,Green,#008000,0,128,0
beige,Beige,#f5f5dc,4,,
black,Black,,0,0,0
| federatedId | name | Hex | R | G | B |
|---|---|---|---|---|---|
| green | Green | #008000 | 0 | 128 | 0 |
| beige | Beige | #f5f5dc | 4 | ||
| black | Black | 0 | 0 | 0 |
Config YAML / JSON¶
Please review the Creating a Loader Process to understand how to provide this Config example to the Loader.
loadType:
- COLOR
federatedMappings:
federatedId: "colorCode"
name: "colorName"
red: "R"
green: "G"
blue: "B"
hex: "Hex"
conditionalColumns:
- toProperty: typePath
default: color
{
"loadType": ["COLOR"],
"federatedMappings": {
"federatedId": "colorCode",
"name": "colorName",
"red": "R",
"green": "G",
"blue": "B",
"hex": "Hex"
},
"conditionalColumns": [
{
"toProperty": "typePath",
"default": "color"
}
]
}