// Generated by Haxe 4.3.1
package transform;

import haxe.root.*;
import transform.DiagramToUML_initAccessors_80__Fun;
import transform.DiagramToUML_initAccessors_79__Fun;
import transform.DiagramToUML;

@SuppressWarnings(value={"rawtypes", "unchecked"})
public class DiagramToUML extends haxe.lang.HxObject
{
	public DiagramToUML(haxe.lang.EmptyObject empty)
	{
	}
	
	
	public DiagramToUML()
	{
		//line 10 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		DiagramToUML.__hx_ctor_transform_DiagramToUML(this);
	}
	
	
	protected static void __hx_ctor_transform_DiagramToUML(DiagramToUML __hx_this)
	{
	}
	
	
	public static void transform(model.Diagram diagram)
	{
		//line 12 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		DiagramToUML.initNavigation(diagram);
		//line 13 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		DiagramToUML.initConstructors(diagram);
		//line 14 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		DiagramToUML.initAccessors(diagram);
	}
	
	
	public static void initNavigation(model.Diagram diagram)
	{
		//line 18 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		java.lang.Object assoc = new haxe.ds._StringMap.StringMapValueIterator<model.Association>(((haxe.ds.StringMap<model.Association>) (diagram.associations) ));
		//line 18 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(assoc, "hasNext", null)) )))
		{
			//line 18 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			model.Association assoc1 = ((model.Association) (haxe.lang.Runtime.callField(assoc, "next", null)) );
			//line 19 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			if (assoc1.isClass()) 
			{
				//line 20 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				int _g = 0;
				//line 20 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				haxe.root.Array<model.Link> _g1 = assoc1.links;
				//line 20 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				while (( _g < _g1.length ))
				{
					//line 20 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					model.Link link = _g1.__get(_g);
					//line 20 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					 ++ _g;
					//line 21 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					assoc1.navFields.push(new model.Field(haxe.lang.Runtime.toString(DiagramToUML.constructFieldName(link, "1")), haxe.lang.Runtime.toString(link.set.className), ((java.lang.Object) (link.visibility) ), ((java.lang.Object) (null) )));
				}
				
			}
			else
			{
				//line 23 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				if (( assoc1.links.length == 2 )) 
				{
					//line 24 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					if ( ! (assoc1.links.__get(0).hasArrow) ) 
					{
						//line 25 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						model.Set c1 = diagram.getObj(assoc1.links.__get(0).set.name);
						//line 26 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						java.lang.String field1Type = ( (haxe.lang.Runtime.valEq(assoc1.links.__get(0).max, "1")) ? (assoc1.links.__get(1).set.className) : (model.Field.arrayOf(assoc1.links.__get(1).set.className)) );
						//line 27 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						c1.navFields.push(new model.Field(haxe.lang.Runtime.toString(DiagramToUML.constructFieldName(assoc1.links.__get(1), assoc1.links.__get(0).max)), haxe.lang.Runtime.toString(field1Type), ((java.lang.Object) (assoc1.links.__get(1).visibility) ), ((java.lang.Object) (null) )));
					}
					
					//line 29 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					if ( ! (assoc1.links.__get(1).hasArrow) ) 
					{
						//line 30 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						model.Set c2 = diagram.getObj(assoc1.links.__get(1).set.name);
						//line 31 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						java.lang.String field2Type = ( (haxe.lang.Runtime.valEq(assoc1.links.__get(1).max, "1")) ? (assoc1.links.__get(0).set.className) : (model.Field.arrayOf(assoc1.links.__get(0).set.className)) );
						//line 32 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						c2.navFields.push(new model.Field(haxe.lang.Runtime.toString(DiagramToUML.constructFieldName(assoc1.links.__get(0), assoc1.links.__get(1).max)), haxe.lang.Runtime.toString(field2Type), ((java.lang.Object) (assoc1.links.__get(0).visibility) ), ((java.lang.Object) (null) )));
					}
					
				}
				
			}
			
		}
		
	}
	
	
	public static java.lang.String constructFieldName(model.Link link, java.lang.String maxCard)
	{
		//line 39 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		java.lang.String fName = link.classRole;
		//line 40 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		if (haxe.lang.Runtime.valEq(link.role, "")) 
		{
			//line 41 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			fName = ( (haxe.lang.Runtime.valEq(maxCard, "N")) ? (link.set.getPluralClassName()) : (link.set.className) );
		}
		
		//line 43 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		fName = ( haxe.lang.StringExt.charAt(fName, 0).toLowerCase() + haxe.lang.StringExt.substr(fName, 1, null) );
		//line 44 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		return fName;
	}
	
	
	public static void initConstructors(model.Diagram diagram)
	{
		//line 48 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		java.lang.Object set = diagram.iterator();
		//line 48 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(set, "hasNext", null)) )))
		{
			//line 48 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			model.Set set1 = ((model.Set) (haxe.lang.Runtime.callField(set, "next", null)) );
			//line 49 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			if (( ( set1.constructors.length == 0 ) && ((  ! (haxe.root.Std.isOfType(set1, model.Association.class))  || (((model.Association) (set1) )).isClass() )) )) 
			{
				//line 50 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				model.Method constructor = new model.Method(haxe.lang.Runtime.toString(set1.className), haxe.lang.Runtime.toString(""), ((java.lang.Object) (( (set1.isAbstract) ? (model.Field.ACCESS_PROTECTED) : (model.Field.ACCESS_PUBLIC) )) ), ((java.lang.Object) (null) ));
				//line 51 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				{
					//line 51 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					int _g = 0;
					//line 51 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					haxe.root.Array<model.Field> _g1 = DiagramToUML.retrieveConstructorFields(set1);
					//line 51 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					while (( _g < _g1.length ))
					{
						//line 51 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						model.Field field = _g1.__get(_g);
						//line 51 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						 ++ _g;
						//line 52 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						constructor.params.push(new model.Field(haxe.lang.Runtime.toString(field.className), haxe.lang.Runtime.toString(field.classType), ((java.lang.Object) (null) ), ((java.lang.Object) (null) )));
					}
					
				}
				
				//line 54 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				set1.constructors.push(constructor);
			}
			
		}
		
	}
	
	
	public static haxe.root.Array<model.Field> retrieveConstructorFields(model.Set set)
	{
		//line 60 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		haxe.root.Array<model.Field> fields = null;
		//line 61 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		if (( set.superset != null )) 
		{
			//line 62 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			fields = DiagramToUML.retrieveConstructorFields(set.superset);
		}
		else
		{
			//line 64 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			fields = new haxe.root.Array<model.Field>();
		}
		
		//line 66 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		{
			//line 66 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			{
				//line 66 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				haxe.root.Array<model.Field> fieldSet = set.fields;
				//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				{
					//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					int _g = 0;
					//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					while (( _g < fieldSet.length ))
					{
						//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						model.Field field = fieldSet.__get(_g);
						//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						 ++ _g;
						//line 68 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						if ( ! (field.isArray()) ) 
						{
							//line 69 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
							fields.push(field);
						}
						
					}
					
				}
				
			}
			
			//line 66 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			{
				//line 66 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				haxe.root.Array<model.Field> fieldSet1 = set.navFields;
				//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				{
					//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					int _g1 = 0;
					//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
					while (( _g1 < fieldSet1.length ))
					{
						//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						model.Field field1 = fieldSet1.__get(_g1);
						//line 67 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						 ++ _g1;
						//line 68 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
						if ( ! (field1.isArray()) ) 
						{
							//line 69 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
							fields.push(field1);
						}
						
					}
					
				}
				
			}
			
		}
		
		//line 73 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		return fields;
	}
	
	
	public static void initAccessors(model.Diagram diagram)
	{
		//line 77 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		java.lang.Object set = diagram.iterator();
		//line 77 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		while (haxe.lang.Runtime.toBool(((java.lang.Boolean) (haxe.lang.Runtime.callField(set, "hasNext", null)) )))
		{
			//line 77 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			model.Set set1 = ((model.Set) (haxe.lang.Runtime.callField(set, "next", null)) );
			//line 78 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			if ((  ! (haxe.root.Std.isOfType(set1, model.Association.class))  || (((model.Association) (set1) )).isClass() )) 
			{
				//line 79 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				haxe.root.Lambda.iter(((java.lang.Object) (set1.fields) ), ((haxe.lang.Function) (new DiagramToUML_initAccessors_79__Fun(set1)) ));
				//line 79 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				java.lang.Object __temp_expr1 = ((java.lang.Object) (null) );
				//line 80 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				haxe.root.Lambda.iter(((java.lang.Object) (set1.navFields) ), ((haxe.lang.Function) (new DiagramToUML_initAccessors_80__Fun(set1)) ));
				//line 80 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				java.lang.Object __temp_expr2 = ((java.lang.Object) (null) );
			}
			
		}
		
	}
	
	
	public static void setAccessors(model.Set set, model.Field field)
	{
		//line 86 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
		if (( field.visibility == model.Field.ACCESS_UNSET )) 
		{
			//line 87 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			field.visibility = model.Field.ACCESS_PROTECTED;
			//line 88 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			model.Method getters = new model.Method(haxe.lang.Runtime.toString(( ( "get" + haxe.lang.StringExt.charAt(field.className, 0).toUpperCase() ) + haxe.lang.StringExt.substr(field.className, 1, null) )), haxe.lang.Runtime.toString(field.classType), ((java.lang.Object) (model.Field.ACCESS_PUBLIC) ), ((java.lang.Object) (null) ));
			//line 91 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			set.accessors.push(getters);
			//line 92 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
			if (haxe.lang.Runtime.valEq(haxe.lang.StringExt.substr(field.classType, 0, 5), "Array")) 
			{
				//line 93 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				java.lang.String itemType = haxe.lang.StringExt.substr(field.classType, 6, ( field.classType.length() - 7 ));
				//line 94 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				model.Method adders = new model.Method(haxe.lang.Runtime.toString(( "add" + itemType )), haxe.lang.Runtime.toString(set.className), ((java.lang.Object) (model.Field.ACCESS_PUBLIC) ), ((java.lang.Object) (null) ));
				//line 95 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				adders.params.push(new model.Field(haxe.lang.Runtime.toString("item"), haxe.lang.Runtime.toString(itemType), ((java.lang.Object) (null) ), ((java.lang.Object) (null) )));
				//line 97 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				set.accessors.push(adders);
				//line 98 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				model.Method removers = new model.Method(haxe.lang.Runtime.toString(( "remove" + itemType )), haxe.lang.Runtime.toString(set.className), ((java.lang.Object) (model.Field.ACCESS_PUBLIC) ), ((java.lang.Object) (null) ));
				//line 99 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				removers.params.push(new model.Field(haxe.lang.Runtime.toString("item"), haxe.lang.Runtime.toString(itemType), ((java.lang.Object) (null) ), ((java.lang.Object) (null) )));
				//line 101 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				set.accessors.push(removers);
			}
			else
			{
				//line 103 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				model.Method setters = new model.Method(haxe.lang.Runtime.toString(( ( "set" + haxe.lang.StringExt.charAt(field.className, 0).toUpperCase() ) + haxe.lang.StringExt.substr(field.className, 1, null) )), haxe.lang.Runtime.toString(field.classType), ((java.lang.Object) (model.Field.ACCESS_PUBLIC) ), ((java.lang.Object) (null) ));
				//line 105 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				setters.params.push(new model.Field(haxe.lang.Runtime.toString(field.className), haxe.lang.Runtime.toString(field.classType), ((java.lang.Object) (null) ), ((java.lang.Object) (null) )));
				//line 107 "/home/frank/Documents/Developpements/dbconcept-0.5.0/src/transform/DiagramToUML.hx"
				set.accessors.push(setters);
			}
			
		}
		
	}
	
	
}


