public LoadDslModelCommand( IDslModel dslModel, IDataTypeProvider dataTypeProvider) { this.DslModel = dslModel; this.DataTypeProvider = dataTypeProvider; }
public void CheckSemantics(IDslModel existingConcepts) { if (!Parameter.Contains(".")) { throw new DslSyntaxException(this, "ParameterType must be full type name, including Module name for a data structure, or C# namespace for other parameter types."); } }
public static IEnumerable<IConceptInfo> GenerateDependencies(IConceptInfo dependent, IDslModel existingConcepts, string sqlScript) { SortedSet<string> sqlObjectsInScript; if (!SqlObjectsCache.TryGetValue(sqlScript, out sqlObjectsInScript)) { sqlObjectsInScript = new SortedSet<string>(ExtractPossibleObjects(sqlScript), StringComparer.InvariantCultureIgnoreCase); SqlObjectsCache.Add(sqlScript, sqlObjectsInScript); } var newConcepts = new List<IConceptInfo>(); var conceptsBySqlName = existingConcepts.GetIndex<SqlObjectsIndex>().ConceptsBySqlName; foreach (var sqlObjectInScript in sqlObjectsInScript) foreach (var conceptInfo in conceptsBySqlName.Get(sqlObjectInScript)) if (conceptInfo != dependent) { if (conceptInfo is DataStructureInfo) newConcepts.Add(new SqlDependsOnDataStructureInfo { Dependent = dependent, DependsOn = (DataStructureInfo)conceptInfo }); else if (conceptInfo is SqlViewInfo) newConcepts.Add(new SqlDependsOnSqlViewInfo { Dependent = dependent, DependsOn = (SqlViewInfo)conceptInfo }); else if (conceptInfo is SqlFunctionInfo) newConcepts.Add(new SqlDependsOnSqlFunctionInfo { Dependent = dependent, DependsOn = (SqlFunctionInfo)conceptInfo }); else throw new DslSyntaxException(dependent, "Internal error: Unexpected SQL concept type: " + conceptInfo.GetUserDescription() + "."); } return newConcepts; }
public void UpdateCaption(IDslModel dslModel, IDictionary<string, string> captionsValue) { var captionsKeys = captionsValue.Keys.ToList(); foreach (var captionKey in captionsKeys) { StringBuilder sb = new StringBuilder(); string caption = captionsValue[captionKey]; if (caption.All(c => char.IsUpper(c))) continue; bool lastWasLetter = false; foreach (char c in caption) { if (lastWasLetter && char.IsUpper(c)) { sb.Append(' '); sb.Append(char.ToLower(c)); } else if (c == '_') { if (lastWasLetter) sb.Append(' '); } else sb.Append(c); lastWasLetter = char.IsLetter(c); } captionsValue[captionKey] = sb.ToString(); } }
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.Any()) { 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 Dictionary <string, IConceptInfo> CreateKeyProperties(IDslModel existingConcepts) { var computedPropertiesByTarget = existingConcepts .FindByReference <PropertyComputedFromInfo>(cp => cp.Dependency_EntityComputedFrom, ComputedFrom) .ToDictionary(cp => cp.Target.Name); return(KeyProperties.Split(' ') .ToDictionary(propertyName => propertyName, propertyName => { if (propertyName == "ID") { return new KeyPropertyIDComputedFromInfo { EntityComputedFrom = ComputedFrom } } ; else if (computedPropertiesByTarget.ContainsKey(propertyName)) { return new KeyPropertyComputedFromInfo { PropertyComputedFrom = computedPropertiesByTarget[propertyName] } } ; else { return (IConceptInfo)null; } })); }
public void CheckSemantics(IDslModel existingConcepts) { if (!(Property is ShortStringPropertyInfo) && !(Property is IntegerPropertyInfo)) { throw new DslSyntaxException("AutoCode is only available for ShortString and Integer properties."); } }
public void CheckSemantics(IDslModel existingConcepts) { if (PropertyFrom.GetType() != PropertyTo.GetType()) { throw new DslSyntaxException(this, "Range can only be used on two properties of same type."); } }
public void CheckSemantics(IDslModel existingConcepts) { if (this.Property is IntegerPropertyInfo) { int i; if (!Int32.TryParse(this.Value, out i)) throw new DslSyntaxException(this, "Value is not an integer."); } else if (this.Property is DecimalPropertyInfo) { if (!DecimalChecker.IsMatch(this.Value)) throw new DslSyntaxException(this, "Value is not an valid decimal (use period as decimal separator)."); } else if (this.Property is MoneyPropertyInfo) { if (!DecimalChecker.IsMatch(this.Value)) throw new DslSyntaxException(this, "Value is not an valid decimal (use period as decimal separator)."); } else if (this.Property is DatePropertyInfo) { DateTime i3; if (!DateTime.TryParse(this.Value, out i3)) throw new DslSyntaxException(this, "Value is not an date."); } else if (this.Property is DateTimePropertyInfo) { DateTime i4; if (!DateTime.TryParse(this.Value, out i4)) throw new DslSyntaxException(this, "Value is not an datetime."); } else throw new DslSyntaxException(this, "MinValue can only be used on Integer, Decimal, Money, Date or DateTime."); }
public void CheckSemantics(IDslModel existingConcepts) { string referenced = Property.Referenced.GetKeyProperties(); const string commonPrincipal = "Common.Principal"; if (referenced != commonPrincipal) throw new DslSyntaxException(this, "This property must reference '" + commonPrincipal + "' instead of '" + referenced + "'."); }
public void CheckSemantics(IDslModel existingConcepts) { if (!(Dependency_ImplementationView is ExtensibleSubtypeSqlViewInfo)) { throw new DslSyntaxException(this, "This concept cannot be used together with '" + Dependency_ImplementationView.GetUserDescription() + "'. Use either " + ConceptInfoHelper.GetKeywordOrTypeName(typeof(SubtypeImplementsPropertyInfo)) + " or " + Dependency_ImplementationView.GetKeywordOrTypeName() + "."); } }
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 (ReferenceToMe.Referenced != Source) { throw new DslSyntaxException("'" + this.GetUserDescription() + "' must use a reference property that points to it's own data structure. Try using FilterByReferenced instead."); } }
public CodeGenerator( ILogProvider logProvider, IDslModel dslModel) { _performanceLogger = logProvider.GetLogger("Performance." + GetType().Name); _logger = logProvider.GetLogger("CodeGenerator"); _dslModel = dslModel; }
public void CheckSemantics(IDslModel existingConcepts) { if (!(Property.DataStructure is LegacyEntityWithAutoCreatedViewInfo)) { throw new DslSyntaxException("Invalid use of " + this.GetUserDescription() + "." + " It may only be used on LegacyEntity with auto-created view."); } }
} // This redundant property is to ensure dependencies: 1. the detail entity must have pessimistic locking, and 2. this concept's code generator is executed after that one. public void CheckSemantics(IDslModel existingConcepts) { if (Reference.DataStructure != Detail.Resource) { throw new DslSyntaxException("Invalid PessimisticLockingParent: reference detail '" + Reference.DataStructure.GetShortDescription() + "' does not match resource '" + Detail.Resource.GetShortDescription() + "'."); } }
public void CheckSemantics(IDslModel 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 CaptionsValueProvider( IDslModel dslModel, IPluginsContainer <ICaptionsValuePlugin> plugins, ILogProvider logProvider) { _dslModel = dslModel; _plugins = plugins; _performanceLogger = logProvider.GetLogger("Performance"); }
public IList <Claim> GetAllClaims(IDslModel dslModel) { var claims = new List <Claim>(); claims.AddRange(dslModel.Concepts.OfType <CustomClaimInfo>() .Select(item => new Claim(item.ClaimResource, item.ClaimRight))); return(claims); }
public IList<Claim> GetAllClaims(IDslModel dslModel) { var claims = new List<Claim>(); claims.AddRange(dslModel.Concepts.OfType<CustomClaimInfo>() .Select(item => new Claim(item.ClaimResource, item.ClaimRight))); return claims; }
public void CheckSemantics(IDslModel existingConcepts) { DataStructureInfo baseDataStructure = GetBaseDataStructure(existingConcepts); if (baseDataStructure == null) { throw new DslSyntaxException("Invalid use of " + this.GetUserDescription() + ". Filter's data structure '" + Source.GetKeyProperties() + "' is not an extension of another base class."); } }
public void CheckSemantics(IDslModel existingConcepts) { if (!(Property.DataStructure is EntityInfo)) { throw new DslSyntaxException(string.Format( "SqlDefault can only be used on entity properties. Property {0} is not entity property.", Property)); } }
public void CheckSemantics(IDslModel existingConcepts) { if (!(PropertyInfo.DataStructure is BrowseDataStructureInfo)) { throw new DslSyntaxException($"'{this.GetKeywordOrTypeName()}' cannot be used" + $" on {PropertyInfo.DataStructure.GetKeywordOrTypeName()} ({PropertyInfo.GetUserDescription()})." + $" It may only be used on {ConceptInfoHelper.GetKeywordOrTypeName(typeof(BrowseDataStructureInfo))}."); } }
public void CheckSemantics(IDslModel existingConcepts) { var myExtends = MyExtendsConceptInfo(existingConcepts); if (myExtends == null) { throw new DslSyntaxException("ComputeForNewBaseItems can only be used if the persisted data structure extends a base entity. Use 'Extends' keyword to define the extension is applicable."); } }
public static void ValidatePath(DataStructureInfo source, string path, IDslModel existingConcepts, IConceptInfo errorContext) { var property = GetPropertyByPath(source, path, existingConcepts); if (property.IsError) { throw new DslSyntaxException(errorContext, "Invalid path: " + property.Error); } }
public void CheckSemantics(IDslModel existingConcepts) { var keyProperties = CreateKeyProperties(existingConcepts); var invalidPropertyName = keyProperties.Where(kp => kp.Value == null).Select(kp => kp.Key).FirstOrDefault(); if (invalidPropertyName != null) { throw new DslSyntaxException(this, $"Cannot find property '{invalidPropertyName}' on '{ComputedFrom.Target.GetKeyProperties()}'."); } }
public void CheckSemantics(IDslModel existingConcepts) { string referenced = Property.Referenced.GetKeyProperties(); const string commonPrincipal = "Common.Principal"; if (referenced != commonPrincipal) { throw new DslSyntaxException(this, "This property must reference '" + commonPrincipal + "' instead of '" + referenced + "'."); } }
public IList<Claim> GetAllClaims(IDslModel dslModel) { List<Claim> allClaims = (from c in dslModel.Concepts let dataStructure = c as DataStructureInfo where dataStructure != null select new Claim(dataStructure.Module.Name + "." + dataStructure.Name, "Read")).ToList(); return allClaims; }
private static string CreateDefaultes(IDslModel dslModel, PropertyInfo info) { bool isAutocode = dslModel.Concepts.OfType<AutoCodePropertyInfo>().Any( p => p.Property.Name == info.Name && p.Property.DataStructure.Module.Name == info.DataStructure.Module.Name && p.Property.DataStructure.Name == info.DataStructure.Name); if (isAutocode) return DefaultAutocode; if (info.Name.ToLower() == "active" && info is BoolPropertyInfo) return DefaultActive; return ""; }
public void CheckSemantics(IDslModel existingConcepts) { var extendsConcept = existingConcepts.FindByReference <UniqueReferenceInfo>(extends => extends.Extension, Computation).FirstOrDefault(); if (extendsConcept == null) { throw new DslSyntaxException("ChangesOnBaseItem is used on '" + Computation.GetUserDescription() + "' which does not extend another base data structure. Consider adding 'Extends' concept."); } }
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 CaptionsValueProvider( IDslModel dslModel, IPluginsContainer<ICaptionsValuePlugin> plugins, ILogProvider logProvider) { _dslModel = dslModel; _plugins = plugins; _logger = logProvider.GetLogger("CaptionsValueGenerator"); _performanceLogger = logProvider.GetLogger("Performance"); }
public void CheckSemantics(IDslModel existingConcepts) { var baseDataStructure = GetBaseDataStructure(existingConcepts); if (baseDataStructure == null) { throw new DslSyntaxException(this, "'" + this.GetKeywordOrTypeName() + "' can only be used on an extension. '" + RowPermissionsFilters.DataStructure.GetUserDescription() + "' does not extend another data structure."); } }
public void CheckSemantics(IDslModel existingConcepts) { if (Dependency_Extends.Extension != EntityComputedFrom.Target) { throw new DslSyntaxException("Invalid use of " + this.GetUserDescription() + ": Extension '" + Dependency_Extends.Extension.GetUserDescription() + "' is not same as " + this.GetKeywordOrTypeName() + " target '" + EntityComputedFrom.Target.GetUserDescription() + "'."); } }
public void CheckSemantics(IDslModel existingConcepts) { var rowPermissionsRead = GetRowPermissionsRead(existingConcepts); var rowPermissionsWrite = GetRowPermissionsWrite(existingConcepts); if (rowPermissionsRead == null && rowPermissionsWrite == null) { throw new DslSyntaxException(this, "Referenced '" + Source.GetUserDescription() + "' does not have row permissions."); } }
public IEnumerable <IClaim> GetAllClaims(IDslModel dslModel, Func <string, string, IClaim> newClaim) { List <IClaim> allClaims = (from c in dslModel.Concepts let dataStructure = c as DataStructureInfo where dataStructure != null select newClaim(dataStructure.Module.Name + "." + dataStructure.Name, "Read")).ToList(); return(allClaims); }
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 void CheckSemantics(IDslModel existingConcepts) { if (UpdateOnChange.Computation != KeepSynchronized.EntityComputedFrom.Source) { throw new DslSyntaxException(string.Format( "Invalid use of {0}: UpdateOnChange.Computation ({1}) should be same as EntityComputedFrom.Source ({2}).", this.GetUserDescription(), UpdateOnChange.Computation.GetUserDescription(), KeepSynchronized.EntityComputedFrom.Source.GetUserDescription())); } }
public static string CreateAdditionalAttributes(IDslModel dslModel, PropertyInfo info, string dodatniAtributi) { HashSet<string> additionalMvcAttributes = new HashSet<string>(); additionalMvcAttributes.Add(HideLookupFields(dslModel, info)); additionalMvcAttributes.Add(HideDetailFields(dslModel, info)); additionalMvcAttributes.Add(CreateDefaultes(dslModel, info)); additionalMvcAttributes.Add(HideIdFields(dslModel, info)); additionalMvcAttributes.Remove(""); return dodatniAtributi + string.Join("", additionalMvcAttributes); }
private static string HideDetailFields(IDslModel dslModel, PropertyInfo info) { string entityName = CaptionHelper.RemoveBrowseSufix(info.DataStructure.Name); bool isDetail = dslModel.Concepts.OfType<ReferenceDetailInfo>().Any( d => d.Reference.Name == info.Name && d.Reference.DataStructure.Name == entityName && d.Reference.DataStructure.Module.Name == info.DataStructure.Module.Name); if (isDetail) return EditModeHidden; return ""; }
public ClaimGenerator( IPluginsContainer<IClaimProvider> claimProviders, IDslModel dslModel, IDomainObjectModel domainObjectModel, ILogProvider logProvider, IClaimRepository claimRepository) { _claimProviders = claimProviders; _dslModel = dslModel; _performanceLogger = logProvider.GetLogger("Performance"); _logger = logProvider.GetLogger("ClaimGenerator"); _claimRepository = claimRepository; }
public IList<Claim> GetAllClaims(IDslModel dslModel) { var claims = dslModel .FindByType<DataStructureInfo>() .Where(dataStructure => dataStructure is IOrmDataStructure || dataStructure is BrowseDataStructureInfo || dataStructure is QueryableExtensionInfo || dataStructure is ComputedInfo) .Select(dataStructure => new Claim(dataStructure.Module.Name + "." + dataStructure.Name, "Read")) .ToList(); return claims; }
public DatabaseGenerator( ISqlExecuter sqlExecuter, IDslModel dslModel, IPluginsContainer<IConceptDatabaseDefinition> plugins, ConceptApplicationRepository conceptApplicationRepository, ILogProvider logProvider) { _sqlExecuter = sqlExecuter; _dslModel = dslModel; _plugins = plugins; _conceptApplicationRepository = conceptApplicationRepository; _logger = logProvider.GetLogger("DatabaseGenerator"); _performanceLogger = logProvider.GetLogger("Performance"); }
public IList<Claim> GetAllClaims(IDslModel dslModel) { var writableDataStructures = dslModel.Concepts.OfType<DataStructureInfo>() .Where(dataStructure => dataStructure is IWritableOrmDataStructure) .Union( dslModel.Concepts.OfType<WriteInfo>() .Select(x => x.DataStructure)).ToArray(); return writableDataStructures.SelectMany(dataStructure => new Claim[] { new Claim(dataStructure.GetKeyProperties(), "New"), new Claim(dataStructure.GetKeyProperties(), "Edit"), new Claim(dataStructure.GetKeyProperties(), "Remove") }).ToList(); }
public static IEnumerable<IConceptInfo> CreateNewConcepts(this IConceptMacro conceptMacro, IConceptInfo conceptInfo, IDslModel existingConcepts) { IEnumerable<IConceptInfo> newConcepts = null; foreach (var method in GetPluginMethods(conceptMacro, conceptInfo)) { var pluginCreatedConcepts = (IEnumerable<IConceptInfo>)method.InvokeEx(conceptMacro, new object[] { conceptInfo, existingConcepts }); if (newConcepts == null) newConcepts = pluginCreatedConcepts; else if (pluginCreatedConcepts != null) newConcepts = newConcepts.Concat(pluginCreatedConcepts); } return newConcepts; }
public void CheckSemantics(IDslModel concepts) { if (ReferenceFromMe.DataStructure != Source) throw new DslSyntaxException("'" + this.GetUserDescription() + "' must use a reference property that is a member of it's own data structure. Try using FilterByLinkedItems instead."); var availableFilters = concepts.FindByReference<ComposableFilterByInfo>(f => f.Source, ReferenceFromMe.Referenced) .Select(f => f.Parameter).OrderBy(f => f).ToList(); if (!availableFilters.Contains(Parameter)) throw new DslSyntaxException(this, string.Format( "There is no {0} '{1}' on {2}. Available {0} filters are: {3}.", ConceptInfoHelper.GetKeywordOrTypeName(typeof(ComposableFilterByInfo)), Parameter, ReferenceFromMe.Referenced.GetUserDescription(), string.Join(", ", availableFilters.Select(parameter => "'" + parameter + "'")))); }
public void CheckSemantics(IDslModel concepts) { if (Module.Name != Source.Module.Name) throw new DslSyntaxException( string.Format("Browse should be created in same module as referenced entity. Expecting {0} instead of {1}.", Source.Module, Module)); var properties = concepts.FindByReference<PropertyInfo>(p => p.DataStructure, this); var propertyWithoutSelector = properties .Where(p => concepts.FindByReference<BrowseFromPropertyInfo>(bfp => bfp.PropertyInfo, p).Count() == 0) .FirstOrDefault(); if (propertyWithoutSelector != null) throw new DslSyntaxException( string.Format("Browse property {0} does not have a source selected. Probably missing '{1}'.", propertyWithoutSelector.GetUserDescription(), ConceptInfoHelper.GetKeywordOrTypeName(typeof(BrowseFromPropertyInfo)))); }
/// <summary> /// Returns a writable data structure that can be used to monitor data changes (intercepting its Save function), in order to update a persisted data. /// Returns empty array if a required data structure is not found. /// </summary> public static IEnumerable<DataStructureInfo> GetBaseChangesOnDependency(DataStructureInfo dependsOn, IDslModel existingConcepts) { if (dependsOn.Name.EndsWith("_History")) { var history = existingConcepts.FindByReference<EntityHistoryInfo>(h => h.Dependency_HistorySqlQueryable, dependsOn).SingleOrDefault(); if (history != null) return new DataStructureInfo[] { history.Entity, history.Dependency_ChangesEntity }; } if (dependsOn is IWritableOrmDataStructure) return new[] { dependsOn }; if (existingConcepts.FindByReference<WriteInfo>(write => write.DataStructure, dependsOn).Any()) return new[] { dependsOn }; var baseDataStructure = existingConcepts.FindByReference<DataStructureExtendsInfo>(ex => ex.Extension, dependsOn) .Select(ex => ex.Base).SingleOrDefault(); if (baseDataStructure != null) return GetBaseChangesOnDependency(baseDataStructure, existingConcepts); return Enumerable.Empty<DataStructureInfo>(); }
public ApplicationGenerator( ILogProvider logProvider, ISqlExecuter sqlExecuter, IDslModel dslModel, IDomGenerator domGenerator, IPluginsContainer<IGenerator> generatorsContainer, DatabaseCleaner databaseCleaner, DataMigration dataMigration, IDatabaseGenerator databaseGenerator, IDslScriptsProvider dslScriptsLoader) { _deployPackagesLogger = logProvider.GetLogger("DeployPackages"); _performanceLogger = logProvider.GetLogger("Performance"); _sqlExecuter = sqlExecuter; _dslModel = dslModel; _domGenerator = domGenerator; _generatorsContainer = generatorsContainer; _databaseCleaner = databaseCleaner; _dataMigration = dataMigration; _databaseGenerator = databaseGenerator; _dslScriptsLoader = dslScriptsLoader; }
public static IEnumerable<IConceptInfo> GenerateDependenciesToObject(IConceptInfo dependent, IDslModel existingConcepts, string sqlObjectName) { var newConcepts = new List<IConceptInfo>(); sqlObjectName = sqlObjectName.Trim(); bool function = sqlObjectName.Contains('('); if (function) sqlObjectName = sqlObjectName.Substring(0, sqlObjectName.IndexOf('(')); var nameParts = sqlObjectName.Split('.'); if (nameParts.Length != 2) return newConcepts; if (function) { newConcepts.AddRange(existingConcepts.FindByType<SqlFunctionInfo>() .Where(ci => ci.Module.Name.Equals(nameParts[0], StringComparison.InvariantCultureIgnoreCase) && ci.Name.Equals(nameParts[1], StringComparison.InvariantCultureIgnoreCase) && ci != dependent) .Select(ci => new SqlDependsOnSqlFunctionInfo { Dependent = dependent, DependsOn = ci })); } else { newConcepts.AddRange(existingConcepts.FindByType<DataStructureInfo>() .Where(ci => ci.Module.Name.Equals(nameParts[0], StringComparison.InvariantCultureIgnoreCase) && ci.Name.Equals(nameParts[1], StringComparison.InvariantCultureIgnoreCase) && ci != dependent) .Select(ci => new SqlDependsOnDataStructureInfo { Dependent = dependent, DependsOn = ci })); newConcepts.AddRange(existingConcepts.FindByType<SqlViewInfo>() .Where(ci => ci.Module.Name.Equals(nameParts[0], StringComparison.InvariantCultureIgnoreCase) && ci.Name.Equals(nameParts[1], StringComparison.InvariantCultureIgnoreCase) && ci != dependent) .Select(ci => new SqlDependsOnSqlViewInfo { Dependent = dependent, DependsOn = ci })); } return newConcepts; }
private static ValueOrError<DataStructureInfo> NavigateToNextDataStructure(DataStructureInfo source, string referenceName, IDslModel existingConcepts) { var selectedProperty = FindProperty(existingConcepts, source, referenceName); IEnumerable<DataStructureExtendsInfo> allExtensions; allExtensions = existingConcepts.FindByType<DataStructureExtendsInfo>(); if (selectedProperty == null && referenceName == "Base") { var baseDataStructure = allExtensions .Where(ex => ex.Extension == source) .Select(ex => ex.Base).SingleOrDefault(); if (baseDataStructure != null) return baseDataStructure; if (selectedProperty == null) return ValueOrError.CreateError("There is no property '" + referenceName + "' nor a base data structure on " + source.GetUserDescription() + "."); } if (selectedProperty == null && referenceName.StartsWith("Extension_")) { string extensionName = referenceName.Substring("Extension_".Length); var extendsionDataStructure = allExtensions .Where(ex => ex.Base == source) .Where(ex => ex.Extension.Module == source.Module && ex.Extension.Name == extensionName || ex.Extension.Module.Name + "_" + ex.Extension.Name == extensionName) .Select(ex => ex.Extension).SingleOrDefault(); if (extendsionDataStructure != null) return extendsionDataStructure; if (selectedProperty == null) return ValueOrError.CreateError("There is no property '" + referenceName + "' nor an extension '" + extensionName + "' on " + source.GetUserDescription() + "."); } if (selectedProperty == null) return ValueOrError.CreateError("There is no property '" + referenceName + "' on " + source.GetUserDescription() + "."); if (!(selectedProperty is ReferencePropertyInfo)) return ValueOrError.CreateError(string.Format("Property {0} cannot be used in the path because it is '{1}'. Only Reference properties can be used in a path.", selectedProperty.Name, selectedProperty.GetKeywordOrTypeName())); return ((ReferencePropertyInfo)selectedProperty).Referenced; }
public IList<Claim> GetAllClaims(IDslModel dslModel) { return new Claim[] { }; }
public void CheckSemantics(IDslModel existingConcepts) { DslUtility.CheckIfPropertyBelongsToDataStructure(MarkProperty, InvalidData.Source, this); }
public static ValueOrError<PropertyInfo> GetPropertyByPath(DataStructureInfo source, string path, IDslModel existingConcepts) { if (path.Contains(" ")) return ValueOrError.CreateError("The path contains a space character."); if (string.IsNullOrEmpty(path)) return ValueOrError.CreateError("The path is empty."); var propertyNames = path.Split('.'); var referenceNames = propertyNames.Take(propertyNames.Count() - 1).ToArray(); var lastPropertyName = propertyNames[propertyNames.Count() - 1]; ValueOrError<DataStructureInfo> selectedDataStructure = source; foreach (var referenceName in referenceNames) { selectedDataStructure = NavigateToNextDataStructure(selectedDataStructure.Value, referenceName, existingConcepts); if (selectedDataStructure.IsError) return ValueOrError.CreateError(selectedDataStructure.Error); } PropertyInfo selectedProperty = FindProperty(existingConcepts, selectedDataStructure.Value, lastPropertyName); if (selectedProperty == null && lastPropertyName == "ID") return new GuidPropertyInfo { DataStructure = selectedDataStructure.Value, Name = "ID" }; if (selectedProperty == null) return ValueOrError.CreateError("There is no property '" + lastPropertyName + "' on " + selectedDataStructure.Value.GetUserDescription() + "."); return selectedProperty; }
public IList<Claim> GetAllClaims(IDslModel dslModel) { return dslModel.Concepts.OfType<ActionInfo>() .Select(actionInfo => new Claim(actionInfo.Module.Name + "." + actionInfo.Name, "Execute")).ToList(); }
public static void ValidatePath(DataStructureInfo source, string path, IDslModel existingConcepts, IConceptInfo errorContext) { var property = GetPropertyByPath(source, path, existingConcepts); if (property.IsError) throw new DslSyntaxException(errorContext, "Invalid path: " + property.Error); }
public static PropertyInfo FindProperty(IDslModel dslModel, DataStructureInfo dataStructure, string propertyName) { var propertyKey = string.Format("PropertyInfo {0}.{1}.{2}", dataStructure.Module.Name, dataStructure.Name, propertyName); return (PropertyInfo)dslModel.FindByKey(propertyKey); }
public DatabaseGenerator_Accessor(IDslModel dslModel, PluginsContainer<IConceptDatabaseDefinition> plugins) : base(null, dslModel, plugins, null, new ConsoleLogProvider(), new DatabaseGeneratorOptions { ShortTransactions = false }) { }
public LongStringPropertyCodeGenerator(IDslModel dslModel) { _dslModel = dslModel; }