Skip to content

Commit

Permalink
Merge pull request #43 from dynamicweb/nha/21123-dropdown-endpoints-r…
Browse files Browse the repository at this point in the history
…esemble-endpoint-treestructure

Endpoints are structured as in the endpoint collection tree structure
  • Loading branch information
MatthiasSort authored Dec 4, 2024
2 parents 8d888af + c0c48f1 commit 29185cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.8.3</Version>
<Version>10.8.4</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
36 changes: 19 additions & 17 deletions src/ODataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ namespace Dynamicweb.DataIntegration.Providers.ODataProvider;
[ResponseMapping(true)]
public class ODataProvider : BaseProvider, ISource, IDestination, IParameterOptions, IODataBaseProvider, IParameterVisibility
{
internal readonly EndpointService _endpointService = new();
internal readonly EndpointService _endpointService = new();
internal readonly EndpointCollectionService _endpointCollectionService = new EndpointCollectionService();
internal Schema _schema;
internal Endpoint _endpoint;
internal ICredentials _credentials;
Expand All @@ -48,9 +49,8 @@ public class ODataProvider : BaseProvider, ISource, IDestination, IParameterOpti
#region AddInManager/ConfigurableAddIn Source

[AddInParameter("Predefined endpoint")]
[AddInParameterEditor(typeof(GroupedDropDownParameterEditor), "none=true;refreshParameters=true;required=true")]
[AddInParameterEditor(typeof(GroupedDropDownParameterEditor), "none=true;refreshParameters=true;required=true;sortBy=,,default")]
[AddInParameterGroup("Source")]
[AddInParameterSection("Source")]
public string EndpointId
{
get => _endpoint?.Id.ToString();
Expand All @@ -64,49 +64,41 @@ public string EndpointId
[AddInParameter("Mode")]
[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; }

[AddInParameter("Maximum page size")]
[AddInParameterEditor(typeof(IntegerNumberParameterEditor), "allowNegativeValues=false")]
[AddInParameterGroup("Source")]
[AddInParameterSection("Advanced activity settings")]
public int MaximumPageSize { get; set; }

[AddInParameter("Request timeout (minutes)")]
[AddInParameterEditor(typeof(IntegerNumberParameterEditor), "allowNegativeValues=false")]
[AddInParameterGroup("Source")]
[AddInParameterSection("Advanced activity settings")]
public int RequestTimeout { get; set; } = 20;

[AddInParameter("Run last response")]
[AddInParameterEditor(typeof(YesNoParameterEditor), "Tooltip=Runs the job from the last saved response instead of calling the endpoint.")]
[AddInParameterGroup("Source")]
[AddInParameterSection("Advanced activity settings")]
public bool RunLastRequest { get; set; }

[AddInParameter("Run request in intervals (pages)")]
[AddInParameterEditor(typeof(IntegerNumberParameterEditor), "allowNegativeValues=false")]
[AddInParameterGroup("Source")]
[AddInParameterSection("Advanced activity settings")]
public int RequestIntervals { get; set; } = 0;

[AddInParameter("Do not store last response in log file")]
[AddInParameterEditor(typeof(YesNoParameterEditor), "Tooltip=Usefull when working with large amount of data.")]
[AddInParameterGroup("Source")]
[AddInParameterSection("Advanced activity settings")]
public bool DoNotStoreLastResponseInLogFile { get; set; }

[AddInParameter("Delta modifier")]
[AddInParameterEditor(typeof(TextParameterEditor), "infoText=Add your own delta properties. Default looking at these properties: Last_Date_Modified, Order_Date, LastDateTimeModified, lastModifiedDateTime and modifiedon.;inputClass=NewUIinput;")]
[AddInParameterGroup("Source")]
[AddInParameterSection("Advanced activity settings")]
public string DeltaModifier { get; set; }

[AddInParameter("Fail job if endpoint is busy or down")]
[AddInParameterEditor(typeof(YesNoParameterEditor), "Tooltip=If endpoint is busy or down during the run time, it will not insert already imported rows.")]
[AddInParameterGroup("Source")]
[AddInParameterSection("Advanced activity settings")]
public bool FailJobOnEndpointIsBusy { get; set; }

#endregion
Expand Down Expand Up @@ -135,7 +127,6 @@ private string GetMetadataURL()
return GetMetadataURLFallBack();

using var responseJson = JsonDocument.Parse(endpointResponse);

if (responseJson.RootElement.ValueKind != JsonValueKind.Object)
return GetMetadataURLFallBack();

Expand Down Expand Up @@ -227,11 +218,22 @@ IEnumerable<ParameterOption> IParameterOptions.GetParameterOptions(string parame
case "Predefined endpoint":
{
var result = new List<ParameterOption>();
foreach (var endpoint in _endpointService.GetEndpoints())
{
var value = new GroupedDropDownParameterEditor.DropDownItem(endpoint.Name, endpoint.Collection != null ? endpoint.Collection.Name : "Dynamicweb 9 Endpoints", endpoint.Id.ToString());
result.Add(new(endpoint.Name, value) { Group = endpoint.Collection != null ? endpoint.Collection.Name : "Dynamicweb 9 Endpoints" });
}

foreach(var collection in _endpointCollectionService.GetEndpointCollections().OrderBy(ec => ec.Sorting))
{
var parameterOptions = _endpointCollectionService.GetEndpoints(collection.Id).Select(endpoint =>
new ParameterOption(endpoint.Name,new GroupedDropDownParameterEditor.DropDownItem(endpoint.Name, collection.Name, endpoint.Id.ToString()))
{
Group = collection.Name
});
result.AddRange(parameterOptions);
}
result.AddRange(_endpointService.GetEndpoints().Where(e => e.Collection == null).Select(endpoint =>
new ParameterOption(endpoint.Name, new GroupedDropDownParameterEditor.DropDownItem(endpoint.Name, "Dynamicweb 9 Endpoints", endpoint.Id.ToString()))
{
Group = "Dynamicweb 9 Endpoints"
}));

return result;
}

Expand Down

0 comments on commit 29185cf

Please sign in to comment.