Beispiel #1
0
        public override void Execute(Componete componente)
        {
            /// DomainPackage
            var domainClass = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:ServiceClass").ToList();

            foreach (var _class in domainClass)
            {
                Componete generalization = null;
                var       tags_class     = new Dictionary <string, string>();
                tags_class.Add("FW_CLASS_NAME", _class.name);

                if (_class.Componentes != null)
                {
                    generalization = _class.Componentes.Where(x => x.tag == "generalization").FirstOrDefault();

                    if (_class.Componentes.Any(x => x.xsi_type == "frameweb:ServiceMethod" && x.isAbstract))
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public abstract");
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public");
                    }

                    if (generalization != null)
                    {
                        var _generalization     = generalization.generalizationSet.Split('/');
                        var _str_generalization = _generalization[_generalization.Length - 1];
                        if (_str_generalization.Contains('.'))
                        {
                            _str_generalization = _str_generalization.Split('.')[0];
                        }
                        tags_class.Add("FW_EXTENDS", "extends " + _str_generalization);
                    }
                    else
                    {
                        tags_class.Add("FW_EXTENDS", string.Empty);
                    }


                    var _class_propeties = _class.Componentes.Where(x => x.xsi_type == "frameweb:ServiceAttribute").ToList();

                    string properties = string.Empty;
                    foreach (var propertie in _class_propeties)
                    {
                        var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + propertie.getXsiTypeFile());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", propertie.GetTypeDomainAttribute());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(propertie.name));
                        text_parameter = text_parameter.Replace("FW_PARAMETER", propertie.name);
                        text_parameter = text_parameter.Replace("FW_VISIBILITY", propertie.visibility);

                        properties += text_parameter;
                    }

                    tags_class.Add("FW_CLASS_PARAMETERS", properties);

                    var class_methods = _class.Componentes.Where(x => x.xsi_type == "frameweb:ServiceMethod").ToList();

                    string methods = string.Empty;
                    foreach (var method in class_methods)
                    {
                        string text_method;
                        if (method.isAbstract)
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                        }
                        else
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                        }

                        var    methodParameters       = method.Componentes.Where(x => x.tag == "ownedParameter").ToList();
                        string text_method_parameters = string.Empty;
                        if (methodParameters != null && methodParameters.Count() > 0)
                        {
                            foreach (var methodParameter in methodParameters)
                            {
                                text_method_parameters += string.Format("{0} {1},", methodParameter.getType(), methodParameter.name);
                            }

                            text_method_parameters = text_method_parameters.Substring(0, text_method_parameters.Length - 1);
                        }

                        text_method = text_method.Replace("FW_METHOD_PARAMETERS", text_method_parameters);

                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                        methods += text_method;
                    }

                    tags_class.Add("FW_CLASS_METHOD", methods);
                }

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _class.getXsiTypeFile());
                foreach (var item in tags_class)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _class.name + config.ext_class), text);
            }

            //SECURED SERVICE CLASSES
            var securedServiceClasses = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:AuthServiceClass").ToList();

            foreach (var _class in securedServiceClasses)
            {
                Componete generalization = null;
                var       tags_class     = new Dictionary <string, string>();
                tags_class.Add("FW_CLASS_NAME", _class.name);
                tags_class.Add("FW_PERM_NAME_APP_CLASS", _class.permissionName);
                if (_class.Componentes != null)
                {
                    generalization = _class.Componentes.Where(x => x.tag == "generalization").FirstOrDefault();

                    if (_class.Componentes.Any(x => x.xsi_type == "frameweb:ServiceMethod" && x.isAbstract))
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public abstract");
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public");
                    }

                    if (generalization != null)
                    {
                        var _generalization     = generalization.generalizationSet.Split('/');
                        var _str_generalization = _generalization[_generalization.Length - 1];
                        if (_str_generalization.Contains('.'))
                        {
                            _str_generalization = _str_generalization.Split('.')[0];
                        }
                        tags_class.Add("FW_EXTENDS", "extends " + _str_generalization);
                    }
                    else
                    {
                        tags_class.Add("FW_EXTENDS", string.Empty);
                    }


                    var _class_propeties = _class.Componentes.Where(x => x.xsi_type == "frameweb:ServiceAttribute").ToList();

                    string properties = string.Empty;
                    foreach (var propertie in _class_propeties)
                    {
                        var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + propertie.getXsiTypeFile());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", propertie.GetTypeDomainAttribute());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(propertie.name));
                        text_parameter = text_parameter.Replace("FW_PARAMETER", propertie.name);
                        text_parameter = text_parameter.Replace("FW_VISIBILITY", propertie.visibility);

                        properties += text_parameter;
                    }

                    tags_class.Add("FW_CLASS_PARAMETERS", properties);

                    var class_methods = _class.Componentes.Where(x => x.xsi_type == "frameweb:ServiceMethod").ToList();

                    string methods = string.Empty;
                    foreach (var method in class_methods)
                    {
                        string text_method;
                        if (method.isAbstract)
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                        }
                        else
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                        }

                        var    methodParameters       = method.Componentes.Where(x => x.tag == "ownedParameter").ToList();
                        string text_method_parameters = string.Empty;
                        if (methodParameters != null && methodParameters.Count() > 0)
                        {
                            foreach (var methodParameter in methodParameters)
                            {
                                text_method_parameters += string.Format("{0} {1},", methodParameter.getType(), methodParameter.name);
                            }

                            text_method_parameters = text_method_parameters.Substring(0, text_method_parameters.Length - 1);
                        }

                        text_method = text_method.Replace("FW_METHOD_PARAMETERS", text_method_parameters);

                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                        methods += text_method;
                    }

                    //SECURED METHOD
                    var secured_class_methods = _class.Componentes.Where(x => x.xsi_type == "frameweb:AuthServiceMethod").ToList();

                    methods = string.Empty;
                    foreach (var method in secured_class_methods)
                    {
                        string text_method;
                        if (method.isAbstract)
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                        }
                        else
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                        }

                        var    methodParameters       = method.Componentes.Where(x => x.tag == "ownedParameter").ToList();
                        string text_method_parameters = string.Empty;
                        if (methodParameters != null && methodParameters.Count() > 0)
                        {
                            foreach (var methodParameter in methodParameters)
                            {
                                text_method_parameters += string.Format("{0} {1},", methodParameter.getType(), methodParameter.name);
                            }

                            text_method_parameters = text_method_parameters.Substring(0, text_method_parameters.Length - 1);
                        }

                        text_method = text_method.Replace("FW_METHOD_PARAMETERS", text_method_parameters);

                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);
                        text_method = text_method.Replace("FW_PERM_NAME_APP_METHOD", method.permissionName);

                        methods += text_method;
                    }

                    tags_class.Add("FW_CLASS_METHOD", methods);
                }

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _class.getXsiTypeFile());
                foreach (var item in tags_class)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _class.name + config.ext_class), text);
            }

            // INTERFACE
            var interfaces = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:ServiceInterface").ToList();

            foreach (var _interface in interfaces)
            {
                var tags_interface = new Dictionary <string, string>();
                tags_interface.Add("FW_INTERFACE_NAME", _interface.name);

                var realizations = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:ServiceRealization" && y.supplier.EndsWith(_interface.name)).ToList();


                foreach (var realization in realizations)
                {
                    string methods = string.Empty;
                    var    list_class_realization = domainClass.Where(x => x.name == realization.getClient()).ToList();
                    foreach (var class_realization in list_class_realization)
                    {
                        var class_methods = class_realization.Componentes.Where(x => x.xsi_type == "frameweb:ServiceMethod").ToList();


                        foreach (var method in class_methods)
                        {
                            string text_method = "FW_METHOD_RETURN_TYPE FW_METHOD_NAME(FW_METHOD_PARAMETERS);\n";

                            var    methodParameters       = method.Componentes.Where(x => x.tag == "ownedParameter").ToList();
                            string text_method_parameters = string.Empty;
                            if (methodParameters != null && methodParameters.Count() > 0)
                            {
                                foreach (var methodParameter in methodParameters)
                                {
                                    text_method_parameters += string.Format("{0} {1},", methodParameter.getType(), methodParameter.name);
                                }

                                text_method_parameters = text_method_parameters.Substring(0, text_method_parameters.Length - 1);
                            }

                            text_method = text_method.Replace("FW_METHOD_PARAMETERS", text_method_parameters);
                            text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                            text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                            methods += text_method;
                        }
                    }
                    tags_interface.Add("FW_INTERFACE_METHOD", methods);
                }

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _interface.getXsiTypeFile());
                foreach (var item in tags_interface)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _interface.name + config.ext_class), text);

                realizations = null;

                //
            }
        }
        private void CreateClasses(Component componente)
        {
            //PersistencePackage

            var package_persistences = componente.Components.Where(y => y.xsi_type == "frameweb:PersistencePackage").ToList();

            foreach (var package_persistence in package_persistences)
            {
                var dir_output_class_package = this.BuildDirectoryStructures(Config.dir_output_class, package_persistence.name);


                var daoClasses = package_persistence.Components.Where(y => y.xsi_type == "frameweb:DAOClass").ToList();


                foreach (var _class in daoClasses)
                {
                    var tags_class = new Dictionary <string, string>();
                    tags_class.Add("FW_CLASS_NAME", _class.name);


                    Component generalization = _class.Components.Where(x => x.tag == "generalization").FirstOrDefault();

                    if (_class.isAbstract)
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public abstract");
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public");
                    }


                    if (generalization != null)
                    {
                        var _generalization     = generalization.generalizationSet.Split('/');
                        var _str_generalization = _generalization[_generalization.Length - 1];
                        if (_str_generalization.Contains('.'))
                        {
                            _str_generalization = _str_generalization.Split('.')[0];
                        }
                        tags_class.Add("FW_EXTENDS", "extends " + _str_generalization);
                    }
                    else
                    {
                        tags_class.Add("FW_EXTENDS", string.Empty);
                    }

                    Component realization = componente.Components.SelectMany(x => x.Components).Where(y => y.xsi_type == "frameweb:DAORealization" && y.getClient() == _class.name).FirstOrDefault();


                    if (realization != null)
                    {
                        tags_class.Add("FW_IMPLEMENTS", "implements " + realization.getSupplier());

                        Component daoInterface = componente.Components.SelectMany(x => x.Components).Where(y => y.xsi_type == "frameweb:DAOInterface" && y.name == realization.getSupplier()).FirstOrDefault();

                        if (daoInterface != null)
                        {
                            tags_class.Add("FW_CLASS_IMPLEMENTS_INFIX", "implements " + realization.getSupplier());
                        }
                        else
                        {
                            tags_class.Add("FW_CLASS_IMPLEMENTS_INFIX", "set infix on interface");
                        }
                    }
                    else
                    {
                        tags_class.Add("FW_IMPLEMENTS", string.Empty);
                    }


                    if (_class.Components != null)
                    {
                        var _class_propeties = _class.Components.Where(x => x.xsi_type == "frameweb:DAOAttribute").ToList();

                        string properties = string.Empty;
                        foreach (var propertie in _class_propeties)
                        {
                            var text_parameter = File.ReadAllText(Config.dir_template + Config.lang + Path.DirectorySeparatorChar + propertie.getXsiTypeFile());
                            text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", propertie.GetTypeDomainAttribute());
                            text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(propertie.name));
                            text_parameter = text_parameter.Replace("FW_PARAMETER", propertie.name);
                            text_parameter = text_parameter.Replace("FW_VISIBILITY", propertie.visibility);


                            properties += text_parameter;
                        }

                        tags_class.Add("FW_CLASS_PARAMETERS", properties);

                        var class_methods = _class.Components.Where(x => x.xsi_type == "frameweb:DAOMethod").ToList();

                        string methods = string.Empty;
                        foreach (var method in class_methods)
                        {
                            string text_method;
                            if (method.isAbstract)
                            {
                                text_method = File.ReadAllText(Config.dir_template + Config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                                text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                            }
                            else
                            {
                                text_method = File.ReadAllText(Config.dir_template + Config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                                text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                            }


                            //text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                            //text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                            text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", (string.IsNullOrWhiteSpace(method.GetMethodTypeDomainAttribute())) ? "void" : method.GetMethodTypeDomainAttribute());
                            text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                            if (!string.IsNullOrWhiteSpace(method.methodType))
                            {
                                text_method = text_method.Replace("FW_METHOD_RETURN", "return null;");
                            }
                            else
                            {
                                text_method = text_method.Replace("FW_METHOD_RETURN", string.Empty);
                            }


                            text_method = text_method.Replace("FW_METHOD_PARAM", method.GetMethodParameter());


                            methods += text_method;
                        }

                        tags_class.Add("FW_CLASS_METHOD", methods);
                    }

                    var text = File.ReadAllText(Config.dir_template + Config.lang + Path.DirectorySeparatorChar + _class.getXsiTypeFile());
                    foreach (var item in tags_class)
                    {
                        text = text.Replace(item.Key, item.Value);
                    }

                    File.WriteAllText(Path.Combine(dir_output_class_package, _class.name + Config.ext_class), text);
                }
            }
        }
Beispiel #3
0
        public override void Execute(Componete componente)
        {
            /// DomainPackage
            var domainClass = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:DomainClass").ToList();

            //domainClass = domainClass.Where(x => x.name == "Person").ToList();

            foreach (var _class in domainClass)
            {
                Componete generalization = null;
                var       tags_class     = new Dictionary <string, string>();
                tags_class.Add("FW_CLASS_NAME", _class.name);

                if (_class.Componentes != null)
                {
                    generalization = _class.Componentes.Where(x => x.tag == "generalization").FirstOrDefault();

                    if (_class.Componentes.Any(x => x.xsi_type == "frameweb:DomainMethod" && x.isAbstract))
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public abstract");
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public");
                    }

                    if (generalization != null)
                    {
                        var _generalization     = generalization.generalizationSet.Split('/');
                        var _str_generalization = _generalization[_generalization.Length - 1];
                        if (_str_generalization.Contains('.'))
                        {
                            _str_generalization = _str_generalization.Split('.')[0];
                        }
                        tags_class.Add("FW_EXTENDS", "extends " + _str_generalization);
                    }
                    else
                    {
                        tags_class.Add("FW_EXTENDS", string.Empty);
                    }


                    var _class_propeties = _class.Componentes.Where(x => x.xsi_type == "frameweb:DomainAttribute").ToList();

                    string properties = string.Empty;
                    foreach (var propertie in _class_propeties)
                    {
                        var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + propertie.getXsiTypeFile());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", propertie.GetTypeDomainAttribute());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(propertie.name));
                        text_parameter = text_parameter.Replace("FW_PARAMETER", propertie.name);
                        text_parameter = text_parameter.Replace("FW_VISIBILITY", propertie.visibility);

                        properties += text_parameter;
                    }

                    tags_class.Add("FW_CLASS_PARAMETERS", properties);

                    var class_methods = _class.Componentes.Where(x => x.xsi_type == "frameweb:DomainMethod").ToList();

                    string methods = string.Empty;
                    foreach (var method in class_methods)
                    {
                        string text_method;
                        if (method.isAbstract)
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                        }
                        else
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                        }


                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                        methods += text_method;
                    }

                    tags_class.Add("FW_CLASS_METHOD", methods);
                }

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _class.getXsiTypeFile());
                foreach (var item in tags_class)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _class.name + config.ext_class), text);
            }
        }
        private void CreateClasses(Componete componente)
        {
            var daoClasses = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:DAOClass").ToList();

            if (daoClasses != null && daoClasses.Count > 0)
            {
                // Copiar arquivos padrões
            }

            foreach (var _class in daoClasses)
            {
                var tags_class = new Dictionary <string, string>();
                tags_class.Add("FW_CLASS_NAME", _class.name);


                Componete generalization = _class.Componentes.Where(x => x.tag == "generalization").FirstOrDefault();


                if (generalization != null)
                {
                    var _generalization     = generalization.generalizationSet.Split('/');
                    var _str_generalization = _generalization[_generalization.Length - 1];
                    if (_str_generalization.Contains('.'))
                    {
                        _str_generalization = _str_generalization.Split('.')[0];
                    }
                    tags_class.Add("FW_EXTENDS", "extends " + _str_generalization);
                }
                else
                {
                    tags_class.Add("FW_EXTENDS", string.Empty);
                }

                Componete realization = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:DAORealization" && y.getClient() == _class.name).FirstOrDefault();


                if (realization != null)
                {
                    tags_class.Add("FW_IMPLEMENTS", "implements " + realization.getSupplier());

                    Componete daoInterface = componente.Componentes.SelectMany(x => x.Componentes).Where(y => y.xsi_type == "frameweb:DAOInterface" && y.name == realization.getSupplier()).FirstOrDefault();

                    if (daoInterface != null)
                    {
                        tags_class.Add("FW_CLASS_IMPLEMENTS_INFIX", "implements " + realization.getSupplier());
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_IMPLEMENTS_INFIX", "set infix on interface");
                    }
                }
                else
                {
                    tags_class.Add("FW_IMPLEMENTS", string.Empty);
                }


                if (_class.Componentes != null)
                {
                    if (_class.Componentes.Any(x => x.xsi_type == "frameweb:DAOMethod" && x.isAbstract))
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public abstract");
                    }
                    else
                    {
                        tags_class.Add("FW_CLASS_VISIBILITY", "public");
                    }


                    var _class_propeties = _class.Componentes.Where(x => x.xsi_type == "frameweb:DAOAttribute").ToList();

                    string properties = string.Empty;
                    foreach (var propertie in _class_propeties)
                    {
                        var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + propertie.getXsiTypeFile());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", propertie.GetTypeDomainAttribute());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(propertie.name));
                        text_parameter = text_parameter.Replace("FW_PARAMETER", propertie.name);
                        text_parameter = text_parameter.Replace("FW_VISIBILITY", propertie.visibility);

                        properties += text_parameter;
                    }

                    tags_class.Add("FW_CLASS_PARAMETERS", properties);

                    var class_methods = _class.Componentes.Where(x => x.xsi_type == "frameweb:DAOMethod").ToList();

                    string methods = string.Empty;
                    foreach (var method in class_methods)
                    {
                        string text_method;
                        if (method.isAbstract)
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + "Abstract" + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public abstract");
                        }
                        else
                        {
                            text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                            text_method = text_method.Replace("FW_METHOD_VISIBILITY", "public");
                        }


                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.GetMethodTypeDomainAttribute());
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                        methods += text_method;
                    }

                    tags_class.Add("FW_CLASS_METHOD", methods);
                }

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + _class.getXsiTypeFile());
                foreach (var item in tags_class)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, _class.name + config.ext_class), text);
            }
        }
Beispiel #5
0
        public override void Execute(Componete componente)
        {
            /// CONTROLLER
            var controllers = componente.Componentes.Where(x => x.xsi_type == "frameweb:ControllerPackage").ToList().SelectMany(x => x.Componentes).ToList();

            foreach (var controller in controllers)
            {
                if (controller.getXsiTypeFile() == "ServiceControllerAssociation.txt")
                {
                    continue;
                }

                var tags_controller = new Dictionary <string, string>();

                tags_controller.Add("FW_CLASS_NAME", controller.name);

                var frontControllerDependency = componente.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerDependency" && x.getSupplier() == controller.name).FirstOrDefault();
                tags_controller.Add("FW_BEAN_NAME", frontControllerDependency != null ? frontControllerDependency.getClient() : string.Empty);

                //tags_controller.Add("FW_BEAN_CLASS_NAME", "NNN");

                var controller_parameters = controller.Componentes.Where(x => x.xsi_type == "frameweb:IOParameter").ToList();

                string parameters = string.Empty;
                foreach (var parameter in controller_parameters)
                {
                    var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + parameter.getXsiTypeFile());
                    text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", parameter.parameterType);
                    text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(parameter.name));
                    text_parameter = text_parameter.Replace("FW_PARAMETER", parameter.name);

                    parameters += text_parameter;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_PARAMETERS", parameters);

                var controller_methods = controller.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerMethod").ToList();

                string methods = string.Empty;
                foreach (var method in controller_methods)
                {
                    var text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                    text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.methodType);
                    text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                    methods += text_method;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_METHOD", methods);

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + controller.getXsiTypeFile());
                foreach (var item in tags_controller)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, controller.name + config.ext_class), text);
            }
            /// VIEW

            var views = componente.Componentes.Where(x => x.xsi_type == "frameweb:ViewPackage").ToList().SelectMany(x => x.Componentes).ToList();

            var views_pages = views.Where(x => x.xsi_type == "frameweb:Page").ToList();

            foreach (var page in views_pages)
            {
                string body = string.Empty;

                var componentes_dentro_pagina = page.Componentes.Where(x => x.xsi_type == "frameweb:NavigationCompositionWhole").ToList();
                foreach (Componete componente_pagina in componentes_dentro_pagina)
                {
                    var comp = views.Where(x => x.name == componente_pagina.getType()).FirstOrDefault();
                    if (comp != null)
                    {
                        string body_form = string.Empty;
                        if (comp.xsi_type == "frameweb:UIComponent")// Form
                        {
                            body_form = File.ReadAllText(config.dir_template + "framework" + Path.DirectorySeparatorChar + comp.getXsiTypeFile());
                        }
                        string body_form_comp = string.Empty;
                        foreach (var item in comp.Componentes)
                        {
                            // Get file path template for component UI (input, radio, ...)
                            var field_template = File.ReadAllText(item.getXsiTypeFile());
                            field_template = field_template.Replace("FW_ID", item.name.Replace('.', '_'));
                            field_template = field_template.Replace("FW_VALUE", comp.name + "." + item.name);

                            body_form_comp += field_template;
                        }

                        body_form = body_form.Replace("FW_BODY", body_form_comp);
                        body_form = body_form.Replace("FW_ID", comp.name);
                        body     += body_form;
                    }
                }

                var text = File.ReadAllText(config.dir_template + "framework" + Path.DirectorySeparatorChar + page.getXsiTypeFile());
                text = text.Replace("FW_BODY", body);

                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_web, page.name), text);
            }

            Utilities.Log("Code generated successfully.");
        }
        public override void Execute(Component componente)
        {
            /// CONTROLLER // FrontControllerClass
            var package_controllers = componente.Components.Where(x => x.xsi_type == "frameweb:ControllerPackage").ToList();

            foreach (var package_controller in package_controllers)
            {
                var dir_output_class_package = this.BuildDirectoryStructures(Config.dir_output_class, package_controller.name);
                var class_controllers        = package_controller.Components.Where(x => x.xsi_type == "frameweb:FrontControllerClass").ToList();

                foreach (var controller in class_controllers)
                {
                    if (controller.getXsiTypeFile() == "ServiceControllerAssociation.txt" || controller.getXsiTypeFile() == "NavigationGeneralizationSet.txt")
                    {
                        continue;
                    }


                    var tags_controller = new Dictionary <string, string>();



                    //     var generalization = class_controllers.SelectMany(x => x.Components).Where(y => y.tag == "generalization").ToList();



                    Component generalization = controller.Components.Where(x => x.tag == "generalization").FirstOrDefault();

                    if (generalization != null)
                    {
                        var _generalization     = generalization.generalizationSet.Split('/');
                        var _str_generalization = _generalization[_generalization.Length - 1];
                        if (_str_generalization.Contains('.'))
                        {
                            _str_generalization = _str_generalization.Split('.')[0];
                        }
                        tags_controller.Add("FW_EXTENDS", "extends " + _str_generalization);
                    }
                    else
                    {
                        tags_controller.Add("FW_EXTENDS", string.Empty);
                    }

                    Component realization = componente.Components.SelectMany(x => x.Components).Where(y => y.xsi_type == "frameweb:NavigationRealization" && y.getClient() == controller.name).FirstOrDefault();


                    if (realization != null)
                    {
                        tags_controller.Add("FW_IMPLEMENTS", "implements " + realization.getSupplier());

                        Component daoInterface = componente.Components.SelectMany(x => x.Components).Where(y => y.xsi_type == "frameweb:NavigationInterface" && y.name == realization.getSupplier()).FirstOrDefault();

                        if (daoInterface != null)
                        {
                            tags_controller.Add("FW_CLASS_IMPLEMENTS_INFIX", "implements " + realization.getSupplier());
                        }
                        else
                        {
                            tags_controller.Add("FW_CLASS_IMPLEMENTS_INFIX", "set infix on interface");
                        }
                    }
                    else
                    {
                        tags_controller.Add("FW_IMPLEMENTS", string.Empty);
                    }


                    tags_controller.Add("FW_CLASS_NAME", controller.name);

                    if (controller.isAbstract)
                    {
                        tags_controller.Add("FW_CLASS_VISIBILITY", "public abstract");
                    }
                    else
                    {
                        tags_controller.Add("FW_CLASS_VISIBILITY", "public");
                    }


                    var frontControllerDependency = componente.Components.Where(x => x.xsi_type == "frameweb:FrontControllerDependency" && x.getSupplier() == controller.name).FirstOrDefault();
                    tags_controller.Add("FW_BEAN_NAME", frontControllerDependency != null ? frontControllerDependency.getClient() : string.Empty);


                    var controller_parameters = controller.Components.Where(x => x.xsi_type == "frameweb:IOParameter").ToList();

                    string parameters = string.Empty;
                    foreach (var parameter in controller_parameters)
                    {
                        var text_parameter = File.ReadAllText(Config.dir_template + Config.lang + Path.DirectorySeparatorChar + parameter.getXsiTypeFile());
                        text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", string.IsNullOrWhiteSpace(parameter.parameterType) ? parameter.getType() : parameter.parameterType);
                        text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(parameter.name));
                        text_parameter = text_parameter.Replace("FW_PARAMETER", parameter.name);

                        parameters += text_parameter;
                    }

                    tags_controller.Add("FW_FRONT_CONTROLLER_PARAMETERS", parameters);

                    var controller_methods = controller.Components.Where(x => x.xsi_type == "frameweb:FrontControllerMethod").ToList();

                    string methods = string.Empty;
                    foreach (var method in controller_methods)
                    {
                        var text_method = File.ReadAllText(Config.dir_template + Config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                        text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", (string.IsNullOrWhiteSpace(method.methodType)) ? "void" : method.methodType);
                        text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                        if (!string.IsNullOrWhiteSpace(method.methodType))
                        {
                            text_method = text_method.Replace("FW_METHOD_RETURN", "return null;");
                        }
                        else
                        {
                            text_method = text_method.Replace("FW_METHOD_RETURN", string.Empty);
                        }


                        text_method = text_method.Replace("FW_METHOD_PARAM", method.GetMethodParameter());

                        methods += text_method;
                    }

                    tags_controller.Add("FW_FRONT_CONTROLLER_METHODS", methods);

                    var text = File.ReadAllText(Config.dir_template + Config.lang + Path.DirectorySeparatorChar + controller.getXsiTypeFile());
                    foreach (var item in tags_controller)
                    {
                        text = text.Replace(item.Key, item.Value);
                    }

                    File.WriteAllText(Path.Combine(dir_output_class_package, controller.name + Config.ext_class), text);
                }
            }
            /// VIEW

            var views = componente.Components.Where(x => x.xsi_type == "frameweb:ViewPackage").ToList();

            foreach (var package_view in views)
            {
                var dir_output_page = this.BuildDirectoryStructures(Config.dir_output_web, package_view.name);


                var views_pages = package_view.Components.Where(x => x.xsi_type == "frameweb:Page").ToList();
                foreach (var page in views_pages)
                {
                    string body = string.Empty;

                    var componentes_dentro_pagina = page.Components.Where(x => x.xsi_type == "frameweb:NavigationCompositionWhole").ToList();
                    foreach (Component componente_pagina in componentes_dentro_pagina)
                    {
                        var comp = views.Where(x => x.name == componente_pagina.getType()).FirstOrDefault();
                        if (comp != null)
                        {
                            string body_form = string.Empty;
                            if (comp.xsi_type == "frameweb:UIComponent")// Form
                            {
                                body_form = File.ReadAllText(Config.dir_template + "framework" + Path.DirectorySeparatorChar + comp.getXsiTypeFile());
                            }
                            string body_form_comp = string.Empty;
                            foreach (var item in comp.Components)
                            {
                                // Get file path template for component UI (input, radio, ...)
                                var field_template = File.ReadAllText(item.getXsiTypeFile());
                                field_template = field_template.Replace("FW_ID", item.name.Replace('.', '_'));
                                field_template = field_template.Replace("FW_VALUE", comp.name + "." + item.name);

                                body_form_comp += field_template;
                            }

                            body_form = body_form.Replace("FW_BODY", body_form_comp);
                            body_form = body_form.Replace("FW_ID", comp.name);
                            body     += body_form;
                        }
                    }

                    var text = File.ReadAllText(Config.dir_template + "framework" + Path.DirectorySeparatorChar + page.getXsiTypeFile());
                    text = text.Replace("FW_BODY", body);

                    File.WriteAllText(Path.Combine(dir_output_page, page.name), text);
                }
            }
            Utilities.Log("Code generated successfully.");
        }
Beispiel #7
0
        public override void Execute(Componete componente)
        {
            /// CONTROLLER
            var controllers = componente.Componentes.Where(x => x.xsi_type == "frameweb:ControllerPackage").ToList().SelectMany(x => x.Componentes).ToList();

            foreach (var controller in controllers)
            {
                if (controller.getXsiTypeFile() == "ServiceControllerAssociation.txt")
                {
                    continue;
                }

                var tags_controller = new Dictionary <string, string>();

                tags_controller.Add("FW_CLASS_NAME", controller.name);

                var frontControllerDependency = componente.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerDependency" && x.getSupplier() == controller.name).FirstOrDefault();
                tags_controller.Add("FW_BEAN_NAME", frontControllerDependency != null ? frontControllerDependency.getClient() : string.Empty);

                //tags_controller.Add("FW_BEAN_CLASS_NAME", "NNN");

                var controller_parameters = controller.Componentes.Where(x => x.xsi_type == "frameweb:IOParameter").ToList();

                string parameters = string.Empty;
                foreach (var parameter in controller_parameters)
                {
                    var text_parameter = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + parameter.getXsiTypeFile());
                    text_parameter = text_parameter.Replace("FW_PARAMETER_TYPE", parameter.parameterType);
                    text_parameter = text_parameter.Replace("FW_PARAMETER_FIRST_UPPER", Utilities.FirstCharToUpper(parameter.name));
                    text_parameter = text_parameter.Replace("FW_PARAMETER", parameter.name);

                    parameters += text_parameter;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_PARAMETERS", parameters);

                var controller_methods = controller.Componentes.Where(x => x.xsi_type == "frameweb:FrontControllerMethod").ToList();

                string methods = string.Empty;
                foreach (var method in controller_methods)
                {
                    var text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                    text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.methodType);
                    text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                    methods += text_method;
                }

                //ADD LOGIN PROCESSING METHOD
                var auth_proc_method = controller.Componentes.Where(x => x.xsi_type == "frameweb:AuthProcessingMethod").ToList();
                foreach (var method in auth_proc_method)
                {
                    var text_method = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + method.getXsiTypeFile());
                    text_method = text_method.Replace("FW_METHOD_RETURN_TYPE", method.methodType);
                    text_method = text_method.Replace("FW_METHOD_NAME", method.name);

                    methods += text_method;
                }

                tags_controller.Add("FW_FRONT_CONTROLLER_METHOD", methods);

                var text = File.ReadAllText(config.dir_template + config.lang + Path.DirectorySeparatorChar + controller.getXsiTypeFile());
                foreach (var item in tags_controller)
                {
                    text = text.Replace(item.Key, item.Value);
                }

                try
                {
                    Directory.CreateDirectory(Path.Combine(config.dir_output, config.dir_output_class));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_class, controller.name + config.ext_class), text);
            }
            /// VIEW

            var views = componente.Componentes.Where(x => x.xsi_type == "frameweb:ViewPackage").ToList().SelectMany(x => x.Componentes).ToList();

            var views_pages = views.Where(x => x.xsi_type == "frameweb:Page" ||
                                          x.xsi_type == "frameweb:AuthPage").ToList();

            foreach (var page in views_pages)
            {
                string body = string.Empty;

                var componentes_dentro_pagina = page.Componentes.Where(x => x.xsi_type == "frameweb:NavigationCompositionWhole").ToList();
                foreach (Componete componente_pagina in componentes_dentro_pagina)
                {
                    var comp = views.Where(x => x.name == componente_pagina.getType()).FirstOrDefault();
                    if (comp != null)
                    {
                        string body_form = string.Empty;
                        if (comp.xsi_type == "frameweb:UIComponent")// Form
                        {
                            body_form = File.ReadAllText(config.dir_template + "framework" + Path.DirectorySeparatorChar + comp.getXsiTypeFile());
                        }
                        else
                        {
                            if (comp.xsi_type == "frameweb:AuthForm")// Form
                            {
                                //USES A LOGIN FORM TEMPLATE INSTEAD
                                body_form = File.ReadAllText(config.dir_template + "framework" + Path.DirectorySeparatorChar + comp.getXsiTypeFile());
                            }
                        }
                        string body_form_comp = string.Empty;
                        foreach (var item in comp.Componentes)
                        {
                            // Get file path template for component UI (input, radio, ...)
                            var field_template = File.ReadAllText(item.getXsiTypeFile());
                            field_template = field_template.Replace("FW_ID", item.name.Replace('.', '_'));
                            field_template = field_template.Replace("FW_VALUE", comp.name + "." + item.name);

                            body_form_comp += field_template;
                        }

                        body_form = body_form.Replace("FW_BODY", body_form_comp);
                        body_form = body_form.Replace("FW_ID", comp.name);
                        body     += body_form;
                    }
                }

                var text = File.ReadAllText(config.dir_template + "framework" + Path.DirectorySeparatorChar + page.getXsiTypeFile());
                text = text.Replace("FW_BODY", body);

                File.WriteAllText(Path.Combine(config.dir_output, config.dir_output_web, page.name), text);
            }

            var login_page = views.Where(x => x.xsi_type == "frameweb:AuthPage").FirstOrDefault();

            if (login_page != null)
            {
                //DICTIONARY FOR THE SECURITY FILE
                var tags_class_sec = new Dictionary <string, string>();
                tags_class_sec.Add("FW_AUTH_LOGIN_PAGE", login_page.name);

                var login_form = views.Where(x => x.xsi_type == "frameweb:AuthPage").FirstOrDefault();

                //GETTING THE SUCCESS AND FAILURE URL
                var authSuccessUrl = componente.Componentes.Where(x => x.xsi_type == "frameweb:AuthSuccessUrl").FirstOrDefault().getSupplier();
                var authFailureUrl = componente.Componentes.Where(x => x.xsi_type == "frameweb:AuthFailureUrl").FirstOrDefault().getSupplier();

                tags_class_sec.Add("FW_AUTH_LOGIN_SUCC_URL", authSuccessUrl);
                tags_class_sec.Add("FW_AUTH_LOGIN_FAIL_URL", authFailureUrl);

                var text_sec = "";

                try
                {
                    text_sec = File.ReadAllText(Path.Combine(config.dir_output, "src\\sec-config.txt"));
                }
                catch
                {
                    text_sec = File.ReadAllText(config.dir_template_sec_config);
                }

                foreach (var item in tags_class_sec)
                {
                    text_sec = text_sec.Replace(item.Key, item.Value);
                }

                try
                {
                    // Directory.CreateDirectory(Path.Combine(config.dir_output,"src\\sec-config.txt"));
                }
                catch
                {
                }
                File.WriteAllText(Path.Combine(config.dir_output, "src\\sec-config.txt"), text_sec);
            }

            Utilities.Log("Code generated successfully.");
        }