[ADF-1769] Added JSDocs to services (#2937)

* [ADF-1769] Added JSDocs to services

* Removed JSDoc return directives from doc comments
This commit is contained in:
Andy Stark
2018-02-13 22:44:47 +00:00
committed by Eugenio Romano
parent b3955b3f6c
commit 68ded23c9a
10 changed files with 331 additions and 63 deletions

View File

@@ -90,6 +90,12 @@ export class FormService {
return this.apiService.getInstance().activiti.groupsApi;
}
/**
* Parses JSON data to create a corresponding Form model.
* @param json JSON to create the form
* @param data Values for the form fields
* @param readOnly Should the form fields be read-only?
*/
parseForm(json: any, data?: FormValues, readOnly: boolean = false): FormModel {
if (json) {
let form = new FormModel(json, data, readOnly, this);
@@ -108,7 +114,8 @@ export class FormService {
}
/**
* Create a Form with a fields for each metadata properties
* Create a Form with a field for each metadata property.
* @param formName Name of the new form
*/
createFormFromANode(formName: string): Observable<any> {
return Observable.create(observer => {
@@ -129,7 +136,8 @@ export class FormService {
}
/**
* Create a Form
* Create a Form.
* @param formName Name of the new form
*/
createForm(formName: string): Observable<any> {
let dataModel = {
@@ -144,6 +152,11 @@ export class FormService {
);
}
/**
* Saves a form.
* @param formId ID of the form to save
* @param formModel Model data for the form
*/
saveForm(formId: string, formModel: FormDefinitionModel): Observable<any> {
return Observable.fromPromise(
this.editorApi.saveForm(formId, formModel)
@@ -152,7 +165,9 @@ export class FormService {
/**
* @deprecated in 1.7.0, use saveForm API instead
* Add Fileds to A form
* Add Fields to A form
* @param formId ID of the form
* @param formModel Form definition
*/
addFieldsToAForm(formId: string, formModel: FormDefinitionModel): Observable<any> {
this.logService.log('addFieldsToAForm is deprecated in 1.7.0, use saveForm API instead');
@@ -162,7 +177,8 @@ export class FormService {
}
/**
* Search For A Form by name
* Search for a form by name.
* @param name The form name to search for
*/
searchFrom(name: string): Observable<any> {
let opts = {
@@ -179,7 +195,7 @@ export class FormService {
}
/**
* Get All the forms
* Gets all the forms.
*/
getForms(): Observable<any> {
let opts = {
@@ -200,6 +216,10 @@ export class FormService {
.catch(err => this.handleError(err));
}
/**
* Get instance variables for a process.
* @param processInstanceId ID of the target process
*/
getProcessVarablesById(processInstanceId: string): Observable<any[]> {
return Observable.fromPromise(this.processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId))
.map(this.toJson)
@@ -207,7 +227,7 @@ export class FormService {
}
/**
* Get All the Tasks
* Gets all the tasks.
*/
getTasks(): Observable<any> {
return Observable.fromPromise(this.taskApi.listTasks({}))
@@ -216,7 +236,7 @@ export class FormService {
}
/**
* Get Task
* Gets a task.
* @param taskId Task Id
*/
getTask(taskId: string): Observable<any> {
@@ -226,7 +246,7 @@ export class FormService {
}
/**
* Save Task Form
* Save Task Form.
* @param taskId Task Id
* @param formValues Form Values
*/
@@ -275,8 +295,8 @@ export class FormService {
}
/**
* Returns form definition by a given name.
* @param name
* Returns form definition with a given name.
* @param name The form name
*/
getFormDefinitionByName(name: string): Observable<any> {
let opts = {
@@ -301,6 +321,10 @@ export class FormService {
.catch(err => this.handleError(err));
}
/**
* Gets a process instance.
* @param processId ID of the process to get
*/
getProcessIntance(processId: string): Observable<any> {
return Observable.fromPromise(this.processApi.getProcessInstance(processId))
.map(this.toJson)
@@ -318,26 +342,57 @@ export class FormService {
.catch(err => this.handleError(err));
}
/**
* Gets values of fields populated by a REST backend.
* @param taskId Task identifier
* @param field Field identifier
*/
getRestFieldValues(taskId: string, field: string): Observable<any> {
return Observable.fromPromise(this.taskApi.getRestFieldValues(taskId, field)).catch(err => this.handleError(err));
}
/**
* Gets values of fields populated by a REST backend using a process ID.
* @param processDefinitionId Process identifier
* @param field Field identifier
*/
getRestFieldValuesByProcessId(processDefinitionId: string, field: string): Observable<any> {
return Observable.fromPromise(this.processApi.getRestFieldValues(processDefinitionId, field)).catch(err => this.handleError(err));
}
/**
* Gets column values of fields populated by a REST backend using a process ID.
* @param processDefinitionId Process identifier
* @param field Field identifier
* @param column Column identifier
*/
getRestFieldValuesColumnByProcessId(processDefinitionId: string, field: string, column?: string): Observable<any> {
return Observable.fromPromise(this.processApi.getRestTableFieldValues(processDefinitionId, field, column)).catch(err => this.handleError(err));
}
/**
* Gets column values of fields populated by a REST backend.
* @param taskId Task identifier
* @param field Field identifier
* @param column Column identifier
*/
getRestFieldValuesColumn(taskId: string, field: string, column?: string): Observable<any> {
return Observable.fromPromise(this.taskApi.getRestFieldValuesColumn(taskId, field, column)).catch(err => this.handleError(err));
}
/**
* Returns a URL for the profile picture of a user.
* @param userId ID of the target user
*/
getUserProfileImageApi(userId: number): string {
return this.apiService.getInstance().activiti.userApi.getUserProfilePictureUrl(userId);
}
/**
* Gets a list of workflow users.
* @param filter Filter to select specific users
* @param groupId Group ID for the search
*/
getWorkflowUsers(filter: string, groupId?: string): Observable<UserProcessModel[]> {
let option: any = {filter: filter};
if (groupId) {
@@ -354,6 +409,11 @@ export class FormService {
.catch(err => this.handleError(err));
}
/**
* Gets a list of groups in a workflow.
* @param filter Filter to select specific groups
* @param groupId Group ID for the search
*/
getWorkflowGroups(filter: string, groupId?: string): Observable<GroupModel[]> {
let option: any = {filter: filter};
if (groupId) {
@@ -364,6 +424,10 @@ export class FormService {
.catch(err => this.handleError(err));
}
/**
* Gets the ID of a form.
* @param res Object representing a form
*/
getFormId(res: any): string {
let result = null;
@@ -374,6 +438,10 @@ export class FormService {
return result;
}
/**
* Creates a JSON representation of form data.
* @param res Object representing form data
*/
toJson(res: any) {
if (res) {
return res || {};
@@ -381,6 +449,10 @@ export class FormService {
return {};
}
/**
* Creates a JSON array representation of form data.
* @param res Object representing form data
*/
toJsonArray(res: any) {
if (res) {
return res.data || [];
@@ -388,6 +460,10 @@ export class FormService {
return [];
}
/**
* Reports an error message.
* @param error Data object with optional `message` and `status` fields for the error
*/
handleError(error: any): Observable<any> {
let errMsg = FormService.UNKNOWN_ERROR_MESSAGE;
if (error) {