private static void RebuildForAbstractionModelDelayed(ModelElement element) { if (!element.IsDeleted) { AbstractionModel model = (AbstractionModel)element; BarkerErModel barkerModel = BarkerErModelIsForAbstractionModel.GetBarkerErModel(model); if (barkerModel != null) { barkerModel.BinaryAssociationCollection.Clear(); barkerModel.EntityTypeCollection.Clear(); barkerModel.ExclusiveArcCollection.Clear(); FullyGenerateBarkerERModel(barkerModel, model, null); } } }
/// <summary> /// Verify that an abstraction model has an appropriate Barker ER model and bridge /// </summary> protected override void ProcessElement(AbstractionModel element, Store store, INotifyElementAdded notifyAdded) { BarkerErModel barkerModel = BarkerErModelIsForAbstractionModel.GetBarkerErModel(element); if (barkerModel == null) { // Create the initial Barker ER model and notify barkerModel = new BarkerErModel( store, new PropertyAssignment[] { new PropertyAssignment(BarkerErModel.NameDomainPropertyId, element.Name) }); new BarkerErModelIsForAbstractionModel(barkerModel, element); BarkerERModelGenerationSetting generationSetting = new BarkerERModelGenerationSetting(store, new PropertyAssignment( BarkerERModelGenerationSetting.CoreAlgorithmVersionDomainPropertyId, CurrentCoreAlgorithmVersion), new PropertyAssignment( BarkerERModelGenerationSetting.NameAlgorithmVersionDomainPropertyId, CurrentNameAlgorithmVersion)); new GenerationSettingTargetsBarkerERModel(generationSetting, barkerModel); new ORMCore.GenerationStateHasGenerationSetting(ORMCore.GenerationState.EnsureGenerationState(store), generationSetting); notifyAdded.ElementAdded(barkerModel, true); FullyGenerateBarkerERModel(barkerModel, element, notifyAdded); } else { BarkerERModelGenerationSetting generationSetting = GenerationSettingTargetsBarkerERModel.GetGenerationSetting(barkerModel); bool regenerateAll = generationSetting == null || generationSetting.CoreAlgorithmVersion != CurrentCoreAlgorithmVersion; bool regenerateNames = false; if (!regenerateAll) { foreach (EntityType barkerEntity in barkerModel.EntityTypeCollection) { if (null == EntityTypeIsPrimarilyForConceptType.GetLinkToConceptType(barkerEntity)) { regenerateAll = true; break; } // Theoretically we should also check that all attributes and uniqueness constraints // are pathed back to the abstraction model. However, this is far from a full validation, // and the scenario we're trying to cover is the abstraction model regenerating during // load and removing our bridge elements. The entity type check above is sufficient. } regenerateNames = !regenerateAll && generationSetting.NameAlgorithmVersion != CurrentNameAlgorithmVersion; generationSetting.NameAlgorithmVersion = CurrentNameAlgorithmVersion; } else { if (generationSetting == null) { generationSetting = new BarkerERModelGenerationSetting(store, new PropertyAssignment( BarkerERModelGenerationSetting.CoreAlgorithmVersionDomainPropertyId, CurrentCoreAlgorithmVersion), new PropertyAssignment( BarkerERModelGenerationSetting.NameAlgorithmVersionDomainPropertyId, CurrentNameAlgorithmVersion)); new GenerationSettingTargetsBarkerERModel(generationSetting, barkerModel); new ORMCore.GenerationStateHasGenerationSetting(ORMCore.GenerationState.EnsureGenerationState(store), generationSetting); } else { regenerateNames = generationSetting.NameAlgorithmVersion != CurrentNameAlgorithmVersion; generationSetting.CoreAlgorithmVersion = CurrentCoreAlgorithmVersion; generationSetting.NameAlgorithmVersion = CurrentNameAlgorithmVersion; } } if (regenerateAll) { barkerModel.BinaryAssociationCollection.Clear(); barkerModel.EntityTypeCollection.Clear(); barkerModel.ExclusiveArcCollection.Clear(); FullyGenerateBarkerERModel(barkerModel, element, notifyAdded); } else if (regenerateNames) { //NameGeneration.GenerateAllNames(barkerModel); } } }