Skip to content

Commit

Permalink
* Removed process-storage related code
Browse files Browse the repository at this point in the history
  • Loading branch information
sivakumar414ram committed Jul 30, 2020
1 parent 15b0282 commit 90f7692
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 124 deletions.
7 changes: 0 additions & 7 deletions docs/process-services-cloud/services/form-cloud.service.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ class MyComponent {
- _formKey:_ `string` - key of the target task
- _version:_ `number` - (Optional) Version of the form
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`FormContent`](../../../lib/process-services-cloud/src/lib/services/form-fields.interfaces.ts)`>` - Form definition
- **getProcessStorageFolderTask**(appName: `string`, taskId: `string`, processInstanceId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessStorageCloudModel`](../../../lib/process-services-cloud/src/lib/form/models/task-variable-cloud.model.ts)`>`<br/>

- _appName:_ `string` -
- _taskId:_ `string` -
- _processInstanceId:_ `string` -
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`ProcessStorageCloudModel`](../../../lib/process-services-cloud/src/lib/form/models/task-variable-cloud.model.ts)`>` -

- **getTask**(appName: `string`, taskId: `string`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`TaskDetailsCloudModel`](../../../lib/process-services-cloud/src/lib/task/start-task/models/task-details-cloud.model.ts)`>`<br/>
Gets details of a task
- _appName:_ `string` - Name of the app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,45 +370,6 @@ describe('FormCloudComponent', () => {
expect(formComponent.getFormByTaskId).toHaveBeenCalledWith(appName, taskId, 1);
});

it('should call the process storage to retrieve the folder with only the taskId', fakeAsync(() => {
spyOn(formCloudService, 'getTaskForm').and.returnValue(of(cloudFormMock));
spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([]));
spyOn(formCloudService, 'getProcessStorageFolderTask')
.and.returnValue(of({ nodeId: '123', path: '/a/path/type', type: 'fakeType' }));
const taskId = '<task id>';
const appName = 'test-app';
formComponent.appName = appName;
formComponent.taskId = taskId;

const change = new SimpleChange(null, appName, true);
formComponent.ngOnChanges({ 'appName': change });
tick();

expect(formCloudService.getProcessStorageFolderTask).toHaveBeenCalledWith(appName, taskId, undefined);
expect(formComponent.form.nodeId).toBe('123');
expect(formComponent.form.contentHost).toBe('/a/path/type');
}));

it('should call the process storage to retrieve the folder with taskId and processInstanceId', fakeAsync(() => {
spyOn(formCloudService, 'getTaskForm').and.returnValue(of(cloudFormMock));
spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([]));
spyOn(formCloudService, 'getProcessStorageFolderTask')
.and.returnValue(of({ nodeId: '123', path: '/a/path/type', type: 'fakeType' }));
const taskId = '<task id>';
const processInstanceId = 'i-am-the-process-instance-id';
const appName = 'test-app';
formComponent.appName = appName;
formComponent.taskId = taskId;
formComponent.processInstanceId = processInstanceId;

const change = new SimpleChange(null, 'new-app-name', true);
formComponent.ngOnChanges({ 'appName': change });
tick();
expect(formCloudService.getProcessStorageFolderTask).toHaveBeenCalledWith(appName, taskId, processInstanceId);
expect(formComponent.form.nodeId).toBe('123');
expect(formComponent.form.contentHost).toBe('/a/path/type');
}));

it('should reload form definition by form id on binding changes', () => {
spyOn(formComponent, 'getFormById').and.stub();
const formId = '123';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,

if (appName && appName.currentValue) {
if (this.taskId) {
this.getFormDefinitionWithFolderTask(this.appName, this.taskId, this.processInstanceId);
this.getFormByTaskId(appName.currentValue, this.taskId, this.appVersion);
} else if (this.formId) {
this.getFormById(appName.currentValue, this.formId, this.appVersion);
}
Expand Down Expand Up @@ -239,31 +239,6 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
);
}

getFormDefinitionWithFolderTask(appName: string, taskId: string, processInstanceId: string) {
this.getFormDefinitionWithFolder(appName, taskId, processInstanceId);
}

async getFormDefinitionWithFolder(appName: string, taskId: string, processInstanceId: string) {
try {
await this.getFormByTaskId(appName, taskId, this.appVersion);

const hasUploadWidget = (<any> this.form).hasUpload;
if (hasUploadWidget) {
try {
const processStorageCloudModel = await this.formCloudService.getProcessStorageFolderTask(appName, taskId, processInstanceId).toPromise();
this.form.nodeId = processStorageCloudModel.nodeId;
this.form.contentHost = processStorageCloudModel.path;
} catch (error) {
this.notificationService.openSnackMessage('The content repo is not configured');
}
}

} catch (error) {
this.notificationService.openSnackMessage('Form service an error occour');
}

}

saveTaskForm() {
if (this.form && this.appName && this.taskId) {
this.formCloudService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent
implements OnInit {

typeId = 'AttachFileCloudWidgetComponent';
rootDirectory = '-my-';
rootNodeId = '-my-';

constructor(
formService: FormService,
Expand Down Expand Up @@ -95,15 +95,15 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent

if (alias && opts && opts.relativePath) {
await this.contentNodeSelectorService.fetchNodeIdFromRelativePath(alias, opts).then((nodeId: string) => {
this.rootDirectory = nodeId;
this.rootNodeId = nodeId;
});
} else {
const errorMessage = this.translationService.instant('ADF_CLOUD_TASK_FORM.ERROR.INVALID_DESTINATION_FOLDER_PATH');
this.notificationService.showError(errorMessage);
}
}
this.contentNodeSelectorService
.openUploadFileDialog(this.rootDirectory, selectedMode, this.isAlfrescoAndLocal())
.openUploadFileDialog(this.rootNodeId, selectedMode, this.isAlfrescoAndLocal())
.subscribe((selections: Node[]) => {
selections.forEach(node => (node['isExternal'] = true));
const selectionWithoutDuplication = this.removeExistingSelection(selections);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,45 +183,6 @@ describe('Form Cloud service', () => {
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[1]).toBe('POST');
done();
});

});

it('should fetch process storage folder with process instance id and task id', (done) => {
oauth2Auth.callCustomApi.and.returnValue(Promise.resolve({
nodeId: 'fake-node-id-really-long',
path: 'path/to/node/id',
type: 'nodeType'
}));

service.getProcessStorageFolderTask(appName, taskId, processInstanceId).subscribe((result) => {
expect(result).toBeDefined();
expect(result).not.toBeNull();
expect(result.nodeId).toBe('fake-node-id-really-long');
expect(result.path).toBe('path/to/node/id');
expect(result.type).toBe('nodeType');
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[0].endsWith(`${appName}/process-storage/v1/folders/${processInstanceId}/${taskId}`)).toBeTruthy();
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[1]).toBe('GET');
done();
});
});

it('should fetch process storage folder with task id only', (done) => {
oauth2Auth.callCustomApi.and.returnValue(Promise.resolve({
nodeId: 'fake-node-id-really-long',
path: 'path/to/node/id',
type: 'nodeType'
}));

service.getProcessStorageFolderTask(appName, taskId, null).subscribe((result) => {
expect(result).toBeDefined();
expect(result).not.toBeNull();
expect(result.nodeId).toBe('fake-node-id-really-long');
expect(result.path).toBe('path/to/node/id');
expect(result.type).toBe('nodeType');
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[0].endsWith(`${appName}/process-storage/v1/folders/${taskId}`)).toBeTruthy();
expect(oauth2Auth.callCustomApi.calls.mostRecent().args[1]).toBe('GET');
done();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,6 @@ export class FormCloudService extends BaseCloudService {
);
}

getProcessStorageFolderTask(appName: string, taskId: string, processInstanceId: string): Observable<ProcessStorageCloudModel> {
const apiUrl = this.buildFolderTask(appName, taskId, processInstanceId);

return this.get(apiUrl).pipe(
map((res: any) => {
return new ProcessStorageCloudModel(res);
})
);
}

/**
* Gets the variables of a task.
* @param appName Name of the app
Expand Down

0 comments on commit 90f7692

Please sign in to comment.