Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
272 changes: 173 additions & 99 deletions compare_archimate.php

Large diffs are not rendered by default.

65 changes: 42 additions & 23 deletions lib/Service/ArchiMateExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ private function addObjectDirectlyToXml(\SimpleXMLElement $folder, array $object
if ($sectionName === 'views') {
$this->addViewDataToXmlNode($objectNode, $xmlData);
} else {
$this->addCleanDataToXmlNode($objectNode, $xmlData);
// Pass section information to help with attribute handling
$this->addCleanDataToXmlNode($objectNode, $xmlData, $sectionName);
}
}
}
Expand Down Expand Up @@ -890,7 +891,7 @@ private function cleanObjectDataForXml(array $object): array
/**
* Add clean data to XML node with proper ArchiMate structure
*/
private function addCleanDataToXmlNode(\SimpleXMLElement $node, array $data): void
private function addCleanDataToXmlNode(\SimpleXMLElement $node, array $data, ?string $sectionName = null): void
{
// Extract attributes from various possible locations
$attributes = [];
Expand All @@ -905,8 +906,18 @@ private function addCleanDataToXmlNode(\SimpleXMLElement $node, array $data): vo
foreach ($data['_attributes'] as $attrKey => $attrValue) {
// Clean up attribute keys (remove colons, etc.)
$cleanKey = str_replace(':', '', $attrKey);
if ($cleanKey === 'type' && !isset($attributes['xsi:type'])) {
$attributes['xsi:type'] = (string)$attrValue;

// Check if this is a property definition to handle 'type' attribute correctly
$isPropertyDefinition = ($sectionName === 'property_definitions');

if ($cleanKey === 'type') {
if ($isPropertyDefinition) {
// For property definitions, 'type' should remain as 'type' attribute
$attributes['type'] = (string)$attrValue;
} else {
// For other elements, 'type' becomes 'xsi:type'
$attributes['xsi:type'] = (string)$attrValue;
}
} elseif (in_array($cleanKey, ['identifier', 'source', 'target', 'accessType'])) {
$attributes[$cleanKey] = (string)$attrValue;
}
Expand All @@ -916,30 +927,38 @@ private function addCleanDataToXmlNode(\SimpleXMLElement $node, array $data): vo
// 3. Look for xsi:type in various forms (including double underscore from import service)
foreach (['xsi:type', 'xsi_type', '_xsi:type', '_xsi__type', '_type'] as $typeKey) {
if (isset($data[$typeKey])) {
// For property definitions, _type should be 'type' attribute, not 'xsi:type'
// Detect property definitions by checking if we have a section field or if this is in property_definitions
$isPropertyDefinition = (isset($data['section']) && $data['section'] === 'property_definitions') ||
(isset($data['_section']) && $data['_section'] === 'property_definitions') ||
($typeKey === '_type' && !isset($attributes['xsi:type']));
// Check if this is a property definition to handle type attributes correctly
$isPropertyDefinition = ($sectionName === 'property_definitions');

if ($isPropertyDefinition && $typeKey === '_type' && !isset($attributes['type'])) {
if ($typeKey === '_type' && $isPropertyDefinition && !isset($attributes['type'])) {
// For property definitions, _type becomes 'type' attribute
$attributes['type'] = (string)$data[$typeKey];
break;
} elseif (!$isPropertyDefinition && !isset($attributes['xsi:type'])) {
$attributes['xsi:type'] = (string)$data[$typeKey];
break;
} elseif (in_array($typeKey, ['xsi:type', 'xsi_type', '_xsi:type', '_xsi__type']) && !isset($attributes['xsi:type'])) {
// For other elements, these become 'xsi:type' attribute
$attributes['xsi:type'] = (string)$data[$typeKey];
break;
}
}
}

// 4. Look for other attributes in various forms
foreach (['source', 'target', 'accessType', 'type'] as $attrName) {
if (isset($data[$attrName]) && !isset($attributes[$attrName])) {
// For 'type', only use if we don't have xsi:type
if ($attrName === 'type' && isset($attributes['xsi:type'])) {
continue;
// Check if this is a property definition to handle 'type' attribute correctly
$isPropertyDefinition = ($sectionName === 'property_definitions');

if ($attrName === 'type') {
if ($isPropertyDefinition) {
// For property definitions, 'type' should remain as 'type' attribute
$attributes['type'] = (string)$data[$attrName];
} elseif (!isset($attributes['xsi:type'])) {
// For other elements, 'type' becomes 'xsi:type' if not already set
$attributes['xsi:type'] = (string)$data[$attrName];
}
} else {
$attributes[$attrName] = (string)$data[$attrName];
}
$attributes[$attrName] = (string)$data[$attrName];
}
}

Expand Down Expand Up @@ -967,7 +986,7 @@ private function addCleanDataToXmlNode(\SimpleXMLElement $node, array $data): vo
// Handle xml:lang in various forms (including double underscore from import service)
foreach (['xml:lang', '_xml:lang', '_xml__lang', 'xml_lang'] as $langKey) {
if (isset($value[$langKey])) {
$nameNode->addAttribute('xml:lang', $value[$langKey]);
$nameNode->addAttribute('xml:lang', $value[$langKey], 'http://www.w3.org/XML/1998/namespace');
break;
}
}
Expand All @@ -979,7 +998,7 @@ private function addCleanDataToXmlNode(\SimpleXMLElement $node, array $data): vo
// Handle xml:lang in various forms (including double underscore from import service)
foreach (['xml:lang', '_xml:lang', '_xml__lang', 'xml_lang'] as $langKey) {
if (isset($value[$langKey])) {
$docNode->addAttribute('xml:lang', $value[$langKey]);
$docNode->addAttribute('xml:lang', $value[$langKey], 'http://www.w3.org/XML/1998/namespace');
break;
}
}
Expand All @@ -993,7 +1012,7 @@ private function addCleanDataToXmlNode(\SimpleXMLElement $node, array $data): vo
// Handle xml:lang in various forms (including double underscore from import service)
foreach (['xml:lang', '_xml:lang', '_xml__lang', 'xml_lang'] as $langKey) {
if (isset($value[$langKey])) {
$valueNode->addAttribute('xml:lang', $value[$langKey]);
$valueNode->addAttribute('xml:lang', $value[$langKey], 'http://www.w3.org/XML/1998/namespace');
break;
}
}
Expand Down Expand Up @@ -1069,7 +1088,7 @@ private function addPropertiesToXml(\SimpleXMLElement $node, array $properties):
// Add xml:lang if present in various forms (including double underscore from import service)
foreach (['xml:lang', '_xml:lang', '_xml__lang', 'xml_lang'] as $langKey) {
if (isset($property['value'][$langKey])) {
$valueNode->addAttribute('xml:lang', $property['value'][$langKey]);
$valueNode->addAttribute('xml:lang', $property['value'][$langKey], 'http://www.w3.org/XML/1998/namespace');
break;
}
}
Expand Down Expand Up @@ -1111,7 +1130,7 @@ private function addModelMetadataToXml(\SimpleXMLElement $xml, array $modelMetad
if (is_array($modelMetadata['name']) && isset($modelMetadata['name']['_value'])) {
$nameNode[0] = (string)$modelMetadata['name']['_value'];
if (isset($modelMetadata['name']['xml:lang'])) {
$nameNode->addAttribute('xml:lang', $modelMetadata['name']['xml:lang']);
$nameNode->addAttribute('xml:lang', $modelMetadata['name']['xml:lang'], 'http://www.w3.org/XML/1998/namespace');
}
} elseif (is_string($modelMetadata['name'])) {
$nameNode[0] = $modelMetadata['name'];
Expand All @@ -1124,7 +1143,7 @@ private function addModelMetadataToXml(\SimpleXMLElement $xml, array $modelMetad
if (is_array($modelMetadata['documentation']) && isset($modelMetadata['documentation']['_value'])) {
$docNode[0] = (string)$modelMetadata['documentation']['_value'];
if (isset($modelMetadata['documentation']['xml:lang'])) {
$docNode->addAttribute('xml:lang', $modelMetadata['documentation']['xml:lang']);
$docNode->addAttribute('xml:lang', $modelMetadata['documentation']['xml:lang'], 'http://www.w3.org/XML/1998/namespace');
}
} elseif (is_string($modelMetadata['documentation'])) {
$docNode[0] = $modelMetadata['documentation'];
Expand Down
45 changes: 29 additions & 16 deletions lib/Settings/softwarecatalogus_register.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@
"groups": null,
"authorization": null,
"deleted": null,
"configuration": null
"configuration": {
"objectNameField": "naam",
"objectDescriptionField": "beschrijving"
}
},
"voorziening": {
"uri": null,
Expand All @@ -156,7 +159,7 @@
"description": "Een generieke voorziening (software product)",
"version": "0.0.80",
"summary": "",
"icon": null,
"icon": "ApplicationCog",
"required": [
"naam"
],
Expand Down Expand Up @@ -1114,7 +1117,8 @@
},
"deleted": null,
"configuration": {
"objectDescriptionField": ""
"objectNameField": "naam",
"objectDescriptionField": "beschrijving"
}
},
"contactpersoon": {
Expand All @@ -1124,7 +1128,7 @@
"description": "Contactgegevens van een persoon",
"version": "0.0.17",
"summary": "",
"icon": null,
"icon": "AccountMultiple",
"required": [
"organisatie",
"e-mailadres"
Expand Down Expand Up @@ -1349,7 +1353,7 @@
"description": "Een organisatie die voorzieningen aanbiedt",
"version": "0.0.90",
"summary": "",
"icon": null,
"icon": "OfficeBuildingOutline",
"required": [
"naam",
"type",
Expand Down Expand Up @@ -1837,7 +1841,7 @@
"deleted": null,
"configuration": {
"objectNameField": "naam",
"objectDescriptionField": "beschrijvingKort"
"objectDescriptionField": "type"
}
},
"voorzieninggebruik": {
Expand Down Expand Up @@ -2311,8 +2315,8 @@
"authorization": null,
"deleted": null,
"configuration": {
"objectNameField": "",
"objectDescriptionField": ""
"objectNameField": "organisatie",
"objectDescriptionField": "status"
}
},
"contract": {
Expand All @@ -2322,7 +2326,7 @@
"description": "Een formele overeenkomst voor het inzetten van een VoorzieningAanbod op een VoorzieningGebruik",
"version": "0.0.4",
"summary": "",
"icon": null,
"icon": "FileDocumentEdit",
"required": [
"voorzieningAanbod",
"voorzieningGebruik",
Expand Down Expand Up @@ -2529,7 +2533,7 @@
"description": "Een specifieke standaard waaraan een voorziening kan voldoen",
"version": "0.0.3",
"summary": "",
"icon": null,
"icon": "FileDocumentCheck",
"required": [
"naam"
],
Expand Down Expand Up @@ -2622,7 +2626,7 @@
"description": "Beoordeling van een voorziening",
"version": "0.0.3",
"summary": "",
"icon": null,
"icon": "Star",
"required": [
"voorziening",
"score"
Expand Down Expand Up @@ -2815,7 +2819,10 @@
"groups": null,
"authorization": null,
"deleted": null,
"configuration": null
"configuration": {
"objectNameField": "type",
"objectDescriptionField": "beschrijvingKort"
}
},
"beoordeeling": {
"uri": null,
Expand Down Expand Up @@ -5052,7 +5059,7 @@
"description": "Schema voor compliancy en standaard ondersteuning",
"version": "0.0.1",
"summary": "",
"icon": null,
"icon": "CheckCircle",
"required": [],
"properties": {
"ondersteuntStandaardversie": {
Expand Down Expand Up @@ -5092,7 +5099,10 @@
"groups": null,
"authorization": null,
"deleted": null,
"configuration": null
"configuration": {
"objectNameField": "ondersteuntStandaardversie",
"objectDescriptionField": "moduleIsCompliant"
}
},
"moduleGebruik": {
"uri": null,
Expand Down Expand Up @@ -5174,7 +5184,7 @@
"description": "Schema voor module versies",
"version": "0.0.1",
"summary": "",
"icon": null,
"icon": "ViewModule",
"required": [],
"properties": {
"module": {
Expand Down Expand Up @@ -5286,7 +5296,10 @@
"groups": null,
"authorization": null,
"deleted": null,
"configuration": null
"configuration": {
"objectNameField": "module",
"objectDescriptionField": "beschrijvingKort"
}
}
},
"objects": []
Expand Down
Loading