コード例 #1
0
ファイル: ModificationTracker.cs プロジェクト: ozialien/NORMA
            /// <summary>
            /// RolePlayerPositionChangeRule: typeof(ORMSolutions.ORMArchitect.ORMAbstraction.UniquenessIncludesConceptTypeChild)
            /// Reorder the columns in a uniqueness constraint when the order changes
            /// </summary>
            private static void UniquenessConstraintRoleOrderChanged(RolePlayerOrderChangedEventArgs e)
            {
                Uniqueness uniqueness;
                LinkedElementCollection <UniquenessConstraint> constraints;
                int constraintCount;

                if (null != (uniqueness = e.SourceElement as Uniqueness) &&
                    e.SourceDomainRole.Id == UniquenessIncludesConceptTypeChild.UniquenessDomainRoleId &&
                    0 != (constraintCount = (constraints = UniquenessConstraintIsForUniqueness.GetUniquenessConstraint(uniqueness)).Count))
                {
                    LinkedElementCollection <ConceptTypeChild> conceptTypeChildren = uniqueness.ConceptTypeChildCollection;
                    int conceptTypeChildCount = conceptTypeChildren.Count;
                    for (int i = 0; i < constraintCount; ++i)
                    {
                        LinkedElementCollection <Column> constraintColumns = constraints[i].ColumnCollection;
                        int constraintColumnCount = constraintColumns.Count;
                        if (constraintColumnCount == conceptTypeChildCount)
                        {
                            constraintColumns.Move(e.OldOrdinal, e.NewOrdinal);
                        }
                        else
                        {
                            // UNDONE: The question of exactly how many columns are associated with a reference to
                            // a conceptTypeChild is highly non-trivial. Punt on the issue for now by regenerating
                            // the model.
                            ConceptType conceptType = uniqueness.ConceptType;
                            if (conceptType != null)
                            {
                                RebuildAbstractionModel(conceptType.Model);
                            }
                        }
                    }
                }
            }
コード例 #2
0
ファイル: ModificationTracker.cs プロジェクト: ozialien/NORMA
            /// <summary>
            /// DeletingRule: typeof(ORMSolutions.ORMArchitect.ORMAbstraction.UniquenessIncludesConceptTypeChild)
            /// Remove a column in a uniqueness constraint when a concept type child is removed from the
            /// corresponding abstraction construct
            /// </summary>
            private static void UniquenessConstraintRoleDeleting(ElementDeletingEventArgs e)
            {
                UniquenessIncludesConceptTypeChild link = (UniquenessIncludesConceptTypeChild)e.ModelElement;
                Uniqueness uniqueness = link.Uniqueness;
                LinkedElementCollection <UniquenessConstraint> constraints;
                int constraintCount;

                if (!uniqueness.IsDeleting &&
                    !link.ConceptTypeChild.IsDeleting &&
                    0 != (constraintCount = (constraints = UniquenessConstraintIsForUniqueness.GetUniquenessConstraint(uniqueness)).Count))
                {
                    int removeAtIndex = UniquenessIncludesConceptTypeChild.GetLinksToConceptTypeChildCollection(uniqueness).IndexOf(link);
                    for (int i = 0; i < constraintCount; ++i)
                    {
                        constraints[i].ColumnCollection.RemoveAt(removeAtIndex);
                    }
                }
            }