Skip to content

Commit

Permalink
Add functionality to remove delta files when resetting tables
Browse files Browse the repository at this point in the history
  • Loading branch information
acjdekorte committed Aug 20, 2024
1 parent 439e706 commit c18c34c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
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

0 comments on commit c18c34c

Please sign in to comment.