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 void CheckSemantics(IDslModel existingConcepts) { if (!(Subtype is IOrmDataStructure)) { throw new DslSyntaxException(this, "Is (polymorphic) may only be used on a database-mapped data structure, such as Entity or SqlQueryable. " + this.Subtype.GetUserDescription() + " is not IOrmDataStructure."); } if (ImplementationName == null) { throw new DslSyntaxException(this, "ImplementationName must not be null. It is allowed to be an empty string."); } if (!string.IsNullOrEmpty(ImplementationName)) { DslUtility.ValidateIdentifier(ImplementationName, this, "Invalid ImplementationName value."); } if (existingConcepts.FindByReference <PolymorphicMaterializedInfo>(pm => pm.Polymorphic, Supertype).Any()) { // Verifying if the ChangesOnChangedItemsInfo can be created (see IsSubtypeOfMacro) var dependsOn = DslUtility.GetBaseChangesOnDependency(Subtype, existingConcepts); if (dependsOn.Count() == 0) { throw new DslSyntaxException(this, Subtype.GetUserDescription() + " should be an *extension* of an entity. Otherwise it cannot be used in a materialized polymorphic entity because the system cannot detect when to update the persisted data."); } } }
public IEnumerable <IConceptInfo> CreateNewConcepts(IEnumerable <IConceptInfo> existingConcepts) { var newConcepts = new List <IConceptInfo>(); DslUtility.ValidatePropertyListSyntax(KeyProperties, this); newConcepts.AddRange(KeyProperties.Split(' ').Select <string, IConceptInfo>(propertyName => { if (propertyName == "ID") { return new KeyPropertyIDComputedFromInfo { EntityComputedFrom = new EntityComputedFromInfo { Target = Persisted } } } ; else { return new KeyPropertyComputedFromInfo { PropertyComputedFrom = new PropertyComputedFromInfo { Target = new PropertyInfo { Name = propertyName, DataStructure = Persisted } } } }; })); return(newConcepts); }
public IEnumerable <IConceptInfo> CreateNewConcepts(ChangesOnReferencedInfo conceptInfo, IDslModel existingConcepts) { var reference = DslUtility.GetPropertyByPath(conceptInfo.Computation, conceptInfo.ReferencePath, existingConcepts).Value; if (!(reference is ReferencePropertyInfo)) { throw new DslSyntaxException(conceptInfo, $"The given path '{conceptInfo.ReferencePath}' should end with a reference property, instead of the {reference.GetUserDescription()}."); } var referenced = ((ReferencePropertyInfo)reference).Referenced; var computationDependencies = new List <Tuple <DataStructureInfo, string> >(); if (referenced is IWritableOrmDataStructure) { computationDependencies.Add(Tuple.Create(referenced, "item => item.ID")); } else if (referenced is PolymorphicInfo) { AddPolymorphicImplementations(computationDependencies, (PolymorphicInfo)referenced, existingConcepts, conceptInfo); } string referencePathWithGuid = ChangeReferenceToGuid(conceptInfo.ReferencePath); return(computationDependencies.Select(dep => new ChangesOnChangedItemsInfo { Computation = conceptInfo.Computation, DependsOn = dep.Item1, FilterType = "FilterCriteria", FilterFormula = $@"changedItems => new FilterCriteria({CsUtility.QuotedString(referencePathWithGuid)}, ""In""," + $" _domRepository.Common.FilterId.CreateQueryableFilterIds(changedItems.Select({dep.Item2})))" })); }
public void CheckSemantics(IEnumerable <IConceptInfo> existingConcepts) { if (!DslUtility.IsQueryable(DataStructure)) { throw new DslSyntaxException(this, "This concept can only be used on a queryable data structure, such as Entity. " + DataStructure.GetKeywordOrTypeName() + " is not queryable."); } GetInterfaceType(); }
public void CheckSemantics(IDslModel existingConcepts) { DslUtility.CheckIfPropertyBelongsToDataStructure(Property, IsSubtypeOf.Supertype, this); if (!(Dependency_ImplementationView is ExtensibleSubtypeSqlViewInfo)) { throw new DslSyntaxException(this, "This property implementation cannot be used together with '" + Dependency_ImplementationView.GetUserDescription() + "'. Use either " + this.GetKeywordOrTypeName() + " or " + Dependency_ImplementationView.GetKeywordOrTypeName() + "."); } }
public void CheckSemantics(IDslModel existingConcepts) { if (!IsSupported(DataStructure)) { throw new DslSyntaxException(this, $"SQL index can only be used in a writable data structure." + $" '{DataStructure.FullName}' is a '{DataStructure.GetKeywordOrTypeName()}'."); } DslUtility.ValidatePropertyListSyntax(PropertyNames, this); }
public void CheckSemantics(IDslModel existingConcepts) { DslUtility.ValidatePath(Computation, ReferencePath, existingConcepts, this); var persistedEntities = existingConcepts.FindByReference <EntityComputedFromInfo>(cf => cf.Source, Computation) .Select(cf => cf.Target); foreach (var persisted in persistedEntities) { DslUtility.ValidatePath(persisted, ReferencePath, existingConcepts, this); } }
public SqlViewInfo GetImplementationViewPrototype() { string viewName = Subtype.Name + "_As_" + DslUtility.NameOptionalModule(Supertype, Subtype.Module); if (ImplementationName != "") { viewName += "_" + ImplementationName; } return(new SqlViewInfo { Module = Subtype.Module, Name = viewName, ViewSource = "<prototype>" }); }
public void CheckSemantics(IEnumerable <IConceptInfo> concepts) { if (!IsSupported(DataStructure)) { throw new DslSyntaxException( string.Format("{0} must be used inside writable data structure. DateStructure {1} is of type {2}.", this.GetUserDescription(), DataStructure, DataStructure.GetType().FullName)); } DslUtility.ValidatePropertyListSyntax(PropertyNames, this); }
public IEnumerable <IConceptInfo> CreateNewConcepts(ComputedFromKeyPropertiesInfo conceptInfo, IDslModel existingConcepts) { DslUtility.ValidatePropertyListSyntax(conceptInfo.KeyProperties, conceptInfo); var keyProperties = conceptInfo.CreateKeyProperties(existingConcepts); // If *not all* listed property names are found in the DSL model, wait for more iterations of macro evaluation, // or return an error in the IValidatedConcept implementation above. if (!keyProperties.Values.All(kp => kp != null)) { return(null); } else { return(keyProperties.Values); } }
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 void CheckSemantics(IEnumerable <IConceptInfo> concepts) { if (!DslUtility.IsQueryable(DataStructure)) { throw new DslSyntaxException(this, this.GetKeywordOrTypeName() + " can only be used on a queryable data structure, such as Entity. " + DataStructure.GetKeywordOrTypeName() + " is not queryable."); } if (!DslUtility.IsQueryable(ReferenceProperty.DataStructure)) { throw new DslSyntaxException(this, this.GetKeywordOrTypeName() + " must reference a queryable data structure, such as Entity. " + ReferenceProperty.DataStructure.GetKeywordOrTypeName() + " is not queryable."); } if (ReferenceProperty.Referenced != DataStructure) { throw new DslSyntaxException(this, string.Format( "{0} references '{1}' which is a reference to '{2}'. Expected is a reference back to '{3}'.", this.GetKeywordOrTypeName(), ReferenceProperty.GetUserDescription(), ReferenceProperty.Referenced.GetUserDescription(), DataStructure.GetUserDescription())); } }
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); }
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); }
public IEnumerable <IConceptInfo> CreateNewConcepts(IsSubtypeOfInfo conceptInfo, IDslModel existingConcepts) { var newConcepts = new List <IConceptInfo>(); // Add a subtype reference (for each subtype) to the supertype data structure: var subtypeReference = new PolymorphicSubtypeReferenceInfo { DataStructure = conceptInfo.Supertype, Referenced = conceptInfo.Subtype, Name = conceptInfo.GetSubtypeReferenceName() }; newConcepts.Add(subtypeReference); newConcepts.Add(new PolymorphicPropertyInfo { Property = subtypeReference }); // Minor optimization to reduce the number of macro evaluations. // Append subtype implementation to the supertype union: newConcepts.Add(new SubtypeExtendPolymorphicInfo { IsSubtypeOf = conceptInfo, SubtypeImplementationView = conceptInfo.GetImplementationViewPrototype(), PolymorphicUnionView = conceptInfo.Supertype.GetUnionViewPrototype() }); var filterBySubtypePrototype = new FilterByInfo { Source = conceptInfo.Supertype, Parameter = "Rhetos.Dom.DefaultConcepts.FilterSubtype" }; newConcepts.Add(new SubtypeExtendFilterInfo { IsSubtypeOf = conceptInfo, FilterBySubtype = filterBySubtypePrototype }); // Add metadata for supertype computation (union): foreach (DataStructureInfo dependsOn in DslUtility.GetBaseChangesOnDependency(conceptInfo.Subtype, existingConcepts)) { newConcepts.Add(new ChangesOnChangedItemsInfo { Computation = conceptInfo.Supertype, DependsOn = dependsOn, FilterType = "Rhetos.Dom.DefaultConcepts.FilterSubtype", FilterFormula = @"changedItems => new Rhetos.Dom.DefaultConcepts.FilterSubtype { Ids = changedItems.Select(" + GetComputeHashIdSelector(conceptInfo) + @").ToArray(), Subtype = " + CsUtility.QuotedString(conceptInfo.Subtype.Module.Name + "." + conceptInfo.Subtype.Name) + @", ImplementationName = " + CsUtility.QuotedString(conceptInfo.ImplementationName) + @" }" }); } // Add metadata for subtype implementation: PersistedSubtypeImplementationIdInfo subtypeImplementationColumn = null; if (conceptInfo.SupportsPersistedSubtypeImplementationColum()) { subtypeImplementationColumn = new PersistedSubtypeImplementationIdInfo { Subtype = conceptInfo.Subtype, ImplementationName = conceptInfo.ImplementationName }; newConcepts.Add(subtypeImplementationColumn); } // Automatic interface implementation: var implementationView = (SqlViewInfo)existingConcepts.FindByKey(conceptInfo.GetImplementationViewPrototype().GetKey()); if (implementationView == null) { implementationView = new ExtensibleSubtypeSqlViewInfo { IsSubtypeOf = conceptInfo }; newConcepts.Add(implementationView); if (subtypeImplementationColumn != null) { newConcepts.Add(new SqlDependsOnSqlObjectInfo { // The subtype implementation view will use the PersistedSubtypeImplementationColumn. DependsOn = subtypeImplementationColumn.GetSqlObjectPrototype(), Dependent = implementationView }); } } // Redirect the developer-provided SQL dependencies from the "Is" concept to the implementation view: newConcepts.AddRange(DslUtility.CopySqlDependencies(conceptInfo, implementationView, existingConcepts)); return(newConcepts); }
public void CheckSemantics(IEnumerable <IConceptInfo> concepts) { CheckIfSupported(DataStructure, this); DslUtility.ValidatePropertyListSyntax(PropertyNames, this); }
public void CheckSemantics(IEnumerable <IConceptInfo> concepts) { DslUtility.CheckIfPropertyBelongsToDataStructure(Group, Property.DataStructure, this); }
public void CheckSemantics(IDslModel existingConcepts) { DslUtility.ValidatePath(Browse.Source, Path, existingConcepts, this); DslUtility.ValidateIdentifier(Name, this, "Specify a valid name before the path, to override the generated name."); }
public void CheckSemantics(IEnumerable <IConceptInfo> existingConcepts) { DslUtility.ValidateIdentifier(Name, this); }
public void CheckSemantics(IDslModel existingConcepts) { DslUtility.ValidatePath(DerivedProperty.DataStructure, Path, existingConcepts, this); }
public string GetSubtypeReferenceName() { return(DslUtility.NameOptionalModule(Subtype, Supertype.Module) + ImplementationName); }
public void CheckSemantics(IDslModel existingConcepts) { DslUtility.CheckIfPropertyBelongsToDataStructure(Property, SqlIndex.DataStructure, this); }
public void CheckSemantics(IEnumerable <IConceptInfo> existingConcepts) { DslUtility.CheckIfPropertyBelongsToDataStructure(Property, Lock.Source, this); }
public void CheckSemantics(IDslModel existingConcepts) { DslUtility.CheckIfPropertyBelongsToDataStructure(ReferenceProperty, RowPermissionsFilters.DataStructure, this); }
public IEnumerable <IConceptInfo> CreateNewConcepts(InitializationConcept conceptInfo, IDslModel existingConcepts) { var newConcepts = new List <IConceptInfo>(); var samePropertiesByInheritance = existingConcepts.FindByType <SamePropertyValueInfo>().Select(x => new { DerivedProperty = x.DerivedProperty, BaseSelector = x.Path.Substring(0, x.Path.LastIndexOf('.')), BaseProperty = DslUtility.GetPropertyByPath(x.DerivedProperty.DataStructure, x.Path, existingConcepts).Value, }).GroupBy(same => new { Module = same.DerivedProperty.DataStructure.Module.Name, DataStructure = same.DerivedProperty.DataStructure.Name, same.BaseSelector }) .ToDictionary(g => g.Key, g => g.ToList()); foreach (var inherit in existingConcepts.FindByType <RowPermissionsInheritReadInfo>()) { var key = new { Module = inherit.InheritFromInfo.RowPermissionsFilters.DataStructure.Module.Name, DataStructure = inherit.InheritFromInfo.RowPermissionsFilters.DataStructure.Name, BaseSelector = inherit.InheritFromInfo.SourceSelector }; var optimizeProperties = samePropertiesByInheritance.GetValueOrEmpty(key); newConcepts.AddRange(optimizeProperties .Select(op => new RowPermissionsInheritReadSameMemberInfo { InheritRead = inherit, BaseMemberName = op.BaseProperty.Name, DerivedMemberName = op.DerivedProperty.Name })); newConcepts.AddRange(optimizeProperties .Where(op => op.DerivedProperty is ReferencePropertyInfo && op.BaseProperty is ReferencePropertyInfo) .Select(op => new RowPermissionsInheritReadSameMemberInfo { InheritRead = inherit, BaseMemberName = op.BaseProperty.Name + "ID", DerivedMemberName = op.DerivedProperty.Name + "ID" })); } foreach (var inherit in existingConcepts.FindByType <RowPermissionsInheritWriteInfo>()) { var key = new { Module = inherit.InheritFromInfo.RowPermissionsFilters.DataStructure.Module.Name, DataStructure = inherit.InheritFromInfo.RowPermissionsFilters.DataStructure.Name, BaseSelector = inherit.InheritFromInfo.SourceSelector }; var optimizeProperties = samePropertiesByInheritance.GetValueOrEmpty(key); newConcepts.AddRange(optimizeProperties .Select(op => new RowPermissionsInheritWriteSameMemberInfo { InheritWrite = inherit, BaseMemberName = op.BaseProperty.Name, DerivedMemberName = op.DerivedProperty.Name })); newConcepts.AddRange(optimizeProperties .Where(op => op.DerivedProperty is ReferencePropertyInfo && op.BaseProperty is ReferencePropertyInfo) .Select(op => new RowPermissionsInheritWriteSameMemberInfo { InheritWrite = inherit, BaseMemberName = op.BaseProperty.Name + "ID", DerivedMemberName = op.DerivedProperty.Name + "ID" })); } return(newConcepts); }
public void CheckSemantics(IDslModel existingConcepts) { DslUtility.ValidateIdentifier(BaseSelector, this, "BaseSelector should be set to a property name from '" + DerivedProperty.DataStructure.GetKeyProperties() + "' class."); }
public void CheckSemantics(IDslModel existingConcepts) { DslUtility.CheckIfPropertyBelongsToDataStructure(MarkProperty, InvalidData.Source, this); }
public void CheckSemantics(IDslModel existingConcepts) { DslUtility.ValidateIdentifier(Name, this); }
public IEnumerable <IConceptInfo> CreateNewConcepts(LogReaderAdditionalSourceInfo conceptInfo, IDslModel existingConcepts) { return(DslUtility.CopySqlDependencies(conceptInfo, conceptInfo.SqlQueryable, existingConcepts)); }