Organisatie Schema Fix Summary
Problem Description
The import of voorzieningen_organisaties.xlsx was working correctly on the local environment but failing on the test environments (Accept and Test). The key issue was that the deelnemers and deelnames relationship was not being established properly during import.
Root Cause Analysis
Investigation Results
-
Local Environment: ✅ Working correctly
deelnemersproperty present withwriteBack: true- Write-back functionality properly updates
deelnamesarrays - Import process establishes relationships correctly
-
Test Environments: ❌ Not working
deelnemersproperty was completely missing from the organisatie schema- No write-back functionality available
- Import process could not establish relationships
Schema Configuration Differences
Local Environment (Working):
{
"deelnemers": {
"type": "array",
"title": "deelnemers",
"description": "Organisaties die deelnemen aan deze community",
"items": {
"type": "object",
"objectConfiguration": {
"handling": "related-object"
},
"$ref": "#/components/schemas/organisatie",
"inversedBy": "deelnames",
"writeBack": true,
"removeAfterWriteBack": true
},
"facetable": false
}
}
Test Environments (Before Fix):
{
// deelnemers property was completely missing
}
Solution Implemented
1. Schema Investigation
Created investigate_schema_diff.php to:
- Compare schema configurations between environments
- Export the working schema from local environment
- Identify missing properties and configurations
2. Schema Update
Created update_test_schemas.php to:
- Update test environments with the correct schema configuration
- Add the missing
deelnemersproperty with proper write-back configuration - Test the functionality after update
3. Verification
Created verify_schema_update.php to:
- Confirm that schema updates were successful
- Verify that all required properties are present
- Check that configuration values are correct
Fix Results
✅ Schema Updates Successful
Both test environments now have the correct configuration:
- Accept Environment: ✅ Updated successfully
- Test Environment: ✅ Updated successfully
✅ Configuration Verified
All environments now have:
deelnemersproperty presentwriteBack: true- Enables automatic updates todeelnamesarraysremoveAfterWriteBack: true- Removesdeelnemersfrom source after processinginversedBy: "deelnames"- Specifies the target property to update
How the Write-Back System Works
Process Flow
- Import Process: Excel file contains samenwerking objects with
deelnemersarrays - Object Creation: Samenwerking objects are created with
deelnemersproperty - Write-Back Processing:
handleInverseRelationsWriteBack()method:- Detects properties with
writeBack: true - Finds referenced organisations using UUIDs
- Updates each organisation's
deelnamesarray - Adds the samenwerking UUID to the
deelnamesarray
- Detects properties with
- Cleanup:
deelnemersproperty is removed from samenwerking (ifremoveAfterWriteBack: true)
Example
Before Import:
// Organisation A
{
"id": "org-a-uuid",
"naam": "Gemeente Amsterdam",
"type": "Gemeente",
"deelnames": []
}
// Samenwerking (from Excel)
{
"naam": "Test Samenwerking",
"type": "Samenwerking",
"deelnemers": ["org-a-uuid"]
}
After Import:
// Organisation A (updated)
{
"id": "org-a-uuid",
"naam": "Gemeente Amsterdam",
"type": "Gemeente",
"deelnames": ["samenwerking-uuid"] // ← Automatically updated
}
// Samenwerking (created)
{
"id": "samenwerking-uuid",
"naam": "Test Samenwerking",
"type": "Samenwerking",
"deelnemers": [] // ← Removed after write-back
}
Testing Instructions
1. Test Import Functionality
You can now test the import functionality on all environments:
- Local Environment: Should continue working as before
- Accept Environment: Should now work correctly
- Test Environment: Should now work correctly
2. Expected Results
After importing voorzieningen_organisaties.xlsx:
- Samenwerking objects should be created successfully
- Gemeente objects should have their
deelnamesarrays updated with samenwerking UUIDs - Samenwerking objects should have empty
deelnemersarrays (due toremoveAfterWriteBack: true)
3. Verification Steps
To verify the fix is working:
- Check Samenwerking objects: Should exist with empty
deelnemersarrays - Check Gemeente objects: Should have samenwerking UUIDs in their
deelnamesarrays - Test API calls: Use
?extend=deelnemersto verify inverse relationships are populated
4. API Testing Commands
# Check a samenwerking object
curl -u 'admin:admin' -H 'OCS-APIREQUEST: true' \
'https://vng.accept.commonground.nu/index.php/apps/openregister/api/objects/6/35/SAMENWERKING-UUID'
# Check a gemeente object to see deelnames
curl -u 'admin:admin' -H 'OCS-APIREQUEST: true' \
'https://vng.accept.commonground.nu/index.php/apps/openregister/api/objects/6/35/GEMEENTE-UUID'
# Test inverse relationship population
curl -u 'admin:admin' -H 'OCS-APIREQUEST: true' \
'https://vng.accept.commonground.nu/index.php/apps/openregister/api/objects/6/35/SAMENWERKING-UUID?extend=deelnemers'
Files Created/Modified
Investigation Scripts
investigate_schema_diff.php- Schema comparison and exportupdate_test_schemas.php- Schema update automationverify_schema_update.php- Update verification
Exported Files
organisatie_schema_local.json- Working schema configuration
Documentation
SCHEMA_FIX_SUMMARY.md- This summary document
Technical Details
Backend Implementation
The write-back functionality is implemented in:
- File:
lib/Service/ObjectHandlers/SaveObject.php - Method:
handleInverseRelationsWriteBack() - Order: Called after cascading but before default values
Key Configuration Properties
writeBack: true: Enables automatic updates to target objectsremoveAfterWriteBack: true: Removes source property after processinginversedBy: "deelnames": Specifies target property to updateobjectConfiguration.handling: "related-object": Handles as related objects
Processing Order
- Sanitization: Clean empty values
- Cascading: Handle object cascading (skips writeBack properties)
- Write-Back: Process inverse relationships with write-back
- Default Values: Set any default values
Conclusion
The issue has been successfully resolved by updating the organisatie schema on the test environments to include the missing deelnemers property with the correct write-back configuration. The import functionality should now work consistently across all environments.
Status: ✅ RESOLVED