// Generated by Haxe 4.3.3
package transform;

import haxe.root.*;
import transform.DiagramToMLD_supersetToChildren_231__Fun;
import transform.DiagramToMLD_supersetToChildren_230__Fun;
import transform.DiagramToMLD_supersetToChildren_227__Fun;
import transform.DiagramToMLD_supersetToChildren_213__Fun;
import transform.DiagramToMLD_subsetsToParent_201__Fun;
import transform.DiagramToMLD_subsetsToParent_199__Fun;
import transform.DiagramToMLD_subsetsToParent_197__Fun;
import transform.DiagramToMLD_associationsToRelations_88__Fun;
import transform.DiagramToMLD_transform_20__Fun;
import transform.DiagramToMLD_transform_18__Fun;
import transform.DiagramToMLD_transform_17__Fun;
import transform.DiagramToMLD;

@SuppressWarnings(value={"rawtypes", "unchecked"})
public class DiagramToMLD extends haxe.lang.HxObject
{
	public DiagramToMLD(haxe.lang.EmptyObject empty)
	{
	}
	
	
	public DiagramToMLD()
	{
		//line 5 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		DiagramToMLD.__hx_ctor_transform_DiagramToMLD(this);
	}
	
	
	protected static void __hx_ctor_transform_DiagramToMLD(DiagramToMLD __hx_this)
	{
	}
	
	
	public static model.MLD transform(model.Diagram diagram)
	{
		//line 7 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		model.MLD mld = new model.MLD();
		//line 8 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		DiagramToMLD.setsToRelations(diagram, mld);
		//line 9 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		DiagramToMLD.subsetsToRelations(diagram, mld);
		//line 10 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		DiagramToMLD.componentsToRelations(diagram, mld);
		//line 11 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		DiagramToMLD.associationsToRelations(diagram, mld);
		//line 12 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		DiagramToMLD.supersetToChildren(diagram, mld);
		//line 13 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		DiagramToMLD.subsetsToParent(diagram, mld);
		//line 14 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		DiagramToMLD.copyLayout(diagram, mld);
		//line 16 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Array<java.lang.String> unneeded = new haxe.root.Array<java.lang.String>();
		//line 17 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Lambda.iter(((java.lang.Object) (mld.relations) ), ((haxe.lang.Function) (new DiagramToMLD_transform_17__Fun(unneeded)) ));
		//line 17 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		java.lang.Object __temp_expr1 = ((java.lang.Object) (null) );
		//line 18 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Lambda.iter(((java.lang.Object) (unneeded) ), ((haxe.lang.Function) (new DiagramToMLD_transform_18__Fun(mld)) ));
		//line 18 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		java.lang.Object __temp_expr2 = ((java.lang.Object) (null) );
		//line 19 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 19 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g = 0;
			//line 19 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (( _g < unneeded.length ))
			{
				//line 19 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				java.lang.String rName = unneeded.__get(_g);
				//line 19 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				 ++ _g;
				//line 20 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				haxe.root.Lambda.iter(((java.lang.Object) (mld.relations) ), ((haxe.lang.Function) (new DiagramToMLD_transform_20__Fun(rName)) ));
				//line 20 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				java.lang.Object __temp_expr3 = ((java.lang.Object) (null) );
			}
			
		}
		
		//line 23 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		return mld;
	}
	
	
	public static void setsToRelations(model.Diagram diagram, model.MLD mld)
	{
		//line 27 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		java.lang.Object set = new haxe.ds._StringMap.StringMapValueIterator<model.Set>(((haxe.ds.StringMap<model.Set>) (diagram.sets) ));
		//line 27 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(set, "hasNext", null)) )))
		{
			//line 27 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			model.Set set1 = ((model.Set) (haxe.lang.Runtime.callField(set, "next", null)) );
			//line 28 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			java.lang.String eName = set1.dbName;
			//line 29 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			model.Relation r = new model.Relation(haxe.lang.Runtime.toString(eName));
			//line 30 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			{
				//line 30 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				int _g = 0;
				//line 30 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				haxe.root.Array<model.Field> _g1 = set1.fields;
				//line 30 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				while (( _g < _g1.length ))
				{
					//line 30 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					model.Field f = _g1.__get(_g);
					//line 30 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					 ++ _g;
					//line 31 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					java.lang.String fName = f.className;
					//line 32 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					if ( ! (f.isStatic) ) 
					{
						//line 33 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						r.fields.push(new model.Field(haxe.lang.Runtime.toString(fName), haxe.lang.Runtime.toString(f.type), ((java.lang.Object) (null) ), ((java.lang.Object) (null) )));
						//line 34 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						if (( set1.id.indexOf(f.name, null) != -1 )) 
						{
							//line 35 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							r.key.push(fName);
						}
						
					}
					
				}
				
			}
			
			//line 39 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			mld.relations.set(eName, r);
		}
		
	}
	
	
	public static void subsetsToRelations(model.Diagram diagram, model.MLD mld)
	{
		//line 44 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		java.lang.Object set = new haxe.ds._StringMap.StringMapValueIterator<model.Set>(((haxe.ds.StringMap<model.Set>) (diagram.sets) ));
		//line 44 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(set, "hasNext", null)) )))
		{
			//line 44 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			model.Set set1 = ((model.Set) (haxe.lang.Runtime.callField(set, "next", null)) );
			//line 45 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			if (( set1.superset != null )) 
			{
				//line 46 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Relation r = mld.relations.get(set1.dbName);
				//line 47 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Relation pr = mld.relations.get(set1.superset.dbName);
				//line 48 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				boolean hasProperKey = ( r.key.length != 0 );
				//line 49 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				int pos = 0;
				//line 50 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				{
					//line 50 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					int _g = 0;
					//line 50 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					haxe.root.Array<java.lang.String> _g1 = pr.key;
					//line 50 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					while (( _g < _g1.length ))
					{
						//line 50 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						java.lang.String fName = _g1.__get(_g);
						//line 50 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						 ++ _g;
						//line 51 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						if ( ! (hasProperKey) ) 
						{
							//line 52 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							r.key.push(fName);
						}
						
						//line 54 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						model.Field pField = pr.getField(fName);
						//line 55 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						r.fields.insert(pos, new model.Field(haxe.lang.Runtime.toString(fName), haxe.lang.Runtime.toString(pField.dbType), ((java.lang.Object) (null) ), ((java.lang.Object) (null) )));
						//line 56 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						 ++ pos;
						//line 57 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						r.foreignKeys.push(new haxe.lang.DynamicObject(new java.lang.String[]{"key", "name", "relation"}, new java.lang.Object[]{fName, fName, pr}, new java.lang.String[]{}, new double[]{}));
					}
					
				}
				
			}
			
		}
		
	}
	
	
	public static void componentsToRelations(model.Diagram diagram, model.MLD mld)
	{
		//line 64 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		java.lang.Object set = new haxe.ds._StringMap.StringMapValueIterator<model.Set>(((haxe.ds.StringMap<model.Set>) (diagram.sets) ));
		//line 64 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(set, "hasNext", null)) )))
		{
			//line 64 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			model.Set set1 = ((model.Set) (haxe.lang.Runtime.callField(set, "next", null)) );
			//line 65 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			if (( set1.compound != null )) 
			{
				//line 66 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Relation r = mld.relations.get(set1.dbName);
				//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				int pos = 0;
				//line 68 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Relation cr = mld.relations.get(set1.compound.dbName);
				//line 69 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				{
					//line 69 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					int _g = 0;
					//line 69 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					haxe.root.Array<java.lang.String> _g1 = cr.key;
					//line 69 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					while (( _g < _g1.length ))
					{
						//line 69 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						java.lang.String fName = _g1.__get(_g);
						//line 69 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						 ++ _g;
						//line 70 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						r.key.insert(pos, fName);
						//line 71 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						model.Field cField = cr.getField(fName);
						//line 72 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						java.lang.String cType = cField.dbType;
						//line 73 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						r.fields.insert(pos, new model.Field(haxe.lang.Runtime.toString(fName), haxe.lang.Runtime.toString(cType), ((java.lang.Object) (null) ), ((java.lang.Object) (null) )));
						//line 74 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						r.foreignKeys.push(new haxe.lang.DynamicObject(new java.lang.String[]{"key", "name", "relation"}, new java.lang.Object[]{fName, fName, cr}, new java.lang.String[]{}, new double[]{}));
						//line 75 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						 ++ pos;
					}
					
				}
				
			}
			
		}
		
	}
	
	
	public static void associationsToRelations(model.Diagram diagram, model.MLD mld)
	{
		//line 82 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Array<model.Association> associations = new haxe.root.Array<model.Association>();
		//line 83 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 83 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			java.lang.Object assoc = new haxe.ds._StringMap.StringMapValueIterator<model.Association>(((haxe.ds.StringMap<model.Association>) (diagram.associations) ));
			//line 83 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(assoc, "hasNext", null)) )))
			{
				//line 83 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Association assoc1 = ((model.Association) (haxe.lang.Runtime.callField(assoc, "next", null)) );
				//line 84 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				associations.push(assoc1);
			}
			
		}
		
		//line 86 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		while (( associations.length != 0 ))
		{
			//line 87 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			model.Association assoc2 = associations.pop();
			//line 88 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			if (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.root.Lambda.exists(((java.lang.Object) (assoc2.links) ), ((haxe.lang.Function) (new DiagramToMLD_associationsToRelations_88__Fun(mld)) ))) ))) 
			{
				//line 89 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				associations.insert(0, assoc2);
				//line 90 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				continue;
			}
			
			//line 92 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			if (assoc2.isRelation()) 
			{
				//line 93 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				DiagramToMLD.associationToRelation(diagram, mld, assoc2);
			}
			else
			{
				//line 95 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				DiagramToMLD.associationToForeignKey(diagram, mld, assoc2);
			}
			
		}
		
	}
	
	
	public static void associationToForeignKey(model.Diagram diagram, model.MLD mld, model.Association assoc)
	{
		//line 101 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		model.Link l1 = null;
		//line 102 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		model.Link ln = null;
		//line 103 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 103 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g = 0;
			//line 103 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			haxe.root.Array<model.Link> _g1 = assoc.links;
			//line 103 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (( _g < _g1.length ))
			{
				//line 103 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Link l = _g1.__get(_g);
				//line 103 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				 ++ _g;
				//line 104 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				if (haxe.lang.Runtime.valEq(l.max, "1")) 
				{
					//line 105 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					if (( l1 == null )) 
					{
						//line 106 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						l1 = l;
					}
					else
					{
						//line 108 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						if (haxe.lang.Runtime.valEq(l.min, "1")) 
						{
							//line 109 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							ln = l1;
							//line 110 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							l1 = l;
						}
						else
						{
							//line 112 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							ln = l;
						}
						
					}
					
				}
				else
				{
					//line 116 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					ln = l;
				}
				
			}
			
		}
		
		//line 119 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		if (( ( l1 != null ) && ( ln != null ) )) 
		{
			//line 120 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			model.Relation r1 = mld.relations.get(l1.set.dbName);
			//line 121 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			if ( ! (l1.isWeak) ) 
			{
				//line 122 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				DiagramToMLD.addForeignKey(mld, ln, r1, false);
			}
			
		}
		
	}
	
	
	public static void associationToRelation(model.Diagram diagram, model.MLD mld, model.Association assoc)
	{
		//line 128 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		model.Relation r = new model.Relation(haxe.lang.Runtime.toString(assoc.dbName));
		//line 129 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		boolean nnAssoc = assoc.isNN();
		//line 130 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 130 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g = 0;
			//line 130 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			haxe.root.Array<model.Link> _g1 = assoc.links;
			//line 130 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (( _g < _g1.length ))
			{
				//line 130 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Link link = _g1.__get(_g);
				//line 130 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				 ++ _g;
				//line 131 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				java.lang.String role = link.role;
				//line 132 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				link.set_role("");
				//line 133 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				DiagramToMLD.addForeignKey(mld, link, r, ( nnAssoc || haxe.lang.Runtime.valEq(link.max, "1") ));
				//line 134 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				link.set_role(role);
			}
			
		}
		
		//line 136 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 136 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g2 = 0;
			//line 136 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			haxe.root.Array<model.Field> _g3 = assoc.fields;
			//line 136 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (( _g2 < _g3.length ))
			{
				//line 136 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Field field = _g3.__get(_g2);
				//line 136 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				 ++ _g2;
				//line 137 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				if ( ! (field.isStatic) ) 
				{
					//line 138 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					r.fields.push(new model.Field(haxe.lang.Runtime.toString(field.className), haxe.lang.Runtime.toString(field.type), ((java.lang.Object) (null) ), ((java.lang.Object) (null) )));
				}
				
			}
			
		}
		
		//line 141 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		mld.relations.set(assoc.dbName, r);
	}
	
	
	public static void addForeignKey(model.MLD mld, model.Link l, model.Relation r, boolean pk)
	{
		//line 145 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		model.Relation rl = mld.relations.get(l.set.dbName);
		//line 146 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		if (( rl == null )) 
		{
			//line 147 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			rl = mld.relations.get(l.set.superset.dbName);
		}
		
		//line 149 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 149 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g = 0;
			//line 149 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			haxe.root.Array<java.lang.String> _g1 = rl.key;
			//line 149 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (( _g < _g1.length ))
			{
				//line 149 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				java.lang.String k = _g1.__get(_g);
				//line 149 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				 ++ _g;
				//line 150 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				java.lang.String fName = DiagramToMLD.constructFieldName(r, k, l.classRole, rl.dbName, ( rl.key.length == 1 ));
				//line 151 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Field rField = rl.getField(k);
				//line 152 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				java.lang.String fType = rField.dbType;
				//line 153 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				r.fields.push(new model.Field(haxe.lang.Runtime.toString(fName), haxe.lang.Runtime.toString(fType), ((java.lang.Object) (null) ), ((java.lang.Object) (null) )));
				//line 154 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				r.foreignKeys.push(new haxe.lang.DynamicObject(new java.lang.String[]{"key", "name", "relation"}, new java.lang.Object[]{k, fName, rl}, new java.lang.String[]{}, new double[]{}));
				//line 155 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				if (pk) 
				{
					//line 156 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					r.key.push(fName);
				}
				
			}
			
		}
		
	}
	
	
	public static java.lang.String constructFieldName(model.Relation r, java.lang.String k, java.lang.String role, java.lang.String rName, boolean isSingleField)
	{
		//line 162 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		java.lang.String fName = "";
		//line 163 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		if ( ! (haxe.lang.Runtime.valEq(role, "")) ) 
		{
			//line 164 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			if (isSingleField) 
			{
				//line 165 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				fName = role;
			}
			else
			{
				//line 167 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				fName = ( k + (( (( ( ((int) (haxe.lang.Runtime.toInt(haxe.lang.StringExt.charCodeAt(k, ( k.length() - 1 )))) ) >= 97 ) && ( ((int) (haxe.lang.Runtime.toInt(haxe.lang.StringExt.charCodeAt(role, 0))) ) <= 90 ) )) ? (( haxe.lang.StringExt.charAt(role, 0).toUpperCase() + haxe.lang.StringExt.substring(role, 1, null) )) : (( "_" + role )) )) );
			}
			
		}
		else
		{
			//line 170 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			if (( ( haxe.lang.StringExt.indexOf(k.toLowerCase(), rName.toLowerCase(), null) == -1 ) && ( k.length() < 5 ) )) 
			{
				//line 171 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				fName = ( k + (( (( ( ((int) (haxe.lang.Runtime.toInt(haxe.lang.StringExt.charCodeAt(k, ( k.length() - 1 )))) ) >= 97 ) && ( ((int) (haxe.lang.Runtime.toInt(haxe.lang.StringExt.charCodeAt(rName, 0))) ) <= 90 ) )) ? (( haxe.lang.StringExt.charAt(rName, 0).toUpperCase() + haxe.lang.StringExt.substring(rName, 1, null) )) : (( "_" + rName )) )) );
			}
			else
			{
				//line 173 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				fName = k;
			}
			
		}
		
		//line 176 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Array<model.Field> _this = r.fields;
		//line 176 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Array<java.lang.String> ret = ((haxe.root.Array<java.lang.String>) (((haxe.root.Array) (haxe.root.Array.alloc(((int) (_this.length) ))) )) );
		//line 176 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 176 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g = 0;
			//line 176 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g1 = _this.length;
			//line 176 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (( _g < _g1 ))
			{
				//line 176 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				int i = _g++;
				//line 176 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				ret.__set(i, _this.__get(i).name);
			}
			
		}
		
		//line 176 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Array<java.lang.String> usedFields = ret;
		//line 177 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		java.lang.String tryName = fName;
		//line 178 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		int num = 0;
		//line 179 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		while (( usedFields.indexOf(tryName, null) != -1 ))
		{
			//line 180 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			 ++ num;
			//line 181 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			tryName = ( fName + haxe.root.Std.string(num) );
		}
		
		//line 183 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		fName = tryName;
		//line 184 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		return fName;
	}
	
	
	public static void subsetsToParent(model.Diagram diagram, model.MLD mld)
	{
		//line 188 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		java.lang.Object set = new haxe.ds._StringMap.StringMapValueIterator<model.Set>(((haxe.ds.StringMap<model.Set>) (diagram.sets) ));
		//line 188 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(set, "hasNext", null)) )))
		{
			//line 188 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			model.Set set1 = ((model.Set) (haxe.lang.Runtime.callField(set, "next", null)) );
			//line 189 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			if (( set1.subsetOption == model.Set.SUBSET_OPT_PARENT )) 
			{
				//line 190 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Relation pr = mld.relations.get(set1.dbName);
				//line 191 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				if ( ! (haxe.lang.Runtime.valEq(set1.subsetCode, "")) ) 
				{
					//line 192 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					pr.fields.push(new model.Field(haxe.lang.Runtime.toString(set1.subsetCode), haxe.lang.Runtime.toString("INT"), ((java.lang.Object) (null) ), ((java.lang.Object) (null) )));
				}
				
				//line 194 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				{
					//line 194 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					int _g = 0;
					//line 194 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					haxe.root.Array<model.Set> _g1 = set1.subsets;
					//line 194 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					while (( _g < _g1.length ))
					{
						//line 194 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						model.Set c = _g1.__get(_g);
						//line 194 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						 ++ _g;
						//line 195 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						model.Relation cr = mld.relations.get(c.dbName);
						//line 197 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						haxe.root.Lambda.iter(((java.lang.Object) (cr.fields) ), ((haxe.lang.Function) (new DiagramToMLD_subsetsToParent_197__Fun(pr)) ));
						//line 197 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						java.lang.Object __temp_expr1 = ((java.lang.Object) (null) );
						//line 199 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						haxe.root.Lambda.iter(((java.lang.Object) (cr.foreignKeys) ), ((haxe.lang.Function) (new DiagramToMLD_subsetsToParent_199__Fun(pr)) ));
						//line 199 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						java.lang.Object __temp_expr2 = ((java.lang.Object) (null) );
						//line 201 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						haxe.root.Lambda.iter(((java.lang.Object) (mld.relations) ), ((haxe.lang.Function) (new DiagramToMLD_subsetsToParent_201__Fun(pr, cr)) ));
						//line 201 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						java.lang.Object __temp_expr3 = ((java.lang.Object) (null) );
						//line 202 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						mld.relations.remove(cr.name);
					}
					
				}
				
			}
			
		}
		
	}
	
	
	public static void supersetToChildren(model.Diagram diagram, model.MLD mld)
	{
		//line 209 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		java.lang.Object set = new haxe.ds._StringMap.StringMapValueIterator<model.Set>(((haxe.ds.StringMap<model.Set>) (diagram.sets) ));
		//line 209 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(set, "hasNext", null)) )))
		{
			//line 209 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			model.Set set1 = ((model.Set) (haxe.lang.Runtime.callField(set, "next", null)) );
			//line 210 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			model.Relation pr = mld.relations.get(set1.dbName);
			//line 211 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			haxe.root.Array<java.lang.String> _g = new haxe.root.Array<java.lang.String>(new java.lang.String[]{});
			//line 211 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			{
				//line 211 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				java.lang.Object x = ((java.lang.Object) (haxe.lang.Runtime.callField(((java.lang.Object) (set1.subsets) ), "iterator", null)) );
				//line 211 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(x, "hasNext", null)) )))
				{
					//line 211 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					model.Set x1 = ((model.Set) (haxe.lang.Runtime.callField(x, "next", null)) );
					//line 211 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					_g.push(x1.dbName);
				}
				
			}
			
			//line 211 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			haxe.root.Array<java.lang.String> subsetsNames = _g;
			//line 212 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			java.lang.String subsetType = set1.subsetType.toUpperCase();
			//line 213 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int refCount = ((int) (haxe.root.Lambda.count(((java.lang.Object) (mld.relations) ), ((haxe.lang.Function) (new DiagramToMLD_supersetToChildren_213__Fun(subsetsNames, pr)) ))) );
			//line 215 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			if (( ( ( set1.subsetOption == model.Set.SUBSET_OPT_CHILDREN ) && ( refCount == 0 ) ) && (( ( ( ( ( set1.subsets.length == 1 ) || haxe.lang.Runtime.valEq(subsetType, "X") ) || haxe.lang.Runtime.valEq(subsetType, "XT") ) || haxe.lang.Runtime.valEq(subsetType, "TX") ) || haxe.lang.Runtime.valEq(subsetType, "P") )) )) 
			{
				//line 218 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				{
					//line 218 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					int _g1 = 0;
					//line 218 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					haxe.root.Array<model.Set> _g2 = set1.subsets;
					//line 218 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					while (( _g1 < _g2.length ))
					{
						//line 218 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						model.Set c = _g2.__get(_g1);
						//line 218 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						 ++ _g1;
						//line 219 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						model.Relation cr = mld.relations.get(c.dbName);
						//line 220 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int pos = ( cr.key.length - 1 );
						//line 221 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						{
							//line 221 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							int _g3 = 0;
							//line 221 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							haxe.root.Array<model.Field> _g4 = pr.fields;
							//line 221 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							while (( _g3 < _g4.length ))
							{
								//line 221 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
								model.Field f = _g4.__get(_g3);
								//line 221 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
								 ++ _g3;
								//line 222 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
								if (( pr.key.indexOf(f.name, null) == -1 )) 
								{
									//line 223 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
									cr.fields.insert(pos, f);
								}
								
								//line 225 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
								 ++ pos;
							}
							
						}
						
						//line 227 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						haxe.root.Lambda.iter(((java.lang.Object) (pr.foreignKeys) ), ((haxe.lang.Function) (new DiagramToMLD_supersetToChildren_227__Fun(cr)) ));
						//line 227 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						java.lang.Object __temp_expr1 = ((java.lang.Object) (null) );
						//line 228 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						if (( ( ( ( set1.subsets.length == 1 ) || haxe.lang.Runtime.valEq(subsetType, "XT") ) || haxe.lang.Runtime.valEq(subsetType, "TX") ) || haxe.lang.Runtime.valEq(subsetType, "P") )) 
						{
							//line 229 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							haxe.root.Array<java.lang.Object> supersetFK = new haxe.root.Array<java.lang.Object>();
							//line 230 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							haxe.root.Lambda.iter(((java.lang.Object) (cr.foreignKeys) ), ((haxe.lang.Function) (new DiagramToMLD_supersetToChildren_230__Fun(supersetFK, pr)) ));
							//line 230 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							java.lang.Object __temp_expr2 = ((java.lang.Object) (null) );
							//line 231 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							haxe.root.Lambda.iter(((java.lang.Object) (supersetFK) ), ((haxe.lang.Function) (new DiagramToMLD_supersetToChildren_231__Fun(cr)) ));
							//line 231 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
							java.lang.Object __temp_expr3 = ((java.lang.Object) (null) );
						}
						
					}
					
				}
				
				//line 234 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				if (( ( ( ( set1.subsets.length == 1 ) || haxe.lang.Runtime.valEq(subsetType, "XT") ) || haxe.lang.Runtime.valEq(subsetType, "TX") ) || haxe.lang.Runtime.valEq(subsetType, "P") )) 
				{
					//line 235 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					mld.relations.remove(pr.name);
				}
				
			}
			
		}
		
	}
	
	
	public static void copyLayout(model.Diagram diagram, model.MLD mld)
	{
		//line 242 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		mld.height = diagram.height;
		//line 243 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		mld.width = diagram.width;
		//line 244 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Array<java.lang.Object> _g = new haxe.root.Array<java.lang.Object>(new java.lang.Object[]{});
		//line 244 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 244 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g1 = 0;
			//line 244 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g2 = mld.height;
			//line 244 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (( _g1 < _g2 ))
			{
				//line 244 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				int i = _g1++;
				//line 244 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				_g.push(0);
			}
			
		}
		
		//line 244 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Array<java.lang.Object> rows = _g;
		//line 245 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Array<java.lang.Object> _g3 = new haxe.root.Array<java.lang.Object>(new java.lang.Object[]{});
		//line 245 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 245 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g4 = 0;
			//line 245 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g5 = mld.width;
			//line 245 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (( _g4 < _g5 ))
			{
				//line 245 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				int i1 = _g4++;
				//line 245 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				_g3.push(0);
			}
			
		}
		
		//line 245 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		haxe.root.Array<java.lang.Object> columns = _g3;
		//line 246 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 246 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			java.lang.Object o = diagram.iterator();
			//line 246 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(o, "hasNext", null)) )))
			{
				//line 246 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Set o1 = ((model.Set) (haxe.lang.Runtime.callField(o, "next", null)) );
				//line 247 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Relation r = mld.relations.get(o1.dbName);
				//line 248 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				if (( r != null )) 
				{
					//line 249 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					r.row = o1.row;
					//line 250 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					r.col = o1.col;
					//line 251 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					{
						//line 251 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int __temp_arrIndex3 = r.row;
						//line 251 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int __temp_arrVal1 = ((int) (haxe.lang.Runtime.toInt(rows.__get(__temp_arrIndex3))) );
						//line 251 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int __temp_arrRet2 = __temp_arrVal1++;
						//line 251 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int __temp_expr1 = ((int) (haxe.lang.Runtime.toInt(rows.__set(__temp_arrIndex3, __temp_arrVal1))) );
						//line 251 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int __temp_expr2 = __temp_arrRet2;
					}
					
					//line 252 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					{
						//line 252 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int __temp_arrIndex6 = r.col;
						//line 252 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int __temp_arrVal4 = ((int) (haxe.lang.Runtime.toInt(columns.__get(__temp_arrIndex6))) );
						//line 252 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int __temp_arrRet5 = __temp_arrVal4++;
						//line 252 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int __temp_expr3 = ((int) (haxe.lang.Runtime.toInt(columns.__set(__temp_arrIndex6, __temp_arrVal4))) );
						//line 252 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
						int __temp_expr4 = __temp_arrRet5;
					}
					
				}
				
			}
			
		}
		
		//line 256 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		int empty = 0;
		//line 257 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 257 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g6 = 0;
			//line 257 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g7 = rows.length;
			//line 257 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (( _g6 < _g7 ))
			{
				//line 257 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				int i2 = _g6++;
				//line 258 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				if (( ((int) (haxe.lang.Runtime.toInt(rows.__get(i2))) ) == 0 )) 
				{
					//line 259 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					 ++ empty;
				}
				else
				{
					//line 261 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					int __temp_expr5 = ((int) (haxe.lang.Runtime.toInt(rows.__set(i2, ( i2 - empty )))) );
				}
				
			}
			
		}
		
		//line 264 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		mld.height -= empty;
		//line 265 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		empty = 0;
		//line 266 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 266 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g8 = 0;
			//line 266 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			int _g9 = columns.length;
			//line 266 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (( _g8 < _g9 ))
			{
				//line 266 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				int i3 = _g8++;
				//line 267 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				if (( ((int) (haxe.lang.Runtime.toInt(columns.__get(i3))) ) == 0 )) 
				{
					//line 268 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					 ++ empty;
				}
				else
				{
					//line 270 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
					int __temp_expr6 = ((int) (haxe.lang.Runtime.toInt(columns.__set(i3, ( i3 - empty )))) );
				}
				
			}
			
		}
		
		//line 273 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		mld.width -= empty;
		//line 274 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
		{
			//line 274 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			java.lang.Object r1 = new haxe.ds._StringMap.StringMapValueIterator<model.Relation>(((haxe.ds.StringMap<model.Relation>) (mld.relations) ));
			//line 274 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
			while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(r1, "hasNext", null)) )))
			{
				//line 274 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				model.Relation r2 = ((model.Relation) (haxe.lang.Runtime.callField(r1, "next", null)) );
				//line 275 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				r2.row = ((int) (haxe.lang.Runtime.toInt(rows.__get(r2.row))) );
				//line 276 "/home/frank/Documents/Developpements/dbconcept-0.5.1/src/transform/DiagramToMLD.hx"
				r2.col = ((int) (haxe.lang.Runtime.toInt(columns.__get(r2.col))) );
			}
			
		}
		
	}
	
	
}


