"*": "0,n",
"+": "1,n",
"?": "0,1",
- "1": "1,1"
+ "1": "1,1",
+ "?R": "(0,1)",
+ "1R": "(1,1)",
};
}
return inheritance;
}
- // Association (parsed here): { entities: ArrayOf entity names + cardinality, [attributes: ArrayOf {name, [isKey], [type], [qualifiers]}] }
+ // Association (parsed here): {
+ // entities: ArrayOf entity names + cardinality,
+ // [attributes: ArrayOf {name, [isKey], [type], [qualifiers]}]
+ // }
parseAssociation(lines, start, end)
{
let assoce = { };
mcdDot += 'rankdir="LR";\n';
// Nodes:
if (mcdStyle == "compact")
- mcdDot += "node [shape=plaintext];\n";
+ mcdDot += 'node [shape=plaintext];\n';
_.shuffle(Object.keys(this.entities)).forEach( name => {
if (mcdStyle == "bubble")
{
mcdDot += '];\n';
if (!!this.entities[name].attributes)
{
- _.shuffle(this.entities[name].attributes).forEach( a => {
+ this.entities[name].attributes.forEach( a => {
let label = (a.isKey ? '#' : '') + a.name;
let attrName = name + '_' + a.name;
mcdDot += '"' + attrName + '" [shape=ellipse, label="' + label + '"];\n';
mcdDot += '<tr><td BGCOLOR="#ae7d4e" BORDER="0"><font COLOR="#FFFFFF">' + name + '</font></td></tr>\n';
if (!!this.entities[name].attributes)
{
- _.shuffle(this.entities[name].attributes).forEach( a => {
+ this.entities[name].attributes.forEach( a => {
let label = (a.isKey ? '<u>' : '') + a.name + (a.isKey ? '</u>' : '');
mcdDot += '<tr><td BGCOLOR="#FFFFFF" BORDER="0" ALIGN="LEFT"><font COLOR="#000000" >' + label + '</font></td></tr>\n';
});
});
// Inheritances:
_.shuffle(this.inheritances).forEach( i => {
+ // TODO: node shape = triangle fill yellow. See
+ // https://merise.developpez.com/faq/?page=MCD#CIF-ou-dependance-fonctionnelle-de-A-a-Z
+ // https://merise.developpez.com/faq/?page=MLD#Comment-transformer-un-MCD-en-MLD
+ // https://www.developpez.net/forums/d1088964/general-developpement/alm/modelisation/structure-agregation-l-association-d-association/
_.shuffle(i.children).forEach( c => {
if (Math.random() < 0.5)
mcdDot += '"' + c + '":name -- "' + i.parent;
});
});
// Relationships:
+ if (mcdStyle == "compact")
+ mcdDot += 'node [shape=rectangle, style=rounded];\n';
let assoceCounter = 0;
_.shuffle(this.associations).forEach( a => {
let name = !!a.name && a.name.length > 0
? a.name
: '_assoce' + assoceCounter++;
- mcdDot += '"' + name + '" [shape="diamond", style="filled", color="lightgrey", label="' + name + '"';
- if (a.weak)
- mcdDot += ', peripheries=2';
- mcdDot += '];\n';
+ if (mcdStyle == "bubble")
+ {
+ mcdDot += '"' + name + '" [shape="diamond", style="filled", color="lightgrey", label="' + name + '"';
+ if (a.weak)
+ mcdDot += ', peripheries=2';
+ mcdDot += '];\n';
+ if (!!a.attributes)
+ {
+ a.attributes.forEach( attr => {
+ let label = (attr.isKey ? '#' : '') + attr.name;
+ mcdDot += '"' + name + '_' + attr.name + '" [shape=ellipse, label="' + label + '"];\n';
+ let attrName = name + '_' + attr.name;
+ if (Math.random() < 0.5)
+ mcdDot += '"' + attrName + '" -- "' + name + '";\n';
+ else
+ mcdDot += '"' + name + '" -- "' + attrName + '";\n';
+ });
+ }
+ }
+ else
+ {
+ let label = name;
+ if (!!a.attributes)
+ {
+ a.attributes.forEach( attr => {
+ let attrLabel = (attr.isKey ? '#' : '') + attr.name;
+ label += '\\n<' + attrLabel + '>';
+ });
+ }
+ mcdDot += '"' + name + '" [color="lightgrey", label="' + label + '"';
+ if (a.weak)
+ mcdDot += ', peripheries=2';
+ mcdDot += '];\n';
+ }
_.shuffle(a.entities).forEach( e => {
if (Math.random() < 0.5)
mcdDot += '"' + e.name + '":name -- "' + name + '"';
mcdDot += '"' + name + '" -- "' + e.name + '":name';
mcdDot += '[label="' + ErDiags.CARDINAL[e.card] + '"];\n';
});
- if (!!a.attributes)
- {
- _.shuffle(a.attributes).forEach( attr => {
- let label = (attr.isKey ? '#' : '') + attr.name;
- mcdDot += '"' + name + '_' + attr.name + '" [shape=ellipse, label="' + label + '"];\n';
- let attrName = name + '_' + attr.name;
- if (Math.random() < 0.5)
- mcdDot += '"' + attrName + '" -- "' + name + '";\n';
- else
- mcdDot += '"' + name + '" -- "' + attrName + '";\n';
- });
- }
});
mcdDot += '}';
console.log(mcdDot);