package org.whole.lang.rdb; import org.whole.lang.builders.IBuilderOperation; import org.whole.lang.templates.AbstractTemplateFactory; public class CompleteRDBEntityMappingQuery extends AbstractTemplateFactory<org.whole.lang.queries.model.Block> { public void apply(IBuilderOperation op) { org.whole.lang.queries.builders.IQueriesBuilder b0 = (org.whole.lang.queries.builders.IQueriesBuilder) op.wGetBuilder(org.whole.lang.queries.reflect.QueriesLanguageKit.URI); b0.Block_(23); b0.QueryDeclaration_(); b0.Name("setCreate"); b0.Names_(3); b0.Name("names"); b0.Name("set"); b0.Name("name"); b0._Names(); b0.Block_(3); b0.Filter_(); org.whole.lang.commons.builders.ICommonsBuilder b1 = (org.whole.lang.commons.builders.ICommonsBuilder) op.wGetBuilder(org.whole.lang.commons.reflect.CommonsLanguageKit.URI); b1.SameStageFragment_(); org.whole.lang.workflows.builders.IWorkflowsBuilder b2 = (org.whole.lang.workflows.builders.IWorkflowsBuilder) op.wGetBuilder(org.whole.lang.workflows.reflect.WorkflowsLanguageKit.URI); b2.CreateJavaClassInstance_(); b2.Text("create a new hash set"); b1.Resolver(); b1.Resolver(); b2.StringLiteral("java.util.HashSet"); b2.StringLiteral("HashSet()"); b1.Resolver(); b2._CreateJavaClassInstance(); b1._SameStageFragment(); b0.VariableTest("set"); b0._Filter(); b0.For_(); b0.Path_(2); b0.VariableRefStep("names"); b0.Filter_(); b0.ChildStep(); b0.VariableTest("name"); b0._Filter(); b0._Path(); b0.Path_(2); b0.VariableRefStep("set"); b0.Call_(); b0.Name("setAdd"); b0.Expressions_(1); b0.VariableRefStep("name"); b0._Expressions(); b0._Call(); b0._Path(); b0._For(); b0.VariableRefStep("set"); b0._Block(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("setAdd"); b0.Names_(2); b0.Name("name"); b0.Name("string"); b0._Names(); b1.SameStageFragment_(); b2.Sequence_(); b2.Text("sequence"); b2.FlowObjects_(2); b2.InvokeJavaInstanceMethod_(); b2.Text("convert name to string"); b2.Variable("string"); b2.Variable("name"); b1.Resolver(); b2.StringLiteral("org.whole.lang.model.IEntity"); b2.StringLiteral("wStringValue()"); b1.Resolver(); b2._InvokeJavaInstanceMethod(); b2.InvokeJavaInstanceMethod_(); b2.Text("add string to set"); b1.Resolver(); b2.Variable("self"); b1.Resolver(); b2.StringLiteral("java.util.Set"); b2.StringLiteral("add(java.lang.Object)"); b2.Expressions_(1); b2.Variable("string"); b2._Expressions(); b2._InvokeJavaInstanceMethod(); b2._FlowObjects(); b2._Sequence(); b1._SameStageFragment(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("setContains"); b0.Names_(2); b0.Name("name"); b0.Name("string"); b0._Names(); b1.SameStageFragment_(); b2.Sequence_(); b2.Text("sequence"); b2.FlowObjects_(2); b2.InvokeJavaInstanceMethod_(); b2.Text("convert name to string"); b2.Variable("string"); b2.Variable("name"); b1.Resolver(); b2.StringLiteral("org.whole.lang.model.IEntity"); b2.StringLiteral("wStringValue()"); b1.Resolver(); b2._InvokeJavaInstanceMethod(); b2.InvokeJavaInstanceMethod_(); b2.Text("set contains string?"); b1.Resolver(); b2.Variable("self"); b1.Resolver(); b2.StringLiteral("java.util.Set"); b2.StringLiteral("contains(java.lang.Object)"); b2.Expressions_(1); b2.Variable("string"); b2._Expressions(); b2._InvokeJavaInstanceMethod(); b2._FlowObjects(); b2._Sequence(); b1._SameStageFragment(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("setClone"); b0.Names_(1); b0.Name("set"); b0._Names(); b1.SameStageFragment_(); b2.CreateJavaClassInstance_(); b2.Text("create a new hash set"); b1.Resolver(); b1.Resolver(); b2.StringLiteral("java.util.HashSet"); b2.StringLiteral("HashSet(java.util.Collection)"); b2.Expressions_(1); b2.Variable("set"); b2._Expressions(); b2._CreateJavaClassInstance(); b1._SameStageFragment(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("mapCreate"); b1.Resolver(); b1.SameStageFragment_(); b2.CreateJavaClassInstance_(); b2.Text("create a new hash map"); b1.Resolver(); b1.Resolver(); b2.StringLiteral("java.util.HashMap"); b2.StringLiteral("HashMap()"); b1.Resolver(); b2._CreateJavaClassInstance(); b1._SameStageFragment(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("mapPut"); b0.Names_(4); b0.Name("name"); b0.Name("value"); b0.Name("nameString"); b0.Name("valueString"); b0._Names(); b1.SameStageFragment_(); b2.Sequence_(); b2.Text("sequence"); b2.FlowObjects_(3); b2.InvokeJavaInstanceMethod_(); b2.Text("convert name to string"); b2.Variable("nameString"); b2.Variable("name"); b1.Resolver(); b2.StringLiteral("org.whole.lang.model.IEntity"); b2.StringLiteral("wStringValue()"); b1.Resolver(); b2._InvokeJavaInstanceMethod(); b2.InvokeJavaInstanceMethod_(); b2.Text("convert value to string"); b2.Variable("valueString"); b2.Variable("value"); b1.Resolver(); b2.StringLiteral("org.whole.lang.model.IEntity"); b2.StringLiteral("wStringValue()"); b1.Resolver(); b2._InvokeJavaInstanceMethod(); b2.InvokeJavaInstanceMethod_(); b2.Text("put mapping"); b1.Resolver(); b2.Variable("self"); b1.Resolver(); b2.StringLiteral("java.util.Map"); b2.StringLiteral("put(java.lang.Object, java.lang.Object)"); b2.Expressions_(2); b2.Variable("nameString"); b2.Variable("valueString"); b2._Expressions(); b2._InvokeJavaInstanceMethod(); b2._FlowObjects(); b2._Sequence(); b1._SameStageFragment(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("mapGet"); b0.Names_(2); b0.Name("name"); b0.Name("nameString"); b0._Names(); b1.SameStageFragment_(); b2.Sequence_(); b2.Text("sequence"); b2.FlowObjects_(2); b2.InvokeJavaInstanceMethod_(); b2.Text("convert name to string"); b2.Variable("nameString"); b2.Variable("name"); b1.Resolver(); b2.StringLiteral("org.whole.lang.model.IEntity"); b2.StringLiteral("wStringValue()"); b1.Resolver(); b2._InvokeJavaInstanceMethod(); b2.InvokeJavaInstanceMethod_(); b2.Text("get mapping"); b1.Resolver(); b2.Variable("self"); b1.Resolver(); b2.StringLiteral("java.util.Map"); b2.StringLiteral("get(java.lang.Object)"); b2.Expressions_(1); b2.Variable("nameString"); b2._Expressions(); b2._InvokeJavaInstanceMethod(); b2._FlowObjects(); b2._Sequence(); b1._SameStageFragment(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("toEntityName"); b0.Names_(1); b0.Name("name"); b0._Names(); b0.Block_(2); b0.Filter_(); b0.SelfStep(); b0.VariableTest("name"); b0._Filter(); b2.InvokeJavaClassMethod_(); b2.Text("to upper cap"); b1.Resolver(); b1.Resolver(); b2.StringLiteral("org.whole.lang.util.StringUtils"); b2.StringLiteral("toUpperCap(java.lang.String)"); b2.Expressions_(1); b2.Variable("name"); b2._Expressions(); b2._InvokeJavaClassMethod(); b0._Block(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("toDataEntityName"); b0.Names_(2); b0.Name("enumValue"); b0.Name("enumValueName"); b0._Names(); b0.Block_(3); b0.Filter_(); b0.SelfStep(); b0.VariableTest("enumValue"); b0._Filter(); b0.Filter_(); b2.InvokeJavaInstanceMethod_(); b2.Text("get enum value name"); b1.Resolver(); b2.Variable("enumValue"); b1.Resolver(); b2.StringLiteral("org.whole.lang.model.EnumValue"); b2.StringLiteral("getName()"); b1.Resolver(); b2._InvokeJavaInstanceMethod(); b0.VariableTest("enumValueName"); b0._Filter(); b0.Call_(); b0.Name("toEntityName"); b0.Expressions_(1); b2.InvokeJavaInstanceMethod_(); b2.Text("enum value name to lower case"); b1.Resolver(); b2.Variable("enumValueName"); b1.Resolver(); b2.StringLiteral("java.lang.String"); b2.StringLiteral("toLowerCase()"); b1.Resolver(); b2._InvokeJavaInstanceMethod(); b0._Expressions(); b0._Call(); b0._Block(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("toFeatureName"); b0.Names_(2); b0.Name("name"); b0.Name("lowerPrefixName"); b0._Names(); b0.Block_(2); b0.Filter_(); b0.SelfStep(); b0.VariableTest("name"); b0._Filter(); b2.InvokeJavaClassMethod_(); b2.Text("to lower prefix"); b1.Resolver(); b1.Resolver(); b2.StringLiteral("org.whole.lang.util.StringUtils"); b2.StringLiteral("toLowerPrefix(java.lang.String)"); b2.Expressions_(1); b2.Variable("name"); b2._Expressions(); b2._InvokeJavaClassMethod(); b0._Block(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("fngCreate"); b0.Names_(1); b0.Name("names"); b0._Names(); b0.Block_(2); b0.Filter_(); b0.Call_(); b0.Name("setCreate"); b1.Resolver(); b0._Call(); b0.VariableTest("names"); b0._Filter(); b1.SameStageFragment_(); b2.CreateJavaClassInstance_(); b2.Text("create a new fresh name generator"); b1.Resolver(); b1.Resolver(); b2.StringLiteral("org.whole.lang.util.FreshNameGenerator"); b2.StringLiteral("FreshNameGenerator(java.util.Collection)"); b2.Expressions_(1); b2.Variable("names"); b2._Expressions(); b2._CreateJavaClassInstance(); b1._SameStageFragment(); b0._Block(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("fngNext"); b0.Names_(1); b0.Name("name"); b0._Names(); b1.SameStageFragment_(); b2.InvokeJavaInstanceMethod_(); b2.Text("next fresh name"); b1.Resolver(); b2.Variable("self"); b1.Resolver(); b2.StringLiteral("org.whole.lang.util.FreshNameGenerator"); b2.StringLiteral("nextFreshName(java.lang.String)"); b2.Expressions_(1); b2.Variable("name"); b2._Expressions(); b2._InvokeJavaInstanceMethod(); b1._SameStageFragment(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("updateCollidingNames"); b0.Names_(3); b0.Name("name"); b0.Name("names"); b0.Name("collisions"); b0._Names(); b0.Block_(2); b0.Path_(2); b0.Choose_(2); b0.If_(); b0.ExpressionTest_(); b0.Singleton_(); b0.Path_(2); b0.VariableRefStep("names"); b0.Call_(); b0.Name("setContains"); b0.Expressions_(1); b0.VariableRefStep("name"); b0._Expressions(); b0._Call(); b0._Path(); b0._Singleton(); b0._ExpressionTest(); b0.VariableRefStep("collisions"); b0._If(); b0.Do_(); b0.VariableRefStep("names"); b0._Do(); b0._Choose(); b0.Call_(); b0.Name("setAdd"); b0.Expressions_(1); b0.VariableRefStep("name"); b0._Expressions(); b0._Call(); b0._Path(); b0.SelfStep(); b0._Block(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("updateWithFreshEntityName"); b0.Names_(4); b0.Name("name"); b0.Name("fng"); b0.Name("names"); b0.Name("collisions"); b0._Names(); b0.Block_(2); b0.PointwiseUpdate_(); b0.SelfStep(); b0.Choose_(2); b0.If_(); b0.ExpressionTest_(); b0.Singleton_(); b0.Path_(2); b0.VariableRefStep("collisions"); b0.Call_(); b0.Name("setContains"); b0.Expressions_(1); b0.VariableRefStep("name"); b0._Expressions(); b0._Call(); b0._Path(); b0._Singleton(); b0._ExpressionTest(); b0.Path_(2); b0.VariableRefStep("fng"); b0.Call_(); b0.Name("fngNext"); b0.Expressions_(1); b0.VariableRefStep("name"); b0._Expressions(); b0._Call(); b0._Path(); b0._If(); b0.Do_(); b0.VariableRefStep("name"); b0._Do(); b0._Choose(); b0._PointwiseUpdate(); b0.SelfStep(); b0._Block(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("updateDatatypesMap"); b0.Names_(5); b0.Name("name"); b0.Name("fng"); b0.Name("names"); b0.Name("datatypesMap"); b0.Name("entityName"); b0._Names(); b0.Block_(2); b0.Path_(2); b0.VariableRefStep("datatypesMap"); b0.Call_(); b0.Name("mapPut"); b0.Expressions_(2); b0.VariableRefStep("name"); b0.Path_(2); b0.VariableRefStep("fng"); b0.Call_(); b0.Name("fngNext"); b0.Expressions_(1); b0.VariableRefStep("name"); b0._Expressions(); b0._Call(); b0._Path(); b0._Expressions(); b0._Call(); b0._Path(); b0.SelfStep(); b0._Block(); b0._QueryDeclaration(); b0.QueryDeclaration_(); b0.Name("updateTablesMapping"); b0.Names_(7); b0.Name("entityNames"); b0.Name("entityNameCollisions"); b0.Name("initialEntityNames"); b0.Name("fng"); b0.Name("tableName"); b0.Name("featureNames"); b0.Name("columnName"); b0._Names(); b0.Block_(9); b0.Filter_(); b0.Call_(); b0.Name("setCreate"); b0.Expressions_(1); b0.Union_(); b0.Expressions_(2); b0.Path_(3); b0.FeatureStep("tables"); b0.ChildStep(); b0.Filter_(); b0.FeatureStep("entityName"); b0.KindTest("DATA"); b0._Filter(); b0._Path(); b0.Path_(5); b0.FeatureStep("tables"); b0.ChildStep(); b0.FeatureStep("columns"); b0.ChildStep(); b0.Filter_(); b0.FeatureStep("featureType"); b0.KindTest("DATA"); b0._Filter(); b0._Path(); b0._Expressions(); b1.Resolver(); b0._Union(); b0._Expressions(); b0._Call(); b0.VariableTest("entityNames"); b0._Filter(); b0.Filter_(); b0.Call_(); b0.Name("setCreate"); b1.Resolver(); b0._Call(); b0.VariableTest("entityNameCollisions"); b0._Filter(); b0.Filter_(); b0.Call_(); b0.Name("setClone"); b0.Expressions_(1); b0.VariableRefStep("entityNames"); b0._Expressions(); b0._Call(); b0.VariableTest("initialEntityNames"); b0._Filter(); b0.Path_(4); b0.FeatureStep("tables"); b0.ChildStep(); b0.FeatureStep("name"); b0.Call_(); b0.Name("updateCollidingNames"); b0.Expressions_(3); b0.Call_(); b0.Name("toEntityName"); b1.Resolver(); b0._Call(); b0.VariableRefStep("initialEntityNames"); b0.VariableRefStep("entityNameCollisions"); b0._Expressions(); b0._Call(); b0._Path(); b0.Filter_(); b0.Call_(); b0.Name("mapCreate"); b1.Resolver(); b0._Call(); b0.VariableTest("datatypesMap"); b0._Filter(); b0.Filter_(); b0.Call_(); b0.Name("fngCreate"); b0.Expressions_(1); b0.VariableRefStep("entityNames"); b0._Expressions(); b0._Call(); b0.VariableTest("fng"); b0._Filter(); b0.Path_(6); b0.FeatureStep("tables"); b0.ChildStep(); b0.FeatureStep("columns"); b0.ChildStep(); b0.Filter_(); b0.FeatureStep("type"); b0.DistinctTest_(); b1.Resolver(); b0._DistinctTest(); b0._Filter(); b0.Call_(); b0.Name("updateDatatypesMap"); b0.Expressions_(4); b0.Call_(); b0.Name("toDataEntityName"); b1.Resolver(); b0._Call(); b0.VariableRefStep("fng"); b0.VariableRefStep("entityNames"); b0.VariableRefStep("datatypesMap"); b0._Expressions(); b0._Call(); b0._Path(); b0.Path_(3); b0.FeatureStep("tables"); b0.Filter_(); b0.ChildStep(); b0.ExpressionTest_(); b0.Filter_(); b0.FeatureStep("name"); b0.VariableTest("tableName"); b0._Filter(); b0._ExpressionTest(); b0._Filter(); b0.Sequence_(3); b0.Filter_(); b0.Call_(); b0.Name("fngCreate"); b0.Expressions_(1); b0.Call_(); b0.Name("setCreate"); b0.Expressions_(1); b0.Union_(); b0.Expressions_(1); b0.Path_(3); b0.FeatureStep("columns"); b0.ChildStep(); b0.Filter_(); b0.FeatureStep("featureName"); b0.KindTest("DATA"); b0._Filter(); b0._Path(); b0._Expressions(); b1.Resolver(); b0._Union(); b0._Expressions(); b0._Call(); b0._Expressions(); b0._Call(); b0.VariableTest("featuresFng"); b0._Filter(); b0.Path_(2); b0.Filter_(); b0.FeatureStep("entityName"); b0.KindTest("RESOLVER"); b0._Filter(); b0.Call_(); b0.Name("updateWithFreshEntityName"); b0.Expressions_(4); b0.Call_(); b0.Name("toEntityName"); b0.Expressions_(1); b0.VariableRefStep("tableName"); b0._Expressions(); b0._Call(); b0.VariableRefStep("fng"); b0.VariableRefStep("entityNames"); b0.VariableRefStep("entityNameCollisions"); b0._Expressions(); b0._Call(); b0._Path(); b0.Path_(3); b0.FeatureStep("columns"); b0.ChildStep(); b0.Sequence_(4); b0.Filter_(); b0.FeatureStep("name"); b0.VariableTest("columnName"); b0._Filter(); b0.Filter_(); b0.FeatureStep("type"); b0.VariableTest("columnType"); b0._Filter(); b0.PointwiseUpdate_(); b0.Filter_(); b0.FeatureStep("featureName"); b0.KindTest("RESOLVER"); b0._Filter(); b0.Path_(2); b0.VariableRefStep("featuresFng"); b0.Call_(); b0.Name("fngNext"); b0.Expressions_(1); b0.Call_(); b0.Name("toFeatureName"); b0.Expressions_(1); b0.VariableRefStep("columnName"); b0._Expressions(); b0._Call(); b0._Expressions(); b0._Call(); b0._Path(); b0._PointwiseUpdate(); b0.PointwiseUpdate_(); b0.Filter_(); b0.FeatureStep("featureType"); b0.KindTest("RESOLVER"); b0._Filter(); b0.Path_(2); b0.VariableRefStep("datatypesMap"); b0.Call_(); b0.Name("mapGet"); b0.Expressions_(1); b0.Call_(); b0.Name("toDataEntityName"); b0.Expressions_(1); b0.VariableRefStep("columnType"); b0._Expressions(); b0._Call(); b0._Expressions(); b0._Call(); b0._Path(); b0._PointwiseUpdate(); b0._Sequence(); b0._Path(); b0._Sequence(); b0._Path(); b0.SelfStep(); b0._Block(); b0._QueryDeclaration(); b1.SameStageFragment_(); b2.InvokeOperation_(); b2.Text("normalize"); b2.Variable("self"); b2.Operation("NORMALIZER"); b1.Resolver(); b2._InvokeOperation(); b1._SameStageFragment(); b0.Filter_(); b0.Call_(); b0.Name("setCreate"); b0.Expressions_(1); b0.Union_(); b0.Expressions_(1); b0.Path_(3); b0.FeatureStep("schemas"); b0.ChildStep(); b0.Filter_(); b0.FeatureStep("modelName"); b0.KindTest("DATA"); b0._Filter(); b0._Path(); b0._Expressions(); b1.Resolver(); b0._Union(); b0._Expressions(); b0._Call(); b0.VariableTest("modelNames"); b0._Filter(); b0.Filter_(); b0.Call_(); b0.Name("setCreate"); b1.Resolver(); b0._Call(); b0.VariableTest("modelNameCollisions"); b0._Filter(); b0.Filter_(); b0.Call_(); b0.Name("setClone"); b0.Expressions_(1); b0.VariableRefStep("modelNames"); b0._Expressions(); b0._Call(); b0.VariableTest("initialModelNames"); b0._Filter(); b0.Path_(3); b0.FeatureStep("schemas"); b0.ChildStep(); b0.Sequence_(2); b0.Path_(2); b0.FeatureStep("name"); b0.Call_(); b0.Name("updateCollidingNames"); b0.Expressions_(3); b0.Call_(); b0.Name("toEntityName"); b1.Resolver(); b0._Call(); b0.VariableRefStep("initialModelNames"); b0.VariableRefStep("modelNameCollisions"); b0._Expressions(); b0._Call(); b0._Path(); b0.Call_(); b0.Name("updateTablesMapping"); b1.Resolver(); b0._Call(); b0._Sequence(); b0._Path(); b0.Path_(4); b0.FeatureStep("schemas"); b0.Filter_(); b0.ChildStep(); b0.And_(2); b0.ExpressionTest_(); b0.Filter_(); b0.Call_(); b0.Name("fngCreate"); b0.Expressions_(1); b0.VariableRefStep("modelNames"); b0._Expressions(); b0._Call(); b0.VariableTest("fng"); b0._Filter(); b0._ExpressionTest(); b0.ExpressionTest_(); b0.Filter_(); b0.FeatureStep("name"); b0.VariableTest("schemaName"); b0._Filter(); b0._ExpressionTest(); b0._And(); b0._Filter(); b0.Filter_(); b0.FeatureStep("modelName"); b0.KindTest("RESOLVER"); b0._Filter(); b0.Call_(); b0.Name("updateWithFreshEntityName"); b0.Expressions_(4); b0.VariableRefStep("schemaName"); b0.VariableRefStep("fng"); b0.VariableRefStep("modelNames"); b0.VariableRefStep("modelNameCollisions"); b0._Expressions(); b0._Call(); b0._Path(); b0.SelfStep(); b0._Block(); } }