ACS-8055 add listAssignedHolds API

This commit is contained in:
DaryaBalvanovich
2024-06-04 18:17:50 +02:00
parent 376969ae42
commit f554c60f07
9 changed files with 242 additions and 5 deletions
@@ -16,7 +16,7 @@
*/
import { Injectable } from '@angular/core';
import { NodeEntry, NodePaging, NodesApi, TrashcanApi, Node } from '@alfresco/js-api';
import { NodeEntry, NodePaging, NodesApi, TrashcanApi, Node, NodeHold } from '@alfresco/js-api';
import { Subject, from, Observable, throwError } from 'rxjs';
import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core';
import { catchError, map } from 'rxjs/operators';
@@ -239,4 +239,28 @@ export class NodesApiService {
return new NodeMetadata(metadata, nodeEntry.entry.nodeType);
}
/**
* Gets the list of holds assigned to the node.
*
* @param nodeId ID of the target node
* @returns List of assigned holds
*/
getNodeAssignHolds(nodeId: string): Observable<NodeHold[]> {
const queryOptions = Object.assign({
maxItems: this.preferences.paginationSize,
skipCount: 0,
where: `(assocType='rma:frozenContent')`
});
return from(this.nodesApi.listAssignedHolds(nodeId, queryOptions)).pipe(
map((holds) =>
holds.list?.entries?.map((entity) => ({
id: entity.entry.id,
name: entity.entry.name
}))
),
catchError((err) => throwError(err))
);
}
}
@@ -34,6 +34,7 @@ import { BaseApi } from './base.api';
import { throwIfNotDefined } from '../../../assert';
import { buildCollectionParam } from '../../../alfrescoApiClient';
import { ContentPagingQuery } from './types';
import { NodeAssignedHoldPaging } from '../model/nodeAssinedHoldsPaging';
export type NodesIncludeQuery = {
/**
@@ -982,4 +983,48 @@ export class NodesApi extends BaseApi {
returnType: DirectAccessUrlEntry
});
}
/**
* List Assigned Holds
*
* **Note:** this endpoint is available in Alfresco 7.1 and newer versions.
*
* Gets a list of assigned holds that are associated with the current **nodeId**.
*
* @param nodeId The identifier of a child node. You can also use one of these well-known aliases:
* - -my-
* - -shared-
* - -root-
* @param opts Optional parameters
* @param opts.where Optionally filter the list by **frozenContent**:
* - where=(assocType='rma:frozenContent')
* @returns Promise<NodeAssignedHoldPaging>
*/
listAssignedHolds(
nodeId: string,
opts?: {
where?: string;
} & ContentPagingQuery
): Promise<NodeAssignedHoldPaging> {
throwIfNotDefined(nodeId, 'nodeId');
opts = opts || {};
const pathParams = {
nodeId
};
const queryParams = {
where: opts?.where,
skipCount: opts?.skipCount,
maxItems: opts?.maxItems
};
return this.get({
path: '/nodes/{nodeId}/parents',
pathParams,
queryParams,
returnType: NodeAssignedHoldPaging
});
}
}
@@ -162,10 +162,10 @@ export * from './siteMember';
export * from './siteMemberEntry';
export * from './siteMemberPaging';
export * from './siteMemberPagingList';
export * from './siteGroup';
export * from './siteGroupEntry';
export * from './siteGroupPaging';
export * from './siteGroupPagingList';
export * from './siteGroup';
export * from './siteGroupEntry';
export * from './siteGroupPaging';
export * from './siteGroupPagingList';
export * from './siteMembershipApprovalBody';
export * from './siteMembershipBodyCreate';
export * from './siteMembershipBodyUpdate';
@@ -199,3 +199,7 @@ export * from './versionPagingList';
export * from './deletedNode';
export * from './nodeAssociation';
export * from './nodeChildAssociation';
export * from './nodeAssignedHoldPagingList';
export * from './nodeAssinedHoldsPaging';
export * from './nodeAssignedHoldEntry';
export * from './nodeAssignedHold';
@@ -0,0 +1,48 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { DateAlfresco } from '../../content-custom-api';
import { UserInfo } from './userInfo';
import { ChildAssociationInfo } from './childAssociationInfo';
export class NodeAssignedHold {
id: string;
/**
* The name must not contain spaces or the following special characters: * \" < > \\ / ? : and |.
* The character . must not be used at the end of the name.
*/
name: string;
nodeType: string;
isFolder: boolean;
isFile: boolean;
modifiedAt: Date;
modifiedByUser: UserInfo;
createdAt: Date;
createdByUser: UserInfo;
parentId?: string;
association?: ChildAssociationInfo;
constructor(input?: Partial<NodeAssignedHold>) {
if (input) {
Object.assign(this, input);
this.modifiedAt = input.modifiedAt ? DateAlfresco.parseDate(input.modifiedAt) : undefined;
this.modifiedByUser = input.modifiedByUser ? new UserInfo(input.modifiedByUser) : undefined;
this.createdAt = input.createdAt ? DateAlfresco.parseDate(input.createdAt) : undefined;
this.createdByUser = input.createdByUser ? new UserInfo(input.createdByUser) : undefined;
}
}
}
@@ -0,0 +1,29 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NodeAssignedHold } from './nodeAssignedHold';
export class NodeAssignedHoldEntry {
entry: NodeAssignedHold;
constructor(input?: Partial<NodeAssignedHoldEntry>) {
if (input) {
Object.assign(this, input);
this.entry = input.entry ? new NodeAssignedHold(input.entry) : undefined;
}
}
}
@@ -0,0 +1,34 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Pagination } from '..';
import { NodeAssignedHoldEntry } from './nodeAssignedHoldEntry';
export class NodeAssignedHoldPagingList {
pagination: Pagination;
entries: NodeAssignedHoldEntry[];
constructor(input?: Partial<NodeAssignedHoldPagingList>) {
if (input) {
Object.assign(this, input);
this.pagination = input.pagination ? new Pagination(input.pagination) : undefined;
if (input.entries) {
this.entries = input.entries.map((item) => new NodeAssignedHoldEntry(item));
}
}
}
}
@@ -0,0 +1,29 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NodeAssignedHoldPagingList } from './nodeAssignedHoldPagingList';
export class NodeAssignedHoldPaging {
list?: NodeAssignedHoldPagingList;
constructor(input?: Partial<NodeAssignedHoldPaging>) {
if (input) {
Object.assign(this, input);
this.list = input.list ? new NodeAssignedHoldPagingList(input.list) : undefined;
}
}
}
@@ -71,3 +71,4 @@ export * from './combinedInstructionBody';
export * from './classificationGuide';
export * from './classificationGuides';
export * from './nodeSecurityMarkBody';
export * from './nodeHold';
@@ -0,0 +1,23 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface NodeHold {
id: string;
name: string;
reason?: string;
description?: string;
}