Merge branch 'master' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot
This commit is contained in:
commit
a4fee58983
|
@ -19,6 +19,7 @@ import { DatasetProfileService } from './services/dataset-profile.service';
|
||||||
import { DmpsServiceService } from './services/dmps-service.service';
|
import { DmpsServiceService } from './services/dmps-service.service';
|
||||||
import { ProjectService } from './services/project-service';
|
import { ProjectService } from './services/project-service';
|
||||||
import { ServiceService } from './services/service-service';
|
import { ServiceService } from './services/service-service';
|
||||||
|
import { ResearcherService } from './services/researcher-service';
|
||||||
import { OrganisationService } from './services/organisation-service';
|
import { OrganisationService } from './services/organisation-service';
|
||||||
import { DmpProfileService } from './services/dmpprofile-service';
|
import { DmpProfileService } from './services/dmpprofile-service';
|
||||||
import { RegistryService } from './services/registry-service';
|
import { RegistryService } from './services/registry-service';
|
||||||
|
@ -31,6 +32,8 @@ import { DmpProfileTableFilterPipe } from './pipes/dmp-profile-table-filter.pipe
|
||||||
import { ProjectTableFilterPipe } from './pipes/project-table-filter.pipe';
|
import { ProjectTableFilterPipe } from './pipes/project-table-filter.pipe';
|
||||||
import { RegistryTableFilterPipe } from './pipes/registry-table-filter.pipe';
|
import { RegistryTableFilterPipe } from './pipes/registry-table-filter.pipe';
|
||||||
import { OrganisationTableFilterPipe } from './pipes/organisation-table-filter.pipe';
|
import { OrganisationTableFilterPipe } from './pipes/organisation-table-filter.pipe';
|
||||||
|
import { ResearcherTableFilterPipe } from './pipes/researcher-table-filter.pipe';
|
||||||
|
|
||||||
|
|
||||||
import { GooggleSignInComponent } from './login/googgle-sign-in/googgle-sign-in.component';
|
import { GooggleSignInComponent } from './login/googgle-sign-in/googgle-sign-in.component';
|
||||||
import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component';
|
import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component';
|
||||||
|
@ -49,6 +52,7 @@ import { DmpProfileEditorComponent } from './managers/dmp-profile-editor/dmp-pro
|
||||||
import { OrganisationEditorComponent } from './managers/organisation-editor/organisation-editor.component';
|
import { OrganisationEditorComponent } from './managers/organisation-editor/organisation-editor.component';
|
||||||
import { RegistryEditorComponent } from './managers/registry-editor/registry-editor.component';
|
import { RegistryEditorComponent } from './managers/registry-editor/registry-editor.component';
|
||||||
import { ServiceEditorComponent } from './managers/service-editor/service-editor.component';
|
import { ServiceEditorComponent } from './managers/service-editor/service-editor.component';
|
||||||
|
import { ResearcherEditorComponent } from './managers/researcher-editor/researcher-editor.component';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,6 +65,7 @@ import { ServiceEditorComponent } from './managers/service-editor/service-editor
|
||||||
OrganisationTableFilterPipe,
|
OrganisationTableFilterPipe,
|
||||||
RegistryTableFilterPipe,
|
RegistryTableFilterPipe,
|
||||||
ServiceTableFilterPipe,
|
ServiceTableFilterPipe,
|
||||||
|
ResearcherTableFilterPipe,
|
||||||
|
|
||||||
AppComponent,
|
AppComponent,
|
||||||
GooggleSignInComponent,
|
GooggleSignInComponent,
|
||||||
|
@ -76,7 +81,8 @@ import { ServiceEditorComponent } from './managers/service-editor/service-editor
|
||||||
OrganisationEditorComponent,
|
OrganisationEditorComponent,
|
||||||
RegistryEditorComponent,
|
RegistryEditorComponent,
|
||||||
ServiceEditorComponent,
|
ServiceEditorComponent,
|
||||||
MainSignInComponent
|
MainSignInComponent,
|
||||||
|
ResearcherEditorComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -90,7 +96,7 @@ import { ServiceEditorComponent } from './managers/service-editor/service-editor
|
||||||
NgbModule.forRoot(),
|
NgbModule.forRoot(),
|
||||||
AppRouting
|
AppRouting
|
||||||
],
|
],
|
||||||
providers: [ DatasetsServiceService, TokenService, DmpsServiceService,
|
providers: [ DatasetsServiceService, TokenService, DmpsServiceService, ResearcherService,
|
||||||
DialogService, DatasetProfileService, ProjectService, OrganisationService,
|
DialogService, DatasetProfileService, ProjectService, OrganisationService,
|
||||||
DmpProfileService, RegistryService, ServiceService, NativeLoginService, HttpModule, Toolbox, HttpClient, RestBase],
|
DmpProfileService, RegistryService, ServiceService, NativeLoginService, HttpModule, Toolbox, HttpClient, RestBase],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
|
|
|
@ -45,6 +45,7 @@ export class MainSignInComponent implements OnInit {
|
||||||
|
|
||||||
this.nativeLogin.login(this.creds.username, this.creds.password).subscribe(
|
this.nativeLogin.login(this.creds.username, this.creds.password).subscribe(
|
||||||
response => {
|
response => {
|
||||||
|
|
||||||
simple_notifier("success",null,"Successful login");
|
simple_notifier("success",null,"Successful login");
|
||||||
|
|
||||||
this.tokenService.setLoggedIn(true);
|
this.tokenService.setLoggedIn(true);
|
||||||
|
|
|
@ -59,6 +59,13 @@
|
||||||
<li [ngClass]="{true:'active'}[currentlySelected=='services']" (click)="setActive('services')" [routerLink]="['/services']">All services</li>
|
<li [ngClass]="{true:'active'}[currentlySelected=='services']" (click)="setActive('services')" [routerLink]="['/services']">All services</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<li data-toggle="collapse" data-target="#manage-researchers" class="collapsed">
|
||||||
|
<a style="cursor:pointer"><i class="fa fa-newspaper-o"></i>Manage Researchers <span class="arrow"></span></a>
|
||||||
|
</li>
|
||||||
|
<ul class="sub-menu collapse" id="manage-researchers">
|
||||||
|
<li [ngClass]="{true:'active'}[currentlySelected=='researchers']" (click)="setActive('researchers')" [routerLink]="['/researchers']">All researchers</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<li data-toggle="collapse" data-target="#manage-users" class="collapsed">
|
<li data-toggle="collapse" data-target="#manage-users" class="collapsed">
|
||||||
<a style="cursor:pointer"><i class="fa fa-newspaper-o"></i> Users <span class="arrow"></span></a>
|
<a style="cursor:pointer"><i class="fa fa-newspaper-o"></i> Users <span class="arrow"></span></a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -76,78 +83,3 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--
|
|
||||||
|
|
||||||
<div class="nav-side-menu">
|
|
||||||
<div class="brand">Quick Navigation</div>
|
|
||||||
<i class="fa fa-bars fa-2x toggle-btn" data-toggle="collapse" data-target="#menu-content"></i>
|
|
||||||
|
|
||||||
<div class="menu-list">
|
|
||||||
|
|
||||||
<ul id="menu-content" class="menu-content collapse out">
|
|
||||||
|
|
||||||
<li data-toggle="collapse" data-target="#products" class="collapsed active">
|
|
||||||
<a style="cursor:pointer"><i class="fa fa-gift fa-lg"></i> Manage Datasets <span class="arrow"></span></a>
|
|
||||||
</li>
|
|
||||||
<ul class="sub-menu collapse" id="products">
|
|
||||||
<li class="active"><a style="cursor:pointer">Datasets</a></li>
|
|
||||||
<li><a style="cursor:pointer">Dataset Profiles</a></li>
|
|
||||||
<li><a style="cursor:pointer">Buttons</a></li>
|
|
||||||
<li><a style="cursor:pointer">Tabs & Accordions</a></li>
|
|
||||||
<li><a style="cursor:pointer">Typography</a></li>
|
|
||||||
<li><a style="cursor:pointer">FontAwesome</a></li>
|
|
||||||
<li><a style="cursor:pointer">Slider</a></li>
|
|
||||||
<li><a style="cursor:pointer">Panels</a></li>
|
|
||||||
<li><a style="cursor:pointer">Widgets</a></li>
|
|
||||||
<li><a style="cursor:pointer">Bootstrap Model</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<li data-toggle="collapse" data-target="#service" class="collapsed">
|
|
||||||
<a style="cursor:pointer"><i class="fa fa-globe fa-lg"></i> Services <span class="arrow"></span></a>
|
|
||||||
</li>
|
|
||||||
<ul class="sub-menu collapse" id="service">
|
|
||||||
<li>New Service 1</li>
|
|
||||||
<li>New Service 2</li>
|
|
||||||
<li>New Service 3</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<li data-toggle="collapse" data-target="#new" class="collapsed">
|
|
||||||
<a style="cursor:pointer"><i class="fa fa-car fa-lg"></i> New <span class="arrow"></span></a>
|
|
||||||
</li>
|
|
||||||
<ul class="sub-menu collapse" id="new">
|
|
||||||
<li>New New 1</li>
|
|
||||||
<li>New New 2</li>
|
|
||||||
<li>New New 3</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<a style="cursor:pointer">
|
|
||||||
<i class="fa fa-user fa-lg"></i> Profile
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<a style="cursor:pointer">
|
|
||||||
<i class="fa fa-users fa-lg"></i> Users
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
-->
|
|
|
@ -137,10 +137,11 @@ export class DmpEditorComponent implements OnInit {
|
||||||
this.dmpsServiceService.delete(dmp).subscribe(
|
this.dmpsServiceService.delete(dmp).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
simple_notifier("success",null,"Deleted dataset");
|
simple_notifier("success",null,"Deleted dataset");
|
||||||
console.log(response);
|
this.getAllDmps(false);
|
||||||
|
this.switchToTable();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
|
simple_notifier("danger",null,"Could not delete dmp");
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,9 +111,11 @@ export class DmpProfileEditorComponent implements OnInit {
|
||||||
this.dmpProfileService.delete(dmpProfile).subscribe(
|
this.dmpProfileService.delete(dmpProfile).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
simple_notifier("success",null,"Deleted DMP Profile");
|
simple_notifier("success",null,"Deleted DMP Profile");
|
||||||
|
this.getAllDmpProfiles(false);
|
||||||
|
this.switchToTable();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
|
simple_notifier("danger",null,"Could not delete DMP Profile");
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,10 +111,11 @@ export class OrganisationEditorComponent implements OnInit {
|
||||||
this.organisationService.delete(organisation).subscribe(
|
this.organisationService.delete(organisation).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
simple_notifier("success",null,"Deleted organisation");
|
simple_notifier("success",null,"Deleted organisation");
|
||||||
|
this.refreshTable(false);
|
||||||
|
this.switchToTable();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
simple_notifier("danger",null,"Could not delete organisation");
|
simple_notifier("danger",null,"Could not delete organisation");
|
||||||
console.log(err);
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,11 +116,11 @@ export class ProjectEditorComponent implements OnInit {
|
||||||
this.projectService.delete(project).subscribe(
|
this.projectService.delete(project).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
simple_notifier("success",null,"Deleted project");
|
simple_notifier("success",null,"Deleted project");
|
||||||
console.log(response);
|
this.getAllProjects(false);
|
||||||
|
this.switchToTable();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
simple_notifier("danger",null,"Could not delete project");
|
simple_notifier("danger",null,"Could not delete project");
|
||||||
console.log(err);
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,9 +113,11 @@ export class RegistryEditorComponent implements OnInit {
|
||||||
this.registryService.delete(registry).subscribe(
|
this.registryService.delete(registry).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
simple_notifier("success",null,"Deleted registry");
|
simple_notifier("success",null,"Deleted registry");
|
||||||
|
this.switchToTable();
|
||||||
|
this.refreshTable(false);
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
|
simple_notifier("danger",null,"Could not delete registry");
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
.invisible {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.visible {
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.hover:hover > * {
|
||||||
|
background-color: #eeeeee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-container{
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-150px {
|
||||||
|
max-width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ng-template{
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grayout-empty-table {
|
||||||
|
opacity: 0.6; /* Real browsers */
|
||||||
|
filter: alpha(opacity = 60); /* MSIE */
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
|
||||||
|
<div class="editor-container container">
|
||||||
|
|
||||||
|
<div [ngClass]="{true:'visible', false:'invisible'}[tableVisible]">
|
||||||
|
<table class="table table-striped" [mfData]="tableData | researcherTableFilter : filterQuery" #mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">
|
||||||
|
<input class="form-control" [(ngModel)]="filterQuery" placeholder='Filter'/>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<button class="btn btn-default" (click)="refreshTable($event)">
|
||||||
|
<span class="glyphicon glyphicon-refresh"></span>
|
||||||
|
</button>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th [ngClass]="{true:'visible', false:'invisible'}[showIDs]"><mfDefaultSorter by="id">ID</mfDefaultSorter></th>
|
||||||
|
<th><mfDefaultSorter by="label">Label</mfDefaultSorter></th>
|
||||||
|
<th><mfDefaultSorter by="uri">Uri</mfDefaultSorter></th>
|
||||||
|
<th><mfDefaultSorter by="primaryEmail">PrimaryEmail</mfDefaultSorter></th>
|
||||||
|
<th><mfDefaultSorter by="definition">Definition</mfDefaultSorter></th>
|
||||||
|
<th><mfDefaultSorter by="reference">Reference</mfDefaultSorter></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="grayout-empty-table" *ngIf="!mf.data[0]" [contextMenu]="basicMenu" [contextMenuSubject]="researcher"> <td colspan="5">No elements</td></tr>
|
||||||
|
|
||||||
|
<tr *ngFor="let researcher of mf.data" class="hover" [contextMenu]="basicMenu" [contextMenuSubject]="researcher">
|
||||||
|
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{researcher.id}}</td>
|
||||||
|
<td>{{researcher?.label}}</td>
|
||||||
|
<td>{{researcher?.uri}}</td>
|
||||||
|
<td>{{researcher?.primaryEmail}}</td>
|
||||||
|
<td>{{researcher?.definition}}</td>
|
||||||
|
<td>{{researcher?.reference}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5">
|
||||||
|
<mfBootstrapPaginator [rowsOnPageSet]="[10,20,40]"></mfBootstrapPaginator>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- this is the dmp editor -->
|
||||||
|
<div [ngClass]="{true:'visible', false:'invisible'}[editorVisible]">
|
||||||
|
|
||||||
|
<div> <!-- form container -->
|
||||||
|
<div style="display:block;">
|
||||||
|
<button (click)="switchToTable()" class="btn btn-lg btn-success pull-right" style="max-width:120px;">
|
||||||
|
<span class="glyphicon glyphicon-arrow-left"></span> Go back
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form [formGroup]="researcherEditorForm" novalidate style="display:block;">
|
||||||
|
<div class="form-group" [ngClass]="{null:'invisible'}[editingResearcher?.id]">
|
||||||
|
<label class="center-block">ID: {{editingResearcher?.id}}
|
||||||
|
<input class="form-control invisible" formControlName="id" [ngModel]="editingResearcher?.id">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="center-block">Label:
|
||||||
|
<input class="form-control" formControlName="label" [ngModel]="editingResearcher?.label" (ngModelChange)="editingResearcher.label=$event">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="center-block">Uri:
|
||||||
|
<input class="form-control" formControlName="uri" [ngModel]="editingResearcher?.uri" (ngModelChange)="editingResearcher.uri$event">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="center-block">Primary Email:
|
||||||
|
<input class="form-control" formControlName="primaryEmail" [ngModel]="editingResearcher?.primaryEmail" (ngModelChange)="editingResearcher.primaryEmail=$event">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="center-block">Definition:
|
||||||
|
<input class="form-control" formControlName="definition" [ngModel]="editingResearcher?.definition" (ngModelChange)="editingResearcher.definition$event">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="center-block">Reference:
|
||||||
|
<input class="form-control" formControlName="reference" [ngModel]="editingResearcher?.reference" (ngModelChange)="editingResearcher.reference$event">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" style="width:540px;">
|
||||||
|
<button style="float:right;" type="submit" (click)="save($event, $data, $form)"class="btn btn-success">Save</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<p>Form value: {{ researcherEditorForm.value | json }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<context-menu>
|
||||||
|
<ng-template contextMenuItem [subMenu]="manage">
|
||||||
|
<span></span>Manage researchers
|
||||||
|
</ng-template>
|
||||||
|
<context-menu #manage>
|
||||||
|
<ng-template contextMenuItem (execute)="newResearcher($event?.item)">
|
||||||
|
<span class="glyphicon glyphicon-plus"></span>Create researcher
|
||||||
|
</ng-template>
|
||||||
|
<ng-template contextMenuItem (execute)="editResearcher($event?.item?.id)">
|
||||||
|
<span class="glyphicon glyphicon-pencil"></span>Edit this researcher
|
||||||
|
</ng-template>
|
||||||
|
<ng-template contextMenuItem (execute)="delete($event?.item?.id)">
|
||||||
|
<span class="glyphicon glyphicon-trash red"></span> Delete this
|
||||||
|
</ng-template>
|
||||||
|
</context-menu>
|
||||||
|
<ng-template contextMenuItem>
|
||||||
|
<span></span>Show full tree connections
|
||||||
|
</ng-template>
|
||||||
|
</context-menu>
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ResearcherEditorComponent } from './researcher-editor.component';
|
||||||
|
|
||||||
|
describe('ResearcherEditorComponent', () => {
|
||||||
|
let component: ResearcherEditorComponent;
|
||||||
|
let fixture: ComponentFixture<ResearcherEditorComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ResearcherEditorComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ResearcherEditorComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,134 @@
|
||||||
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||||
|
import { ResearcherService } from '../../services/researcher-service';
|
||||||
|
import { ContextMenuComponent } from 'ngx-contextmenu';
|
||||||
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
|
|
||||||
|
import '../../../assets/custom.js';
|
||||||
|
declare function simple_notifier(type: string, title: string, message:string): any;
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-researcher-editor',
|
||||||
|
templateUrl: './researcher-editor.component.html',
|
||||||
|
styleUrls: ['./researcher-editor.component.css']
|
||||||
|
})
|
||||||
|
export class ResearcherEditorComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor(private researcherService : ResearcherService, private fb: FormBuilder) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//whole dmp data model
|
||||||
|
tableData : any[] = new Array();
|
||||||
|
|
||||||
|
//researcher editor data model
|
||||||
|
editingResearcher: any = {};
|
||||||
|
researcherEditorForm : any;
|
||||||
|
|
||||||
|
//required by the table
|
||||||
|
public filterQuery = "";
|
||||||
|
public rowsOnPage = 10;
|
||||||
|
//public sortBy = "email";
|
||||||
|
public sortOrder = "asc";
|
||||||
|
|
||||||
|
//visibility rules for containers
|
||||||
|
tableVisible: boolean = true;
|
||||||
|
editorVisible: boolean = false;
|
||||||
|
|
||||||
|
|
||||||
|
// for tableIds
|
||||||
|
showIDs : boolean = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.getAllResearchers(false);
|
||||||
|
this.createResearcherEditorForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
createResearcherEditorForm(){
|
||||||
|
this.researcherEditorForm = this.fb.group({
|
||||||
|
id: null,
|
||||||
|
label: ['', Validators.required ],
|
||||||
|
uri: '',
|
||||||
|
primaryEmail: '',
|
||||||
|
definition: '',
|
||||||
|
reference: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
switchToTable(){
|
||||||
|
this.tableVisible = true;
|
||||||
|
this.editorVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switchToEditor(researcherID){
|
||||||
|
|
||||||
|
this.tableVisible = false;
|
||||||
|
this.editorVisible = true;
|
||||||
|
if(researcherID == null){
|
||||||
|
this.editingResearcher = {id: null, label: "", uri: "", primaryEmail: "", definition: "", reference: "" };
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.editingResearcher = this.tableData.filter((researcher) => researcher.id === researcherID)[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getAllResearchers(showNotification : boolean){
|
||||||
|
this.researcherService.getAllResearchers().subscribe( (data) => {
|
||||||
|
this.tableData = data;
|
||||||
|
if(showNotification)
|
||||||
|
simple_notifier("info",null,"Refreshed the table");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
editResearcher(researcher){
|
||||||
|
this.switchToEditor(researcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
newResearcher(){
|
||||||
|
this.switchToEditor(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
save(mouseEvent){
|
||||||
|
this.researcherService.create(this.researcherEditorForm.value).subscribe(
|
||||||
|
response => {
|
||||||
|
simple_notifier("success",null,"Saved resercher");
|
||||||
|
this.getAllResearchers(false);
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
simple_notifier("danger",null,"Could not save researcher");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(resercher){
|
||||||
|
this.researcherService.delete(resercher).subscribe(
|
||||||
|
(response) => {
|
||||||
|
simple_notifier("success",null,"Deleted researcher");
|
||||||
|
this.getAllResearchers(false);
|
||||||
|
this.switchToTable();
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
simple_notifier("danger",null,"Could not delete researcher");
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
refreshTable($event){
|
||||||
|
this.getAllResearchers(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ViewChild(ContextMenuComponent) public basicMenu: ContextMenuComponent;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
import * as _ from "lodash";
|
||||||
|
import {Pipe, PipeTransform} from "@angular/core";
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: "researcherTableFilter"
|
||||||
|
})
|
||||||
|
export class ResearcherTableFilterPipe implements PipeTransform {
|
||||||
|
|
||||||
|
transform(array: any[], query: string): any {
|
||||||
|
|
||||||
|
if (query) {
|
||||||
|
|
||||||
|
return _.filter(array, row => {
|
||||||
|
if (row.uri == null) row.uri = "";
|
||||||
|
if (row.label == null) row.label = "";
|
||||||
|
if (row.id == null) row.id = "";
|
||||||
|
return (
|
||||||
|
|
||||||
|
row.label.indexOf(query) > -1 ||
|
||||||
|
|
||||||
|
//row.version == query ||
|
||||||
|
row.id.indexOf(query) > -1
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import { ProjectEditorComponent } from './managers/project-editor/project-editor
|
||||||
import { ServiceEditorComponent } from './managers/service-editor/service-editor.component';
|
import { ServiceEditorComponent } from './managers/service-editor/service-editor.component';
|
||||||
import { RegistryEditorComponent } from './managers/registry-editor/registry-editor.component';
|
import { RegistryEditorComponent } from './managers/registry-editor/registry-editor.component';
|
||||||
import { OrganisationEditorComponent } from './managers/organisation-editor/organisation-editor.component';
|
import { OrganisationEditorComponent } from './managers/organisation-editor/organisation-editor.component';
|
||||||
|
import { ResearcherEditorComponent } from './managers/researcher-editor/researcher-editor.component';
|
||||||
|
|
||||||
|
|
||||||
import { MainWindowComponent } from './main-window/main-window.component';
|
import { MainWindowComponent } from './main-window/main-window.component';
|
||||||
|
@ -57,6 +58,10 @@ export const routes: Routes = [
|
||||||
path: 'registries',
|
path: 'registries',
|
||||||
component: RegistryEditorComponent
|
component: RegistryEditorComponent
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'researchers',
|
||||||
|
component: ResearcherEditorComponent
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'main',
|
path: 'main',
|
||||||
component: MainWindowComponent
|
component: MainWindowComponent
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
import { Component, Input, OnInit, AfterViewChecked, ViewChild } from '@angular/core';
|
||||||
|
import { HttpClient , HttpHeaders, HttpParams} from '@angular/common/http';
|
||||||
|
import { TokenService, TokenProvider } from './login/token.service'
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Toolbox } from '../services/toolbox';
|
||||||
|
import {RestBase} from './rest-base';
|
||||||
|
import 'rxjs/Rx';
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ResearcherService implements OnInit {
|
||||||
|
|
||||||
|
|
||||||
|
constructor(public restBase: RestBase) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getResearcherIdsLabels() {
|
||||||
|
return this.restBase.get("researcher/listAllLabelIDs");
|
||||||
|
}
|
||||||
|
|
||||||
|
getResearcherIds(){
|
||||||
|
return this.restBase.get("researchers");
|
||||||
|
}
|
||||||
|
|
||||||
|
getAllResearchers(){
|
||||||
|
return this.restBase.get("researcher/getAll");
|
||||||
|
}
|
||||||
|
|
||||||
|
create(researcher){
|
||||||
|
return this.restBase.post("researcher/create", researcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
delete(researcherID){
|
||||||
|
var researcher = {"id": researcherID};
|
||||||
|
return this.restBase.post("researcher/delete", researcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,13 @@ export class RestBase {
|
||||||
restpath: string = "rest";
|
restpath: string = "rest";
|
||||||
|
|
||||||
|
|
||||||
loginPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/";
|
loginPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/login/";
|
||||||
restBasePath: string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/"+this.restpath+"/";
|
restBasePath: string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/"+this.restpath+"/";
|
||||||
|
|
||||||
|
|
||||||
public login(path : string, data : any){
|
public login(path : string, data : any){
|
||||||
return this.http.post<any>(this.loginPath + path, JSON.stringify(data));
|
let options = { headers: new HttpHeaders().set('Content-Type', 'application/json') };
|
||||||
|
return this.http.post<any>(this.loginPath + path, JSON.stringify(data), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get(path : string){
|
public get(path : string){
|
||||||
|
|
|
@ -23,8 +23,7 @@ import org.hibernate.annotations.Type;
|
||||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
|
|
||||||
|
@Entity
|
||||||
@Entity(name="\"DataRepository\"")
|
|
||||||
@Table(name="\"DataRepository\"")
|
@Table(name="\"DataRepository\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||||
public class DataRepository implements Serializable {
|
public class DataRepository implements Serializable {
|
||||||
|
|
|
@ -2,6 +2,9 @@ package rest.entities;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import org.apache.commons.lang3.SerializationUtils;
|
import org.apache.commons.lang3.SerializationUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -66,11 +69,11 @@ public class DataRepositories {
|
||||||
@Autowired private ServiceDao serviceDao;
|
@Autowired private ServiceDao serviceDao;
|
||||||
|
|
||||||
|
|
||||||
|
private ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
// MANAGE DATAREPOSITORy(IES)
|
// MANAGE DATAREPOSITORy(IES)
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/datarepositories" })
|
@RequestMapping(method = RequestMethod.GET, value = { "/datarepos" })
|
||||||
public @ResponseBody ResponseEntity<Object> listDataRepositories(){
|
public @ResponseBody ResponseEntity<Object> listDataRepositories(){
|
||||||
try {
|
try {
|
||||||
List<UUID> allIDs = dataRepositoryDao.listAllIDs();
|
List<UUID> allIDs = dataRepositoryDao.listAllIDs();
|
||||||
|
@ -82,7 +85,7 @@ public class DataRepositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/datarepositories/{id}" })
|
@RequestMapping(method = RequestMethod.GET, value = { "/datarepos/{id}" })
|
||||||
public @ResponseBody ResponseEntity<Object> getDataRepository(@PathVariable("id") String id) {
|
public @ResponseBody ResponseEntity<Object> getDataRepository(@PathVariable("id") String id) {
|
||||||
try {
|
try {
|
||||||
DataRepository dataRepository = dataRepositoryDao.read(UUID.fromString(id));
|
DataRepository dataRepository = dataRepositoryDao.read(UUID.fromString(id));
|
||||||
|
@ -93,28 +96,58 @@ public class DataRepositories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/setDataRepository" }, consumes = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = { "/datarepo/getAll" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Object> setDataRepository(@RequestBody DataRepository dataRepository) {
|
public @ResponseBody ResponseEntity<Object> getAllDataRepositories(){
|
||||||
String reason = "";
|
|
||||||
DataRepository storedDataRepository = null;
|
|
||||||
//try first to create
|
|
||||||
try {
|
try {
|
||||||
storedDataRepository = dataRepositoryDao.create(dataRepository);
|
List<DataRepository> allDataRepositories = dataRepositoryDao.getAll();
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("Created dataRepository with id: " + storedDataRepository.getId());
|
|
||||||
|
//sorry for that, spring-jersey serialisation has issues when performed on tables, so -> custom
|
||||||
|
List<String> datareposStrL = allDataRepositories.parallelStream().map((datarepoObj) -> {
|
||||||
|
try {
|
||||||
|
return objectMapper.writeValueAsString(datarepoObj);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return new ResponseEntity<Object>("["+String.join(",", datareposStrL)+"]", HttpStatus.OK);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception ex) {
|
||||||
reason += e.getMessage();
|
ex.printStackTrace();
|
||||||
//try updating
|
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
try {
|
|
||||||
storedDataRepository = dataRepositoryDao.update(dataRepository);
|
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("Updated dataRepository with id: " + storedDataRepository.getId());
|
|
||||||
}
|
|
||||||
catch(Exception ex) {
|
|
||||||
reason += (System.lineSeparator()+e.getMessage());
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update dataRepository! Reason: " + reason);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = { "/datarepo/create" }, consumes = "application/json", produces="application/json")
|
||||||
|
public @ResponseBody ResponseEntity<Object> setOrganisation(@RequestBody DataRepository dataRepository) {
|
||||||
|
DataRepository createdDataRepository = dataRepositoryDao.update(dataRepository);
|
||||||
|
try {
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdDataRepository));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create data repository!\"}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = { "/datarepo/delete" }, consumes = "application/json", produces="text/plain")
|
||||||
|
public @ResponseBody ResponseEntity<Object> delete(@RequestBody DataRepository dataRepository) {
|
||||||
|
|
||||||
|
DataRepository dr = new DataRepository();
|
||||||
|
dr.setId(dataRepository.getId());
|
||||||
|
try {
|
||||||
|
dataRepositoryDao.delete(dr);
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted data repository!\"}");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete data repository!\"}");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class DmpProfiles {
|
||||||
try {
|
try {
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdDMPProfile));
|
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdDMPProfile));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create DMP Profile!\"");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create DMP Profile!\"}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,9 +154,9 @@ public class DmpProfiles {
|
||||||
dmpp.setId(dmpprofile.getId());
|
dmpp.setId(dmpprofile.getId());
|
||||||
try {
|
try {
|
||||||
dMPProfileDao.delete(dmpp);
|
dMPProfileDao.delete(dmpp);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted DMP Profile!\"}");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete DMP Profile!\"");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete DMP Profile!\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class Organisations {
|
||||||
try {
|
try {
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdOrganisation));
|
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdOrganisation));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create organisation!\"");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create organisation!\"}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,9 +139,9 @@ public class Organisations {
|
||||||
org.setId(organisation.getId());
|
org.setId(organisation.getId());
|
||||||
try {
|
try {
|
||||||
organisationDao.delete(org);
|
organisationDao.delete(org);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted organisation!\"}");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete organisation!\"");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete organisation!\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class Projects {
|
||||||
try {
|
try {
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdProject));
|
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdProject));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create Project!\"");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create Project!\"}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,9 +151,9 @@ public class Projects {
|
||||||
p.setId(project.getId());
|
p.setId(project.getId());
|
||||||
try {
|
try {
|
||||||
projectDao.delete(p);
|
projectDao.delete(p);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted Project entity!\"}");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete Project!\"");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete Project!\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class Registries {
|
||||||
try {
|
try {
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdRegistry));
|
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdRegistry));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create registry!\"");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create registry!\"}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,9 +152,9 @@ public class Registries {
|
||||||
r.setId(registry.getId());
|
r.setId(registry.getId());
|
||||||
try {
|
try {
|
||||||
registryDao.delete(r);
|
registryDao.delete(r);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted registry!\"}");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete registry!\"");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete registry!\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,9 @@ package rest.entities;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import org.apache.commons.lang3.SerializationUtils;
|
import org.apache.commons.lang3.SerializationUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -66,6 +69,8 @@ public class Researchers {
|
||||||
@Autowired private ServiceDao serviceDao;
|
@Autowired private ServiceDao serviceDao;
|
||||||
|
|
||||||
|
|
||||||
|
private ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
// MANAGE RESEARCHER(S)
|
// MANAGE RESEARCHER(S)
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/researchers" })
|
@RequestMapping(method = RequestMethod.GET, value = { "/researchers" })
|
||||||
|
@ -91,31 +96,57 @@ public class Researchers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/setResearcher" }, consumes = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = { "/researcher/getAll" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Object> setResearcher(@RequestBody Researcher researcher) {
|
public @ResponseBody ResponseEntity<Object> getAllResearchers(){
|
||||||
String reason = "";
|
|
||||||
Researcher storedResearcher = null;
|
|
||||||
//try first to create
|
|
||||||
try {
|
try {
|
||||||
storedResearcher = researcherDao.create(researcher);
|
List<Researcher> allResearchers = researcherDao.getAll();
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("Created researcher with id: " + storedResearcher.getId());
|
|
||||||
|
//sorry for that, spring-jersey serialisation has issues when performed on tables, so -> custom
|
||||||
|
List<String> researcherStrL = allResearchers.parallelStream().map((researcherObj) -> {
|
||||||
|
try {
|
||||||
|
return objectMapper.writeValueAsString(researcherObj);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return new ResponseEntity<Object>("["+String.join(",", researcherStrL)+"]", HttpStatus.OK);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception ex) {
|
||||||
reason += e.getMessage();
|
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
//try updating
|
|
||||||
try {
|
|
||||||
storedResearcher = researcherDao.update(researcher);
|
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("Updated researcher with id: " + storedResearcher.getId());
|
|
||||||
}
|
|
||||||
catch(Exception ex) {
|
|
||||||
reason += (System.lineSeparator()+e.getMessage());
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Could not create or update researcher! Reason: " + reason);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = { "/researcher/create" }, consumes = "application/json", produces="application/json")
|
||||||
|
public @ResponseBody ResponseEntity<Object> setResearcher(@RequestBody Researcher researcher) {
|
||||||
|
Researcher createdResearcher = researcherDao.update(researcher);
|
||||||
|
try {
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdResearcher));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create researcher!\"}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = { "/researcher/delete" }, consumes = "application/json", produces="text/plain")
|
||||||
|
public @ResponseBody ResponseEntity<Object> delete(@RequestBody Researcher researcher) {
|
||||||
|
|
||||||
|
Researcher res = new Researcher();
|
||||||
|
res.setId(researcher.getId());
|
||||||
|
try {
|
||||||
|
researcherDao.delete(res);
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted researcher!\"}");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete researcher!\"}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class Services {
|
||||||
try {
|
try {
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdService));
|
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdService));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create service entity!\"");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not create service entity!\"}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,9 +140,9 @@ public class Services {
|
||||||
s.setId(service.getId());
|
s.setId(service.getId());
|
||||||
try {
|
try {
|
||||||
serviceDao.delete(s);
|
serviceDao.delete(s);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted Service entity!\"}");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete Service entity!\"");
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete Service entity!\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,8 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
||||||
@Override
|
@Override
|
||||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||||
|
|
||||||
System.out.println("AUTHENTICATION");
|
|
||||||
System.out.println(authentication);
|
|
||||||
|
|
||||||
if (authentication != null) {
|
if (authentication != null) {
|
||||||
|
|
||||||
System.out.println((String)authentication.getCredentials());
|
|
||||||
|
|
||||||
String token = (String)authentication.getCredentials();
|
String token = (String)authentication.getCredentials();
|
||||||
TokenValidator tokenValidator = null;
|
TokenValidator tokenValidator = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue