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

Add functionality to remove delta files when resetting tables #165

Merged
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
11 changes: 10 additions & 1 deletion businessCentral/app/src/Communication.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,20 @@ codeunit 82562 "ADLSE Communication"

procedure ResetTableExport(ltableId: Integer)
var
ADLSESetup: Record "ADLSE Setup";
ADLSEUtil: Codeunit "ADLSE Util";
ADLSEGen2Util: Codeunit "ADLSE Gen 2 Util";
Body: JsonObject;
begin
ADLSESetup.GetSingleton();
ADLSECredentials.Init();
ADLSEGen2Util.CreateOrUpdateJsonBlob(GetBaseUrl() + StrSubstNo(ResetTableExportTxt, ADLSEUtil.GetDataLakeCompliantTableName(ltableId)), ADLSECredentials, '', Body);
case ADLSESetup."Storage Type" of
"ADLSE Storage Type"::"Microsoft Fabric":
ADLSEGen2Util.CreateOrUpdateJsonBlob(GetBaseUrl() + StrSubstNo(ResetTableExportTxt, ADLSEUtil.GetDataLakeCompliantTableName(ltableId)), ADLSECredentials, '', Body);
"ADLSE Storage Type"::"Azure Data Lake":
ADLSEGen2Util.RemoveDeltasFromDataLake(ADLSEUtil.GetDataLakeCompliantTableName(ltableId), ADLSECredentials);
end;
end;


}
20 changes: 20 additions & 0 deletions businessCentral/app/src/Gen2Util.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,26 @@ codeunit 82568 "ADLSE Gen 2 Util"
exit(true);
end;

procedure RemoveDeltasFromDataLake(ADLSEntityName: Text; ADLSECredentials: Codeunit "ADLSE Credentials")
var
ADLSESetup: Record "ADLSE Setup";
ADLSEHttp: Codeunit "ADLSE Http";
Response: Text;
Url: Text;
ADLSEContainerUrlTxt: Label 'https://%1.dfs.core.windows.net/%2', Comment = '%1: Account name, %2: Container Name', Locked = true;
begin
// DELETE https://{accountName}.{dnsSuffix}/{filesystem}/{path}
// https://learn.microsoft.com/en-us/rest/api/storageservices/datalakestoragegen2/path/delete?view=rest-storageservices-datalakestoragegen2-2019-12-12
ADLSESetup.GetSingleton();
Url := StrSubstNo(ADLSEContainerUrlTxt, ADLSESetup."Account Name", ADLSESetup.Container);
Url += '/deltas/' + ADLSEntityName + '?recursive=true';

ADLSEHttp.SetMethod("ADLSE Http Method"::Delete);
ADLSEHttp.SetUrl(Url);
ADLSEHttp.SetAuthorizationCredentials(ADLSECredentials);
ADLSEHttp.InvokeRestApi(Response)
end;

[IntegrationEvent(false, false)]
local procedure OnBeforeGetBlobContent(BlobPath: Text; ADLSECredentials: Codeunit "ADLSE Credentials"; var BlobExists: Boolean; var Content: JsonObject; var IsHandled: Boolean)
begin
Expand Down
1 change: 0 additions & 1 deletion businessCentral/app/src/Setup.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ page 82560 "ADLSE Setup"
field("Delete Table"; Rec."Delete Table")
{
ToolTip = 'Specifies if the table will be deleted if a reset of the table is done.';
Editable = not AzureDataLake;
}
field("Delivered DateTime"; Rec."Delivered DateTime")
{
Expand Down
2 changes: 1 addition & 1 deletion businessCentral/app/src/Table.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ table 82561 "ADLSE Table"
ADLSEDeletedRecord.DeleteAll();

ADLSESetup.GetSingleton();
if (ADLSESetup."Delete Table") and (ADLSESetup."Storage Type" = ADLSESetup."Storage Type"::"Microsoft Fabric") then
if (ADLSESetup."Delete Table") then
ADLSECommunication.ResetTableExport(Rec."Table ID");

OnAfterResetSelected(Rec);
Expand Down
Loading