/// <summary>
        /// Validates this object.
        /// </summary>
        /// <param name="validationLog">The validation information.</param>
        protected internal override void Validate(ValidationLog validationLog)
        {
            base.Validate(validationLog);

            if (!ExistObjectType)
            {
                var message = this.ValidationName + " has no object type";
                validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.AssociationTypeObjectType);
            }

            if (!ExistRelationTypeWhereAssociationType)
            {
                var message = this.ValidationName + " has no relation type";
                validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.RelationTypeAssociationType);
            }

            if (ExistAssignedSingularName && !ExistAssignedPluralName)
            {
                var message = this.ValidationName + " has a singular but no plural name";
                validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.AssociationTypeAssignedPluralName);
            }

            if (this.ExistAssignedSingularName && this.AssignedSingularName.Length < 2)
            {
                var message = this.ValidationName + " should have an assigned singular name with at least 2 characters";
                validationLog.AddError(message, this, ValidationKind.MinimumLength, AllorsEmbeddedDomain.AssociationTypeAssignedSingularName);
            }

            if (this.ExistAssignedPluralName && this.AssignedPluralName.Length < 2)
            {
                var message = this.ValidationName + " should have an assigned plural name with at least 2 characters";
                validationLog.AddError(message, this, ValidationKind.MinimumLength, AllorsEmbeddedDomain.AssociationTypeAssignedPluralName);
            }
        }
Exemple #2
0
        /// <summary>
        /// Validates the instance.
        /// </summary>
        /// <param name="validationLog">The validation.</param>
        protected internal override void Validate(ValidationLog validationLog)
        {
            base.Validate(validationLog);

            if (!ExistName)
            {
                var message = this.ValidationName + " has no name";
                validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.MethodTypeName);
            }
        }
        /// <summary>
        /// Validates this instance.
        /// </summary>
        /// <param name="validationLog">The validation.</param>
        protected internal override void Validate(ValidationLog validationLog)
        {
            base.Validate(validationLog);

            if (ExistSubtype && ExistSupertype)
            {
                if (this.Subtype.IsCyclicInheritance(this.Supertype))
                {
                    var message = this.ValidationName + " has a cycle in its inheritance hierarchy";
                    validationLog.AddError(message, this, ValidationKind.Cyclic, AllorsEmbeddedDomain.InheritanceSubtype);
                }

                var inheritance = this.Subtype.FindInheritanceWhereDirectSubtype(this.Supertype);
                if (inheritance != null && !this.Equals(inheritance))
                {
                    var message = "name of " + this.ValidationName + " is already in use";
                    validationLog.AddError(message, this, ValidationKind.Unique, AllorsEmbeddedDomain.InheritanceSupertype);
                }

                if (this.Supertype.IsClass && this.Subtype.ExistDirectSuperclass)
                {
                    var existingInheritance = this.Subtype.FindInheritanceWhereDirectSubtype(this.Subtype.DirectSuperclass);
                    if (!this.Equals(existingInheritance))
                    {
                        var message = "multiple class inheritance is not supported (" + this.ValidationName + ")";
                        validationLog.AddError(message, this, ValidationKind.Exclusive, AllorsEmbeddedDomain.InheritanceSupertype);
                    }
                }

                if (this.Supertype.IsConcreteComposite)
                {
                    var message = this.ValidationName + " can not have a concrete superclass";
                    validationLog.AddError(message, this, ValidationKind.Hierarchy, AllorsEmbeddedDomain.InheritanceSupertype);
                }

                if (this.Supertype.IsAbstractComposite && this.Subtype.IsInterface)
                {
                    var message = this.ValidationName + " can not have an abstract superclass";
                    validationLog.AddError(message, this, ValidationKind.Hierarchy, AllorsEmbeddedDomain.InheritanceSupertype);
                }
            }
            else
            {
                if (!ExistSubtype)
                {
                    var message = this.ValidationName + " has a missing Supertype";
                    validationLog.AddError(message, this, ValidationKind.Unique, AllorsEmbeddedDomain.InheritanceSupertype);
                }
                else
                {
                    var message = this.ValidationName + " has a missing Subtype";
                    validationLog.AddError(message, this, ValidationKind.Unique, AllorsEmbeddedDomain.InheritanceSupertype);
                }
            }
        }
        /// <summary>
        /// Validates this. instance.
        /// </summary>
        /// <param name="validationLog">The validation.</param>
        protected internal override void Validate(ValidationLog validationLog)
        {
            base.Validate(validationLog);

            if (this.ExistAssociationType && this.ExistRoleType)
            {
                if (validationLog.ExistRelationName(this.Name))
                {
                    var message = "name of " + this.ValidationName + " is already in use";
                    validationLog.AddError(message, this, ValidationKind.Unique, AllorsEmbeddedDomain.RoleTypeAssignedSingularName);
                }
                else
                {
                    validationLog.AddRelationTypeName(this.Name);
                }

                if (validationLog.ExistRelationName(this.ReverseName))
                {
                    var message = "reversed name of " + this.ValidationName + " is already in use";
                    validationLog.AddError(message, this, ValidationKind.Unique, AllorsEmbeddedDomain.RoleTypeAssignedSingularName);
                }
                else
                {
                    validationLog.AddRelationTypeName(this.ReverseName);
                }

                if (validationLog.ExistObjectTypeName(this.Name))
                {
                    var message = "name of " + this.ValidationName + " is in conflict with object type " + this.Name;
                    validationLog.AddError(message, this, ValidationKind.Unique, AllorsEmbeddedDomain.RoleTypeAssignedSingularName);
                }

                if (validationLog.ExistObjectTypeName(this.ReverseName))
                {
                    var message = "reversed name of " + this.ValidationName + " is in conflict with object type " + this.Name;
                    validationLog.AddError(message, this, ValidationKind.Unique, AllorsEmbeddedDomain.RoleTypeAssignedSingularName);
                }
            }
            else
            {
                if (!this.ExistAssociationType)
                {
                    var message = this.ValidationName + " has no association type";
                    validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.RelationTypeAssociationType);
                }

                if (!this.ExistRoleType)
                {
                    var message = this.ValidationName + " has no role type";
                    validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.RelationTypeRoleType);
                }
            }
        }
 /// <summary>
 /// Validate this object.
 /// </summary>
 /// <param name="validationLog">
 /// The validation log.
 /// </param>
 protected internal virtual void Validate(ValidationLog validationLog)
 {
     if (!this.ExistId)
     {
         var message = "id on " + this.ValidationName + " is required";
         validationLog.AddError(message, this, ValidationKind.Unique, AllorsEmbeddedDomain.MetaObjectId);
     }
     else
     {
         if (validationLog.ExistId(this.Id))
         {
             var message = "id " + this.ValidationName + " is already in use";
             validationLog.AddError(message, this, ValidationKind.Unique, AllorsEmbeddedDomain.MetaObjectId);
         }
         else
         {
             validationLog.AddId(this.Id);
         }
     }
 }
        /// <summary>
        /// Validates the instance.
        /// </summary>
        /// <param name="validationLog">The validation.</param>
        protected internal override void Validate(ValidationLog validationLog)
        {
            base.Validate(validationLog);

            if (!ExistObjectType)
            {
                var message = this.ValidationName + " has no ObjectType";
                validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.RoleTypeObjectType);
            }
            else
            {
                if (this.ObjectType.IsUnit)
                {
                    switch ((UnitTypeTags)this.ObjectType.UnitTag)
                    {
                    case UnitTypeTags.AllorsString:
                        if (!this.ExistSize)
                        {
                            var message = this.ValidationName + " should have a size.";
                            validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.RoleTypeSize);
                        }

                        break;

                    case UnitTypeTags.AllorsBinary:
                        if (!this.ExistSize)
                        {
                            var message = this.ValidationName + " should have a size.";
                            validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.RoleTypeSize);
                        }

                        break;

                    case UnitTypeTags.AllorsDecimal:
                        if (!this.ExistPrecision)
                        {
                            var message = this.ValidationName + " should have a precision.";
                            validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.RoleTypePrecision);
                        }

                        if (!this.ExistScale)
                        {
                            var message = this.ValidationName + " should have a scale.";
                            validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.RoleTypeScale);
                        }

                        break;
                    }
                }
            }

            if (!ExistRelationTypeWhereRoleType)
            {
                var message = this.ValidationName + " has no relation type";
                validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.RelationTypeRoleType);
            }

            if (ExistAssignedSingularName && !ExistAssignedPluralName)
            {
                var message = this.ValidationName + " has a singular but no plural name";
                validationLog.AddError(message, this, ValidationKind.Required, AllorsEmbeddedDomain.RoleTypeAssignedPluralName);
            }

            if (this.ExistAssignedSingularName && this.AssignedSingularName.Length < 2)
            {
                var message = this.ValidationName + " should have an assigned singular name with at least 2 characters";
                validationLog.AddError(message, this, ValidationKind.MinimumLength, AllorsEmbeddedDomain.RoleTypeAssignedSingularName);
            }

            if (this.ExistAssignedPluralName && this.AssignedPluralName.Length < 2)
            {
                var message = this.ValidationName + " should have an assigned plural role name with at least 2 characters";
                validationLog.AddError(message, this, ValidationKind.MinimumLength, AllorsEmbeddedDomain.RoleTypeAssignedPluralName);
            }
        }