Exemplo n.º 1
0
        public static JavaClass CreateBoClass(DDLTable table, JavaBeanConfig javaBeanConfig, bool createVo)
        {
            JavaClass javaClass = new JavaClass(javaBeanConfig.PackageName, table, javaBeanConfig);



            table.Columns.ForEach(c =>
            {
                if (false == c.Validate())
                {
                    return;
                }
                FieldBase filedBase;
                javaClass.Fields.Add(filedBase = FieldBase.Create(c));
                filedBase.FiledTypeStr         = GetFildTypeStr(filedBase);
            });

            javaClass.Desc = table.Desc;

            javaClass.ClassName = table.ClassName.Length == 0 ? CodeUtil.GetClassName(javaBeanConfig, table.TableName) : table.ClassName;

            if (createVo)
            {
                javaClass.JavaVoClass = JavaClass.CreateVo(javaBeanConfig.VOPackageName, javaClass);
            }
            return(javaClass);
        }
Exemplo n.º 2
0
        public void DDLToJavaBeanTest()
        {
            javaBeanConfig               = new JavaBeanConfig();
            javaBeanConfig.DDLConfig     = ddlConfig;
            javaBeanConfig.PackageName   = "com.wintop.third.cbs.bean";
            javaBeanConfig.VOPackageName = "com.wintop.third.cbs.vo";
            javaBeanConfig.JavaDiretory  = @"D:\fgq\work\code\wintop-third-eas\bean\third-cbs-bean\src\main\java";
            javaBeanConfig.OmmitPrefix   = "ODS";

            JavaGenerator toJavaBean = new JavaGenerator();

            toJavaBean.GenerateBean(javaBeanConfig);
        }
Exemplo n.º 3
0
        public void GenerateBean(JavaBeanConfig javaBeanConfig)
        {
            initDefault();

            //IRazorEngineCompiledTemplate template = razorEngine.Compile(templateContent);// "Hello @Model.Name");

            javaBeanConfig.DDLConfig.Prepare();



            string beanRootDir = CodeUtil.PrepareCodeRoot(javaBeanConfig.JavaDiretory, javaBeanConfig.PackageName);
            string voRootDir   = CodeUtil.PrepareCodeRoot(javaBeanConfig.JavaDiretory, javaBeanConfig.VOPackageName);


            string result = String.Empty;

            javaBeanConfig.DDLConfig.Tables.ForEach(t =>
            {
                result = beanTemplate.Run(instance =>
                {
                    javaBeanConfig.Table = t;
                    t.CreatedClass       = JavaClass.CreateBoClass(t, javaBeanConfig, true);
                    instance.Model       = t.CreatedClass as JavaClass;
                });
                Console.WriteLine(result);
                string filePath = beanRootDir + Path.DirectorySeparatorChar + t.CreatedClass.ClassName + ".java";

                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                File.WriteAllText(filePath, result, new UTF8Encoding(false));


                result = beanTemplate.Run(instance =>
                {
                    instance.Model = (t.CreatedClass as JavaClass).JavaVoClass;
                });
                Console.WriteLine(result);
                filePath = voRootDir + Path.DirectorySeparatorChar + (t.CreatedClass as JavaClass).JavaVoClass.ClassName + ".java";
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                File.WriteAllText(filePath, result, new UTF8Encoding(false));
            });
        }
Exemplo n.º 4
0
 public JavaClass(string packageName, DDLTable ddLTable, JavaBeanConfig javaBeanConfig) : this(packageName, ddLTable)
 {
     JavaBeanConfig = javaBeanConfig;
 }