Beispiel #1
0
        private void GetGlobalsAndFilters(IContainer containerToImportOneInto, out ISqlParameter[] globals, out IFilter[] otherFilters)
        {
            var aggregatecontainer = containerToImportOneInto as AggregateFilterContainer;
            var filtercontainer    = containerToImportOneInto as FilterContainer;


            if (aggregatecontainer != null)
            {
                var aggregate = aggregatecontainer.GetAggregate();
                var factory   = new AggregateBuilderOptionsFactory();
                var options   = factory.Create(aggregate);

                globals = options.GetAllParameters(aggregate);
                var root = aggregate.RootFilterContainer;
                otherFilters = root == null ? new IFilter[0] : GetAllFiltersRecursively(root, new List <IFilter>()).ToArray();
                return;
            }

            if (filtercontainer != null)
            {
                var selectedDataSet = filtercontainer.GetSelectedDataSetsRecursively();
                var config          = selectedDataSet.ExtractionConfiguration;
                var root            = selectedDataSet.RootFilterContainer;

                globals      = config.GlobalExtractionFilterParameters;
                otherFilters = root == null ? new IFilter[0] : GetAllFiltersRecursively(root, new List <IFilter>()).ToArray();

                return;
            }


            throw new Exception("Container " + containerToImportOneInto + " was an unexpected Type:" + containerToImportOneInto.GetType().Name);
        }
Beispiel #2
0
        public override void Execute()
        {
            base.Execute();

            if (string.IsNullOrWhiteSpace(column) && !askAtRuntime)
            {
                aggregate.PivotOnDimensionID = null;
                aggregate.SaveToDatabase();
            }
            else
            {
                var opts = new AggregateBuilderOptionsFactory().Create(aggregate);
                AggregateDimension match = null;

                if (askAtRuntime)
                {
                    var possible = aggregate.AggregateDimensions.Where(d => !d.IsDate()).ToArray();

                    if (!possible.Any())
                    {
                        throw new Exception($"There are no AggregateDimensions in {aggregate} that can be used as a Pivot");
                    }

                    match = (AggregateDimension)BasicActivator.SelectOne("Choose pivot dimension", possible);

                    if (match == null)
                    {
                        return;
                    }
                }
                else
                {
                    match = aggregate.AggregateDimensions.FirstOrDefault(a => string.Equals(column, a.ToString()));
                    if (match == null)
                    {
                        throw new Exception($"Could not find AggregateDimension {column} in Aggregate {aggregate} so could not set it as a pivot dimension.  Try adding the column to the aggregate first");
                    }
                }

                if (match.IsDate())
                {
                    throw new Exception($"AggregateDimension {match} is a Date so cannot set it as a Pivot for Aggregate {aggregate}");
                }

                var enable = opts.ShouldBeEnabled(AggregateEditorSection.PIVOT, aggregate);

                if (!enable)
                {
                    throw new Exception($"Current state of Aggregate {aggregate} does not support having a Pivot Dimension");
                }

                aggregate.PivotOnDimensionID = match.ID;
                aggregate.SaveToDatabase();
            }

            Publish(aggregate);
        }
Beispiel #3
0
        public AggregateFilterUIOptions(AggregateFilter aggregateFilter) : base(aggregateFilter)
        {
            var aggregateConfiguration = aggregateFilter.GetAggregate();

            if (aggregateConfiguration == null)
            {
                throw new Exception("AggregateFilter '" + aggregateFilter + "' (ID=" + aggregateFilter.ID + ") does not belong to any AggregateConfiguration, is it somehow an orphan?");
            }

            //it part of an AggregateConfiguration so get the same factory that is used by AggregateEditorUI to tell us about the globals and the columns
            var options = new AggregateBuilderOptionsFactory().Create(aggregateConfiguration);

            _globals = options.GetAllParameters(aggregateConfiguration);

            //get all the tables
            _tables = aggregateConfiguration.Catalogue.GetTableInfoList(true);

            //but also add the ExtractionInformations and AggregateDimensions - in the case of PatientIndex table join usages (duplicates are ignored by _autoCompleteProvider)
            _columns = options.GetAvailableWHEREColumns(aggregateConfiguration);
        }
Beispiel #4
0
        public override void Execute()
        {
            base.Execute();

            var opts = new AggregateBuilderOptionsFactory().Create(aggregate);
            ExtractionInformation match = null;

            var possible = opts.GetAvailableSELECTColumns(aggregate).OfType <ExtractionInformation>().ToArray();

            if (askAtRuntime)
            {
                if (!possible.Any())
                {
                    throw new Exception($"There are no ExtractionInformation that can be added as new dimensions to {aggregate}");
                }

                match = (ExtractionInformation)BasicActivator.SelectOne("Choose dimension to add", possible);

                if (match == null)
                {
                    return;
                }
            }
            else
            {
                match = possible.FirstOrDefault(a => string.Equals(column, a.ToString()));
                if (match == null)
                {
                    throw new Exception($"Could not find ExtractionInformation {column} in as an addable column to {aggregate}");
                }
            }

            var dim = new AggregateDimension(BasicActivator.RepositoryLocator.CatalogueRepository, match, aggregate);

            dim.SaveToDatabase();

            Publish(aggregate);
        }
        public override void Execute()
        {
            base.Execute();

            if (string.IsNullOrWhiteSpace(column) && !askAtRuntime)
            {
                aggregate.GetAxisIfAny()?.DeleteInDatabase();
            }
            else
            {
                if (aggregate.GetAxisIfAny() != null)
                {
                    throw new Exception($"Aggregate {aggregate} already has an axis");
                }

                var opts = new AggregateBuilderOptionsFactory().Create(aggregate);
                AggregateDimension match = null;

                if (askAtRuntime)
                {
                    var possible = aggregate.AggregateDimensions.Where(d => d.IsDate()).ToArray();

                    if (!possible.Any())
                    {
                        throw new Exception($"There are no AggregateDimensions in {aggregate} that can be used as an axis (Dimensions must be Date Type)");
                    }

                    match = (AggregateDimension)BasicActivator.SelectOne("Choose axis dimension", possible);

                    if (match == null)
                    {
                        return;
                    }
                }
                else
                {
                    match = aggregate.AggregateDimensions.FirstOrDefault(a => string.Equals(column, a.ToString()));
                    if (match == null)
                    {
                        throw new Exception($"Could not find AggregateDimension {column} in Aggregate {aggregate} so could not set it as an axis dimension.  Try adding the column to the aggregate first");
                    }
                }

                if (!match.IsDate())
                {
                    throw new Exception($"AggregateDimension {match} is not a Date so cannot set it as an axis for Aggregate {aggregate}");
                }

                var enable = opts.ShouldBeEnabled(AggregateEditorSection.AXIS, aggregate);

                if (!enable)
                {
                    throw new Exception($"Current state of Aggregate {aggregate} does not support having an axis Dimension");
                }

                var axis = new AggregateContinuousDateAxis(BasicActivator.RepositoryLocator.CatalogueRepository, match);
                axis.SaveToDatabase();
            }

            Publish(aggregate);
        }