Skip to content

Commit

Permalink
Merge pull request #145 from RevealBi/data-source/azure-synapse-analy…
Browse files Browse the repository at this point in the history
…tics

Data source/azure synapse analytics
  • Loading branch information
brianlagunas authored Dec 12, 2024
2 parents 94ab7e6 + 86d8924 commit f001d01
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 16 deletions.
45 changes: 45 additions & 0 deletions e2e/Sandbox/DashboardCreators/MSAzureSynapseAnalyticsDashboard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Reveal.Sdk.Dom;
using Reveal.Sdk.Dom.Data;
using Reveal.Sdk.Dom.Visualizations;
using System.Collections.Generic;

namespace Sandbox.DashboardFactories
{
internal class MSAzureSynapseAnalyticsDashboard : IDashboardCreator
{
public string Name => "MS Azure Synapse Analytics Data Source";

public RdashDocument CreateDashboard()
{
var document = new RdashDocument("Azure Synapse Analytics Dashboard");

var dataSource = new MicrosoftAzureSynapseAnalyticsDataSource()
{
Id = "azureSynapseDSId",
Title = "Synapse data source title",
Host = "revealdb01.infragistics.local",
Database = "Northwind",
Port = 1433,
TrustServerCertificate = false
};
var dataSourceItem = new MicrosoftAzureSynapseAnalyticsDataSourceItem("MS Azure Synapse DS Item", dataSource)
{
Id = "azureSynapseDSItemId",
Title = "Synapse DS item title",
Database = dataSource.Database,
Table = "Categories",
Fields = new List<IField>
{
new NumberField("CategoryID"),
new TextField("CategoryName"),
new TextField("Description")
}
};

document.Visualizations.Add(new GridVisualization("List Categories", dataSourceItem)
.SetColumns("CategoryID", "CategoryName", "Description"));

return document;
}
}
}
2 changes: 2 additions & 0 deletions e2e/Sandbox/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public partial class MainWindow : Window
new MSAnalysisServiceDashboard(),
new MSAzureAnalysisServiceDashboard(),
new MSAzureSqlDashboard(),
new MSAzureSynapseAnalyticsDashboard(),
new MySqlDashboard(),
new MySqlDataSourceDashboards(),
new MSAzureSqlServerDSDashboard(),
new ODataDashboard(),
Expand Down
6 changes: 5 additions & 1 deletion e2e/Sandbox/Reveal/AuthenticationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ internal class AuthenticationProvider : IRVAuthenticationProvider
public Task<IRVDataSourceCredential> ResolveCredentialsAsync(RVDashboardDataSource dataSource)
{
IRVDataSourceCredential userCredential = null;
if (dataSource is RVAzureSqlDataSource)
if (dataSource is RVAzureSynapseDataSource)
{
userCredential = new RVUsernamePasswordDataSourceCredential("azure-synapse-username", "password", "domain");
}
else if (dataSource is RVAzureSqlDataSource)
{
userCredential = new RVUsernamePasswordDataSourceCredential("azure-username", "password");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
using Reveal.Sdk.Dom.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems
{
public class MicrosoftAzureSynapseAnalyticsDataSourceItemFixture
{
[Fact]
public void Constructor_CreateAzureSynapseDSItem_WithTitle()
{
// Arrange
var expectedDSItemTitle = "Azure Synapse DSI Title";

// Act
var dataSourceItem = new MicrosoftAzureSynapseAnalyticsDataSourceItem(expectedDSItemTitle);

// Assert
Assert.Equal(expectedDSItemTitle, dataSourceItem.Title);
Assert.NotNull(dataSourceItem.DataSource);
Assert.Equal(expectedDSItemTitle, dataSourceItem.DataSource.Title);
Assert.IsType<MicrosoftAzureSynapseAnalyticsDataSource>(dataSourceItem.DataSource);
}

[Theory]
[InlineData("DS Title", "DS Item Title", "DS Title", "DS Item Title")]
[InlineData(null, "DS Item Title", "DS Item Title", "DS Item Title")]
public void Constructor_SetsTitleAndDatasource_AsProvided(string dSTitle, string dSItemTitle, string expectedDSTitle, string expectedDSItemTitle)
public void Constructor_CreateDataSource_WithTitleAndDataSource(string dSTitle, string dSItemTitle, string expectedDSTitle, string expectedDSItemTitle)
{
// Arrange
var dataSource = new MicrosoftAzureSynapseAnalyticsDataSource() { Title = dSTitle };
var dataSource = new DataSource() { Title = dSTitle };

// Act
var dataSourceItem = new MicrosoftAzureSynapseAnalyticsDataSourceItem(dSItemTitle, dataSource);
Expand All @@ -27,8 +37,27 @@ public void Constructor_SetsTitleAndDatasource_AsProvided(string dSTitle, string
Assert.Equal(dataSource, dataSourceItem.DataSource);
Assert.Equal(dataSource.Id, dataSourceItem.DataSourceId);
Assert.Equal(expectedDSTitle, dataSourceItem.DataSource.Title);
Assert.NotSame(dataSource, dataSourceItem.DataSource);
Assert.IsType<MicrosoftAzureSynapseAnalyticsDataSource>(dataSourceItem.DataSource);
}

[Theory]
[InlineData("DS Title", "DS Item Title", "DS Title", "DS Item Title")]
[InlineData(null, "DS Item Title", "DS Item Title", "DS Item Title")]
public void Constructor_CreateDataSource_WithTitleAndAzureSynapseDataSource(string dSTitle, string dSItemTitle, string expectedDSTitle, string expectedDSItemTitle)
{
// Arrange
var dataSource = new MicrosoftAzureSynapseAnalyticsDataSource() { Title = dSTitle };

// Act
var dataSourceItem = new MicrosoftAzureSynapseAnalyticsDataSourceItem(dSItemTitle, dataSource);

// Assert
Assert.Equal(expectedDSItemTitle, dataSourceItem.Title);
Assert.Equal(dataSource, dataSourceItem.DataSource);
Assert.Equal(dataSource.Id, dataSourceItem.DataSourceId);
Assert.Equal(expectedDSTitle, dataSourceItem.DataSource.Title);
Assert.Same(dataSource, dataSourceItem.DataSource);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using Reveal.Sdk.Dom.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSources
{
public class MicrosoftAzureSynapseAnalyticsDataSourceFixture
{
[Fact]
public void Constructor_SetProviderToMicrosoftAzureSqlServer_WhenConstructed()
public void Constructor_SetProviderToMicrosoftAzureSynapseAnalytics_WithoutParameters()
{
// Act
var dataSource = new MicrosoftAzureSynapseAnalyticsDataSource();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
namespace Reveal.Sdk.Dom.Data
{
internal class MicrosoftAzureSynapseAnalyticsDataSourceItem : MicrosoftSqlServerDataSourceItem
public class MicrosoftAzureSynapseAnalyticsDataSourceItem : MicrosoftSqlServerDataSourceItem
{
public MicrosoftAzureSynapseAnalyticsDataSourceItem(string title) :
base(title, new MicrosoftAzureSynapseAnalyticsDataSource())
{ }

public MicrosoftAzureSynapseAnalyticsDataSourceItem(string title, DataSource dataSource) :
base(title, dataSource)
{ }

public MicrosoftAzureSynapseAnalyticsDataSourceItem(string title, MicrosoftAzureSynapseAnalyticsDataSource dataSource)
: base(title, dataSource)
{ }

protected override DataSource CreateDataSourceInstance(DataSource dataSource)
{
return Create<MicrosoftAzureSynapseAnalyticsDataSource>(dataSource);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Reveal.Sdk.Dom.Data
{
internal class MicrosoftAzureSynapseAnalyticsDataSource : MicrosoftAzureSqlServerDataSource
public class MicrosoftAzureSynapseAnalyticsDataSource : MicrosoftAzureSqlServerDataSource
{
public MicrosoftAzureSynapseAnalyticsDataSource()
{
Expand Down

0 comments on commit f001d01

Please sign in to comment.