예제 #1
0
        private ICollection <EntityDescriptor.Attribute> GetForeignKeys(EntityDescriptor entityDescriptor)
        {
            IEnumerator <EntityDescriptor.Relationship> oneToManyRealtionships  = entityDescriptor.GetManyToOneRelationships();
            IEnumerator <EntityDescriptor.Relationship> manyToManyRealtionships = entityDescriptor.GetManyToManyRelationships();

            ICollection <EntityDescriptor.Attribute> foreignAttributes = new List <EntityDescriptor.Attribute>();

            IEnumerator <EntityDescriptor.Attribute> attributes = entityDescriptor.GetAttributes();

            while (attributes.MoveNext())
            {
                EntityDescriptor.Attribute attribute = attributes.Current;
                if (attribute.IsPrimaryKey())
                {
                    foreignAttributes.Add(attribute);
                }
            }

            while (oneToManyRealtionships.MoveNext())
            {
                EntityDescriptor.Relationship relationship = oneToManyRealtionships.Current;
                EntityDescriptor referedEntityDescriptor   = relationship.GetReferedEntityDescriptor();

                ICollection <EntityDescriptor.Attribute> referedForeignKeys        = GetForeignKeys(referedEntityDescriptor);
                IEnumerator <EntityDescriptor.Attribute> referedForeignKeysIterate = referedForeignKeys.GetEnumerator();

                while (referedForeignKeysIterate.MoveNext())
                {
                    foreignAttributes.Add(referedForeignKeysIterate.Current);
                }
            }

            while (manyToManyRealtionships.MoveNext())
            {
                EntityDescriptor.Relationship relationship = manyToManyRealtionships.Current;
                EntityDescriptor referedEntityDescriptor   = relationship.GetReferedEntityDescriptor();

                ICollection <EntityDescriptor.Attribute> referedForeignKeys        = GetForeignKeys(referedEntityDescriptor);
                IEnumerator <EntityDescriptor.Attribute> referedForeignKeysIterate = referedForeignKeys.GetEnumerator();

                while (referedForeignKeysIterate.MoveNext())
                {
                    foreignAttributes.Add(referedForeignKeysIterate.Current);
                }
            }

            return(foreignAttributes);
        }
예제 #2
0
        private void DoValidation()
        {
            /*
             * Validate Table Name field.
             */
            String tableName = entityDescriptor.GetTableName();

            if (tableName == null || tableName.Length <= 0)
            {
                Log.Log.Error(typeof(EntityDescriptorReader).FullName, "DoValidation", "TABLE-NAME IS MANDATORY FIELD - ENTITY-DESCRIPTOR: " + this.entityDescriptorName);
                throw new DeploymentException(typeof(EntityDescriptorReader).FullName, "DoValidation", "TABLE-NAME IS MANDATORY FIELD - ENTITY-DESCRIPTOR: " + this.entityDescriptorName);
            }

            /*
             * Validate Class Name field.
             */
            String className = entityDescriptor.GetClassName();

            if (className == null || className.Length <= 0)
            {
                Log.Log.Error(typeof(EntityDescriptorReader).FullName, "DoValidation", "CLASS-NAME IS MANDATORY FIELD - ENTITY-DESCRIPTOR: " + this.entityDescriptorName);
                throw new DeploymentException(typeof(EntityDescriptorReader).FullName, "DoValidation", "CLASS-NAME IS MANDATORY FIELD - ENTITY-DESCRIPTOR: " + this.entityDescriptorName);
            }

            IEnumerator <EntityDescriptor.Attribute> attributes = entityDescriptor.GetAttributes();

            while (attributes.MoveNext())
            {
                EntityDescriptor.Attribute attribute = attributes.Current;

                /*
                 * Validate Variable Name field.
                 */
                String variableName = attribute.GetVariableName();
                if (variableName == null || variableName.Length <= 0)
                {
                    Log.Log.Error(typeof(EntityDescriptorReader).FullName, "DoValidation", "VARIABLE-NAME IS MANDATORY FIELD - ENTITY-DESCRIPTOR - COLUMN: " + this.entityDescriptorName);
                    throw new DeploymentException(typeof(EntityDescriptorReader).FullName, "DoValidation", "VARIABLE-NAME IS MANDATORY FIELD - ENTITY-DESCRIPTOR - COLUMN: " + this.entityDescriptorName);
                }

                /*
                 * Validate Column Name filed.
                 */
                String columnName = attribute.GetColumnName();
                if (columnName == null || columnName.Length <= 0)
                {
                    Log.Log.Error(typeof(EntityDescriptorReader).FullName, "DoValidation", "COLUMN-NAME IS MANDATORY FIELD - ENTITY-DESCRIPTOR - COLUMN: " + this.entityDescriptorName);
                    throw new DeploymentException(typeof(EntityDescriptorReader).FullName, "DoValidation", "COLUMN-NAME IS MANDATORY FIELD - ENTITY-DESCRIPTOR - COLUMN: " + this.entityDescriptorName);
                }

                /*
                 * Validate Type field.
                 */
                String type = attribute.GetType();
                if (type == null || type.Length <= 0)
                {
                    Log.Log.Error(typeof(EntityDescriptorReader).FullName, "DoValidation", "COLUMN-TYPE IS MANDATORY FIELD - ENTITY-DESCRIPTOR - COLUMN: " + this.entityDescriptorName);
                    throw new DeploymentException(typeof(EntityDescriptorReader).FullName, "DoValidation", "COLUMN-TYPE IS MANDATORY FIELD - ENTITY-DESCRIPTOR - COLUMN: " + this.entityDescriptorName);
                }
            }
        }