示例#1
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);
                    }
                }
            }
        private static void UpdateTablesOnDataTypeChange(ValueTypeHasDataType link)
        {
            InformationTypeFormat format;
            LinkedElementCollection <ConceptType> conceptTypes;

            if (null != (format = InformationTypeFormatIsForValueType.GetInformationTypeFormat(link.ValueType)) &&
                0 != (conceptTypes = InformationType.GetConceptTypeCollection(format)).Count)
            {
                foreach (ConceptType conceptType in conceptTypes)
                {
                    UpdateTablesForConceptType(conceptType, null, null);
                }
            }
        }
示例#4
0
		/// <summary>
		/// Generates the <see cref="InformationTypeFormat"/> objects and adds them to the model.
		/// </summary>
		private void GenerateInformationTypeFormats()
		{
			ORMModel model = this.ORMModel;
			IEnumerable<ObjectType> modelValueTypes = model.ValueTypeCollection;
			AbstractionModel oialModel = this.AbstractionModel;

			// For each ValueType in the model...
			foreach (ObjectType valueType in modelValueTypes)
			{
				if (ShouldIgnoreObjectType(valueType))
				{
					continue;
				}
				// Create InformationTypeFormat.
				PropertyAssignment namePropertyAssignment = new PropertyAssignment(InformationTypeFormat.NameDomainPropertyId, valueType.Name);
				InformationTypeFormat informationTypeFormat = new InformationTypeFormat(Store, namePropertyAssignment);
				InformationTypeFormatIsForValueType informationTypeFormatIsForValueType = new InformationTypeFormatIsForValueType(informationTypeFormat, valueType);
				// TODO: information type format data types

				// Add it to the model.
				oialModel.InformationTypeFormatCollection.Add(informationTypeFormat);
			}
		}