[ACS-7690] Saving adding o a new hold (#9862)

* ACS-7689 Save and delete to existing hold

* ACS-7689 Save and delete to existing hold, cleanup

* ACS-7689 Save and delete to existing hold, revert to separate methods

* ACS-7689 Save and delete to existing hold, fix specs

* ACS-7689 Save and delete to existing hold, fix specs

* ACS-7689 Save and delete to existing hold

* ACS-8055 add listAssignedHolds API

* ACS-8055 create legal-hold service

* ACS-8055 add documentation

* ACS-8055 fix imports

* ACS-8055 add HoldPaging class and documentation

* ACS-8055 add interface and fix test

* ACS-7689 Save and delete to existing hold, fix specs

* ACS-7689 Save and delete to existing hold, fix specs

* ACS-7690 integrate create and assign holds endpoints

* ACS-7690 fix imports

* ACS-7690 add bulk method

* ACS-7690 update readme file

* ACS-7690 add tests

* ACS-7690 update docs file

* ACS-7690 remove interface

* ACS-7690 update geHolds description and md file with createHold

* ACS-7690 add createHolds to md file

* ACS-7690 fix typo in spec, and description in legal-hold service

* ACS-7690 refactor create hold parameter and documentation

* ACS-7690 fixed test

* ACS-7690 fix test for getHolds

* ACS-7690 fix md for create hold action

* ACS-7690 fix rebase conflicts

---------

Co-authored-by: Tomasz Nastaly <tomasz.nastaly@hyland.com>
Co-authored-by: DaryaBalvanovich <darya.balvanovich1@hyland.com>
This commit is contained in:
Darya Blavanovich
2024-06-26 14:35:26 +02:00
parent 206f2e02ea
commit 0843263ce3
5 changed files with 233 additions and 23 deletions

View File

@@ -34,7 +34,7 @@ export class LegalHoldService {
constructor(private readonly apiService: AlfrescoApiService) {}
/**
* Gets the list of holds.
* Gets the list of holds available in the file plan.
*
* @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias.
* @param options Optional parameters supported by JS-API
@@ -83,4 +83,26 @@ export class LegalHoldService {
unassignHold(holdId: string, nodeId: string): Observable<void> {
return from(this.legalHoldApi.unassignHold(holdId, nodeId));
}
/**
* Create hold.
*
* @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias.
* @param hold Hold to create
* @returns List of created holds Observable<HoldEntry>
*/
createHold(filePlanId: string, hold: Hold): Observable<HoldEntry> {
return from(this.legalHoldApi.createHold(filePlanId, hold));
}
/**
* Create list of holds.
*
* @param filePlanId The identifier of a file plan. You can also use the -filePlan- alias.
* @param holds Array of holds to create
* @returns List of created holds Observable<HoldPaging>
*/
createHolds(filePlanId: string, holds: Hold[]): Observable<HoldPaging> {
return from(this.legalHoldApi.createHolds(filePlanId, holds));
}
}

View File

@@ -18,11 +18,12 @@
import { TestBed } from '@angular/core/testing';
import { LegalHoldService } from './legal-hold.service';
import { ContentTestingModule } from '../../testing/content.testing.module';
import { Hold, HoldPaging } from '@alfresco/js-api';
import { Hold, HoldEntry, HoldPaging } from '@alfresco/js-api';
describe('LegalHoldsService', () => {
let service: LegalHoldService;
let legalHolds: HoldPaging;
let legalHoldEntry: HoldEntry;
let returnedHolds: Hold[];
const mockId = 'mockId';
@@ -34,24 +35,23 @@ describe('LegalHoldsService', () => {
legalHolds = {
list: {
entries: [
{
entry: {
id: mockId,
name: 'some name',
reason: 'some description'
}
}
]
entries: [legalHoldEntry]
}
} as HoldPaging;
legalHoldEntry = {
entry: {
id: mockId,
name: 'some name',
reason: 'some reason',
description: 'some description'
}
};
returnedHolds = [
{
id: mockId,
name: 'some name',
reason: 'some description',
description: undefined
name: 'some name'
}
];
});
@@ -66,7 +66,7 @@ describe('LegalHoldsService', () => {
service.getHolds(mockId).subscribe((holds) => {
expect(holds).toEqual(returnedHolds);
expect(service.legalHoldApi.getHolds).toHaveBeenCalledWith(mockId, {});
expect(service.legalHoldApi.getHolds).toHaveBeenCalledWith(mockId, undefined);
done();
});
});
@@ -89,7 +89,7 @@ describe('LegalHoldsService', () => {
describe('assignHolds', () => {
it('should assign nodes to existing hold', (done) => {
const nodeIds = [{ id: 'qwe' }, { id: 'abc'}];
const nodeIds = [{ id: 'qwe' }, { id: 'abc' }];
const holdId = 'foo';
spyOn(service.legalHoldApi, 'assignHolds').and.returnValue(Promise.resolve(legalHolds));
@@ -114,4 +114,42 @@ describe('LegalHoldsService', () => {
});
});
});
describe('createHold', () => {
it('should create new hold', (done) => {
const mockHold = {
name: 'Hold 1',
reason: 'reason 1'
};
spyOn(service.legalHoldApi, 'createHold').and.returnValue(Promise.resolve(legalHoldEntry));
service.createHold(mockId, mockHold).subscribe((hold) => {
expect(hold).toEqual(legalHoldEntry);
expect(service.legalHoldApi.createHold).toHaveBeenCalledWith(mockId, mockHold);
done();
});
});
});
describe('createHolds', () => {
it('should create list of holds', (done) => {
const mockHolds = [
{
name: 'Hold 1',
reason: 'reason 1'
},
{
name: 'Hold 2',
reason: 'reason 2'
}
];
spyOn(service.legalHoldApi, 'createHolds').and.returnValue(Promise.resolve(legalHolds));
service.createHolds(mockId, mockHolds).subscribe((holds) => {
expect(holds).toEqual(legalHolds);
expect(service.legalHoldApi.createHolds).toHaveBeenCalledWith(mockId, mockHolds);
done();
});
});
});
});