Browse Source

Updated the graphviz backend

Yann Weber 9 years ago
parent
commit
d3b1b4b659
1 changed files with 13 additions and 14 deletions
  1. 13
    14
      EditorialModel/backend/graphviz.py

+ 13
- 14
EditorialModel/backend/graphviz.py View File

@@ -3,8 +3,8 @@
3 3
 import datetime
4 4
 import EditorialModel
5 5
 from EditorialModel.classtypes import EmClassType
6
-from EditorialModel.fieldgroups import EmFieldGroup
7 6
 from EditorialModel.types import EmType
7
+from EditorialModel.fields import EmField
8 8
 from Lodel.utils.mlstring import MlString
9 9
 from EditorialModel.backend.dummy_backend import EmBackendDummy
10 10
 
@@ -45,27 +45,22 @@ class EmBackendGraphviz(EmBackendDummy):
45 45
                 self.edges += cid+' -> ct%s [ style="dashed" ]\n'%c.classtype
46 46
             dotfp.write("}\n")
47 47
 
48
-            #dotfp.write('subgraph cluster_fieldgroup {\nstyle="invis"\n')
49
-            for c in em.components(EmFieldGroup):
50
-                dotfp.write(self._component_node(c, em))
51
-                cn = c.__class__.__name__
52
-                cid = self._component_id(c)
53
-                self.edges += cid+' -> '+self._component_id(c.em_class)+' [ style="dashed" ]\n'
54
-            #dotfp.write("}\n")
55
-
56
-
57 48
             #dotfp.write('subgraph cluster_type {\nstyle="invis"\n')
58 49
             for c in em.components(EmType):
59 50
                 dotfp.write(self._component_node(c, em))
60 51
                 cn = c.__class__.__name__
61 52
                 cid = self._component_id(c)
62 53
                 self.edges += cid+' -> '+self._component_id(c.em_class)+' [ style="dotted" ]\n'
63
-                for fg in c.fieldgroups():
64
-                    self.edges += cid+' -> '+self._component_id(fg)+' [ style="dashed" ]\n'
65 54
                 for nat, sups in c.superiors().items():
66 55
                     for sup in sups:
67 56
                         self.edges += cid+' -> '+self._component_id(sup)+' [ label="%s" color="green" ]'%nat
68 57
             #dotfp.write("}\n")
58
+            
59
+            for rf in [ f for f in em.components(EmField) if f.fieldtype == 'rel2type']:
60
+                dotfp.write(self._component_node(rf, em))
61
+                cid = self._component_id(rf)
62
+                self.edges += cid+' -> '+self._component_id(rf.em_class)+'\n'
63
+                self.edges += cid+' -> '+self._component_id(em.component(rf.rel_to_type_id))+'\n'
69 64
 
70 65
             dotfp.write(self.edges)
71 66
 
@@ -83,13 +78,17 @@ class EmBackendGraphviz(EmBackendDummy):
83 78
         rel_field = ""
84 79
         if cn == 'EmClass':
85 80
             ret += '[ label="%s", shape="%s" ]'%(c.name.replace('"','\\"'), 'doubleoctagon')
86
-        elif cn == 'EmType' or cn == 'EmFieldGroup':
81
+        elif cn == 'EmField':
82
+            str_def = '[ label="Rel2Type {fname}|{{{records}}}", shape="record"]'
83
+            records = ' | '.join([f.name for f in em.components('EmField') if f.rel_field_id == c.uid])
84
+            ret += str_def.format(fname=c.name.replace('"','\\"'), records=records)
85
+        elif cn == 'EmType':
87 86
             ret += '[ label="%s %s '%(cn, c.name.replace('"','\\"'))
88 87
 
89 88
             cntref = 0
90 89
             first = True
91 90
             for f in c.fields():
92
-                if ((cn == 'EmType' and f.optional) or (cn == 'EmFieldGroup' and not f.optional)) and f.rel_field_id is None:
91
+                if cn == 'EmType' and f.rel_field_id is None:
93 92
                     
94 93
                     #if not (f.rel_to_type_id is None):
95 94
                     if isinstance(f, EditorialModel.fieldtypes.rel2type.EmFieldType):

Loading…
Cancel
Save