예제 #1
0
        private void ValidManyToMany()
        {
            ValidOneToMany();

            var secondaryCslaObject           = _cslaObjects.Find(SecondaryObject);
            var secondaryCslaObjectCollection = _cslaObjects.Find(SecondaryCollectionTypeName);
            var secondaryCslaObjectItem       = _cslaObjects.Find(SecondaryItemTypeName);

            if (secondaryCslaObject == null)
            {
                _validationError += "Secondary Object not found." + Environment.NewLine;
            }
            else if (!RelationRulesEngine.IsAllowedEntityObject(secondaryCslaObject))
            {
                _validationError += SecondaryObject + " isn't allowed to be Secondary Object." + Environment.NewLine;
            }

            if (secondaryCslaObjectCollection == null)
            {
                if (string.IsNullOrEmpty(SecondaryCollectionTypeName))
                {
                    _validationError += "Secondary Collection must be filled." + Environment.NewLine;
                }
            }
            else if (!RelationRulesEngine.IsAllowedEntityCollection(secondaryCslaObjectCollection))
            {
                _validationError += SecondaryCollectionTypeName + " isn't allowed to be Secondary Collection." +
                                    Environment.NewLine;
            }
            else
            {
                _validationError += ValidateLoadingScheme(SecondaryLoadingScheme, SecondaryLazyLoad, "Secondary");
            }

            if (secondaryCslaObjectItem == null)
            {
                if (string.IsNullOrEmpty(SecondaryItemTypeName))
                {
                    _validationError += "Secondary Collection Item must be filled." + Environment.NewLine;
                }
            }
            else if (!RelationRulesEngine.IsAllowedEntityCollectionItem(secondaryCslaObjectItem))
            {
                _validationError += SecondaryItemTypeName + " isn't allowed to be Secondary Collection Item." +
                                    Environment.NewLine;
            }

            if (secondaryCslaObjectCollection != null && secondaryCslaObjectItem != null)
            {
                if (
                    !RelationRulesEngine.IsCompatibleEntityCollectionItemPair(secondaryCslaObjectCollection,
                                                                              secondaryCslaObjectItem))
                {
                    _validationError += SecondaryCollectionTypeName + " Collection is not compatible with " +
                                        SecondaryItemTypeName + " Collection Item." + Environment.NewLine;
                }

                if (!IsChildCorrect(_cslaObjects, SecondaryObject, SecondaryCollectionTypeName))
                {
                    _validationError += SecondaryObject + " must be the parent of " + SecondaryCollectionTypeName + "." +
                                        Environment.NewLine;
                }

                if (!IsChildCorrect(_cslaObjects, SecondaryCollectionTypeName, SecondaryItemTypeName))
                {
                    _validationError += SecondaryCollectionTypeName + " must be the parent of " + SecondaryItemTypeName +
                                        "." + Environment.NewLine;
                }

                if (!IsItemCorrect(_cslaObjects, SecondaryCollectionTypeName, SecondaryItemTypeName))
                {
                    _validationError += SecondaryCollectionTypeName + " item must be " + SecondaryItemTypeName +
                                        "." + Environment.NewLine;
                }
            }

            var mainCslaObject = _cslaObjects.Find(MainObject);

            if (ObjectRelationsFactory.FindAssociativeTable(mainCslaObject, secondaryCslaObject) == null)
            {
                _validationError += "Associative table not found.";
            }
        }
예제 #2
0
        private void ValidOneToMany()
        {
            var mainCslaObject           = _cslaObjects.Find(MainObject);
            var mainCslaObjectCollection = _cslaObjects.Find(MainCollectionTypeName);
            var mainCslaObjectItem       = _cslaObjects.Find(MainItemTypeName);

            if (mainCslaObject == null)
            {
                _validationError += "Primary Object not found." + Environment.NewLine;
            }
            else if (!RelationRulesEngine.IsAllowedEntityObject(mainCslaObject))
            {
                _validationError += MainObject + " isn't allowed to be Primary Object." + Environment.NewLine;
            }
            else
            {
                _validationError += ValidateLoadingScheme(MainLoadingScheme, MainLazyLoad, "Primary");
            }

            if (mainCslaObjectCollection == null)
            {
                if (string.IsNullOrEmpty(MainCollectionTypeName))
                {
                    _validationError += "Primary Collection must be filled." + Environment.NewLine;
                }
                else
                {
                    if (RelationType == ObjectRelationType.OneToMany)
                    {
                        _validationError += "Primary Collection not found." + Environment.NewLine;
                    }
                }
            }
            else if (!RelationRulesEngine.IsAllowedEntityCollection(mainCslaObjectCollection))
            {
                _validationError += MainCollectionTypeName + " isn't allowed to be Primary Collection." +
                                    Environment.NewLine;
            }

            if (mainCslaObjectItem == null)
            {
                if (string.IsNullOrEmpty(MainItemTypeName))
                {
                    _validationError += "Primary Collection Item must be filled." + Environment.NewLine;
                }
                else
                {
                    if (RelationType == ObjectRelationType.OneToMany)
                    {
                        _validationError += "Primary Collection Item not found." + Environment.NewLine;
                    }
                }
            }
            else if (!RelationRulesEngine.IsAllowedEntityCollectionItem(mainCslaObjectItem))
            {
                _validationError += MainItemTypeName + " isn't allowed to be Primary Collection Item." +
                                    Environment.NewLine;
            }

            if (mainCslaObjectCollection != null && mainCslaObjectItem != null)
            {
                if (!RelationRulesEngine.IsCompatibleEntityCollectionItemPair(mainCslaObjectCollection,
                                                                              mainCslaObjectItem))
                {
                    _validationError += MainCollectionTypeName + " Collection is not compatible with " +
                                        MainItemTypeName + " Collection Item." + Environment.NewLine;
                }

                if (!IsChildCorrect(_cslaObjects, MainObject, MainCollectionTypeName))
                {
                    _validationError += MainObject + " must be the parent of " + MainCollectionTypeName + "." +
                                        Environment.NewLine;
                }

                if (!IsChildCorrect(_cslaObjects, MainCollectionTypeName, MainItemTypeName))
                {
                    _validationError += MainCollectionTypeName + " must be the parent of " + MainItemTypeName + "." +
                                        Environment.NewLine;
                }

                if (!IsItemCorrect(_cslaObjects, MainCollectionTypeName, MainItemTypeName))
                {
                    _validationError += MainCollectionTypeName + " item must be " + MainItemTypeName +
                                        "." + Environment.NewLine;
                }
            }
        }