예제 #1
0
        private void ddIncrement_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (updating || _axis == null)
            {
                return;
            }

            _axis.AxisIncrement = (AxisIncrement)ddIncrement.SelectedValue;
            _axis.SaveToDatabase();
        }
예제 #2
0
        private void ddAxisDimension_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (isRefreshing)
            {
                return;
            }

            var selectedDimension = ddAxisDimension.SelectedItem as AggregateDimension;

            if (selectedDimension == null)
            {
                return;
            }

            //is there already an axis? if so keep the old start/end dates
            var existing = _aggregate.GetAxisIfAny();

            //create a new one
            var axis = new AggregateContinuousDateAxis(Activator.RepositoryLocator.CatalogueRepository, selectedDimension);

            axis.AxisIncrement = AxisIncrement.Month;

            //copy over old values of start/end/increment
            if (existing != null && existing.AggregateDimension_ID != selectedDimension.ID)
            {
                axis.StartDate     = existing.StartDate;
                axis.EndDate       = existing.EndDate;
                axis.AxisIncrement = existing.AxisIncrement;
                existing.DeleteInDatabase();
            }

            axis.SaveToDatabase();
            PublishToSelfOnly();
        }
예제 #3
0
        /// <summary>
        /// Creates a new AggregateGraph for the given dataset (<paramref name="cata"/>)
        /// </summary>
        /// <param name="cata"></param>
        /// <param name="name">The name to give the graph</param>
        /// <param name="dimension1">The first dimension e.g. pass only one dimension to create a bar chart</param>
        /// <param name="isAxis">True if <paramref name="dimension1"/> should be created as a axis (creates a line chart)</param>
        /// <param name="dimension2">Optional second dimension to create (this will be the pivot column)</param>
        private AggregateConfiguration CreateGraph(Catalogue cata, string name, string dimension1, bool isAxis, string dimension2)
        {
            var ac = new AggregateConfiguration(_repos.CatalogueRepository, cata, name);

            ac.CountSQL = "count(*) as NumberOfRecords";
            ac.SaveToDatabase();
            ac.IsExtractable = true;

            var mainDimension  = ac.AddDimension(GetExtractionInformation(cata, dimension1));
            var otherDimension = string.IsNullOrWhiteSpace(dimension2) ? null : ac.AddDimension(GetExtractionInformation(cata, dimension2));

            if (isAxis)
            {
                var axis = new AggregateContinuousDateAxis(_repos.CatalogueRepository, mainDimension);
                axis.StartDate     = "'1970-01-01'";
                axis.AxisIncrement = FAnsi.Discovery.QuerySyntax.Aggregation.AxisIncrement.Year;
                axis.SaveToDatabase();
            }

            if (otherDimension != null)
            {
                ac.PivotOnDimensionID = otherDimension.ID;
                ac.SaveToDatabase();
            }

            return(ac);
        }
예제 #4
0
        private AggregateConfiguration SetupAggregateWithAxis(DatabaseType type, ExtractionInformation[] extractionInformations,
                                                              ICatalogue catalogue, out AggregateDimension axisDimension)
        {
            var dateDimension =
                extractionInformations.Single(
                    e => e.GetRuntimeName().Equals("EventDate", StringComparison.CurrentCultureIgnoreCase));
            var configuration = new AggregateConfiguration(CatalogueRepository, catalogue, "GroupBy_Category");

            axisDimension = new AggregateDimension(CatalogueRepository, dateDimension, configuration);

            var axis = new AggregateContinuousDateAxis(CatalogueRepository, axisDimension);

            axis.StartDate     = "'2000-01-01'";
            axis.AxisIncrement = AxisIncrement.Year;
            axis.SaveToDatabase();
            return(configuration);
        }
예제 #5
0
        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);
        }