cancel
Showing results for 
Search instead for 
Did you mean: 

How to Call APS API from ADF ?

dharmraj
Confirmed Champ
Confirmed Champ

I have  import this api 

import {AlfrescoApiService,} from '@alfresco/adf-core'
 and  i want to filter user and group of APS 
 
 so In APS Api explorer we have  group filter and user filter api 
1. /activiti-app/api/enterprise/groups?filter=' + data
2. '/activiti-app/api/enterprise/users?filter=' + data
But  I don't want to call direct api like  that .So i want to use using ADF 
4 REPLIES 4

abbask01
Star Collaborator
Star Collaborator

There's already a people search component

You can look into its source if you want to customize it

Regards,
Abbas

I need API call from component level so  I need ADF service to call User filter and Group Filter

Scenario for process named 'taskAssignProcess':

  • Task with id 'mngTask' is being assigned to group of manager
  • Manager that claims task becomes assignee of the 'mngTask'
  • Based on assignee 'mngTask' referenced form needs to have component/item/stencil that contains people from group 'assigneeGroup'. assigneeGroup needs to be  group for which manager is assignee( manager that claimed 'mngTask')
  • Component that contains or is restricted to 'assigneeGroup' can be for example dropdown Component called 'dropdownuser'. Based on selected user from 'dropdownuser' component or group of people next task called 'employeeTask' is being assigned to the selected user.

Tried to use alfrescoApiService:AlfrescoApiService methods (alfrescoApiService.getInstance().activiti.adminGroupsApi, alfrescoApiService.getInstance().activiti.groupsApi..) in order to obtain necessary users and groups according to scenario, but problem is that all involed users need to have high level capability such as Administration of tenant of this group  in order this scenario works using alfrescoApiService:AlfrescoApiService methods.

In code bellow I am getting groups using AlfrescoApiService in TaskDetails Component.. and passing it to custom service called dropDownService.

this.taskListService.getTaskDetails(taskId).subscribe(
                (res: TaskDetailsModel) =>  
this.taskDetails = res; this.dropDownService.setTaskAssignee(this.taskDetails.assignee.id);this.alfApi.getInstance().activiti.adminGroupsApi.getGroup(3003, opts2)
.then(grupaMngri => this.dropDownService.setMngGroup(grupaMngri["groups"]); this.alfApi.getInstance().activiti.adminGroupsApi.getGroup(3003, opts2)
.then(grupaMngri => this.dropDownService.setMngGroup(grupaMngri["groups"]);
); });

In dropdown user custom ADF component that extends Widget Component I am getting groups and assignee id from dropDownService and using it  to fill dropdown user list according to scenario above

this.taskAssigneeId=this.dropDownService.getTaskAssignee();  
 this.dropDownService.taskAssignIdUpdate.subscribe(
      ((id:number)=> this.taskAssigneeId=id)
    );    
    let opts = { includeAllUsers: true };
    this.mngGroups = this.dropDownService.getMngGroups();     
    this.dropDownService.mngsUpdated.subscribe(
      (dDMngs: TempGroup[]) => this.mngGroups = dDMngs);
    this.mngGroups.forEach(group => {
      this.alfApi.getInstance().activiti.adminGroupsApi.getGroup(group["id"], opts).then(grupa => {
        if (grupa["manager"]["id"] === this.taskAssigneeId) {
          grupa["users"].forEach(user => {
            let tempUser = new TempUser(user["id"], user["email"]);
            this.dropDownUsers.push(tempUser);
          });
        };       

REST

In order to use rest calls Tried to use  AuthenticationService using AuthenticationService.getToken() in order to obtain token in certain ADF components or services but received token is being null.  Even if I could get token probably  rest call from …/activiti-app/api-explorer.html#/ wouldn't work if user in process that is using ADF does not have tenant capabilities.

So.. question still remains: How to Call APS API from ADF ?

Scenario for process named 'taskAssignProcess':

  • Task with id 'mngTask' is being assigned to group of manager
  • Manager that claims task becomes assignee of the 'mngTask'
  • Based on assignee 'mngTask' referenced form needs to have component/item/stencil that contains people from group 'assigneeGroup'. assigneeGroup needs to be  group for which manager is assignee( manager that claimed 'mngTask')
  • Component that contains or is restricted to 'assigneeGroup' can be for example dropdown Component called 'dropdownuser'. Based on selected user from 'dropdownuser' component or group of people next task called 'employeeTask' is being assigned to the selected user.

Tried to use alfrescoApiService:AlfrescoApiService methods (alfrescoApiService.getInstance().activiti.adminGroupsApi, alfrescoApiService.getInstance().activiti.groupsApi..) in order to obtain necessary users and groups according to scenario, but problem is that all involed users need to have high level capability such as Administration of tenant of this group  in order this scenario works using alfrescoApiService:AlfrescoApiService methods.

In code bellow I am getting groups using AlfrescoApiService in TaskDetails Component.. and passing it to custom service called dropDownService.

this.taskListService.getTaskDetails(taskId).subscribe(
                (res: TaskDetailsModel) =>  
this.taskDetails = res; this.dropDownService.setTaskAssignee(this.taskDetails.assignee.id);this.alfApi.getInstance().activiti.adminGroupsApi.getGroup(3003, opts2)
.then(grupaMngri => this.dropDownService.setMngGroup(grupaMngri["groups"]); this.alfApi.getInstance().activiti.adminGroupsApi.getGroup(3003, opts2)
.then(grupaMngri => this.dropDownService.setMngGroup(grupaMngri["groups"]);
); });

In dropdown user custom ADF component that extends Widget Component I am getting groups and assignee id from dropDownService and using it  to fill dropdown user list according to scenario above

this.taskAssigneeId=this.dropDownService.getTaskAssignee();  
 this.dropDownService.taskAssignIdUpdate.subscribe(
      ((id:number)=> this.taskAssigneeId=id)
    );    
    let opts = { includeAllUsers: true };
    this.mngGroups = this.dropDownService.getMngGroups();     
    this.dropDownService.mngsUpdated.subscribe(
      (dDMngs: TempGroup[]) => this.mngGroups = dDMngs);
    this.mngGroups.forEach(group => {
      this.alfApi.getInstance().activiti.adminGroupsApi.getGroup(group["id"], opts).then(grupa => {
        if (grupa["manager"]["id"] === this.taskAssigneeId) {
          grupa["users"].forEach(user => {
            let tempUser = new TempUser(user["id"], user["email"]);
            this.dropDownUsers.push(tempUser);
          });
        };       

REST

In order to use rest calls Tried to use  AuthenticationService using AuthenticationService.getToken() in order to obtain token in certain ADF components or services but received token is being null.  Even if I could get token probably  rest call from …/activiti-app/api-explorer.html#/ wouldn't work if user in process that is using ADF does not have tenant capabilities.

So.. question still remains: How to Call APS API from ADF ?