Skip to content

Commit

Permalink
fix(graph): add relationship for scalar and map decl
Browse files Browse the repository at this point in the history
Signed-off-by: muhammed-abdulkadir <muhammed.abdulkadir@docusign.com>
  • Loading branch information
muhammed-abdulkadir committed Oct 30, 2024
1 parent 15a3c52 commit 9875f3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
13 changes: 8 additions & 5 deletions lib/common/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
'use strict';

const { ModelUtil } = require('@accordproject/concerto-core');
const { ModelUtil, Property } = require('@accordproject/concerto-core');

const DiagramVisitor = require('./diagramvisitor');

Expand Down Expand Up @@ -219,10 +219,13 @@ class ConcertoGraphVisitor extends DiagramVisitor {
if(argument && argument.name) {
const fqn = modelFile.getFullyQualifiedTypeName(argument.name);
if (fqn) {
const m = modelFile.getModelManager().getType(fqn);
(parent === modelFile)
? parameters.graph.addEdge(parent.getNamespace(), m.getFullyQualifiedName())
: parameters.graph.addEdge(parameters.stack.slice(-1), m.getFullyQualifiedName());
const type = modelFile.getModelManager().getType(fqn);
const parentFqn = parent === modelFile ? parent.getNamespace() : parent.getFullyQualifiedName();
if (parent instanceof Property) {
parameters.graph.addEdge(parameters.stack.slice(-1), type.getFullyQualifiedName());
} else {
parameters.graph.addEdge(parentFqn, type.getFullyQualifiedName());
}
}
}
});
Expand Down
7 changes: 3 additions & 4 deletions test/common/__snapshots__/graph.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ exports[`graph #visitor should visit a model manager 1`] = `
\`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr.base@1.0.0.Address\`
\`concerto@1.0.0.Transaction\`
\`concerto@1.0.0.Transaction\` <--> \`org.acme.hr@1.0.0.ChangeOfAddress\`
\`\`
\`\` --> \`org.acme.hr.base@1.0.0.GeneralCategory\`
\`org.acme.hr@1.0.0.KinName\`
\`org.acme.hr@1.0.0.KinName\` --> \`org.acme.hr.base@1.0.0.GeneralCategory\`
\`org.acme.hr@1.0.0.KinTelephone\`
\`org.acme.hr@1.0.0\`
\`org.acme.hr@1.0.0\` --> \`org.acme.hr.base@1.0.0.GeneralCategory\`
Expand Down Expand Up @@ -179,9 +178,8 @@ exports[`graph #visitor should visit a model manager and create a dependency gra
\`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`concerto@1.0.0.Transaction\`
\`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr@1.0.0.Person\`
\`org.acme.hr@1.0.0.ChangeOfAddress\` --> \`org.acme.hr.base@1.0.0.Address\`
\`\`
\`\` --> \`org.acme.hr.base@1.0.0.GeneralCategory\`
\`org.acme.hr@1.0.0.KinName\`
\`org.acme.hr@1.0.0.KinName\` --> \`org.acme.hr.base@1.0.0.GeneralCategory\`
\`org.acme.hr@1.0.0.KinTelephone\`
\`org.acme.hr@1.0.0\`
\`org.acme.hr@1.0.0\` --> \`org.acme.hr.base@1.0.0.GeneralCategory\`
Expand Down Expand Up @@ -266,6 +264,7 @@ exports[`graph #visitor should visit find a connected subgraph 1`] = `
\`concerto@1.0.0.Transaction\`
\`concerto@1.0.0.Transaction\` <--> \`org.acme.hr@1.0.0.ChangeOfAddress\`
\`org.acme.hr@1.0.0.KinName\`
\`org.acme.hr@1.0.0.KinName\` --> \`org.acme.hr.base@1.0.0.GeneralCategory\`
\`org.acme.hr@1.0.0.KinTelephone\`
"
`;

0 comments on commit 9875f3e

Please sign in to comment.