Skip to content

Commit

Permalink
Merge pull request #46 from Informatievlaanderen/SDTT-283-When-a-name…
Browse files Browse the repository at this point in the history
…-tag-already-contains-a-prefix-no-camel-case-should-be-applied

SDTT-283 Update local name casing, to only case when not prefixed
  • Loading branch information
ddvlanck authored Feb 16, 2024
2 parents 7eecfc7 + 96acdbc commit 8a49744
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,16 @@ export class AttributeConverterHandler extends ConverterHandler<EaAttribute> {
attribute.name,
);

if(!localName){
if (!localName) {
throw new Error(`[AttributeConverterHandler]: Unable to determine local name for attribute (${attribute.path}). If you used a "name" tag, did you set it correctly?`)
}
localName = toCamelCase(localName);

// Names on the diagram are not prefixed, so if this value contains
// a prefix (by checking for a dot), we assume this value was added by the editor through
// a name tag. We assume the spelling is correctly done and we do not camel case it.
if (!localName.includes('.')) {
localName = toCamelCase(localName);
}

const attributeURI: URL = new URL(`${attributeBaseURI}${localName}`);
uriRegistry.attributeIdUriMap.set(attribute.id, attributeURI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ConnectorNormalisationService } from '@oslo-converter-uml-ea/ConnectorN
import { TagNames } from '@oslo-converter-uml-ea/enums/TagNames';
import { ConverterHandler } from '@oslo-converter-uml-ea/interfaces/ConverterHandler';
import type { UriRegistry } from '@oslo-converter-uml-ea/UriRegistry';
import { getTagValue, ignore } from '@oslo-converter-uml-ea/utils/utils';
import { getTagValue, ignore, toCamelCase } from '@oslo-converter-uml-ea/utils/utils';

@injectable()
export class ConnectorConverterHandler extends ConverterHandler<NormalizedConnector> {
Expand Down Expand Up @@ -136,11 +136,23 @@ export class ConnectorConverterHandler extends ConverterHandler<NormalizedConnec
}
}

const localName: string = getTagValue(
let localName: string = getTagValue(
connector,
TagNames.LocalName,
connector.name,
);

if(!localName){
throw new Error(`[ConnectorConverterHandler]: Unable to find local name for connector (${connector.path}).`);
}

// Names on the diagram are not prefixed, so if this value contains
// a prefix (by checking for a dot), we assume this value was added by the editor through
// a name tag. We assume the spelling is correctly done and we do not camel case it.
if(!localName.includes('.')){
localName = toCamelCase(localName);
}

const connectorUri = new URL(`${baseUri}${localName}`);
uriRegistry.connectorOsloIdUriMap.set(connector.id, connectorUri);
});
Expand Down

0 comments on commit 8a49744

Please sign in to comment.