fetcher, ui small changes
This commit is contained in:
parent
b343b76c9e
commit
fd30b89f93
|
@ -0,0 +1,14 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
public class DescriptionTemplateSemanticsLookup {
|
||||
|
||||
private String like;
|
||||
|
||||
public String getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(String like) {
|
||||
this.like = like;
|
||||
}
|
||||
}
|
|
@ -5,9 +5,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.PathNotFoundException;
|
||||
import eu.eudat.commons.JsonHandlingService;
|
||||
import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
||||
import eu.eudat.commons.exceptions.HugeResultSetException;
|
||||
import eu.eudat.commons.types.dashborad.RecentActivityItemEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.eudat.model.Reference;
|
||||
|
@ -39,10 +39,12 @@ public class RemoteFetcherServiceImpl implements RemoteFetcherService {
|
|||
private WebClient webClient;
|
||||
private final ExternalUrlConfigProvider externalUrlConfigProvider;
|
||||
private final ConventionService conventionService;
|
||||
private final JsonHandlingService jsonHandlingService;
|
||||
@Autowired
|
||||
public RemoteFetcherServiceImpl(ExternalUrlConfigProvider externalUrlConfigProvider, ConventionService conventionService) {
|
||||
public RemoteFetcherServiceImpl(ExternalUrlConfigProvider externalUrlConfigProvider, ConventionService conventionService, JsonHandlingService jsonHandlingService) {
|
||||
this.externalUrlConfigProvider = externalUrlConfigProvider;
|
||||
this.conventionService = conventionService;
|
||||
this.jsonHandlingService = jsonHandlingService;
|
||||
}
|
||||
|
||||
private WebClient getWebClient(){
|
||||
|
@ -304,10 +306,13 @@ public class RemoteFetcherServiceImpl implements RemoteFetcherService {
|
|||
Object value = JsonPath.parse(resultItem).read(field.getResponsePath());
|
||||
map.put(field.getCode(), normalizeJsonValue(value));
|
||||
}catch (PathNotFoundException e){
|
||||
List<Object> nextLevelResults = jsonContext.read(resultsConfigurationEntity.getResultsArrayPath() + field.getResponsePath());
|
||||
for(Object nextLevelResultValue : nextLevelResults) {
|
||||
map.put(field.getCode(), normalizeJsonValue(nextLevelResultValue));
|
||||
}
|
||||
// List<Object> nextLevelResults = jsonContext.read(resultsConfigurationEntity.getResultsArrayPath() + field.getResponsePath());
|
||||
// for(Object nextLevelResultValue : nextLevelResults) {
|
||||
// map.put(field.getCode(), normalizeJsonValue(nextLevelResultValue));
|
||||
// }
|
||||
logger.debug("Json Path Error: " + e.getMessage() + " on source " + jsonHandlingService.toJsonSafe(resultItem));
|
||||
//TODO if value don't exist
|
||||
continue;
|
||||
}
|
||||
}
|
||||
parsedData.add(map);
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.controllers;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import eu.eudat.audit.AuditableAction;
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.query.lookup.DescriptionTemplateSemanticsLookup;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
||||
import eu.eudat.data.DescriptionTemplateEntity;
|
||||
|
@ -202,14 +203,14 @@ public class DescriptionTemplateController {
|
|||
return model;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/get-semantics"}, produces = "application/json")
|
||||
public List<String> getSemantics(@RequestParam(value = "query", required = false) String query) throws IOException {
|
||||
logger.debug(new MapLogEntry("import" + DescriptionTemplate.class.getSimpleName()).And("query", query));
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"get-semantics"})
|
||||
public List<String> getSemantics(@RequestBody DescriptionTemplateSemanticsLookup lookup) throws IOException {
|
||||
logger.debug(new MapLogEntry("retrieving {}" + DescriptionTemplate.class.getSimpleName()).And("like", lookup.getLike()));
|
||||
|
||||
List<String> semantics = this.descriptionTemplateTypeService.getSemantics(query);
|
||||
List<String> semantics = this.descriptionTemplateTypeService.getSemantics(lookup.getLike());
|
||||
|
||||
this.auditService.track(AuditableAction.DescriptionTemplate_GetSemantics, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("query", query)
|
||||
new AbstractMap.SimpleEntry<String, Object>("lookup", lookup)
|
||||
));
|
||||
|
||||
return semantics;
|
||||
|
|
|
@ -15,7 +15,7 @@ BEGIN
|
|||
created_by uuid,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
type smallint NOT NULL,
|
||||
type uuid NOT NULL,
|
||||
definition character varying COLLATE pg_catalog."default",
|
||||
reference character varying(1024) COLLATE pg_catalog."default" NOT NULL,
|
||||
source_type smallint NOT NULL,
|
||||
|
@ -30,6 +30,13 @@ BEGIN
|
|||
OIDS = FALSE
|
||||
);
|
||||
|
||||
ALTER TABLE public."Reference"
|
||||
ADD CONSTRAINT "Reference_type_fkey" FOREIGN KEY (type)
|
||||
REFERENCES public."ReferenceType" (id)
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
NOT VALID;
|
||||
|
||||
CREATE TABLE public."ReferenceType"
|
||||
(
|
||||
id uuid NOT NULL,
|
||||
|
|
|
@ -18,6 +18,7 @@ import { ConfigurationService } from '../configuration/configuration.service';
|
|||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||
import { DescriptionTemplateVersionStatus } from '@app/core/common/enum/description-template-version-status';
|
||||
import { DescriptionTemplateStatus } from '@app/core/common/enum/description-template-status';
|
||||
import { DescriptionTemplateSemanticsLookup } from '@app/core/query/description-template-semantics.lookup';
|
||||
|
||||
@Injectable()
|
||||
export class DescriptionTemplateService {
|
||||
|
@ -98,6 +99,11 @@ export class DescriptionTemplateService {
|
|||
return this.http.post(url, formData, { params: params });
|
||||
}
|
||||
|
||||
searchSemantics(q: DescriptionTemplateSemanticsLookup ): Observable<String[]> {
|
||||
const url = `${this.apiBase}/get-semantics`;
|
||||
return this.http.post<String[]>(url, q).pipe(catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
//
|
||||
// Autocomplete Commons
|
||||
//
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<div class="col-6">
|
||||
<mat-form-field class="w-100">
|
||||
<mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label>
|
||||
<app-single-auto-complete placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}" [required]="true" [form]="form.get('data').get('referenceTypeId')" [configuration]="referenceTypeService.singleAutocompleteConfiguration"></app-single-auto-complete>
|
||||
<app-single-auto-complete placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}" [required]="true" [formControl]="form.get('data').get('referenceTypeId')" [configuration]="referenceTypeService.singleAutocompleteConfiguration"></app-single-auto-complete>
|
||||
<mat-error *ngIf="form.get('data').get('referenceTypeId').hasError('backendError')">{{form.get('data').get('referenceTypeId').getError('backendError').message}}</mat-error>
|
||||
<mat-error *ngIf="form.get('data').get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
</mat-form-field>
|
||||
|
|
|
@ -26,6 +26,8 @@ import { Observable, of } from 'rxjs';
|
|||
import { map } from 'rxjs/operators';
|
||||
import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel } from '../../description-template-editor.model';
|
||||
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
||||
import { DescriptionTemplateSemanticsLookup } from '@app/core/query/description-template-semantics.lookup';
|
||||
import { FilterService } from '@common/modules/text-filter/filter-service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-description-template-editor-field-component',
|
||||
|
@ -51,22 +53,29 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
|
|||
readonly separatorKeysCodes: number[] = [ENTER, COMMA];
|
||||
|
||||
semanticsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
||||
filterFn: this.filterSemantics.bind(this),
|
||||
initialItems: (excludedItems: any[]) => this.filterSemantics('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x !== resultItem)))),
|
||||
initialItems: (data?: any) => this.descriptionTemplateService.searchSemantics(this.buildAutocompleteLookup()).pipe(map(x => x)),
|
||||
filterFn: (searchQuery: string, data?: any) => this.descriptionTemplateService.searchSemantics(this.buildAutocompleteLookup(searchQuery)).pipe(map(x => x)),
|
||||
displayFn: (item) => item,
|
||||
titleFn: (item) => item
|
||||
titleFn: (item) => item,
|
||||
}
|
||||
|
||||
filterSemantics(value: string): Observable<String[]> {
|
||||
// return this.descriptionTemplateService.searchSemantics(value);
|
||||
return of([]);
|
||||
// filterSemantics(value: string): Observable<String[]> {
|
||||
// // return this.descriptionTemplateService.searchSemantics(value);
|
||||
// return of([]);
|
||||
// }
|
||||
|
||||
private buildAutocompleteLookup(like?: string ): DescriptionTemplateSemanticsLookup {
|
||||
const lookup: DescriptionTemplateSemanticsLookup = new DescriptionTemplateSemanticsLookup();
|
||||
if (like) { lookup.like = this.filterService.transformLike(like); }
|
||||
return lookup;
|
||||
}
|
||||
|
||||
constructor(
|
||||
public enumUtils: EnumUtils,
|
||||
public descriptionTemplateService: DescriptionTemplateService,
|
||||
private dialog: MatDialog,
|
||||
private configurationService: ConfigurationService
|
||||
private configurationService: ConfigurationService,
|
||||
private filterService: FilterService
|
||||
) {
|
||||
super();
|
||||
|
||||
|
|
Loading…
Reference in New Issue