Example #1
0
        protected void ComputeCreateAndRemoveQuery(List<NewConceptApplication> newConceptApplications, IEnumerable<IConceptInfo> allConceptInfos)
        {
            Graph.TopologicalSort(newConceptApplications, GetDependencyPairs(newConceptApplications));

            var conceptInfosByKey = allConceptInfos.ToDictionary(ci => ci.GetKey());

            var sqlCodeBuilder = new CodeBuilder("/*", "*/");
            var createdDependencies = new List<Tuple<IConceptInfo, IConceptInfo, string>>();
            foreach (var ca in newConceptApplications)
            {
                AddConceptApplicationSeparator(ca, sqlCodeBuilder);

                // Generate RemoveQuery:

                GenerateRemoveQuery(ca);

                // Generate CreateQuery:

                sqlCodeBuilder.InsertCode(ca.ConceptImplementation.CreateDatabaseStructure(ca.ConceptInfo));

                if (ca.ConceptImplementation is IConceptDatabaseDefinitionExtension)
                {
                    IEnumerable<Tuple<IConceptInfo, IConceptInfo>> pluginCreatedDependencies;
                    ((IConceptDatabaseDefinitionExtension)ca.ConceptImplementation).ExtendDatabaseStructure(ca.ConceptInfo, sqlCodeBuilder, out pluginCreatedDependencies);

                    if (pluginCreatedDependencies != null)
                    {
                        var resolvedDependencies = pluginCreatedDependencies.Select(dep => Tuple.Create(
                            GetValidConceptInfo(dep.Item1.GetKey(), conceptInfosByKey, ca),
                            GetValidConceptInfo(dep.Item2.GetKey(), conceptInfosByKey, ca),
                            "ExtendDatabaseStructure " + ca.ToString())).ToList();

                        createdDependencies.AddRange(resolvedDependencies);
                    }
                }
            }

            ExtractCreateQueries(sqlCodeBuilder.GeneratedCode, newConceptApplications);

            var createdConceptApplicationDependencies = GetConceptApplicationDependencies(createdDependencies, newConceptApplications);
            UpdateConceptApplicationsFromDependencyList(createdConceptApplicationDependencies);
        }
 public static new void AddConceptApplicationSeparator(ConceptApplication ca, CodeBuilder sqlCodeBuilder)
 {
     DatabaseGenerator.AddConceptApplicationSeparator(ca, sqlCodeBuilder);
 }
Example #3
0
 protected static void AddConceptApplicationSeparator(ConceptApplication ca, CodeBuilder sqlCodeBuilder)
 {
     sqlCodeBuilder.InsertCode(string.Format("{0}{1}{2}{3}",
         NextConceptApplicationSeparator, NextConceptApplicationIdPrefix, ca.Id, NextConceptApplicationIdSuffix));
 }