[CST-5246] Correction service should support multiple providers

This commit is contained in:
Luca Giamminonni
2022-02-18 19:01:30 +01:00
parent b8e9f620b6
commit 4ca51387d1
60 changed files with 1150 additions and 1138 deletions

View File

@@ -0,0 +1 @@
<ds-notifications-broker-events></ds-notifications-broker-events>

View File

@@ -0,0 +1,26 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AdminNotificationsBrokerEventsPageComponent } from './admin-notifications-broker-events-page.component';
describe('AdminNotificationsBrokerEventsPageComponent', () => {
let component: AdminNotificationsBrokerEventsPageComponent;
let fixture: ComponentFixture<AdminNotificationsBrokerEventsPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AdminNotificationsBrokerEventsPageComponent ],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AdminNotificationsBrokerEventsPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create AdminNotificationsBrokerEventsPageComponent', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,9 @@
import { Component } from '@angular/core';
@Component({
selector: 'ds-notifications-broker-events-page',
templateUrl: './admin-notifications-broker-events-page.component.html'
})
export class AdminNotificationsBrokerEventsPageComponent {
}

View File

@@ -4,7 +4,7 @@ import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/r
/**
* Interface for the route parameters.
*/
export interface AdminNotificationsOpenaireEventsPageParams {
export interface AdminNotificationsBrokerEventsPageParams {
pageId?: string;
pageSize?: number;
currentPage?: number;
@@ -14,15 +14,15 @@ export interface AdminNotificationsOpenaireEventsPageParams {
* This class represents a resolver that retrieve the route data before the route is activated.
*/
@Injectable()
export class AdminNotificationsOpenaireEventsPageResolver implements Resolve<AdminNotificationsOpenaireEventsPageParams> {
export class AdminNotificationsBrokerEventsPageResolver implements Resolve<AdminNotificationsBrokerEventsPageParams> {
/**
* Method for resolving the parameters in the current route.
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
* @returns AdminNotificationsOpenaireEventsPageParams Emits the route parameters
* @returns AdminNotificationsBrokerEventsPageParams Emits the route parameters
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminNotificationsOpenaireEventsPageParams {
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminNotificationsBrokerEventsPageParams {
return {
pageId: route.queryParams.pageId,
pageSize: parseInt(route.queryParams.pageSize, 10),

View File

@@ -4,7 +4,7 @@ import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/r
/**
* Interface for the route parameters.
*/
export interface AdminNotificationsOpenaireTopicsPageParams {
export interface AdminNotificationsBrokerTopicsPageParams {
pageId?: string;
pageSize?: number;
currentPage?: number;
@@ -14,15 +14,15 @@ export interface AdminNotificationsOpenaireTopicsPageParams {
* This class represents a resolver that retrieve the route data before the route is activated.
*/
@Injectable()
export class AdminNotificationsOpenaireTopicsPageResolver implements Resolve<AdminNotificationsOpenaireTopicsPageParams> {
export class AdminNotificationsBrokerTopicsPageResolver implements Resolve<AdminNotificationsBrokerTopicsPageParams> {
/**
* Method for resolving the parameters in the current route.
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
* @returns AdminNotificationsOpenaireTopicsPageParams Emits the route parameters
* @returns AdminNotificationsBrokerTopicsPageParams Emits the route parameters
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminNotificationsOpenaireTopicsPageParams {
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): AdminNotificationsBrokerTopicsPageParams {
return {
pageId: route.queryParams.pageId,
pageSize: parseInt(route.queryParams.pageSize, 10),

View File

@@ -0,0 +1 @@
<ds-notifications-broker-topic></ds-notifications-broker-topic>

View File

@@ -0,0 +1,26 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AdminNotificationsBrokerTopicsPageComponent } from './admin-notifications-broker-topics-page.component';
describe('AdminNotificationsBrokerTopicsPageComponent', () => {
let component: AdminNotificationsBrokerTopicsPageComponent;
let fixture: ComponentFixture<AdminNotificationsBrokerTopicsPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AdminNotificationsBrokerTopicsPageComponent ],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AdminNotificationsBrokerTopicsPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create AdminNotificationsBrokerTopicsPageComponent', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,9 @@
import { Component } from '@angular/core';
@Component({
selector: 'ds-notification-broker-page',
templateUrl: './admin-notifications-broker-topics-page.component.html'
})
export class AdminNotificationsBrokerTopicsPageComponent {
}

View File

@@ -1,26 +0,0 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AdminNotificationsOpenaireEventsPageComponent } from './admin-notifications-openaire-events-page.component';
describe('AdminNotificationsOpenaireEventsPageComponent', () => {
let component: AdminNotificationsOpenaireEventsPageComponent;
let fixture: ComponentFixture<AdminNotificationsOpenaireEventsPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AdminNotificationsOpenaireEventsPageComponent ],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AdminNotificationsOpenaireEventsPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create AdminNotificationsOpenaireEventsPageComponent', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,9 +0,0 @@
import { Component } from '@angular/core';
@Component({
selector: 'ds-notification-openaire-events-page',
templateUrl: './admin-notifications-openaire-events-page.component.html'
})
export class AdminNotificationsOpenaireEventsPageComponent {
}

View File

@@ -1,26 +0,0 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AdminNotificationsOpenaireTopicsPageComponent } from './admin-notifications-openaire-topics-page.component';
describe('AdminNotificationsOpenaireTopicsPageComponent', () => {
let component: AdminNotificationsOpenaireTopicsPageComponent;
let fixture: ComponentFixture<AdminNotificationsOpenaireTopicsPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AdminNotificationsOpenaireTopicsPageComponent ],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AdminNotificationsOpenaireTopicsPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create AdminNotificationsOpenaireTopicsPageComponent', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,9 +0,0 @@
import { Component } from '@angular/core';
@Component({
selector: 'ds-notification-openairebroker-page',
templateUrl: './admin-notifications-openaire-topics-page.component.html'
})
export class AdminNotificationsOpenaireTopicsPageComponent {
}

View File

@@ -1,8 +1,8 @@
import { URLCombiner } from '../../core/url-combiner/url-combiner';
import { getNotificationsModuleRoute } from '../admin-routing-paths';
export const NOTIFICATIONS_EDIT_PATH = 'openaire-broker';
export const NOTIFICATIONS_EDIT_PATH = 'notifications-broker';
export function getNotificationsOpenairebrokerRoute(id: string) {
export function getNotificationsBrokerbrokerRoute(id: string) {
return new URLCombiner(getNotificationsModuleRoute(), NOTIFICATIONS_EDIT_PATH, id).toString();
}

View File

@@ -5,10 +5,10 @@ import { AuthenticatedGuard } from '../../core/auth/authenticated.guard';
import { I18nBreadcrumbResolver } from '../../core/breadcrumbs/i18n-breadcrumb.resolver';
import { I18nBreadcrumbsService } from '../../core/breadcrumbs/i18n-breadcrumbs.service';
import { NOTIFICATIONS_EDIT_PATH } from './admin-notifications-routing-paths';
import { AdminNotificationsOpenaireTopicsPageComponent } from './admin-notifications-openaire-topics-page/admin-notifications-openaire-topics-page.component';
import { AdminNotificationsOpenaireEventsPageComponent } from './admin-notifications-openaire-events-page/admin-notifications-openaire-events-page.component';
import { AdminNotificationsOpenaireTopicsPageResolver } from './admin-notifications-openaire-topics-page/admin-notifications-openaire-topics-page-resolver.service';
import { AdminNotificationsOpenaireEventsPageResolver } from './admin-notifications-openaire-events-page/admin-notifications-openaire-events-page.resolver';
import { AdminNotificationsBrokerTopicsPageComponent } from './admin-notifications-broker-topics-page/admin-notifications-broker-topics-page.component';
import { AdminNotificationsBrokerEventsPageComponent } from './admin-notifications-broker-events-page/admin-notifications-broker-events-page.component';
import { AdminNotificationsBrokerTopicsPageResolver } from './admin-notifications-broker-topics-page/admin-notifications-broker-topics-page-resolver.service';
import { AdminNotificationsBrokerEventsPageResolver } from './admin-notifications-broker-events-page/admin-notifications-broker-events-page.resolver';
@NgModule({
imports: [
@@ -16,30 +16,30 @@ import { AdminNotificationsOpenaireEventsPageResolver } from './admin-notificati
{
canActivate: [ AuthenticatedGuard ],
path: `${NOTIFICATIONS_EDIT_PATH}`,
component: AdminNotificationsOpenaireTopicsPageComponent,
component: AdminNotificationsBrokerTopicsPageComponent,
pathMatch: 'full',
resolve: {
breadcrumb: I18nBreadcrumbResolver,
openaireBrokerTopicsParams: AdminNotificationsOpenaireTopicsPageResolver
openaireBrokerTopicsParams: AdminNotificationsBrokerTopicsPageResolver
},
data: {
title: 'admin.notifications.openairebroker.page.title',
breadcrumbKey: 'admin.notifications.openairebroker',
title: 'admin.notifications.broker.page.title',
breadcrumbKey: 'admin.notifications.broker',
showBreadcrumbsFluid: false
}
},
{
canActivate: [ AuthenticatedGuard ],
path: `${NOTIFICATIONS_EDIT_PATH}/:id`,
component: AdminNotificationsOpenaireEventsPageComponent,
component: AdminNotificationsBrokerEventsPageComponent,
pathMatch: 'full',
resolve: {
breadcrumb: I18nBreadcrumbResolver,
openaireBrokerEventsParams: AdminNotificationsOpenaireEventsPageResolver
openaireBrokerEventsParams: AdminNotificationsBrokerEventsPageResolver
},
data: {
title: 'admin.notifications.openaireevent.page.title',
breadcrumbKey: 'admin.notifications.openaireevent',
title: 'admin.notifications.event.page.title',
breadcrumbKey: 'admin.notifications.event',
showBreadcrumbsFluid: false
}
}
@@ -48,8 +48,8 @@ import { AdminNotificationsOpenaireEventsPageResolver } from './admin-notificati
providers: [
I18nBreadcrumbResolver,
I18nBreadcrumbsService,
AdminNotificationsOpenaireTopicsPageResolver,
AdminNotificationsOpenaireEventsPageResolver
AdminNotificationsBrokerTopicsPageResolver,
AdminNotificationsBrokerEventsPageResolver
]
})
/**

View File

@@ -3,9 +3,9 @@ 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 { AdminNotificationsOpenaireTopicsPageComponent } from './admin-notifications-openaire-topics-page/admin-notifications-openaire-topics-page.component';
import { AdminNotificationsOpenaireEventsPageComponent } from './admin-notifications-openaire-events-page/admin-notifications-openaire-events-page.component';
import { OpenaireModule } from '../../openaire/openaire.module';
import { AdminNotificationsBrokerTopicsPageComponent } from './admin-notifications-broker-topics-page/admin-notifications-broker-topics-page.component';
import { AdminNotificationsBrokerEventsPageComponent } from './admin-notifications-broker-events-page/admin-notifications-broker-events-page.component';
import { NotificationsModule } from '../../notifications/notifications.module';
@NgModule({
imports: [
@@ -13,11 +13,11 @@ import { OpenaireModule } from '../../openaire/openaire.module';
SharedModule,
CoreModule.forRoot(),
AdminNotificationsRoutingModule,
OpenaireModule
NotificationsModule
],
declarations: [
AdminNotificationsOpenaireTopicsPageComponent,
AdminNotificationsOpenaireEventsPageComponent
AdminNotificationsBrokerTopicsPageComponent,
AdminNotificationsBrokerEventsPageComponent
],
entryComponents: []
})

View File

@@ -483,8 +483,8 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit {
visible: authorized,
model: {
type: MenuItemType.LINK,
text: 'menu.section.notifications_openaire_broker',
link: '/admin/notifications/openaire-broker'
text: 'menu.section.notifications_broker',
link: '/admin/notifications/notifications-broker'
} as LinkMenuItemModel,
},
/* Admin Search */

View File

@@ -162,8 +162,8 @@ import { SearchConfig } from './shared/search/search-filters/search-config.model
import { SequenceService } from './shared/sequence.service';
import { GroupDataService } from './eperson/group-data.service';
import { SubmissionAccessesModel } from './config/models/config-submission-accesses.model';
import { OpenaireBrokerTopicObject } from './openaire/broker/models/openaire-broker-topic.model';
import { OpenaireBrokerEventObject } from './openaire/broker/models/openaire-broker-event.model';
import { NotificationsBrokerTopicObject } from './notifications/broker/models/notifications-broker-topic.model';
import { NotificationsBrokerEventObject } from './notifications/broker/models/notifications-broker-event.model';
/**
* When not in production, endpoint responses can be mocked for testing purposes
@@ -345,8 +345,8 @@ export const models =
ShortLivedToken,
Registration,
UsageReport,
OpenaireBrokerTopicObject,
OpenaireBrokerEventObject,
NotificationsBrokerTopicObject,
NotificationsBrokerEventObject,
Root,
SearchConfig,
SubmissionAccessesModel

View File

@@ -15,17 +15,17 @@ import { PageInfo } from '../../../shared/page-info.model';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { createSuccessfulRemoteDataObject } from '../../../../shared/remote-data.utils';
import { OpenaireBrokerEventRestService } from './openaire-broker-event-rest.service';
import { NotificationsBrokerEventRestService } from './notifications-broker-event-rest.service';
import {
openaireBrokerEventObjectMissingPid,
openaireBrokerEventObjectMissingPid2,
openaireBrokerEventObjectMissingProjectFound
} from '../../../../shared/mocks/openaire.mock';
notificationsBrokerEventObjectMissingPid,
notificationsBrokerEventObjectMissingPid2,
notificationsBrokerEventObjectMissingProjectFound
} from '../../../../shared/mocks/notifications.mock';
import { ReplaceOperation } from 'fast-json-patch';
describe('OpenaireBrokerEventRestService', () => {
describe('NotificationsBrokerEventRestService', () => {
let scheduler: TestScheduler;
let service: OpenaireBrokerEventRestService;
let service: NotificationsBrokerEventRestService;
let serviceASAny: any;
let responseCacheEntry: RequestEntry;
let responseCacheEntryB: RequestEntry;
@@ -43,10 +43,10 @@ describe('OpenaireBrokerEventRestService', () => {
const topic = 'ENRICH!MORE!PID';
const pageInfo = new PageInfo();
const array = [ openaireBrokerEventObjectMissingPid, openaireBrokerEventObjectMissingPid2 ];
const array = [ notificationsBrokerEventObjectMissingPid, notificationsBrokerEventObjectMissingPid2 ];
const paginatedList = buildPaginatedList(pageInfo, array);
const brokerEventObjectRD = createSuccessfulRemoteDataObject(openaireBrokerEventObjectMissingPid);
const brokerEventObjectMissingProjectRD = createSuccessfulRemoteDataObject(openaireBrokerEventObjectMissingProjectFound);
const brokerEventObjectRD = createSuccessfulRemoteDataObject(notificationsBrokerEventObjectMissingPid);
const brokerEventObjectMissingProjectRD = createSuccessfulRemoteDataObject(notificationsBrokerEventObjectMissingProjectFound);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
const status = 'ACCEPTED';
@@ -99,7 +99,7 @@ describe('OpenaireBrokerEventRestService', () => {
http = {} as HttpClient;
comparator = {} as any;
service = new OpenaireBrokerEventRestService(
service = new NotificationsBrokerEventRestService(
requestService,
rdbService,
objectCache,
@@ -138,7 +138,7 @@ describe('OpenaireBrokerEventRestService', () => {
expect(serviceASAny.dataService.searchBy).toHaveBeenCalledWith('findByTopic', options, true, true);
});
it('should return a RemoteData<PaginatedList<OpenaireBrokerEventObject>> for the object with the given Topic', () => {
it('should return a RemoteData<PaginatedList<NotificationsBrokerEventObject>> for the object with the given Topic', () => {
const result = service.getEventsByTopic(topic);
const expected = cold('(a)', {
a: paginatedListRD
@@ -155,15 +155,15 @@ describe('OpenaireBrokerEventRestService', () => {
});
it('should proxy the call to dataservice.findById', () => {
service.getEvent(openaireBrokerEventObjectMissingPid.id).subscribe(
service.getEvent(notificationsBrokerEventObjectMissingPid.id).subscribe(
(res) => {
expect(serviceASAny.dataService.findById).toHaveBeenCalledWith(openaireBrokerEventObjectMissingPid.id, true, true);
expect(serviceASAny.dataService.findById).toHaveBeenCalledWith(notificationsBrokerEventObjectMissingPid.id, true, true);
}
);
});
it('should return a RemoteData<OpenaireBrokerEventObject> for the object with the given URL', () => {
const result = service.getEvent(openaireBrokerEventObjectMissingPid.id);
it('should return a RemoteData<NotificationsBrokerEventObject> for the object with the given URL', () => {
const result = service.getEvent(notificationsBrokerEventObjectMissingPid.id);
const expected = cold('(a)', {
a: brokerEventObjectRD
});
@@ -179,17 +179,17 @@ describe('OpenaireBrokerEventRestService', () => {
});
it('should proxy the call to dataservice.patch', () => {
service.patchEvent(status, openaireBrokerEventObjectMissingPid).subscribe(
service.patchEvent(status, notificationsBrokerEventObjectMissingPid).subscribe(
(res) => {
expect(serviceASAny.dataService.patch).toHaveBeenCalledWith(openaireBrokerEventObjectMissingPid, operation);
expect(serviceASAny.dataService.patch).toHaveBeenCalledWith(notificationsBrokerEventObjectMissingPid, operation);
}
);
});
it('should return a RemoteData with HTTP 200', () => {
const result = service.patchEvent(status, openaireBrokerEventObjectMissingPid);
const result = service.patchEvent(status, notificationsBrokerEventObjectMissingPid);
const expected = cold('(a|)', {
a: createSuccessfulRemoteDataObject(openaireBrokerEventObjectMissingPid)
a: createSuccessfulRemoteDataObject(notificationsBrokerEventObjectMissingPid)
});
expect(result).toBeObservable(expected);
});
@@ -203,17 +203,17 @@ describe('OpenaireBrokerEventRestService', () => {
});
it('should proxy the call to dataservice.postOnRelated', () => {
service.boundProject(openaireBrokerEventObjectMissingProjectFound.id, requestUUID).subscribe(
service.boundProject(notificationsBrokerEventObjectMissingProjectFound.id, requestUUID).subscribe(
(res) => {
expect(serviceASAny.dataService.postOnRelated).toHaveBeenCalledWith(openaireBrokerEventObjectMissingProjectFound.id, requestUUID);
expect(serviceASAny.dataService.postOnRelated).toHaveBeenCalledWith(notificationsBrokerEventObjectMissingProjectFound.id, requestUUID);
}
);
});
it('should return a RestResponse with HTTP 201', () => {
const result = service.boundProject(openaireBrokerEventObjectMissingProjectFound.id, requestUUID);
const result = service.boundProject(notificationsBrokerEventObjectMissingProjectFound.id, requestUUID);
const expected = cold('(a|)', {
a: createSuccessfulRemoteDataObject(openaireBrokerEventObjectMissingProjectFound)
a: createSuccessfulRemoteDataObject(notificationsBrokerEventObjectMissingProjectFound)
});
expect(result).toBeObservable(expected);
});
@@ -227,15 +227,15 @@ describe('OpenaireBrokerEventRestService', () => {
});
it('should proxy the call to dataservice.deleteOnRelated', () => {
service.removeProject(openaireBrokerEventObjectMissingProjectFound.id).subscribe(
service.removeProject(notificationsBrokerEventObjectMissingProjectFound.id).subscribe(
(res) => {
expect(serviceASAny.dataService.deleteOnRelated).toHaveBeenCalledWith(openaireBrokerEventObjectMissingProjectFound.id);
expect(serviceASAny.dataService.deleteOnRelated).toHaveBeenCalledWith(notificationsBrokerEventObjectMissingProjectFound.id);
}
);
});
it('should return a RestResponse with HTTP 204', () => {
const result = service.removeProject(openaireBrokerEventObjectMissingProjectFound.id);
const result = service.removeProject(notificationsBrokerEventObjectMissingProjectFound.id);
const expected = cold('(a|)', {
a: createSuccessfulRemoteDataObject({})
});

View File

@@ -17,8 +17,8 @@ import { DataService } from '../../../data/data.service';
import { ChangeAnalyzer } from '../../../data/change-analyzer';
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
import { RemoteData } from '../../../data/remote-data';
import { OpenaireBrokerEventObject } from '../models/openaire-broker-event.model';
import { OPENAIRE_BROKER_EVENT_OBJECT } from '../models/openaire-broker-event-object.resource-type';
import { NotificationsBrokerEventObject } from '../models/notifications-broker-event.model';
import { NOTIFICATIONS_BROKER_EVENT_OBJECT } from '../models/notifications-broker-event-object.resource-type';
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
import { PaginatedList } from '../../../data/paginated-list.model';
import { ReplaceOperation } from 'fast-json-patch';
@@ -29,7 +29,7 @@ import { NoContent } from '../../../shared/NoContent.model';
/**
* A private DataService implementation to delegate specific methods to.
*/
class DataServiceImpl extends DataService<OpenaireBrokerEventObject> {
class DataServiceImpl extends DataService<NotificationsBrokerEventObject> {
/**
* The REST endpoint.
*/
@@ -44,7 +44,7 @@ class DataServiceImpl extends DataService<OpenaireBrokerEventObject> {
* @param {HALEndpointService} halService
* @param {NotificationsService} notificationsService
* @param {HttpClient} http
* @param {ChangeAnalyzer<OpenaireBrokerEventObject>} comparator
* @param {ChangeAnalyzer<NotificationsBrokerEventObject>} comparator
*/
constructor(
protected requestService: RequestService,
@@ -54,17 +54,17 @@ class DataServiceImpl extends DataService<OpenaireBrokerEventObject> {
protected halService: HALEndpointService,
protected notificationsService: NotificationsService,
protected http: HttpClient,
protected comparator: ChangeAnalyzer<OpenaireBrokerEventObject>) {
protected comparator: ChangeAnalyzer<NotificationsBrokerEventObject>) {
super();
}
}
/**
* The service handling all OpenAIRE Broker topic REST requests.
* The service handling all Notifications Broker topic REST requests.
*/
@Injectable()
@dataService(OPENAIRE_BROKER_EVENT_OBJECT)
export class OpenaireBrokerEventRestService {
@dataService(NOTIFICATIONS_BROKER_EVENT_OBJECT)
export class NotificationsBrokerEventRestService {
/**
* A private DataService implementation to delegate specific methods to.
*/
@@ -78,7 +78,7 @@ export class OpenaireBrokerEventRestService {
* @param {HALEndpointService} halService
* @param {NotificationsService} notificationsService
* @param {HttpClient} http
* @param {DefaultChangeAnalyzer<OpenaireBrokerEventObject>} comparator
* @param {DefaultChangeAnalyzer<NotificationsBrokerEventObject>} comparator
*/
constructor(
protected requestService: RequestService,
@@ -87,23 +87,23 @@ export class OpenaireBrokerEventRestService {
protected halService: HALEndpointService,
protected notificationsService: NotificationsService,
protected http: HttpClient,
protected comparator: DefaultChangeAnalyzer<OpenaireBrokerEventObject>) {
protected comparator: DefaultChangeAnalyzer<NotificationsBrokerEventObject>) {
this.dataService = new DataServiceImpl(requestService, rdbService, null, objectCache, halService, notificationsService, http, comparator);
}
/**
* Return the list of OpenAIRE Broker events by topic.
* Return the list of Notifications Broker events by topic.
*
* @param topic
* The OpenAIRE Broker topic
* The Notifications Broker topic
* @param options
* Find list options object.
* @param linksToFollow
* List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved.
* @return Observable<RemoteData<PaginatedList<OpenaireBrokerEventObject>>>
* The list of OpenAIRE Broker events.
* @return Observable<RemoteData<PaginatedList<NotificationsBrokerEventObject>>>
* The list of Notifications Broker events.
*/
public getEventsByTopic(topic: string, options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<OpenaireBrokerEventObject>[]): Observable<RemoteData<PaginatedList<OpenaireBrokerEventObject>>> {
public getEventsByTopic(topic: string, options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<NotificationsBrokerEventObject>[]): Observable<RemoteData<PaginatedList<NotificationsBrokerEventObject>>> {
options.searchParams = [
{
fieldName: 'topic',
@@ -121,32 +121,32 @@ export class OpenaireBrokerEventRestService {
}
/**
* Return a single OpenAIRE Broker event.
* Return a single Notifications Broker event.
*
* @param id
* The OpenAIRE Broker event id
* The Notifications Broker event id
* @param linksToFollow
* List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
* @return Observable<RemoteData<OpenaireBrokerEventObject>>
* The OpenAIRE Broker event.
* @return Observable<RemoteData<NotificationsBrokerEventObject>>
* The Notifications Broker event.
*/
public getEvent(id: string, ...linksToFollow: FollowLinkConfig<OpenaireBrokerEventObject>[]): Observable<RemoteData<OpenaireBrokerEventObject>> {
public getEvent(id: string, ...linksToFollow: FollowLinkConfig<NotificationsBrokerEventObject>[]): Observable<RemoteData<NotificationsBrokerEventObject>> {
return this.dataService.findById(id, true, true, ...linksToFollow);
}
/**
* Save the new status of an OpenAIRE Broker event.
* Save the new status of a Notifications Broker event.
*
* @param status
* The new status
* @param dso OpenaireBrokerEventObject
* @param dso NotificationsBrokerEventObject
* The event item
* @param reason
* The optional reason (not used for now; for future implementation)
* @return Observable<RestResponse>
* The REST response.
*/
public patchEvent(status, dso, reason?: string): Observable<RemoteData<OpenaireBrokerEventObject>> {
public patchEvent(status, dso, reason?: string): Observable<RemoteData<NotificationsBrokerEventObject>> {
const operation: ReplaceOperation<string>[] = [
{
path: '/status',
@@ -158,24 +158,24 @@ export class OpenaireBrokerEventRestService {
}
/**
* Bound a project to an OpenAIRE Broker event publication.
* Bound a project to a Notifications Broker event publication.
*
* @param itemId
* The Id of the OpenAIRE Broker event
* The Id of the Notifications Broker event
* @param projectId
* The project Id to bound
* @return Observable<RestResponse>
* The REST response.
*/
public boundProject(itemId: string, projectId: string): Observable<RemoteData<OpenaireBrokerEventObject>> {
public boundProject(itemId: string, projectId: string): Observable<RemoteData<NotificationsBrokerEventObject>> {
return this.dataService.postOnRelated(itemId, projectId);
}
/**
* Remove a project from an OpenAIRE Broker event publication.
* Remove a project from a Notifications Broker event publication.
*
* @param itemId
* The Id of the OpenAIRE Broker event
* The Id of the Notifications Broker event
* @return Observable<RestResponse>
* The REST response.
*/

View File

@@ -1,9 +1,9 @@
import { ResourceType } from '../../../shared/resource-type';
/**
* The resource type for the OpenAIRE Broker event
* The resource type for the Notifications Broker event
*
* Needs to be in a separate file to prevent circular
* dependencies in webpack.
*/
export const OPENAIRE_BROKER_EVENT_OBJECT = new ResourceType('nbevent');
export const NOTIFICATIONS_BROKER_EVENT_OBJECT = new ResourceType('nbevent');

View File

@@ -1,7 +1,7 @@
import { Observable } from 'rxjs';
import { autoserialize, autoserializeAs, deserialize } from 'cerialize';
import { CacheableObject } from '../../../cache/object-cache.reducer';
import { OPENAIRE_BROKER_EVENT_OBJECT } from './openaire-broker-event-object.resource-type';
import { NOTIFICATIONS_BROKER_EVENT_OBJECT } from './notifications-broker-event-object.resource-type';
import { excludeFromEquals } from '../../../utilities/equals.decorators';
import { ResourceType } from '../../../shared/resource-type';
import { HALLink } from '../../../shared/hal-link.model';
@@ -11,85 +11,92 @@ import { link, typedObject } from '../../../cache/builders/build-decorators';
import { RemoteData } from '../../../data/remote-data';
/**
* The interface representing the OpenAIRE Broker event message
* The interface representing the Notifications Broker event message
*/
export interface OpenaireBrokerEventMessageObject {
export interface NotificationsBrokerEventMessageObject {
}
/**
* The interface representing the Notifications Broker event message
*/
export interface OpenaireBrokerEventMessageObject{
/**
* The type of 'value'
*/
type: string;
/**
* The value suggested by OpenAIRE
* The value suggested by Notifications
*/
value: string;
/**
* The abstract suggested by OpenAIRE
* The abstract suggested by Notifications
*/
abstract: string;
/**
* The project acronym suggested by OpenAIRE
* The project acronym suggested by Notifications
*/
acronym: string;
/**
* The project code suggested by OpenAIRE
* The project code suggested by Notifications
*/
code: string;
/**
* The project funder suggested by OpenAIRE
* The project funder suggested by Notifications
*/
funder: string;
/**
* The project program suggested by OpenAIRE
* The project program suggested by Notifications
*/
fundingProgram?: string;
/**
* The project jurisdiction suggested by OpenAIRE
* The project jurisdiction suggested by Notifications
*/
jurisdiction: string;
/**
* The project title suggested by OpenAIRE
* The project title suggested by Notifications
*/
title: string;
/**
* The OpenAIRE ID.
* The OPENAIRE ID.
*/
openaireId: string;
}
/**
* The interface representing the OpenAIRE Broker event model
* The interface representing the Notifications Broker event model
*/
@typedObject
export class OpenaireBrokerEventObject implements CacheableObject {
export class NotificationsBrokerEventObject implements CacheableObject {
/**
* A string representing the kind of object, e.g. community, item,
*/
static type = OPENAIRE_BROKER_EVENT_OBJECT;
static type = NOTIFICATIONS_BROKER_EVENT_OBJECT;
/**
* The OpenAIRE Broker event uuid inside DSpace
* The Notifications Broker event uuid inside DSpace
*/
@autoserialize
id: string;
/**
* The universally unique identifier of this OpenAIRE Broker event
* The universally unique identifier of this Notifications Broker event
*/
@autoserializeAs(String, 'id')
uuid: string;
/**
* The OpenAIRE Broker event original id (ex.: the source archive OAI-PMH identifier)
* The Notifications Broker event original id (ex.: the source archive OAI-PMH identifier)
*/
@autoserialize
originalId: string;
@@ -107,19 +114,19 @@ export class OpenaireBrokerEventObject implements CacheableObject {
trust: number;
/**
* The timestamp OpenAIRE Broker event was saved in DSpace
* The timestamp Notifications Broker event was saved in DSpace
*/
@autoserialize
eventDate: string;
/**
* The OpenAIRE Broker event status (ACCEPTED, REJECTED, DISCARDED, PENDING)
* The Notifications Broker event status (ACCEPTED, REJECTED, DISCARDED, PENDING)
*/
@autoserialize
status: string;
/**
* The suggestion data. Data may vary depending on the topic
* The suggestion data. Data may vary depending on the source
*/
@autoserialize
message: OpenaireBrokerEventMessageObject;

View File

@@ -1,9 +1,9 @@
import { ResourceType } from '../../../shared/resource-type';
/**
* The resource type for the OpenAIRE Broker topic
* The resource type for the Notifications Broker topic
*
* Needs to be in a separate file to prevent circular
* dependencies in webpack.
*/
export const OPENAIRE_BROKER_TOPIC_OBJECT = new ResourceType('nbtopic');
export const NOTIFICATIONS_BROKER_TOPIC_OBJECT = new ResourceType('nbtopic');

View File

@@ -1,42 +1,42 @@
import { autoserialize, deserialize } from 'cerialize';
import { CacheableObject } from '../../../cache/object-cache.reducer';
import { OPENAIRE_BROKER_TOPIC_OBJECT } from './openaire-broker-topic-object.resource-type';
import { NOTIFICATIONS_BROKER_TOPIC_OBJECT } from './notifications-broker-topic-object.resource-type';
import { excludeFromEquals } from '../../../utilities/equals.decorators';
import { ResourceType } from '../../../shared/resource-type';
import { HALLink } from '../../../shared/hal-link.model';
import { typedObject } from '../../../cache/builders/build-decorators';
/**
* The interface representing the OpenAIRE Broker topic model
* The interface representing the Notifications Broker topic model
*/
@typedObject
export class OpenaireBrokerTopicObject implements CacheableObject {
export class NotificationsBrokerTopicObject implements CacheableObject {
/**
* A string representing the kind of object, e.g. community, item,
*/
static type = OPENAIRE_BROKER_TOPIC_OBJECT;
static type = NOTIFICATIONS_BROKER_TOPIC_OBJECT;
/**
* The OpenAIRE Broker topic id
* The Notifications Broker topic id
*/
@autoserialize
id: string;
/**
* The OpenAIRE Broker topic name to display
* The Notifications Broker topic name to display
*/
@autoserialize
name: string;
/**
* The date of the last udate from OpenAIRE
* The date of the last udate from Notifications
*/
@autoserialize
lastEvent: string;
/**
* The total number of suggestions provided by OpenAIRE for this topic
* The total number of suggestions provided by Notifications for this topic
*/
@autoserialize
totalEvents: number;

View File

@@ -14,15 +14,15 @@ import { PageInfo } from '../../../shared/page-info.model';
import { HALEndpointService } from '../../../shared/hal-endpoint.service';
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
import { createSuccessfulRemoteDataObject } from '../../../../shared/remote-data.utils';
import { OpenaireBrokerTopicRestService } from './openaire-broker-topic-rest.service';
import { NotificationsBrokerTopicRestService } from './notifications-broker-topic-rest.service';
import {
openaireBrokerTopicObjectMoreAbstract,
openaireBrokerTopicObjectMorePid
} from '../../../../shared/mocks/openaire.mock';
notificationsBrokerTopicObjectMoreAbstract,
notificationsBrokerTopicObjectMorePid
} from '../../../../shared/mocks/notifications.mock';
describe('OpenaireBrokerTopicRestService', () => {
describe('NotificationsBrokerTopicRestService', () => {
let scheduler: TestScheduler;
let service: OpenaireBrokerTopicRestService;
let service: NotificationsBrokerTopicRestService;
let responseCacheEntry: RequestEntry;
let requestService: RequestService;
let rdbService: RemoteDataBuildService;
@@ -36,9 +36,9 @@ describe('OpenaireBrokerTopicRestService', () => {
const requestUUID = '8b3c913a-5a4b-438b-9181-be1a5b4a1c8a';
const pageInfo = new PageInfo();
const array = [ openaireBrokerTopicObjectMorePid, openaireBrokerTopicObjectMoreAbstract ];
const array = [ notificationsBrokerTopicObjectMorePid, notificationsBrokerTopicObjectMoreAbstract ];
const paginatedList = buildPaginatedList(pageInfo, array);
const brokerTopicObjectRD = createSuccessfulRemoteDataObject(openaireBrokerTopicObjectMorePid);
const brokerTopicObjectRD = createSuccessfulRemoteDataObject(notificationsBrokerTopicObjectMorePid);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
beforeEach(() => {
@@ -72,7 +72,7 @@ describe('OpenaireBrokerTopicRestService', () => {
http = {} as HttpClient;
comparator = {} as any;
service = new OpenaireBrokerTopicRestService(
service = new NotificationsBrokerTopicRestService(
requestService,
rdbService,
objectCache,
@@ -96,7 +96,7 @@ describe('OpenaireBrokerTopicRestService', () => {
done();
});
it('should return a RemoteData<PaginatedList<OpenaireBrokerTopicObject>> for the object with the given URL', () => {
it('should return a RemoteData<PaginatedList<NotificationsBrokerTopicObject>> for the object with the given URL', () => {
const result = service.getTopics();
const expected = cold('(a)', {
a: paginatedListRD
@@ -107,16 +107,16 @@ describe('OpenaireBrokerTopicRestService', () => {
describe('getTopic', () => {
it('should proxy the call to dataservice.findByHref', (done) => {
service.getTopic(openaireBrokerTopicObjectMorePid.id).subscribe(
service.getTopic(notificationsBrokerTopicObjectMorePid.id).subscribe(
(res) => {
expect((service as any).dataService.findByHref).toHaveBeenCalledWith(endpointURL + '/' + openaireBrokerTopicObjectMorePid.id, true, true);
expect((service as any).dataService.findByHref).toHaveBeenCalledWith(endpointURL + '/' + notificationsBrokerTopicObjectMorePid.id, true, true);
}
);
done();
});
it('should return a RemoteData<OpenaireBrokerTopicObject> for the object with the given URL', () => {
const result = service.getTopic(openaireBrokerTopicObjectMorePid.id);
it('should return a RemoteData<NotificationsBrokerTopicObject> for the object with the given URL', () => {
const result = service.getTopic(notificationsBrokerTopicObjectMorePid.id);
const expected = cold('(a)', {
a: brokerTopicObjectRD
});

View File

@@ -17,8 +17,8 @@ import { DataService } from '../../../data/data.service';
import { ChangeAnalyzer } from '../../../data/change-analyzer';
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
import { RemoteData } from '../../../data/remote-data';
import { OpenaireBrokerTopicObject } from '../models/openaire-broker-topic.model';
import { OPENAIRE_BROKER_TOPIC_OBJECT } from '../models/openaire-broker-topic-object.resource-type';
import { NotificationsBrokerTopicObject } from '../models/notifications-broker-topic.model';
import { NOTIFICATIONS_BROKER_TOPIC_OBJECT } from '../models/notifications-broker-topic-object.resource-type';
import { FollowLinkConfig } from '../../../../shared/utils/follow-link-config.model';
import { PaginatedList } from '../../../data/paginated-list.model';
@@ -27,7 +27,7 @@ import { PaginatedList } from '../../../data/paginated-list.model';
/**
* A private DataService implementation to delegate specific methods to.
*/
class DataServiceImpl extends DataService<OpenaireBrokerTopicObject> {
class DataServiceImpl extends DataService<NotificationsBrokerTopicObject> {
/**
* The REST endpoint.
*/
@@ -42,7 +42,7 @@ class DataServiceImpl extends DataService<OpenaireBrokerTopicObject> {
* @param {HALEndpointService} halService
* @param {NotificationsService} notificationsService
* @param {HttpClient} http
* @param {ChangeAnalyzer<OpenaireBrokerTopicObject>} comparator
* @param {ChangeAnalyzer<NotificationsBrokerTopicObject>} comparator
*/
constructor(
protected requestService: RequestService,
@@ -52,17 +52,17 @@ class DataServiceImpl extends DataService<OpenaireBrokerTopicObject> {
protected halService: HALEndpointService,
protected notificationsService: NotificationsService,
protected http: HttpClient,
protected comparator: ChangeAnalyzer<OpenaireBrokerTopicObject>) {
protected comparator: ChangeAnalyzer<NotificationsBrokerTopicObject>) {
super();
}
}
/**
* The service handling all OpenAIRE Broker topic REST requests.
* The service handling all Notifications Broker topic REST requests.
*/
@Injectable()
@dataService(OPENAIRE_BROKER_TOPIC_OBJECT)
export class OpenaireBrokerTopicRestService {
@dataService(NOTIFICATIONS_BROKER_TOPIC_OBJECT)
export class NotificationsBrokerTopicRestService {
/**
* A private DataService implementation to delegate specific methods to.
*/
@@ -76,7 +76,7 @@ export class OpenaireBrokerTopicRestService {
* @param {HALEndpointService} halService
* @param {NotificationsService} notificationsService
* @param {HttpClient} http
* @param {DefaultChangeAnalyzer<OpenaireBrokerTopicObject>} comparator
* @param {DefaultChangeAnalyzer<NotificationsBrokerTopicObject>} comparator
*/
constructor(
protected requestService: RequestService,
@@ -85,21 +85,21 @@ export class OpenaireBrokerTopicRestService {
protected halService: HALEndpointService,
protected notificationsService: NotificationsService,
protected http: HttpClient,
protected comparator: DefaultChangeAnalyzer<OpenaireBrokerTopicObject>) {
protected comparator: DefaultChangeAnalyzer<NotificationsBrokerTopicObject>) {
this.dataService = new DataServiceImpl(requestService, rdbService, null, objectCache, halService, notificationsService, http, comparator);
}
/**
* Return the list of OpenAIRE Broker topics.
* Return the list of Notifications Broker topics.
*
* @param options
* Find list options object.
* @param linksToFollow
* List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved.
* @return Observable<RemoteData<PaginatedList<OpenaireBrokerTopicObject>>>
* The list of OpenAIRE Broker topics.
* @return Observable<RemoteData<PaginatedList<NotificationsBrokerTopicObject>>>
* The list of Notifications Broker topics.
*/
public getTopics(options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<OpenaireBrokerTopicObject>[]): Observable<RemoteData<PaginatedList<OpenaireBrokerTopicObject>>> {
public getTopics(options: FindListOptions = {}, ...linksToFollow: FollowLinkConfig<NotificationsBrokerTopicObject>[]): Observable<RemoteData<PaginatedList<NotificationsBrokerTopicObject>>> {
return this.dataService.getBrowseEndpoint(options, 'nbtopics').pipe(
take(1),
mergeMap((href: string) => this.dataService.findAllByHref(href, options, true, true, ...linksToFollow)),
@@ -114,16 +114,16 @@ export class OpenaireBrokerTopicRestService {
}
/**
* Return a single OpenAIRE Broker topic.
* Return a single Notifications Broker topic.
*
* @param id
* The OpenAIRE Broker topic id
* The Notifications Broker topic id
* @param linksToFollow
* List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved.
* @return Observable<RemoteData<OpenaireBrokerTopicObject>>
* The OpenAIRE Broker topic.
* @return Observable<RemoteData<NotificationsBrokerTopicObject>>
* The Notifications Broker topic.
*/
public getTopic(id: string, ...linksToFollow: FollowLinkConfig<OpenaireBrokerTopicObject>[]): Observable<RemoteData<OpenaireBrokerTopicObject>> {
public getTopic(id: string, ...linksToFollow: FollowLinkConfig<NotificationsBrokerTopicObject>[]): Observable<RemoteData<NotificationsBrokerTopicObject>> {
const options = {};
return this.dataService.getBrowseEndpoint(options, 'nbtopics').pipe(
take(1),

View File

@@ -1,12 +1,12 @@
<div class="container">
<div class="row">
<div class="col-12">
<h2 class="border-bottom pb-2">{{'openaire.events.title'| translate}}</h2>
<p>{{'openaire.broker.events.description'| translate}}</p>
<h2 class="border-bottom pb-2">{{'notifications.events.title'| translate}}</h2>
<p>{{'notifications.broker.events.description'| translate}}</p>
<p>
<a class="btn btn-outline-secondary" [routerLink]="['/admin/notifications/openaire-broker']">
<a class="btn btn-outline-secondary" [routerLink]="['/admin/notifications/notifications-broker']">
<i class="fas fa-angle-double-left"></i>
{{'openaire.broker.events.back' | translate}}
{{'notifications.broker.events.back' | translate}}
</a>
</p>
</div>
@@ -14,31 +14,31 @@
<div class="row">
<div class="col-12">
<h3 class="border-bottom pb-2">
{{'openaire.broker.events.topic' | translate}} {{this.showTopic}}
{{'notifications.broker.events.topic' | translate}} {{this.showTopic}}
</h3>
<ds-loading class="container" *ngIf="(isEventPageLoading | async)" message="{{'openaire.broker.loading' | translate}}"></ds-loading>
<ds-loading class="container" *ngIf="(isEventPageLoading | async)" message="{{'notifications.broker.loading' | translate}}"></ds-loading>
<ds-pagination *ngIf="!(isEventPageLoading | async)"
[paginationOptions]="paginationConfig"
[collectionSize]="(totalElements$ | async)"
[sortOptions]="paginationSortConfig"
(paginationChange)="getOpenaireBrokerEvents()">
(paginationChange)="getNotificationsBrokerEvents()">
<ds-loading class="container" *ngIf="(isEventLoading | async)" message="{{'openaire.broker.loading' | translate}}"></ds-loading>
<ds-loading class="container" *ngIf="(isEventLoading | async)" message="{{'notifications.broker.loading' | translate}}"></ds-loading>
<ng-container *ngIf="!(isEventLoading | async)">
<div *ngIf="(eventsUpdated$|async)?.length == 0" class="alert alert-info w-100 mb-2 mt-2" role="alert">
{{'openaire.broker.noEvents' | translate}}
{{'notifications.broker.noEvents' | translate}}
</div>
<div *ngIf="(eventsUpdated$|async)?.length != 0" class="table-responsive mt-2">
<table id="events" class="table table-striped table-hover table-bordered">
<thead>
<tr>
<th scope="col">{{'openaire.broker.event.table.trust' | translate}}</th>
<th scope="col">{{'openaire.broker.event.table.publication' | translate}}</th>
<th *ngIf="hasDetailColumn() && showTopic.indexOf('/PROJECT') == -1" scope="col">{{'openaire.broker.event.table.details' | translate}}</th>
<th *ngIf="hasDetailColumn() && showTopic.indexOf('/PROJECT') !== -1" scope="col">{{'openaire.broker.event.table.project-details' | translate}}</th>
<th scope="col" class="button-rows">{{'openaire.broker.event.table.actions' | translate}}</th>
<th scope="col">{{'notifications.broker.event.table.trust' | translate}}</th>
<th scope="col">{{'notifications.broker.event.table.publication' | translate}}</th>
<th *ngIf="hasDetailColumn() && showTopic.indexOf('/PROJECT') == -1" scope="col">{{'notifications.broker.event.table.details' | translate}}</th>
<th *ngIf="hasDetailColumn() && showTopic.indexOf('/PROJECT') !== -1" scope="col">{{'notifications.broker.event.table.project-details' | translate}}</th>
<th scope="col" class="button-rows">{{'notifications.broker.event.table.actions' | translate}}</th>
</tr>
</thead>
<tbody>
@@ -51,8 +51,8 @@
<span *ngIf="!eventElement?.target">{{eventElement.title}}</span>
</td>
<td *ngIf="showTopic.indexOf('/PID') !== -1">
<p><span class="small">{{'openaire.broker.event.table.pidtype' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.type}}</span></p>
<p><span class="small">{{'openaire.broker.event.table.pidvalue' | translate}}</span><br>
<p><span class="small">{{'notifications.broker.event.table.pidtype' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.type}}</span></p>
<p><span class="small">{{'notifications.broker.event.table.pidvalue' | translate}}</span><br>
<a *ngIf="hasPIDHref(eventElement.event.message); else noPID" href="{{getPIDHref(eventElement.event.message)}}" target="_blank">
{{eventElement.event.message.value}}
</a>
@@ -60,37 +60,37 @@
</p>
</td>
<td *ngIf="showTopic.indexOf('/SUBJECT') !== -1">
<p><span class="small">{{'openaire.broker.event.table.subjectValue' | translate}}</span><br><span class="badge badge-info">{{eventElement.event.message.value}}</span></p>
<p><span class="small">{{'notifications.broker.event.table.subjectValue' | translate}}</span><br><span class="badge badge-info">{{eventElement.event.message.value}}</span></p>
</td>
<td *ngIf="showTopic.indexOf('/ABSTRACT') !== -1">
<p class="abstract-container" [class.show]="showMore">
<span class="small">{{'openaire.broker.event.table.abstract' | translate}}</span><br>
<span class="small">{{'notifications.broker.event.table.abstract' | translate}}</span><br>
<span class="text-ellipsis">{{eventElement.event.message.abstract}}</span>
</p>
<button class="btn btn-outline-primary btn-sm" (click)="showMore = !showMore">
<i *ngIf="!showMore" class="fas fa-angle-down"></i>
<i *ngIf="showMore" class="fas fa-angle-up"></i>
{{ (showMore ? 'openaire.broker.event.table.less': 'openaire.broker.event.table.more') | translate }}
{{ (showMore ? 'notifications.broker.event.table.less': 'notifications.broker.event.table.more') | translate }}
</button>
</td>
<td *ngIf="showTopic.indexOf('/PROJECT') !== -1">
<p>
{{'openaire.broker.event.table.suggestedProject' | translate}}
{{'notifications.broker.event.table.suggestedProject' | translate}}
</p>
<p>
<span class="small">{{'openaire.broker.event.table.project' | translate}}</span><br>
<span class="small">{{'notifications.broker.event.table.project' | translate}}</span><br>
<a href="https://explore.openaire.eu/search/project?projectId={{ eventElement.event.message.openaireId}}" target="_blank">{{eventElement.event.message.title}}</a>
</p>
<p>
<span *ngIf="eventElement.event.message.acronym"><span class="small">{{'openaire.broker.event.table.acronym' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.acronym}}</span><br></span>
<span *ngIf="eventElement.event.message.code"><span class="small">{{'openaire.broker.event.table.code' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.code}}</span><br></span>
<span *ngIf="eventElement.event.message.funder"><span class="small">{{'openaire.broker.event.table.funder' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.funder}}</span><br></span>
<span *ngIf="eventElement.event.message.fundingProgram"><span class="small">{{'openaire.broker.event.table.fundingProgram' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.fundingProgram}}</span><br></span>
<span *ngIf="eventElement.event.message.jurisdiction"><span class="small">{{'openaire.broker.event.table.jurisdiction' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.jurisdiction}}</span></span>
<span *ngIf="eventElement.event.message.acronym"><span class="small">{{'notifications.broker.event.table.acronym' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.acronym}}</span><br></span>
<span *ngIf="eventElement.event.message.code"><span class="small">{{'notifications.broker.event.table.code' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.code}}</span><br></span>
<span *ngIf="eventElement.event.message.funder"><span class="small">{{'notifications.broker.event.table.funder' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.funder}}</span><br></span>
<span *ngIf="eventElement.event.message.fundingProgram"><span class="small">{{'notifications.broker.event.table.fundingProgram' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.fundingProgram}}</span><br></span>
<span *ngIf="eventElement.event.message.jurisdiction"><span class="small">{{'notifications.broker.event.table.jurisdiction' | translate}}</span> <span class="badge badge-info">{{eventElement.event.message.jurisdiction}}</span></span>
</p>
<hr>
<div>
{{(eventElement.hasProject ? 'openaire.broker.event.project.found' : 'openaire.broker.event.project.notFound') | translate}}
{{(eventElement.hasProject ? 'notifications.broker.event.project.found' : 'notifications.broker.event.project.notFound') | translate}}
<a target="_blank" *ngIf="eventElement.hasProject" title="{{eventElement.projectTitle}}" [routerLink]="['/items', eventElement.projectId]">{{eventElement.handle}}</a>
<div class="btn-group">
<button class="btn btn-outline-primary btn-sm"
@@ -114,19 +114,19 @@
[disabled]="eventElement.isRunning"
(click)="modalChoice('ACCEPTED', eventElement, acceptModal)">
<i class="fas fa-check"></i>
<span class="d-none d-sm-inline">{{'openaire.broker.event.action.import' | translate}}</span>
<span class="d-none d-sm-inline">{{'notifications.broker.event.action.import' | translate}}</span>
</button>
<button *ngIf="showTopic.indexOf('/PROJECT') == -1" class="btn btn-outline-success btn-sm button-width" [disabled]="eventElement.isRunning" (click)="executeAction('ACCEPTED', eventElement)">
<i class="fas fa-check"></i>
<span class="d-none d-sm-inline">{{'openaire.broker.event.action.accept' | translate}}</span>
<span class="d-none d-sm-inline">{{'notifications.broker.event.action.accept' | translate}}</span>
</button>
<button class="btn btn-outline-dark btn-sm button-width" [disabled]="eventElement.isRunning" (click)="openModal('DISCARDED', eventElement, ignoreModal)">
<i class="fas fa-trash-alt"></i>
<span class="d-none d-sm-inline">{{'openaire.broker.event.action.ignore' | translate}}</span>
<span class="d-none d-sm-inline">{{'notifications.broker.event.action.ignore' | translate}}</span>
</button>
<button class="btn btn-outline-danger btn-sm button-width" [disabled]="eventElement.isRunning" (click)="openModal('REJECTED', eventElement, rejectModal)">
<i class="fas fa-trash-alt"></i>
<span class="d-none d-sm-inline">{{'openaire.broker.event.action.reject' | translate}}</span>
<span class="d-none d-sm-inline">{{'notifications.broker.event.action.reject' | translate}}</span>
</button>
</div>
</td>
@@ -140,9 +140,9 @@
</div>
<div class="row">
<div class="col-md-12">
<a class="btn btn-outline-secondary" [routerLink]="['/admin/notifications/openaire-broker']">
<a class="btn btn-outline-secondary" [routerLink]="['/admin/notifications/notifications-broker']">
<i class="fas fa-angle-double-left"></i>
{{'openaire.broker.events.back' | translate}}
{{'notifications.broker.events.back' | translate}}
</a>
</div>
</div>
@@ -150,58 +150,58 @@
<ng-template #acceptModal let-modal>
<div class="modal-header">
<h4 class="modal-title" id="acceptModal">{{'openaire.broker.event.sure' | translate}}</h4>
<h4 class="modal-title" id="acceptModal">{{'notifications.broker.event.sure' | translate}}</h4>
</div>
<div class="modal-body">
<p>{{'openaire.broker.event.accept.description' | translate}}</p>
<p>{{'notifications.broker.event.accept.description' | translate}}</p>
<button class="btn btn-outline-success float-left" (click)="modal.close('do')">
<i class="fas fa-check"></i>
<span class="d-none d-sm-inline">{{'openaire.broker.event.action.import' | translate}}</span>
<span class="d-none d-sm-inline">{{'notifications.broker.event.action.import' | translate}}</span>
</button>
<button class="btn btn-outline-secondary float-right" (click)="modal.close('cancel')">
<i class="fas fa-close"></i>
<span class="d-none d-sm-inline">{{'openaire.broker.event.action.cancel' | translate}}</span>
<span class="d-none d-sm-inline">{{'notifications.broker.event.action.cancel' | translate}}</span>
</button>
</div>
</ng-template>
<ng-template #ignoreModal let-modal>
<div class="modal-header">
<h4 class="modal-title" id="ignoreModal">{{'openaire.broker.event.sure' | translate}}</h4>
<h4 class="modal-title" id="ignoreModal">{{'notifications.broker.event.sure' | translate}}</h4>
</div>
<div class="modal-body">
<p>{{'openaire.broker.event.ignore.description' | translate}}</p>
<p>{{'notifications.broker.event.ignore.description' | translate}}</p>
<!-- textarea class="form-control mb-2" [(ngModel)]="selectedReason" placeholder="{{'openaire.broker.event.reason' |translate}}"></textarea -->
<!-- textarea class="form-control mb-2" [(ngModel)]="selectedReason" placeholder="{{'notifications.broker.event.reason' |translate}}"></textarea -->
<button class="btn btn-outline-danger float-left" (click)="modal.close('do')">
<i class="fas fa-trash-alt"></i>
<span class="d-none d-sm-inline">{{'openaire.broker.event.action.ignore' | translate}}</span>
<span class="d-none d-sm-inline">{{'notifications.broker.event.action.ignore' | translate}}</span>
</button>
<button class="btn btn-outline-secondary float-right" (click)="modal.close('cancel')">
<i class="fas fa-close"></i>
<span class="d-none d-sm-inline">{{'openaire.broker.event.action.cancel' | translate}}</span>
<span class="d-none d-sm-inline">{{'notifications.broker.event.action.cancel' | translate}}</span>
</button>
</div>
</ng-template>
<ng-template #rejectModal let-modal>
<div class="modal-header">
<h4 class="modal-title" id="rejectModal">{{'openaire.broker.event.sure' | translate}}</h4>
<h4 class="modal-title" id="rejectModal">{{'notifications.broker.event.sure' | translate}}</h4>
</div>
<div class="modal-body">
<p>{{'openaire.broker.event.reject.description' | translate}}</p>
<p>{{'notifications.broker.event.reject.description' | translate}}</p>
<!-- textarea class="form-control mb-2" [(ngModel)]="selectedReason" placeholder="{{'openaire.broker.event.reason' |translate}}"></textarea -->
<!-- textarea class="form-control mb-2" [(ngModel)]="selectedReason" placeholder="{{'notifications.broker.event.reason' |translate}}"></textarea -->
<button class="btn btn-outline-danger float-left" (click)="modal.close('do')">
<i class="fas fa-trash-alt"></i>
<span class="d-none d-sm-inline">{{'openaire.broker.event.action.reject' | translate}}</span>
<span class="d-none d-sm-inline">{{'notifications.broker.event.action.reject' | translate}}</span>
</button>
<button class="btn btn-outline-secondary float-right" (click)="modal.close('cancel')">
<i class="fas fa-close"></i>
<span class="d-none d-sm-inline">{{'openaire.broker.event.action.cancel' | translate}}</span>
<span class="d-none d-sm-inline">{{'notifications.broker.event.action.cancel' | translate}}</span>
</button>
</div>
</ng-template>

View File

@@ -5,25 +5,25 @@ import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/t
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { of as observableOf } from 'rxjs';
import { OpenaireBrokerEventRestService } from '../../../core/openaire/broker/events/openaire-broker-event-rest.service';
import { OpenaireBrokerEventsComponent } from './openaire-broker-events.component';
import { NotificationsBrokerEventRestService } from '../../../core/notifications/broker/events/notifications-broker-event-rest.service';
import { NotificationsBrokerEventsComponent } from './notifications-broker-events.component';
import {
getMockOpenaireBrokerEventRestService,
getMockNotificationsBrokerEventRestService,
ItemMockPid10,
ItemMockPid8,
ItemMockPid9,
openaireBrokerEventObjectMissingProjectFound,
openaireBrokerEventObjectMissingProjectNotFound,
OpenaireMockDspaceObject
} from '../../../shared/mocks/openaire.mock';
notificationsBrokerEventObjectMissingProjectFound,
notificationsBrokerEventObjectMissingProjectNotFound,
NotificationsMockDspaceObject
} from '../../../shared/mocks/notifications.mock';
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { getMockTranslateService } from '../../../shared/mocks/translate.service.mock';
import { createTestComponent } from '../../../shared/testing/utils.test';
import { ActivatedRouteStub } from '../../../shared/testing/active-router.stub';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { OpenaireBrokerEventObject } from '../../../core/openaire/broker/models/openaire-broker-event.model';
import { OpenaireBrokerEventData } from '../project-entry-import-modal/project-entry-import-modal.component';
import { NotificationsBrokerEventObject } from '../../../core/notifications/broker/models/notifications-broker-event.model';
import { NotificationsBrokerEventData } from '../project-entry-import-modal/project-entry-import-modal.component';
import { TestScheduler } from 'rxjs/testing';
import { getTestScheduler } from 'jasmine-marbles';
import { followLink } from '../../../shared/utils/follow-link-config.model';
@@ -39,9 +39,9 @@ import { SortDirection, SortOptions } from '../../../core/cache/models/sort-opti
import { PaginationService } from '../../../core/pagination/pagination.service';
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
describe('OpenaireBrokerEventsComponent test suite', () => {
let fixture: ComponentFixture<OpenaireBrokerEventsComponent>;
let comp: OpenaireBrokerEventsComponent;
describe('NotificationsBrokerEventsComponent test suite', () => {
let fixture: ComponentFixture<NotificationsBrokerEventsComponent>;
let comp: NotificationsBrokerEventsComponent;
let compAsAny: any;
let scheduler: TestScheduler;
@@ -50,9 +50,9 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
close: () => null,
dismiss: () => null
};
const openaireBrokerEventRestServiceStub: any = getMockOpenaireBrokerEventRestService();
const notificationsBrokerEventRestServiceStub: any = getMockNotificationsBrokerEventRestService();
const activatedRouteParams = {
openaireBrokerEventsParams: {
notificationsBrokerEventsParams: {
currentPage: 0,
pageSize: 10
}
@@ -61,19 +61,19 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
id: 'ENRICH!MISSING!PROJECT'
};
const events: OpenaireBrokerEventObject[] = [
openaireBrokerEventObjectMissingProjectFound,
openaireBrokerEventObjectMissingProjectNotFound
const events: NotificationsBrokerEventObject[] = [
notificationsBrokerEventObjectMissingProjectFound,
notificationsBrokerEventObjectMissingProjectNotFound
];
const paginationService = new PaginationServiceStub();
function getOpenAireBrokerEventData1(): OpenaireBrokerEventData {
function getNotificationsBrokerEventData1(): NotificationsBrokerEventData {
return {
event: openaireBrokerEventObjectMissingProjectFound,
id: openaireBrokerEventObjectMissingProjectFound.id,
title: openaireBrokerEventObjectMissingProjectFound.title,
event: notificationsBrokerEventObjectMissingProjectFound,
id: notificationsBrokerEventObjectMissingProjectFound.id,
title: notificationsBrokerEventObjectMissingProjectFound.title,
hasProject: true,
projectTitle: openaireBrokerEventObjectMissingProjectFound.message.title,
projectTitle: notificationsBrokerEventObjectMissingProjectFound.message.title,
projectId: ItemMockPid10.id,
handle: ItemMockPid10.handle,
reason: null,
@@ -82,11 +82,11 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
};
}
function getOpenAireBrokerEventData2(): OpenaireBrokerEventData {
function getNotificationsBrokerEventData2(): NotificationsBrokerEventData {
return {
event: openaireBrokerEventObjectMissingProjectNotFound,
id: openaireBrokerEventObjectMissingProjectNotFound.id,
title: openaireBrokerEventObjectMissingProjectNotFound.title,
event: notificationsBrokerEventObjectMissingProjectNotFound,
id: notificationsBrokerEventObjectMissingProjectNotFound.id,
title: notificationsBrokerEventObjectMissingProjectNotFound.title,
hasProject: false,
projectTitle: null,
projectId: null,
@@ -104,17 +104,17 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
TranslateModule.forRoot(),
],
declarations: [
OpenaireBrokerEventsComponent,
NotificationsBrokerEventsComponent,
TestComponent,
],
providers: [
{ provide: ActivatedRoute, useValue: new ActivatedRouteStub(activatedRouteParamsMap, activatedRouteParams) },
{ provide: OpenaireBrokerEventRestService, useValue: openaireBrokerEventRestServiceStub },
{ provide: NotificationsBrokerEventRestService, useValue: notificationsBrokerEventRestServiceStub },
{ provide: NgbModal, useValue: modalStub },
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
{ provide: TranslateService, useValue: getMockTranslateService() },
{ provide: PaginationService, useValue: paginationService },
OpenaireBrokerEventsComponent
NotificationsBrokerEventsComponent
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents().then();
@@ -129,7 +129,7 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
// synchronous beforeEach
beforeEach(() => {
const html = `
<ds-openaire-broker-event></ds-openaire-broker-event>`;
<ds-notifications-broker-event></ds-notifications-broker-event>`;
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
testComp = testFixture.componentInstance;
});
@@ -138,14 +138,14 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
testFixture.destroy();
});
it('should create OpenaireBrokerEventsComponent', inject([OpenaireBrokerEventsComponent], (app: OpenaireBrokerEventsComponent) => {
it('should create NotificationsBrokerEventsComponent', inject([NotificationsBrokerEventsComponent], (app: NotificationsBrokerEventsComponent) => {
expect(app).toBeDefined();
}));
});
describe('Main tests', () => {
beforeEach(() => {
fixture = TestBed.createComponent(OpenaireBrokerEventsComponent);
fixture = TestBed.createComponent(NotificationsBrokerEventsComponent);
comp = fixture.componentInstance;
compAsAny = comp;
});
@@ -159,8 +159,8 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
describe('setEventUpdated', () => {
it('should update events', () => {
const expected = [
getOpenAireBrokerEventData1(),
getOpenAireBrokerEventData2()
getNotificationsBrokerEventData1(),
getNotificationsBrokerEventData2()
];
scheduler.schedule(() => {
compAsAny.setEventUpdated(events);
@@ -179,14 +179,14 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
it('should call executeAction if a project is present', () => {
const action = 'ACCEPTED';
comp.modalChoice(action, getOpenAireBrokerEventData1(), modalStub);
expect(comp.executeAction).toHaveBeenCalledWith(action, getOpenAireBrokerEventData1());
comp.modalChoice(action, getNotificationsBrokerEventData1(), modalStub);
expect(comp.executeAction).toHaveBeenCalledWith(action, getNotificationsBrokerEventData1());
});
it('should call openModal if a project is not present', () => {
const action = 'ACCEPTED';
comp.modalChoice(action, getOpenAireBrokerEventData2(), modalStub);
expect(comp.openModal).toHaveBeenCalledWith(action, getOpenAireBrokerEventData2(), modalStub);
comp.modalChoice(action, getNotificationsBrokerEventData2(), modalStub);
expect(comp.openModal).toHaveBeenCalledWith(action, getNotificationsBrokerEventData2(), modalStub);
});
});
@@ -197,7 +197,7 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
spyOn(compAsAny.modalService, 'open').and.returnValue({ result: new Promise((res, rej) => 'do' ) });
spyOn(comp, 'executeAction');
comp.openModal(action, getOpenAireBrokerEventData1(), modalStub);
comp.openModal(action, getNotificationsBrokerEventData1(), modalStub);
expect(compAsAny.modalService.open).toHaveBeenCalled();
});
});
@@ -211,13 +211,13 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
externalSourceEntry: null,
label: null,
importedObject: observableOf({
indexableObject: OpenaireMockDspaceObject
indexableObject: NotificationsMockDspaceObject
})
}
}
);
scheduler.schedule(() => {
comp.openModalLookup(getOpenAireBrokerEventData1());
comp.openModalLookup(getNotificationsBrokerEventData1());
});
scheduler.flush();
@@ -227,27 +227,27 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
});
describe('executeAction', () => {
it('should call getOpenaireBrokerEvents on 200 response from REST', () => {
it('should call getNotificationsBrokerEvents on 200 response from REST', () => {
const action = 'ACCEPTED';
spyOn(compAsAny, 'getOpenaireBrokerEvents');
openaireBrokerEventRestServiceStub.patchEvent.and.returnValue(createSuccessfulRemoteDataObject$({}));
spyOn(compAsAny, 'getNotificationsBrokerEvents');
notificationsBrokerEventRestServiceStub.patchEvent.and.returnValue(createSuccessfulRemoteDataObject$({}));
scheduler.schedule(() => {
comp.executeAction(action, getOpenAireBrokerEventData1());
comp.executeAction(action, getNotificationsBrokerEventData1());
});
scheduler.flush();
expect(compAsAny.getOpenaireBrokerEvents).toHaveBeenCalled();
expect(compAsAny.getNotificationsBrokerEvents).toHaveBeenCalled();
});
});
describe('boundProject', () => {
it('should populate the project data inside "eventData"', () => {
const eventData = getOpenAireBrokerEventData2();
const eventData = getNotificationsBrokerEventData2();
const projectId = 'UUID-23943-34u43-38344';
const projectName = 'Test Project';
const projectHandle = '1000/1000';
openaireBrokerEventRestServiceStub.boundProject.and.returnValue(createSuccessfulRemoteDataObject$({}));
notificationsBrokerEventRestServiceStub.boundProject.and.returnValue(createSuccessfulRemoteDataObject$({}));
scheduler.schedule(() => {
comp.boundProject(eventData, projectId, projectName, projectHandle);
@@ -263,8 +263,8 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
describe('removeProject', () => {
it('should remove the project data inside "eventData"', () => {
const eventData = getOpenAireBrokerEventData1();
openaireBrokerEventRestServiceStub.removeProject.and.returnValue(createNoContentRemoteDataObject$());
const eventData = getNotificationsBrokerEventData1();
notificationsBrokerEventRestServiceStub.removeProject.and.returnValue(createNoContentRemoteDataObject$());
scheduler.schedule(() => {
comp.removeProject(eventData);
@@ -278,8 +278,8 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
});
});
describe('getOpenaireBrokerEvents', () => {
it('should call the "openaireBrokerEventRestService.getEventsByTopic" to take data and "setEventUpdated" to populate eventData', () => {
describe('getNotificationsBrokerEvents', () => {
it('should call the "notificationsBrokerEventRestService.getEventsByTopic" to take data and "setEventUpdated" to populate eventData', () => {
comp.paginationConfig = new PaginationComponentOptions();
comp.paginationConfig.currentPage = 1;
comp.paginationConfig.pageSize = 20;
@@ -297,20 +297,20 @@ describe('OpenaireBrokerEventsComponent test suite', () => {
currentPage: comp.paginationConfig.currentPage
});
const array = [
openaireBrokerEventObjectMissingProjectFound,
openaireBrokerEventObjectMissingProjectNotFound,
notificationsBrokerEventObjectMissingProjectFound,
notificationsBrokerEventObjectMissingProjectNotFound,
];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
openaireBrokerEventRestServiceStub.getEventsByTopic.and.returnValue(observableOf(paginatedListRD));
notificationsBrokerEventRestServiceStub.getEventsByTopic.and.returnValue(observableOf(paginatedListRD));
spyOn(compAsAny, 'setEventUpdated');
scheduler.schedule(() => {
compAsAny.getOpenaireBrokerEvents();
compAsAny.getNotificationsBrokerEvents();
});
scheduler.flush();
expect(compAsAny.openaireBrokerEventRestService.getEventsByTopic).toHaveBeenCalledWith(
expect(compAsAny.notificationsBrokerEventRestService.getEventsByTopic).toHaveBeenCalledWith(
activatedRouteParamsMap.id,
options,
followLink('target'),followLink('related')

View File

@@ -11,10 +11,10 @@ import { PaginatedList } from '../../../core/data/paginated-list.model';
import { RemoteData } from '../../../core/data/remote-data';
import { FindListOptions } from '../../../core/data/request.models';
import {
OpenaireBrokerEventMessageObject,
OpenaireBrokerEventObject
} from '../../../core/openaire/broker/models/openaire-broker-event.model';
import { OpenaireBrokerEventRestService } from '../../../core/openaire/broker/events/openaire-broker-event-rest.service';
NotificationsBrokerEventObject,
OpenaireBrokerEventMessageObject
} from '../../../core/notifications/broker/models/notifications-broker-event.model';
import { NotificationsBrokerEventRestService } from '../../../core/notifications/broker/events/notifications-broker-event-rest.service';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { Metadata } from '../../../core/shared/metadata.utils';
import { followLink } from '../../../shared/utils/follow-link-config.model';
@@ -22,7 +22,7 @@ import { hasValue } from '../../../shared/empty.util';
import { ItemSearchResult } from '../../../shared/object-collection/shared/item-search-result.model';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import {
OpenaireBrokerEventData,
NotificationsBrokerEventData,
ProjectEntryImportModalComponent
} from '../project-entry-import-modal/project-entry-import-modal.component';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
@@ -31,14 +31,14 @@ import { combineLatest } from 'rxjs/internal/observable/combineLatest';
import { Item } from '../../../core/shared/item.model';
/**
* Component to display the OpenAIRE Broker event list.
* Component to display the Notifications Broker event list.
*/
@Component({
selector: 'ds-openaire-broker-events',
templateUrl: './openaire-broker-events.component.html',
styleUrls: ['./openaire-broker-events.scomponent.scss'],
selector: 'ds-notifications-broker-events',
templateUrl: './notifications-broker-events.component.html',
styleUrls: ['./notifications-broker-events.scomponent.scss'],
})
export class OpenaireBrokerEventsComponent implements OnInit {
export class NotificationsBrokerEventsComponent implements OnInit {
/**
* The pagination system configuration for HTML listing.
* @type {PaginationComponentOptions}
@@ -50,27 +50,27 @@ export class OpenaireBrokerEventsComponent implements OnInit {
pageSizeOptions: [5, 10, 20, 40, 60]
});
/**
* The OpenAIRE Broker event list sort options.
* The Notifications Broker event list sort options.
* @type {SortOptions}
*/
public paginationSortConfig: SortOptions = new SortOptions('trust', SortDirection.DESC);
/**
* Array to save the presence of a project inside an OpenAIRE Broker event.
* @type {OpenaireBrokerEventData[]>}
* Array to save the presence of a project inside an Notifications Broker event.
* @type {NotificationsBrokerEventData[]>}
*/
public eventsUpdated$: BehaviorSubject<OpenaireBrokerEventData[]> = new BehaviorSubject([]);
public eventsUpdated$: BehaviorSubject<NotificationsBrokerEventData[]> = new BehaviorSubject([]);
/**
* The total number of OpenAIRE Broker events.
* The total number of Notifications Broker events.
* @type {Observable<number>}
*/
public totalElements$: Observable<number>;
/**
* The topic of the OpenAIRE Broker events; suitable for displaying.
* The topic of the Notifications Broker events; suitable for displaying.
* @type {string}
*/
public showTopic: string;
/**
* The topic of the OpenAIRE Broker events; suitable for HTTP calls.
* The topic of the Notifications Broker events; suitable for HTTP calls.
* @type {string}
*/
public topic: string;
@@ -114,7 +114,7 @@ export class OpenaireBrokerEventsComponent implements OnInit {
* @param {ActivatedRoute} activatedRoute
* @param {NgbModal} modalService
* @param {NotificationsService} notificationsService
* @param {OpenaireBrokerEventRestService} openaireBrokerEventRestService
* @param {NotificationsBrokerEventRestService} notificationsBrokerEventRestService
* @param {PaginationService} paginationService
* @param {TranslateService} translateService
*/
@@ -122,7 +122,7 @@ export class OpenaireBrokerEventsComponent implements OnInit {
private activatedRoute: ActivatedRoute,
private modalService: NgbModal,
private notificationsService: NotificationsService,
private openaireBrokerEventRestService: OpenaireBrokerEventRestService,
private notificationsBrokerEventRestService: NotificationsBrokerEventRestService,
private paginationService: PaginationService,
private translateService: TranslateService
) {
@@ -142,7 +142,7 @@ export class OpenaireBrokerEventsComponent implements OnInit {
this.showTopic = id.replace(regEx, '/');
this.topic = id;
this.isEventPageLoading.next(false);
this.getOpenaireBrokerEvents();
this.getNotificationsBrokerEvents();
});
}
@@ -162,12 +162,12 @@ export class OpenaireBrokerEventsComponent implements OnInit {
*
* @param {string} action
* the action (can be: ACCEPTED, REJECTED, DISCARDED, PENDING)
* @param {OpenaireBrokerEventData} eventData
* the OpenAIRE Broker event data
* @param {NotificationsBrokerEventData} eventData
* the Notifications Broker event data
* @param {any} content
* Reference to the modal
*/
public modalChoice(action: string, eventData: OpenaireBrokerEventData, content: any): void {
public modalChoice(action: string, eventData: NotificationsBrokerEventData, content: any): void {
if (eventData.hasProject) {
this.executeAction(action, eventData);
} else {
@@ -180,12 +180,12 @@ export class OpenaireBrokerEventsComponent implements OnInit {
*
* @param {string} action
* the action (can be: ACCEPTED, REJECTED, DISCARDED, PENDING)
* @param {OpenaireBrokerEventData} eventData
* the OpenAIRE Broker event data
* @param {NotificationsBrokerEventData} eventData
* the Notifications Broker event data
* @param {any} content
* Reference to the modal
*/
public openModal(action: string, eventData: OpenaireBrokerEventData, content: any): void {
public openModal(action: string, eventData: NotificationsBrokerEventData, content: any): void {
this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then(
(result) => {
if (result === 'do') {
@@ -203,10 +203,10 @@ export class OpenaireBrokerEventsComponent implements OnInit {
/**
* Open a modal where the user can select the project.
*
* @param {OpenaireBrokerEventData} eventData
* the OpenAIRE Broker event item data
* @param {NotificationsBrokerEventData} eventData
* the Notifications Broker event item data
*/
public openModalLookup(eventData: OpenaireBrokerEventData): void {
public openModalLookup(eventData: NotificationsBrokerEventData): void {
this.modalRef = this.modalService.open(ProjectEntryImportModalComponent, {
size: 'lg'
});
@@ -232,22 +232,22 @@ export class OpenaireBrokerEventsComponent implements OnInit {
*
* @param {string} action
* the action (can be: ACCEPTED, REJECTED, DISCARDED, PENDING)
* @param {OpenaireBrokerEventData} eventData
* the OpenAIRE Broker event data
* @param {NotificationsBrokerEventData} eventData
* the Notifications Broker event data
*/
public executeAction(action: string, eventData: OpenaireBrokerEventData): void {
public executeAction(action: string, eventData: NotificationsBrokerEventData): void {
eventData.isRunning = true;
this.subs.push(
this.openaireBrokerEventRestService.patchEvent(action, eventData.event, eventData.reason).pipe(getFirstCompletedRemoteData())
.subscribe((rd: RemoteData<OpenaireBrokerEventObject>) => {
this.notificationsBrokerEventRestService.patchEvent(action, eventData.event, eventData.reason).pipe(getFirstCompletedRemoteData())
.subscribe((rd: RemoteData<NotificationsBrokerEventObject>) => {
if (rd.isSuccess && rd.statusCode === 200) {
this.notificationsService.success(
this.translateService.instant('openaire.broker.event.action.saved')
this.translateService.instant('notifications.broker.event.action.saved')
);
this.getOpenaireBrokerEvents();
this.getNotificationsBrokerEvents();
} else {
this.notificationsService.error(
this.translateService.instant('openaire.broker.event.action.error')
this.translateService.instant('notifications.broker.event.action.error')
);
}
eventData.isRunning = false;
@@ -256,10 +256,10 @@ export class OpenaireBrokerEventsComponent implements OnInit {
}
/**
* Bound a project to the publication described in the OpenAIRE Broker event calling the REST service.
* Bound a project to the publication described in the Notifications Broker event calling the REST service.
*
* @param {OpenaireBrokerEventData} eventData
* the OpenAIRE Broker event item data
* @param {NotificationsBrokerEventData} eventData
* the Notifications Broker event item data
* @param {string} projectId
* the project Id to bound
* @param {string} projectTitle
@@ -267,14 +267,14 @@ export class OpenaireBrokerEventsComponent implements OnInit {
* @param {string} projectHandle
* the project handle
*/
public boundProject(eventData: OpenaireBrokerEventData, projectId: string, projectTitle: string, projectHandle: string): void {
public boundProject(eventData: NotificationsBrokerEventData, projectId: string, projectTitle: string, projectHandle: string): void {
eventData.isRunning = true;
this.subs.push(
this.openaireBrokerEventRestService.boundProject(eventData.id, projectId).pipe(getFirstCompletedRemoteData())
.subscribe((rd: RemoteData<OpenaireBrokerEventObject>) => {
this.notificationsBrokerEventRestService.boundProject(eventData.id, projectId).pipe(getFirstCompletedRemoteData())
.subscribe((rd: RemoteData<NotificationsBrokerEventObject>) => {
if (rd.isSuccess) {
this.notificationsService.success(
this.translateService.instant('openaire.broker.event.project.bounded')
this.translateService.instant('notifications.broker.event.project.bounded')
);
eventData.hasProject = true;
eventData.projectTitle = projectTitle;
@@ -282,7 +282,7 @@ export class OpenaireBrokerEventsComponent implements OnInit {
eventData.projectId = projectId;
} else {
this.notificationsService.error(
this.translateService.instant('openaire.broker.event.project.error')
this.translateService.instant('notifications.broker.event.project.error')
);
}
eventData.isRunning = false;
@@ -291,19 +291,19 @@ export class OpenaireBrokerEventsComponent implements OnInit {
}
/**
* Remove the bounded project from the publication described in the OpenAIRE Broker event calling the REST service.
* Remove the bounded project from the publication described in the Notifications Broker event calling the REST service.
*
* @param {OpenaireBrokerEventData} eventData
* the OpenAIRE Broker event data
* @param {NotificationsBrokerEventData} eventData
* the Notifications Broker event data
*/
public removeProject(eventData: OpenaireBrokerEventData): void {
public removeProject(eventData: NotificationsBrokerEventData): void {
eventData.isRunning = true;
this.subs.push(
this.openaireBrokerEventRestService.removeProject(eventData.id).pipe(getFirstCompletedRemoteData())
.subscribe((rd: RemoteData<OpenaireBrokerEventObject>) => {
this.notificationsBrokerEventRestService.removeProject(eventData.id).pipe(getFirstCompletedRemoteData())
.subscribe((rd: RemoteData<NotificationsBrokerEventObject>) => {
if (rd.isSuccess) {
this.notificationsService.success(
this.translateService.instant('openaire.broker.event.project.removed')
this.translateService.instant('notifications.broker.event.project.removed')
);
eventData.hasProject = false;
eventData.projectTitle = null;
@@ -311,7 +311,7 @@ export class OpenaireBrokerEventsComponent implements OnInit {
eventData.projectId = null;
} else {
this.notificationsService.error(
this.translateService.instant('openaire.broker.event.project.error')
this.translateService.instant('notifications.broker.event.project.error')
);
}
eventData.isRunning = false;
@@ -337,26 +337,26 @@ export class OpenaireBrokerEventsComponent implements OnInit {
/**
* Dispatch the OpenAIRE Broker events retrival.
* Dispatch the Notifications Broker events retrival.
*/
public getOpenaireBrokerEvents(): void {
public getNotificationsBrokerEvents(): void {
this.paginationService.getFindListOptions(this.paginationConfig.id, this.defaultConfig).pipe(
distinctUntilChanged(),
switchMap((options: FindListOptions) => this.openaireBrokerEventRestService.getEventsByTopic(
switchMap((options: FindListOptions) => this.notificationsBrokerEventRestService.getEventsByTopic(
this.topic,
options,
followLink('target'), followLink('related')
)),
getFirstCompletedRemoteData(),
).subscribe((rd: RemoteData<PaginatedList<OpenaireBrokerEventObject>>) => {
).subscribe((rd: RemoteData<PaginatedList<NotificationsBrokerEventObject>>) => {
if (rd.hasSucceeded) {
this.isEventLoading.next(false);
this.totalElements$ = observableOf(rd.payload.totalElements);
this.setEventUpdated(rd.payload.page);
} else {
throw new Error('Can\'t retrieve OpenAIRE Broker events from the Broker events REST service');
throw new Error('Can\'t retrieve Notifications Broker events from the Broker events REST service');
}
this.openaireBrokerEventRestService.clearFindByTopicRequests();
this.notificationsBrokerEventRestService.clearFindByTopicRequests();
});
}
@@ -370,15 +370,15 @@ export class OpenaireBrokerEventsComponent implements OnInit {
}
/**
* Set the project status for the OpenAIRE Broker events.
* Set the project status for the Notifications Broker events.
*
* @param {OpenaireBrokerEventObject[]} events
* the OpenAIRE Broker event item
* @param {NotificationsBrokerEventObject[]} events
* the Notifications Broker event item
*/
protected setEventUpdated(events: OpenaireBrokerEventObject[]): void {
protected setEventUpdated(events: NotificationsBrokerEventObject[]): void {
this.subs.push(
from(events).pipe(
mergeMap((event: OpenaireBrokerEventObject) => {
mergeMap((event: NotificationsBrokerEventObject) => {
const related$ = event.related.pipe(
getFirstCompletedRemoteData(),
);
@@ -387,7 +387,7 @@ export class OpenaireBrokerEventsComponent implements OnInit {
);
return combineLatest([related$, target$]).pipe(
map(([relatedItemRD, targetItemRD]: [RemoteData<Item>, RemoteData<Item>]) => {
const data: OpenaireBrokerEventData = {
const data: NotificationsBrokerEventData = {
event: event,
id: event.id,
title: event.title,

View File

@@ -17,16 +17,16 @@ import { buildPaginatedList } from '../../../core/data/paginated-list.model';
import { PageInfo } from '../../../core/shared/page-info.model';
import {
ItemMockPid10,
openaireBrokerEventObjectMissingProjectFound,
OpenaireMockDspaceObject
} from '../../../shared/mocks/openaire.mock';
notificationsBrokerEventObjectMissingProjectFound,
NotificationsMockDspaceObject
} from '../../../shared/mocks/notifications.mock';
const eventData = {
event: openaireBrokerEventObjectMissingProjectFound,
id: openaireBrokerEventObjectMissingProjectFound.id,
title: openaireBrokerEventObjectMissingProjectFound.title,
event: notificationsBrokerEventObjectMissingProjectFound,
id: notificationsBrokerEventObjectMissingProjectFound.id,
title: notificationsBrokerEventObjectMissingProjectFound.title,
hasProject: true,
projectTitle: openaireBrokerEventObjectMissingProjectFound.message.title,
projectTitle: notificationsBrokerEventObjectMissingProjectFound.message.title,
projectId: ItemMockPid10.id,
handle: ItemMockPid10.handle,
reason: null,
@@ -36,7 +36,7 @@ const eventData = {
const searchString = 'Test project to search';
const pagination = Object.assign(
new PaginationComponentOptions(), {
id: 'openaire-project-bound',
id: 'notifications-project-bound',
pageSize: 3
}
);
@@ -54,7 +54,7 @@ const pageInfo = new PageInfo({
currentPage: 1
});
const array = [
OpenaireMockDspaceObject,
NotificationsMockDspaceObject,
];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
@@ -143,7 +143,7 @@ describe('ProjectEntryImportModalComponent test suite', () => {
spyOn(comp, 'deselectAllLists');
spyOn(comp, 'close');
spyOn(comp.importedObject, 'emit');
comp.selectedEntity = OpenaireMockDspaceObject;
comp.selectedEntity = NotificationsMockDspaceObject;
comp.bound();
expect(comp.importedObject.emit).toHaveBeenCalled();

View File

@@ -12,7 +12,11 @@ import { ListableObject } from '../../../shared/object-collection/shared/listabl
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { SearchService } from '../../../core/shared/search/search.service';
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
import { OpenaireBrokerEventObject } from '../../../core/openaire/broker/models/openaire-broker-event.model';
import {
NotificationsBrokerEventObject,
NotificationsBrokerEventMessageObject,
OpenaireBrokerEventMessageObject,
} from '../../../core/notifications/broker/models/notifications-broker-event.model';
import { hasValue, isNotEmpty } from '../../../shared/empty.util';
import { Item } from '../../../core/shared/item.model';
@@ -30,13 +34,13 @@ export enum ImportType {
/**
* The data type passed from the parent page
*/
export interface OpenaireBrokerEventData {
export interface NotificationsBrokerEventData {
/**
* The OpenAIRE Broker event
* The Notifications Broker event
*/
event: OpenaireBrokerEventObject;
event: NotificationsBrokerEventObject;
/**
* The OpenAIRE Broker event Id (uuid)
* The Notifications Broker event Id (uuid)
*/
id: string;
/**
@@ -79,14 +83,14 @@ export interface OpenaireBrokerEventData {
templateUrl: './project-entry-import-modal.component.html'
})
/**
* Component to display a modal window for linking a project to an OpenAIRE Broker event
* Component to display a modal window for linking a project to an Notifications Broker event
* Shows information about the selected project and a selectable list.
*/
export class ProjectEntryImportModalComponent implements OnInit {
/**
* The external source entry
*/
@Input() externalSourceEntry: OpenaireBrokerEventData;
@Input() externalSourceEntry: NotificationsBrokerEventData;
/**
* The number of results per page
*/
@@ -94,7 +98,7 @@ export class ProjectEntryImportModalComponent implements OnInit {
/**
* The prefix for every i18n key within this modal
*/
labelPrefix = 'openaire.broker.event.modal.';
labelPrefix = 'notifications.broker.event.modal.';
/**
* The search configuration to retrieve project
*/
@@ -126,11 +130,11 @@ export class ProjectEntryImportModalComponent implements OnInit {
/**
* List ID for selecting local entities
*/
entityListId = 'openaire-project-bound';
entityListId = 'notifications-project-bound';
/**
* List ID for selecting local authorities
*/
authorityListId = 'openaire-project-bound-authority';
authorityListId = 'notifications-project-bound-authority';
/**
* ImportType enum
*/
@@ -175,8 +179,9 @@ export class ProjectEntryImportModalComponent implements OnInit {
* Component intitialization.
*/
public ngOnInit(): void {
this.pagination = Object.assign(new PaginationComponentOptions(), { id: 'openaire-project-bound', pageSize: this.pageSize });
this.projectTitle = (this.externalSourceEntry.projectTitle !== null) ? this.externalSourceEntry.projectTitle : this.externalSourceEntry.event.message.title;
this.pagination = Object.assign(new PaginationComponentOptions(), { id: 'notifications-project-bound', pageSize: this.pageSize });
this.projectTitle = (this.externalSourceEntry.projectTitle !== null) ? this.externalSourceEntry.projectTitle
: (this.externalSourceEntry.event.message as OpenaireBrokerEventMessageObject).title;
this.searchOptions = Object.assign(new PaginatedSearchOptions(
{
configuration: this.configuration,

View File

@@ -1,6 +1,6 @@
import { Action } from '@ngrx/store';
import { type } from '../../../shared/ngrx/type';
import { OpenaireBrokerTopicObject } from '../../../core/openaire/broker/models/openaire-broker-topic.model';
import { NotificationsBrokerTopicObject } from '../../../core/notifications/broker/models/notifications-broker-topic.model';
/**
* For each action type in an action group, make a simple
@@ -10,19 +10,19 @@ import { OpenaireBrokerTopicObject } from '../../../core/openaire/broker/models/
* literal types and runs a simple check to guarantee all
* action types in the application are unique.
*/
export const OpenaireBrokerTopicActionTypes = {
ADD_TOPICS: type('dspace/integration/openaire/broker/topic/ADD_TOPICS'),
RETRIEVE_ALL_TOPICS: type('dspace/integration/openaire/broker/topic/RETRIEVE_ALL_TOPICS'),
RETRIEVE_ALL_TOPICS_ERROR: type('dspace/integration/openaire/broker/topic/RETRIEVE_ALL_TOPICS_ERROR'),
export const NotificationsBrokerTopicActionTypes = {
ADD_TOPICS: type('dspace/integration/notifications/broker/topic/ADD_TOPICS'),
RETRIEVE_ALL_TOPICS: type('dspace/integration/notifications/broker/topic/RETRIEVE_ALL_TOPICS'),
RETRIEVE_ALL_TOPICS_ERROR: type('dspace/integration/notifications/broker/topic/RETRIEVE_ALL_TOPICS_ERROR'),
};
/* tslint:disable:max-classes-per-file */
/**
* An ngrx action to retrieve all the OpenAIRE Broker topics.
* An ngrx action to retrieve all the Notifications Broker topics.
*/
export class RetrieveAllTopicsAction implements Action {
type = OpenaireBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS;
type = NotificationsBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS;
payload: {
elementsPerPage: number;
currentPage: number;
@@ -45,20 +45,20 @@ export class RetrieveAllTopicsAction implements Action {
}
/**
* An ngrx action for retrieving 'all OpenAIRE Broker topics' error.
* An ngrx action for retrieving 'all Notifications Broker topics' error.
*/
export class RetrieveAllTopicsErrorAction implements Action {
type = OpenaireBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS_ERROR;
type = NotificationsBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS_ERROR;
}
/**
* An ngrx action to load the OpenAIRE Broker topic objects.
* An ngrx action to load the Notifications Broker topic objects.
* Called by the ??? effect.
*/
export class AddTopicsAction implements Action {
type = OpenaireBrokerTopicActionTypes.ADD_TOPICS;
type = NotificationsBrokerTopicActionTypes.ADD_TOPICS;
payload: {
topics: OpenaireBrokerTopicObject[];
topics: NotificationsBrokerTopicObject[];
totalPages: number;
currentPage: number;
totalElements: number;
@@ -74,9 +74,9 @@ export class AddTopicsAction implements Action {
* @param currentPage
* the current page
* @param totalElements
* the total available OpenAIRE Broker topics
* the total available Notifications Broker topics
*/
constructor(topics: OpenaireBrokerTopicObject[], totalPages: number, currentPage: number, totalElements: number) {
constructor(topics: NotificationsBrokerTopicObject[], totalPages: number, currentPage: number, totalElements: number) {
this.payload = {
topics,
totalPages,
@@ -93,7 +93,7 @@ export class AddTopicsAction implements Action {
* Export a type alias of all actions in this action group
* so that reducers can easily compose action types.
*/
export type OpenaireBrokerTopicsActions
export type NotificationsBrokerTopicsActions
= AddTopicsAction
|RetrieveAllTopicsAction
|RetrieveAllTopicsErrorAction;

View File

@@ -1,34 +1,34 @@
<div class="container">
<div class="row">
<div class="col-12">
<h2 class="border-bottom pb-2">{{'openaire.broker.title'| translate}}</h2>
<p>{{'openaire.broker.topics.description'| translate}}</p>
<h2 class="border-bottom pb-2">{{'notifications.broker.title'| translate}}</h2>
<p>{{'notifications.broker.topics.description'| translate}}</p>
</div>
</div>
<div class="row">
<div class="col-12">
<h3 class="border-bottom pb-2">{{'openaire.broker.topics'| translate}}</h3>
<h3 class="border-bottom pb-2">{{'notifications.broker.topics'| translate}}</h3>
<ds-loading class="container" *ngIf="(isTopicsLoading() | async)" message="{{'openaire.broker.loading' | translate}}"></ds-loading>
<ds-loading class="container" *ngIf="(isTopicsLoading() | async)" message="{{'notifications.broker.loading' | translate}}"></ds-loading>
<ds-pagination *ngIf="!(isTopicsLoading() | async)"
[paginationOptions]="paginationConfig"
[collectionSize]="(totalElements$ | async)"
[hideGear]="false"
[hideSortOptions]="true"
(paginationChange)="getOpenaireBrokerTopics()">
(paginationChange)="getNotificationsBrokerTopics()">
<ds-loading class="container" *ngIf="(isTopicsProcessing() | async)" message="'openaire.broker.loading' | translate"></ds-loading>
<ds-loading class="container" *ngIf="(isTopicsProcessing() | async)" message="'notifications.broker.loading' | translate"></ds-loading>
<ng-container *ngIf="!(isTopicsProcessing() | async)">
<div *ngIf="(topics$|async)?.length == 0" class="alert alert-info w-100 mb-2 mt-2" role="alert">
{{'openaire.broker.noTopics' | translate}}
{{'notifications.broker.noTopics' | translate}}
</div>
<div *ngIf="(topics$|async)?.length != 0" class="table-responsive mt-2">
<table id="epeople" class="table table-striped table-hover table-bordered">
<thead>
<tr>
<th scope="col">{{'openaire.broker.table.topic' | translate}}</th>
<th scope="col">{{'openaire.broker.table.last-event' | translate}}</th>
<th scope="col">{{'openaire.broker.table.actions' | translate}}</th>
<th scope="col">{{'notifications.broker.table.topic' | translate}}</th>
<th scope="col">{{'notifications.broker.table.last-event' | translate}}</th>
<th scope="col">{{'notifications.broker.table.actions' | translate}}</th>
</tr>
</thead>
<tbody>
@@ -39,7 +39,7 @@
<div class="btn-group edit-field">
<button
class="btn btn-outline-primary btn-sm"
title="{{'openaire.broker.button.detail' | translate }}"
title="{{'notifications.broker.button.detail' | translate }}"
[routerLink]="[topicElement.id]">
<span class="badge badge-info">{{topicElement.totalEvents}}</span>
<i class="fas fa-info fa-fw"></i>

View File

@@ -6,23 +6,23 @@ import { of as observableOf } from 'rxjs';
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
import { createTestComponent } from '../../../shared/testing/utils.test';
import {
getMockOpenaireStateService,
openaireBrokerTopicObjectMoreAbstract,
openaireBrokerTopicObjectMorePid
} from '../../../shared/mocks/openaire.mock';
import { OpenaireBrokerTopicsComponent } from './openaire-broker-topics.component';
import { OpenaireStateService } from '../../openaire-state.service';
getMockNotificationsStateService,
notificationsBrokerTopicObjectMoreAbstract,
notificationsBrokerTopicObjectMorePid
} from '../../../shared/mocks/notifications.mock';
import { NotificationsBrokerTopicsComponent } from './notifications-broker-topics.component';
import { NotificationsStateService } from '../../notifications-state.service';
import { cold } from 'jasmine-marbles';
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
import { PaginationService } from '../../../core/pagination/pagination.service';
describe('OpenaireBrokerTopicsComponent test suite', () => {
let fixture: ComponentFixture<OpenaireBrokerTopicsComponent>;
let comp: OpenaireBrokerTopicsComponent;
describe('NotificationsBrokerTopicsComponent test suite', () => {
let fixture: ComponentFixture<NotificationsBrokerTopicsComponent>;
let comp: NotificationsBrokerTopicsComponent;
let compAsAny: any;
const mockOpenaireStateService = getMockOpenaireStateService();
const mockNotificationsStateService = getMockNotificationsStateService();
const activatedRouteParams = {
openaireBrokerTopicsParams: {
notificationsBrokerTopicsParams: {
currentPage: 0,
pageSize: 5
}
@@ -36,27 +36,27 @@ describe('OpenaireBrokerTopicsComponent test suite', () => {
TranslateModule.forRoot(),
],
declarations: [
OpenaireBrokerTopicsComponent,
NotificationsBrokerTopicsComponent,
TestComponent,
],
providers: [
{ provide: OpenaireStateService, useValue: mockOpenaireStateService },
{ provide: NotificationsStateService, useValue: mockNotificationsStateService },
{ provide: ActivatedRoute, useValue: { data: observableOf(activatedRouteParams), params: observableOf({}) } },
{ provide: PaginationService, useValue: paginationService },
OpenaireBrokerTopicsComponent
NotificationsBrokerTopicsComponent
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents().then(() => {
mockOpenaireStateService.getOpenaireBrokerTopics.and.returnValue(observableOf([
openaireBrokerTopicObjectMorePid,
openaireBrokerTopicObjectMoreAbstract
mockNotificationsStateService.getNotificationsBrokerTopics.and.returnValue(observableOf([
notificationsBrokerTopicObjectMorePid,
notificationsBrokerTopicObjectMoreAbstract
]));
mockOpenaireStateService.getOpenaireBrokerTopicsTotalPages.and.returnValue(observableOf(1));
mockOpenaireStateService.getOpenaireBrokerTopicsCurrentPage.and.returnValue(observableOf(0));
mockOpenaireStateService.getOpenaireBrokerTopicsTotals.and.returnValue(observableOf(2));
mockOpenaireStateService.isOpenaireBrokerTopicsLoaded.and.returnValue(observableOf(true));
mockOpenaireStateService.isOpenaireBrokerTopicsLoading.and.returnValue(observableOf(false));
mockOpenaireStateService.isOpenaireBrokerTopicsProcessing.and.returnValue(observableOf(false));
mockNotificationsStateService.getNotificationsBrokerTopicsTotalPages.and.returnValue(observableOf(1));
mockNotificationsStateService.getNotificationsBrokerTopicsCurrentPage.and.returnValue(observableOf(0));
mockNotificationsStateService.getNotificationsBrokerTopicsTotals.and.returnValue(observableOf(2));
mockNotificationsStateService.isNotificationsBrokerTopicsLoaded.and.returnValue(observableOf(true));
mockNotificationsStateService.isNotificationsBrokerTopicsLoading.and.returnValue(observableOf(false));
mockNotificationsStateService.isNotificationsBrokerTopicsProcessing.and.returnValue(observableOf(false));
});
}));
@@ -68,7 +68,7 @@ describe('OpenaireBrokerTopicsComponent test suite', () => {
// synchronous beforeEach
beforeEach(() => {
const html = `
<ds-openaire-broker-topic></ds-openaire-broker-topic>`;
<ds-notifications-broker-topic></ds-notifications-broker-topic>`;
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
testComp = testFixture.componentInstance;
});
@@ -77,14 +77,14 @@ describe('OpenaireBrokerTopicsComponent test suite', () => {
testFixture.destroy();
});
it('should create OpenaireBrokerTopicsComponent', inject([OpenaireBrokerTopicsComponent], (app: OpenaireBrokerTopicsComponent) => {
it('should create NotificationsBrokerTopicsComponent', inject([NotificationsBrokerTopicsComponent], (app: NotificationsBrokerTopicsComponent) => {
expect(app).toBeDefined();
}));
});
describe('Main tests running with two topics', () => {
beforeEach(() => {
fixture = TestBed.createComponent(OpenaireBrokerTopicsComponent);
fixture = TestBed.createComponent(NotificationsBrokerTopicsComponent);
comp = fixture.componentInstance;
compAsAny = comp;
@@ -102,8 +102,8 @@ describe('OpenaireBrokerTopicsComponent test suite', () => {
expect(comp.topics$).toBeObservable(cold('(a|)', {
a: [
openaireBrokerTopicObjectMorePid,
openaireBrokerTopicObjectMoreAbstract
notificationsBrokerTopicObjectMorePid,
notificationsBrokerTopicObjectMoreAbstract
]
}));
expect(comp.totalElements$).toBeObservable(cold('(a|)', {
@@ -112,12 +112,12 @@ describe('OpenaireBrokerTopicsComponent test suite', () => {
});
it(('Should set data properly after the view init'), () => {
spyOn(compAsAny, 'getOpenaireBrokerTopics');
spyOn(compAsAny, 'getNotificationsBrokerTopics');
comp.ngAfterViewInit();
fixture.detectChanges();
expect(compAsAny.getOpenaireBrokerTopics).toHaveBeenCalled();
expect(compAsAny.getNotificationsBrokerTopics).toHaveBeenCalled();
});
it(('isTopicsLoading should return FALSE'), () => {
@@ -132,12 +132,12 @@ describe('OpenaireBrokerTopicsComponent test suite', () => {
}));
});
it(('getOpenaireBrokerTopics should call the service to dispatch a STATE change'), () => {
it(('getNotificationsBrokerTopics should call the service to dispatch a STATE change'), () => {
comp.ngOnInit();
fixture.detectChanges();
compAsAny.openaireStateService.dispatchRetrieveOpenaireBrokerTopics(comp.paginationConfig.pageSize, comp.paginationConfig.currentPage).and.callThrough();
expect(compAsAny.openaireStateService.dispatchRetrieveOpenaireBrokerTopics).toHaveBeenCalledWith(comp.paginationConfig.pageSize, comp.paginationConfig.currentPage);
compAsAny.notificationsStateService.dispatchRetrieveNotificationsBrokerTopics(comp.paginationConfig.pageSize, comp.paginationConfig.currentPage).and.callThrough();
expect(compAsAny.notificationsStateService.dispatchRetrieveNotificationsBrokerTopics).toHaveBeenCalledWith(comp.paginationConfig.pageSize, comp.paginationConfig.currentPage);
});
});
});

View File

@@ -4,22 +4,22 @@ import { Observable, Subscription } from 'rxjs';
import { distinctUntilChanged, take } from 'rxjs/operators';
import { SortOptions } from '../../../core/cache/models/sort-options.model';
import { OpenaireBrokerTopicObject } from '../../../core/openaire/broker/models/openaire-broker-topic.model';
import { NotificationsBrokerTopicObject } from '../../../core/notifications/broker/models/notifications-broker-topic.model';
import { hasValue } from '../../../shared/empty.util';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { OpenaireStateService } from '../../openaire-state.service';
import { AdminNotificationsOpenaireTopicsPageParams } from '../../../admin/admin-notifications/admin-notifications-openaire-topics-page/admin-notifications-openaire-topics-page-resolver.service';
import { NotificationsStateService } from '../../notifications-state.service';
import { AdminNotificationsBrokerTopicsPageParams } from '../../../admin/admin-notifications/admin-notifications-broker-topics-page/admin-notifications-broker-topics-page-resolver.service';
import { PaginationService } from '../../../core/pagination/pagination.service';
/**
* Component to display the OpenAIRE Broker topic list.
* Component to display the Notifications Broker topic list.
*/
@Component({
selector: 'ds-openaire-broker-topic',
templateUrl: './openaire-broker-topics.component.html',
styleUrls: ['./openaire-broker-topics.component.scss'],
selector: 'ds-notifications-broker-topic',
templateUrl: './notifications-broker-topics.component.html',
styleUrls: ['./notifications-broker-topics.component.scss'],
})
export class OpenaireBrokerTopicsComponent implements OnInit {
export class NotificationsBrokerTopicsComponent implements OnInit {
/**
* The pagination system configuration for HTML listing.
* @type {PaginationComponentOptions}
@@ -30,16 +30,16 @@ export class OpenaireBrokerTopicsComponent implements OnInit {
pageSizeOptions: [5, 10, 20, 40, 60]
});
/**
* The OpenAIRE Broker topic list sort options.
* The Notifications Broker topic list sort options.
* @type {SortOptions}
*/
public paginationSortConfig: SortOptions;
/**
* The OpenAIRE Broker topic list.
* The Notifications Broker topic list.
*/
public topics$: Observable<OpenaireBrokerTopicObject[]>;
public topics$: Observable<NotificationsBrokerTopicObject[]>;
/**
* The total number of OpenAIRE Broker topics.
* The total number of Notifications Broker topics.
*/
public totalElements$: Observable<number>;
/**
@@ -51,62 +51,62 @@ export class OpenaireBrokerTopicsComponent implements OnInit {
/**
* Initialize the component variables.
* @param {PaginationService} paginationService
* @param {OpenaireStateService} openaireStateService
* @param {NotificationsStateService} notificationsStateService
*/
constructor(
private paginationService: PaginationService,
private openaireStateService: OpenaireStateService,
private notificationsStateService: NotificationsStateService,
) { }
/**
* Component initialization.
*/
ngOnInit(): void {
this.topics$ = this.openaireStateService.getOpenaireBrokerTopics();
this.totalElements$ = this.openaireStateService.getOpenaireBrokerTopicsTotals();
this.topics$ = this.notificationsStateService.getNotificationsBrokerTopics();
this.totalElements$ = this.notificationsStateService.getNotificationsBrokerTopicsTotals();
}
/**
* First OpenAIRE Broker topics loading after view initialization.
* First Notifications Broker topics loading after view initialization.
*/
ngAfterViewInit(): void {
this.subs.push(
this.openaireStateService.isOpenaireBrokerTopicsLoaded().pipe(
this.notificationsStateService.isNotificationsBrokerTopicsLoaded().pipe(
take(1)
).subscribe(() => {
this.getOpenaireBrokerTopics();
this.getNotificationsBrokerTopics();
})
);
}
/**
* Returns the information about the loading status of the OpenAIRE Broker topics (if it's running or not).
* Returns the information about the loading status of the Notifications Broker topics (if it's running or not).
*
* @return Observable<boolean>
* 'true' if the topics are loading, 'false' otherwise.
*/
public isTopicsLoading(): Observable<boolean> {
return this.openaireStateService.isOpenaireBrokerTopicsLoading();
return this.notificationsStateService.isNotificationsBrokerTopicsLoading();
}
/**
* Returns the information about the processing status of the OpenAIRE Broker topics (if it's running or not).
* Returns the information about the processing status of the Notifications Broker topics (if it's running or not).
*
* @return Observable<boolean>
* 'true' if there are operations running on the topics (ex.: a REST call), 'false' otherwise.
*/
public isTopicsProcessing(): Observable<boolean> {
return this.openaireStateService.isOpenaireBrokerTopicsProcessing();
return this.notificationsStateService.isNotificationsBrokerTopicsProcessing();
}
/**
* Dispatch the OpenAIRE Broker topics retrival.
* Dispatch the Notifications Broker topics retrival.
*/
public getOpenaireBrokerTopics(): void {
public getNotificationsBrokerTopics(): void {
this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig).pipe(
distinctUntilChanged(),
).subscribe((options: PaginationComponentOptions) => {
this.openaireStateService.dispatchRetrieveOpenaireBrokerTopics(
this.notificationsStateService.dispatchRetrieveNotificationsBrokerTopics(
options.pageSize,
options.currentPage
);
@@ -118,7 +118,7 @@ export class OpenaireBrokerTopicsComponent implements OnInit {
*
* @param eventsRouteParams
*/
protected updatePaginationFromRouteParams(eventsRouteParams: AdminNotificationsOpenaireTopicsPageParams) {
protected updatePaginationFromRouteParams(eventsRouteParams: AdminNotificationsBrokerTopicsPageParams) {
if (eventsRouteParams.currentPage) {
this.paginationConfig.currentPage = eventsRouteParams.currentPage;
}

View File

@@ -6,35 +6,35 @@ import { catchError, map, switchMap, tap, withLatestFrom } from 'rxjs/operators'
import { of as observableOf } from 'rxjs';
import {
AddTopicsAction,
OpenaireBrokerTopicActionTypes,
NotificationsBrokerTopicActionTypes,
RetrieveAllTopicsAction,
RetrieveAllTopicsErrorAction,
} from './openaire-broker-topics.actions';
} from './notifications-broker-topics.actions';
import { OpenaireBrokerTopicObject } from '../../../core/openaire/broker/models/openaire-broker-topic.model';
import { NotificationsBrokerTopicObject } from '../../../core/notifications/broker/models/notifications-broker-topic.model';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { OpenaireBrokerTopicsService } from './openaire-broker-topics.service';
import { NotificationsBrokerTopicsService } from './notifications-broker-topics.service';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { OpenaireBrokerTopicRestService } from '../../../core/openaire/broker/topics/openaire-broker-topic-rest.service';
import { NotificationsBrokerTopicRestService } from '../../../core/notifications/broker/topics/notifications-broker-topic-rest.service';
/**
* Provides effect methods for the OpenAIRE Broker topics actions.
* Provides effect methods for the Notifications Broker topics actions.
*/
@Injectable()
export class OpenaireBrokerTopicsEffects {
export class NotificationsBrokerTopicsEffects {
/**
* Retrieve all OpenAIRE Broker topics managing pagination and errors.
* Retrieve all Notifications Broker topics managing pagination and errors.
*/
@Effect() retrieveAllTopics$ = this.actions$.pipe(
ofType(OpenaireBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS),
ofType(NotificationsBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS),
withLatestFrom(this.store$),
switchMap(([action, currentState]: [RetrieveAllTopicsAction, any]) => {
return this.openaireBrokerTopicService.getTopics(
return this.notificationsBrokerTopicService.getTopics(
action.payload.elementsPerPage,
action.payload.currentPage
).pipe(
map((topics: PaginatedList<OpenaireBrokerTopicObject>) =>
map((topics: PaginatedList<NotificationsBrokerTopicObject>) =>
new AddTopicsAction(topics.page, topics.totalPages, topics.currentPage, topics.totalElements)
),
catchError((error: Error) => {
@@ -51,9 +51,9 @@ export class OpenaireBrokerTopicsEffects {
* Show a notification on error.
*/
@Effect({ dispatch: false }) retrieveAllTopicsErrorAction$ = this.actions$.pipe(
ofType(OpenaireBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS_ERROR),
ofType(NotificationsBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS_ERROR),
tap(() => {
this.notificationsService.error(null, this.translate.get('openaire.broker.topic.error.service.retrieve'));
this.notificationsService.error(null, this.translate.get('notifications.broker.topic.error.service.retrieve'));
})
);
@@ -61,9 +61,9 @@ export class OpenaireBrokerTopicsEffects {
* Clear find all topics requests from cache.
*/
@Effect({ dispatch: false }) addTopicsAction$ = this.actions$.pipe(
ofType(OpenaireBrokerTopicActionTypes.ADD_TOPICS),
ofType(NotificationsBrokerTopicActionTypes.ADD_TOPICS),
tap(() => {
this.openaireBrokerTopicDataService.clearFindAllTopicsRequests();
this.notificationsBrokerTopicDataService.clearFindAllTopicsRequests();
})
);
@@ -73,15 +73,15 @@ export class OpenaireBrokerTopicsEffects {
* @param {Store<any>} store$
* @param {TranslateService} translate
* @param {NotificationsService} notificationsService
* @param {OpenaireBrokerTopicsService} openaireBrokerTopicService
* @param {OpenaireBrokerTopicRestService} openaireBrokerTopicDataService
* @param {NotificationsBrokerTopicsService} notificationsBrokerTopicService
* @param {NotificationsBrokerTopicRestService} notificationsBrokerTopicDataService
*/
constructor(
private actions$: Actions,
private store$: Store<any>,
private translate: TranslateService,
private notificationsService: NotificationsService,
private openaireBrokerTopicService: OpenaireBrokerTopicsService,
private openaireBrokerTopicDataService: OpenaireBrokerTopicRestService
private notificationsBrokerTopicService: NotificationsBrokerTopicsService,
private notificationsBrokerTopicDataService: NotificationsBrokerTopicRestService
) { }
}

View File

@@ -0,0 +1,68 @@
import {
AddTopicsAction,
RetrieveAllTopicsAction,
RetrieveAllTopicsErrorAction
} from './notifications-broker-topics.actions';
import { notificationsBrokerTopicsReducer, NotificationsBrokerTopicState } from './notifications-broker-topics.reducer';
import {
notificationsBrokerTopicObjectMoreAbstract,
notificationsBrokerTopicObjectMorePid
} from '../../../shared/mocks/notifications.mock';
describe('notificationsBrokerTopicsReducer test suite', () => {
let notificationsBrokerTopicInitialState: NotificationsBrokerTopicState;
const elementPerPage = 3;
const currentPage = 0;
beforeEach(() => {
notificationsBrokerTopicInitialState = {
topics: [],
processing: false,
loaded: false,
totalPages: 0,
currentPage: 0,
totalElements: 0
};
});
it('Action RETRIEVE_ALL_TOPICS should set the State property "processing" to TRUE', () => {
const expectedState = notificationsBrokerTopicInitialState;
expectedState.processing = true;
const action = new RetrieveAllTopicsAction(elementPerPage, currentPage);
const newState = notificationsBrokerTopicsReducer(notificationsBrokerTopicInitialState, action);
expect(newState).toEqual(expectedState);
});
it('Action RETRIEVE_ALL_TOPICS_ERROR should change the State to initial State but processing, loaded, and currentPage', () => {
const expectedState = notificationsBrokerTopicInitialState;
expectedState.processing = false;
expectedState.loaded = true;
expectedState.currentPage = 0;
const action = new RetrieveAllTopicsErrorAction();
const newState = notificationsBrokerTopicsReducer(notificationsBrokerTopicInitialState, action);
expect(newState).toEqual(expectedState);
});
it('Action ADD_TOPICS should populate the State with Notifications Broker topics', () => {
const expectedState = {
topics: [ notificationsBrokerTopicObjectMorePid, notificationsBrokerTopicObjectMoreAbstract ],
processing: false,
loaded: true,
totalPages: 1,
currentPage: 0,
totalElements: 2
};
const action = new AddTopicsAction(
[ notificationsBrokerTopicObjectMorePid, notificationsBrokerTopicObjectMoreAbstract ],
1, 0, 2
);
const newState = notificationsBrokerTopicsReducer(notificationsBrokerTopicInitialState, action);
expect(newState).toEqual(expectedState);
});
});

View File

@@ -0,0 +1,72 @@
import { NotificationsBrokerTopicObject } from '../../../core/notifications/broker/models/notifications-broker-topic.model';
import { NotificationsBrokerTopicActionTypes, NotificationsBrokerTopicsActions } from './notifications-broker-topics.actions';
/**
* The interface representing the Notifications Broker topic state.
*/
export interface NotificationsBrokerTopicState {
topics: NotificationsBrokerTopicObject[];
processing: boolean;
loaded: boolean;
totalPages: number;
currentPage: number;
totalElements: number;
}
/**
* Used for the Notifications Broker topic state initialization.
*/
const notificationsBrokerTopicInitialState: NotificationsBrokerTopicState = {
topics: [],
processing: false,
loaded: false,
totalPages: 0,
currentPage: 0,
totalElements: 0
};
/**
* The Notifications Broker Topic Reducer
*
* @param state
* the current state initialized with notificationsBrokerTopicInitialState
* @param action
* the action to perform on the state
* @return NotificationsBrokerTopicState
* the new state
*/
export function notificationsBrokerTopicsReducer(state = notificationsBrokerTopicInitialState, action: NotificationsBrokerTopicsActions): NotificationsBrokerTopicState {
switch (action.type) {
case NotificationsBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS: {
return Object.assign({}, state, {
topics: [],
processing: true
});
}
case NotificationsBrokerTopicActionTypes.ADD_TOPICS: {
return Object.assign({}, state, {
topics: action.payload.topics,
processing: false,
loaded: true,
totalPages: action.payload.totalPages,
currentPage: state.currentPage,
totalElements: action.payload.totalElements
});
}
case NotificationsBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS_ERROR: {
return Object.assign({}, state, {
processing: false,
loaded: true,
totalPages: 0,
currentPage: 0,
totalElements: 0
});
}
default: {
return state;
}
}
}

View File

@@ -1,27 +1,27 @@
import { TestBed } from '@angular/core/testing';
import { of as observableOf } from 'rxjs';
import { OpenaireBrokerTopicsService } from './openaire-broker-topics.service';
import { NotificationsBrokerTopicsService } from './notifications-broker-topics.service';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
import { OpenaireBrokerTopicRestService } from '../../../core/openaire/broker/topics/openaire-broker-topic-rest.service';
import { NotificationsBrokerTopicRestService } from '../../../core/notifications/broker/topics/notifications-broker-topic-rest.service';
import { PageInfo } from '../../../core/shared/page-info.model';
import { FindListOptions } from '../../../core/data/request.models';
import {
getMockOpenaireBrokerTopicRestService,
openaireBrokerTopicObjectMoreAbstract,
openaireBrokerTopicObjectMorePid
} from '../../../shared/mocks/openaire.mock';
getMockNotificationsBrokerTopicRestService,
notificationsBrokerTopicObjectMoreAbstract,
notificationsBrokerTopicObjectMorePid
} from '../../../shared/mocks/notifications.mock';
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
import { cold } from 'jasmine-marbles';
import { buildPaginatedList } from '../../../core/data/paginated-list.model';
describe('OpenaireBrokerTopicsService', () => {
let service: OpenaireBrokerTopicsService;
let restService: OpenaireBrokerTopicRestService;
describe('NotificationsBrokerTopicsService', () => {
let service: NotificationsBrokerTopicsService;
let restService: NotificationsBrokerTopicRestService;
let serviceAsAny: any;
let restServiceAsAny: any;
const pageInfo = new PageInfo();
const array = [ openaireBrokerTopicObjectMorePid, openaireBrokerTopicObjectMoreAbstract ];
const array = [ notificationsBrokerTopicObjectMorePid, notificationsBrokerTopicObjectMoreAbstract ];
const paginatedList = buildPaginatedList(pageInfo, array);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
const elementsPerPage = 3;
@@ -30,22 +30,22 @@ describe('OpenaireBrokerTopicsService', () => {
beforeEach(async () => {
TestBed.configureTestingModule({
providers: [
{ provide: OpenaireBrokerTopicRestService, useClass: getMockOpenaireBrokerTopicRestService },
{ provide: OpenaireBrokerTopicsService, useValue: service }
{ provide: NotificationsBrokerTopicRestService, useClass: getMockNotificationsBrokerTopicRestService },
{ provide: NotificationsBrokerTopicsService, useValue: service }
]
}).compileComponents();
});
beforeEach(() => {
restService = TestBed.get(OpenaireBrokerTopicRestService);
restService = TestBed.get(NotificationsBrokerTopicRestService);
restServiceAsAny = restService;
restServiceAsAny.getTopics.and.returnValue(observableOf(paginatedListRD));
service = new OpenaireBrokerTopicsService(restService);
service = new NotificationsBrokerTopicsService(restService);
serviceAsAny = service;
});
describe('getTopics', () => {
it('Should proxy the call to openaireBrokerTopicRestService.getTopics', () => {
it('Should proxy the call to notificationsBrokerTopicRestService.getTopics', () => {
const sortOptions = new SortOptions('name', SortDirection.ASC);
const findListOptions: FindListOptions = {
elementsPerPage: elementsPerPage,
@@ -53,10 +53,10 @@ describe('OpenaireBrokerTopicsService', () => {
sort: sortOptions
};
const result = service.getTopics(elementsPerPage, currentPage);
expect((service as any).openaireBrokerTopicRestService.getTopics).toHaveBeenCalledWith(findListOptions);
expect((service as any).notificationsBrokerTopicRestService.getTopics).toHaveBeenCalledWith(findListOptions);
});
it('Should return a paginated list of OpenAIRE Broker topics', () => {
it('Should return a paginated list of Notifications Broker topics', () => {
const expected = cold('(a|)', {
a: paginatedList
});

View File

@@ -0,0 +1,55 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { find, map } from 'rxjs/operators';
import { NotificationsBrokerTopicRestService } from '../../../core/notifications/broker/topics/notifications-broker-topic-rest.service';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
import { FindListOptions } from '../../../core/data/request.models';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { NotificationsBrokerTopicObject } from '../../../core/notifications/broker/models/notifications-broker-topic.model';
/**
* The service handling all Notifications Broker topic requests to the REST service.
*/
@Injectable()
export class NotificationsBrokerTopicsService {
/**
* Initialize the service variables.
* @param {NotificationsBrokerTopicRestService} notificationsBrokerTopicRestService
*/
constructor(
private notificationsBrokerTopicRestService: NotificationsBrokerTopicRestService
) { }
/**
* Return the list of Notifications Broker topics managing pagination and errors.
*
* @param elementsPerPage
* The number of the topics per page
* @param currentPage
* The page number to retrieve
* @return Observable<PaginatedList<NotificationsBrokerTopicObject>>
* The list of Notifications Broker topics.
*/
public getTopics(elementsPerPage, currentPage): Observable<PaginatedList<NotificationsBrokerTopicObject>> {
const sortOptions = new SortOptions('name', SortDirection.ASC);
const findListOptions: FindListOptions = {
elementsPerPage: elementsPerPage,
currentPage: currentPage,
sort: sortOptions
};
return this.notificationsBrokerTopicRestService.getTopics(findListOptions).pipe(
find((rd: RemoteData<PaginatedList<NotificationsBrokerTopicObject>>) => !rd.isResponsePending),
map((rd: RemoteData<PaginatedList<NotificationsBrokerTopicObject>>) => {
if (rd.hasSucceeded) {
return rd.payload;
} else {
throw new Error('Can\'t retrieve Notifications Broker topics from the Broker topics REST service');
}
})
);
}
}

View File

@@ -2,17 +2,17 @@ import { TestBed } from '@angular/core/testing';
import { Store, StoreModule } from '@ngrx/store';
import { provideMockStore } from '@ngrx/store/testing';
import { cold } from 'jasmine-marbles';
import { openaireReducers } from './openaire.reducer';
import { OpenaireStateService } from './openaire-state.service';
import { notificationsReducers } from './notifications.reducer';
import { NotificationsStateService } from './notifications-state.service';
import {
openaireBrokerTopicObjectMissingPid,
openaireBrokerTopicObjectMoreAbstract,
openaireBrokerTopicObjectMorePid
} from '../shared/mocks/openaire.mock';
import { RetrieveAllTopicsAction } from './broker/topics/openaire-broker-topics.actions';
notificationsBrokerTopicObjectMissingPid,
notificationsBrokerTopicObjectMoreAbstract,
notificationsBrokerTopicObjectMorePid
} from '../shared/mocks/notifications.mock';
import { RetrieveAllTopicsAction } from './broker/topics/notifications-broker-topics.actions';
describe('OpenaireStateService', () => {
let service: OpenaireStateService;
describe('NotificationsStateService', () => {
let service: NotificationsStateService;
let serviceAsAny: any;
let store: any;
let initialState: any;
@@ -20,7 +20,7 @@ describe('OpenaireStateService', () => {
function init(mode: string) {
if (mode === 'empty') {
initialState = {
openaire: {
notifications: {
brokerTopic: {
topics: [],
processing: false,
@@ -34,12 +34,12 @@ describe('OpenaireStateService', () => {
};
} else {
initialState = {
openaire: {
notifications: {
brokerTopic: {
topics: [
openaireBrokerTopicObjectMorePid,
openaireBrokerTopicObjectMoreAbstract,
openaireBrokerTopicObjectMissingPid
notificationsBrokerTopicObjectMorePid,
notificationsBrokerTopicObjectMoreAbstract,
notificationsBrokerTopicObjectMissingPid
],
processing: false,
loaded: true,
@@ -58,25 +58,25 @@ describe('OpenaireStateService', () => {
init('empty');
TestBed.configureTestingModule({
imports: [
StoreModule.forRoot({ openaire: openaireReducers } as any),
StoreModule.forRoot({ notifications: notificationsReducers } as any),
],
providers: [
provideMockStore({ initialState }),
{ provide: OpenaireStateService, useValue: service }
{ provide: NotificationsStateService, useValue: service }
]
}).compileComponents();
});
beforeEach(() => {
store = TestBed.get(Store);
service = new OpenaireStateService(store);
service = new NotificationsStateService(store);
serviceAsAny = service;
spyOn(store, 'dispatch');
});
describe('getOpenaireBrokerTopics', () => {
describe('getNotificationsBrokerTopics', () => {
it('Should return an empty array', () => {
const result = service.getOpenaireBrokerTopics();
const result = service.getNotificationsBrokerTopics();
const expected = cold('(a)', {
a: []
});
@@ -84,9 +84,9 @@ describe('OpenaireStateService', () => {
});
});
describe('getOpenaireBrokerTopicsTotalPages', () => {
describe('getNotificationsBrokerTopicsTotalPages', () => {
it('Should return zero (0)', () => {
const result = service.getOpenaireBrokerTopicsTotalPages();
const result = service.getNotificationsBrokerTopicsTotalPages();
const expected = cold('(a)', {
a: 0
});
@@ -94,9 +94,9 @@ describe('OpenaireStateService', () => {
});
});
describe('getOpenaireBrokerTopicsCurrentPage', () => {
describe('getNotificationsBrokerTopicsCurrentPage', () => {
it('Should return minus one (0)', () => {
const result = service.getOpenaireBrokerTopicsCurrentPage();
const result = service.getNotificationsBrokerTopicsCurrentPage();
const expected = cold('(a)', {
a: 0
});
@@ -104,9 +104,9 @@ describe('OpenaireStateService', () => {
});
});
describe('getOpenaireBrokerTopicsTotals', () => {
describe('getNotificationsBrokerTopicsTotals', () => {
it('Should return zero (0)', () => {
const result = service.getOpenaireBrokerTopicsTotals();
const result = service.getNotificationsBrokerTopicsTotals();
const expected = cold('(a)', {
a: 0
});
@@ -114,9 +114,9 @@ describe('OpenaireStateService', () => {
});
});
describe('isOpenaireBrokerTopicsLoading', () => {
describe('isNotificationsBrokerTopicsLoading', () => {
it('Should return TRUE', () => {
const result = service.isOpenaireBrokerTopicsLoading();
const result = service.isNotificationsBrokerTopicsLoading();
const expected = cold('(a)', {
a: true
});
@@ -124,9 +124,9 @@ describe('OpenaireStateService', () => {
});
});
describe('isOpenaireBrokerTopicsLoaded', () => {
describe('isNotificationsBrokerTopicsLoaded', () => {
it('Should return FALSE', () => {
const result = service.isOpenaireBrokerTopicsLoaded();
const result = service.isNotificationsBrokerTopicsLoaded();
const expected = cold('(a)', {
a: false
});
@@ -134,9 +134,9 @@ describe('OpenaireStateService', () => {
});
});
describe('isOpenaireBrokerTopicsProcessing', () => {
describe('isNotificationsBrokerTopicsProcessing', () => {
it('Should return FALSE', () => {
const result = service.isOpenaireBrokerTopicsProcessing();
const result = service.isNotificationsBrokerTopicsProcessing();
const expected = cold('(a)', {
a: false
});
@@ -150,39 +150,39 @@ describe('OpenaireStateService', () => {
init('full');
TestBed.configureTestingModule({
imports: [
StoreModule.forRoot({ openaire: openaireReducers } as any),
StoreModule.forRoot({ notifications: notificationsReducers } as any),
],
providers: [
provideMockStore({ initialState }),
{ provide: OpenaireStateService, useValue: service }
{ provide: NotificationsStateService, useValue: service }
]
}).compileComponents();
});
beforeEach(() => {
store = TestBed.get(Store);
service = new OpenaireStateService(store);
service = new NotificationsStateService(store);
serviceAsAny = service;
spyOn(store, 'dispatch');
});
describe('getOpenaireBrokerTopics', () => {
describe('getNotificationsBrokerTopics', () => {
it('Should return an array of topics', () => {
const result = service.getOpenaireBrokerTopics();
const result = service.getNotificationsBrokerTopics();
const expected = cold('(a)', {
a: [
openaireBrokerTopicObjectMorePid,
openaireBrokerTopicObjectMoreAbstract,
openaireBrokerTopicObjectMissingPid
notificationsBrokerTopicObjectMorePid,
notificationsBrokerTopicObjectMoreAbstract,
notificationsBrokerTopicObjectMissingPid
]
});
expect(result).toBeObservable(expected);
});
});
describe('getOpenaireBrokerTopicsTotalPages', () => {
describe('getNotificationsBrokerTopicsTotalPages', () => {
it('Should return one (1)', () => {
const result = service.getOpenaireBrokerTopicsTotalPages();
const result = service.getNotificationsBrokerTopicsTotalPages();
const expected = cold('(a)', {
a: 1
});
@@ -190,9 +190,9 @@ describe('OpenaireStateService', () => {
});
});
describe('getOpenaireBrokerTopicsCurrentPage', () => {
describe('getNotificationsBrokerTopicsCurrentPage', () => {
it('Should return minus zero (1)', () => {
const result = service.getOpenaireBrokerTopicsCurrentPage();
const result = service.getNotificationsBrokerTopicsCurrentPage();
const expected = cold('(a)', {
a: 1
});
@@ -200,9 +200,9 @@ describe('OpenaireStateService', () => {
});
});
describe('getOpenaireBrokerTopicsTotals', () => {
describe('getNotificationsBrokerTopicsTotals', () => {
it('Should return three (3)', () => {
const result = service.getOpenaireBrokerTopicsTotals();
const result = service.getNotificationsBrokerTopicsTotals();
const expected = cold('(a)', {
a: 3
});
@@ -210,9 +210,9 @@ describe('OpenaireStateService', () => {
});
});
describe('isOpenaireBrokerTopicsLoading', () => {
describe('isNotificationsBrokerTopicsLoading', () => {
it('Should return FALSE', () => {
const result = service.isOpenaireBrokerTopicsLoading();
const result = service.isNotificationsBrokerTopicsLoading();
const expected = cold('(a)', {
a: false
});
@@ -220,9 +220,9 @@ describe('OpenaireStateService', () => {
});
});
describe('isOpenaireBrokerTopicsLoaded', () => {
describe('isNotificationsBrokerTopicsLoaded', () => {
it('Should return TRUE', () => {
const result = service.isOpenaireBrokerTopicsLoaded();
const result = service.isNotificationsBrokerTopicsLoaded();
const expected = cold('(a)', {
a: true
});
@@ -230,9 +230,9 @@ describe('OpenaireStateService', () => {
});
});
describe('isOpenaireBrokerTopicsProcessing', () => {
describe('isNotificationsBrokerTopicsProcessing', () => {
it('Should return FALSE', () => {
const result = service.isOpenaireBrokerTopicsProcessing();
const result = service.isNotificationsBrokerTopicsProcessing();
const expected = cold('(a)', {
a: false
});
@@ -246,28 +246,28 @@ describe('OpenaireStateService', () => {
init('full');
TestBed.configureTestingModule({
imports: [
StoreModule.forRoot({ openaire: openaireReducers } as any),
StoreModule.forRoot({ notifications: notificationsReducers } as any),
],
providers: [
provideMockStore({ initialState }),
{ provide: OpenaireStateService, useValue: service }
{ provide: NotificationsStateService, useValue: service }
]
}).compileComponents();
});
beforeEach(() => {
store = TestBed.get(Store);
service = new OpenaireStateService(store);
service = new NotificationsStateService(store);
serviceAsAny = service;
spyOn(store, 'dispatch');
});
describe('dispatchRetrieveOpenaireBrokerTopics', () => {
describe('dispatchRetrieveNotificationsBrokerTopics', () => {
it('Should call store.dispatch', () => {
const elementsPerPage = 3;
const currentPage = 1;
const action = new RetrieveAllTopicsAction(elementsPerPage, currentPage);
service.dispatchRetrieveOpenaireBrokerTopics(elementsPerPage, currentPage);
service.dispatchRetrieveNotificationsBrokerTopics(elementsPerPage, currentPage);
expect(serviceAsAny.store.dispatch).toHaveBeenCalledWith(action);
});
});

View File

@@ -0,0 +1,116 @@
import { Injectable } from '@angular/core';
import { select, Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import {
getNotificationsBrokerTopicsCurrentPageSelector,
getNotificationsBrokerTopicsTotalPagesSelector,
getNotificationsBrokerTopicsTotalsSelector,
isNotificationsBrokerTopicsLoadedSelector,
notificationsBrokerTopicsObjectSelector,
isNotificationsBrokerTopicsProcessingSelector
} from './selectors';
import { NotificationsBrokerTopicObject } from '../core/notifications/broker/models/notifications-broker-topic.model';
import { NotificationsState } from './notifications.reducer';
import { RetrieveAllTopicsAction } from './broker/topics/notifications-broker-topics.actions';
/**
* The service handling the Notifications State.
*/
@Injectable()
export class NotificationsStateService {
/**
* Initialize the service variables.
* @param {Store<NotificationsState>} store
*/
constructor(private store: Store<NotificationsState>) { }
// Notifications Broker topics
// --------------------------------------------------------------------------
/**
* Returns the list of Notifications Broker topics from the state.
*
* @return Observable<NotificationsBrokerTopicObject>
* The list of Notifications Broker topics.
*/
public getNotificationsBrokerTopics(): Observable<NotificationsBrokerTopicObject[]> {
return this.store.pipe(select(notificationsBrokerTopicsObjectSelector()));
}
/**
* Returns the information about the loading status of the Notifications Broker topics (if it's running or not).
*
* @return Observable<boolean>
* 'true' if the topics are loading, 'false' otherwise.
*/
public isNotificationsBrokerTopicsLoading(): Observable<boolean> {
return this.store.pipe(
select(isNotificationsBrokerTopicsLoadedSelector),
map((loaded: boolean) => !loaded)
);
}
/**
* Returns the information about the loading status of the Notifications Broker topics (whether or not they were loaded).
*
* @return Observable<boolean>
* 'true' if the topics are loaded, 'false' otherwise.
*/
public isNotificationsBrokerTopicsLoaded(): Observable<boolean> {
return this.store.pipe(select(isNotificationsBrokerTopicsLoadedSelector));
}
/**
* Returns the information about the processing status of the Notifications Broker topics (if it's running or not).
*
* @return Observable<boolean>
* 'true' if there are operations running on the topics (ex.: a REST call), 'false' otherwise.
*/
public isNotificationsBrokerTopicsProcessing(): Observable<boolean> {
return this.store.pipe(select(isNotificationsBrokerTopicsProcessingSelector));
}
/**
* Returns, from the state, the total available pages of the Notifications Broker topics.
*
* @return Observable<number>
* The number of the Notifications Broker topics pages.
*/
public getNotificationsBrokerTopicsTotalPages(): Observable<number> {
return this.store.pipe(select(getNotificationsBrokerTopicsTotalPagesSelector));
}
/**
* Returns the current page of the Notifications Broker topics, from the state.
*
* @return Observable<number>
* The number of the current Notifications Broker topics page.
*/
public getNotificationsBrokerTopicsCurrentPage(): Observable<number> {
return this.store.pipe(select(getNotificationsBrokerTopicsCurrentPageSelector));
}
/**
* Returns the total number of the Notifications Broker topics.
*
* @return Observable<number>
* The number of the Notifications Broker topics.
*/
public getNotificationsBrokerTopicsTotals(): Observable<number> {
return this.store.pipe(select(getNotificationsBrokerTopicsTotalsSelector));
}
/**
* Dispatch a request to change the Notifications Broker topics state, retrieving the topics from the server.
*
* @param elementsPerPage
* The number of the topics per page.
* @param currentPage
* The number of the current page.
*/
public dispatchRetrieveNotificationsBrokerTopics(elementsPerPage: number, currentPage: number): void {
this.store.dispatch(new RetrieveAllTopicsAction(elementsPerPage, currentPage));
}
}

View File

@@ -0,0 +1,5 @@
import { NotificationsBrokerTopicsEffects } from './broker/topics/notifications-broker-topics.effects';
export const notificationsEffects = [
NotificationsBrokerTopicsEffects
];

View File

@@ -6,14 +6,14 @@ import { EffectsModule } from '@ngrx/effects';
import { CoreModule } from '../core/core.module';
import { SharedModule } from '../shared/shared.module';
import { storeModuleConfig } from '../app.reducer';
import { OpenaireBrokerTopicsComponent } from './broker/topics/openaire-broker-topics.component';
import { OpenaireBrokerEventsComponent } from './broker/events/openaire-broker-events.component';
import { OpenaireStateService } from './openaire-state.service';
import { openaireReducers, OpenaireState } from './openaire.reducer';
import { openaireEffects } from './openaire.effects';
import { OpenaireBrokerTopicsService } from './broker/topics/openaire-broker-topics.service';
import { OpenaireBrokerTopicRestService } from '../core/openaire/broker/topics/openaire-broker-topic-rest.service';
import { OpenaireBrokerEventRestService } from '../core/openaire/broker/events/openaire-broker-event-rest.service';
import { NotificationsBrokerTopicsComponent } from './broker/topics/notifications-broker-topics.component';
import { NotificationsBrokerEventsComponent } from './broker/events/notifications-broker-events.component';
import { NotificationsStateService } from './notifications-state.service';
import { notificationsReducers, NotificationsState } from './notifications.reducer';
import { notificationsEffects } from './notifications.effects';
import { NotificationsBrokerTopicsService } from './broker/topics/notifications-broker-topics.service';
import { NotificationsBrokerTopicRestService } from '../core/notifications/broker/topics/notifications-broker-topic-rest.service';
import { NotificationsBrokerEventRestService } from '../core/notifications/broker/events/notifications-broker-event-rest.service';
import { ProjectEntryImportModalComponent } from './broker/project-entry-import-modal/project-entry-import-modal.component';
import { TranslateModule } from '@ngx-translate/core';
import { SearchModule } from '../shared/search/search.module';
@@ -22,14 +22,14 @@ const MODULES = [
CommonModule,
SharedModule,
CoreModule.forRoot(),
StoreModule.forFeature('openaire', openaireReducers, storeModuleConfig as StoreConfig<OpenaireState, Action>),
EffectsModule.forFeature(openaireEffects),
StoreModule.forFeature('notifications', notificationsReducers, storeModuleConfig as StoreConfig<NotificationsState, Action>),
EffectsModule.forFeature(notificationsEffects),
TranslateModule
];
const COMPONENTS = [
OpenaireBrokerTopicsComponent,
OpenaireBrokerEventsComponent
NotificationsBrokerTopicsComponent,
NotificationsBrokerEventsComponent
];
const DIRECTIVES = [ ];
@@ -39,10 +39,10 @@ const ENTRY_COMPONENTS = [
];
const PROVIDERS = [
OpenaireStateService,
OpenaireBrokerTopicsService,
OpenaireBrokerTopicRestService,
OpenaireBrokerEventRestService
NotificationsStateService,
NotificationsBrokerTopicsService,
NotificationsBrokerTopicRestService,
NotificationsBrokerEventRestService
];
@NgModule({
@@ -70,5 +70,5 @@ const PROVIDERS = [
/**
* This module handles all components that are necessary for the OpenAIRE components
*/
export class OpenaireModule {
export class NotificationsModule {
}

View File

@@ -0,0 +1,16 @@
import { ActionReducerMap, createFeatureSelector } from '@ngrx/store';
import { notificationsBrokerTopicsReducer, NotificationsBrokerTopicState, } from './broker/topics/notifications-broker-topics.reducer';
/**
* The OpenAIRE State
*/
export interface NotificationsState {
'brokerTopic': NotificationsBrokerTopicState;
}
export const notificationsReducers: ActionReducerMap<NotificationsState> = {
brokerTopic: notificationsBrokerTopicsReducer,
};
export const notificationsSelector = createFeatureSelector<NotificationsState>('notifications');

View File

@@ -0,0 +1,79 @@
import { createSelector, MemoizedSelector } from '@ngrx/store';
import { subStateSelector } from '../shared/selector.util';
import { notificationsSelector, NotificationsState } from './notifications.reducer';
import { NotificationsBrokerTopicObject } from '../core/notifications/broker/models/notifications-broker-topic.model';
import { NotificationsBrokerTopicState } from './broker/topics/notifications-broker-topics.reducer';
/**
* Returns the Notifications state.
* @function _getNotificationsState
* @param {AppState} state Top level state.
* @return {NotificationsState}
*/
const _getNotificationsState = (state: any) => state.notifications;
// Notifications Broker topics
// ----------------------------------------------------------------------------
/**
* Returns the Notifications Broker topics State.
* @function notificationsBrokerTopicsStateSelector
* @return {NotificationsBrokerTopicState}
*/
export function notificationsBrokerTopicsStateSelector(): MemoizedSelector<NotificationsState, NotificationsBrokerTopicState> {
return subStateSelector<NotificationsState,NotificationsBrokerTopicState>(notificationsSelector, 'brokerTopic');
}
/**
* Returns the Notifications Broker topics list.
* @function notificationsBrokerTopicsObjectSelector
* @return {NotificationsBrokerTopicObject[]}
*/
export function notificationsBrokerTopicsObjectSelector(): MemoizedSelector<NotificationsState, NotificationsBrokerTopicObject[]> {
return subStateSelector<NotificationsState, NotificationsBrokerTopicObject[]>(notificationsBrokerTopicsStateSelector(), 'topics');
}
/**
* Returns true if the Notifications Broker topics are loaded.
* @function isNotificationsBrokerTopicsLoadedSelector
* @return {boolean}
*/
export const isNotificationsBrokerTopicsLoadedSelector = createSelector(_getNotificationsState,
(state: NotificationsState) => state.brokerTopic.loaded
);
/**
* Returns true if the deduplication sets are processing.
* @function isDeduplicationSetsProcessingSelector
* @return {boolean}
*/
export const isNotificationsBrokerTopicsProcessingSelector = createSelector(_getNotificationsState,
(state: NotificationsState) => state.brokerTopic.processing
);
/**
* Returns the total available pages of Notifications Broker topics.
* @function getNotificationsBrokerTopicsTotalPagesSelector
* @return {number}
*/
export const getNotificationsBrokerTopicsTotalPagesSelector = createSelector(_getNotificationsState,
(state: NotificationsState) => state.brokerTopic.totalPages
);
/**
* Returns the current page of Notifications Broker topics.
* @function getNotificationsBrokerTopicsCurrentPageSelector
* @return {number}
*/
export const getNotificationsBrokerTopicsCurrentPageSelector = createSelector(_getNotificationsState,
(state: NotificationsState) => state.brokerTopic.currentPage
);
/**
* Returns the total number of Notifications Broker topics.
* @function getNotificationsBrokerTopicsTotalsSelector
* @return {number}
*/
export const getNotificationsBrokerTopicsTotalsSelector = createSelector(_getNotificationsState,
(state: NotificationsState) => state.brokerTopic.totalElements
);

View File

@@ -1,68 +0,0 @@
import {
AddTopicsAction,
RetrieveAllTopicsAction,
RetrieveAllTopicsErrorAction
} from './openaire-broker-topics.actions';
import { openaireBrokerTopicsReducer, OpenaireBrokerTopicState } from './openaire-broker-topics.reducer';
import {
openaireBrokerTopicObjectMoreAbstract,
openaireBrokerTopicObjectMorePid
} from '../../../shared/mocks/openaire.mock';
describe('openaireBrokerTopicsReducer test suite', () => {
let openaireBrokerTopicInitialState: OpenaireBrokerTopicState;
const elementPerPage = 3;
const currentPage = 0;
beforeEach(() => {
openaireBrokerTopicInitialState = {
topics: [],
processing: false,
loaded: false,
totalPages: 0,
currentPage: 0,
totalElements: 0
};
});
it('Action RETRIEVE_ALL_TOPICS should set the State property "processing" to TRUE', () => {
const expectedState = openaireBrokerTopicInitialState;
expectedState.processing = true;
const action = new RetrieveAllTopicsAction(elementPerPage, currentPage);
const newState = openaireBrokerTopicsReducer(openaireBrokerTopicInitialState, action);
expect(newState).toEqual(expectedState);
});
it('Action RETRIEVE_ALL_TOPICS_ERROR should change the State to initial State but processing, loaded, and currentPage', () => {
const expectedState = openaireBrokerTopicInitialState;
expectedState.processing = false;
expectedState.loaded = true;
expectedState.currentPage = 0;
const action = new RetrieveAllTopicsErrorAction();
const newState = openaireBrokerTopicsReducer(openaireBrokerTopicInitialState, action);
expect(newState).toEqual(expectedState);
});
it('Action ADD_TOPICS should populate the State with OpenAIRE Broker topics', () => {
const expectedState = {
topics: [ openaireBrokerTopicObjectMorePid, openaireBrokerTopicObjectMoreAbstract ],
processing: false,
loaded: true,
totalPages: 1,
currentPage: 0,
totalElements: 2
};
const action = new AddTopicsAction(
[ openaireBrokerTopicObjectMorePid, openaireBrokerTopicObjectMoreAbstract ],
1, 0, 2
);
const newState = openaireBrokerTopicsReducer(openaireBrokerTopicInitialState, action);
expect(newState).toEqual(expectedState);
});
});

View File

@@ -1,72 +0,0 @@
import { OpenaireBrokerTopicObject } from '../../../core/openaire/broker/models/openaire-broker-topic.model';
import { OpenaireBrokerTopicActionTypes, OpenaireBrokerTopicsActions } from './openaire-broker-topics.actions';
/**
* The interface representing the OpenAIRE Broker topic state.
*/
export interface OpenaireBrokerTopicState {
topics: OpenaireBrokerTopicObject[];
processing: boolean;
loaded: boolean;
totalPages: number;
currentPage: number;
totalElements: number;
}
/**
* Used for the OpenAIRE Broker topic state initialization.
*/
const openaireBrokerTopicInitialState: OpenaireBrokerTopicState = {
topics: [],
processing: false,
loaded: false,
totalPages: 0,
currentPage: 0,
totalElements: 0
};
/**
* The OpenAIRE Broker Topic Reducer
*
* @param state
* the current state initialized with openaireBrokerTopicInitialState
* @param action
* the action to perform on the state
* @return OpenaireBrokerTopicState
* the new state
*/
export function openaireBrokerTopicsReducer(state = openaireBrokerTopicInitialState, action: OpenaireBrokerTopicsActions): OpenaireBrokerTopicState {
switch (action.type) {
case OpenaireBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS: {
return Object.assign({}, state, {
topics: [],
processing: true
});
}
case OpenaireBrokerTopicActionTypes.ADD_TOPICS: {
return Object.assign({}, state, {
topics: action.payload.topics,
processing: false,
loaded: true,
totalPages: action.payload.totalPages,
currentPage: state.currentPage,
totalElements: action.payload.totalElements
});
}
case OpenaireBrokerTopicActionTypes.RETRIEVE_ALL_TOPICS_ERROR: {
return Object.assign({}, state, {
processing: false,
loaded: true,
totalPages: 0,
currentPage: 0,
totalElements: 0
});
}
default: {
return state;
}
}
}

View File

@@ -1,55 +0,0 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { find, map } from 'rxjs/operators';
import { OpenaireBrokerTopicRestService } from '../../../core/openaire/broker/topics/openaire-broker-topic-rest.service';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
import { FindListOptions } from '../../../core/data/request.models';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { OpenaireBrokerTopicObject } from '../../../core/openaire/broker/models/openaire-broker-topic.model';
/**
* The service handling all OpenAIRE Broker topic requests to the REST service.
*/
@Injectable()
export class OpenaireBrokerTopicsService {
/**
* Initialize the service variables.
* @param {OpenaireBrokerTopicRestService} openaireBrokerTopicRestService
*/
constructor(
private openaireBrokerTopicRestService: OpenaireBrokerTopicRestService
) { }
/**
* Return the list of OpenAIRE Broker topics managing pagination and errors.
*
* @param elementsPerPage
* The number of the topics per page
* @param currentPage
* The page number to retrieve
* @return Observable<PaginatedList<OpenaireBrokerTopicObject>>
* The list of OpenAIRE Broker topics.
*/
public getTopics(elementsPerPage, currentPage): Observable<PaginatedList<OpenaireBrokerTopicObject>> {
const sortOptions = new SortOptions('name', SortDirection.ASC);
const findListOptions: FindListOptions = {
elementsPerPage: elementsPerPage,
currentPage: currentPage,
sort: sortOptions
};
return this.openaireBrokerTopicRestService.getTopics(findListOptions).pipe(
find((rd: RemoteData<PaginatedList<OpenaireBrokerTopicObject>>) => !rd.isResponsePending),
map((rd: RemoteData<PaginatedList<OpenaireBrokerTopicObject>>) => {
if (rd.hasSucceeded) {
return rd.payload;
} else {
throw new Error('Can\'t retrieve OpenAIRE Broker topics from the Broker topics REST service');
}
})
);
}
}

View File

@@ -1,116 +0,0 @@
import { Injectable } from '@angular/core';
import { select, Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import {
getOpenaireBrokerTopicsCurrentPageSelector,
getOpenaireBrokerTopicsTotalPagesSelector,
getOpenaireBrokerTopicsTotalsSelector,
isOpenaireBrokerTopicsLoadedSelector,
openaireBrokerTopicsObjectSelector,
sOpenaireBrokerTopicsProcessingSelector
} from './selectors';
import { OpenaireBrokerTopicObject } from '../core/openaire/broker/models/openaire-broker-topic.model';
import { OpenaireState } from './openaire.reducer';
import { RetrieveAllTopicsAction } from './broker/topics/openaire-broker-topics.actions';
/**
* The service handling the OpenAIRE State.
*/
@Injectable()
export class OpenaireStateService {
/**
* Initialize the service variables.
* @param {Store<OpenaireState>} store
*/
constructor(private store: Store<OpenaireState>) { }
// OpenAIRE Broker topics
// --------------------------------------------------------------------------
/**
* Returns the list of OpenAIRE Broker topics from the state.
*
* @return Observable<OpenaireBrokerTopicObject>
* The list of OpenAIRE Broker topics.
*/
public getOpenaireBrokerTopics(): Observable<OpenaireBrokerTopicObject[]> {
return this.store.pipe(select(openaireBrokerTopicsObjectSelector()));
}
/**
* Returns the information about the loading status of the OpenAIRE Broker topics (if it's running or not).
*
* @return Observable<boolean>
* 'true' if the topics are loading, 'false' otherwise.
*/
public isOpenaireBrokerTopicsLoading(): Observable<boolean> {
return this.store.pipe(
select(isOpenaireBrokerTopicsLoadedSelector),
map((loaded: boolean) => !loaded)
);
}
/**
* Returns the information about the loading status of the OpenAIRE Broker topics (whether or not they were loaded).
*
* @return Observable<boolean>
* 'true' if the topics are loaded, 'false' otherwise.
*/
public isOpenaireBrokerTopicsLoaded(): Observable<boolean> {
return this.store.pipe(select(isOpenaireBrokerTopicsLoadedSelector));
}
/**
* Returns the information about the processing status of the OpenAIRE Broker topics (if it's running or not).
*
* @return Observable<boolean>
* 'true' if there are operations running on the topics (ex.: a REST call), 'false' otherwise.
*/
public isOpenaireBrokerTopicsProcessing(): Observable<boolean> {
return this.store.pipe(select(sOpenaireBrokerTopicsProcessingSelector));
}
/**
* Returns, from the state, the total available pages of the OpenAIRE Broker topics.
*
* @return Observable<number>
* The number of the OpenAIRE Broker topics pages.
*/
public getOpenaireBrokerTopicsTotalPages(): Observable<number> {
return this.store.pipe(select(getOpenaireBrokerTopicsTotalPagesSelector));
}
/**
* Returns the current page of the OpenAIRE Broker topics, from the state.
*
* @return Observable<number>
* The number of the current OpenAIRE Broker topics page.
*/
public getOpenaireBrokerTopicsCurrentPage(): Observable<number> {
return this.store.pipe(select(getOpenaireBrokerTopicsCurrentPageSelector));
}
/**
* Returns the total number of the OpenAIRE Broker topics.
*
* @return Observable<number>
* The number of the OpenAIRE Broker topics.
*/
public getOpenaireBrokerTopicsTotals(): Observable<number> {
return this.store.pipe(select(getOpenaireBrokerTopicsTotalsSelector));
}
/**
* Dispatch a request to change the OpenAIRE Broker topics state, retrieving the topics from the server.
*
* @param elementsPerPage
* The number of the topics per page.
* @param currentPage
* The number of the current page.
*/
public dispatchRetrieveOpenaireBrokerTopics(elementsPerPage: number, currentPage: number): void {
this.store.dispatch(new RetrieveAllTopicsAction(elementsPerPage, currentPage));
}
}

View File

@@ -1,5 +0,0 @@
import { OpenaireBrokerTopicsEffects } from './broker/topics/openaire-broker-topics.effects';
export const openaireEffects = [
OpenaireBrokerTopicsEffects
];

View File

@@ -1,16 +0,0 @@
import { ActionReducerMap, createFeatureSelector } from '@ngrx/store';
import { openaireBrokerTopicsReducer, OpenaireBrokerTopicState, } from './broker/topics/openaire-broker-topics.reducer';
/**
* The OpenAIRE State
*/
export interface OpenaireState {
'brokerTopic': OpenaireBrokerTopicState;
}
export const openaireReducers: ActionReducerMap<OpenaireState> = {
brokerTopic: openaireBrokerTopicsReducer,
};
export const openaireSelector = createFeatureSelector<OpenaireState>('openaire');

View File

@@ -1,79 +0,0 @@
import { createSelector, MemoizedSelector } from '@ngrx/store';
import { subStateSelector } from '../shared/selector.util';
import { openaireSelector, OpenaireState } from './openaire.reducer';
import { OpenaireBrokerTopicObject } from '../core/openaire/broker/models/openaire-broker-topic.model';
import { OpenaireBrokerTopicState } from './broker/topics/openaire-broker-topics.reducer';
/**
* Returns the OpenAIRE state.
* @function _getOpenaireState
* @param {AppState} state Top level state.
* @return {OpenaireState}
*/
const _getOpenaireState = (state: any) => state.openaire;
// OpenAIRE Broker topics
// ----------------------------------------------------------------------------
/**
* Returns the OpenAIRE Broker topics State.
* @function openaireBrokerTopicsStateSelector
* @return {OpenaireBrokerTopicState}
*/
export function openaireBrokerTopicsStateSelector(): MemoizedSelector<OpenaireState, OpenaireBrokerTopicState> {
return subStateSelector<OpenaireState,OpenaireBrokerTopicState>(openaireSelector, 'brokerTopic');
}
/**
* Returns the OpenAIRE Broker topics list.
* @function openaireBrokerTopicsObjectSelector
* @return {OpenaireBrokerTopicObject[]}
*/
export function openaireBrokerTopicsObjectSelector(): MemoizedSelector<OpenaireState, OpenaireBrokerTopicObject[]> {
return subStateSelector<OpenaireState, OpenaireBrokerTopicObject[]>(openaireBrokerTopicsStateSelector(), 'topics');
}
/**
* Returns true if the OpenAIRE Broker topics are loaded.
* @function isOpenaireBrokerTopicsLoadedSelector
* @return {boolean}
*/
export const isOpenaireBrokerTopicsLoadedSelector = createSelector(_getOpenaireState,
(state: OpenaireState) => state.brokerTopic.loaded
);
/**
* Returns true if the deduplication sets are processing.
* @function isDeduplicationSetsProcessingSelector
* @return {boolean}
*/
export const sOpenaireBrokerTopicsProcessingSelector = createSelector(_getOpenaireState,
(state: OpenaireState) => state.brokerTopic.processing
);
/**
* Returns the total available pages of OpenAIRE Broker topics.
* @function getOpenaireBrokerTopicsTotalPagesSelector
* @return {number}
*/
export const getOpenaireBrokerTopicsTotalPagesSelector = createSelector(_getOpenaireState,
(state: OpenaireState) => state.brokerTopic.totalPages
);
/**
* Returns the current page of OpenAIRE Broker topics.
* @function getOpenaireBrokerTopicsCurrentPageSelector
* @return {number}
*/
export const getOpenaireBrokerTopicsCurrentPageSelector = createSelector(_getOpenaireState,
(state: OpenaireState) => state.brokerTopic.currentPage
);
/**
* Returns the total number of OpenAIRE Broker topics.
* @function getOpenaireBrokerTopicsTotalsSelector
* @return {number}
*/
export const getOpenaireBrokerTopicsTotalsSelector = createSelector(_getOpenaireState,
(state: OpenaireState) => state.brokerTopic.totalElements
);

View File

@@ -1,11 +1,11 @@
import { of as observableOf } from 'rxjs';
import { ResourceType } from '../../core/shared/resource-type';
import { OpenaireBrokerTopicObject } from '../../core/openaire/broker/models/openaire-broker-topic.model';
import { OpenaireBrokerEventObject } from '../../core/openaire/broker/models/openaire-broker-event.model';
import { OpenaireBrokerTopicRestService } from '../../core/openaire/broker/topics/openaire-broker-topic-rest.service';
import { OpenaireBrokerEventRestService } from '../../core/openaire/broker/events/openaire-broker-event-rest.service';
import { NotificationsBrokerTopicObject } from '../../core/notifications/broker/models/notifications-broker-topic.model';
import { NotificationsBrokerEventObject } from '../../core/notifications/broker/models/notifications-broker-event.model';
import { NotificationsBrokerTopicRestService } from '../../core/notifications/broker/topics/notifications-broker-topic-rest.service';
import { NotificationsBrokerEventRestService } from '../../core/notifications/broker/events/notifications-broker-event-rest.service';
import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { OpenaireStateService } from '../../openaire/openaire-state.service';
import { NotificationsStateService } from '../../notifications/notifications-state.service';
import { Item } from '../../core/shared/item.model';
import {
createNoContentRemoteDataObject$,
@@ -1210,7 +1210,7 @@ export const ItemMockPid10: Item = Object.assign(
}
);
export const OpenaireMockDspaceObject: SearchResult<DSpaceObject> = Object.assign(
export const NotificationsMockDspaceObject: SearchResult<DSpaceObject> = Object.assign(
new SearchResult<DSpaceObject>(),
{
handle: '10713/29832',
@@ -1332,7 +1332,7 @@ export const OpenaireMockDspaceObject: SearchResult<DSpaceObject> = Object.assig
// Topics
// -------------------------------------------------------------------------------
export const openaireBrokerTopicObjectMorePid: OpenaireBrokerTopicObject = {
export const notificationsBrokerTopicObjectMorePid: NotificationsBrokerTopicObject = {
type: new ResourceType('nbtopic'),
id: 'ENRICH!MORE!PID',
name: 'ENRICH/MORE/PID',
@@ -1345,7 +1345,7 @@ export const openaireBrokerTopicObjectMorePid: OpenaireBrokerTopicObject = {
}
};
export const openaireBrokerTopicObjectMoreAbstract: OpenaireBrokerTopicObject = {
export const notificationsBrokerTopicObjectMoreAbstract: NotificationsBrokerTopicObject = {
type: new ResourceType('nbtopic'),
id: 'ENRICH!MORE!ABSTRACT',
name: 'ENRICH/MORE/ABSTRACT',
@@ -1358,7 +1358,7 @@ export const openaireBrokerTopicObjectMoreAbstract: OpenaireBrokerTopicObject =
}
};
export const openaireBrokerTopicObjectMissingPid: OpenaireBrokerTopicObject = {
export const notificationsBrokerTopicObjectMissingPid: NotificationsBrokerTopicObject = {
type: new ResourceType('nbtopic'),
id: 'ENRICH!MISSING!PID',
name: 'ENRICH/MISSING/PID',
@@ -1371,7 +1371,7 @@ export const openaireBrokerTopicObjectMissingPid: OpenaireBrokerTopicObject = {
}
};
export const openaireBrokerTopicObjectMissingAbstract: OpenaireBrokerTopicObject = {
export const notificationsBrokerTopicObjectMissingAbstract: NotificationsBrokerTopicObject = {
type: new ResourceType('nbtopic'),
id: 'ENRICH!MISSING!ABSTRACT',
name: 'ENRICH/MISSING/ABSTRACT',
@@ -1384,7 +1384,7 @@ export const openaireBrokerTopicObjectMissingAbstract: OpenaireBrokerTopicObject
}
};
export const openaireBrokerTopicObjectMissingAcm: OpenaireBrokerTopicObject = {
export const notificationsBrokerTopicObjectMissingAcm: NotificationsBrokerTopicObject = {
type: new ResourceType('nbtopic'),
id: 'ENRICH!MISSING!SUBJECT!ACM',
name: 'ENRICH/MISSING/SUBJECT/ACM',
@@ -1397,7 +1397,7 @@ export const openaireBrokerTopicObjectMissingAcm: OpenaireBrokerTopicObject = {
}
};
export const openaireBrokerTopicObjectMissingProject: OpenaireBrokerTopicObject = {
export const notificationsBrokerTopicObjectMissingProject: NotificationsBrokerTopicObject = {
type: new ResourceType('nbtopic'),
id: 'ENRICH!MISSING!PROJECT',
name: 'ENRICH/MISSING/PROJECT',
@@ -1413,7 +1413,7 @@ export const openaireBrokerTopicObjectMissingProject: OpenaireBrokerTopicObject
// Events
// -------------------------------------------------------------------------------
export const openaireBrokerEventObjectMissingPid: OpenaireBrokerEventObject = {
export const notificationsBrokerEventObjectMissingPid: NotificationsBrokerEventObject = {
id: '123e4567-e89b-12d3-a456-426614174001',
uuid: '123e4567-e89b-12d3-a456-426614174001',
type: new ResourceType('nbevent'),
@@ -1449,10 +1449,10 @@ export const openaireBrokerEventObjectMissingPid: OpenaireBrokerEventObject = {
related: observableOf(createSuccessfulRemoteDataObject(ItemMockPid10))
};
export const openaireBrokerEventObjectMissingPid2: OpenaireBrokerEventObject = {
export const notificationsBrokerEventObjectMissingPid2: NotificationsBrokerEventObject = {
id: '123e4567-e89b-12d3-a456-426614174004',
uuid: '123e4567-e89b-12d3-a456-426614174004',
type: new ResourceType('openaireBrokerEvent'),
type: new ResourceType('notificationsBrokerEvent'),
originalId: 'oai:www.openstarts.units.it:10077/21486',
title: 'UNA NUOVA RILETTURA DELL\u0027 ARISTOTELE DI FRANZ BRENTANO ALLA LUCE DI ALCUNI INEDITI',
trust: 1.0,
@@ -1485,10 +1485,10 @@ export const openaireBrokerEventObjectMissingPid2: OpenaireBrokerEventObject = {
related: observableOf(createSuccessfulRemoteDataObject(ItemMockPid10))
};
export const openaireBrokerEventObjectMissingPid3: OpenaireBrokerEventObject = {
export const notificationsBrokerEventObjectMissingPid3: NotificationsBrokerEventObject = {
id: '123e4567-e89b-12d3-a456-426614174005',
uuid: '123e4567-e89b-12d3-a456-426614174005',
type: new ResourceType('openaireBrokerEvent'),
type: new ResourceType('notificationsBrokerEvent'),
originalId: 'oai:www.openstarts.units.it:10077/554',
title: 'Sustainable development',
trust: 0.375,
@@ -1521,10 +1521,10 @@ export const openaireBrokerEventObjectMissingPid3: OpenaireBrokerEventObject = {
related: observableOf(createSuccessfulRemoteDataObject(ItemMockPid10))
};
export const openaireBrokerEventObjectMissingPid4: OpenaireBrokerEventObject = {
export const notificationsBrokerEventObjectMissingPid4: NotificationsBrokerEventObject = {
id: '123e4567-e89b-12d3-a456-426614174006',
uuid: '123e4567-e89b-12d3-a456-426614174006',
type: new ResourceType('openaireBrokerEvent'),
type: new ResourceType('notificationsBrokerEvent'),
originalId: 'oai:www.openstarts.units.it:10077/10787',
title: 'Reply to Critics',
trust: 1.0,
@@ -1557,10 +1557,10 @@ export const openaireBrokerEventObjectMissingPid4: OpenaireBrokerEventObject = {
related: observableOf(createSuccessfulRemoteDataObject(ItemMockPid10))
};
export const openaireBrokerEventObjectMissingPid5: OpenaireBrokerEventObject = {
export const notificationsBrokerEventObjectMissingPid5: NotificationsBrokerEventObject = {
id: '123e4567-e89b-12d3-a456-426614174007',
uuid: '123e4567-e89b-12d3-a456-426614174007',
type: new ResourceType('openaireBrokerEvent'),
type: new ResourceType('notificationsBrokerEvent'),
originalId: 'oai:www.openstarts.units.it:10077/11339',
title: 'PROGETTAZIONE, SINTESI E VALUTAZIONE DELL\u0027ATTIVITA\u0027 ANTIMICOBATTERICA ED ANTIFUNGINA DI NUOVI DERIVATI ETEROCICLICI',
trust: 0.375,
@@ -1593,10 +1593,10 @@ export const openaireBrokerEventObjectMissingPid5: OpenaireBrokerEventObject = {
related: observableOf(createSuccessfulRemoteDataObject(ItemMockPid10))
};
export const openaireBrokerEventObjectMissingPid6: OpenaireBrokerEventObject = {
export const notificationsBrokerEventObjectMissingPid6: NotificationsBrokerEventObject = {
id: '123e4567-e89b-12d3-a456-426614174008',
uuid: '123e4567-e89b-12d3-a456-426614174008',
type: new ResourceType('openaireBrokerEvent'),
type: new ResourceType('notificationsBrokerEvent'),
originalId: 'oai:www.openstarts.units.it:10077/29860',
title: 'Donald Davidson',
trust: 0.375,
@@ -1629,10 +1629,10 @@ export const openaireBrokerEventObjectMissingPid6: OpenaireBrokerEventObject = {
related: observableOf(createSuccessfulRemoteDataObject(ItemMockPid10))
};
export const openaireBrokerEventObjectMissingAbstract: OpenaireBrokerEventObject = {
export const notificationsBrokerEventObjectMissingAbstract: NotificationsBrokerEventObject = {
id: '123e4567-e89b-12d3-a456-426614174009',
uuid: '123e4567-e89b-12d3-a456-426614174009',
type: new ResourceType('openaireBrokerEvent'),
type: new ResourceType('notificationsBrokerEvent'),
originalId: 'oai:www.openstarts.units.it:10077/21110',
title: 'Missing abstract article',
trust: 0.751,
@@ -1665,10 +1665,10 @@ export const openaireBrokerEventObjectMissingAbstract: OpenaireBrokerEventObject
related: observableOf(createSuccessfulRemoteDataObject(ItemMockPid10))
};
export const openaireBrokerEventObjectMissingProjectFound: OpenaireBrokerEventObject = {
export const notificationsBrokerEventObjectMissingProjectFound: NotificationsBrokerEventObject = {
id: '123e4567-e89b-12d3-a456-426614174002',
uuid: '123e4567-e89b-12d3-a456-426614174002',
type: new ResourceType('openaireBrokerEvent'),
type: new ResourceType('notificationsBrokerEvent'),
originalId: 'oai:www.openstarts.units.it:10077/21838',
title: 'Egypt, crossroad of translations and literary interweavings (3rd-6th centuries). A reconsideration of earlier Coptic literature',
trust: 1.0,
@@ -1701,10 +1701,10 @@ export const openaireBrokerEventObjectMissingProjectFound: OpenaireBrokerEventOb
related: createSuccessfulRemoteDataObject$(ItemMockPid10)
};
export const openaireBrokerEventObjectMissingProjectNotFound: OpenaireBrokerEventObject = {
export const notificationsBrokerEventObjectMissingProjectNotFound: NotificationsBrokerEventObject = {
id: '123e4567-e89b-12d3-a456-426614174003',
uuid: '123e4567-e89b-12d3-a456-426614174003',
type: new ResourceType('openaireBrokerEvent'),
type: new ResourceType('notificationsBrokerEvent'),
originalId: 'oai:www.openstarts.units.it:10077/21838',
title: 'Morocco, crossroad of translations and literary interweavings (3rd-6th centuries). A reconsideration of earlier Coptic literature',
trust: 1.0,
@@ -1741,37 +1741,37 @@ export const openaireBrokerEventObjectMissingProjectNotFound: OpenaireBrokerEven
// -------------------------------------------------------------------------------
/**
* Mock for [[OpenaireStateService]]
* Mock for [[NotificationsStateService]]
*/
export function getMockOpenaireStateService(): any {
return jasmine.createSpyObj('OpenaireStateService', {
getOpenaireBrokerTopics: jasmine.createSpy('getOpenaireBrokerTopics'),
isOpenaireBrokerTopicsLoading: jasmine.createSpy('isOpenaireBrokerTopicsLoading'),
isOpenaireBrokerTopicsLoaded: jasmine.createSpy('isOpenaireBrokerTopicsLoaded'),
isOpenaireBrokerTopicsProcessing: jasmine.createSpy('isOpenaireBrokerTopicsProcessing'),
getOpenaireBrokerTopicsTotalPages: jasmine.createSpy('getOpenaireBrokerTopicsTotalPages'),
getOpenaireBrokerTopicsCurrentPage: jasmine.createSpy('getOpenaireBrokerTopicsCurrentPage'),
getOpenaireBrokerTopicsTotals: jasmine.createSpy('getOpenaireBrokerTopicsTotals'),
dispatchRetrieveOpenaireBrokerTopics: jasmine.createSpy('dispatchRetrieveOpenaireBrokerTopics'),
export function getMockNotificationsStateService(): any {
return jasmine.createSpyObj('NotificationsStateService', {
getNotificationsBrokerTopics: jasmine.createSpy('getNotificationsBrokerTopics'),
isNotificationsBrokerTopicsLoading: jasmine.createSpy('isNotificationsBrokerTopicsLoading'),
isNotificationsBrokerTopicsLoaded: jasmine.createSpy('isNotificationsBrokerTopicsLoaded'),
isNotificationsBrokerTopicsProcessing: jasmine.createSpy('isNotificationsBrokerTopicsProcessing'),
getNotificationsBrokerTopicsTotalPages: jasmine.createSpy('getNotificationsBrokerTopicsTotalPages'),
getNotificationsBrokerTopicsCurrentPage: jasmine.createSpy('getNotificationsBrokerTopicsCurrentPage'),
getNotificationsBrokerTopicsTotals: jasmine.createSpy('getNotificationsBrokerTopicsTotals'),
dispatchRetrieveNotificationsBrokerTopics: jasmine.createSpy('dispatchRetrieveNotificationsBrokerTopics'),
dispatchMarkUserSuggestionsAsVisitedAction: jasmine.createSpy('dispatchMarkUserSuggestionsAsVisitedAction')
});
}
/**
* Mock for [[OpenaireBrokerTopicRestService]]
* Mock for [[NotificationsBrokerTopicRestService]]
*/
export function getMockOpenaireBrokerTopicRestService(): OpenaireBrokerTopicRestService {
return jasmine.createSpyObj('OpenaireBrokerTopicRestService', {
export function getMockNotificationsBrokerTopicRestService(): NotificationsBrokerTopicRestService {
return jasmine.createSpyObj('NotificationsBrokerTopicRestService', {
getTopics: jasmine.createSpy('getTopics'),
getTopic: jasmine.createSpy('getTopic'),
});
}
/**
* Mock for [[OpenaireBrokerEventRestService]]
* Mock for [[NotificationsBrokerEventRestService]]
*/
export function getMockOpenaireBrokerEventRestService(): OpenaireBrokerEventRestService {
return jasmine.createSpyObj('OpenaireBrokerEventRestService', {
export function getMockNotificationsBrokerEventRestService(): NotificationsBrokerEventRestService {
return jasmine.createSpyObj('NotificationsBrokerEventRestService', {
getEventsByTopic: jasmine.createSpy('getEventsByTopic'),
getEvent: jasmine.createSpy('getEvent'),
patchEvent: jasmine.createSpy('patchEvent'),
@@ -1782,7 +1782,7 @@ export function getMockOpenaireBrokerEventRestService(): OpenaireBrokerEventRest
}
/**
* Mock for [[OpenaireBrokerEventRestService]]
* Mock for [[NotificationsBrokerEventRestService]]
*/
export function getMockSuggestionsService(): any {
return jasmine.createSpyObj('SuggestionsService', {

View File

@@ -479,13 +479,13 @@
"admin.access-control.groups.form.return": "Back",
"admin.notifications.openairebroker.breadcrumbs": "OpenAIRE Broker",
"admin.notifications.broker.breadcrumbs": "Notifications Broker",
"admin.notifications.openairebroker.page.title": "OpenAIRE Broker",
"admin.notifications.event.breadcrumbs": "Broker Suggestions",
"admin.notifications.openaireevent.breadcrumbs": "OpenAIRE Broker Suggestions",
"admin.notifications.event.page.title": "Broker Suggestions",
"admin.notifications.openaireevent.page.title": "OpenAIRE Broker Suggestions",
"admin.notifications.broker.page.title": "Notifications Broker",
"admin.search.breadcrumbs": "Administrative Search",
@@ -2544,7 +2544,7 @@
"menu.section.notifications": "Notifications",
"menu.section.notifications_openaire_broker": "OpenAIRE Broker",
"menu.section.notifications_broker": "Notifications Broker",
"menu.section.notifications_reciter": "Publication Claim",
@@ -2713,125 +2713,125 @@
"none.listelement.badge": "Item",
"openaire.broker.title": "OpenAIRE Broker",
"notifications.broker.title": "{{source}} Broker",
"openaire.broker.topics.description": "Below you can see all the topics received from the subscriptions to OpenAIRE.",
"notifications.broker.topics.description": "Below you can see all the topics received from the subscriptions to {{source}}.",
"openaire.broker.topics": "Current Topics",
"notifications.broker.topics": "Current Topics",
"openaire.broker.table.topic": "Topic",
"notifications.broker.table.topic": "Topic",
"openaire.broker.table.last-event": "Last Event",
"notifications.broker.table.last-event": "Last Event",
"openaire.broker.table.actions": "Actions",
"notifications.broker.table.actions": "Actions",
"openaire.broker.button.detail": "Show details",
"notifications.broker.button.detail": "Show details",
"openaire.broker.noTopics": "No topics found.",
"notifications.broker.noTopics": "No topics found.",
"openaire.broker.topic.error.service.retrieve": "An error occurred while loading the OpenAIRE Broker topics",
"notifications.events.title": "{{source}} Broker Suggestions",
"openaire.broker.loading": "Loading ...",
"notifications.broker.topic.error.service.retrieve": "An error occurred while loading the Notifications Broker topics",
"openaire.events.title": "OpenAIRE Broker Suggestions",
"notifications.broker.events.description": "Below the list of all the suggestions, received from {{source}}, for the selected topic.",
"openaire.broker.events.description": "Below the list of all the suggestions, received from OpenAIRE, for the selected topic.",
"notifications.broker.loading": "Loading ...",
"openaire.broker.events.topic": "Topic:",
"notifications.broker.events.topic": "Topic:",
"openaire.broker.noEvents": "No suggestions found.",
"notifications.broker.noEvents": "No suggestions found.",
"openaire.broker.event.table.trust": "Trust",
"notifications.broker.event.table.trust": "Trust",
"openaire.broker.event.table.publication": "Publication",
"notifications.broker.event.table.publication": "Publication",
"openaire.broker.event.table.details": "Details",
"notifications.broker.event.table.details": "Details",
"openaire.broker.event.table.project-details": "Project details",
"notifications.broker.event.table.project-details": "Project details",
"openaire.broker.event.table.actions": "Actions",
"notifications.broker.event.table.actions": "Actions",
"openaire.broker.event.action.accept": "Accept suggestion",
"notifications.broker.event.action.accept": "Accept suggestion",
"openaire.broker.event.action.ignore": "Ignore suggestion",
"notifications.broker.event.action.ignore": "Ignore suggestion",
"openaire.broker.event.action.reject": "Reject suggestion",
"notifications.broker.event.action.reject": "Reject suggestion",
"openaire.broker.event.action.import": "Import project and accept suggestion",
"notifications.broker.event.action.import": "Import project and accept suggestion",
"openaire.broker.event.table.pidtype": "PID Type:",
"notifications.broker.event.table.pidtype": "PID Type:",
"openaire.broker.event.table.pidvalue": "PID Value:",
"notifications.broker.event.table.pidvalue": "PID Value:",
"openaire.broker.event.table.subjectValue": "Subject Value:",
"notifications.broker.event.table.subjectValue": "Subject Value:",
"openaire.broker.event.table.abstract": "Abstract:",
"notifications.broker.event.table.abstract": "Abstract:",
"openaire.broker.event.table.suggestedProject": "OpenAIRE Suggested Project data",
"notifications.broker.event.table.suggestedProject": "OpenAIRE Suggested Project data",
"openaire.broker.event.table.project": "Project title:",
"notifications.broker.event.table.project": "Project title:",
"openaire.broker.event.table.acronym": "Acronym:",
"notifications.broker.event.table.acronym": "Acronym:",
"openaire.broker.event.table.code": "Code:",
"notifications.broker.event.table.code": "Code:",
"openaire.broker.event.table.funder": "Funder:",
"notifications.broker.event.table.funder": "Funder:",
"openaire.broker.event.table.fundingProgram": "Funding program:",
"notifications.broker.event.table.fundingProgram": "Funding program:",
"openaire.broker.event.table.jurisdiction": "Jurisdiction:",
"notifications.broker.event.table.jurisdiction": "Jurisdiction:",
"openaire.broker.events.back": "Back to topics",
"notifications.broker.events.back": "Back to topics",
"openaire.broker.event.table.less": "Show less",
"notifications.broker.event.table.less": "Show less",
"openaire.broker.event.table.more": "Show more",
"notifications.broker.event.table.more": "Show more",
"openaire.broker.event.project.found": "Bound to the local record:",
"notifications.broker.event.project.found": "Bound to the local record:",
"openaire.broker.event.project.notFound": "No local record found",
"notifications.broker.event.project.notFound": "No local record found",
"openaire.broker.event.sure": "Are you sure?",
"notifications.broker.event.sure": "Are you sure?",
"openaire.broker.event.ignore.description": "This operation can't be undone. Ignore this suggestion?",
"notifications.broker.event.ignore.description": "This operation can't be undone. Ignore this suggestion?",
"openaire.broker.event.reject.description": "This operation can't be undone. Reject this suggestion?",
"notifications.broker.event.reject.description": "This operation can't be undone. Reject this suggestion?",
"openaire.broker.event.accept.description": "No DSpace project selected. A new project will be created based on the suggestion data.",
"notifications.broker.event.accept.description": "No DSpace project selected. A new project will be created based on the suggestion data.",
"openaire.broker.event.action.cancel": "Cancel",
"notifications.broker.event.action.cancel": "Cancel",
"openaire.broker.event.action.saved": "Your decision has been saved successfully.",
"notifications.broker.event.action.saved": "Your decision has been saved successfully.",
"openaire.broker.event.action.error": "An error has occurred. Your decision has not been saved.",
"notifications.broker.event.action.error": "An error has occurred. Your decision has not been saved.",
"openaire.broker.event.modal.project.title": "Choose a project to bound",
"notifications.broker.event.modal.project.title": "Choose a project to bound",
"openaire.broker.event.modal.project.publication": "Publication:",
"notifications.broker.event.modal.project.publication": "Publication:",
"openaire.broker.event.modal.project.bountToLocal": "Bound to the local record:",
"notifications.broker.event.modal.project.bountToLocal": "Bound to the local record:",
"openaire.broker.event.modal.project.select": "Project search",
"notifications.broker.event.modal.project.select": "Project search",
"openaire.broker.event.modal.project.search": "Search",
"notifications.broker.event.modal.project.search": "Search",
"openaire.broker.event.modal.project.clear": "Clear",
"notifications.broker.event.modal.project.clear": "Clear",
"openaire.broker.event.modal.project.cancel": "Cancel",
"notifications.broker.event.modal.project.cancel": "Cancel",
"openaire.broker.event.modal.project.bound": "Bound project",
"notifications.broker.event.modal.project.bound": "Bound project",
"openaire.broker.event.modal.project.placeholder": "Enter a project name",
"notifications.broker.event.modal.project.placeholder": "Enter a project name",
"openaire.broker.event.modal.project.notFound": "No project found.",
"notifications.broker.event.modal.project.notFound": "No project found.",
"openaire.broker.event.project.bounded": "The project has been linked successfully.",
"notifications.broker.event.project.bounded": "The project has been linked successfully.",
"openaire.broker.event.project.removed": "The project has been successfully unlinked.",
"notifications.broker.event.project.removed": "The project has been successfully unlinked.",
"openaire.broker.event.project.error": "An error has occurred. No operation performed.",
"notifications.broker.event.project.error": "An error has occurred. No operation performed.",
"openaire.broker.event.reason": "Reason",
"notifications.broker.event.reason": "Reason",
"orgunit.listelement.badge": "Organizational Unit",