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.isNull(root.get("grant").get("enddate"))));
}
if (this.getCriteria().datasetProfile != null && !this.getCriteria().datasetProfile.isEmpty()) query
.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().datasetProfile)));
if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty()) query
.where(((builder, root) -> root.join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
if (this.getCriteria().datasetProfile != null && !this.getCriteria().datasetProfile.isEmpty())
query.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().datasetProfile)));
if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty())
query.where(((builder, root) -> root.join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
return query;
}

View File

@ -1,25 +1,19 @@
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.table.datasetprofile.DatasetProfileTableRequestItem;
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
import eu.eudat.logic.managers.DatasetProfileManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
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.security.Principal;
import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.UUID;
@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));
}
@RequestMapping(method = RequestMethod.GET, value = {"/datasetprofiles/getAll"}, produces = "application/json")
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/getAll"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<DatasetProfileListingModel>>> getAll() throws InstantiationException, IllegalAccessException {
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll();
ResponseEntity<ResponseItem<List<DatasetProfileListingModel>>> getAll(@RequestBody DatasetProfileTableRequestItem tableRequestItem) throws InstantiationException, IllegalAccessException {
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
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();
}
public List<DatasetProfileListingModel> getAll() throws IllegalAccessException, InstantiationException {
DatasetProfileCriteria criteria = new DatasetProfileCriteria();
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(criteria);
public List<DatasetProfileListingModel> getAll(DatasetProfileTableRequestItem tableRequestItem) throws IllegalAccessException, InstantiationException {
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(tableRequestItem.getCriteria());
List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
return datasetProfiles;
}

View File

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

View File

@ -5,6 +5,8 @@ import { takeUntil } from 'rxjs/operators';
import { BaseComponent } from '../../../../core/common/base/base.component';
import { DatasetProfileModel } from '../../../../core/model/dataset/dataset-profile';
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({
selector: 'app-available-profiles-component',
@ -24,7 +26,13 @@ export class AvailableProfilesComponent extends BaseComponent implements OnInit
ngOnInit(): void {
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))
.subscribe(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 { MatAccordion } from '@angular/material/expansion';
import { ActivatedRoute, Params } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { BaseComponent } from '../../../core/common/base/base.component';
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 { RequestItem } from '../../../core/query/request-item';
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 { DmpService } from '../../../core/services/dmp/dmp.service';
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 { DmpListingModel } from '../../../core/model/dmp/dmp-listing';
import { ExploreDmpCriteriaModel } from '../../../core/query/explore-dmp/explore-dmp-criteria';
import { DmpModel } from '../../../core/model/dmp/dmp';
import { BaseCriteriaComponent } from '../../misc/criteria/base-criteria.component';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
import { DatasetProfileCriteria } from "../../../core/query/dataset-profile/dataset-profile-criteria";
@Component({
selector: 'app-explore-dataset-filters-component',
@ -91,7 +88,7 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
profileAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
filterFn: this.filterProfile.bind(this),
initialItems: (excludedItems: any[]) =>
this.getProfiles().pipe(
this.filterProfile('').pipe(
map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1))),
displayFn: (item) => item['label'],
titleFn: (item) => item['label']
@ -114,18 +111,17 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
public languageService: TranslateService,
public datasetProfileService: DatasetService,
public externalSourcesService: ExternalSourcesService,
private authentication: AuthService,
) { super(); }
ngOnInit() {
setTimeout(x => {
setTimeout(() => {
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.ACTIVE'), value: GrantStateType.OnGoing },
]);
});
this.profiles = this.datasetProfileService.getDatasetProfiles();
// this.profiles = this.datasetProfileService.getDatasetProfiles();
this.dmpOrganisations = this.externalSourcesService.searchDMPOrganizations('');
}
@ -186,9 +182,9 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
this.facetCriteriaChange.emit(this.facetCriteria);
}
getProfiles() {
return this.datasetProfileService.getDatasetProfiles();
}
// getProfiles() {
// return this.datasetProfileService.getDatasetProfiles();
// }
removeProfile(profile) {
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);
}
public profileSearch(value: string) {
return this.datasetProfileService.getDatasetProfiles();
}
// public profileSearch(value: string) {
// return this.datasetProfileService.getDatasetProfiles();
// }
public controlModified() {
this.facetCriteriaChange.emit(this.facetCriteria);
@ -339,11 +335,12 @@ export class ExploreDatasetFiltersComponent extends BaseComponent implements OnI
filterProfile(query: string) {
const fields: Array<string> = new Array<string>();
fields.push('asc');
const profileRequestItem: DataTableRequest<ExploreDatasetCriteriaModel> = new DataTableRequest(0, null, { fields: fields });
profileRequestItem.criteria = new ExploreDatasetCriteriaModel();
const profileRequestItem: DataTableRequest<DatasetProfileCriteria> = new DataTableRequest(0, null, { fields: fields });
profileRequestItem.criteria = new DatasetProfileCriteria();
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) {

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 { FormBuilder, FormControl, FormGroup } from "@angular/forms";
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 { TranslateService } from "@ngx-translate/core";
import { ValidationErrorModel } from "../../../common/forms/validation/error-model/validation-error-model";
import { GrantStateType } from '../../../core/common/enum/grant-state-type';
import { DataTableRequest } from "../../../core/model/data-table/data-table-request";
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 { ExploreDatasetCriteriaModel } from "../../../core/query/explore-dataset/explore-dataset-criteria";
import { ExploreDmpCriteriaModel } from "../../../core/query/explore-dmp/explore-dmp-criteria";
import { GrantCriteria } from "../../../core/query/grant/grant-criteria";
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 { OrganisationCriteria } from "../../../core/query/organisation/organisation-criteria";
import { OrganisationService } from "../../../core/services/organisation/organisation.service";
import { DatasetProfileCriteria } from "../../../core/query/dataset-profile/dataset-profile-criteria";
@Component({
selector: 'app-explore-dmp-filters-component',
@ -71,7 +67,7 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
profileAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
filterFn: this.filterProfile.bind(this),
initialItems: (excludedItems: any[]) =>
this.getProfiles().pipe(
this.filterProfile('').pipe(
map(result => result.filter(resultItem => excludedItems.map(x => x.id).indexOf(resultItem.id) === -1))),
displayFn: (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 },
]);
});
this.profiles = this.datasetProfileService.getDatasetProfiles();
//this.profiles = this.datasetProfileService.getDatasetProfiles();
const fields: Array<string> = new Array<string>();
fields.push('asc');
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);
}
profileSearch(value: string) {
return this.datasetProfileService.getDatasetProfiles();
}
// profileSearch(value: string) {
// return this.datasetProfileService.getDatasetProfiles();
// }
dmpOrganisationSearch(value: string): Observable<OrganizationModel[]> {
const fields: Array<string> = new Array<string>();
@ -286,9 +282,9 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
this.facetCriteriaChange.emit(this.facetCriteria);
}
getProfiles() {
return this.datasetProfileService.getDatasetProfiles();
}
// getProfiles() {
// return this.datasetProfileService.getDatasetProfiles();
// }
getOrganisations() {
const fields: Array<string> = new Array<string>();
@ -311,11 +307,11 @@ export class ExploreDmpFiltersComponent extends BaseCriteriaComponent implements
filterProfile(query: string) {
const fields: Array<string> = new Array<string>();
fields.push('asc');
const profileRequestItem: DataTableRequest<ExploreDatasetCriteriaModel> = new DataTableRequest(0, null, { fields: fields });
profileRequestItem.criteria = new ExploreDatasetCriteriaModel();
const profileRequestItem: DataTableRequest<DatasetProfileCriteria> = new DataTableRequest(0, null, { fields: fields });
profileRequestItem.criteria = new DatasetProfileCriteria();
profileRequestItem.criteria.like = query;
return this.dmpService.getPublicPaged(profileRequestItem, "listing").pipe(map(x => x.data));
return this.datasetProfileService.getDatasetProfiles(profileRequestItem);
}
filterOrganisation(value: string) {