Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed specific data source and data source items #7

Merged
merged 1 commit into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ public class DashboardDocumentValidatorFixture
[Fact]
public void DataSources_AddedToDashboardDocument()
{
var excelDataSource = new ExcelDataSource();
var excelDataSourceItem = new ExcelDataSourceItem(excelDataSource, new List<Field>());
var dataSourceItem = new RestBuilder("").SetFields(new List<Field>() { null }).Build();

var document = new DashboardDocument();
document.Visualizations.Add(new KpiTimeVisualization(excelDataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));

Assert.Empty(document.DataSources);

Expand All @@ -29,45 +28,44 @@ public void DataSources_AddedToDashboardDocument()
[Fact]
public void DataSources_FromVisualizationsAreNotDuplicated()
{
var excelDataSource = new ExcelDataSource();
var excelDataSourceItem = new ExcelDataSourceItem(excelDataSource, new List<Field>());
var dataSourceItem = new RestBuilder("").SetFields(new List<Field>() { null }).Build();

var document = new DashboardDocument();
document.Visualizations.Add(new KpiTimeVisualization(excelDataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(excelDataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(excelDataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(excelDataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));

Assert.Empty(document.DataSources);

DashboardDocumentValidator.FixDashboardDocument(document);

var excelDataSources = document.DataSources.Where(x => x.Provider == DataSourceProviders.ExcelProvider);
var jsonDataSources = document.DataSources.Where(x => x.Provider == DataSourceProviders.JSON);

Assert.Single(excelDataSources);
Assert.Single(jsonDataSources);
}

[Fact]
public void DataSources_FromVisualizations_AndDataSources_AreNotDuplicated()
{
var excelDataSource = new ExcelDataSource();
var excelDataSourceItem = new ExcelDataSourceItem(excelDataSource, new List<Field>());
var dataSourceItem = new RestBuilder("").SetFields(new List<Field>() { null }).Build();
var dataSource = dataSourceItem.DataSource;

var document = new DashboardDocument();
document.DataSources.Add(excelDataSource);
document.DataSources.Add(dataSource);

document.Visualizations.Add(new KpiTimeVisualization(excelDataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(excelDataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(excelDataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(excelDataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));
document.Visualizations.Add(new KpiTimeVisualization(dataSourceItem));

Assert.Single(document.DataSources);

DashboardDocumentValidator.FixDashboardDocument(document);

var excelDataSources = document.DataSources.Where(x => x.Provider == DataSourceProviders.ExcelProvider);
var jsonDataSources = document.DataSources.Where(x => x.Provider == DataSourceProviders.JSON);

Assert.Single(excelDataSources);
Assert.Single(jsonDataSources);
}
}
}

This file was deleted.

This file was deleted.

91 changes: 0 additions & 91 deletions Reveal.Sdk.Dom/Data/Builders/ExcelBuilder.cs

This file was deleted.

11 changes: 7 additions & 4 deletions Reveal.Sdk.Dom/Data/Builders/RestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public RestBuilder SetSubtitle(string subtitle)

public DataSourceItem Build()
{
if (_dataSourceItem.Fields == null || _dataSourceItem.Fields.Count == 0)
throw new ArgumentException("You must provide the field definitions for the data source item.");
if (_dataSourceItem.Fields.Count == 0)
throw new ArgumentException("You must provide the field definitions for the data source item. Call the SetFields method and provide the fields.");

return _dataSourceItem;
}
Expand Down Expand Up @@ -130,13 +130,16 @@ public RestBuilder UseExcel(string sheet = null, ExcelFileType fileType = ExcelF
return this;
}

//todo: why is this required for json data? We already have the fields? Is this used for CSV too?
//todo: why is this required for json data? We already have the fields?
Dictionary<string, object> BuildConfig(IEnumerable<Field> fields)
{
Dictionary<string, object> config = new Dictionary<string, object>();
List<ColumnConfig> columnConfigs = new List<ColumnConfig>();
foreach (var field in fields)
{
if (field == null)
continue;

var columnConfig = new ColumnConfig();
columnConfig.Key = field.FieldName;

Expand All @@ -153,7 +156,7 @@ Dictionary<string, object> BuildConfig(IEnumerable<Field> fields)
columnConfigs.Add(columnConfig);
}

config.Add("iterationDepth", 0); //todo: what is this all about?
config.Add("iterationDepth", 0);
config.Add("columnsConfig", columnConfigs);
return config;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using Newtonsoft.Json;
using Reveal.Sdk.Dom.Core;
using Reveal.Sdk.Dom.Core.Constants;
using Reveal.Sdk.Dom.Core.Serialization.Converters;
using System;
using System.Collections.Generic;

namespace Reveal.Sdk.Dom.Data
{
//[JsonConverter(typeof(DataSourceConverter))]
public class DataSource : SchemaType, IEquatable<DataSource>
{
public string Id { get; set; } = Guid.NewGuid().ToString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using Newtonsoft.Json;
using Reveal.Sdk.Dom.Core;
using Reveal.Sdk.Dom.Core.Constants;
using Reveal.Sdk.Dom.Core.Serialization.Converters;
using Reveal.Sdk.Dom.Visualizations;
using System;
using System.Collections.Generic;

namespace Reveal.Sdk.Dom.Data
{
[JsonConverter(typeof(DataSourceItemConverter))]
public class DataSourceItem : SchemaType
{
public string Id { get; set; } = Guid.NewGuid().ToString();
Expand All @@ -24,15 +22,17 @@ public class DataSourceItem : SchemaType
[JsonIgnore]
public List<Field> Fields { get; internal set; } = new List<Field>();

[JsonIgnore]
/// <summary>
/// The data source for the current DataSourceItem
/// </summary>
internal DataSource DataSource { get; set; }
public DataSource DataSource { get; internal set; }

[JsonIgnore]
/// <summary>
/// The data source for the ResourceItem
/// </summary>
internal DataSource ResourceItemDataSource { get; set; }
public DataSource ResourceItemDataSource { get; internal set; }

public DataSourceItem()
{
Expand Down

This file was deleted.

59 changes: 0 additions & 59 deletions Reveal.Sdk.Dom/Data/DataSourceItems/ExcelDataSourceItem.cs

This file was deleted.

23 changes: 0 additions & 23 deletions Reveal.Sdk.Dom/Data/DataSources/ExcelDataSource.cs

This file was deleted.

Loading