fix external references enums

This commit is contained in:
amentis 2023-10-20 17:44:41 +03:00
parent a94cce47e8
commit 0bd3ff6898
10 changed files with 89 additions and 39 deletions

View File

@ -1,8 +1,10 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
public enum ExternalReferencesType { public enum ExternalReferencesType implements DatabaseEnum<Short> {
Taxonomies((short) 0), Taxonomies((short) 0),
Licenses((short) 1), Licenses((short) 1),
Publications((short) 2), Publications((short) 2),
@ -12,13 +14,13 @@ public enum ExternalReferencesType {
Registries((short) 6), Registries((short) 6),
Services((short) 7), Services((short) 7),
Project((short) 8), Project((short) 8),
Founder((short) 8), Funder((short) 9),
Datasets((short) 9), Datasets((short) 10),
Organizations((short) 10), Organizations((short) 11),
Grants((short) 11), Grants((short) 12),
Prefillings((short) 12),
Validators((short) 13), Validators((short) 13),
Researcher((short) 14); Researcher((short) 14),
Prefillings((short) 15);
private final Short value; private final Short value;
ExternalReferencesType(Short value) { ExternalReferencesType(Short value) {
@ -29,9 +31,9 @@ public enum ExternalReferencesType {
return value; return value;
} }
private static final Map<Short, IsActive> map = EnumUtils.getEnumValueMap(IsActive.class); private static final Map<Short, ExternalReferencesType> map = EnumUtils.getEnumValueMap(ExternalReferencesType.class);
public static IsActive of(Short i) { public static ExternalReferencesType of(Short i) {
return map.get(i); return map.get(i);
} }
} }

View File

@ -70,14 +70,15 @@ public class ExternalReferencesController extends BaseController {
@GetMapping(path = {"data-repo/{externalType}"}, produces = "application/json") @GetMapping(path = {"{externalType}"}, produces = "application/json")
public @ResponseBody ResponseEntity<ResponseItem<List<ExternalReference>>> listExternalReferecnes(@RequestParam(value = "externalType") ExternalReferencesType externalType, public @ResponseBody ResponseEntity<ResponseItem<List<ExternalReference>>> listExternalReferecnes(@PathVariable(value = "externalType") int externalType,
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "query", required = false) String query,
@RequestParam(value = "type", required = false) String type @RequestParam(value = "type", required = false) String type
) throws HugeResultSet, NoURLFound, InvalidApplicationException { ) throws HugeResultSet, NoURLFound, InvalidApplicationException {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole); this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
ExternalReferencesType externalReferencesType = ExternalReferencesType.of((short) externalType);
List<ExternalReference> externalReferences = this.externalReferencesService.getExternalReference(externalType, query, type); List<ExternalReference> externalReferences = this.externalReferencesService.getExternalReference(externalReferencesType, query, type);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalReference>>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalReference>>().status(ApiMessageCode.NO_MESSAGE).payload(externalReferences));
} }

View File

@ -5,7 +5,7 @@ import eu.eudat.controllers.BaseController;
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet; import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
import eu.eudat.logic.proxy.config.exceptions.NoURLFound; import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.ValidationService; import eu.eudat.logic.services.ExternalValidationService;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
@ -17,15 +17,15 @@ import org.springframework.web.bind.annotation.*;
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping(path = {"api/validation"}) @RequestMapping(path = {"api/validation"})
public class ValidationController extends BaseController { public class ExternalValidationController extends BaseController {
private ValidationService validationService; private ExternalValidationService externalValidationService;
private final AuthorizationService authorizationService; private final AuthorizationService authorizationService;
@Autowired @Autowired
public ValidationController(ApiContext apiContext, ValidationService validationService, AuthorizationService authorizationService) { public ExternalValidationController(ApiContext apiContext, ExternalValidationService externalValidationService, AuthorizationService authorizationService) {
super(apiContext); super(apiContext);
this.validationService = validationService; this.externalValidationService = externalValidationService;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
} }
@ -36,7 +36,7 @@ public class ValidationController extends BaseController {
) throws HugeResultSet, NoURLFound { ) throws HugeResultSet, NoURLFound {
this.authorizationService.authorizeForce(Permission.AuthenticatedRole); this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
Boolean isValid = this.validationService.validateIdentifier(query, type); Boolean isValid = this.externalValidationService.validateIdentifier(query, type);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().payload(isValid).status(ApiMessageCode.NO_MESSAGE)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().payload(isValid).status(ApiMessageCode.NO_MESSAGE));
} }
} }

View File

@ -73,7 +73,7 @@ public class RemoteFetcher {
case Grants: return configLoader.getExternalUrls().getGrants(); case Grants: return configLoader.getExternalUrls().getGrants();
case Organizations: return configLoader.getExternalUrls().getOrganisations(); case Organizations: return configLoader.getExternalUrls().getOrganisations();
case Datasets: return configLoader.getExternalUrls().getDatasets(); case Datasets: return configLoader.getExternalUrls().getDatasets();
case Founder: return configLoader.getExternalUrls().getFunders(); case Funder: return configLoader.getExternalUrls().getFunders();
case Project: return configLoader.getExternalUrls().getProjects(); case Project: return configLoader.getExternalUrls().getProjects();
case Researcher: return configLoader.getExternalUrls().getResearchers(); case Researcher: return configLoader.getExternalUrls().getResearchers();
case Validators: return configLoader.getExternalUrls().getValidations(); case Validators: return configLoader.getExternalUrls().getValidations();

View File

@ -9,13 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
public class ValidationService { public class ExternalValidationService {
private RemoteFetcher remoteFetcher; private RemoteFetcher remoteFetcher;
private final UserScope userScope; private final UserScope userScope;
@Autowired @Autowired
public ValidationService(RemoteFetcher remoteFetcher, UserScope userScope) { public ExternalValidationService(RemoteFetcher remoteFetcher, UserScope userScope) {
super(); super();
this.remoteFetcher = remoteFetcher; this.remoteFetcher = remoteFetcher;
this.userScope = userScope; this.userScope = userScope;

View File

@ -25,7 +25,7 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@org.springframework.stereotype.Service @org.springframework.stereotype.Service
public class ExternalReferencesService {//implements ExternalReferencesService{ public class ExternalReferencesService {
private final ApiContext apiContext; private final ApiContext apiContext;
private final UserScope userScope; private final UserScope userScope;

View File

@ -0,0 +1,18 @@
export enum ExternalReferencesType {
Taxonomies = 0,
Licenses = 1,
Publications = 2,
Journals = 3,
PubRepositories = 4,
DataRepositories = 5,
Registries = 6,
Services = 7,
Project = 8,
Funder = 9,
Datasets = 10,
Organizations = 11,
Grants = 12,
Validators = 13,
Researcher = 14,
Prefillings = 15
}

View File

@ -0,0 +1,19 @@
export interface ExternalReference {
id: string;
name: string;
abbreviation: string;
pid: string;
originalId: string;
key: string;
pidTypeField: string;
uri: string;
description: string;
source: string;
count: string;
path: string;
host: string;
types: string;
firstName: string;
lastName: string;
tag: string;
}

View File

@ -14,7 +14,8 @@ import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service'; import { ConfigurationService } from '../configuration/configuration.service';
import { LicenseCriteria } from '@app/core/query/license/license-criteria'; import { LicenseCriteria } from '@app/core/query/license/license-criteria';
import {PublicationCriteria} from "@app/core/query/publication/publication-criteria"; import {PublicationCriteria} from "@app/core/query/publication/publication-criteria";
import { ExternalReference } from '@app/core/model/external-reference/external-reference';
import { ExternalReferencesType } from '@app/core/common/enum/external-references-type';
@Injectable() @Injectable()
export class ExternalSourcesService { export class ExternalSourcesService {
@ -58,6 +59,13 @@ export class ExternalSourcesService {
return this.http.get<ExternalSourceItemModel[]>(this.actionUrl + 'licenses' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers }); return this.http.get<ExternalSourceItemModel[]>(this.actionUrl + 'licenses' + '?query=' + requestItem.criteria.like + '&type=' + requestItem.criteria.type, { headers: this.headers });
} }
public listExternal(externalType: ExternalReferencesType, query: string, type: string): Observable<ExternalReference[]> {
const url = this.configurationService.server + `external-references/${externalType}`;
const options = { params: { query: query, type: type } };
return this.http.get<ExternalReference[]>(url, options);
}
public searchDatasetTags(requestItem: RequestItem<TagCriteria>): Observable<ExternalSourceItemModel[]> { public searchDatasetTags(requestItem: RequestItem<TagCriteria>): Observable<ExternalSourceItemModel[]> {
// return Observable.of([ // return Observable.of([
// { id: '1', name: 'Tag 1', description: '' }, // { id: '1', name: 'Tag 1', description: '' },

View File

@ -48,6 +48,8 @@ import {MatDialog} from "@angular/material/dialog";
import {HttpError} from "@common/modules/errors/error-handling/http-error-handling.service"; import {HttpError} from "@common/modules/errors/error-handling/http-error-handling.service";
import {HttpErrorResponse} from "@angular/common/http"; import {HttpErrorResponse} from "@angular/common/http";
import * as FileSaver from "file-saver"; import * as FileSaver from "file-saver";
import { ExternalReference } from '@app/core/model/external-reference/external-reference';
import { ExternalReferencesType } from '@app/core/common/enum/external-references-type';
@Component({ @Component({
selector: 'app-form-field', selector: 'app-form-field',
@ -470,63 +472,63 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem); return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem);
} }
searchDatasetExternalDataRepositories(query: string): Observable<ExternalSourceItemModel[]> { searchDatasetExternalDataRepositories(query: string): Observable<ExternalReference[]> {
const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem(); const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
requestItem.criteria = new DataRepositoryCriteria(); requestItem.criteria = new DataRepositoryCriteria();
requestItem.criteria.like = query; requestItem.criteria.like = query;
requestItem.criteria.type = ''; requestItem.criteria.type = '';
return this.externalSourcesService.searchDatasetRepository(requestItem); return this.externalSourcesService.listExternal(ExternalReferencesType.DataRepositories, requestItem.criteria.like, requestItem.criteria.type);
} }
searchDatasetExternalPubRepositories(query: string): Observable<ExternalSourceItemModel[]> { searchDatasetExternalPubRepositories(query: string): Observable<ExternalReference[]> {
const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem(); const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
requestItem.criteria = new DataRepositoryCriteria(); requestItem.criteria = new DataRepositoryCriteria();
requestItem.criteria.like = query; requestItem.criteria.like = query;
requestItem.criteria.type = ''; requestItem.criteria.type = '';
return this.externalSourcesService.searchPublicationRepository(requestItem); return this.externalSourcesService.listExternal(ExternalReferencesType.PubRepositories, requestItem.criteria.like, requestItem.criteria.type);
} }
searchDatasetExternalJournalRepositories(query: string): Observable<ExternalSourceItemModel[]> { searchDatasetExternalJournalRepositories(query: string): Observable<ExternalReference[]> {
const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem(); const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
requestItem.criteria = new DataRepositoryCriteria(); requestItem.criteria = new DataRepositoryCriteria();
requestItem.criteria.like = query; requestItem.criteria.like = query;
requestItem.criteria.type = ''; requestItem.criteria.type = '';
return this.externalSourcesService.searchJournals(requestItem); return this.externalSourcesService.listExternal(ExternalReferencesType.Journals, requestItem.criteria.like, requestItem.criteria.type);
} }
searchDatasetExternalTaxonomies(query: string): Observable<ExternalSourceItemModel[]> { searchDatasetExternalTaxonomies(query: string): Observable<ExternalReference[]> {
const requestItem: RequestItem<TaxonomyCriteria> = new RequestItem(); const requestItem: RequestItem<TaxonomyCriteria> = new RequestItem();
requestItem.criteria = new TaxonomyCriteria(); requestItem.criteria = new TaxonomyCriteria();
requestItem.criteria.like = query; requestItem.criteria.like = query;
requestItem.criteria.type = ''; requestItem.criteria.type = '';
return this.externalSourcesService.searchTaxonomies(requestItem); return this.externalSourcesService.listExternal(ExternalReferencesType.Taxonomies, requestItem.criteria.like, requestItem.criteria.type);
} }
searchDatasetExternalLicences(query: string): Observable<ExternalSourceItemModel[]> { searchDatasetExternalLicences(query: string): Observable<ExternalReference[]> {
const requestItem: RequestItem<LicenseCriteria> = new RequestItem(); const requestItem: RequestItem<LicenseCriteria> = new RequestItem();
requestItem.criteria = new LicenseCriteria(); requestItem.criteria = new LicenseCriteria();
requestItem.criteria.like = query; requestItem.criteria.like = query;
requestItem.criteria.type = ''; requestItem.criteria.type = '';
return this.externalSourcesService.searchLicense(requestItem); return this.externalSourcesService.listExternal(ExternalReferencesType.Licenses, requestItem.criteria.like, requestItem.criteria.type);
} }
searchDatasetExternalPublications(query: string): Observable<ExternalSourceItemModel[]> { searchDatasetExternalPublications(query: string): Observable<ExternalReference[]> {
const requestItem: RequestItem<PublicationCriteria> = new RequestItem(); const requestItem: RequestItem<PublicationCriteria> = new RequestItem();
requestItem.criteria = new PublicationCriteria(); requestItem.criteria = new PublicationCriteria();
requestItem.criteria.like = query; requestItem.criteria.like = query;
requestItem.criteria.type = ''; requestItem.criteria.type = '';
return this.externalSourcesService.searchPublications(requestItem); return this.externalSourcesService.listExternal(ExternalReferencesType.Publications, requestItem.criteria.like, requestItem.criteria.type);
} }
searchDatasetExternalRegistries(query: string): Observable<ExternalSourceItemModel[]> { searchDatasetExternalRegistries(query: string): Observable<ExternalReference[]> {
const requestItem: RequestItem<RegistryCriteria> = new RequestItem(); const requestItem: RequestItem<RegistryCriteria> = new RequestItem();
requestItem.criteria = new RegistryCriteria(); requestItem.criteria = new RegistryCriteria();
requestItem.criteria.like = query; requestItem.criteria.like = query;
requestItem.criteria.type = ''; requestItem.criteria.type = '';
return this.externalSourcesService.searchDatasetRegistry(requestItem); return this.externalSourcesService.listExternal(ExternalReferencesType.Registries, requestItem.criteria.like, requestItem.criteria.type);
} }
searchDatasetExternalServices(query: string): Observable<ExternalSourceItemModel[]> { searchDatasetExternalServices(query: string): Observable<ExternalReference[]> {
const requestItem: RequestItem<ServiceCriteria> = new RequestItem(); const requestItem: RequestItem<ServiceCriteria> = new RequestItem();
requestItem.criteria = new ServiceCriteria(); requestItem.criteria = new ServiceCriteria();
requestItem.criteria.like = query; requestItem.criteria.like = query;
requestItem.criteria.type = ''; requestItem.criteria.type = '';
return this.externalSourcesService.searchDatasetService(requestItem); return this.externalSourcesService.listExternal(ExternalReferencesType.Services, requestItem.criteria.like, requestItem.criteria.type);
} }
searchDatasetTags(query: string): Observable<ExternalSourceItemModel[]> { searchDatasetTags(query: string): Observable<ExternalSourceItemModel[]> {