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; } }
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); } } } }
/// <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); } } }