Fixes bug of Published DMP and Published Dataet Descriptions on filter "Dataset Specification" not searching properly.

This commit is contained in:
gkolokythas 2019-09-24 11:25:16 +03:00
parent 26f28bca55
commit 812891fed1
7 changed files with 51 additions and 57 deletions

View File

@ -29,10 +29,10 @@ public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManageme
builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date()) builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date())
, builder.isNull(root.get("grant").get("enddate")))); , builder.isNull(root.get("grant").get("enddate"))));
} }
if (this.getCriteria().datasetProfile != null && !this.getCriteria().datasetProfile.isEmpty()) query if (this.getCriteria().datasetProfile != null && !this.getCriteria().datasetProfile.isEmpty())
.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().datasetProfile))); query.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().datasetProfile)));
if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty()) query if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty())
.where(((builder, root) -> root.join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations()))); query.where(((builder, root) -> root.join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
return query; return query;
} }

View File

@ -1,25 +1,19 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest; import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest;
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
import eu.eudat.logic.managers.DatasetProfileManager; import eu.eudat.logic.managers.DatasetProfileManager;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem; import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel; import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.UUID;
@RestController @RestController
@ -42,10 +36,10 @@ public class DatasetProfiles extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileAutocompleteItems)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileAutocompleteItems));
} }
@RequestMapping(method = RequestMethod.GET, value = {"/datasetprofiles/getAll"}, produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/getAll"}, produces = "application/json")
public @ResponseBody public @ResponseBody
ResponseEntity<ResponseItem<List<DatasetProfileListingModel>>> getAll() throws InstantiationException, IllegalAccessException { ResponseEntity<ResponseItem<List<DatasetProfileListingModel>>> getAll(@RequestBody DatasetProfileTableRequestItem tableRequestItem) throws InstantiationException, IllegalAccessException {
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(); List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
} }
} }

View File

@ -81,9 +81,8 @@ public class DatasetProfileManager {
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build(); return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build();
} }
public List<DatasetProfileListingModel> getAll() throws IllegalAccessException, InstantiationException { public List<DatasetProfileListingModel> getAll(DatasetProfileTableRequestItem tableRequestItem) throws IllegalAccessException, InstantiationException {
DatasetProfileCriteria criteria = new DatasetProfileCriteria(); QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(tableRequestItem.getCriteria());
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(criteria);
List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item)); List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
return datasetProfiles; return datasetProfiles;
} }

View File

@ -31,8 +31,8 @@ export class DatasetService {
return this.http.get(this.actionUrl + 'makepublic/' + id); return this.http.get(this.actionUrl + 'makepublic/' + id);
} }
getDatasetProfiles(): Observable<DatasetProfileModel[]> { getDatasetProfiles(dataTableRequest: DataTableRequest<DatasetProfileCriteria>): Observable<DatasetProfileModel[]> {
return this.http.get<DatasetProfileModel[]>(environment.Server + 'datasetprofiles/getAll'); return this.http.post<DatasetProfileModel[]>(environment.Server + 'datasetprofiles/getAll', dataTableRequest);
} }
getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>) { getDatasetProfilesUsedPaged(dataTableRequest: DataTableRequest<DatasetProfileCriteria>) {

View File

@ -5,6 +5,8 @@ import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../../../core/common/base/base.component'; import { BaseComponent } from '../../../../core/common/base/base.component';
import { DatasetProfileModel } from '../../../../core/model/dataset/dataset-profile'; import { DatasetProfileModel } from '../../../../core/model/dataset/dataset-profile';
import { DatasetService } from '../../../../core/services/dataset/dataset.service'; import { DatasetService } from '../../../../core/services/dataset/dataset.service';
import { DataTableRequest } from "../../../../core/model/data-table/data-table-request";
import { DatasetProfileCriteria } from "../../../../core/query/dataset-profile/dataset-profile-criteria";
@Component({ @Component({
selector: 'app-available-profiles-component', selector: 'app-available-profiles-component',
@ -24,7 +26,13 @@ export class AvailableProfilesComponent extends BaseComponent implements OnInit
ngOnInit(): void { ngOnInit(): void {
this.formGroup = this.data['profiles']; this.formGroup = this.data['profiles'];
this.datasetService.getDatasetProfiles() const fields: Array<string> = new Array<string>();
fields.push('asc');
const profileRequestItem: DataTableRequest<DatasetProfileCriteria> = new DataTableRequest(0, null, { fields: fields });
profileRequestItem.criteria = new DatasetProfileCriteria();
profileRequestItem.criteria.like = '';
this.datasetService.getDatasetProfiles(profileRequestItem)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(data => { .subscribe(data => {
this.profiles = data; this.profiles = data;

View File

@ -1,10 +1,10 @@
import {of as observableOf, Observable } from 'rxjs'; import { of as observableOf, Observable } from 'rxjs';
import {map, takeUntil } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
import { MatAccordion } from '@angular/material/expansion'; import { MatAccordion } from '@angular/material/expansion';
import { ActivatedRoute, Params } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { BaseComponent } from '../../../core/common/base/base.component'; import { BaseComponent } from '../../../core/common/base/base.component';
import { GrantStateType } from '../../../core/common/enum/grant-state-type'; import { GrantStateType } from '../../../core/common/enum/grant-state-type';
@ -19,7 +19,6 @@ import { ExternalSourcesService } from '../../../core/services/external-sources/
import { GrantService } from '../../../core/services/grant/grant.service'; import { GrantService } from '../../../core/services/grant/grant.service';
import { RequestItem } from '../../../core/query/request-item'; import { RequestItem } from '../../../core/query/request-item';
import { DataTableRequest } from '../../../core/model/data-table/data-table-request'; import { DataTableRequest } from '../../../core/model/data-table/data-table-request';
import { AuthService } from '../../../core/services/auth/auth.service';
import { MultipleAutoCompleteConfiguration } from '../../../library/auto-complete/multiple/multiple-auto-complete-configuration'; import { MultipleAutoCompleteConfiguration } from '../../../library/auto-complete/multiple/multiple-auto-complete-configuration';
import { DmpService } from '../../../core/services/dmp/dmp.service'; import { DmpService } from '../../../core/services/dmp/dmp.service';
import { OrganisationCriteria } from '../../../core/query/organisation/organisation-criteria'; import { OrganisationCriteria } from '../../../core/query/organisation/organisation-criteria';
@ -28,9 +27,7 @@ import { OrganizationModel } from '../../../core/model/organisation/organization
import { DataTableData } from '../../../core/model/data-table/data-table-data'; import { DataTableData } from '../../../core/model/data-table/data-table-data';
import { DmpListingModel } from '../../../core/model/dmp/dmp-listing'; import { DmpListingModel } from '../../../core/model/dmp/dmp-listing';
import { ExploreDmpCriteriaModel } from '../../../core/query/explore-dmp/explore-dmp-criteria'; import { ExploreDmpCriteriaModel } from '../../../core/query/explore-dmp/explore-dmp-criteria';
import { DmpModel } from '../../../core/model/dmp/dmp'; import { DatasetProfileCriteria } from "../../../core/query/dataset-profile/dataset-profile-criteria";
import { BaseCriteriaComponent } from '../../misc/criteria/base-criteria.component';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
@Component({ @Component({
selector: 'app-explore-dataset-filters-component', selector: 'app-explore-dataset-filters-component',
@ -91,7 +88,7 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
profileAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { profileAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
filterFn: this.filterProfile.bind(this), filterFn: this.filterProfile.bind(this),
initialItems: (excludedItems: any[]) => initialItems: (excludedItems: any[]) =>
this.getProfiles().pipe( this.filterProfile('').pipe(
map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1))), map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1))),
displayFn: (item) => item['label'], displayFn: (item) => item['label'],
titleFn: (item) => item['label'] titleFn: (item) => item['label']
@ -114,18 +111,17 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
public languageService: TranslateService, public languageService: TranslateService,
public datasetProfileService: DatasetService, public datasetProfileService: DatasetService,
public externalSourcesService: ExternalSourcesService, public externalSourcesService: ExternalSourcesService,
private authentication: AuthService,
) { super(); } ) { super(); }
ngOnInit() { ngOnInit() {
setTimeout(x => { setTimeout(() => {
this.grantStateOptions = observableOf( this.grantStateOptions = observableOf(
[ [
{ label: this.languageService.instant('FACET-SEARCH.GRANT-STATUS.OPTIONS.INACTIVE'), value: GrantStateType.Finished }, { label: this.languageService.instant('FACET-SEARCH.GRANT-STATUS.OPTIONS.INACTIVE'), value: GrantStateType.Finished },
{ label: this.languageService.instant('FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE'), value: GrantStateType.OnGoing }, { label: this.languageService.instant('FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE'), value: GrantStateType.OnGoing },
]); ]);
}); });
this.profiles = this.datasetProfileService.getDatasetProfiles(); // this.profiles = this.datasetProfileService.getDatasetProfiles();
this.dmpOrganisations = this.externalSourcesService.searchDMPOrganizations(''); this.dmpOrganisations = this.externalSourcesService.searchDMPOrganizations('');
} }
@ -186,9 +182,9 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
this.facetCriteriaChange.emit(this.facetCriteria); this.facetCriteriaChange.emit(this.facetCriteria);
} }
getProfiles() { // getProfiles() {
return this.datasetProfileService.getDatasetProfiles(); // return this.datasetProfileService.getDatasetProfiles();
} // }
removeProfile(profile) { removeProfile(profile) {
this.facetCriteria.datasetProfile.splice(this.facetCriteria.datasetProfile.indexOf(profile), 1); this.facetCriteria.datasetProfile.splice(this.facetCriteria.datasetProfile.indexOf(profile), 1);
@ -240,9 +236,9 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
this.facetCriteriaChange.emit(this.facetCriteria); this.facetCriteriaChange.emit(this.facetCriteria);
} }
public profileSearch(value: string) { // public profileSearch(value: string) {
return this.datasetProfileService.getDatasetProfiles(); // return this.datasetProfileService.getDatasetProfiles();
} // }
public controlModified() { public controlModified() {
this.facetCriteriaChange.emit(this.facetCriteria); this.facetCriteriaChange.emit(this.facetCriteria);
@ -339,11 +335,12 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
filterProfile(query: string) { filterProfile(query: string) {
const fields: Array<string> = new Array<string>(); const fields: Array<string> = new Array<string>();
fields.push('asc'); fields.push('asc');
const profileRequestItem: DataTableRequest<ExploreDatasetCriteriaModel> = new DataTableRequest(0, null, { fields: fields }); const profileRequestItem: DataTableRequest<DatasetProfileCriteria> = new DataTableRequest(0, null, { fields: fields });
profileRequestItem.criteria = new ExploreDatasetCriteriaModel(); profileRequestItem.criteria = new DatasetProfileCriteria();
profileRequestItem.criteria.like = query; profileRequestItem.criteria.like = query;
return this.dmpService.getPublicPaged(profileRequestItem, "listing").pipe(map(x => x.data)); return this.datasetProfileService.getDatasetProfiles(profileRequestItem);
// this.dmpService.getPublicPaged(profileRequestItem, "listing").pipe(map(x => x.data));
} }
filterOrganisation(value: string) { filterOrganisation(value: string) {

View File

@ -1,21 +1,16 @@
import {of as observableOf, Observable } from 'rxjs'; import { of as observableOf, Observable } from 'rxjs';
import {map, takeUntil } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild } from "@angular/core"; import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output, ViewChild } from "@angular/core";
import { FormBuilder, FormControl, FormGroup } from "@angular/forms";
import { MatAccordion } from "@angular/material/expansion"; import { MatAccordion } from "@angular/material/expansion";
import { MatGridTileHeaderCssMatStyler } from "@angular/material/grid-list";
import { fadeInItems } from "@angular/material/menu";
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { TranslateService } from "@ngx-translate/core"; import { TranslateService } from "@ngx-translate/core";
import { ValidationErrorModel } from "../../../common/forms/validation/error-model/validation-error-model"; import { ValidationErrorModel } from "../../../common/forms/validation/error-model/validation-error-model";
import { GrantStateType } from '../../../core/common/enum/grant-state-type'; import { GrantStateType } from '../../../core/common/enum/grant-state-type';
import { DataTableRequest } from "../../../core/model/data-table/data-table-request"; import { DataTableRequest } from "../../../core/model/data-table/data-table-request";
import { DatasetProfileModel } from "../../../core/model/dataset/dataset-profile"; import { DatasetProfileModel } from "../../../core/model/dataset/dataset-profile";
import { ExternalSourceItemModel } from "../../../core/model/external-sources/external-source-item";
import { GrantListingModel } from "../../../core/model/grant/grant-listing"; import { GrantListingModel } from "../../../core/model/grant/grant-listing";
import { ExploreDatasetCriteriaModel } from "../../../core/query/explore-dataset/explore-dataset-criteria";
import { ExploreDmpCriteriaModel } from "../../../core/query/explore-dmp/explore-dmp-criteria"; import { ExploreDmpCriteriaModel } from "../../../core/query/explore-dmp/explore-dmp-criteria";
import { GrantCriteria } from "../../../core/query/grant/grant-criteria"; import { GrantCriteria } from "../../../core/query/grant/grant-criteria";
import { DatasetService } from "../../../core/services/dataset/dataset.service"; import { DatasetService } from "../../../core/services/dataset/dataset.service";
@ -27,6 +22,7 @@ import { BaseCriteriaComponent } from "../../misc/criteria/base-criteria.compone
import { OrganizationModel } from "../../../core/model/organisation/organization"; import { OrganizationModel } from "../../../core/model/organisation/organization";
import { OrganisationCriteria } from "../../../core/query/organisation/organisation-criteria"; import { OrganisationCriteria } from "../../../core/query/organisation/organisation-criteria";
import { OrganisationService } from "../../../core/services/organisation/organisation.service"; import { OrganisationService } from "../../../core/services/organisation/organisation.service";
import { DatasetProfileCriteria } from "../../../core/query/dataset-profile/dataset-profile-criteria";
@Component({ @Component({
selector: 'app-explore-dmp-filters-component', selector: 'app-explore-dmp-filters-component',
@ -71,7 +67,7 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
profileAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = { profileAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
filterFn: this.filterProfile.bind(this), filterFn: this.filterProfile.bind(this),
initialItems: (excludedItems: any[]) => initialItems: (excludedItems: any[]) =>
this.getProfiles().pipe( this.filterProfile('').pipe(
map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1))), map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1))),
displayFn: (item) => item['label'], displayFn: (item) => item['label'],
titleFn: (item) => item['label'] titleFn: (item) => item['label']
@ -121,7 +117,7 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
{ label: this.languageService.instant('FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE'), value: GrantStateType.OnGoing }, { label: this.languageService.instant('FACET-SEARCH.GRANT-STATUS.OPTIONS.ACTIVE'), value: GrantStateType.OnGoing },
]); ]);
}); });
this.profiles = this.datasetProfileService.getDatasetProfiles(); //this.profiles = this.datasetProfileService.getDatasetProfiles();
const fields: Array<string> = new Array<string>(); const fields: Array<string> = new Array<string>();
fields.push('asc'); fields.push('asc');
this.dmpOrganisations = this.organisationService.searchPublicOrganisations(new DataTableRequest<OrganisationCriteria>(0, null, { fields: fields })).pipe(map(x => x.data)); this.dmpOrganisations = this.organisationService.searchPublicOrganisations(new DataTableRequest<OrganisationCriteria>(0, null, { fields: fields })).pipe(map(x => x.data));
@ -268,9 +264,9 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
this.facetCriteriaChange.emit(this.facetCriteria); this.facetCriteriaChange.emit(this.facetCriteria);
} }
profileSearch(value: string) { // profileSearch(value: string) {
return this.datasetProfileService.getDatasetProfiles(); // return this.datasetProfileService.getDatasetProfiles();
} // }
dmpOrganisationSearch(value: string): Observable<OrganizationModel[]> { dmpOrganisationSearch(value: string): Observable<OrganizationModel[]> {
const fields: Array<string> = new Array<string>(); const fields: Array<string> = new Array<string>();
@ -286,9 +282,9 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
this.facetCriteriaChange.emit(this.facetCriteria); this.facetCriteriaChange.emit(this.facetCriteria);
} }
getProfiles() { // getProfiles() {
return this.datasetProfileService.getDatasetProfiles(); // return this.datasetProfileService.getDatasetProfiles();
} // }
getOrganisations() { getOrganisations() {
const fields: Array<string> = new Array<string>(); const fields: Array<string> = new Array<string>();
@ -311,11 +307,11 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
filterProfile(query: string) { filterProfile(query: string) {
const fields: Array<string> = new Array<string>(); const fields: Array<string> = new Array<string>();
fields.push('asc'); fields.push('asc');
const profileRequestItem: DataTableRequest<ExploreDatasetCriteriaModel> = new DataTableRequest(0, null, { fields: fields }); const profileRequestItem: DataTableRequest<DatasetProfileCriteria> = new DataTableRequest(0, null, { fields: fields });
profileRequestItem.criteria = new ExploreDatasetCriteriaModel(); profileRequestItem.criteria = new DatasetProfileCriteria();
profileRequestItem.criteria.like = query; profileRequestItem.criteria.like = query;
return this.dmpService.getPublicPaged(profileRequestItem, "listing").pipe(map(x => x.data)); return this.datasetProfileService.getDatasetProfiles(profileRequestItem);
} }
filterOrganisation(value: string) { filterOrganisation(value: string) {