Skip to content

Commit

Permalink
Merge pull request #18 from dynamicweb/mss/12257-ParameterOptionsWith…
Browse files Browse the repository at this point in the history
…Hints

Added hints for Mode options.
  • Loading branch information
MatthiasSort authored Sep 28, 2023
2 parents 08a7167 + 2a1ba91 commit 2dd3297
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/Dynamicweb.DataIntegration.Providers.ODataProvider.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.0.6</Version>
<Version>10.0.7</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>OData Provider</Title>
<Description>The Odata Provider lets you fetch and map data from or to any OData endpoint.</Description>
Expand All @@ -24,7 +24,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.0.10" />
<PackageReference Include="Dynamicweb.DataIntegration" Version="10.0.13" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions src/ODataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Dynamicweb.DataIntegration.Providers.ODataProvider
[ResponseMapping(true)]
public class ODataProvider : BaseProvider, ISource, IDestination, IParameterOptions, IODataBaseProvider
{
internal readonly EndpointService _endpointService = new EndpointService();
internal readonly EndpointService _endpointService = new EndpointService();
internal Schema _schema;
internal Endpoint _endpoint;
internal ICredentials _credentials;
Expand Down Expand Up @@ -165,8 +165,8 @@ IEnumerable<ParameterOption> IParameterOptions.GetParameterOptions(string parame
{
return new List<ParameterOption>()
{
{ new("Delta replication|This mode filters records on date and time, whenever possible, and it only acts on new or updated records. It never deletes.","Delta Replication") },
{ new("First page|If maximum page size is 100 then this setting only handles the 100 records of the first page.", "First page") }
{ new("Delta replication", "Delta Replication") { Hint = "This mode filters records on date and time, whenever possible, and it only acts on new or updated records. It never deletes." } },
{ new("First page", "First page") { Hint = "If maximum page size is 100 then this setting only handles the 100 records of the first page." } }
};
}

Expand Down Expand Up @@ -415,7 +415,7 @@ public override void Close()
}

public override string ValidateSourceSettings()
{
{
SetCredentials();
if (string.IsNullOrEmpty(EndpointId))
{
Expand Down Expand Up @@ -443,7 +443,7 @@ public override string ValidateSourceSettings()

public override string ValidateDestinationSettings()
{
SetCredentials();
SetCredentials();
if (string.IsNullOrEmpty(DestinationEndpointId))
{
return "Destination endpoint can not be empty. Please select any destination endpoint";
Expand Down Expand Up @@ -623,7 +623,7 @@ public override bool RunJob(Job job)
}

Logger?.Log($"Begin synchronizing '{mapping.SourceTable.Name}' to '{mapping.DestinationTable.Name}'.");

using (var writer = new ODataWriter(Logger, mapping, _endpoint, _credentials))
{
using (ISourceReader sourceReader = mapping.Source.GetReader(mapping))
Expand Down
36 changes: 13 additions & 23 deletions src/ODataSourceReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ private List<string> GetFilterAsParameters()
{
string condition = item.Condition;
string operatorInOData = "";
bool isAlreadyAddedToResult = false;
switch (item.ConditionalOperator)
{
case ConditionalOperator.EqualTo:
Expand All @@ -336,12 +335,10 @@ private List<string> GetFilterAsParameters()
break;
case ConditionalOperator.Contains:
result.Add($"contains({item.SourceColumn.Name},'{item.Condition}')");
isAlreadyAddedToResult = true;
break;
continue;
case ConditionalOperator.NotContains:
result.Add($"contains({item.SourceColumn.Name},'{item.Condition}') ne true");
isAlreadyAddedToResult = true;
break;
continue;
case ConditionalOperator.In:
operatorInOData = "eq";
List<string> equalConditions = item.Condition.Split(',').Select(val => val.Trim()).ToList();
Expand All @@ -368,32 +365,25 @@ private List<string> GetFilterAsParameters()
break;
case ConditionalOperator.StartsWith:
result.Add($"startswith({item.SourceColumn.Name},'{item.Condition}')");
isAlreadyAddedToResult = true;
break;
continue;
case ConditionalOperator.NotStartsWith:
result.Add($"startswith({item.SourceColumn.Name},'{item.Condition}') ne true");
isAlreadyAddedToResult = true;
break;
continue;
case ConditionalOperator.EndsWith:
result.Add($"endswith({item.SourceColumn.Name},'{item.Condition}')");
isAlreadyAddedToResult = true;
break;
continue;
case ConditionalOperator.NotEndsWith:
result.Add($"endswith({item.SourceColumn.Name},'{item.Condition}') ne true");
isAlreadyAddedToResult = true;
break;
continue;

}
if (!isAlreadyAddedToResult)
if (item.SourceColumn.Type == typeof(string))
{
if (item.SourceColumn.Type == typeof(string))
{
result.Add($"({item.SourceColumn.Name} {operatorInOData} '{condition}')");
}
else
{
result.Add($"({item.SourceColumn.Name} {operatorInOData} {condition})");
}
result.Add($"({item.SourceColumn.Name} {operatorInOData} '{condition}')");
}
else
{
result.Add($"({item.SourceColumn.Name} {operatorInOData} {condition})");
}
}
}
Expand Down Expand Up @@ -594,7 +584,7 @@ private bool CheckIfEndpointIsReadyForUse(string url)
if (endpointAuthentication.IsTokenBased())
{
string token = OAuthHelper.GetToken(_endpoint, endpointAuthentication, out Exception exception);
if (exception != null)
if (exception != null)
{
throw exception;
}
Expand Down

0 comments on commit 2dd3297

Please sign in to comment.