Documentation
fsds/bbu-location-attributes-import-plan.md
BBU Location Attributes Import Plan
Overview
First use of Prism attribute system - import BBU Run and Run Sequence for customer locations.
Source: engines/bbu/resources/lfsp_runs.csv
Matching: spatial.locations.erp_location = CSV facility_code
Key IDs
| Entity | ID |
|---|---|
| Location Category "Point of Use / Customer" | 019a4865-3eaf-7eb3-a5ae-71e072e483bf |
| Platform Type: Attribute Definition | 1010 |
| Platform Type: Attribute Assignment | 1012 |
| Platform Type: Attribute Value | 1011 |
Hierarchy Context
Collection 3 (Spatial) hierarchy by collection_level:
- Level 30: Location Category
- Level 40: Location (children of categories)
- Level 50: Address (children of locations)
Step 1: Create Attribute Definitions
Two definitions - bbu_run (text) and bbu_run_sequence (numeric):
-- Generate UUIDs
DO $$
DECLARE
run_def_id UUID := gen_random_uuid();
seq_def_id UUID := gen_random_uuid();
BEGIN
-- Passports
INSERT INTO prism.passports (global_id, platform_type_id) VALUES
(run_def_id, 1010), (seq_def_id, 1010);
-- Definitions
INSERT INTO prism.attribute_definitions
(id, platform_type_id, key_slug, kind, name, sort_order, "PassportGlobalId")
VALUES
(run_def_id, 1010, 'bbu_run', 'text', 'BBU Run', 1, run_def_id),
(seq_def_id, 1010, 'bbu_run_sequence', 'numeric', 'BBU Run Sequence', 2, seq_def_id);
RAISE NOTICE 'Created definitions: run=%, seq=%', run_def_id, seq_def_id;
END $$;
Step 2: Create Attribute Assignments
Scope to "Point of Use / Customer" category:
applies_to_self: false (category doesn't have run/sequence)applies_to_children: true (locations in this category can have these)allow_override: true (inheritance supported)required: false (not all customers are on runs)
DO $$
DECLARE
run_def_id UUID;
seq_def_id UUID;
run_assign_id UUID := gen_random_uuid();
seq_assign_id UUID := gen_random_uuid();
category_id UUID := '019a4865-3eaf-7eb3-a5ae-71e072e483bf';
BEGIN
SELECT id INTO run_def_id FROM prism.attribute_definitions WHERE key_slug = 'bbu_run';
SELECT id INTO seq_def_id FROM prism.attribute_definitions WHERE key_slug = 'bbu_run_sequence';
-- Passports
INSERT INTO prism.passports (global_id, platform_type_id) VALUES
(run_assign_id, 1012), (seq_assign_id, 1012);
-- Assignments
INSERT INTO prism.attribute_assignments
(id, attribute_definition_id, scope_global_id, applies_to_self, applies_to_children,
allow_override, required, sort_order, "PassportGlobalId")
VALUES
(run_assign_id, run_def_id, category_id, false, true, true, false, 1, run_assign_id),
(seq_assign_id, seq_def_id, category_id, false, true, true, false, 2, seq_assign_id);
END $$;
Step 3: Import Attribute Values via Python
Python script to:
- Parse CSV and deduplicate by facility_code
- Match locations via erp_location
- Generate SQL inserts for attribute_values
Implementation
Execute directly in chat via SQL and Python - no C# project needed.