Skip to content

Commit

Permalink
adds fix to checkSemanticId for Handover Documentation IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronzi committed Dec 7, 2024
1 parent 395446e commit ce271e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 2 additions & 1 deletion aas-web-ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
node_modules
/dist


# local env files
.env.local
.env.*.local
Expand All @@ -22,4 +23,4 @@ pnpm-debug.log*
*.sw?

# coverages
/coverage
/coverage
15 changes: 9 additions & 6 deletions aas-web-ui/src/mixins/SubmodelElementHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,22 @@ 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
// .replace('https://api.eclass-cdp.com/', '')
// .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
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions aas-web-ui/tests/mixins/SubmodelElementHandling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down

0 comments on commit ce271e6

Please sign in to comment.