From b3cbd1addff017755f1a31db59ce43acb5e7d3c3 Mon Sep 17 00:00:00 2001 From: annampak Date: Tue, 19 Dec 2017 14:47:08 +0200 Subject: [PATCH 1/5] dataset editor --- dmp-frontend/src/app/app-routing.module.ts | 5 +++ dmp-frontend/src/app/app.module.ts | 4 +- .../dataset-listing.component.html | 9 ++-- .../datasets_new/dataset-listing.component.ts | 22 +++++----- .../editor/dataset-editor.component.html | 42 ++++++++++++------- .../editor/dataset-editor.component.ts | 18 ++++---- .../criteria/dataset/DatasetCriteria.ts | 3 +- .../dataset/DatasetCriteriaErrorModel.ts | 3 +- .../app/services/dataset/dataset.service.ts | 2 +- .../datasets/datasets-criteria.component.html | 14 ++++--- .../datasets/datasets-criteria.component.ts | 5 +++ dmp-frontend/src/assets/lang/en.json | 20 +++++++++ 12 files changed, 97 insertions(+), 50 deletions(-) diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index c4e80203e..698390eec 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -14,6 +14,8 @@ import { ProjectListingComponent } from './projects/project-listing.component'; import { DataManagementPlanListingComponent } from './dmps/dmp-listing.component'; import { ProjectEditorComponent } from './projects/editor/project-editor.component'; import { DataManagementPlanEditorComponent } from './dmps/editor/dmp-editor.component'; +import { DatasetEditorComponent } from './datasets_new/editor/dataset-editor.component'; +import { DatasetListingComponent } from './datasets_new/dataset-listing.component'; const appRoutes: Routes = [ @@ -26,6 +28,9 @@ const appRoutes: Routes = [ { path: 'dmps', component: DataManagementPlanListingComponent, canActivate: [AuthGuard]}, { path: 'dmp/:id', component: DataManagementPlanEditorComponent, canActivate: [AuthGuard]}, { path: 'dmps/new', component: DataManagementPlanEditorComponent, canActivate: [AuthGuard]}, + { path: 'datasets', component: DatasetListingComponent, canActivate: [AuthGuard]}, + { path: 'dataset/:id', component: DatasetEditorComponent, canActivate: [AuthGuard]}, + { path: 'datasets/new', component: DatasetEditorComponent, canActivate: [AuthGuard]}, { path: 'login', component: MainSignInComponent}, { path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' }, { path: 'welcome', component: HomepageComponent, canActivate: [AuthGuard]}, diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index 50d6f6571..6018c1f02 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -111,6 +111,7 @@ import { ProjectEditorComponent } from './projects/editor/project-editor.compone import { DataManagementPlanEditorComponent } from './dmps/editor/dmp-editor.component'; import { FigurecardComponent } from './shared/components/figurecard/figurecard.component'; +import { DatasetEditorComponent } from './datasets_new/editor/dataset-editor.component'; @@ -152,7 +153,8 @@ import { FigurecardComponent } from './shared/components/figurecard/figurecard.c BreadcrumbComponent, DmpDetailedComponent, ProjectDetailedComponent, ProjectEditorComponent, DataManagementPlanEditorComponent, - FigurecardComponent + FigurecardComponent, + DatasetEditorComponent ], imports: [ BrowserModule, diff --git a/dmp-frontend/src/app/datasets_new/dataset-listing.component.html b/dmp-frontend/src/app/datasets_new/dataset-listing.component.html index 495384bed..6490e3ec5 100644 --- a/dmp-frontend/src/app/datasets_new/dataset-listing.component.html +++ b/dmp-frontend/src/app/datasets_new/dataset-listing.component.html @@ -28,7 +28,8 @@ {{'DATASET-LISTING.COLUMNS.STATUS' | translate}} - {{row.status}} + {{row.status}} + @@ -53,13 +54,11 @@ - + - + \ No newline at end of file diff --git a/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts b/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts index c4e41dc1c..cb61b321a 100644 --- a/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts +++ b/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts @@ -20,7 +20,7 @@ import { DatasetListingModel } from "../models/datasets/DatasetListingModel"; styleUrls: ['./dataset-listing.component.css'], providers: [DatasetService] }) -export class DatasetListingComponent implements OnInit, AfterViewInit { +export class DatasetListingComponent implements OnInit { @ViewChild(MatPaginator) _paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; @@ -29,6 +29,11 @@ export class DatasetListingComponent implements OnInit, AfterViewInit { dataSource: DatasetDataSource | null; displayedColumns: String[] = ['label', 'reference', 'uri', 'status', 'description', 'created', 'actions']; + statuses = [ + {value: '0', viewValue: 'Active'}, + {value: '1', viewValue: 'Inactive'} + ]; + constructor( private datasetService: DatasetService, private router: Router, @@ -39,14 +44,9 @@ export class DatasetListingComponent implements OnInit, AfterViewInit { } ngOnInit() { - - } - - ngAfterViewInit() { - setTimeout(() => { - this.criteria.setRefreshCallback(() => this.refresh()); - this.criteria.setCriteria(this.getDefaultCriteria()); - }); + this.criteria.setCriteria(this.getDefaultCriteria()); + this.refresh(); + this.criteria.setRefreshCallback(() => this.refresh()); } refresh() { @@ -54,7 +54,7 @@ export class DatasetListingComponent implements OnInit, AfterViewInit { } rowClick(rowId: String) { - this.router.navigate(['/project/' + rowId]); + this.router.navigate(['/dataset/' + rowId]); } getDefaultCriteria(): DatasetCriteria { @@ -112,7 +112,7 @@ export class DatasetDataSource extends DataSource { setTimeout(() => { this.isLoadingResults = false; }); - return result.payload; + return result; }) .map(result => { if (!result) { return []; } diff --git a/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html b/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html index 177130ba3..5cdfd4d13 100644 --- a/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html +++ b/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html @@ -1,28 +1,28 @@
- {{'DMP-EDITOR.TITLE.NEW' | translate}} - {{'DMP-EDITOR.TITLE.EDIT' | translate}} {{project.label}} + {{'DATASET-EDITOR.TITLE.NEW' | translate}} + {{'DATASET-EDITOR.TITLE.EDIT' | translate}} {{dataset.label}} - + {{baseErrorModel.label}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + - {{errorModel.description}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} - +
{{chip.name.substring(0, 1).toUpperCase()}}
{{chip.name}} @@ -70,8 +70,8 @@
- +
{{chip.name.substring(0, 1).toUpperCase()}}
{{chip.name}} @@ -84,6 +84,20 @@
+ + +
{{chip.name.substring(0, 1).toUpperCase()}}
+ {{chip.name}} +
+ +
+ {{option.name}} +
+
+ +
+
diff --git a/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.ts b/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.ts index c4b90e9d8..e7101a5b8 100644 --- a/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.ts +++ b/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.ts @@ -19,14 +19,14 @@ import { ExternalSourcesItemModel } from "../../models/external-sources/External @Component({ selector: 'app-dataset-editor-component', templateUrl: 'dataset-editor.component.html', - styleUrls: ['./dataset-editor.component.scss'], + styleUrls: ['./dataset-editor.component.css'], providers: [DatasetService, ExternalSourcesService], encapsulation: ViewEncapsulation.None }) export class DatasetEditorComponent implements AfterViewInit { isNew = true; - dataManagementPlan: DatasetModel; + dataset: DatasetModel; formGroup: FormGroup = null; filteringOrganisationsAsync: boolean = false; @@ -53,13 +53,13 @@ export class DatasetEditorComponent implements AfterViewInit { this.isNew = false; this.datasetService.getSingle(itemId).map(data => data as DatasetModel) .subscribe(data => { - this.dataManagementPlan = new JsonSerializer().fromJSONObject(data, DatasetModel); - this.formGroup = this.dataManagementPlan.buildForm(); + this.dataset = new JsonSerializer().fromJSONObject(data, DatasetModel); + this.formGroup = this.dataset.buildForm(); }); } else { - this.dataManagementPlan = new DatasetModel(); + this.dataset = new DatasetModel(); setTimeout(() => { - this.formGroup = this.dataManagementPlan.buildForm(); + this.formGroup = this.dataset.buildForm(); }); } }); @@ -88,7 +88,7 @@ export class DatasetEditorComponent implements AfterViewInit { duration: 3000, extraClasses: ['snackbar-success'] }) - this.router.navigate(['/dataManagementPlans']); + this.router.navigate(['/datasets']); } onCallbackError(error: any) { @@ -98,12 +98,12 @@ export class DatasetEditorComponent implements AfterViewInit { public setErrorModel(errorModel: BaseErrorModel) { Object.keys(errorModel).forEach(item => { - (this.dataManagementPlan.errorModel)[item] = (errorModel)[item]; + (this.dataset.errorModel)[item] = (errorModel)[item]; }) } public cancel(): void { - this.router.navigate(['/dataManagementPlans']); + this.router.navigate(['/datasets']); } filterOrganisations(value: string): void { diff --git a/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteria.ts b/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteria.ts index 0e219a6c7..d5a1ef522 100644 --- a/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteria.ts +++ b/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteria.ts @@ -1,6 +1,5 @@ import { BaseCriteria } from "../BaseCriteria"; export class DatasetCriteria extends BaseCriteria { - public Name: String; - public Status: Number; + public status: Number; } diff --git a/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteriaErrorModel.ts b/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteriaErrorModel.ts index bfd401872..4c8c081a5 100644 --- a/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteriaErrorModel.ts +++ b/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteriaErrorModel.ts @@ -1,6 +1,5 @@ import { BaseCriteriaErrorModel } from "../BaseCriteriaErrorModel"; export class DatasetCriteriaErrorModel extends BaseCriteriaErrorModel{ - public Name: String; - public Status: Number; + public status: Number; } diff --git a/dmp-frontend/src/app/services/dataset/dataset.service.ts b/dmp-frontend/src/app/services/dataset/dataset.service.ts index 808563f43..2f482292b 100644 --- a/dmp-frontend/src/app/services/dataset/dataset.service.ts +++ b/dmp-frontend/src/app/services/dataset/dataset.service.ts @@ -30,7 +30,7 @@ export class DatasetService { } getSingle(id: string): Observable { - return this.http.get(this.actionUrl + id, { headers: this.headers }); + return this.http.get(this.actionUrl +'getSingle/' + id, { headers: this.headers }); } createDataset(datasetModel: DatasetModel): Observable { diff --git a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html index ed16bc2af..ba29fd80e 100644 --- a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html +++ b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html @@ -17,16 +17,20 @@
-->
- - {{baseErrorModel['Criteria.Name']}} + {{baseErrorModel['Criteria.like']}}
- - {{baseErrorModel['Criteria.Status']}} + + + {{status.viewValue}} + + + {{baseErrorModel['Criteria.status']}}
diff --git a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts index 3461dbd30..04bbcfe40 100644 --- a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts +++ b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts @@ -21,6 +21,11 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O // public formStatus: ProjectStatus; public criteria: DatasetCriteria= new DatasetCriteria(); + statuses = [ + {value: '0', viewValue: 'Active'}, + {value: '1', viewValue: 'Inactive'} + ]; + constructor( public language: TranslateService, public formBuilder: FormBuilder diff --git a/dmp-frontend/src/assets/lang/en.json b/dmp-frontend/src/assets/lang/en.json index 2876089f3..ff00c2670 100644 --- a/dmp-frontend/src/assets/lang/en.json +++ b/dmp-frontend/src/assets/lang/en.json @@ -93,5 +93,25 @@ "PERIOD-TO": "End", "STATUS": "Status" } + }, + "DATASET-EDITOR": { + "TITLE": { + "NEW": "New Data Management Plan", + "EDIT": "Edit" + }, + "FIELDS": { + "NAME": "Name", + "DESCRIPTION": "Description", + "PROFILE": "Profile", + "URI": "Uri", + "DATAREPOSITORIES": "Data Repositories", + "REGISTRIES": "Registries", + "SERVICES": "Services" + }, + "ACTIONS": { + "SAVE": "Save", + "CANCEL": "Cancel", + "DELETE": "Delete" + } } } \ No newline at end of file From 3a0100da055dc8a52e3eb94048279b2b3aad358b Mon Sep 17 00:00:00 2001 From: annampak Date: Tue, 19 Dec 2017 17:38:28 +0200 Subject: [PATCH 2/5] dataset editor - data table --- .../dataset-listing.component.html | 34 ++++++++++++++----- .../datasets_new/dataset-listing.component.ts | 2 +- .../editor/dataset-editor.component.html | 8 ++--- .../editor/dataset-editor.component.ts | 28 +++++++-------- .../models/datasets/DatasetListingModel.ts | 20 ++++++++--- dmp-frontend/src/assets/lang/en.json | 7 +++- 6 files changed, 66 insertions(+), 33 deletions(-) diff --git a/dmp-frontend/src/app/datasets_new/dataset-listing.component.html b/dmp-frontend/src/app/datasets_new/dataset-listing.component.html index 6490e3ec5..3c0c089bd 100644 --- a/dmp-frontend/src/app/datasets_new/dataset-listing.component.html +++ b/dmp-frontend/src/app/datasets_new/dataset-listing.component.html @@ -13,16 +13,34 @@ {{row.label}} - - - {{'DATASET-LISTING.COLUMNS.REFERNCE' | translate}} - {{row.reference}} + + + {{'DATASET-LISTING.COLUMNS.DMP' | translate}} + {{row.dmp}} - - - {{'DATASET-LISTING.COLUMNS.URI' | translate}} - {{row.uri}} + + + {{'DATASET-LISTING.COLUMNS.PROFILE' | translate}} + {{row.profile}} + + + + + {{'DATASET-LISTING.COLUMNS.DATAREPOSITORIES' | translate}} + {{row.dataRepositories}} + + + + + {{'DATASET-LISTING.COLUMNS.REGISTRIES' | translate}} + {{row.registries}} + + + + + {{'DATASET-LISTING.COLUMNS.SERVICES' | translate}} + {{row.services}} diff --git a/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts b/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts index fee90cb5d..0ee505e33 100644 --- a/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts +++ b/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts @@ -27,7 +27,7 @@ export class DatasetListingComponent implements OnInit { @ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent; dataSource: DatasetDataSource | null; - displayedColumns: String[] = ['label', 'reference', 'uri', 'status', 'description', 'created', 'actions']; + displayedColumns: String[] = ['label','dmp' ,'profile' , 'dataRepositories', 'registries','services', 'status', 'description', 'created', 'actions']; statuses = [ {value: '0', viewValue: 'Active'}, diff --git a/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html b/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html index 5cdfd4d13..681d5ae3c 100644 --- a/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html +++ b/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html @@ -57,7 +57,7 @@ + (inputChange)="filterdataRepositories($event)" requireMatch>
{{chip.name.substring(0, 1).toUpperCase()}}
{{chip.name}} @@ -67,11 +67,11 @@ {{option.name}}
- +
+ (inputChange)="filterRegistries($event)" requireMatch>
{{chip.name.substring(0, 1).toUpperCase()}}
{{chip.name}} @@ -81,7 +81,7 @@ {{option.name}}
- +
{ - this.filteredOrganisations = items; - this.filteringOrganisationsAsync = false; + this.filtereddataRepositories = items; + this.filtereddataRepositoriesAsync = false; // this.filteredOrganisations = items.filter((filteredObj: any) => { // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true; @@ -124,15 +124,15 @@ export class DatasetEditorComponent implements AfterViewInit { } } - filterResearchers(value: string): void { + filterRegistries(value: string): void { - this.filteredResearchers = undefined; + this.filteredRegistries = undefined; if (value) { - this.filteringResearchersAsync = true; + this.filteredRegistriesAsync = true; this.externalSourcesService.searchDMPResearchers(value).subscribe(items => { - this.filteredResearchers = items; - this.filteringResearchersAsync = false; + this.filteredRegistries = items; + this.filteredRegistriesAsync = false; // this.filteredOrganisations = items.filter((filteredObj: any) => { // return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true; diff --git a/dmp-frontend/src/app/models/datasets/DatasetListingModel.ts b/dmp-frontend/src/app/models/datasets/DatasetListingModel.ts index 633ab7fcc..376e7f918 100644 --- a/dmp-frontend/src/app/models/datasets/DatasetListingModel.ts +++ b/dmp-frontend/src/app/models/datasets/DatasetListingModel.ts @@ -2,18 +2,28 @@ import { Serializable } from "../Serializable"; export class DatasetListingModel implements Serializable { public id: String; - public label:String; - public reference: String; - public uri: String; + public label:String; + public dmp: String; + public profile: String; + public dataRepositories: String; + public registries: String; + public services: String; public description: String; public status: Number; public created: Date; + //public uri: String; + // public reference: String; fromJSONObject(item: any): DatasetListingModel { this.id = item.id; this.label = item.label; - this.reference = item.reference; - this.uri = item.uri; + this.dmp = item.dmp; + this.profile = item.profile; + this.dataRepositories = item.dataRepositories; + this.registries = item.registries; + this.services = item.services; + //this.reference = item.reference; + //this.uri = item.uri; this.status = item.status; this.description = item.description; this.created = item.created; diff --git a/dmp-frontend/src/assets/lang/en.json b/dmp-frontend/src/assets/lang/en.json index 7f8115f00..d1197085d 100644 --- a/dmp-frontend/src/assets/lang/en.json +++ b/dmp-frontend/src/assets/lang/en.json @@ -43,7 +43,12 @@ "STATUS": "Status", "DESCRIPTION": "Description", "CREATED": "Created", - "ACTIONS": "Actions" + "ACTIONS": "Actions", + "DMP": "Dmp", + "PROFILE": "Profile", + "DATAREPOSITORIES": "Data Repositories", + "REGISTRIES": "Registries", + "SERVICES": "Services" } }, "PROJECT-EDITOR": { From 703d0b84c3b42758d1668a4bef26d853439edb44 Mon Sep 17 00:00:00 2001 From: annabakouli Date: Tue, 19 Dec 2017 18:22:30 +0200 Subject: [PATCH 3/5] no message --- .../java/eu/eudat/controllers/Datasets.java | 10 +- .../main/java/eu/eudat/controllers/Login.java | 4 + .../main/java/eu/eudat/controllers/Users.java | 1 - .../context/DatabaseContext.java | 10 +- .../dao/entities/security/CredentialDao.java | 6 +- .../entities/security/CredentialDaoImpl.java | 13 +- .../java/eu/eudat/entities/Credential.java | 15 +- .../eu/eudat/managers/DatasetManager.java | 7 +- .../eudat/models/dataset/DataRepository.java | 8 +- .../eu/eudat/models/dataset/Registry.java | 8 +- .../java/eu/eudat/models/dataset/Service.java | 8 +- .../DataManagementPlanListingModel.java | 8 +- .../listingmodels/DatasetListingModel.java | 137 ++++++++++++++++++ .../java/eu/eudat/responses/RestResponse.java | 32 ---- .../CustomAuthenticationProvider.java | 3 +- .../validators/GoogleTokenValidator.java | 66 ++++----- .../security/validators/TokenValidator.java | 3 +- .../eudat/utilities/helpers/LabelBuilder.java | 8 +- 18 files changed, 253 insertions(+), 94 deletions(-) create mode 100644 dmp-backend/src/main/java/eu/eudat/models/listingmodels/DatasetListingModel.java delete mode 100644 dmp-backend/src/main/java/eu/eudat/responses/RestResponse.java diff --git a/dmp-backend/src/main/java/eu/eudat/controllers/Datasets.java b/dmp-backend/src/main/java/eu/eudat/controllers/Datasets.java index 49f565fb3..1131a4b49 100644 --- a/dmp-backend/src/main/java/eu/eudat/controllers/Datasets.java +++ b/dmp-backend/src/main/java/eu/eudat/controllers/Datasets.java @@ -12,6 +12,7 @@ import eu.eudat.managers.DatasetManager; import eu.eudat.models.dataset.DatasetTableRequest; import eu.eudat.models.helpers.DataTableData; import eu.eudat.models.helpers.responses.*; +import eu.eudat.models.listingmodels.DatasetListingModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -41,7 +42,6 @@ import eu.eudat.dao.entities.UserInfoDao; import eu.eudat.models.criteria.DataRepositoryCriteria; import eu.eudat.models.criteria.RegistryCriteria; import eu.eudat.models.criteria.ServiceCriteria; -import eu.eudat.responses.RestResponse; @RestController @@ -66,14 +66,14 @@ public class Datasets { @RequestMapping(method = RequestMethod.POST, value = { "/datasets/getPaged" }, consumes = "application/json", produces="application/json") - public @ResponseBody ResponseItem> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) { + public @ResponseBody ResponseItem> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) { try { - DataTableData dataTable = new DatasetManager().getPaged(datasetDao, datasetTableRequest); - return new ResponseItem>().status(HttpStatus.OK).payload(dataTable); + DataTableData dataTable = new DatasetManager().getPaged(datasetDao, datasetTableRequest); + return new ResponseItem>().status(HttpStatus.OK).payload(dataTable); } catch (Exception ex) { ex.printStackTrace(); - return new ResponseItem>().status(HttpStatus.OK).message(ex.getMessage()); + return new ResponseItem>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage()); } } diff --git a/dmp-backend/src/main/java/eu/eudat/controllers/Login.java b/dmp-backend/src/main/java/eu/eudat/controllers/Login.java index 704213d30..9db59b2d1 100644 --- a/dmp-backend/src/main/java/eu/eudat/controllers/Login.java +++ b/dmp-backend/src/main/java/eu/eudat/controllers/Login.java @@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; +import javax.transaction.Transactional; + /** * Created by ikalyvas on 12/15/2017. */ @@ -23,6 +25,8 @@ public class Login { @Autowired private AuthenticationService authenticationService; + + @Transactional @RequestMapping(method = RequestMethod.POST, value = { "/externallogin" }, consumes = "application/json", produces="application/json") public @ResponseBody ResponseItem googleLogin(@RequestBody LoginInfo credentials) { try { diff --git a/dmp-backend/src/main/java/eu/eudat/controllers/Users.java b/dmp-backend/src/main/java/eu/eudat/controllers/Users.java index 0cdc9e7e4..8f6b0cff8 100644 --- a/dmp-backend/src/main/java/eu/eudat/controllers/Users.java +++ b/dmp-backend/src/main/java/eu/eudat/controllers/Users.java @@ -51,7 +51,6 @@ import eu.eudat.entities.Researcher; import eu.eudat.entities.Service; import eu.eudat.entities.UserInfo; import eu.eudat.helpers.Transformers; -import eu.eudat.responses.RestResponse; @RestController diff --git a/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/context/DatabaseContext.java b/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/context/DatabaseContext.java index 0ba671cb0..4a6b26ec4 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/context/DatabaseContext.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/databaselayer/context/DatabaseContext.java @@ -28,9 +28,13 @@ public class DatabaseContext> { public T createOrUpdate(T item, Class type) { if (item.getKeys()[0] != null) { T oldItem = entityManager.find(type, item.getKeys()[0]); - oldItem.update(item); - entityManager.merge(oldItem); - return oldItem; + if(oldItem!=null) { + oldItem.update(item); + entityManager.merge(oldItem); + return oldItem; + }else { + entityManager.persist(item); + } } else entityManager.persist(item); return item; } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDao.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDao.java index 4c258d96e..9179a22c2 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDao.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDao.java @@ -2,6 +2,7 @@ package eu.eudat.dao.entities.security; import eu.eudat.dao.Dao; import eu.eudat.entities.Credential; +import eu.eudat.entities.Project; import eu.eudat.entities.UserToken; import java.util.UUID; @@ -9,5 +10,8 @@ import java.util.UUID; /** * Created by ikalyvas on 12/15/2017. */ -public interface CredentialDao extends Dao { +public interface CredentialDao { + + Credential createOrUpdate(Credential item); + } diff --git a/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDaoImpl.java b/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDaoImpl.java index 1326c3d49..183b3fe3c 100644 --- a/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDaoImpl.java +++ b/dmp-backend/src/main/java/eu/eudat/dao/entities/security/CredentialDaoImpl.java @@ -1,8 +1,11 @@ package eu.eudat.dao.entities.security; import eu.eudat.dao.JpaDao; +import eu.eudat.dao.databaselayer.service.DatabaseService; import eu.eudat.entities.Credential; +import eu.eudat.entities.Project; import eu.eudat.entities.UserToken; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.UUID; @@ -11,9 +14,13 @@ import java.util.UUID; * Created by ikalyvas on 12/15/2017. */ @Component("credentialDao") -public class CredentialDaoImpl extends JpaDao implements CredentialDao { +public class CredentialDaoImpl implements CredentialDao { + + @Autowired + DatabaseService databaseService; + @Override - public Credential loadDetails(Credential credential) { - return null; + public Credential createOrUpdate(Credential item) { + return this.databaseService.createOrUpdate(item,Credential.class); } } diff --git a/dmp-backend/src/main/java/eu/eudat/entities/Credential.java b/dmp-backend/src/main/java/eu/eudat/entities/Credential.java index 27c20528a..86b5466ac 100644 --- a/dmp-backend/src/main/java/eu/eudat/entities/Credential.java +++ b/dmp-backend/src/main/java/eu/eudat/entities/Credential.java @@ -11,7 +11,7 @@ import java.util.UUID; */ @Entity @Table(name="\"Credential\"") -public class Credential { +public class Credential implements DataEntity { @Id @Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @@ -113,4 +113,17 @@ public class Credential { public int hashCode() { return provider.intValue(); } + + @Override + public void update(Credential entity) { + this.status = entity.status; + this.publicValue = entity.getPublicValue(); + this.secret = entity.getSecret(); + this.lastUpdateTime = new Date(); + } + + @Override + public Object[] getKeys() { + return new UUID[]{this.id == null ? null : this.id}; + } } diff --git a/dmp-backend/src/main/java/eu/eudat/managers/DatasetManager.java b/dmp-backend/src/main/java/eu/eudat/managers/DatasetManager.java index 0855bad2b..ce93d5ac0 100644 --- a/dmp-backend/src/main/java/eu/eudat/managers/DatasetManager.java +++ b/dmp-backend/src/main/java/eu/eudat/managers/DatasetManager.java @@ -5,6 +5,7 @@ import eu.eudat.dao.entities.ProjectDao; import eu.eudat.models.dataset.Dataset; import eu.eudat.models.dataset.DatasetTableRequest; import eu.eudat.models.helpers.DataTableData; +import eu.eudat.models.listingmodels.DatasetListingModel; import eu.eudat.models.project.Project; import eu.eudat.models.project.ProjectTableRequest; import eu.eudat.queryable.QueryableList; @@ -18,11 +19,11 @@ import java.util.UUID; */ public class DatasetManager { - public DataTableData getPaged(DatasetDao datatasetRepository, DatasetTableRequest datasetTableRequest) throws IllegalAccessException, InstantiationException{ + public DataTableData getPaged(DatasetDao datatasetRepository, DatasetTableRequest datasetTableRequest) throws IllegalAccessException, InstantiationException{ QueryableList items = datatasetRepository.getWithCriteria(datasetTableRequest.getCriteria()); QueryableList pagedItems = PaginationManager.applyPaging( items ,datasetTableRequest); - List datasets = new DomainModelConverter().fromDataModel( pagedItems.toList(), eu.eudat.models.dataset.Dataset.class); - DataTableData dataTable = new DataTableData(); + List datasets = new DomainModelConverter().fromDataModel( pagedItems.toList(), DatasetListingModel.class); + DataTableData dataTable = new DataTableData(); dataTable.setData(datasets); dataTable.setTotalCount(items.count()); return dataTable; diff --git a/dmp-backend/src/main/java/eu/eudat/models/dataset/DataRepository.java b/dmp-backend/src/main/java/eu/eudat/models/dataset/DataRepository.java index ba4f56f0a..f23a661c7 100644 --- a/dmp-backend/src/main/java/eu/eudat/models/dataset/DataRepository.java +++ b/dmp-backend/src/main/java/eu/eudat/models/dataset/DataRepository.java @@ -1,10 +1,11 @@ package eu.eudat.models.dataset; import eu.eudat.models.DataModel; +import eu.eudat.utilities.helpers.LabelGenerator; import java.util.Date; -public class DataRepository implements DataModel{ +public class DataRepository implements DataModel,LabelGenerator{ private String pid; private String name; private String uri; @@ -49,4 +50,9 @@ public class DataRepository implements DataModel{ +public class Registry implements DataModel,LabelGenerator { private UUID id; private String label; private String abbreviation; @@ -34,6 +35,11 @@ public class Registry implements DataModel{ return abbreviation; } + @Override + public String generateLabel() { + return getLabel(); + } + public void setAbbreviation(String abbreviation) { this.abbreviation = abbreviation; } diff --git a/dmp-backend/src/main/java/eu/eudat/models/dataset/Service.java b/dmp-backend/src/main/java/eu/eudat/models/dataset/Service.java index ddeb6336e..fc76838a5 100644 --- a/dmp-backend/src/main/java/eu/eudat/models/dataset/Service.java +++ b/dmp-backend/src/main/java/eu/eudat/models/dataset/Service.java @@ -1,12 +1,13 @@ package eu.eudat.models.dataset; import eu.eudat.models.DataModel; +import eu.eudat.utilities.helpers.LabelGenerator; import org.hibernate.annotations.Type; import javax.persistence.Column; import java.util.UUID; -public class Service implements DataModel{ +public class Service implements DataModel,LabelGenerator{ private UUID id; private String label; @@ -79,4 +80,9 @@ public class Service implements DataModel{ eu.eudat.entities.Service entity = new eu.eudat.entities.Service(); return entity; } + + @Override + public String generateLabel() { + return this.label; + } } diff --git a/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DataManagementPlanListingModel.java b/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DataManagementPlanListingModel.java index 8d3bd8ab2..22b7c3759 100644 --- a/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DataManagementPlanListingModel.java +++ b/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DataManagementPlanListingModel.java @@ -86,8 +86,8 @@ public class DataManagementPlanListingModel implements DataModel { this.label = entity.getLabel(); this.project = entity.getProject().getLabel(); this.profile = entity.getProfile().getLabel(); - this.organisations =getLabel(new DomainModelConverter().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class)); - this.researchers =getLabel(new DomainModelConverter().fromDataModel(entity.getResearchers().stream().collect(Collectors.toList()),Researcher.class)); + this.organisations =LabelBuilder.getLabel(new DomainModelConverter().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class)); + this.researchers =LabelBuilder.getLabel(new DomainModelConverter().fromDataModel(entity.getResearchers().stream().collect(Collectors.toList()),Researcher.class)); this.version = ""+entity.getVersion(); } @@ -96,7 +96,5 @@ public class DataManagementPlanListingModel implements DataModel { return null; } - private String getLabel(List items){ - return LabelBuilder.generateLabel(items); - } + } diff --git a/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DatasetListingModel.java b/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DatasetListingModel.java new file mode 100644 index 000000000..237e5238e --- /dev/null +++ b/dmp-backend/src/main/java/eu/eudat/models/listingmodels/DatasetListingModel.java @@ -0,0 +1,137 @@ +package eu.eudat.models.listingmodels; + +import eu.eudat.entities.*; +import eu.eudat.entities.DataRepository; +import eu.eudat.entities.Dataset; +import eu.eudat.entities.Organisation; +import eu.eudat.entities.Registry; +import eu.eudat.entities.Researcher; +import eu.eudat.models.DataModel; +import eu.eudat.models.dataset.*; +import eu.eudat.models.dataset.Service; +import eu.eudat.models.dmp.*; +import eu.eudat.utilities.builders.DomainModelConverter; +import eu.eudat.utilities.helpers.LabelBuilder; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Type; + +import javax.persistence.*; +import java.util.Date; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * Created by ikalyvas on 12/19/2017. + */ +public class DatasetListingModel implements DataModel { + private String id; + private String label; + private String dmp; + private String profile; + private String dataRepositories; + private String registries; + private String services; + private String status; + private String created; + private String description; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getDmp() { + return dmp; + } + + public void setDmp(String dmp) { + this.dmp = dmp; + } + + public String getProfile() { + return profile; + } + + public void setProfile(String profile) { + this.profile = profile; + } + + public String getDataRepositories() { + return dataRepositories; + } + + public void setDataRepositories(String dataRepositories) { + this.dataRepositories = dataRepositories; + } + + public String getRegistries() { + return registries; + } + + public void setRegistries(String registries) { + this.registries = registries; + } + + public String getServices() { + return services; + } + + public void setServices(String services) { + this.services = services; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreated() { + return created; + } + + public void setCreated(String created) { + this.created = created; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public void fromDataModel(Dataset entity) throws InstantiationException, IllegalAccessException { + this.id = entity.getId().toString(); + this.label = entity.getLabel(); + this.created = entity.getCreated().toString(); + this.dmp = entity.getDmp()!=null? entity.getDmp().getLabel():""; + this.profile = entity.getProfile()!=null? entity.getProfile().getLabel():""; + this.description = entity.getDescription(); + this.status = ""+entity.getStatus(); + this.registries = LabelBuilder.getLabel(new DomainModelConverter().fromDataModel(entity.getRegistries().stream().collect(Collectors.toList()), eu.eudat.models.dataset.Registry.class)); + this.dataRepositories = LabelBuilder.getLabel(new DomainModelConverter().fromDataModel(entity.getDataRepositories().stream().collect(Collectors.toList()), eu.eudat.models.dataset.DataRepository.class)); + this.services = LabelBuilder.getLabel(new DomainModelConverter().fromDataModel(entity.getServices().stream().collect(Collectors.toList()), Service.class)); + } + + @Override + public Dataset toDataModel() { + return null; + } +} diff --git a/dmp-backend/src/main/java/eu/eudat/responses/RestResponse.java b/dmp-backend/src/main/java/eu/eudat/responses/RestResponse.java deleted file mode 100644 index da6a1971c..000000000 --- a/dmp-backend/src/main/java/eu/eudat/responses/RestResponse.java +++ /dev/null @@ -1,32 +0,0 @@ -package eu.eudat.responses; - -public class RestResponse { - - private String message; - private String objID; - - public RestResponse(String message, String objID) { - super(); - this.message = message; - this.objID = objID; - } - - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - public String getObjID() { - return objID; - } - public void setObjID(String objID) { - this.objID = objID; - } - - @Override - public String toString() { - return "{\"message\":\"" + message + "\", \"objID\":\"" + objID + "\"}"; - } - -} diff --git a/dmp-backend/src/main/java/eu/eudat/security/CustomAuthenticationProvider.java b/dmp-backend/src/main/java/eu/eudat/security/CustomAuthenticationProvider.java index 804449849..1a3b0b98c 100644 --- a/dmp-backend/src/main/java/eu/eudat/security/CustomAuthenticationProvider.java +++ b/dmp-backend/src/main/java/eu/eudat/security/CustomAuthenticationProvider.java @@ -1,6 +1,7 @@ package eu.eudat.security; import java.io.IOException; +import java.security.GeneralSecurityException; import java.util.ArrayList; import javax.naming.NameAlreadyBoundException; @@ -32,7 +33,7 @@ public class CustomAuthenticationProvider { @Autowired private GoogleTokenValidator googleTokenValidator; @Autowired private NativeTokenValidator nativeTokenValidator; - public Principal authenticate(LoginInfo credentials) throws AuthenticationException { + public Principal authenticate(LoginInfo credentials) throws AuthenticationException, GeneralSecurityException { String token = credentials.getTicket(); try { Principal principal = googleTokenValidator.validateToken(token); diff --git a/dmp-backend/src/main/java/eu/eudat/security/validators/GoogleTokenValidator.java b/dmp-backend/src/main/java/eu/eudat/security/validators/GoogleTokenValidator.java index 9074f4ee6..040a95388 100644 --- a/dmp-backend/src/main/java/eu/eudat/security/validators/GoogleTokenValidator.java +++ b/dmp-backend/src/main/java/eu/eudat/security/validators/GoogleTokenValidator.java @@ -5,6 +5,8 @@ import java.io.IOException; import java.security.GeneralSecurityException; import java.security.Principal; import java.util.*; +import java.util.stream.Collector; +import java.util.stream.Collectors; import com.google.api.client.googleapis.auth.oauth2.*; import eu.eudat.dao.entities.security.CredentialDao; @@ -38,53 +40,39 @@ public class GoogleTokenValidator implements TokenValidator { @Autowired private CredentialDao credentialDao; @Autowired private AuthenticationService authenticationService; @Autowired private UserTokenDao userTokenDao; - - private GoogleTokenResponse verifyUser(String authCode) throws IOException { - - GoogleTokenResponse tokenResponse = - new GoogleAuthorizationCodeTokenRequest( - new NetHttpTransport(), - JacksonFactory.getDefaultInstance(), - "https://www.googleapis.com/oauth2/v4/token", - "524432312250-sc9qsmtmbvlv05r44onl6l93ia3k9deo.apps.googleusercontent.com", - "IQjhbYdExPIsjy37mOfB103F", - authCode, - "postmessage") // Specify the same redirect URI that you use with your web - // app. If you don't have a web version of your app, you can - // specify an empty string. - .execute(); - return tokenResponse; + private GoogleIdTokenVerifier verifier; + public GoogleTokenValidator(){ + verifier = new GoogleIdTokenVerifier.Builder(transport, JacksonFactory.getDefaultInstance()) + .setAudience(Collections.singletonList("524432312250-sc9qsmtmbvlv05r44onl6l93ia3k9deo.apps.googleusercontent.com")) + // Or, if multiple clients access the backend: + //.setAudience(Arrays.asList(CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3)) + .build(); } - private String getAccessToken(GoogleTokenResponse response){ - return response.getAccessToken(); + private GoogleIdToken verifyUserAndGetUser(String idTokenString) throws IOException, GeneralSecurityException { + + GoogleIdToken idToken = verifier.verify(idTokenString); + + return idToken; } - private GoogleIdToken getUser(GoogleTokenResponse response) throws IOException { - return response.parseIdToken(); - } @Override - public eu.eudat.models.security.Principal validateToken(String authCode) throws NonValidTokenException, IOException { - - GoogleTokenResponse tokenResponse = this.verifyUser(authCode); - String token = getAccessToken(tokenResponse); - GoogleIdToken idToken = getUser(tokenResponse); + public eu.eudat.models.security.Principal validateToken(String token) throws NonValidTokenException, IOException, GeneralSecurityException { + GoogleIdToken idToken = this.verifyUserAndGetUser(token); Payload payload = idToken.getPayload(); UserInfo userInfo = userInfoDao.getByMail(payload.getEmail()); - Credential credential = new Credential(); + final Credential credential = new Credential(); credential.setCreationTime(new Date()); - credential.setId(UUID.randomUUID()); credential.setStatus(1); credential.setLastUpdateTime(new Date()); credential.setProvider(1); credential.setSecret(token); credential.setPublicValue(userInfo.getName()); - credential.setUserInfo(userInfo); - credentialDao.create(credential); - if(userInfo == null) { //means not existing in db, so create one + if(userInfo == null) { + credential.setId(UUID.randomUUID()); userInfo = new UserInfo(); userInfo.setName((String)payload.get("name")); userInfo.setVerified_email(payload.getEmailVerified()); @@ -94,14 +82,24 @@ public class GoogleTokenValidator implements TokenValidator { userInfo.setAuthorization_level(new Short("1")); userInfo.setUsertype(new Short("1")); userInfo = userInfoDao.create(userInfo); - credential = credentialDao.create(credential); + credential.setUserInfo(userInfo); + credentialDao.createOrUpdate(credential); } else { userInfo.setLastloggedin(new Date()); Set credentials = userInfo.getCredentials(); - if(credentials.contains(credential))credentials.remove(credential); - credentials.add(credential); + if(credentials.contains(credential)){ + Credential oldCredential = credentials.stream().filter(item->credential.getProvider().equals(item.getProvider())).findFirst().get(); + credential.setId(oldCredential.getId()); + } + else{ + credential.setUserInfo(userInfo); + credential.setId(UUID.randomUUID()); + credentialDao.createOrUpdate(credential); + userInfo.getCredentials().add(credential); + } userInfo = userInfoDao.update(userInfo); + } UserToken userToken = new UserToken(); diff --git a/dmp-backend/src/main/java/eu/eudat/security/validators/TokenValidator.java b/dmp-backend/src/main/java/eu/eudat/security/validators/TokenValidator.java index b5de4eb29..331c94810 100644 --- a/dmp-backend/src/main/java/eu/eudat/security/validators/TokenValidator.java +++ b/dmp-backend/src/main/java/eu/eudat/security/validators/TokenValidator.java @@ -5,9 +5,10 @@ import eu.eudat.exceptions.NonValidTokenException; import eu.eudat.models.security.Principal; import java.io.IOException; +import java.security.GeneralSecurityException; public interface TokenValidator { - public Principal validateToken(String token) throws NonValidTokenException, IOException; + public Principal validateToken(String token) throws NonValidTokenException, IOException, GeneralSecurityException; } diff --git a/dmp-backend/src/main/java/eu/eudat/utilities/helpers/LabelBuilder.java b/dmp-backend/src/main/java/eu/eudat/utilities/helpers/LabelBuilder.java index 6ca8cca5d..136d65b42 100644 --- a/dmp-backend/src/main/java/eu/eudat/utilities/helpers/LabelBuilder.java +++ b/dmp-backend/src/main/java/eu/eudat/utilities/helpers/LabelBuilder.java @@ -6,16 +6,22 @@ import java.util.List; * Created by ikalyvas on 12/19/2017. */ public class LabelBuilder { - public static String generateLabel(List items){ + private static String generateLabel(List items){ String label=""; for(T item : items){ if(items.indexOf(item)==3){ label+="..."; break; } + if(items.indexOf(item)>1){ + label+=", "; + } label+=item.generateLabel(); } return label; } + public static String getLabel(List items){ + return generateLabel(items); + } } From 44a53be5b17f4862c761d0e69dc38f56aff11759 Mon Sep 17 00:00:00 2001 From: annampak Date: Tue, 19 Dec 2017 18:26:29 +0200 Subject: [PATCH 4/5] dataset listing fields model --- .../dataRepositories/DataRepositoryModel.ts | 17 +++++++++++++++++ .../src/app/models/datasets/DatasetModel.ts | 13 ++++++++++--- .../src/app/models/registers/RegisterModel.ts | 17 +++++++++++++++++ .../src/app/models/services/ServiceModel.ts | 17 +++++++++++++++++ 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 dmp-frontend/src/app/models/dataRepositories/DataRepositoryModel.ts create mode 100644 dmp-frontend/src/app/models/registers/RegisterModel.ts create mode 100644 dmp-frontend/src/app/models/services/ServiceModel.ts diff --git a/dmp-frontend/src/app/models/dataRepositories/DataRepositoryModel.ts b/dmp-frontend/src/app/models/dataRepositories/DataRepositoryModel.ts new file mode 100644 index 000000000..13d429099 --- /dev/null +++ b/dmp-frontend/src/app/models/dataRepositories/DataRepositoryModel.ts @@ -0,0 +1,17 @@ +import { Serializable } from "../Serializable"; + +export class DataRepositoryModel implements Serializable { + public id: String; + public name: String; + public pid: String; + public uri: String; + + fromJSONObject(item: any): DataRepositoryModel { + this.id = item.id; + this.name = item.name; + this.pid = item.pid; + this.uri = item.uri; + + return this; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/datasets/DatasetModel.ts b/dmp-frontend/src/app/models/datasets/DatasetModel.ts index bd563addc..ead91446e 100644 --- a/dmp-frontend/src/app/models/datasets/DatasetModel.ts +++ b/dmp-frontend/src/app/models/datasets/DatasetModel.ts @@ -5,6 +5,10 @@ import { BackendErrorValidator } from "../../utilities/validators/BackendErrorVa import { BaseErrorModel } from "../error/BaseErrorModel"; import { AutoCompleteItem } from "../../shared/components/autocomplete/AutoCompleteItem"; import { ExternalSourcesItemModel } from "../external-sources/ExternalSourcesItemModel"; +import { ServiceModel } from "../services/ServiceModel"; +import { JsonSerializer } from "../../utilities/JsonSerializer"; +import { RegisterModel } from "../registers/RegisterModel"; +import { DataRepositoryModel } from "../dataRepositories/DataRepositoryModel"; export class DatasetModel implements Serializable { public id: String; @@ -13,9 +17,9 @@ export class DatasetModel implements Serializable { public uri: String; public status: String; public description: String; - public services: ExternalSourcesItemModel[] = []; - public registries: ExternalSourcesItemModel[] = []; - public dataRepositories: ExternalSourcesItemModel[] = []; + public services: ServiceModel[] = []; + public registries: RegisterModel[] = []; + public dataRepositories: DataRepositoryModel[] = []; public errorModel: BaseErrorModel = new BaseErrorModel(); @@ -26,6 +30,9 @@ export class DatasetModel implements Serializable { this.uri = item.uri; this.status = item.status; this.description = item.description; + this.services = new JsonSerializer().fromJSONArray(item.services, ServiceModel); + //this.registries = new JsonSerializer().fromJSONArray(item.registries, RegisterModel); + //this.dataRepositories = new JsonSerializer().fromJSONArray(item.dataRepositories, DataRepositoryModel); return this; } diff --git a/dmp-frontend/src/app/models/registers/RegisterModel.ts b/dmp-frontend/src/app/models/registers/RegisterModel.ts new file mode 100644 index 000000000..d96b53d6b --- /dev/null +++ b/dmp-frontend/src/app/models/registers/RegisterModel.ts @@ -0,0 +1,17 @@ +import { Serializable } from "../Serializable"; + +export class RegisterModel implements Serializable { + public id: String; + public name: String; + public pid: String; + public uri: String; + + fromJSONObject(item: any): RegisterModel { + this.id = item.id; + this.name = item.name; + this.pid = item.pid; + this.uri = item.uri; + + return this; + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/models/services/ServiceModel.ts b/dmp-frontend/src/app/models/services/ServiceModel.ts new file mode 100644 index 000000000..c5ac08fd6 --- /dev/null +++ b/dmp-frontend/src/app/models/services/ServiceModel.ts @@ -0,0 +1,17 @@ +import { Serializable } from "../Serializable"; + +export class ServiceModel implements Serializable { + public id: String; + public name: String; + public pid: String; + public uri: String; + + fromJSONObject(item: any): ServiceModel { + this.id = item.id; + this.name = item.name; + this.pid = item.pid; + this.uri = item.uri; + + return this; + } +} \ No newline at end of file From c981cc28d9b482afc4ee8dd9fced989f9b71cdc4 Mon Sep 17 00:00:00 2001 From: annampak Date: Tue, 19 Dec 2017 18:50:00 +0200 Subject: [PATCH 5/5] dataset editor --- .../editor/dataset-editor.component.html | 10 +++++----- .../src/app/models/datasets/DatasetModel.ts | 4 ++-- .../src/app/models/registers/RegisterModel.ts | 12 ++++++++---- .../src/app/models/services/ServiceModel.ts | 14 +++++++++----- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html b/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html index 681d5ae3c..015a8a8da 100644 --- a/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html +++ b/dmp-frontend/src/app/datasets_new/editor/dataset-editor.component.html @@ -73,7 +73,7 @@ -
{{chip.name.substring(0, 1).toUpperCase()}}
+
{{chip.label.substring(0, 1).toUpperCase()}}
{{chip.name}}
@@ -87,7 +87,7 @@ -
{{chip.name.substring(0, 1).toUpperCase()}}
+
{{chip.label.substring(0, 1).toUpperCase()}}
{{chip.name}}
@@ -99,9 +99,9 @@
- - - + + +
diff --git a/dmp-frontend/src/app/models/datasets/DatasetModel.ts b/dmp-frontend/src/app/models/datasets/DatasetModel.ts index ead91446e..37974a7f0 100644 --- a/dmp-frontend/src/app/models/datasets/DatasetModel.ts +++ b/dmp-frontend/src/app/models/datasets/DatasetModel.ts @@ -31,8 +31,8 @@ export class DatasetModel implements Serializable { this.status = item.status; this.description = item.description; this.services = new JsonSerializer().fromJSONArray(item.services, ServiceModel); - //this.registries = new JsonSerializer().fromJSONArray(item.registries, RegisterModel); - //this.dataRepositories = new JsonSerializer().fromJSONArray(item.dataRepositories, DataRepositoryModel); + this.registries = new JsonSerializer().fromJSONArray(item.registries, RegisterModel); + this.dataRepositories = new JsonSerializer().fromJSONArray(item.dataRepositories, DataRepositoryModel); return this; } diff --git a/dmp-frontend/src/app/models/registers/RegisterModel.ts b/dmp-frontend/src/app/models/registers/RegisterModel.ts index d96b53d6b..f52389330 100644 --- a/dmp-frontend/src/app/models/registers/RegisterModel.ts +++ b/dmp-frontend/src/app/models/registers/RegisterModel.ts @@ -1,15 +1,19 @@ import { Serializable } from "../Serializable"; export class RegisterModel implements Serializable { + public abbreviation: String; + public definition: String; public id: String; - public name: String; - public pid: String; + public label: String; + public reference: String; public uri: String; fromJSONObject(item: any): RegisterModel { + this.abbreviation = item.abbreviation; + this.definition = item.definition; this.id = item.id; - this.name = item.name; - this.pid = item.pid; + this.label = item.label; + this.reference = item.reference; this.uri = item.uri; return this; diff --git a/dmp-frontend/src/app/models/services/ServiceModel.ts b/dmp-frontend/src/app/models/services/ServiceModel.ts index c5ac08fd6..90f5a8194 100644 --- a/dmp-frontend/src/app/models/services/ServiceModel.ts +++ b/dmp-frontend/src/app/models/services/ServiceModel.ts @@ -2,16 +2,20 @@ import { Serializable } from "../Serializable"; export class ServiceModel implements Serializable { public id: String; - public name: String; - public pid: String; + public abbreviation: String; + public definition: String; public uri: String; + public label: String; + public reference: String; fromJSONObject(item: any): ServiceModel { this.id = item.id; - this.name = item.name; - this.pid = item.pid; + this.abbreviation = item.abbreviation; + this.definition = item.definition; this.uri = item.uri; + this.label = item.label; + this.reference = item.reference; return this; } -} \ No newline at end of file +}