X-Git-Url: https://git.auder.net/?p=erdiag.git;a=blobdiff_plain;f=parser.js;h=57cf81c1c39ba005d8bc1b26be0e7b1f279690ed;hp=8a0932160a0a50f7f1b551242aed17dac2f9c30d;hb=e2610c05f3687c9362342718eb74410bfb279079;hpb=ae81f3059c9110deebb253268b3595c71a19f7af diff --git a/parser.js b/parser.js index 8a09321..57cf81c 100644 --- a/parser.js +++ b/parser.js @@ -7,6 +7,7 @@ class ErDiags this.inheritances = []; this.associations = []; this.txt2json(description); + this.tables = []; // Cache SVG graphs returned by server (in addition to server cache = good perfs) this.mcdGraph = ""; this.mldGraph = ""; @@ -268,9 +269,24 @@ class ErDiags element.innerHTML = this.mcdGraph; return; } - //UNIMPLEMENTED - // TODO: analyze cardinalities (eat attributes, create new tables...) - // mldDot = ... + // Build dot graph input + let mldDot = 'graph {\n'; + // Nodes: + Object.keys(this.entities).forEach( name => { + //mld. ... --> devient table + // mldDot = ... + }); + // Relationships: + this.associations.forEach( a => { + a.entities.forEach( e => { // e.card e.name ... + // Pass 1 : entites deviennent tables + // Pass 2 : sur les assoces + // multi-arite : sub-loop si 0,1 ou 1,1 : aspiré comme attribut de l'association (phase 1) + // ensuite, que du 0,n ou 1,n : si == 1, OK une table + // si 2 ou + : n tables + 1 pour l'assoce, avec attrs clés étrangères + // clé étrangère NOT NULL si 1,1 + }); + }); // this.graphMld = ... }