예제 #1
0
            private static void ValidateAssociatedColumnsIsNullable(ConceptTypeChild child)
            {
                bool canBeNullable = !child.IsMandatory;

                foreach (Column column in ColumnHasConceptTypeChild.GetColumn(child))
                {
                    FrameworkDomainModel.DelayValidateElement(column, ValidateColumnIsNullableDelayed);
                }
            }
예제 #2
0
 private static void DelayValidateConceptTypeChildNameChanged(ModelElement element)
 {
     if (!element.IsDeleted)
     {
         ConceptTypeChild child = (ConceptTypeChild)element;
         foreach (Column column in ColumnHasConceptTypeChild.GetColumn(child))
         {
             ValidateSchemaNamesChanged(column.Table.Schema);
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Implements <see cref="IVerbalize.GetVerbalization"/>
        /// </summary>
        protected bool GetVerbalization(TextWriter writer, IDictionary <Type, IVerbalizationSets> snippetsDictionary, IVerbalizationContext verbalizationContext, VerbalizationSign sign)
        {
            // We are redirected to this point by the associated Column element
            Column column     = this.Column;
            bool   firstWrite = true;

            foreach (ConceptTypeChild child in ColumnHasConceptTypeChild.GetConceptTypeChildPath(this.Column))
            {
                foreach (FactType factType in ConceptTypeChildHasPathFactType.GetPathFactTypeCollection(child))
                {
                    if (firstWrite)
                    {
                        firstWrite = false;
                    }
                    else
                    {
                        writer.WriteLine();
                    }
                    verbalizationContext.DeferVerbalization(factType, DeferVerbalizationOptions.MultipleVerbalizations, null);
                }
            }
            return(false);
        }
        /// <summary>
        /// Get a minimal unique identifier for a column based on mapped roles. The identifer
        /// will stop as soon as the fact type is used in a single column or in a partitioned
        /// or separated column.
        /// </summary>
        /// <param name="column">The <see cref="Column"/> to analyze</param>
        /// <param name="idList">Scratch list used to determine keys</param>
        /// <param name="minKeySize">The minimum number of ids that uniquely
        /// identify this column. The actually key may be longer than this
        /// minimimum for partitioned and separated tables. Key comparisons
        /// may be performed down to this minimum size.</param>
        /// <returns><see langword="true"/> if the key was available.</returns>
        private static bool BuildKey(Column column, List <Guid> idList, out int minKeySize)
        {
            idList.Clear();
            int uniqueUseIndex = -1;

            minKeySize = 0;
            LinkedElementCollection <ConceptTypeChild> childNodes = ColumnHasConceptTypeChild.GetConceptTypeChildPath(column);

            for (int i = childNodes.Count - 1; i >= 0; --i)
            {
                ConceptTypeChild child       = childNodes[i];
                bool             uniqueChild = ColumnHasConceptTypeChild.GetLinksToColumn(child).Count == 1;
                LinkedElementCollection <FactType> pathFactTypes = ConceptTypeChildHasPathFactType.GetPathFactTypeCollection(child);
                int             factTypeCount = pathFactTypes.Count;
                InformationType infoType;
                ObjectType      objectType;
                if (0 != (factTypeCount = pathFactTypes.Count))
                {
                    for (int j = factTypeCount - 1; j >= 0; --j)
                    {
                        FactType factType = pathFactTypes[j];
                        idList.Add(FactTypeMapsTowardsRole.GetTowardsRole(factType).Id);
                        if (-1 == uniqueUseIndex &&
                            uniqueChild &&
                            ConceptTypeChildHasPathFactType.GetLinksToConceptTypeChild(factType).Count == 1)
                        {
                            minKeySize     = idList.Count;
                            uniqueUseIndex = minKeySize - 1;
                        }
                    }
                    ConceptTypeAssimilatesConceptType assimilation;
                    if (uniqueUseIndex != -1 &&
                        null != (assimilation = child as ConceptTypeAssimilatesConceptType) &&
                        AssimilationMapping.GetAbsorptionChoiceFromAssimilation(assimilation) != AssimilationAbsorptionChoice.Absorb)
                    {
                        uniqueUseIndex = idList.Count - 1;
                    }
                }
                else if (null != (infoType = child as InformationType) &&
                         null != (objectType = ConceptTypeIsForObjectType.GetObjectType(infoType.ConceptType)))
                {
                    // Happens for a value column in an object type table, which has one concept type child
                    idList.Add(objectType.Id);
                }
            }
            int count = idList.Count;

            if (0 == count)
            {
                return(false);
            }
            if (uniqueUseIndex != -1 &&
                (uniqueUseIndex + 1) < count)
            {
                idList.RemoveRange(uniqueUseIndex + 1, count - uniqueUseIndex - 1);
            }
            if (minKeySize == 0)
            {
                minKeySize = idList.Count;
            }
            return(true);
        }