Exemplo n.º 1
0
 private static void UpdateChildNamesForFactTypeDelayedWorker(ModelElement element)
 {
     if (!element.IsDeleted)
     {
         FactType factType = (FactType)element;
         foreach (ConceptTypeChild child in ConceptTypeChildHasPathFactType.GetConceptTypeChild(factType))
         {
             LinkedElementCollection <FactType> factTypePath = ConceptTypeChildHasPathFactType.GetPathFactTypeCollection(child);
             int      pathCount;
             RoleBase towardsRole;
             RoleBase fromRole;
             if (0 != (pathCount = factTypePath.Count) &&
                 factType == factTypePath[pathCount - 1] &&
                 null != (towardsRole = FactTypeMapsTowardsRole.GetTowardsRole(factType)) &&
                 null != (fromRole = towardsRole.OppositeRole))
             {
                 string resolvedName = ResolveRoleName(fromRole);
                 ConceptTypeReferencesConceptType reference;
                 if (null != (reference = child as ConceptTypeReferencesConceptType))
                 {
                     // Match original backwards pattern
                     reference.OppositeName = resolvedName;
                     child.Name             = ResolveRoleName(towardsRole);
                 }
                 else
                 {
                     child.Name = resolvedName;
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 private static void ValidateMandatoryDelayed(ModelElement element)
 {
     if (!element.IsDeleted)
     {
         ConceptTypeChild child        = (ConceptTypeChild)element;
         bool             newMandatory = true;
         foreach (FactType factType in ConceptTypeChildHasPathFactType.GetPathFactTypeCollection(child))
         {
             FactTypeMapsTowardsRole towardsRoleLink = FactTypeMapsTowardsRole.GetLinkToTowardsRole(factType);
             if (null == towardsRoleLink)
             {
                 newMandatory = false;
                 break;
             }
             else
             {
                 switch (towardsRoleLink.MandatoryPattern)
                 {
                 case MappingMandatoryPattern.None:
                 case MappingMandatoryPattern.NotMandatory:
                 case MappingMandatoryPattern.OppositeRoleMandatory:
                     newMandatory = false;
                     break;
                 }
                 if (!newMandatory)
                 {
                     break;
                 }
             }
         }
         child.IsMandatory = newMandatory;
     }
 }
Exemplo n.º 3
0
            private static void FactTypeConstraintPatternChangedDelayed(ModelElement element)
            {
                FactType factType;
                ORMModel model;

                if (!element.IsDeleted &&
                    null != (model = (factType = (FactType)element).Model) &&
                    !ORMElementGateway.IsElementExcluded(factType))
                {
                    // If we're not previously mapped, then we will have been added at this point
                    FactTypeMapsTowardsRole mapToRole = FactTypeMapsTowardsRole.GetLinkToTowardsRole(factType);
                    if (mapToRole != null)
                    {
                        MappingMandatoryPattern startMandatoryPattern = mapToRole.MandatoryPattern;
                        if (mapToRole.SynchronizeMappingPatterns())
                        {
                            MappingMandatoryPattern endMandatoryPattern = mapToRole.MandatoryPattern;
                            if (endMandatoryPattern != startMandatoryPattern)
                            {
                                foreach (ConceptTypeChild child in ConceptTypeChildHasPathFactType.GetConceptTypeChild(factType))
                                {
                                    ValidateMandatory(child, startMandatoryPattern, endMandatoryPattern);
                                }
                            }
                        }
                        else
                        {
                            AddTransactedModelElement(factType, ModelElementModification.ORMElementChanged);
                            FrameworkDomainModel.DelayValidateElement(model, DelayValidateModel);
                        }
                    }
                }
            }
Exemplo n.º 4
0
 private static void UpdateNamesForObjectTypeDelayed(ModelElement element)
 {
     if (!element.IsDeleted)
     {
         ObjectType  objectType     = (ObjectType)element;
         string      objectTypeName = objectType.Name;
         ConceptType conceptType    = ConceptTypeIsForObjectType.GetConceptType(objectType);
         LinkedElementCollection <FactType> pathFactTypes;
         int      factTypeCount;
         RoleBase towardsRole;
         RoleBase oppositeRole;
         if (null != conceptType)
         {
             // Precheck name to minimize downstream calls, the property change
             // will check itself.
             if (conceptType.Name != objectTypeName)
             {
                 conceptType.Name = objectTypeName;
                 foreach (ConceptTypeReferencesConceptType reference in ConceptTypeReferencesConceptType.GetLinksToReferencingConceptTypeCollection(conceptType))
                 {
                     pathFactTypes = ConceptTypeChildHasPathFactType.GetPathFactTypeCollection(reference);
                     if (0 != (factTypeCount = pathFactTypes.Count) &&
                         null != (towardsRole = FactTypeMapsTowardsRole.GetTowardsRole(pathFactTypes[factTypeCount - 1])) &&
                         null != (oppositeRole = towardsRole.OppositeRole))
                     {
                         reference.OppositeName = ResolveRoleName(oppositeRole);
                     }
                 }
                 foreach (ConceptTypeReferencesConceptType reference in ConceptTypeReferencesConceptType.GetLinksToReferencedConceptTypeCollection(conceptType))
                 {
                     pathFactTypes = ConceptTypeChildHasPathFactType.GetPathFactTypeCollection(reference);
                     if (0 != (factTypeCount = pathFactTypes.Count) &&
                         null != (towardsRole = FactTypeMapsTowardsRole.GetTowardsRole(pathFactTypes[factTypeCount - 1])))
                     {
                         reference.Name = ResolveRoleName(towardsRole);
                     }
                 }
             }
         }
         InformationTypeFormat informationTypeFormat = InformationTypeFormatIsForValueType.GetInformationTypeFormat(objectType);
         if (null != informationTypeFormat)
         {
             if (informationTypeFormat.Name != objectTypeName)
             {
                 informationTypeFormat.Name = objectTypeName;
                 foreach (InformationType informationType in InformationType.GetLinksToConceptTypeCollection(informationTypeFormat))
                 {
                     pathFactTypes = ConceptTypeChildHasPathFactType.GetPathFactTypeCollection(informationType);
                     if (0 != (factTypeCount = pathFactTypes.Count) &&
                         null != (towardsRole = FactTypeMapsTowardsRole.GetTowardsRole(pathFactTypes[factTypeCount - 1])) &&
                         null != (oppositeRole = towardsRole.OppositeRole))
                     {
                         informationType.Name = ResolveRoleName(oppositeRole);
                     }
                 }
             }
         }
     }
 }
            /// <summary>
            /// Make sure we have our tracker attached to all loaded models.
            /// </summary>
            /// <param name="element">An ORMModel element</param>
            /// <param name="store">The context store</param>
            /// <param name="notifyAdded">The listener to notify if elements are added during fixup</param>
            protected sealed override void ProcessElement(ORMModel element, Store store, INotifyElementAdded notifyAdded)
            {
                AbstractionModel oil = AbstractionModelIsForORMModel.GetAbstractionModel(element);

                if (oil == null)
                {
                    // UNDONE: DelayValidateModel currently deletes and recreates any existing
                    // bridge relationship, so there is no point deleting it up front, we'll
                    // just retrieve it later. Also note that DelayValidateModel does not call notifyAdded.
                    DelayValidateModel(element);
                    oil = AbstractionModelIsForORMModel.GetAbstractionModel(element);
                    if (oil != null)
                    {
                        notifyAdded.ElementAdded(oil, true);
                    }
                }
                else
                {
                    AbstractionModelGenerationSetting generationSetting;
                    bool regenerateForVersion   = null == (generationSetting = GenerationSettingTargetsAbstractionModel.GetGenerationSetting(oil)) || generationSetting.AlgorithmVersion != CurrentAlgorithmVersion;
                    bool excludedBridgedElement = false;
                    ORMElementGateway.Initialize(
                        element,
                        regenerateForVersion ? (ORMElementGateway.NotifyORMElementExcluded) null :
                        delegate(ORMModelElement modelElement)
                    {
                        if (excludedBridgedElement)
                        {
                            return;
                        }
                        ObjectType objectType;
                        FactType factType;
                        // Note that the types we're checking here are synchronized with the ORMElementGateway.ExclusionAdded method
                        if (null != (objectType = modelElement as ObjectType))
                        {
                            if (null != ConceptTypeIsForObjectType.GetLinkToConceptType(objectType) ||
                                null != InformationTypeFormatIsForValueType.GetLinkToInformationTypeFormat(objectType))
                            {
                                excludedBridgedElement = true;
                            }
                        }
                        else if (null != (factType = modelElement as FactType))
                        {
                            if (null != FactTypeMapsTowardsRole.GetLinkToTowardsRole(factType) ||
                                ConceptTypeChildHasPathFactType.GetLinksToConceptTypeChild(factType).Count != 0)
                            {
                                excludedBridgedElement = true;
                            }
                        }
                    });
                    if (regenerateForVersion || excludedBridgedElement)
                    {
                        // Something is very wrong, regenerate (does not regenerate the excluded elements we already have)
                        DelayValidateModel(element);
                    }
                }
            }