mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
ACS-7689 Save and delete to existing hold (#9841)
This commit is contained in:
committed by
Darya Blavanovich
parent
bf7f202b91
commit
206f2e02ea
@@ -5,7 +5,7 @@ Status: Active
|
|||||||
Last reviewed: 2024-06-19
|
Last reviewed: 2024-06-19
|
||||||
---
|
---
|
||||||
|
|
||||||
# [Legal Hold service](../../../lib/content-services/src/lib/legal-hold/services/legal-hold.service.ts "Defined in legal-hold.service.ts")
|
# [Legal Hold service](../../../lib/content-services/src/lib/legal-hold/services/legal-hold.service.ts) "Defined in legal-hold.service.ts"
|
||||||
|
|
||||||
Manages holds for nodes.
|
Manages holds for nodes.
|
||||||
|
|
||||||
@@ -19,6 +19,25 @@ Manages holds for nodes.
|
|||||||
- _options_: `ContentPagingQuery` - Optional parameters supported by JS-API
|
- _options_: `ContentPagingQuery` - Optional parameters supported by JS-API
|
||||||
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`[]>` - List of holds
|
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`[]>` - List of holds
|
||||||
|
|
||||||
|
- **assignHold**(nodeId: `string`, holdId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`>`<br/>
|
||||||
|
Assign a node to a hold.
|
||||||
|
- _nodeId_: `string` - The Id of the node which will be assigned to a hold
|
||||||
|
- _holdId_: `string` - The Id of the hold to which nodes will be assigned
|
||||||
|
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldEntry`](../../../lib/js-api/src/api/gs-core-rest-api/docs/HoldEntry.md)`>` - Entry with the hold
|
||||||
|
|
||||||
|
- **assignHolds**(nodeIds: `<{id: string}[]>`, holdId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`Hold`](../../../lib/js-api/src/api/gs-core-rest-api/docs/HoldPaging.md)`>`<br/>
|
||||||
|
Assign a node to a hold.
|
||||||
|
- _nodeIds_: `<{id: string}[]>` - The Ids of the nodes which will be assigned to a hold
|
||||||
|
- _holdId_: `string` - The Id of the hold to which nodes will be assigned
|
||||||
|
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`HoldPaging`](../../../lib/js-api/src/api/gs-core-rest-api/docs/Hold.md)`>` - Hold paging
|
||||||
|
|
||||||
|
- **unassignHold**(holdId: `string`, nodeId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`void`]`>`<br/>
|
||||||
|
Assign a node to a hold.
|
||||||
|
- _holdId_: `string` - The hold Id
|
||||||
|
- _nodeId_: `string` - The Id of the node which is unassigned
|
||||||
|
- **Returns** [`void`]
|
||||||
|
|
||||||
|
|
||||||
## Details
|
## Details
|
||||||
|
|
||||||
To create, delete or get holds Records Management should be created and user should be added to it.
|
To create, delete or get holds Records Management should be created and user should be added to it.
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { ContentPagingQuery, Hold, LegalHoldApi } from '@alfresco/js-api';
|
import { ContentPagingQuery, Hold, HoldEntry, HoldPaging, LegalHoldApi } from '@alfresco/js-api';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable, from } from 'rxjs';
|
import { Observable, from } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
@@ -50,4 +50,37 @@ export class LegalHoldService {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign a node to a hold.
|
||||||
|
*
|
||||||
|
* @param nodeId The Id of the node which will be assigned to a hold
|
||||||
|
* @param holdId The Id of the hold to which nodes will be assigned
|
||||||
|
* @returns Observable<HoldEntry>
|
||||||
|
*/
|
||||||
|
assignHold(nodeId: string, holdId: string): Observable<HoldEntry> {
|
||||||
|
return from(this.legalHoldApi.assignHold(nodeId, holdId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign a node to a hold.
|
||||||
|
*
|
||||||
|
* @param nodeIds The list of managed node Ids
|
||||||
|
* @param holdId The Id of the hold to which nodes will be assigned
|
||||||
|
* @returns Observable<HoldPaging>
|
||||||
|
*/
|
||||||
|
assignHolds(nodeIds: { id: string }[], holdId: string): Observable<HoldPaging> {
|
||||||
|
return from(this.legalHoldApi.assignHolds(nodeIds, holdId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unassign the relationship between a child with id nodeId and a parent hold with id holdId.
|
||||||
|
*
|
||||||
|
* @param holdId The hold Id
|
||||||
|
* @param nodeId The Id of the node which is unassigned
|
||||||
|
* @returns Empty response
|
||||||
|
*/
|
||||||
|
unassignHold(holdId: string, nodeId: string): Observable<void> {
|
||||||
|
return from(this.legalHoldApi.unassignHold(holdId, nodeId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -71,4 +71,47 @@ describe('LegalHoldsService', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('assignHold', () => {
|
||||||
|
it('should assign node to existing hold', (done) => {
|
||||||
|
const nodeId = 'qwe';
|
||||||
|
const holdId = 'foo';
|
||||||
|
const mockResponse = { entry: { id: holdId } };
|
||||||
|
spyOn(service.legalHoldApi, 'assignHold').and.returnValue(Promise.resolve(mockResponse));
|
||||||
|
|
||||||
|
service.assignHold(nodeId, holdId).subscribe((holds) => {
|
||||||
|
expect(holds).toEqual(mockResponse);
|
||||||
|
expect(service.legalHoldApi.assignHold).toHaveBeenCalledWith(nodeId, holdId);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('assignHolds', () => {
|
||||||
|
it('should assign nodes to existing hold', (done) => {
|
||||||
|
const nodeIds = [{ id: 'qwe' }, { id: 'abc'}];
|
||||||
|
const holdId = 'foo';
|
||||||
|
spyOn(service.legalHoldApi, 'assignHolds').and.returnValue(Promise.resolve(legalHolds));
|
||||||
|
|
||||||
|
service.assignHolds(nodeIds, holdId).subscribe((holds) => {
|
||||||
|
expect(holds).toEqual(legalHolds);
|
||||||
|
expect(service.legalHoldApi.assignHolds).toHaveBeenCalledWith(nodeIds, holdId);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('unassignHold', () => {
|
||||||
|
it('should unassign node from existing hold', (done) => {
|
||||||
|
const nodeId = 'qwe';
|
||||||
|
const holdId = 'foo';
|
||||||
|
|
||||||
|
spyOn(service.legalHoldApi, 'unassignHold').and.returnValue(Promise.resolve(undefined));
|
||||||
|
|
||||||
|
service.unassignHold(holdId, nodeId).subscribe(() => {
|
||||||
|
expect(service.legalHoldApi.unassignHold).toHaveBeenCalledWith(holdId, nodeId);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -19,6 +19,7 @@ import { BaseApi } from './base.api';
|
|||||||
import { throwIfNotDefined } from '../../../assert';
|
import { throwIfNotDefined } from '../../../assert';
|
||||||
import { ContentPagingQuery } from '../../content-rest-api';
|
import { ContentPagingQuery } from '../../content-rest-api';
|
||||||
import { HoldPaging } from '../model/holdPaging';
|
import { HoldPaging } from '../model/holdPaging';
|
||||||
|
import { HoldEntry } from '../model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legal Holds service.
|
* Legal Holds service.
|
||||||
@@ -52,4 +53,59 @@ export class LegalHoldApi extends BaseApi {
|
|||||||
returnType: HoldPaging
|
returnType: HoldPaging
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign node to legal hold
|
||||||
|
*
|
||||||
|
* @param holdId The identifier of a hold
|
||||||
|
* @param nodeId The id of the node to be assigned to existing hold
|
||||||
|
* @returns Promise<HoldEntry>
|
||||||
|
*/
|
||||||
|
assignHold(nodeId: string, holdId: string): Promise<HoldEntry> {
|
||||||
|
throwIfNotDefined(holdId, 'holdId');
|
||||||
|
throwIfNotDefined(nodeId, 'nodeId');
|
||||||
|
|
||||||
|
return this.post({
|
||||||
|
path: `/holds/{holdId}/children`,
|
||||||
|
pathParams: { holdId },
|
||||||
|
bodyParam: [nodeId],
|
||||||
|
returnType: HoldEntry
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign nodes to legal hold
|
||||||
|
*
|
||||||
|
* @param holdId The identifier of a hold
|
||||||
|
* @param nodeIds The list with id of nodes to assign to existing hold
|
||||||
|
* @returns Promise<HoldPaging>
|
||||||
|
*/
|
||||||
|
assignHolds(nodeIds: { id: string }[], holdId: string): Promise<HoldPaging> {
|
||||||
|
throwIfNotDefined(holdId, 'holdId');
|
||||||
|
throwIfNotDefined(nodeIds, 'nodeIds');
|
||||||
|
|
||||||
|
return this.post({
|
||||||
|
path: `/holds/{holdId}/children`,
|
||||||
|
pathParams: { holdId },
|
||||||
|
bodyParam: nodeIds,
|
||||||
|
returnType: HoldPaging
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the relationship between a child with id nodeId and a parent hold with id holdId
|
||||||
|
*
|
||||||
|
* @param holdId The identifier of a hold
|
||||||
|
* @param nodeId The Id of the node which is unassigned
|
||||||
|
* @returns Empty response
|
||||||
|
*/
|
||||||
|
unassignHold(holdId: string, nodeId: string): Promise<void> {
|
||||||
|
throwIfNotDefined(holdId, 'holdId');
|
||||||
|
throwIfNotDefined(nodeId, 'nodeId');
|
||||||
|
|
||||||
|
return this.delete({
|
||||||
|
path: `/holds/{holdId}/children/{nodeId}`,
|
||||||
|
pathParams: { holdId, nodeId }
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,18 +1,24 @@
|
|||||||
# LegalHoldApi
|
# LegalHoldApi
|
||||||
|
|
||||||
All URIs are relative to *https://localhost/alfresco/api/-default-/public/gs/versions/1*
|
All URIs are relative to _https://localhost/alfresco/api/-default-/public/gs/versions/1_
|
||||||
|
|
||||||
Method | HTTP request | Description
|
| Method | HTTP request | Description |
|
||||||
------------- | ------------- | -------------
|
| ------------------------------------------------ | -------------------------------------------- | ----------------------------- |
|
||||||
[**getHolds**](LegalHoldApi.md#getHolds) | **GET** /file-plans/{filePlanId}/holds | Get legal holds list
|
| [**getHolds**](LegalHoldApi.md#getHolds) | **GET** /file-plans/{filePlanId}/holds | Get legal holds list |
|
||||||
|
| [**assignHold**](LegalHoldApi.md#assignHold) | **POST** /holds/{holdId}/children | Assign node to legal hold |
|
||||||
|
| [**assignHolds**](LegalHoldApi.md#assignHolds) | **POST** /holds/{holdId}/children | Assign nodes to legal hold |
|
||||||
|
| [**unassignHold**](LegalHoldApi.md#unassignHold) | **DELETE** /holds/{holdId}/children/{nodeId} | Unassign node from legal hold |
|
||||||
|
|
||||||
<a name="getHolds"></a>
|
<a name="getHolds"></a>
|
||||||
|
|
||||||
# **getHolds**
|
# **getHolds**
|
||||||
|
|
||||||
> HoldPaging getHolds(filePlanId, opts)
|
> HoldPaging getHolds(filePlanId, opts)
|
||||||
|
|
||||||
Get legal holds list.
|
Get legal holds list.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import LegalHoldApi from 'LegalHoldApi';
|
import LegalHoldApi from 'LegalHoldApi';
|
||||||
import { AlfrescoApi } from '@alfresco/js-api';
|
import { AlfrescoApi } from '@alfresco/js-api';
|
||||||
@@ -24,7 +30,7 @@ this.alfrescoApi.setConfig({
|
|||||||
|
|
||||||
let legalHoldApi = new LegalHoldApi(this.alfrescoApi);
|
let legalHoldApi = new LegalHoldApi(this.alfrescoApi);
|
||||||
|
|
||||||
let opts = {
|
let opts = {
|
||||||
'skipCount': 56 // | The number of entities that exist in the collection before those included in this list.
|
'skipCount': 56 // | The number of entities that exist in the collection before those included in this list.
|
||||||
'maxItems': 56 // | The maximum number of items to return in the list.
|
'maxItems': 56 // | The maximum number of items to return in the list.
|
||||||
};
|
};
|
||||||
@@ -39,12 +45,138 @@ legalHoldApi.getHolds('-filePlan-', opts).then((data) => {
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
Name | Type | Default value | Description
|
| Name | Type | Default value | Description |
|
||||||
------------- | ------------- | ------------- | -------------
|
| -------------- | ---------- | ------------- | -------------------------------------------------------------------------------------------------- |
|
||||||
**filePlanId** | **string** | | The site details
|
| **filePlanId** | **string** | | The site details |
|
||||||
**skipCount** | **number**| `0` | The number of entities that exist in the collection before those included in this list. [optional]
|
| **skipCount** | **number** | `0` | The number of entities that exist in the collection before those included in this list. [optional] |
|
||||||
**maxItems** | **number**| `100` | The maximum number of items to return in the list. [optional]
|
| **maxItems** | **number** | `100` | The maximum number of items to return in the list. [optional] |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
[**HoldPaging**](HoldPaging.md)
|
[**HoldPaging**](HoldPaging.md)
|
||||||
|
|
||||||
|
<a name="assignHold"></a>
|
||||||
|
|
||||||
|
# **assignHold**
|
||||||
|
|
||||||
|
> HoldEntry assignHold(nodeId, holdId)
|
||||||
|
|
||||||
|
Assign node to legal hold.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import LegalHoldApi from 'LegalHoldApi';
|
||||||
|
import { AlfrescoApi } from '@alfresco/js-api';
|
||||||
|
|
||||||
|
this.alfrescoApi = new AlfrescoApi();
|
||||||
|
this.alfrescoApi.setConfig({
|
||||||
|
hostEcm: 'http://127.0.0.1:8080'
|
||||||
|
});
|
||||||
|
|
||||||
|
let legalHoldApi = new LegalHoldApi(this.alfrescoApi);
|
||||||
|
|
||||||
|
legalHoldApi.assignHold('nodeId', 'holdId').then(
|
||||||
|
(data) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Default value | Description |
|
||||||
|
| ---------- | ---------- | ------------- | ----------------------------------------- |
|
||||||
|
| **nodeId** | **string** | | The id of the node to be assigned to hold |
|
||||||
|
| **holdId** | **string** | | The identifier of a hold. |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**HoldEntry**](HoldEntry.md)
|
||||||
|
|
||||||
|
<a name="assignHolds"></a>
|
||||||
|
|
||||||
|
# **assignHolds**
|
||||||
|
|
||||||
|
> HoldPaging assignHolds(nodeIds, holdId)
|
||||||
|
|
||||||
|
Assign nodes to legal hold.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import LegalHoldApi from 'LegalHoldApi';
|
||||||
|
import { AlfrescoApi } from '@alfresco/js-api';
|
||||||
|
|
||||||
|
this.alfrescoApi = new AlfrescoApi();
|
||||||
|
this.alfrescoApi.setConfig({
|
||||||
|
hostEcm: 'http://127.0.0.1:8080'
|
||||||
|
});
|
||||||
|
|
||||||
|
let legalHoldApi = new LegalHoldApi(this.alfrescoApi);
|
||||||
|
|
||||||
|
legalHoldApi.assignHolds([{ id: 'foo' }, { id: 'bar' }], 'holdId').then(
|
||||||
|
(data) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Default value | Description |
|
||||||
|
| ----------- |----------------------| ------------- | ---------------------------------------------------- |
|
||||||
|
| **nodeIds** | **{ id: string }[]** | | The list with id of nodes to assign to existing hold |
|
||||||
|
| **holdId** | **string** | | The identifier of a hold. |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**HoldPaging**](HoldPaging.md)
|
||||||
|
|
||||||
|
<a name="unassignHold"></a>
|
||||||
|
|
||||||
|
# **unassignHold**
|
||||||
|
|
||||||
|
> void unassignHold(holdId, nodeId)
|
||||||
|
|
||||||
|
Unassign node from legal hold.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import LegalHoldApi from 'LegalHoldApi';
|
||||||
|
import { AlfrescoApi } from '@alfresco/js-api';
|
||||||
|
|
||||||
|
this.alfrescoApi = new AlfrescoApi();
|
||||||
|
this.alfrescoApi.setConfig({
|
||||||
|
hostEcm: 'http://127.0.0.1:8080'
|
||||||
|
});
|
||||||
|
|
||||||
|
let legalHoldApi = new LegalHoldApi(this.alfrescoApi);
|
||||||
|
|
||||||
|
legalHoldApi.unassignHold('holdId', 'nodeId').then(
|
||||||
|
(data) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Default value | Description |
|
||||||
|
| ---------- | ---------- | ------------- | ------------------------------------------ |
|
||||||
|
| **holdId** | **string** | | The identifier of a hold |
|
||||||
|
| **nodeId** | **string** | | The nodeId of the node which is unassigned |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**void**
|
||||||
|
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export interface Hold {
|
export interface Hold {
|
||||||
name: string;
|
|
||||||
id?: string;
|
id?: string;
|
||||||
|
name?: string;
|
||||||
reason?: string;
|
reason?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
|
Reference in New Issue
Block a user