AmpersandTarski / Ampersand

Build database applications faster than anyone else, and keep your data pollution free as a bonus.
http://ampersandtarski.github.io/
GNU General Public License v3.0
40 stars 8 forks source link

Feature: logical data model with patterns #1231

Closed stefjoosten closed 2 years ago

stefjoosten commented 2 years ago

Problem

The ampersand documentation command generates a file called LogicalDataModel.png. This picture is usually too large to print on an A4, but this feature request will make it even larger. The problem is that Graphviz places the entities in the global context and entities that are defined inside a pattern are sometimes taken apart. I wish entities that are defined inside the same pattern are drawn in the same contour and that contour is labeled with the name of the pattern. I would hope that large diagrams become more readable if entities from the same pattern are kept together.

Complications

  1. Each entity has a key concept. If a concept definition of that concept is defined inside a pattern, that entity can be drawn inside that pattern in LogicalDataModel.png. If that concept has multiple concept definitions spread over multiple patterns, the algorithm may pick an arbitrary one, e.g. the first one it sees.
  2. Both pictures are large. The new one will be even larger than the existing one. I suggest we generate both, so we can choose. This lets us gain some experience with both forms.

@hanjoosten, I have sent you some test input.

stefjoosten commented 2 years ago

@hanjoosten , I ran your attempt using:

I used the same large input files as you did. The result is the same as yours with Graphviz version2.43 on Windows: It runs into an error when generating LogicalDataModel_Grouped_By_Pattern.png. With one difference, however. LogicalDataModel_Grouped_By_Pattern.png has not been written.

sjo00577@BA92-C02T81JCGTDY GrotePlaatMateriaal % ampersand documentation --format docx ConceptueleAnalyse.adl --graphics                     
Generating functional design document for Veligheidsregios...
/Users/sjo00577/surfdrive/LMS/Ampersand/GrotePlaatMateriaal/images/TechnicalDataModel.png written.
/Users/sjo00577/surfdrive/LMS/Ampersand/GrotePlaatMateriaal/images/LogicalDataModel.png written.
Error running utility program: Unable to create ./images/LogicalDataModel_Grouped_By_Pattern.png

I also did it on a slightly smaller subset of the same input. With success: There were no Graphviz errors and the file LogicalDataModel_Grouped_By_Pattern.png was generated.

hanjoosten commented 2 years ago

I did some tests myself too: I isolated the original .gv file, that was created from your original mail. I observed that creating it causes no problem. Also rendering it in the vscode extention causes no problem.

So I tried to render it using my version of dot, which is on ubuntu. The latest version on ubuntu currently is dot - graphviz version 2.43.0 (0). The command I run is

dot -Tpng LogicalDataModel_Grouped_By_Pattern.gv -o test.png

This gives a nice result. However, there are some warnings about ports not being found. I have to dive into that, but that has to do with the drawing itself.

I also did a code inspection on the Graphviz package that we use. There is no reason to believe that it is broken.

hanjoosten commented 2 years ago

@stefjoosten created a somewhat smaller testcase. That one works fine. The problem occurs in a large model, and is likely caused by graphviz itself. I Also looked at the aforementioned warnings. That is because of some wierd combination of the use of ports and subgraphs. I consider this something we have to live with for now.