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

Added extension of IParameterVisibility to control what add-ins to hi… #42

Merged
merged 1 commit into from
Aug 16, 2024
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
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.6.2</Version>
<Version>10.6.3</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 Down
32 changes: 29 additions & 3 deletions src/ODataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Dynamicweb.DataIntegration.Providers.ODataProvider;
[AddInIgnore(false)]
[AddInUseParameterSectioning(true)]
[ResponseMapping(true)]
public class ODataProvider : BaseProvider, ISource, IDestination, IParameterOptions, IODataBaseProvider
public class ODataProvider : BaseProvider, ISource, IDestination, IParameterOptions, IODataBaseProvider, IParameterVisibility
{
internal readonly EndpointService _endpointService = new EndpointService();
internal Schema _schema;
Expand Down Expand Up @@ -61,7 +61,7 @@ public string EndpointId
}

[AddInParameter("Mode")]
[AddInParameterEditor(typeof(DropDownParameterEditor), "Info=Required;none=true;nonetext=Full Replication;noneHint=This mode gets all records and deletes nothing. This option should only run once.;columns=Mode|Comment;SortBy=Key;HideParameters=Run request in intervals (pages),Do not store last response in log file")]
[AddInParameterEditor(typeof(DropDownParameterEditor), "required=true;reloadOnChange=true;none=true;nonetext=Please select a Mode;SortBy=Key;")]
[AddInParameterGroup("Source")]
[AddInParameterSection("Advanced activity settings")]
public string Mode { get; set; }
Expand Down Expand Up @@ -168,6 +168,27 @@ internal void SetCredentials()
}
}

IEnumerable<string> IParameterVisibility.GetHiddenParameterNames(string parameterName, object parameterValue)
{
var parameters = new List<string>();
switch (parameterName)
{
case nameof(Mode):
if (!"Full Replication".Equals((string)parameterValue, StringComparison.OrdinalIgnoreCase))
{
parameters.Add("Run request in intervals (pages)");
parameters.Add("Do not store last response in log file");
}
if (!"Delta replication".Equals((string)parameterValue, StringComparison.OrdinalIgnoreCase))
{
parameters.Add("Delta modifier");
}
break;
}

return parameters;
}

IEnumerable<ParameterOption> IParameterOptions.GetParameterOptions(string parameterName)
{
switch (parameterName ?? "")
Expand All @@ -176,6 +197,7 @@ IEnumerable<ParameterOption> IParameterOptions.GetParameterOptions(string parame
{
return new List<ParameterOption>()
{
{ new("Full Replication", "Full Replication") { Hint = "This mode gets all records and deletes nothing. This option should only run once." } },
{ 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 @@ -427,7 +449,7 @@ public override ISourceReader GetReader(Mapping mapping)
throw new Exception("License check for OData failed.");
}

if (!string.IsNullOrEmpty(Mode))
if (!string.IsNullOrEmpty(Mode) && !Mode.Equals("Full Replication", StringComparison.OrdinalIgnoreCase))
{
RequestIntervals = 0;
DoNotStoreLastResponseInLogFile = false;
Expand All @@ -449,6 +471,10 @@ public override string ValidateSourceSettings()
{
return "Predefined endpoint can not be empty. Please select any predefined endpoint.";
}
if (string.IsNullOrEmpty(Mode))
{
return "Mode can not be empty. Please select a mode.";
}
if (_endpoint?.Authentication == null)
{
return "Credentials not set for endpoint, please add credentials before continue.";
Expand Down
Loading