示例#1
0
        public ComponentGenerator(SpringInterfaceGenerator springInterfaceGen, SpringClassGenerator springClassGen,
            SpringConfigurationGenerator springConfigGen, SpringViewGenerator springViewGen, SpringGeneratorUtil generatorUtil,
            BindingDiscoverer bindingDiscoverer, DirectoryHandler directoryHandler,
            DependencyDiscoverer dependencyDiscoverer, DataAccessFinder dataAccessFinder, JSFGenerator jSFGenerator)
        {
            this.springInterfaceGen = springInterfaceGen;
            this.springClassGen = springClassGen;
            this.springConfigGen = springConfigGen;
            this.springViewGen = springViewGen;
            this.generatorUtil = generatorUtil;

            this.bindingDiscoverer = bindingDiscoverer;
            this.directoryHandler = directoryHandler;

            this.dependencyDiscoverer = dependencyDiscoverer;
            this.dataAccessFinder = dataAccessFinder;
            this.jSFGenerator = jSFGenerator;
        }
示例#2
0
        public void Generate()
        {
            this.PrepareGeneration();
            if (this.Diagnostics.HasErrors()) return;

            var namespaces = this.Model.Instances.OfType<Namespace>();
            foreach (var ns in namespaces)
            {
                SpringClassGenerator springClassGen = new SpringClassGenerator(ns);
                SpringInterfaceGenerator springInterfaceGen = new SpringInterfaceGenerator(ns);
                SpringConfigurationGenerator springConfigGen = new SpringConfigurationGenerator(ns);
                SpringViewGenerator springViewGen = new SpringViewGenerator(ns);
                SpringGeneratorUtil generatorUtil = new SpringGeneratorUtil(ns);

                BindingDiscoverer bindingDiscoverer = new BindingDiscoverer();
                DirectoryHandler directoryHandler = new DirectoryHandler();
                DependencyDiscoverer dependencyDiscoverer = new DependencyDiscoverer(bindingDiscoverer);
                DataAccessFinder dataAccessFinder = new DataAccessFinder(bindingDiscoverer);
                JSFGenerator jSFGenerator = new JSFGenerator(springViewGen, generatorUtil, directoryHandler);
                ModelGenerator modelGenerator = new ModelGenerator(directoryHandler, springClassGen, springConfigGen, generatorUtil);

                ComponentGenerator componentGenerator =
                    new ComponentGenerator(springInterfaceGen, springClassGen, springConfigGen, springViewGen, generatorUtil,
                    bindingDiscoverer, directoryHandler, dependencyDiscoverer, dataAccessFinder, jSFGenerator);

                if (ns.Uri != null)
                {
                    List<string> modules = new List<string>();

                    List<Struct> entities = new List<Struct>();
                    foreach (Database db in ns.Declarations.OfType<Database>())
                    {
                        entities.AddRange(db.Entities);
                    }

                    List<Wire> wires = new List<Wire>();
                    foreach (Composite comppsoite in ns.Declarations.OfType<Composite>())
                    {
                        foreach (Wire wire in comppsoite.Wires)
                        {
                            wires.Add(wire);
                        }
                    }

                    Dictionary<string, string> properties = componentGenerator.GenerateComponent(ns, wires, modules);

                    if (entities.Any() || ns.Declarations.OfType<Enum>().Any())
                    {
                        modules.Add("Model");
                        modelGenerator.GenerateModelModule(ns, entities, properties);
                    }

                    // generate master pom.xml
                    if (modules.Any())
                    {
                        using (StreamWriter writer = new StreamWriter("pom.xml"))
                        {
                            writer.WriteLine(springConfigGen.GenerateMasterPom(ns, modules));
                        }
                    }
                }
            }
        }