コード例 #1
0
        private static void FullyGenerateBarkerERModel(BarkerErModel barkerModel, AbstractionModel sourceModel, INotifyElementAdded notifyAdded)
        {
            LinkedElementCollection <EntityType>  barkerEntities = barkerModel.EntityTypeCollection;
            LinkedElementCollection <ConceptType> conceptTypes   = sourceModel.ConceptTypeCollection;
            Store store = barkerModel.Store;

            // Generate all Barker entities
            List <ConceptType> manyToMany = new List <ConceptType>();

            foreach (ConceptType conceptType in conceptTypes)
            {
                if (!IsSimpleManyToManyAssociation(conceptType))
                {
                    EntityType entity = new EntityType(
                        conceptType.Store,
                        new PropertyAssignment[] {
                        new PropertyAssignment(EntityType.NameDomainPropertyId, conceptType.Name)
                    });
                    new EntityTypeIsPrimarilyForConceptType(entity, conceptType);

                    barkerEntities.Add(entity);
                    if (notifyAdded != null)
                    {
                        notifyAdded.ElementAdded(entity, true);
                    }
                }
                else
                {
                    manyToMany.Add(conceptType);
                }
            }

            // For every concept type create all attributes that they represent, map uniquenesses that they participate in.
            int associationCounter = 0;

            foreach (ConceptType conceptType in conceptTypes)
            {
                if (!manyToMany.Contains(conceptType))
                {
                    CreateAttributesAndBinaryRelationships(conceptType, notifyAdded, ref associationCounter);
                }
                else
                {
                    CreateBinaryAssociation(conceptType, notifyAdded, ref associationCounter);
                }
            }

            // For each entity type in the Barker model generate relationships it plays and detemine which of its atrributes are mandatory and nullable.
            foreach (EntityType entity in barkerModel.EntityTypeCollection)
            {
                GenerateMandatoryConstraints(entity);
            }
        }
コード例 #2
0
            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);
                    }
                }
            }
コード例 #3
0
 void IDiagramInitialization.InitializeDiagram(Diagram diagram)
 {
     if (null == diagram.Subject)
     {
         Store store = diagram.Store;
         ReadOnlyCollection <BarkerErModel> barkerModels = store.ElementDirectory.FindElements <BarkerErModel>(false);
         if (barkerModels.Count != 0)
         {
             BarkerErModel model = barkerModels[0];
             diagram.Associate(model);
             foreach (EntityType entity in model.EntityTypeCollection)
             {
                 Diagram.FixUpDiagram(model, entity);
             }
             foreach (BarkerErModelContainsBinaryAssociation link in store.ElementDirectory.FindElements <BarkerErModelContainsBinaryAssociation>(false))
             {
                 if (link.BarkerErModel == model)
                 {
                     FixUpDiagram(model, link);
                 }
             }
         }
     }
 }
コード例 #4
0
            /// <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);
                    }
                }
            }