diff --git a/packages/concerto-core/lib/introspect/mapkeytype.js b/packages/concerto-core/lib/introspect/mapkeytype.js index acf7ef280..51a3b31e6 100644 --- a/packages/concerto-core/lib/introspect/mapkeytype.js +++ b/packages/concerto-core/lib/introspect/mapkeytype.js @@ -71,7 +71,8 @@ class MapKeyType extends Decorated { validate() { if (!ModelUtil.isPrimitiveType(this.type)) { - const decl = ModelUtil.getTypeDeclaration(this.ast.type.name, this.modelFile); + + const decl = this.modelFile.getType(this.ast.type.name); if (!ModelUtil.isValidMapKeyScalar(decl)) { throw new IllegalModelException( diff --git a/packages/concerto-core/lib/introspect/mapvaluetype.js b/packages/concerto-core/lib/introspect/mapvaluetype.js index 9ede733a0..0ea4d8a6a 100644 --- a/packages/concerto-core/lib/introspect/mapvaluetype.js +++ b/packages/concerto-core/lib/introspect/mapvaluetype.js @@ -69,7 +69,8 @@ class MapValueType extends Decorated { */ validate() { if (!ModelUtil.isPrimitiveType(this.type)) { - const decl = ModelUtil.getTypeDeclaration(this.ast.type.name, this.modelFile); + + const decl = this.modelFile.getType(this.ast.type.name); // All declarations, with the exception of MapDeclarations, are valid Values. if(decl.isMapDeclaration?.()) { diff --git a/packages/concerto-core/lib/modelutil.js b/packages/concerto-core/lib/modelutil.js index 44a269d0b..d83210b21 100644 --- a/packages/concerto-core/lib/modelutil.js +++ b/packages/concerto-core/lib/modelutil.js @@ -338,21 +338,6 @@ class ModelUtil { `${MetaModelNamespace}.ObjectMapValueType` ].includes(value.$class); } - - /** - * Returns the corresponding ClassDeclaration representation of the Map Type - * @param {string} type - the Type of the Map Value - * @param {ModelFile} modelFile - the ModelFile that owns the Property - * @return {Object} the corresponding ClassDeclaration representation - */ - static getTypeDeclaration(type, modelFile) { - if (modelFile.isLocalType(type)) { - return modelFile.getAllDeclarations().find(d => d.name === type); - } else { - const fqn = modelFile.resolveImport(type); - return modelFile.getModelManager().getType(fqn); - } - } } module.exports = ModelUtil; diff --git a/packages/concerto-core/test/data/parser/mapdeclaration/mapdeclaration.goodvalue.declaration.participant.cto b/packages/concerto-core/test/data/parser/mapdeclaration/mapdeclaration.goodvalue.declaration.participant.cto index c3d08c9cc..0c2f4a697 100644 --- a/packages/concerto-core/test/data/parser/mapdeclaration/mapdeclaration.goodvalue.declaration.participant.cto +++ b/packages/concerto-core/test/data/parser/mapdeclaration/mapdeclaration.goodvalue.declaration.participant.cto @@ -13,11 +13,11 @@ */ namespace com.testing@1.0.0 -participant Customer identified by email { +participant CustomerParticipant identified by email { o String email } map Customer { o String - o Customer + o CustomerParticipant }