Skip to content

Commit 92a10ce

Browse files
authored
Merge pull request DSpace#1562 from 4Science/CST-5337
Enrich local data via the OpenAIRE Graph
2 parents 38733e6 + 56cf0e1 commit 92a10ce

82 files changed

Lines changed: 8147 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { URLCombiner } from '../../core/url-combiner/url-combiner';
2+
import { getNotificationsModuleRoute } from '../admin-routing-paths';
3+
4+
export const QUALITY_ASSURANCE_EDIT_PATH = 'quality-assurance';
5+
6+
export function getQualityAssuranceRoute(id: string) {
7+
return new URLCombiner(getNotificationsModuleRoute(), QUALITY_ASSURANCE_EDIT_PATH, id).toString();
8+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { NgModule } from '@angular/core';
2+
import { RouterModule } from '@angular/router';
3+
4+
import { AuthenticatedGuard } from '../../core/auth/authenticated.guard';
5+
import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver';
6+
import { I18nBreadcrumbsService } from '../../core/breadcrumbs/i18n-breadcrumbs.service';
7+
import { QUALITY_ASSURANCE_EDIT_PATH } from './admin-notifications-routing-paths';
8+
import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page.component';
9+
import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.component';
10+
import { AdminQualityAssuranceTopicsPageResolver } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page-resolver.service';
11+
import { AdminQualityAssuranceEventsPageResolver } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.resolver';
12+
import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page.component';
13+
import { AdminQualityAssuranceSourcePageResolver } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page-resolver.service';
14+
import { QualityAssuranceBreadcrumbResolver } from '../../core/breadcrumbs/quality-assurance-breadcrumb.resolver';
15+
import { QualityAssuranceBreadcrumbService } from '../../core/breadcrumbs/quality-assurance-breadcrumb.service';
16+
import {
17+
SourceDataResolver
18+
} from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-data.resolver';
19+
20+
@NgModule({
21+
imports: [
22+
RouterModule.forChild([
23+
{
24+
canActivate: [ AuthenticatedGuard ],
25+
path: `${QUALITY_ASSURANCE_EDIT_PATH}/:sourceId`,
26+
component: AdminQualityAssuranceTopicsPageComponent,
27+
pathMatch: 'full',
28+
resolve: {
29+
breadcrumb: QualityAssuranceBreadcrumbResolver,
30+
openaireQualityAssuranceTopicsParams: AdminQualityAssuranceTopicsPageResolver
31+
},
32+
data: {
33+
title: 'admin.quality-assurance.page.title',
34+
breadcrumbKey: 'admin.quality-assurance',
35+
showBreadcrumbsFluid: false
36+
}
37+
},
38+
{
39+
canActivate: [ AuthenticatedGuard ],
40+
path: `${QUALITY_ASSURANCE_EDIT_PATH}`,
41+
component: AdminQualityAssuranceSourcePageComponent,
42+
pathMatch: 'full',
43+
resolve: {
44+
breadcrumb: I18nBreadcrumbResolver,
45+
openaireQualityAssuranceSourceParams: AdminQualityAssuranceSourcePageResolver,
46+
sourceData: SourceDataResolver
47+
},
48+
data: {
49+
title: 'admin.notifications.source.breadcrumbs',
50+
breadcrumbKey: 'admin.notifications.source',
51+
showBreadcrumbsFluid: false
52+
}
53+
},
54+
{
55+
canActivate: [ AuthenticatedGuard ],
56+
path: `${QUALITY_ASSURANCE_EDIT_PATH}/:sourceId/:topicId`,
57+
component: AdminQualityAssuranceEventsPageComponent,
58+
pathMatch: 'full',
59+
resolve: {
60+
breadcrumb: QualityAssuranceBreadcrumbResolver,
61+
openaireQualityAssuranceEventsParams: AdminQualityAssuranceEventsPageResolver
62+
},
63+
data: {
64+
title: 'admin.notifications.event.page.title',
65+
breadcrumbKey: 'admin.notifications.event',
66+
showBreadcrumbsFluid: false
67+
}
68+
}
69+
])
70+
],
71+
providers: [
72+
I18nBreadcrumbResolver,
73+
I18nBreadcrumbsService,
74+
SourceDataResolver,
75+
AdminQualityAssuranceTopicsPageResolver,
76+
AdminQualityAssuranceEventsPageResolver,
77+
AdminQualityAssuranceSourcePageResolver,
78+
QualityAssuranceBreadcrumbResolver,
79+
QualityAssuranceBreadcrumbService
80+
]
81+
})
82+
/**
83+
* Routing module for the Notifications section of the admin sidebar
84+
*/
85+
export class AdminNotificationsRoutingModule {
86+
87+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
3+
import { CoreModule } from '../../core/core.module';
4+
import { SharedModule } from '../../shared/shared.module';
5+
import { AdminNotificationsRoutingModule } from './admin-notifications-routing.module';
6+
import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page.component';
7+
import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.component';
8+
import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page.component';
9+
import {NotificationsModule} from '../../notifications/notifications.module';
10+
11+
@NgModule({
12+
imports: [
13+
CommonModule,
14+
SharedModule,
15+
CoreModule.forRoot(),
16+
AdminNotificationsRoutingModule,
17+
NotificationsModule
18+
],
19+
declarations: [
20+
AdminQualityAssuranceTopicsPageComponent,
21+
AdminQualityAssuranceEventsPageComponent,
22+
AdminQualityAssuranceSourcePageComponent
23+
],
24+
entryComponents: []
25+
})
26+
/**
27+
* This module handles all components related to the notifications pages
28+
*/
29+
export class AdminNotificationsModule {
30+
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<ds-quality-assurance-events></ds-quality-assurance-events>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3+
import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page.component';
4+
5+
describe('AdminQualityAssuranceEventsPageComponent', () => {
6+
let component: AdminQualityAssuranceEventsPageComponent;
7+
let fixture: ComponentFixture<AdminQualityAssuranceEventsPageComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ AdminQualityAssuranceEventsPageComponent ],
12+
schemas: [NO_ERRORS_SCHEMA]
13+
})
14+
.compileComponents();
15+
}));
16+
17+
beforeEach(() => {
18+
fixture = TestBed.createComponent(AdminQualityAssuranceEventsPageComponent);
19+
component = fixture.componentInstance;
20+
fixture.detectChanges();
21+
});
22+
23+
it('should create AdminQualityAssuranceEventsPageComponent', () => {
24+
expect(component).toBeTruthy();
25+
});
26+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Component } from '@angular/core';
2+
3+
/**
4+
* Component for the page that show the QA events related to a specific topic.
5+
*/
6+
@Component({
7+
selector: 'ds-quality-assurance-events-page',
8+
templateUrl: './admin-quality-assurance-events-page.component.html'
9+
})
10+
export class AdminQualityAssuranceEventsPageComponent {
11+
12+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Injectable } from '@angular/core';
2+
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
3+
4+
/**
5+
* Interface for the route parameters.
6+
*/
7+
export interface AdminQualityAssuranceEventsPageParams {
8+
pageId?: string;
9+
pageSize?: number;
10+
currentPage?: number;
11+
}
12+
13+
/**
14+
* This class represents a resolver that retrieve the route data before the route is activated.
15+
*/
16+
@Injectable()
17+
export class AdminQualityAssuranceEventsPageResolver implements Resolve<AdminQualityAssuranceEventsPageParams> {
18+
19+
/**
20+
* Method for resolving the parameters in the current route.
21+
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
22+
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
23+
* @returns AdminQualityAssuranceEventsPageParams Emits the route parameters
24+
*/
25+
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminQualityAssuranceEventsPageParams {
26+
return {
27+
pageId: route.queryParams.pageId,
28+
pageSize: parseInt(route.queryParams.pageSize, 10),
29+
currentPage: parseInt(route.queryParams.page, 10)
30+
};
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Injectable } from '@angular/core';
2+
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot, Router } from '@angular/router';
3+
import { Observable } from 'rxjs';
4+
import { map } from 'rxjs/operators';
5+
import { PaginatedList } from '../../../core/data/paginated-list.model';
6+
import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model';
7+
import { QualityAssuranceSourceService } from '../../../notifications/qa/source/quality-assurance-source.service';
8+
import {environment} from '../../../../environments/environment';
9+
/**
10+
* This class represents a resolver that retrieve the route data before the route is activated.
11+
*/
12+
@Injectable()
13+
export class SourceDataResolver implements Resolve<Observable<QualityAssuranceSourceObject[]>> {
14+
private pageSize = environment.qualityAssuranceConfig.pageSize;
15+
/**
16+
* Initialize the effect class variables.
17+
* @param {QualityAssuranceSourceService} qualityAssuranceSourceService
18+
*/
19+
constructor(
20+
private qualityAssuranceSourceService: QualityAssuranceSourceService,
21+
private router: Router
22+
) { }
23+
/**
24+
* Method for resolving the parameters in the current route.
25+
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
26+
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
27+
* @returns Observable<QualityAssuranceSourceObject[]>
28+
*/
29+
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<QualityAssuranceSourceObject[]> {
30+
return this.qualityAssuranceSourceService.getSources(this.pageSize, 0).pipe(
31+
map((sources: PaginatedList<QualityAssuranceSourceObject>) => {
32+
if (sources.page.length === 1) {
33+
this.router.navigate([this.getResolvedUrl(route) + '/' + sources.page[0].id]);
34+
}
35+
return sources.page;
36+
}));
37+
}
38+
39+
/**
40+
*
41+
* @param route url path
42+
* @returns url path
43+
*/
44+
getResolvedUrl(route: ActivatedRouteSnapshot): string {
45+
return route.pathFromRoot.map(v => v.url.map(segment => segment.toString()).join('/')).join('/');
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Injectable } from '@angular/core';
2+
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
3+
4+
/**
5+
* Interface for the route parameters.
6+
*/
7+
export interface AdminQualityAssuranceSourcePageParams {
8+
pageId?: string;
9+
pageSize?: number;
10+
currentPage?: number;
11+
}
12+
13+
/**
14+
* This class represents a resolver that retrieve the route data before the route is activated.
15+
*/
16+
@Injectable()
17+
export class AdminQualityAssuranceSourcePageResolver implements Resolve<AdminQualityAssuranceSourcePageParams> {
18+
19+
/**
20+
* Method for resolving the parameters in the current route.
21+
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
22+
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
23+
* @returns AdminQualityAssuranceSourcePageParams Emits the route parameters
24+
*/
25+
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminQualityAssuranceSourcePageParams {
26+
return {
27+
pageId: route.queryParams.pageId,
28+
pageSize: parseInt(route.queryParams.pageSize, 10),
29+
currentPage: parseInt(route.queryParams.page, 10)
30+
};
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<ds-quality-assurance-source></ds-quality-assurance-source>

0 commit comments

Comments
 (0)