Exemplo n.º 1
0
        public IEnumerable<IConceptInfo> CreateNewConcepts(IEnumerable<IConceptInfo> existingConcepts)
        {
            ComputedInfo computedDataStructure = GetComputedDataStructure();
            PersistedDataStructureInfo persistedDataStructure = GetPersistedDataStructure();
            var persistedLeftIndexProperty = new IntegerPropertyInfo { DataStructure = persistedDataStructure, Name = "LeftIndex" };

            var dependencies = GetDependsOnWriteableDataStructure(DataStructure, existingConcepts, this);
            var computedDataStructureDependencies = dependencies.Select(dependsOn =>
                new ChangesOnChangedItemsInfo
                {
                    Computation = computedDataStructure,
                    DependsOn = dependsOn,
                    FilterType = "FilterAll",
                    FilterFormula = "changedItems => new FilterAll()"
                });

            var filterAncestorsParameter = new ParameterInfo { Module = DataStructure.Module, Name = Name + "HierarchyAncestors" };
            var filterDescendantsParameter = new ParameterInfo { Module = DataStructure.Module, Name = Name + "HierarchyDescendants" };

            return new IConceptInfo[]
            {
                new ReferencePropertyInfo { DataStructure = DataStructure, Name = Name, Referenced = DataStructure },

                // Computing the hierarcy information:
                computedDataStructure,
                new DataStructureExtendsInfo { Extension = computedDataStructure, Base = DataStructure },
                new IntegerPropertyInfo { DataStructure = computedDataStructure, Name = "LeftIndex" },
                new IntegerPropertyInfo { DataStructure = computedDataStructure, Name = "RightIndex" },
                new IntegerPropertyInfo { DataStructure = computedDataStructure, Name = "Level" },

                // Persisting the hierarcy information:
                persistedDataStructure,
                new PersistedAllPropertiesInfo { Persisted = persistedDataStructure }, // This will copy all properties from computedDataStructure.
                new PersistedKeepSynchronizedInfo { Persisted = persistedDataStructure },
                persistedLeftIndexProperty,
                new SqlIndexInfo { Property = persistedLeftIndexProperty },

                // Implement filters for finding ancestors and descendants, using indexed pesisted data:
                filterAncestorsParameter,
                filterDescendantsParameter,
                new GuidPropertyInfo { DataStructure = filterAncestorsParameter, Name = "ID" },
                new GuidPropertyInfo { DataStructure = filterDescendantsParameter, Name = "ID" },
                new ComposableFilterByInfo { Source = DataStructure, Parameter = Name + "HierarchyAncestors", Expression = FilterAncestorsExpression() },
                new ComposableFilterByInfo { Source = DataStructure, Parameter = Name + "HierarchyDescendants", Expression = FilterDescendantsExpression() },

            }.Concat(computedDataStructureDependencies);
        }
Exemplo n.º 2
0
        public IEnumerable <IConceptInfo> CreateNewConcepts(HierarchyInfo conceptInfo, IDslModel existingConcepts)
        {
            ComputedInfo computedDataStructure = conceptInfo.GetComputedDataStructure();
            PersistedDataStructureInfo persistedDataStructure = conceptInfo.GetPersistedDataStructure();
            var persistedLeftIndexProperty = new IntegerPropertyInfo {
                DataStructure = persistedDataStructure, Name = "LeftIndex"
            };

            var dependencies = GetDependsOnWriteableDataStructure(conceptInfo.DataStructure, existingConcepts, conceptInfo);
            var computedDataStructureDependencies = dependencies.Select(dependsOn =>
                                                                        new ChangesOnChangedItemsInfo
            {
                Computation   = computedDataStructure,
                DependsOn     = dependsOn,
                FilterType    = "FilterAll",
                FilterFormula = "changedItems => new FilterAll()"
            });

            var filterAncestorsParameter = new ParameterInfo {
                Module = conceptInfo.DataStructure.Module, Name = conceptInfo.Name + "HierarchyAncestors"
            };
            var filterDescendantsParameter = new ParameterInfo {
                Module = conceptInfo.DataStructure.Module, Name = conceptInfo.Name + "HierarchyDescendants"
            };

            return(new IConceptInfo[]
            {
                // Computing the hierarchy information:
                computedDataStructure,
                new ModuleExternalReferenceInfo {
                    Module = computedDataStructure.Module, TypeOrAssembly = @"Plugins\Rhetos.Dom.DefaultConcepts.dll"
                },
                new DataStructureExtendsInfo {
                    Extension = computedDataStructure, Base = conceptInfo.DataStructure
                },
                new IntegerPropertyInfo {
                    DataStructure = computedDataStructure, Name = "LeftIndex"
                },
                new IntegerPropertyInfo {
                    DataStructure = computedDataStructure, Name = "RightIndex"
                },
                new IntegerPropertyInfo {
                    DataStructure = computedDataStructure, Name = "Level"
                },

                // Persisting the hierarchy information:
                persistedDataStructure,
                new PersistedAllPropertiesInfo {
                    Persisted = persistedDataStructure
                },                                                                     // This will copy all properties from computedDataStructure.
                new PersistedKeepSynchronizedInfo {
                    Persisted = persistedDataStructure
                },
                persistedLeftIndexProperty,
                new SqlIndexInfo {
                    Property = persistedLeftIndexProperty
                },

                // Implement filters for finding ancestors and descendants, using indexed persisted data:
                filterAncestorsParameter,
                filterDescendantsParameter,
                new GuidPropertyInfo {
                    DataStructure = filterAncestorsParameter, Name = "ID"
                },
                new GuidPropertyInfo {
                    DataStructure = filterDescendantsParameter, Name = "ID"
                },
                new ComposableFilterByInfo {
                    Source = conceptInfo.DataStructure, Parameter = conceptInfo.Name + "HierarchyAncestors", Expression = conceptInfo.FilterAncestorsExpression()
                },
                new ComposableFilterByInfo {
                    Source = conceptInfo.DataStructure, Parameter = conceptInfo.Name + "HierarchyDescendants", Expression = conceptInfo.FilterDescendantsExpression()
                },
            }.Concat(computedDataStructureDependencies));
        }