mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge branch 'master' into w2p-63825_UI-language-cookie
This commit is contained in:
@@ -13,7 +13,7 @@ module.exports = {
|
||||
host: 'dspace7.4science.cloud',
|
||||
port: 443,
|
||||
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
|
||||
nameSpace: '/dspace-spring-rest/api'
|
||||
nameSpace: '/server/api'
|
||||
},
|
||||
// Caching settings
|
||||
cache: {
|
||||
|
@@ -7,7 +7,7 @@ import {
|
||||
} from '../../../../shared/items/item-type-decorator';
|
||||
import { ItemComponent } from '../shared/item.component';
|
||||
import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model';
|
||||
import { filterRelationsByTypeLabel, relationsToItems } from '../shared/item-relationships-utils';
|
||||
import { getRelatedItemsByTypeLabel } from '../shared/item-relationships-utils';
|
||||
|
||||
@rendersItemType('Publication', ItemViewMode.Full)
|
||||
@rendersItemType(DEFAULT_ITEM_TYPE, ItemViewMode.Full)
|
||||
@@ -46,18 +46,15 @@ export class PublicationComponent extends ItemComponent implements OnInit {
|
||||
this.authors$ = this.buildRepresentations('Person', 'dc.contributor.author');
|
||||
|
||||
this.projects$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isProjectOfPublication'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfPublication')
|
||||
);
|
||||
|
||||
this.orgUnits$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isOrgUnitOfPublication'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfPublication')
|
||||
);
|
||||
|
||||
this.journalIssues$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isJournalIssueOfPublication'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isJournalIssueOfPublication')
|
||||
);
|
||||
|
||||
}
|
||||
|
@@ -2,16 +2,15 @@ import { ItemMetadataRepresentation } from '../../../../core/shared/metadata-rep
|
||||
import { MetadataRepresentation } from '../../../../core/shared/metadata-representation/metadata-representation.model';
|
||||
import { MetadatumRepresentation } from '../../../../core/shared/metadata-representation/metadatum/metadatum-representation.model';
|
||||
import { MetadataValue } from '../../../../core/shared/metadata.models';
|
||||
import { getSucceededRemoteData } from '../../../../core/shared/operators';
|
||||
import { hasValue } from '../../../../shared/empty.util';
|
||||
import { getRemoteDataPayload, getSucceededRemoteData } from '../../../../core/shared/operators';
|
||||
import { hasNoValue, hasValue } from '../../../../shared/empty.util';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { Relationship } from '../../../../core/shared/item-relationships/relationship.model';
|
||||
import { RelationshipType } from '../../../../core/shared/item-relationships/relationship-type.model';
|
||||
import { distinctUntilChanged, flatMap, map } from 'rxjs/operators';
|
||||
import { distinctUntilChanged, flatMap, map, switchMap } from 'rxjs/operators';
|
||||
import { of as observableOf, zip as observableZip, combineLatest as observableCombineLatest } from 'rxjs';
|
||||
import { ItemDataService } from '../../../../core/data/item-data.service';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
|
||||
/**
|
||||
* Operator for comparing arrays using a mapping function
|
||||
@@ -43,23 +42,36 @@ export const compareArraysUsingIds = <T extends { id: string }>() =>
|
||||
/**
|
||||
* Fetch the relationships which match the type label given
|
||||
* @param {string} label Type label
|
||||
* @param thisId The item's id of which the relations belong to
|
||||
* @returns {(source: Observable<[Relationship[] , RelationshipType[]]>) => Observable<Relationship[]>}
|
||||
*/
|
||||
export const filterRelationsByTypeLabel = (label: string) =>
|
||||
export const filterRelationsByTypeLabel = (label: string, thisId?: string) =>
|
||||
(source: Observable<[Relationship[], RelationshipType[]]>): Observable<Relationship[]> =>
|
||||
source.pipe(
|
||||
map(([relsCurrentPage, relTypesCurrentPage]) =>
|
||||
relsCurrentPage.filter((rel: Relationship, idx: number) =>
|
||||
hasValue(relTypesCurrentPage[idx]) && (relTypesCurrentPage[idx].leftLabel === label ||
|
||||
relTypesCurrentPage[idx].rightLabel === label)
|
||||
)
|
||||
),
|
||||
switchMap(([relsCurrentPage, relTypesCurrentPage]) => {
|
||||
const relatedItems$ = observableZip(...relsCurrentPage.map((rel: Relationship) =>
|
||||
observableCombineLatest(
|
||||
rel.leftItem.pipe(getSucceededRemoteData(), getRemoteDataPayload()),
|
||||
rel.rightItem.pipe(getSucceededRemoteData(), getRemoteDataPayload()))
|
||||
)
|
||||
);
|
||||
return relatedItems$.pipe(
|
||||
map((arr) => relsCurrentPage.filter((rel: Relationship, idx: number) =>
|
||||
hasValue(relTypesCurrentPage[idx]) && (
|
||||
(hasNoValue(thisId) && (relTypesCurrentPage[idx].leftLabel === label ||
|
||||
relTypesCurrentPage[idx].rightLabel === label)) ||
|
||||
(thisId === arr[idx][0].id && relTypesCurrentPage[idx].leftLabel === label) ||
|
||||
(thisId === arr[idx][1].id && relTypesCurrentPage[idx].rightLabel === label)
|
||||
)
|
||||
))
|
||||
);
|
||||
}),
|
||||
distinctUntilChanged(compareArraysUsingIds())
|
||||
);
|
||||
|
||||
/**
|
||||
* Operator for turning a list of relationships into a list of the relevant items
|
||||
* @param {string} thisId The item's id of which the relations belong to
|
||||
* @param {string} thisId The item's id of which the relations belong to
|
||||
* @returns {(source: Observable<Relationship[]>) => Observable<Item[]>}
|
||||
*/
|
||||
export const relationsToItems = (thisId: string) =>
|
||||
@@ -79,10 +91,25 @@ export const relationsToItems = (thisId: string) =>
|
||||
} else if (rightItem.payload.id === thisId) {
|
||||
return leftItem.payload;
|
||||
}
|
||||
})),
|
||||
})
|
||||
.filter((item: Item) => hasValue(item))
|
||||
),
|
||||
distinctUntilChanged(compareArraysUsingIds()),
|
||||
);
|
||||
|
||||
/**
|
||||
* Operator for turning a list of relationships and their relationship-types into a list of relevant items by relationship label
|
||||
* @param thisId The item's id of which the relations belong to
|
||||
* @param label The label of the relationship-type to filter on
|
||||
* @param side Filter only on one side of the relationship (for example: child-parent relationships)
|
||||
*/
|
||||
export const getRelatedItemsByTypeLabel = (thisId: string, label: string) =>
|
||||
(source: Observable<[Relationship[], RelationshipType[]]>): Observable<Item[]> =>
|
||||
source.pipe(
|
||||
filterRelationsByTypeLabel(label, thisId),
|
||||
relationsToItems(thisId)
|
||||
);
|
||||
|
||||
/**
|
||||
* Operator for turning a list of relationships into a list of metadatarepresentations given the original metadata
|
||||
* @param parentId The id of the parent item
|
||||
|
@@ -104,7 +104,9 @@ export function containsFieldInput(fields: DebugElement[], metadataKey: string):
|
||||
export function createRelationshipsObservable() {
|
||||
return observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), [
|
||||
Object.assign(new Relationship(), {
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, null, new RelationshipType()))
|
||||
relationshipType: observableOf(new RemoteData(false, false, true, null, new RelationshipType())),
|
||||
leftItem: observableOf(new RemoteData(false, false, true, null, new Item())),
|
||||
rightItem: observableOf(new RemoteData(false, false, true, null, new Item()))
|
||||
})
|
||||
])));
|
||||
}
|
||||
|
@@ -60,6 +60,7 @@ import { HALEndpointService } from './shared/hal-endpoint.service';
|
||||
import { FacetValueResponseParsingService } from './data/facet-value-response-parsing.service';
|
||||
import { FacetValueMapResponseParsingService } from './data/facet-value-map-response-parsing.service';
|
||||
import { FacetConfigResponseParsingService } from './data/facet-config-response-parsing.service';
|
||||
import { ResourcePolicyService } from './data/resource-policy.service';
|
||||
import { RegistryService } from './registry/registry.service';
|
||||
import { RegistryMetadataschemasResponseParsingService } from './data/registry-metadataschemas-response-parsing.service';
|
||||
import { RegistryMetadatafieldsResponseParsingService } from './data/registry-metadatafields-response-parsing.service';
|
||||
@@ -125,6 +126,7 @@ const PROVIDERS = [
|
||||
MetadataService,
|
||||
ObjectCacheService,
|
||||
PaginationComponentOptions,
|
||||
ResourcePolicyService,
|
||||
RegistryService,
|
||||
NormalizedObjectBuildService,
|
||||
RemoteDataBuildService,
|
||||
|
@@ -13,15 +13,38 @@ import { MetadataSchema } from '../metadata/metadataschema.model';
|
||||
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { ChangeAnalyzer } from './change-analyzer';
|
||||
import { DefaultChangeAnalyzer } from './default-change-analyzer.service';
|
||||
|
||||
/* tslint:disable:max-classes-per-file */
|
||||
class DataServiceImpl extends DataService<MetadataSchema> {
|
||||
protected linkPath = 'metadataschemas';
|
||||
protected forceBypassCache = false;
|
||||
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected dataBuildService: NormalizedObjectBuildService,
|
||||
protected store: Store<CoreState>,
|
||||
protected objectCache: ObjectCacheService,
|
||||
protected halService: HALEndpointService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: ChangeAnalyzer<MetadataSchema>) {
|
||||
super();
|
||||
}
|
||||
|
||||
getBrowseEndpoint(options: FindAllOptions = {}, linkPath: string = this.linkPath): Observable<string> {
|
||||
return this.halService.getEndpoint(linkPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A service responsible for fetching/sending data from/to the REST API on the metadataschemas endpoint
|
||||
*/
|
||||
@Injectable()
|
||||
export class MetadataSchemaDataService extends DataService<MetadataSchema> {
|
||||
protected linkPath = 'metadataschemas';
|
||||
protected forceBypassCache = false;
|
||||
export class MetadataSchemaDataService {
|
||||
private dataService: DataServiceImpl;
|
||||
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
@@ -33,17 +56,6 @@ export class MetadataSchemaDataService extends DataService<MetadataSchema> {
|
||||
protected dataBuildService: NormalizedObjectBuildService,
|
||||
protected http: HttpClient,
|
||||
protected notificationsService: NotificationsService) {
|
||||
super();
|
||||
this.dataService = new DataServiceImpl(requestService, rdbService, dataBuildService, null, objectCache, halService, notificationsService, http, comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the endpoint for browsing metadataschemas
|
||||
* @param {FindAllOptions} options
|
||||
* @returns {Observable<string>}
|
||||
*/
|
||||
public getBrowseEndpoint(options: FindAllOptions = {}, linkPath: string = this.linkPath): Observable<string> {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
77
src/app/core/data/resource-policy.service.spec.ts
Normal file
77
src/app/core/data/resource-policy.service.spec.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { cold, getTestScheduler } from 'jasmine-marbles';
|
||||
import { TestScheduler } from 'rxjs/testing';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { ResourcePolicy } from '../shared/resource-policy.model';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { GetRequest } from './request.models';
|
||||
import { RequestService } from './request.service';
|
||||
import { ResourcePolicyService } from './resource-policy.service';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
|
||||
|
||||
describe('ResourcePolicyService', () => {
|
||||
let scheduler: TestScheduler;
|
||||
let service: ResourcePolicyService;
|
||||
let requestService: RequestService;
|
||||
let rdbService: RemoteDataBuildService;
|
||||
let objectCache: ObjectCacheService;
|
||||
const testObject = {
|
||||
uuid: '664184ee-b254-45e8-970d-220e5ccc060b'
|
||||
} as ResourcePolicy;
|
||||
const requestURL = `https://rest.api/rest/api/resourcepolicies/${testObject.uuid}`;
|
||||
const requestUUID = '8b3c613a-5a4b-438b-9686-be1d5b4a1c5a';
|
||||
|
||||
beforeEach(() => {
|
||||
scheduler = getTestScheduler();
|
||||
|
||||
requestService = jasmine.createSpyObj('requestService', {
|
||||
generateRequestId: requestUUID,
|
||||
configure: true
|
||||
});
|
||||
rdbService = jasmine.createSpyObj('rdbService', {
|
||||
buildSingle: cold('a', {
|
||||
a: {
|
||||
payload: testObject
|
||||
}
|
||||
})
|
||||
});
|
||||
objectCache = {} as ObjectCacheService;
|
||||
const halService = {} as HALEndpointService;
|
||||
const notificationsService = {} as NotificationsService;
|
||||
const http = {} as HttpClient;
|
||||
const comparator = {} as any;
|
||||
const dataBuildService = {} as NormalizedObjectBuildService;
|
||||
|
||||
service = new ResourcePolicyService(
|
||||
requestService,
|
||||
rdbService,
|
||||
dataBuildService,
|
||||
objectCache,
|
||||
halService,
|
||||
notificationsService,
|
||||
http,
|
||||
comparator
|
||||
)
|
||||
});
|
||||
|
||||
describe('findByHref', () => {
|
||||
it('should configure the proper GetRequest', () => {
|
||||
scheduler.schedule(() => service.findByHref(requestURL));
|
||||
scheduler.flush();
|
||||
|
||||
expect(requestService.configure).toHaveBeenCalledWith(new GetRequest(requestUUID, requestURL, null), false);
|
||||
});
|
||||
|
||||
it('should return a RemoteData<ResourcePolicy> for the object with the given URL', () => {
|
||||
const result = service.findByHref(requestURL);
|
||||
const expected = cold('a', {
|
||||
a: {
|
||||
payload: testObject
|
||||
}
|
||||
});
|
||||
expect(result).toBeObservable(expected);
|
||||
});
|
||||
});
|
||||
});
|
67
src/app/core/data/resource-policy.service.ts
Normal file
67
src/app/core/data/resource-policy.service.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { DataService } from '../data/data.service';
|
||||
import { RequestService } from '../data/request.service';
|
||||
import { FindAllOptions } from '../data/request.models';
|
||||
import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { ResourcePolicy } from '../shared/resource-policy.model';
|
||||
import { RemoteData } from '../data/remote-data';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { CoreState } from '../core.reducers';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
|
||||
import { ChangeAnalyzer } from './change-analyzer';
|
||||
import { DefaultChangeAnalyzer } from '../data/default-change-analyzer.service';
|
||||
import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service';
|
||||
|
||||
/* tslint:disable:max-classes-per-file */
|
||||
class DataServiceImpl extends DataService<ResourcePolicy> {
|
||||
protected linkPath = 'resourcepolicies';
|
||||
protected forceBypassCache = false;
|
||||
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected dataBuildService: NormalizedObjectBuildService,
|
||||
protected store: Store<CoreState>,
|
||||
protected objectCache: ObjectCacheService,
|
||||
protected halService: HALEndpointService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: ChangeAnalyzer<ResourcePolicy>) {
|
||||
super();
|
||||
}
|
||||
|
||||
getBrowseEndpoint(options: FindAllOptions = {}, linkPath: string = this.linkPath): Observable<string> {
|
||||
return this.halService.getEndpoint(linkPath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A service responsible for fetching/sending data from/to the REST API on the resourcepolicies endpoint
|
||||
*/
|
||||
@Injectable()
|
||||
export class ResourcePolicyService {
|
||||
private dataService: DataServiceImpl;
|
||||
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected dataBuildService: NormalizedObjectBuildService,
|
||||
protected objectCache: ObjectCacheService,
|
||||
protected halService: HALEndpointService,
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: DefaultChangeAnalyzer<ResourcePolicy>) {
|
||||
this.dataService = new DataServiceImpl(requestService, rdbService, dataBuildService, null, objectCache, halService, notificationsService, http, comparator);
|
||||
}
|
||||
|
||||
findByHref(href: string, options?: HttpOptions): Observable<RemoteData<ResourcePolicy>> {
|
||||
return this.dataService.findByHref(href, options);
|
||||
}
|
||||
}
|
@@ -4,10 +4,7 @@ import { Item } from '../../../../core/shared/item.model';
|
||||
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||
import { isNotEmpty } from '../../../../shared/empty.util';
|
||||
import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component';
|
||||
import {
|
||||
filterRelationsByTypeLabel,
|
||||
relationsToItems
|
||||
} from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
|
||||
@rendersItemType('JournalIssue', ItemViewMode.Full)
|
||||
@Component({
|
||||
@@ -34,12 +31,10 @@ export class JournalIssueComponent extends ItemComponent {
|
||||
|
||||
if (isNotEmpty(this.resolvedRelsAndTypes$)) {
|
||||
this.volumes$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isJournalVolumeOfIssue'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isJournalVolumeOfIssue')
|
||||
);
|
||||
this.publications$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isPublicationOfJournalIssue'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfJournalIssue')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -4,10 +4,7 @@ import { Item } from '../../../../core/shared/item.model';
|
||||
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||
import { isNotEmpty } from '../../../../shared/empty.util';
|
||||
import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component';
|
||||
import {
|
||||
filterRelationsByTypeLabel,
|
||||
relationsToItems
|
||||
} from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
|
||||
@rendersItemType('JournalVolume', ItemViewMode.Full)
|
||||
@Component({
|
||||
@@ -34,12 +31,10 @@ export class JournalVolumeComponent extends ItemComponent {
|
||||
|
||||
if (isNotEmpty(this.resolvedRelsAndTypes$)) {
|
||||
this.journals$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isJournalOfVolume'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isJournalOfVolume')
|
||||
);
|
||||
this.issues$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isIssueOfJournalVolume'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isIssueOfJournalVolume')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -4,10 +4,7 @@ import { Item } from '../../../../core/shared/item.model';
|
||||
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||
import { isNotEmpty } from '../../../../shared/empty.util';
|
||||
import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component';
|
||||
import {
|
||||
filterRelationsByTypeLabel,
|
||||
relationsToItems
|
||||
} from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
|
||||
@rendersItemType('Journal', ItemViewMode.Full)
|
||||
@Component({
|
||||
@@ -29,8 +26,7 @@ export class JournalComponent extends ItemComponent {
|
||||
|
||||
if (isNotEmpty(this.resolvedRelsAndTypes$)) {
|
||||
this.volumes$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isVolumeOfJournal'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isVolumeOfJournal')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -4,10 +4,7 @@ import { Item } from '../../../../core/shared/item.model';
|
||||
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||
import { isNotEmpty } from '../../../../shared/empty.util';
|
||||
import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component';
|
||||
import {
|
||||
filterRelationsByTypeLabel,
|
||||
relationsToItems
|
||||
} from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
|
||||
@rendersItemType('OrgUnit', ItemViewMode.Full)
|
||||
@Component({
|
||||
@@ -39,18 +36,15 @@ export class OrgunitComponent extends ItemComponent implements OnInit {
|
||||
|
||||
if (isNotEmpty(this.resolvedRelsAndTypes$)) {
|
||||
this.people$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isPersonOfOrgUnit'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isPersonOfOrgUnit')
|
||||
);
|
||||
|
||||
this.projects$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isProjectOfOrgUnit'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfOrgUnit')
|
||||
);
|
||||
|
||||
this.publications$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isPublicationOfOrgUnit'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfOrgUnit')
|
||||
);
|
||||
}
|
||||
}}
|
||||
|
@@ -6,10 +6,7 @@ import { ITEM } from '../../../../shared/items/switcher/item-type-switcher.compo
|
||||
import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service';
|
||||
import { isNotEmpty } from '../../../../shared/empty.util';
|
||||
import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component';
|
||||
import {
|
||||
filterRelationsByTypeLabel,
|
||||
relationsToItems
|
||||
} from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
|
||||
@rendersItemType('Person', ItemViewMode.Full)
|
||||
@Component({
|
||||
@@ -57,18 +54,15 @@ export class PersonComponent extends ItemComponent {
|
||||
|
||||
if (isNotEmpty(this.resolvedRelsAndTypes$)) {
|
||||
this.publications$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isPublicationOfAuthor'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfAuthor')
|
||||
);
|
||||
|
||||
this.projects$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isProjectOfPerson'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isProjectOfPerson')
|
||||
);
|
||||
|
||||
this.orgUnits$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isOrgUnitOfPerson'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfPerson')
|
||||
);
|
||||
|
||||
this.fixedFilterQuery = this.fixedFilterService.getQueryByRelations('isAuthorOfPublication', this.item.id);
|
||||
|
@@ -5,10 +5,7 @@ import { MetadataRepresentation } from '../../../../core/shared/metadata-represe
|
||||
import { ItemViewMode, rendersItemType } from '../../../../shared/items/item-type-decorator';
|
||||
import { isNotEmpty } from '../../../../shared/empty.util';
|
||||
import { ItemComponent } from '../../../../+item-page/simple/item-types/shared/item.component';
|
||||
import {
|
||||
filterRelationsByTypeLabel,
|
||||
relationsToItems
|
||||
} from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
import { getRelatedItemsByTypeLabel } from '../../../../+item-page/simple/item-types/shared/item-relationships-utils';
|
||||
|
||||
@rendersItemType('Project', ItemViewMode.Full)
|
||||
@Component({
|
||||
@@ -47,18 +44,15 @@ export class ProjectComponent extends ItemComponent implements OnInit {
|
||||
this.contributors$ = this.buildRepresentations('OrgUnit', 'project.contributor.other');
|
||||
|
||||
this.people$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isPersonOfProject'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isPersonOfProject')
|
||||
);
|
||||
|
||||
this.publications$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isPublicationOfProject'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isPublicationOfProject')
|
||||
);
|
||||
|
||||
this.orgUnits$ = this.resolvedRelsAndTypes$.pipe(
|
||||
filterRelationsByTypeLabel('isOrgUnitOfProject'),
|
||||
relationsToItems(this.item.id)
|
||||
getRelatedItemsByTypeLabel(this.item.id, 'isOrgUnitOfProject')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import { GroupEpersonService } from '../../../core/eperson/group-eperson.service
|
||||
import { cold, hot } from 'jasmine-marbles';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { ResourcePolicy } from '../../../core/shared/resource-policy.model';
|
||||
import { ResourcePolicyService } from '../../../core/data/resource-policy.service';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { ConfigData } from '../../../core/config/config-data';
|
||||
import { PageInfo } from '../../../core/shared/page-info.model';
|
||||
@@ -47,8 +48,7 @@ function getMockSubmissionUploadsConfigService(): SubmissionFormsConfigService {
|
||||
|
||||
function getMockCollectionDataService(): CollectionDataService {
|
||||
return jasmine.createSpyObj('CollectionDataService', {
|
||||
findById: jasmine.createSpy('findById'),
|
||||
findByHref: jasmine.createSpy('findByHref')
|
||||
findById: jasmine.createSpy('findById')
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,6 +59,12 @@ function getMockGroupEpersonService(): GroupEpersonService {
|
||||
});
|
||||
}
|
||||
|
||||
function getMockResourcePolicyService(): ResourcePolicyService {
|
||||
return jasmine.createSpyObj('ResourcePolicyService', {
|
||||
findByHref: jasmine.createSpy('findByHref')
|
||||
});
|
||||
}
|
||||
|
||||
const sectionObject: SectionDataObject = {
|
||||
config: 'https://dspace7.4science.it/or2018/api/config/submissionforms/upload',
|
||||
mandatory: true,
|
||||
@@ -80,6 +86,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
let sectionsServiceStub: SectionsServiceStub;
|
||||
let collectionDataService: any;
|
||||
let groupService: any;
|
||||
let resourcePolicyService: any;
|
||||
let uploadsConfigService: any;
|
||||
let bitstreamService: any;
|
||||
|
||||
@@ -120,6 +127,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
providers: [
|
||||
{ provide: CollectionDataService, useValue: getMockCollectionDataService() },
|
||||
{ provide: GroupEpersonService, useValue: getMockGroupEpersonService() },
|
||||
{ provide: ResourcePolicyService, useValue: getMockResourcePolicyService() },
|
||||
{ provide: SubmissionUploadsConfigService, useValue: getMockSubmissionUploadsConfigService() },
|
||||
{ provide: SectionsService, useClass: SectionsServiceStub },
|
||||
{ provide: SubmissionService, useClass: SubmissionServiceStub },
|
||||
@@ -166,6 +174,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
sectionsServiceStub = TestBed.get(SectionsService);
|
||||
collectionDataService = TestBed.get(CollectionDataService);
|
||||
groupService = TestBed.get(GroupEpersonService);
|
||||
resourcePolicyService = TestBed.get(ResourcePolicyService);
|
||||
uploadsConfigService = TestBed.get(SubmissionUploadsConfigService);
|
||||
bitstreamService = TestBed.get(SectionUploadService);
|
||||
});
|
||||
@@ -184,7 +193,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
new RemoteData(false, false, true,
|
||||
undefined, mockCollection)));
|
||||
|
||||
collectionDataService.findByHref.and.returnValue(observableOf(
|
||||
resourcePolicyService.findByHref.and.returnValue(observableOf(
|
||||
new RemoteData(false, false, true,
|
||||
undefined, mockDefaultAccessCondition)
|
||||
));
|
||||
@@ -230,7 +239,7 @@ describe('SubmissionSectionUploadComponent test suite', () => {
|
||||
new RemoteData(false, false, true,
|
||||
undefined, mockCollection)));
|
||||
|
||||
collectionDataService.findByHref.and.returnValue(observableOf(
|
||||
resourcePolicyService.findByHref.and.returnValue(observableOf(
|
||||
new RemoteData(false, false, true,
|
||||
undefined, mockDefaultAccessCondition)
|
||||
));
|
||||
|
@@ -8,6 +8,7 @@ import { hasValue, isNotEmpty, isNotUndefined, isUndefined } from '../../../shar
|
||||
import { SectionUploadService } from './section-upload.service';
|
||||
import { CollectionDataService } from '../../../core/data/collection-data.service';
|
||||
import { GroupEpersonService } from '../../../core/eperson/group-eperson.service';
|
||||
import { ResourcePolicyService } from '../../../core/data/resource-policy.service';
|
||||
import { SubmissionUploadsConfigService } from '../../../core/config/submission-uploads-config.service';
|
||||
import { SubmissionUploadsModel } from '../../../core/config/models/config-submission-uploads.model';
|
||||
import { SubmissionFormsModel } from '../../../core/config/models/config-submission-forms.model';
|
||||
@@ -116,6 +117,7 @@ export class SubmissionSectionUploadComponent extends SectionModelComponent {
|
||||
* @param {ChangeDetectorRef} changeDetectorRef
|
||||
* @param {CollectionDataService} collectionDataService
|
||||
* @param {GroupEpersonService} groupService
|
||||
* @param {ResourcePolicyService} resourcePolicyService
|
||||
* @param {SectionsService} sectionService
|
||||
* @param {SubmissionService} submissionService
|
||||
* @param {SubmissionUploadsConfigService} uploadsConfigService
|
||||
@@ -126,6 +128,7 @@ export class SubmissionSectionUploadComponent extends SectionModelComponent {
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private collectionDataService: CollectionDataService,
|
||||
private groupService: GroupEpersonService,
|
||||
private resourcePolicyService: ResourcePolicyService,
|
||||
protected sectionService: SectionsService,
|
||||
private submissionService: SubmissionService,
|
||||
private uploadsConfigService: SubmissionUploadsConfigService,
|
||||
@@ -155,7 +158,7 @@ export class SubmissionSectionUploadComponent extends SectionModelComponent {
|
||||
find((rd: RemoteData<Collection>) => isNotUndefined((rd.payload))),
|
||||
tap((collectionRemoteData: RemoteData<Collection>) => this.collectionName = collectionRemoteData.payload.name),
|
||||
flatMap((collectionRemoteData: RemoteData<Collection>) => {
|
||||
return this.collectionDataService.findByHref(
|
||||
return this.resourcePolicyService.findByHref(
|
||||
(collectionRemoteData.payload as any)._links.defaultAccessConditions
|
||||
);
|
||||
}),
|
||||
|
Reference in New Issue
Block a user