From 7380c554431063a26195c596cf6917cf557552ee Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Fri, 15 Feb 2019 13:00:26 +0200 Subject: [PATCH 1/4] Fixes single and multiple autocomplete's performance. --- .../auto-complete/multiple/multiple-auto-complete.component.ts | 3 ++- .../auto-complete/single/single-auto-complete.component.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts b/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts index 63e163b78..b29306f1b 100644 --- a/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts +++ b/dmp-frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.ts @@ -7,6 +7,7 @@ import { Observable, of as observableOf, Subject } from 'rxjs'; import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators'; import { AutoCompleteGroup } from '../auto-complete-group'; import { MultipleAutoCompleteConfiguration } from './multiple-auto-complete-configuration'; +import { switchMap } from 'rxjs/internal/operators/switchMap'; @Component({ selector: 'app-multiple-auto-complete', @@ -189,7 +190,7 @@ export class MultipleAutoCompleteComponent implements OnInit, MatFormFieldContro debounceTime(this.requestDelay), distinctUntilChanged(), tap(() => { this.loading = true; }), - mergeMap(query => { + switchMap(query => { // If its a valid object, a selection just made and the object is set as the value of the form control. That means we should fire an extra request to the server. if (this._isValidObject(query)) { return observableOf([]); } diff --git a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts index 17b1d85bf..d3b77a365 100644 --- a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts +++ b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts @@ -7,6 +7,7 @@ import { Observable, of as observableOf, Subject } from 'rxjs'; import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators'; import { AutoCompleteGroup } from '../auto-complete-group'; import { SingleAutoCompleteConfiguration } from './single-auto-complete-configuration'; +import { switchMap } from 'rxjs/internal/operators/switchMap'; @Component({ @@ -167,7 +168,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl< debounceTime(this.requestDelay), distinctUntilChanged(), tap(() => { this.loading = true; }), - mergeMap(query => { + switchMap(query => { // If its a valid object, a selection just made and the object is set as the value of the form control. That means we should fire an extra request to the server. if (this._isValidObject(query)) { return observableOf([]); } From f6f28d6058a88c559722b67470c18deeb713373a Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Fri, 15 Feb 2019 13:03:59 +0200 Subject: [PATCH 2/4] Fixes bug on Researchers autocomplete with case sensitivity. --- .../java/eu/eudat/data/dao/entities/ResearcherDaoImpl.java | 4 ++-- .../main/java/eu/eudat/logic/managers/ResearcherManager.java | 4 ++-- .../services/external-sources/external-sources.service.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ResearcherDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ResearcherDaoImpl.java index 3b4904319..086adf820 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ResearcherDaoImpl.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/ResearcherDaoImpl.java @@ -24,9 +24,9 @@ public class ResearcherDaoImpl extends DatabaseAccess implements Res public QueryableList getWithCriteria(ResearcherCriteria criteria) { QueryableList query = asQueryable(); if (criteria.getLike() != null && !criteria.getLike().isEmpty()) - query.where((builder, root) ->builder.or(builder.like(root.get("reference"), "%" + criteria.getLike().toUpperCase() + "%"))); + query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"))); if (criteria.getName() != null && !criteria.getName().isEmpty()) - query.where((builder, root) ->builder.or(builder.like(root.get("label"), "%" + criteria.getName().toUpperCase() + "%"))); + query.where((builder, root) ->builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getName().toUpperCase() + "%"))); return query; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java index 95066af1e..1671dd91d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/ResearcherManager.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * Created by ikalyvas on 2/5/2018. @@ -40,7 +41,6 @@ public class ResearcherManager { .build(); researchers.add(researcher); } - researchers.stream().distinct(); - return researchers; + return researchers.stream().distinct().collect(Collectors.toList()); } } diff --git a/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts b/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts index 94b684044..2e2a5fe14 100644 --- a/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts +++ b/dmp-frontend/src/app/core/services/external-sources/external-sources.service.ts @@ -58,7 +58,7 @@ export class ExternalSourcesService { } public searchDMPResearchers(requestItem: RequestItem): Observable { - return this.http.post(environment.Server + '/researchers/getWithExternal', requestItem, { headers: this.headers }); + return this.http.post(environment.Server + 'researchers/getWithExternal', requestItem, { headers: this.headers }); } public searchDMPOrganizations(like: string): Observable { From 19d16072cd7b518d4406df5dc29dcc8bb5cce985 Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Fri, 15 Feb 2019 13:11:11 +0200 Subject: [PATCH 3/4] Fix Dataset Profile Delete --- .../web/src/main/java/eu/eudat/controllers/Admin.java | 1 + .../core/services/dataset-profile/dataset-profile.service.ts | 5 +++-- .../editor/dataset-profile-editor.component.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java index 2d0416abf..494b2bd3a 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java @@ -56,6 +56,7 @@ public class Admin extends BaseController { eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); datasetprofile.setDefinition(modelDefinition.getDefinition()); datasetprofile.setStatus(modelDefinition.getStatus()); + datasetprofile.setLabel(modelDefinition.getLabel()); this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE)); } diff --git a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts index 43dcecb4e..e4d04194d 100644 --- a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts +++ b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts @@ -42,8 +42,9 @@ export class DatasetProfileService { return this.http.post(this.actionUrl + 'datasetprofile/clone/' + id, {}); } - delete(id: string): Observable { - return this.http.delete(this.actionUrl + id, {}); + delete(id: string, data): Observable { + return this.http.post(this.actionUrl + 'addDmp/' + id, data); + //return this.http.delete(this.actionUrl + id, {}); } } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts index cdda82bf6..94995f39e 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts @@ -204,7 +204,8 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { - this.datasetProfileService.delete(this.datasetProfileId) + this.form.get('status').setValue(DatasetProfileEnum.DELETED); + this.datasetProfileService.delete(this.datasetProfileId,this.form.value) .pipe(takeUntil(this._destroyed)) .subscribe( complete => { From 900d2c8bb15e4627ba8ca31fe206278c155e1d51 Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Fri, 15 Feb 2019 13:12:20 +0200 Subject: [PATCH 4/4] Fixes Available Dataset profiles, not excluding the deleted ones. --- .../java/eu/eudat/logic/managers/DatasetProfileManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index 8e92dbee6..acab5f066 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -2,6 +2,7 @@ package eu.eudat.logic.managers; import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; +import eu.eudat.data.dao.criteria.DatasetProfileCriteria; import eu.eudat.data.dao.entities.DatasetProfileDao; import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest; @@ -49,7 +50,8 @@ public class DatasetProfileManager { } public List getAll(DatasetProfileDao datasetProfileRepository) throws IllegalAccessException, InstantiationException { - QueryableList items = datasetProfileRepository.getAll(); + DatasetProfileCriteria criteria = new DatasetProfileCriteria(); + QueryableList items = datasetProfileRepository.getWithCriteria(criteria); List datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); return datasetProfiles; }