Skip to content

Commit

Permalink
Merge pull request DSpace#1562 from 4Science/CST-5337
Browse files Browse the repository at this point in the history
Enrich local data via the OpenAIRE Graph
  • Loading branch information
tdonohue authored Dec 18, 2023
2 parents 38733e6 + 56cf0e1 commit 92a10ce
Show file tree
Hide file tree
Showing 82 changed files with 8,147 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { URLCombiner } from '../../core/url-combiner/url-combiner';
import { getNotificationsModuleRoute } from '../admin-routing-paths';

export const QUALITY_ASSURANCE_EDIT_PATH = 'quality-assurance';

export function getQualityAssuranceRoute(id: string) {
return new URLCombiner(getNotificationsModuleRoute(), QUALITY_ASSURANCE_EDIT_PATH, id).toString();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { AuthenticatedGuard } from '../../core/auth/authenticated.guard';
import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver';
import { I18nBreadcrumbsService } from '../../core/breadcrumbs/i18n-breadcrumbs.service';
import { QUALITY_ASSURANCE_EDIT_PATH } from './admin-notifications-routing-paths';
import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page.component';
import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.component';
import { AdminQualityAssuranceTopicsPageResolver } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page-resolver.service';
import { AdminQualityAssuranceEventsPageResolver } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.resolver';
import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page.component';
import { AdminQualityAssuranceSourcePageResolver } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page-resolver.service';
import { QualityAssuranceBreadcrumbResolver } from '../../core/breadcrumbs/quality-assurance-breadcrumb.resolver';
import { QualityAssuranceBreadcrumbService } from '../../core/breadcrumbs/quality-assurance-breadcrumb.service';
import {
SourceDataResolver
} from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-data.resolver';

@NgModule({
imports: [
RouterModule.forChild([
{
canActivate: [ AuthenticatedGuard ],
path: `${QUALITY_ASSURANCE_EDIT_PATH}/:sourceId`,
component: AdminQualityAssuranceTopicsPageComponent,
pathMatch: 'full',
resolve: {
breadcrumb: QualityAssuranceBreadcrumbResolver,
openaireQualityAssuranceTopicsParams: AdminQualityAssuranceTopicsPageResolver
},
data: {
title: 'admin.quality-assurance.page.title',
breadcrumbKey: 'admin.quality-assurance',
showBreadcrumbsFluid: false
}
},
{
canActivate: [ AuthenticatedGuard ],
path: `${QUALITY_ASSURANCE_EDIT_PATH}`,
component: AdminQualityAssuranceSourcePageComponent,
pathMatch: 'full',
resolve: {
breadcrumb: I18nBreadcrumbResolver,
openaireQualityAssuranceSourceParams: AdminQualityAssuranceSourcePageResolver,
sourceData: SourceDataResolver
},
data: {
title: 'admin.notifications.source.breadcrumbs',
breadcrumbKey: 'admin.notifications.source',
showBreadcrumbsFluid: false
}
},
{
canActivate: [ AuthenticatedGuard ],
path: `${QUALITY_ASSURANCE_EDIT_PATH}/:sourceId/:topicId`,
component: AdminQualityAssuranceEventsPageComponent,
pathMatch: 'full',
resolve: {
breadcrumb: QualityAssuranceBreadcrumbResolver,
openaireQualityAssuranceEventsParams: AdminQualityAssuranceEventsPageResolver
},
data: {
title: 'admin.notifications.event.page.title',
breadcrumbKey: 'admin.notifications.event',
showBreadcrumbsFluid: false
}
}
])
],
providers: [
I18nBreadcrumbResolver,
I18nBreadcrumbsService,
SourceDataResolver,
AdminQualityAssuranceTopicsPageResolver,
AdminQualityAssuranceEventsPageResolver,
AdminQualityAssuranceSourcePageResolver,
QualityAssuranceBreadcrumbResolver,
QualityAssuranceBreadcrumbService
]
})
/**
* Routing module for the Notifications section of the admin sidebar
*/
export class AdminNotificationsRoutingModule {

}
31 changes: 31 additions & 0 deletions src/app/admin/admin-notifications/admin-notifications.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { CoreModule } from '../../core/core.module';
import { SharedModule } from '../../shared/shared.module';
import { AdminNotificationsRoutingModule } from './admin-notifications-routing.module';
import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page/admin-quality-assurance-topics-page.component';
import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page/admin-quality-assurance-events-page.component';
import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page-component/admin-quality-assurance-source-page.component';
import {NotificationsModule} from '../../notifications/notifications.module';

@NgModule({
imports: [
CommonModule,
SharedModule,
CoreModule.forRoot(),
AdminNotificationsRoutingModule,
NotificationsModule
],
declarations: [
AdminQualityAssuranceTopicsPageComponent,
AdminQualityAssuranceEventsPageComponent,
AdminQualityAssuranceSourcePageComponent
],
entryComponents: []
})
/**
* This module handles all components related to the notifications pages
*/
export class AdminNotificationsModule {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ds-quality-assurance-events></ds-quality-assurance-events>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AdminQualityAssuranceEventsPageComponent } from './admin-quality-assurance-events-page.component';

describe('AdminQualityAssuranceEventsPageComponent', () => {
let component: AdminQualityAssuranceEventsPageComponent;
let fixture: ComponentFixture<AdminQualityAssuranceEventsPageComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AdminQualityAssuranceEventsPageComponent ],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AdminQualityAssuranceEventsPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create AdminQualityAssuranceEventsPageComponent', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';

/**
* Component for the page that show the QA events related to a specific topic.
*/
@Component({
selector: 'ds-quality-assurance-events-page',
templateUrl: './admin-quality-assurance-events-page.component.html'
})
export class AdminQualityAssuranceEventsPageComponent {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';

/**
* Interface for the route parameters.
*/
export interface AdminQualityAssuranceEventsPageParams {
pageId?: string;
pageSize?: number;
currentPage?: number;
}

/**
* This class represents a resolver that retrieve the route data before the route is activated.
*/
@Injectable()
export class AdminQualityAssuranceEventsPageResolver implements Resolve<AdminQualityAssuranceEventsPageParams> {

/**
* Method for resolving the parameters in the current route.
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
* @returns AdminQualityAssuranceEventsPageParams Emits the route parameters
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminQualityAssuranceEventsPageParams {
return {
pageId: route.queryParams.pageId,
pageSize: parseInt(route.queryParams.pageSize, 10),
currentPage: parseInt(route.queryParams.page, 10)
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { QualityAssuranceSourceObject } from '../../../core/notifications/qa/models/quality-assurance-source.model';
import { QualityAssuranceSourceService } from '../../../notifications/qa/source/quality-assurance-source.service';
import {environment} from '../../../../environments/environment';
/**
* This class represents a resolver that retrieve the route data before the route is activated.
*/
@Injectable()
export class SourceDataResolver implements Resolve<Observable<QualityAssuranceSourceObject[]>> {
private pageSize = environment.qualityAssuranceConfig.pageSize;
/**
* Initialize the effect class variables.
* @param {QualityAssuranceSourceService} qualityAssuranceSourceService
*/
constructor(
private qualityAssuranceSourceService: QualityAssuranceSourceService,
private router: Router
) { }
/**
* Method for resolving the parameters in the current route.
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
* @returns Observable<QualityAssuranceSourceObject[]>
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<QualityAssuranceSourceObject[]> {
return this.qualityAssuranceSourceService.getSources(this.pageSize, 0).pipe(
map((sources: PaginatedList<QualityAssuranceSourceObject>) => {
if (sources.page.length === 1) {
this.router.navigate([this.getResolvedUrl(route) + '/' + sources.page[0].id]);
}
return sources.page;
}));
}

/**
*
* @param route url path
* @returns url path
*/
getResolvedUrl(route: ActivatedRouteSnapshot): string {
return route.pathFromRoot.map(v => v.url.map(segment => segment.toString()).join('/')).join('/');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';

/**
* Interface for the route parameters.
*/
export interface AdminQualityAssuranceSourcePageParams {
pageId?: string;
pageSize?: number;
currentPage?: number;
}

/**
* This class represents a resolver that retrieve the route data before the route is activated.
*/
@Injectable()
export class AdminQualityAssuranceSourcePageResolver implements Resolve<AdminQualityAssuranceSourcePageParams> {

/**
* Method for resolving the parameters in the current route.
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
* @returns AdminQualityAssuranceSourcePageParams Emits the route parameters
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminQualityAssuranceSourcePageParams {
return {
pageId: route.queryParams.pageId,
pageSize: parseInt(route.queryParams.pageSize, 10),
currentPage: parseInt(route.queryParams.page, 10)
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ds-quality-assurance-source></ds-quality-assurance-source>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AdminQualityAssuranceSourcePageComponent } from './admin-quality-assurance-source-page.component';

describe('AdminQualityAssuranceSourcePageComponent', () => {
let component: AdminQualityAssuranceSourcePageComponent;
let fixture: ComponentFixture<AdminQualityAssuranceSourcePageComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AdminQualityAssuranceSourcePageComponent ],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(AdminQualityAssuranceSourcePageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create AdminQualityAssuranceSourcePageComponent', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

/**
* Component for the page that show the QA sources.
*/
@Component({
selector: 'ds-admin-quality-assurance-source-page-component',
templateUrl: './admin-quality-assurance-source-page.component.html',
})
export class AdminQualityAssuranceSourcePageComponent {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';

/**
* Interface for the route parameters.
*/
export interface AdminQualityAssuranceTopicsPageParams {
pageId?: string;
pageSize?: number;
currentPage?: number;
}

/**
* This class represents a resolver that retrieve the route data before the route is activated.
*/
@Injectable()
export class AdminQualityAssuranceTopicsPageResolver implements Resolve<AdminQualityAssuranceTopicsPageParams> {

/**
* Method for resolving the parameters in the current route.
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
* @returns AdminQualityAssuranceTopicsPageParams Emits the route parameters
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminQualityAssuranceTopicsPageParams {
return {
pageId: route.queryParams.pageId,
pageSize: parseInt(route.queryParams.pageSize, 10),
currentPage: parseInt(route.queryParams.page, 10)
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ds-quality-assurance-topic></ds-quality-assurance-topic>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AdminQualityAssuranceTopicsPageComponent } from './admin-quality-assurance-topics-page.component';

describe('AdminQualityAssuranceTopicsPageComponent', () => {
let component: AdminQualityAssuranceTopicsPageComponent;
let fixture: ComponentFixture<AdminQualityAssuranceTopicsPageComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AdminQualityAssuranceTopicsPageComponent ],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AdminQualityAssuranceTopicsPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create AdminQualityAssuranceTopicsPageComponent', () => {
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit 92a10ce

Please sign in to comment.