69305: Refactor workflow-actions to be resolved as HAL links

This commit is contained in:
Kristof De Langhe
2020-03-04 16:22:05 +01:00
parent 496bedfe2e
commit c087b8859f
10 changed files with 40 additions and 19 deletions

View File

@@ -13,6 +13,8 @@ import { HALLink } from '../../shared/hal-link.model';
import { WorkflowItem } from '../../submission/models/workflowitem.model'; import { WorkflowItem } from '../../submission/models/workflowitem.model';
import { TASK_OBJECT } from './task-object.resource-type'; import { TASK_OBJECT } from './task-object.resource-type';
import { WORKFLOWITEM } from '../../eperson/models/workflowitem.resource-type'; import { WORKFLOWITEM } from '../../eperson/models/workflowitem.resource-type';
import { WORKFLOW_ACTION } from './workflow-action-object.resource-type';
import { WorkflowAction } from './workflow-action-object.model';
/** /**
* An abstract model class for a TaskObject. * An abstract model class for a TaskObject.
@@ -34,12 +36,6 @@ export class TaskObject extends DSpaceObject implements CacheableObject {
@autoserialize @autoserialize
step: string; step: string;
/**
* The task action type
*/
@autoserialize
action: string;
/** /**
* The {@link HALLink}s for this TaskObject * The {@link HALLink}s for this TaskObject
*/ */
@@ -49,6 +45,7 @@ export class TaskObject extends DSpaceObject implements CacheableObject {
owner: HALLink; owner: HALLink;
group: HALLink; group: HALLink;
workflowitem: HALLink; workflowitem: HALLink;
action: HALLink;
}; };
/** /**
@@ -72,4 +69,11 @@ export class TaskObject extends DSpaceObject implements CacheableObject {
@link(WORKFLOWITEM) @link(WORKFLOWITEM)
workflowitem?: Observable<RemoteData<WorkflowItem>> | WorkflowItem; workflowitem?: Observable<RemoteData<WorkflowItem>> | WorkflowItem;
/**
* The task action type
* Will be undefined unless the group {@link HALLink} has been resolved.
*/
@link(WORKFLOW_ACTION, false, 'action')
action: Observable<RemoteData<WorkflowAction>>;
} }

View File

@@ -96,7 +96,7 @@ export class ClaimedTaskActionsComponent extends MyDSpaceActionsComponent<Claime
* @param object * @param object
*/ */
initAction(object: ClaimedTask) { initAction(object: ClaimedTask) {
this.actionRD$ = this.workflowActionService.findById(object.action); this.actionRD$ = object.action;
} }
} }

View File

@@ -84,7 +84,12 @@ describe('ClaimedTaskSearchResultDetailElementComponent', () => {
it('should init workflowitem properly', (done) => { it('should init workflowitem properly', (done) => {
component.workflowitemRD$.subscribe((workflowitemRD) => { component.workflowitemRD$.subscribe((workflowitemRD) => {
expect(linkService.resolveLink).toHaveBeenCalled(); // Make sure the necessary links are being resolved
expect(linkService.resolveLinks).toHaveBeenCalledWith(
component.dso,
jasmine.objectContaining({ name: 'workflowitem' }),
jasmine.objectContaining({ name: 'action' })
);
expect(workflowitemRD.payload).toEqual(workflowitem); expect(workflowitemRD.payload).toEqual(workflowitem);
done(); done();
}); });

View File

@@ -49,12 +49,12 @@ export class ClaimedTaskSearchResultDetailElementComponent extends SearchResultD
*/ */
ngOnInit() { ngOnInit() {
super.ngOnInit(); super.ngOnInit();
this.linkService.resolveLink(this.dso, followLink( this.linkService.resolveLinks(this.dso, followLink(
'workflowitem', 'workflowitem',
null, null,
followLink('item', null, followLink('bundles')), followLink('item', null, followLink('bundles')),
followLink('submitter') followLink('submitter')
)); ), followLink('action'));
this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>; this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>;
} }

View File

@@ -86,7 +86,11 @@ describe('PoolSearchResultDetailElementComponent', () => {
it('should init workflowitem properly', (done) => { it('should init workflowitem properly', (done) => {
component.workflowitemRD$.subscribe((workflowitemRD) => { component.workflowitemRD$.subscribe((workflowitemRD) => {
expect(linkService.resolveLink).toHaveBeenCalled(); expect(linkService.resolveLinks).toHaveBeenCalledWith(
component.dso,
jasmine.objectContaining({ name: 'workflowitem' }),
jasmine.objectContaining({ name: 'action' })
);
expect(workflowitemRD.payload).toEqual(workflowitem); expect(workflowitemRD.payload).toEqual(workflowitem);
done(); done();
}); });

View File

@@ -48,12 +48,12 @@ export class PoolSearchResultDetailElementComponent extends SearchResultDetailEl
*/ */
ngOnInit() { ngOnInit() {
super.ngOnInit(); super.ngOnInit();
this.linkService.resolveLink(this.dso, followLink( this.linkService.resolveLinks(this.dso, followLink(
'workflowitem', 'workflowitem',
null, null,
followLink('item', null, followLink('bundles')), followLink('item', null, followLink('bundles')),
followLink('submitter') followLink('submitter')
)); ), followLink('action'));
this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>; this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>;
} }

View File

@@ -86,7 +86,11 @@ describe('ClaimedSearchResultListElementComponent', () => {
it('should init workflowitem properly', (done) => { it('should init workflowitem properly', (done) => {
component.workflowitemRD$.subscribe((workflowitemRD) => { component.workflowitemRD$.subscribe((workflowitemRD) => {
expect(linkService.resolveLink).toHaveBeenCalled(); expect(linkService.resolveLinks).toHaveBeenCalledWith(
component.dso,
jasmine.objectContaining({ name: 'workflowitem' }),
jasmine.objectContaining({ name: 'action' })
);
expect(workflowitemRD.payload).toEqual(workflowitem); expect(workflowitemRD.payload).toEqual(workflowitem);
done(); done();
}); });

View File

@@ -55,12 +55,12 @@ export class ClaimedSearchResultListElementComponent extends SearchResultListEle
*/ */
ngOnInit() { ngOnInit() {
super.ngOnInit(); super.ngOnInit();
this.linkService.resolveLink(this.dso, followLink( this.linkService.resolveLinks(this.dso, followLink(
'workflowitem', 'workflowitem',
null, null,
followLink('item'), followLink('item'),
followLink('submitter') followLink('submitter')
)); ), followLink('action'));
this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>; this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>;
} }
} }

View File

@@ -86,7 +86,11 @@ describe('PoolSearchResultListElementComponent', () => {
it('should init workflowitem properly', (done) => { it('should init workflowitem properly', (done) => {
component.workflowitemRD$.subscribe((workflowitemRD) => { component.workflowitemRD$.subscribe((workflowitemRD) => {
expect(linkService.resolveLink).toHaveBeenCalled(); expect(linkService.resolveLinks).toHaveBeenCalledWith(
component.dso,
jasmine.objectContaining({ name: 'workflowitem' }),
jasmine.objectContaining({ name: 'action' })
);
expect(workflowitemRD.payload).toEqual(workflowitem); expect(workflowitemRD.payload).toEqual(workflowitem);
done(); done();
}); });

View File

@@ -58,12 +58,12 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
*/ */
ngOnInit() { ngOnInit() {
super.ngOnInit(); super.ngOnInit();
this.linkService.resolveLink(this.dso, followLink( this.linkService.resolveLinks(this.dso, followLink(
'workflowitem', 'workflowitem',
null, null,
followLink('item'), followLink('item'),
followLink('submitter') followLink('submitter')
)); ), followLink('action'));
this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>; this.workflowitemRD$ = this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>;
} }
} }