Example #1
0
        public IEnumerable <IConceptInfo> CreateNewConcepts(ExtensibleSubtypeSqlViewInfo conceptInfo, IDslModel existingConcepts)
        {
            var newConcepts = new List <IConceptInfo>();

            // Automatic interface implementation: Add missing property implementations and missing properties to the subtype.

            var implementableSupertypeProperties = existingConcepts.FindByType <PolymorphicPropertyInfo>()
                                                   .Where(pp => pp.Property.DataStructure == conceptInfo.IsSubtypeOf.Supertype && pp.IsImplementable(_conceptMetadata))
                                                   .Select(pp => pp.Property).ToList();
            var subtypeProperties           = existingConcepts.FindByReference <PropertyInfo>(p => p.DataStructure, conceptInfo.IsSubtypeOf.Subtype);
            var subtypeImplementsProperties = existingConcepts.FindByReference <SubtypeImplementsPropertyInfo>(subim => subim.IsSubtypeOf, conceptInfo.IsSubtypeOf)
                                              .Select(subim => subim.Property).ToList();

            var missingImplementations = implementableSupertypeProperties.Except(subtypeImplementsProperties)
                                         .Select(missing => new SubtypeImplementsPropertyInfo
            {
                IsSubtypeOf = conceptInfo.IsSubtypeOf,
                Property    = missing,
                Expression  = GetColumnName(missing)
            })
                                         .ToList();

            var missingProperties = missingImplementations.Select(subim => subim.Property).Where(supp => !subtypeProperties.Any(subp => subp.Name == supp.Name))
                                    .Select(missing => DslUtility.CreatePassiveClone(missing, conceptInfo.IsSubtypeOf.Subtype))
                                    .ToList();

            newConcepts.AddRange(missingImplementations);
            newConcepts.AddRange(missingProperties);

            return(newConcepts);
        }
        public IEnumerable <IConceptInfo> CreateNewConcepts(BrowseTakeNamedPropertyInfo conceptInfo, IDslModel existingConcepts)
        {
            ValueOrError <PropertyInfo> sourceProperty = DslUtility.GetPropertyByPath(conceptInfo.Browse.Source, conceptInfo.Path, existingConcepts);

            if (sourceProperty.IsError)
            {
                return(null); // Creating the browse property may be delayed for other macro concepts to generate the needed properties. If this condition is not resolved, the CheckSemantics function below will throw an exception.
            }
            var browseProperty = DslUtility.CreatePassiveClone(sourceProperty.Value, conceptInfo.Browse);

            browseProperty.Name = conceptInfo.Name;

            var browsePropertySelector = new BrowseFromPropertyInfo {
                PropertyInfo = browseProperty, Path = conceptInfo.Path
            };

            return(new IConceptInfo[] { browseProperty, browsePropertySelector });
        }
        public IEnumerable <IConceptInfo> CreateNewConcepts(ExtensibleSubtypeSqlViewInfo conceptInfo, IDslModel existingConcepts)
        {
            var newConcepts = new List <IConceptInfo>();

            // Automatic interface implementation: Add missing property implementations and missing properties to the subtype.

            var implementableSupertypeProperties = existingConcepts.FindByType <PolymorphicPropertyInfo>()
                                                   .Where(pp => pp.Property.DataStructure == conceptInfo.IsSubtypeOf.Supertype && pp.IsImplementable())
                                                   .Select(pp => pp.Property).ToList();
            var subtypeProperties           = existingConcepts.FindByReference <PropertyInfo>(p => p.DataStructure, conceptInfo.IsSubtypeOf.Subtype);
            var subtypeImplementsProperties = existingConcepts.FindByReference <SubtypeImplementsPropertyInfo>(subim => subim.IsSubtypeOf, conceptInfo.IsSubtypeOf)
                                              .Select(subim => subim.Property).ToList();

            var missingImplementations = implementableSupertypeProperties.Except(subtypeImplementsProperties)
                                         .Select(missing => new SubtypeImplementsPropertyInfo
            {
                IsSubtypeOf = conceptInfo.IsSubtypeOf,
                Property    = missing,
                Expression  = GetColumnName(missing)
            })
                                         .ToList();

            var missingProperties      = missingImplementations.Select(subim => subim.Property).Where(supp => !subtypeProperties.Any(subp => subp.Name == supp.Name));
            var missingPropertiesToAdd = missingProperties.Select(missing => DslUtility.CreatePassiveClone(missing, conceptInfo.IsSubtypeOf.Subtype)).ToList();

            if (_configuration.GetBool("CommonConcepts.Legacy.AutoGeneratePolymorphicProperty", true).Value == false &&
                missingProperties.Count() > 0)
            {
                throw new DslSyntaxException("The property " + missingProperties.First().GetUserDescription() +
                                             " is not implemented in the polymorphic subtype " + conceptInfo.IsSubtypeOf.Subtype.GetUserDescription() + ". " +
                                             "Please add the property implementation to the subtype.");
            }

            newConcepts.AddRange(missingImplementations);
            newConcepts.AddRange(missingPropertiesToAdd);

            return(newConcepts);
        }
Example #4
0
        public IEnumerable <IConceptInfo> CreateNewConcepts(PropertyFromInfo conceptInfo, IDslModel existingConcepts)
        {
            var newConcepts = new List <IConceptInfo>();

            var property = DslUtility.CreatePassiveClone(conceptInfo.Source, conceptInfo.Destination);

            newConcepts.Add(property);

            var required = existingConcepts.FindByReference <RequiredPropertyInfo>(ci => ci.Property, conceptInfo.Source)
                           .Select(ci => new RequiredPropertyInfo {
                Property = property
            })
                           .SingleOrDefault();

            if (required != null)
            {
                newConcepts.Add(required);
            }

            if (SqlIndexMultipleInfo.IsSupported(conceptInfo.Destination))
            {
                foreach (var sourceIndex in existingConcepts.FindByReference <SqlIndexMultipleInfo>(ci => ci.DataStructure, conceptInfo.Source.DataStructure))
                {
                    var indexProperties = sourceIndex.PropertyNames.Split(' ');
                    if (property.Name == indexProperties.FirstOrDefault() &&
                        indexProperties.Skip(1).All(indexProperty =>
                                                    DslUtility.FindProperty(existingConcepts, conceptInfo.Destination, indexProperty) != null))
                    {
                        newConcepts.Add(new SqlIndexMultipleInfo {
                            DataStructure = conceptInfo.Destination, PropertyNames = sourceIndex.PropertyNames
                        });
                    }
                }
            }

            return(newConcepts);
        }