Example #1
0
        public override void Execute(ProjectState project, List <ActionParameter> parameters)
        {
            var schemaName = GetStringParameterValue(parameters, SchemaNameParameter).ToWordPascalCase();
            var schema     = project.GetSchema(schemaName)
                             ?? throw new Exception($"Can't find any schema named '{schemaName}'");
            var    useCaseTypeName         = GetStringParameterValue(parameters, UseCaseParameter);
            var    type                    = UseCase.StringToType(useCaseTypeName);
            Schema intersectionSchemaModel = null;

            //if (type == UseCase.UseCaseTypes.RetrieveMultipleIntersection)
            //{
            //    var intersectionSchemaName = GetStringParameterValue(parameters, IntersectionDomainParameter).ToWordPascalCase();
            //    var intersectionSchema = project.GetSchema(intersectionSchemaName)
            //        ?? throw new Exception($"Can't find any intersection schema named '{intersectionSchemaName}'");
            //    intersectionSchemaModel = intersectionSchema;
            //}
            //var caseUse = new UseCase(type, intersectionSchemaModel);
            //var authorization = GetBoolParameterValue(parameters, NeedsAthorizationParameter);
            ////if (authorization)
            ////{
            ////    caseUse.NeedsAuthorization = true;
            ////}
            //schema.AddUseCase(caseUse);
            OverrideOutputParameter(SchemaNameParameter.Name, schemaName);
        }
Example #2
0
        public override void Execute(ProjectState project, List <ActionParameter> parameters)
        {
            var schemaName        = GetStringParameterValue(parameters, SchemaNameParameter).ToWordPascalCase();
            var name              = GetStringParameterValue(parameters, NameParameter).ToWordPascalCase();
            var type              = GetStringParameterValue(parameters, TypeParameter);
            var length            = GetIntParameterValue(parameters, LengthParameter);
            var isPrimaryKey      = GetBoolParameterValue(parameters, IsPrimaryKeyParameter);
            var isNullable        = GetBoolParameterValue(parameters, IsNullableParameter);
            var isUnique          = GetBoolParameterValue(parameters, IsUniqueParameter);
            var isAutoincremental = GetBoolParameterValue(parameters, IsAutoIncrementalParameter);

            var schema = project.GetSchema(schemaName);

            if (schema == null)
            {
                throw new Exception($"Can't find any schema named '{schemaName}'");
            }

            var typedType = SchemaProperty.StringToType(type);
            var property  = new SchemaProperty(name, typedType, true)
            {
                IsAutoIncremental = isAutoincremental,
                IsNullable        = isNullable,
                IsPrimaryKey      = isPrimaryKey,
                IsUnique          = isUnique,
                Length            = length
            };

            schema.AddProperty(property);
            OverrideOutputParameter(SchemaNameParameter.Name, schemaName);
            OverrideOutputParameter(NameParameter.Name, name);
        }
Example #3
0
        public override void Execute(ProjectState project, List <ActionParameter> parameters)
        {
            var schemaName       = GetStringParameterValue(parameters, NameParameter).ToWordPascalCase();
            var firstSchemaName  = GetStringParameterValue(parameters, FirstSchemaNameParameter);
            var secondSchemaName = GetStringParameterValue(parameters, SecondSchemaNameParameter);

            var firstSchema = project.GetSchema(firstSchemaName);

            if (firstSchema == null)
            {
                throw new Exception($"Can't find any schema named '{firstSchemaName}'");
            }

            var secondSchema = project.GetSchema(secondSchemaName);

            if (secondSchema == null)
            {
                throw new Exception($"Can't find any schema named '{secondSchemaName}'");
            }

            var firstAttributeName = firstSchema.Name == secondSchema.Name
                ? $"{firstSchema.Name}OneId"
                : $"{firstSchema.Name}Id";
            var secondAttributeName = firstSchema.Name == secondSchema.Name
                ? $"{secondSchema.Name}TwoId"
                : $"{secondSchema.Name}Id";

            var newSchema = new Schema(schemaName)
            {
                HasId = true, IsIntersection = true
            };

            newSchema.AddProperty(
                new SchemaProperty(firstAttributeName, SchemaProperty.PropertyTypes.ForeingKey, false));
            newSchema.AddProperty(
                new SchemaProperty(secondAttributeName, SchemaProperty.PropertyTypes.ForeingKey, false));

            //firstSchema.AddUseCase(new UseCase(UseCase.UseCaseTypes.RetrieveMultipleIntersection, newSchema));
            //secondSchema.AddUseCase(new UseCase(UseCase.UseCaseTypes.RetrieveMultipleIntersection, newSchema));
            OverrideOutputParameter(NameParameter.Name, schemaName);
        }
Example #4
0
        public override void Execute(ProjectState project, List <ActionParameter> parameters)
        {
            var schemaName = GetStringParameterValue(parameters, ViewNameParameter);
            var name       = GetStringParameterValue(parameters, SchemaNameParameter).ToWordPascalCase();
            var schema     = project.GetSchema(schemaName);

            if (schema == null)
            {
                throw new Exception($"Can't find any schema named '{schemaName}'");
            }
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.Custom, name, true));
            OverrideOutputParameter(ViewNameParameter.Name, name);
        }
Example #5
0
        public override void Execute(ProjectState project, List <ActionParameter> parameters)
        {
            var schemaName = GetStringParameterValue(parameters, SchemaNameParameter);
            var schema     = project.GetSchema(schemaName)
                             ?? throw new Exception($"Can't find any schema named '{schemaName}'");

            var    useCaseTypeName         = GetStringParameterValue(parameters, UseCaseParameter);
            var    type                    = UseCase.StringToType(useCaseTypeName);
            Schema intersectionSchemaModel = null;

            //if (type == UseCase.UseCaseTypes.RetrieveMultipleIntersection)
            //{
            //    var intersectionSchemaName = GetStringParameterValue(parameters, IntersectionSchemaParameter).ToWordPascalCase();
            //    var intersectionSchema = project.GetSchema(intersectionSchemaName)
            //        ?? throw new Exception($"Can't find any intersection domain named '{schemaName}'");
            //    intersectionSchemaModel = intersectionSchema;
            //}
            schema.DeleteUseCase(type, intersectionSchemaModel);
            OverrideOutputParameter(SchemaNameParameter.Name, schemaName);
        }
Example #6
0
        public override void Execute(ProjectState project, List <ActionParameter> parameters)
        {
            var name                = GetStringParameterValue(parameters, NameParameter).ToWordPascalCase();
            var hasState            = GetBoolParameterValue(parameters, HasStateParameter);
            var hasUserRelationship = GetBoolParameterValue(parameters, HasUserRelationshipParameter);
            var hasOwner            = GetBoolParameterValue(parameters, HasOwnerParameter);

            var domainName = GetStringParameterValue(parameters, DomainParameter);
            var domain     = project.Domains.FirstOrDefault(k => k.Name == domainName)
                             ?? throw new Exception($"Can't find domain named '{domainName}'");
            var schema = new Schema(name);

            schema.HasId = true;
            schema.AddProperty(new SchemaProperty(DefaultAttributesSchemaNames.Id, SchemaProperty.PropertyTypes.PrimaryKey, false)
            {
                IsPrimaryKey = true
            });

            if (hasState)
            {
                schema.HasState = true;
                schema.AddProperty(new SchemaProperty(DefaultAttributesSchemaNames.State, SchemaProperty.PropertyTypes.State, false));
                schema.AddProperty(new SchemaProperty(DefaultAttributesSchemaNames.Status, SchemaProperty.PropertyTypes.Status, false));
                schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.Active, false)
                                                                  .AddDefaultOutputViewParameter());
                schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.Inactive, false)
                                                                  .AddDefaultOutputViewParameter());
            }

            schema.HasDates = true;
            schema.AddProperty(new SchemaProperty(DefaultAttributesSchemaNames.CreatedOn, SchemaProperty.PropertyTypes.DateTime, false));
            schema.AddProperty(new SchemaProperty(DefaultAttributesSchemaNames.ModifiedOn, SchemaProperty.PropertyTypes.DateTime, false));

            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.CreatedOnAtYear, false)
                                                              .AddInputParameter(DomainInputType.Integer, "Year")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.CreatedOnAtMonth, false)
                                                              .AddInputParameter(DomainInputType.Integer, "Year")
                                                              .AddInputParameter(DomainInputType.Integer, "Month")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.CreatedOnAtDay, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.CreatedOnAtDayAndHour, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.CreatedOnAtDayAndHourAndMinute, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.CreatedOnAtDayAndHourAndMinuteSecond, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.CreatedOnBetween, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTimeFrom")
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTimeTo")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.CreatedOnBefore, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.CreatedOnAfter, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.ModifiedOnAtYear, false)
                                                              .AddInputParameter(DomainInputType.Integer, "Year")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.ModifiedOnAtMonth, false)
                                                              .AddInputParameter(DomainInputType.Integer, "Year")
                                                              .AddInputParameter(DomainInputType.Integer, "Month")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.ModifiedOnAtDay, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.ModifiedOnAtDayAndHour, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.ModifiedOnAtDayAndHourAndMinute, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.ModifiedOnAtDayAndHourAndMinuteSecond, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.ModifiedOnBetween, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTimeFrom")
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTimeTo")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.ModifiedOnBefore, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());
            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.ModifiedOnAfter, false)
                                                              .AddInputParameter(DomainInputType.Datetime, "DateTime")
                                                              .AddDefaultOutputViewParameter());

            if (hasOwner)
            {
                var userSchema = project.GetSchema(Definitions.DefaultBasicDomainNames.User);
                if (userSchema == null)
                {
                    throw new Exception("Can't add user relationship because 'User' domain doesn't exists");
                }
                schema.HasOwner = true;
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.Owner, SchemaProperty.PropertyTypes.ForeingKey, false)
                {
                    ForeingSchema = userSchema
                });

                schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.Owner, false)
                                                                  .AddInputParameter(DomainInputType.Guid, "Id")
                                                                  .AddDefaultOutputViewParameter());
            }

            if (hasUserRelationship)
            {
                var userSchema = project.GetSchema(Definitions.DefaultBasicDomainNames.User);
                if (userSchema == null)
                {
                    throw new Exception("Can't add user relationship because 'User' domain doesn't exists");
                }
                schema.HasUserRelationship = true;
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.CreatedBy, SchemaProperty.PropertyTypes.ForeingKey, false)
                {
                    ForeingSchema = userSchema
                });
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.ModifiedBy, SchemaProperty.PropertyTypes.ForeingKey, false)
                {
                    ForeingSchema = userSchema
                });

                schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.CreatedBy, false)
                                                                  .AddInputParameter(DomainInputType.Guid, "Id")
                                                                  .AddDefaultOutputViewParameter());
                schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.View, DefaultViewNames.ModifiedBy, false)
                                                                  .AddInputParameter(DomainInputType.Guid, "Id")
                                                                  .AddDefaultOutputViewParameter());
            }

            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.Create, DefaultRepositoryMethodNames.Create, false)
                                                              .AddInputParameter(DomainInputType.DomainEntity, "Entity")
                                                              .AddOutputParameter(DomainInputType.Guid, "Id"));

            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.DeleteByPk, DefaultRepositoryMethodNames.DeleteByPk, false)
                                                              .AddInputParameter(DomainInputType.Guid, "Id"));;

            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.Update, DefaultRepositoryMethodNames.Update, false)
                                                              .AddInputParameter(DomainInputType.DomainEntity, "Entity"));

            schema.GetDefaultRepository().AddRepositoryMethod(new RepositoryMethod(UseCase.UseCaseTypes.RetrieveByPk, DefaultRepositoryMethodNames.RetrieveByPk, false)
                                                              .AddInputParameter(DomainInputType.Guid, "Id")
                                                              .AddOutputParameter(DomainInputType.DomainEntity, "Entity"));

            var useCaseCreate       = GetCreateUseCase(domain, schema);
            var useCaseUpdate       = GetUpdateUseCase(domain, schema);
            var useCaseDeleteByPk   = GetDeleteByPkUseCase(domain, schema);
            var useCaseRetrieveByPk = GetRetrieveByPkUseCase(domain, schema);

            schema.AddUseCase(useCaseCreate);
            schema.AddUseCase(useCaseDeleteByPk);
            schema.AddUseCase(useCaseRetrieveByPk);
            schema.AddUseCase(useCaseUpdate);

            domain.AddSchema(schema);

            OverrideOutputParameter(NameParameter.Name, name);
        }
Example #7
0
        public override void Execute(ProjectState project, List <ActionParameter> parameters)
        {
            var schemaName = GetStringParameterValue(parameters, SchemaNameParameter).ToWordPascalCase();

            var addId               = GetBoolParameterValue(parameters, AddIdParameter);
            var addState            = GetBoolParameterValue(parameters, AddStateParameter);
            var addDates            = GetBoolParameterValue(parameters, AddDatesParameter);
            var addUserRelationship = GetBoolParameterValue(parameters, AddUserRelationshipParameter);
            var addOwner            = GetBoolParameterValue(parameters, AddOwnerParameter);
            var schema              = project.GetSchema(schemaName);

            if (schema == null)
            {
                throw new Exception($"Can't find any schema named '{schemaName}'");
            }

            if (addId && !schema.HasId)
            {
                schema.HasId = true;
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.Id, SchemaProperty.PropertyTypes.PrimaryKey, false)
                {
                    IsPrimaryKey = true
                });
            }
            if (addState && !schema.HasState)
            {
                schema.HasState = true;
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.State, SchemaProperty.PropertyTypes.State, false));
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.Status, SchemaProperty.PropertyTypes.Status, false));
            }
            if (addDates && !schema.HasDates)
            {
                schema.HasDates = true;
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.CreatedOn, SchemaProperty.PropertyTypes.DateTime, false));
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.ModifiedOn, SchemaProperty.PropertyTypes.DateTime, false));
            }
            if (addOwner && !schema.HasOwner)
            {
                var userSchema = project.GetSchema(Definitions.DefaultBasicDomainNames.User);
                if (userSchema == null)
                {
                    throw new Exception("Can't add user relationship because 'User' domain doesn't exists");
                }
                schema.HasOwner = true;
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.Owner, SchemaProperty.PropertyTypes.ForeingKey, false)
                {
                    ForeingSchema = userSchema
                });
            }
            if (addUserRelationship && !schema.HasUserRelationship)
            {
                var userSchema = project.GetSchema(Definitions.DefaultBasicDomainNames.User);
                if (userSchema == null)
                {
                    throw new Exception("Can't add user relationship because 'User' domain doesn't exists");
                }
                schema.HasUserRelationship = true;
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.CreatedBy, SchemaProperty.PropertyTypes.ForeingKey, false)
                {
                    ForeingSchema = userSchema
                });
                schema.AddProperty(new SchemaProperty(Definitions.DefaultAttributesSchemaNames.ModifiedOn, SchemaProperty.PropertyTypes.ForeingKey, false)
                {
                    ForeingSchema = userSchema
                });
            }

            OverrideOutputParameter(SchemaNameParameter.Name, schemaName);
        }