示例#1
0
        private void TransformViews(SmartAppInfo manifest)
        {
            if (manifest != null)
            {
                var enabledEntities = manifest.DataModel.Entities.Where(e => !e.IsAbstract);
                var applicationId   = manifest.Id;

                foreach (var entity in enabledEntities)
                {
                    IndexTemplate  indexTemplate  = new IndexTemplate(entity, applicationId);
                    ShowTemplate   showTemplate   = new ShowTemplate(entity, applicationId);
                    CreateTemplate createTemplate = new CreateTemplate(entity, applicationId);
                    EditTemplate   editTemplate   = new EditTemplate(entity, applicationId);
                    DeleteTemplate deleteTemplate = new DeleteTemplate(entity, applicationId);

                    var folderName = TextConverter.CamelCase(entity.Id);

                    _writingService.WriteFile(Path.Combine(_context.BasePath, indexTemplate.OutputPath, folderName, "index.blade.php"), indexTemplate.TransformText());
                    _writingService.WriteFile(Path.Combine(_context.BasePath, showTemplate.OutputPath, folderName, "show.blade.php"), showTemplate.TransformText());
                    _writingService.WriteFile(Path.Combine(_context.BasePath, createTemplate.OutputPath, folderName, "create.blade.php"), createTemplate.TransformText());
                    _writingService.WriteFile(Path.Combine(_context.BasePath, editTemplate.OutputPath, folderName, "edit.blade.php"), editTemplate.TransformText());
                    _writingService.WriteFile(Path.Combine(_context.BasePath, deleteTemplate.OutputPath, folderName, "delete.blade.php"), deleteTemplate.TransformText());
                }
            }
        }
 private void TransformServiceBase(SmartAppInfo smartApp)
 {
     if (smartApp != null)
     {
         RestApiTemplate serviceBaseTemplate = new RestApiTemplate(smartApp);
         _writingService.WriteFile(Path.Combine(_context.BasePath, serviceBaseTemplate.OutputPath), serviceBaseTemplate.TransformText());
     }
 }
示例#3
0
        /// <summary>
        /// Generating package.json
        /// </summary>
        /// <param name="smartApp">A SmartApp's manifest</param>
        private void TransformPackage(SmartAppInfo smartApp)
        {
            Package packageTemplate      = new Package(smartApp);
            string  packageDirectoryPath = packageTemplate.OutputPath;
            string  fileToWritePath      = Path.Combine(_context.BasePath, packageDirectoryPath);
            string  textToWrite          = packageTemplate.TransformText();

            _writingService.WriteFile(fileToWritePath, textToWrite);
        }
        private void TransformNavigations(SmartAppInfo smartApp)
        {
            if (smartApp != null && smartApp.Concerns != null && smartApp.Concerns.Count > 0)
            {
                foreach (ConcernInfo concern in smartApp.Concerns)
                {
                    NavigationTemplate navigationTemplate = new NavigationTemplate(smartApp, concern);

                    string filename = TextConverter.PascalCase(concern.Id) + "StackNavigator.js";

                    _writingService.WriteFile(Path.Combine(_context.BasePath, navigationTemplate.OutputPath, filename), navigationTemplate.TransformText());
                }
            }
        }
        /// <summary>
        /// Generating an angular module containing the configuration
        /// required to get the page integrated in the Ionic 2 navigation.
        /// Ionic 2 recommends a module for each page. One page = one layout.
        /// </summary>
        /// <param name="concernId">A concern Id.</param>
        /// <param name="layout">A layout.</param>
        /// <param name="languages">A list of languages. (can be null)</param>
        /// <param name="api">A lit of apis.</param>
        public void TransformLayoutModule(string concernId, LayoutInfo layout, LanguageList languages, ApiList api)
        {
            if (concernId != null && layout != null && layout.Id != null && api != null)
            {
                LayoutModuleTemplate layoutModuleTemplate = new LayoutModuleTemplate(concernId, layout, languages, api);

                string layoutModuleDirectoryPath = Path.Combine(layoutModuleTemplate.OutputPath, TextConverter.CamelCase(concernId), TextConverter.CamelCase(layout.Id));
                string layoutModuleFilename      = TextConverter.CamelCase(concernId) + "-" + TextConverter.CamelCase(layout.Id) + ".module.ts";

                string fileToWritePath = Path.Combine(_context.BasePath, layoutModuleDirectoryPath, layoutModuleFilename);
                string textToWrite     = layoutModuleTemplate.TransformText();

                _writingService.WriteFile(fileToWritePath, textToWrite);
            }
        }
示例#6
0
        private void TransformEnvTemplate(SmartAppInfo smartApp)
        {
            if (smartApp != null)
            {
                DatabaseConfigInfo  databaseConfigInfo  = GetDatabasConfigInfo();
                RedisConfigInfo     redisConfigInfo     = GetRedisConfigInfo();
                MailConfigInfo      mailConfigInfo      = GetMailConfigInfo();
                SessionConfigInfo   sessionConfigInfo   = GetSessionConfigInfo();
                CockieConfigInfo    cockieConfigInfo    = GetCockieConfigInfo();
                MemCachedConfigInfo memCachedConfigInfo = GetMemCachedConfigInfo();

                EnvTemplate envTemplate = new EnvTemplate(smartApp.Id, databaseConfigInfo, redisConfigInfo, mailConfigInfo, sessionConfigInfo, cockieConfigInfo, memCachedConfigInfo);

                _writingService.WriteFile(Path.Combine(_context.BasePath, envTemplate.OutputPath), envTemplate.TransformText());
            }
        }
        /// <summary>
        /// Generating a typescript model.
        /// </summary>
        /// <param name="entity">An entity.</param>
        private void TransformDataModel(EntityInfo entity)
        {
            if (entity != null && entity.Id != null)
            {
                string fileToWritePath = "";
                string textToWrite     = "";
                if (entity.IsEnum)
                {
                    EnumTemplate enumTemplate      = new EnumTemplate(entity);
                    string       enumDirectoryPath = Path.Combine(enumTemplate.OutputPath);
                    string       enumFilename      = TextConverter.CamelCase(entity.Id) + "Enum.ts";
                    fileToWritePath = Path.Combine(_context.BasePath, enumDirectoryPath, enumFilename);
                    textToWrite     = enumTemplate.TransformText();
                }
                else
                {
                    DataModelTemplate dataModelTemplate      = new DataModelTemplate(entity);
                    string            dataModelDirectoryPath = Path.Combine(dataModelTemplate.OutputPath);
                    string            dataModelFilename      = TextConverter.CamelCase(entity.Id) + "Model.ts";
                    fileToWritePath = Path.Combine(_context.BasePath, dataModelDirectoryPath, dataModelFilename);
                    textToWrite     = dataModelTemplate.TransformText();
                }

                _writingService.WriteFile(fileToWritePath, textToWrite);
            }
        }
示例#8
0
        /// <summary>
        /// Generating a JSON file for the configuration of internationalization
        /// for each languages described in the manifeste.
        /// </summary>
        /// <param name="smartApp">A SmartApp manifeste.</param>
        public void TransformJsonTemplate(SmartAppInfo smartApp)
        {
            if (smartApp != null && smartApp.Languages.AsEnumerable() != null && smartApp.Languages.AsEnumerable().Count() > 0)
            {
                foreach (LanguageInfo languageInfo in smartApp.Languages.AsEnumerable())
                {
                    JsonTemplate jsonTemplate      = new JsonTemplate(smartApp, languageInfo.Id);
                    string       jsonDirectoryPath = Path.Combine(jsonTemplate.OutputPath);
                    string       enJsonFile        = TextConverter.PascalCase(languageInfo.Id) + ".json";

                    string fileToWritePath = Path.Combine(_context.BasePath, jsonDirectoryPath, enJsonFile);
                    string textToWrite     = jsonTemplate.TransformText();

                    _writingService.WriteFile(fileToWritePath, textToWrite);
                }
            }
        }
示例#9
0
 private void TransformViewModel(EntityInfo dataModel, string viewModelSuffix, string modelSuffix)
 {
     if (dataModel != null)
     {
         ViewModelsTemplate viewModelTemplate = new ViewModelsTemplate(dataModel, viewModelSuffix, modelSuffix);
         _writingService.WriteFile(Path.Combine(_context.BasePath, viewModelTemplate.OutputPath, TextConverter.PascalCase(dataModel.Id) + viewModelSuffix + ".php"), viewModelTemplate.TransformText());
     }
 }
        private void TransformReducers(SmartAppInfo smartApp)
        {
            if (smartApp != null && smartApp.Concerns != null && smartApp.Concerns.Count > 0)
            {
                foreach (var concern in smartApp.Concerns)
                {
                    foreach (LayoutInfo layout in concern.Layouts.AsEnumerable())
                    {
                        ReducersTemplate reducersTemplate = new ReducersTemplate(concern, layout);

                        string path = Path.Combine(_context.BasePath, reducersTemplate.OutputPath, TextConverter.PascalCase(concern.Id));

                        _writingService.WriteFile(Path.Combine(path, TextConverter.PascalCase(layout.Id) + "Reducer.js"), reducersTemplate.TransformText());
                    }
                }
            }
        }
        /// <summary>
        /// Transform each services into mocks form.
        /// </summary>
        /// <param name="smartApp">A SmartApp's manifeste.</param>
        private void TransformServicesMocks(SmartAppInfo smartApp)
        {
            if (smartApp != null && smartApp.Api.AsEnumerable() != null)
            {
                foreach (ApiInfo api in smartApp.Api.AsEnumerable())
                {
                    MocksTemplate mocksTemplate = new MocksTemplate(api);

                    string mocksDirectoryPath = mocksTemplate.OutputPath;
                    string mocksFilename      = TextConverter.CamelCase(api.Id) + "Mock.ts";

                    string fileToWritePath = Path.Combine(_context.BasePath, mocksDirectoryPath, mocksFilename);
                    string textToWrite     = mocksTemplate.TransformText();

                    _writingService.WriteFile(fileToWritePath, textToWrite);
                }
            }
        }
示例#12
0
        private void TransformViews(SmartAppInfo smartApp)
        {
            if (smartApp != null)
            {
                string apiSuffix       = GetApiSuffix();
                string viewModelSuffix = GetViewModelSuffix();

                foreach (var concern in smartApp.Concerns)
                {
                    foreach (LayoutInfo layout in concern.Layouts.AsEnumerable())
                    {
                        ViewTemplate viewTemplate = new ViewTemplate(smartApp.Title, concern, layout, smartApp.Languages, smartApp.Api, apiSuffix, viewModelSuffix);

                        string path = Path.Combine(_context.BasePath, viewTemplate.OutputPath, TextConverter.PascalCase(concern.Id));

                        _writingService.WriteFile(Path.Combine(path, TextConverter.PascalCase(layout.Id) + "Screen.js"), viewTemplate.TransformText());
                    }
                }
            }
        }
        private void TransformApiRoutes(SmartAppInfo smartApp)
        {
            if (smartApp != null && smartApp.Api != null)
            {
                string controllerSuffix = GetControllerSuffix();

                ApiRoutesTemplate apiTemplate = new ApiRoutesTemplate(smartApp, controllerSuffix);

                _writingService.WriteFile(Path.Combine(_context.BasePath, apiTemplate.OutputPath), apiTemplate.TransformText());
            }
        }
        private void TransformModels(SmartAppInfo smartApp)
        {
            if (smartApp != null && smartApp.DataModel != null && smartApp.DataModel.Entities != null)
            {
                string modelSuffix = GetModelSuffix();

                foreach (var entity in smartApp.DataModel.Entities)
                {
                    ModelsTemplate template = new ModelsTemplate(entity, modelSuffix);
                    _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath), template.TransformText());
                }
            }
        }
        private void TransformApiControllers(SmartAppInfo smartApp)
        {
            if (smartApp != null && smartApp.Api != null)
            {
                string controllerSuffix = GetControllerSuffix();

                foreach (var apiList in smartApp.Api)
                {
                    ApiControllersTemplate template = new ApiControllersTemplate(apiList, controllerSuffix);
                    _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath, (TextConverter.PascalCase(apiList.Id) + controllerSuffix + ".php")), template.TransformText());
                }
            }
        }
 private void TransformDatabaseMigrations(SmartAppInfo smartApp)
 {
     if (smartApp != null && smartApp.DataModel != null && smartApp.DataModel.Entities != null)
     {
         foreach (var entity in smartApp.DataModel.Entities)
         {
             if (!entity.IsAbstract)
             {
                 ModelMigrationTemplate migrationTemplate = new ModelMigrationTemplate(entity);
                 _writingService.WriteFile(Path.Combine(_context.BasePath, migrationTemplate.OutputPath), migrationTemplate.TransformText());
             }
         }
     }
 }
示例#17
0
        private void TransformControllerApi(SmartAppInfo manifest)
        {
            bool result  = true;
            var  apiList = manifest.Api.AsEnumerable();

            if (apiList != null)
            {
                foreach (var api in apiList)
                {
                    if (!result)
                    {
                        break;
                    }

                    if (api != null)
                    {
                        _serviceTypes = new Dictionary <string, string>();

                        foreach (var action in api.Actions)
                        {
                            TransformControllerApiReturnTypes(manifest, action);
                            TransformControllerApiParameters(manifest, action);
                        }

                        var template = new ApiController(api, manifest.Id, Constants.Version, _serviceTypes);
                        try
                        {
                            result = _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath, Constants.Version, api.Id + ".g.cs"), template.TransformText());
                        }
                        catch (Exception ex)
                        {
                            result = false;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Generating typescript models containing the
        /// definition of the viewmodel for the current layout.
        /// </summary>
        /// <param name="dataModel">A dataModel.</param>
        private void TransformViewModel(EntityInfo dataModel)
        {
            if (dataModel != null && dataModel.Id != null)
            {
                ViewModelTemplate viewModelTemplate = new ViewModelTemplate(dataModel);

                string viewModelDirectoryPath = viewModelTemplate.OutputPath;
                string viewModelFilename      = TextConverter.CamelCase(dataModel.Id) + ".ts";

                string fileToWritePath = Path.Combine(_context.BasePath, viewModelDirectoryPath, viewModelFilename);
                string textToWrite     = viewModelTemplate.TransformText();

                _writingService.WriteFile(fileToWritePath, textToWrite);
            }
        }
        private void TransformWebControllers(SmartAppInfo smartApp)
        {
            if (smartApp != null && smartApp.Api != null)
            {
                string controllerSuffix = GetControllerSuffix();
                string modelSuffix      = GetModelSuffix();

                foreach (var entity in smartApp.DataModel.Entities)
                {
                    if (!entity.IsAbstract)
                    {
                        WebControllersTemplate template = new WebControllersTemplate(entity, controllerSuffix, modelSuffix);
                        _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath, (TextConverter.PascalCase(entity.Id) + controllerSuffix + ".php")), template.TransformText());
                    }
                }
            }
        }
        private void TransformDataModel(SmartAppInfo manifest)
        {
            string modelSuffix = GetModelSuffix();

            var entities = manifest.DataModel.Entities;

            if (entities != null)
            {
                foreach (var entity in entities)
                {
                    if (entity != null)
                    {
                        DataModelTemplate template = new DataModelTemplate(entity, manifest.Id, modelSuffix);
                        _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath, TextConverter.PascalCase(entity.Id) + "." + modelSuffix + ".js"), template.TransformText());
                    }
                }
            }
        }
示例#21
0
        /// <summary>
        /// Start function for the generation of all apis.
        /// </summary>
        /// <param name="smartApp">A SmartApp's manifeste.</param>
        /// <param name="apiTemplatesDirectoryPath">Path to api activity templates.</param>
        private void TransformApi(SmartAppInfo smartApp, string apiTemplatesDirectoryPath)
        {
            if (smartApp != null && smartApp.Api.AsEnumerable() != null)
            {
                foreach (ApiInfo api in smartApp.Api.AsEnumerable())
                {
                    ApiTemplate apiTemplate = new ApiTemplate(api);

                    string apiDirectoryPath = apiTemplate.OutputPath;
                    string apiFilename      = TextConverter.CamelCase(api.Id) + ".service.ts";

                    string fileToWritePath = Path.Combine(_context.BasePath, apiDirectoryPath, apiFilename);
                    string textToWrite     = apiTemplate.TransformText();

                    _writingService.WriteFile(fileToWritePath, textToWrite);
                }
                _writingService.CopyDirectory(apiTemplatesDirectoryPath, _context.BasePath);
            }
        }
示例#22
0
        private void TransformJwtIssuerOptions(SmartAppInfo manifest)
        {
            var template = new JwtIssuerOptions(manifest);

            _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath), template.TransformText());
        }
示例#23
0
        private void TransferRootFiles(SmartAppInfo smartApp)
        {
            if (smartApp != null)
            {
                IndexTemplate indexTemplate = new IndexTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, indexTemplate.OutputPath), indexTemplate.TransformText());

                AppJsonTemplate appJsonTemplate = new AppJsonTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, appJsonTemplate.OutputPath), appJsonTemplate.TransformText());

                PackageJsonTemplate packageJsonTemplate = new PackageJsonTemplate(smartApp);
                _writingService.WriteFile(Path.Combine(_context.BasePath, packageJsonTemplate.OutputPath), packageJsonTemplate.TransformText());
            }
        }
示例#24
0
        private void TransformDesignTimeDbContextFactory(SmartAppInfo manifest)
        {
            var template = new DesignTimeDbContextFactory(manifest);

            _writingService.WriteFile(Path.Combine(_context.BasePath, template.OutputPath), template.TransformText());
        }