From ce271e6ceadd5df4e675ced817fdd9bf2ca20365 Mon Sep 17 00:00:00 2001 From: Aaron Zielstorff Date: Sat, 7 Dec 2024 20:43:17 +0100 Subject: [PATCH] adds fix to checkSemanticId for Handover Documentation IDs --- aas-web-ui/.gitignore | 3 ++- aas-web-ui/src/mixins/SubmodelElementHandling.ts | 15 +++++++++------ .../tests/mixins/SubmodelElementHandling.test.ts | 9 +++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/aas-web-ui/.gitignore b/aas-web-ui/.gitignore index 18148f3f..3a621707 100644 --- a/aas-web-ui/.gitignore +++ b/aas-web-ui/.gitignore @@ -2,6 +2,7 @@ node_modules /dist + # local env files .env.local .env.*.local @@ -22,4 +23,4 @@ pnpm-debug.log* *.sw? # coverages -/coverage \ No newline at end of file +/coverage diff --git a/aas-web-ui/src/mixins/SubmodelElementHandling.ts b/aas-web-ui/src/mixins/SubmodelElementHandling.ts index 82dbbc75..0eae41f1 100644 --- a/aas-web-ui/src/mixins/SubmodelElementHandling.ts +++ b/aas-web-ui/src/mixins/SubmodelElementHandling.ts @@ -142,9 +142,9 @@ export default defineComponent({ if (key.value.startsWith('0173-1#')) { // Eclass IRDI like 0173-1#01-AHF578#001 // console.log('key.value', '0173-1#...'); - // console.log('key.value', key.value); - // console.log('(1) ', semanticId); - // console.log('(2) ', semanticId.replace(/\/1\/\/\/(\d{2})#/, '-1#$1-')); + console.log('key.value', key.value); + console.log('(1) ', semanticId); + console.log('(2) ', semanticId.replace(/\/1\/\/\/(\d{2})#/, '-1#$1-')); // console.log( // '(3) ', // semanticId @@ -152,9 +152,12 @@ export default defineComponent({ // .replace(/-1-(\d{2})-/, '-1#$1-') // .replace(/-(\d{3})$/, '#$1') // ); + if (new RegExp(/\*\d{2}$/).test(key.value)) { + key.value = key.value.slice(0, -3); + } if (new RegExp(/[#-]{1}\d{3}$/).test(semanticId)) { // Eclass IRDI with version; like 0173-1#01-AHF578#001 - // console.log('semanticId --> with version', semanticId); + console.log('semanticId --> with version', semanticId); if ( key.value === semanticId || // e.g.0173-1#01-AHF578#001 key.value === semanticId.replace(/\/1\/\/\/(\d{2})#/, '-1#$1-') || // e.g. semanticId 0173/1///01#AHF578#001 --> 0173-1#01-AHF578#001 @@ -164,12 +167,12 @@ export default defineComponent({ .replace(/-1-(\d{2})-/, '-1#$1-') .replace(/-(\d{3})$/, '#$1') // e.g. semanticId https://api.eclass-cdp.com/0173-1-01-AHF578-001 --> 0173-1#01-AHF578#001 ) { - // console.log('--> with version: true'); + console.log('--> with version: true'); return true; } } else { // Eclass IRDI without version; like 0173-1#01-AHF578 - // console.log('semanticId --> without version', semanticId); + console.log('semanticId --> without version', semanticId); if ( key.value.startsWith(semanticId) || // e.g. semanticId 0173-1#01-AHF578#001 key.value.startsWith(semanticId.replace(/\/1\/\/\/(\d{2})#/, '-1#$1-')) || // e.g. semanticId0173/1///01#AHF578#001 --> 0173-1#01-AHF578#001 diff --git a/aas-web-ui/tests/mixins/SubmodelElementHandling.test.ts b/aas-web-ui/tests/mixins/SubmodelElementHandling.test.ts index 1de1f7fd..8feb50be 100644 --- a/aas-web-ui/tests/mixins/SubmodelElementHandling.test.ts +++ b/aas-web-ui/tests/mixins/SubmodelElementHandling.test.ts @@ -19,6 +19,8 @@ describe('SubmodelElementHandling', () => { const iri = 'https://admin-shell.io/zvei/nameplate/2/0/Nameplate'; const eclassIrdiWithVersion = '0173-1#01-AHF578#001'; const eclassIrdiWithoutVersion = '0173-1#01-AHF578'; + const eclassIrdiWithVersionAndCardinality = '0173-1#02-ABI502#001/0173-1#01-AHF581#001*02'; + const eclassIrdiWithVersionAndNoCardinality = '0173-1#02-ABI502#001/0173-1#01-AHF581#001'; const eclassIrdiSlashesWithVersion = '0173/1///01#AHF578#001'; const eclassIrdiSlashesWithoutVersion = '0173/1///01#AHF578'; const eclassIriWithVersion = 'https://api.eclass-cdp.com/0173-1-01-AHF578-001'; @@ -43,6 +45,13 @@ describe('SubmodelElementHandling', () => { strategy: 'exact', match: true, }, + { + testId: '24d16939-05f4-423b-b71b-f6f4f49ef30f', + semanticId: eclassIrdiWithVersionAndNoCardinality, + submodelElementSemanticId: eclassIrdiWithVersionAndCardinality, + strategy: 'exact', + match: true, + }, { testId: 'de06d9a2-2ec6-4e96-b980-805f91cd227e', semanticId: eclassIrdiWithoutVersion,