add reference type auth enabled
This commit is contained in:
parent
62a5a6fe1d
commit
4187943654
|
@ -5,6 +5,7 @@ import jakarta.xml.bind.annotation.XmlElement;
|
||||||
|
|
||||||
public class AuthenticationConfigurationEntity {
|
public class AuthenticationConfigurationEntity {
|
||||||
|
|
||||||
|
private Boolean enabled;
|
||||||
private String authUrl;
|
private String authUrl;
|
||||||
private ReferenceTypeExternalApiHTTPMethodType authMethod;
|
private ReferenceTypeExternalApiHTTPMethodType authMethod;
|
||||||
private String authTokenPath;
|
private String authTokenPath;
|
||||||
|
@ -15,6 +16,15 @@ public class AuthenticationConfigurationEntity {
|
||||||
return authUrl;
|
return authUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "enabled")
|
||||||
|
public void setEnabled(Boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
@XmlElement(name = "authUrl")
|
@XmlElement(name = "authUrl")
|
||||||
public void setAuthUrl(String authUrl) {
|
public void setAuthUrl(String authUrl) {
|
||||||
this.authUrl = authUrl;
|
this.authUrl = authUrl;
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class AuthenticationConfigurationBuilder extends BaseBuilder<Authenticati
|
||||||
List<AuthenticationConfiguration> models = new ArrayList<>();
|
List<AuthenticationConfiguration> models = new ArrayList<>();
|
||||||
for (AuthenticationConfigurationEntity d : data) {
|
for (AuthenticationConfigurationEntity d : data) {
|
||||||
AuthenticationConfiguration m = new AuthenticationConfiguration();
|
AuthenticationConfiguration m = new AuthenticationConfiguration();
|
||||||
|
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._enabled))) m.setEnabled(d.getEnabled());
|
||||||
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authUrl))) m.setAuthUrl(d.getAuthUrl());
|
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authUrl))) m.setAuthUrl(d.getAuthUrl());
|
||||||
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authMethod))) m.setAuthMethod(d.getAuthMethod());
|
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authMethod))) m.setAuthMethod(d.getAuthMethod());
|
||||||
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authTokenPath))) m.setAuthTokenPath(d.getAuthTokenPath());
|
if (fields.hasField(this.asIndexer(AuthenticationConfiguration._authTokenPath))) m.setAuthTokenPath(d.getAuthTokenPath());
|
||||||
|
|
|
@ -6,6 +6,8 @@ import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
public class AuthenticationConfigurationPersist {
|
public class AuthenticationConfigurationPersist {
|
||||||
|
|
||||||
|
@NotNull(message = "{validation.empty}")
|
||||||
|
private Boolean enabled;
|
||||||
@NotNull(message = "{validation.empty}")
|
@NotNull(message = "{validation.empty}")
|
||||||
private String authUrl;
|
private String authUrl;
|
||||||
|
|
||||||
|
@ -19,6 +21,14 @@ public class AuthenticationConfigurationPersist {
|
||||||
@NotNull(message = "{validation.empty}")
|
@NotNull(message = "{validation.empty}")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
public Boolean getEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(Boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAuthUrl() {
|
public String getAuthUrl() {
|
||||||
return authUrl;
|
return authUrl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ import eu.eudat.commons.enums.ReferenceTypeExternalApiHTTPMethodType;
|
||||||
|
|
||||||
public class AuthenticationConfiguration {
|
public class AuthenticationConfiguration {
|
||||||
|
|
||||||
|
public final static String _enabled = "enabled";
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
public final static String _authUrl = "authUrl";
|
public final static String _authUrl = "authUrl";
|
||||||
private String authUrl;
|
private String authUrl;
|
||||||
|
|
||||||
|
@ -19,6 +22,14 @@ public class AuthenticationConfiguration {
|
||||||
public final static String _type = "type";
|
public final static String _type = "type";
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
|
public Boolean getEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(Boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
public String getAuthUrl() {
|
public String getAuthUrl() {
|
||||||
return authUrl;
|
return authUrl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,6 +223,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
||||||
AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity();
|
AuthenticationConfigurationEntity data = new AuthenticationConfigurationEntity();
|
||||||
if (persist == null) return data;
|
if (persist == null) return data;
|
||||||
|
|
||||||
|
data.setEnabled(persist.getEnabled());
|
||||||
data.setAuthUrl(persist.getAuthUrl());
|
data.setAuthUrl(persist.getAuthUrl());
|
||||||
data.setAuthMethod(persist.getAuthMethod());
|
data.setAuthMethod(persist.getAuthMethod());
|
||||||
data.setAuthRequestBody(persist.getAuthRequestBody());
|
data.setAuthRequestBody(persist.getAuthRequestBody());
|
||||||
|
|
|
@ -107,6 +107,25 @@ public class ReferenceTypeController extends BaseController {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("code/{code}")
|
||||||
|
public ReferenceType get(@PathVariable("code") String code, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||||
|
logger.debug(new MapLogEntry("retrieving" + ReferenceType.class.getSimpleName()).And("code", code).And("fields", fieldSet));
|
||||||
|
|
||||||
|
this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
|
ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).codes(code);
|
||||||
|
ReferenceType model = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
||||||
|
if (model == null)
|
||||||
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{code, Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.ReferenceType_Lookup, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("code", code),
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||||
|
));
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("persist")
|
@PostMapping("persist")
|
||||||
@Transactional
|
@Transactional
|
||||||
public ReferenceType persist(@MyValidate @RequestBody ReferenceTypePersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, InvalidApplicationException {
|
public ReferenceType persist(@MyValidate @RequestBody ReferenceTypePersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, JAXBException, JsonProcessingException, InvalidApplicationException {
|
||||||
|
|
|
@ -55,6 +55,7 @@ export interface ResultFieldsMappingConfiguration{
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthenticationConfiguration{
|
export interface AuthenticationConfiguration{
|
||||||
|
enabled: boolean;
|
||||||
authUrl: string;
|
authUrl: string;
|
||||||
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||||
authTokenPath: string;
|
authTokenPath: string;
|
||||||
|
@ -148,6 +149,7 @@ export interface ResultFieldsMappingConfigurationPersist{
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthenticationConfigurationPersist{
|
export interface AuthenticationConfigurationPersist{
|
||||||
|
enabled: boolean;
|
||||||
authUrl: string;
|
authUrl: string;
|
||||||
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||||
authTokenPath: string;
|
authTokenPath: string;
|
||||||
|
|
|
@ -40,6 +40,15 @@ export class ReferenceTypeService {
|
||||||
catchError((error: any) => throwError(error)));
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSingleWithCode(code: string, reqFields: string[] = []): Observable<ReferenceType> {
|
||||||
|
const url = `${this.apiBase}/code/${code}`;
|
||||||
|
const options = { params: { f: reqFields } };
|
||||||
|
|
||||||
|
return this.http
|
||||||
|
.get<ReferenceType>(url, options).pipe(
|
||||||
|
catchError((error: any) => throwError(error)));
|
||||||
|
}
|
||||||
|
|
||||||
persist(item: ReferenceTypePersist): Observable<ReferenceType> {
|
persist(item: ReferenceTypePersist): Observable<ReferenceType> {
|
||||||
const url = `${this.apiBase}/persist`;
|
const url = `${this.apiBase}/persist`;
|
||||||
|
|
||||||
|
@ -111,4 +120,13 @@ export class ReferenceTypeService {
|
||||||
return lookup;
|
return lookup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///system fields
|
||||||
|
getSystemFields(fields: string[]): string[]{
|
||||||
|
fields.push('reference_id');
|
||||||
|
fields.push('label');
|
||||||
|
fields.push('description');
|
||||||
|
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -240,8 +240,8 @@
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6" *ngIf="source.get('httpMethod').value == referenceTypeExternalApiHTTPMethodType.POST" >
|
||||||
<mat-form-field *ngIf="source.get('httpMethod').value == referenceTypeExternalApiHTTPMethodType.POST" class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUEST-BODY' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUEST-BODY' | translate}}</mat-label>
|
||||||
<input matInput type="text" name="requestBody" [formControl]="source.get('requestBody')">
|
<input matInput type="text" name="requestBody" [formControl]="source.get('requestBody')">
|
||||||
<mat-error *ngIf="source.get('requestBody').hasError('required')">
|
<mat-error *ngIf="source.get('requestBody').hasError('required')">
|
||||||
|
@ -278,30 +278,10 @@
|
||||||
</div>
|
</div>
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<!-- <div class="row" *ngIf="fieldMappingIndex < systemFieldsMapping.length">
|
|
||||||
<div class="col-6">
|
|
||||||
<mat-form-field class="w-100">
|
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
|
||||||
<input matInput type="text" [readonly]="true" name="code" [formControl]="field.get('code')"[ngModel]="systemFieldsMapping[fieldMappingIndex]">
|
|
||||||
<mat-error *ngIf="field.get('code').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<mat-form-field class="w-100">
|
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.RESPONSE-PATH' | translate}}</mat-label>
|
|
||||||
<input matInput type="text" name="responsePath" [formControl]="field.get('responsePath')">
|
|
||||||
<mat-error *ngIf="field.get('responsePath').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
<!-- <div class="row" *ngIf="fieldMappingIndex >= systemFieldsMapping.length"> -->
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||||
<!-- <input matInput type="text" [readonly]="true" name="code" [formControl]="field.get('code')" [ngModel]="formGroup.get('definition').get('fields').value[fieldMappingIndex - systemFieldsMapping.length].code"> -->
|
|
||||||
<input matInput type="text" [readonly]="field.get('code').disabled" name="code" [formControl]="field.get('code')">
|
<input matInput type="text" [readonly]="field.get('code').disabled" name="code" [formControl]="field.get('code')">
|
||||||
<mat-error *ngIf="field.get('code').hasError('required')">
|
<mat-error *ngIf="field.get('code').hasError('required')">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
@ -321,50 +301,54 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Auth info -->
|
<!-- Auth info -->
|
||||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.AUTHENTICATION' | translate}}</h3>
|
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.AUTHENTICATION' | translate}}
|
||||||
<div class="col-6">
|
<mat-checkbox [formControl]="source.get('auth').get('enabled')"></mat-checkbox>
|
||||||
<mat-form-field class="w-100">
|
</h3>
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
|
<div class="row" *ngIf="source.get('auth').get('enabled').value == true">
|
||||||
<input matInput type="text" name="authUrl" [formControl]="source.get('auth').get('authUrl')">
|
<div class="col-6">
|
||||||
<mat-error *ngIf="source.get('auth').get('authUrl').hasError('required')">
|
<mat-form-field class="w-100">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.URL' | translate}}</mat-label>
|
||||||
</mat-form-field>
|
<input matInput type="text" name="authUrl" [formControl]="source.get('auth').get('authUrl')">
|
||||||
</div>
|
<mat-error *ngIf="source.get('auth').get('authUrl').hasError('required')">
|
||||||
<div class="col-6">
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<mat-form-field class="w-100">
|
</mat-form-field>
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.HTTP-METHOD' | translate}}</mat-label>
|
</div>
|
||||||
<mat-select name="httpMethod" [formControl]="source.get('auth').get('authMethod')">
|
<div class="col-6">
|
||||||
<mat-option *ngFor="let httpMethod of referenceTypeExternalApiHTTPMethodTypeEnum" [value]="httpMethod">
|
<mat-form-field class="w-100">
|
||||||
{{enumUtils.toReferenceTypeExternalApiHTTPMethodTypeString(httpMethod)}}
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.HTTP-METHOD' | translate}}</mat-label>
|
||||||
</mat-option>
|
<mat-select name="httpMethod" [formControl]="source.get('auth').get('authMethod')">
|
||||||
</mat-select>
|
<mat-option *ngFor="let httpMethod of referenceTypeExternalApiHTTPMethodTypeEnum" [value]="httpMethod">
|
||||||
<mat-error *ngIf="source.get('auth').get('authMethod').hasError('required')">
|
{{enumUtils.toReferenceTypeExternalApiHTTPMethodTypeString(httpMethod)}}
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
</mat-option>
|
||||||
</mat-form-field>
|
</mat-select>
|
||||||
</div>
|
<mat-error *ngIf="source.get('auth').get('authMethod').hasError('required')">
|
||||||
<div class="col-6">
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<mat-form-field class="w-100">
|
</mat-form-field>
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TOKEN-PATH' | translate}}</mat-label>
|
</div>
|
||||||
<input matInput type="text" name="authTokenPath" [formControl]="source.get('auth').get('authTokenPath')">
|
<div class="col-6">
|
||||||
<mat-error *ngIf="source.get('auth').get('authTokenPath').hasError('required')">
|
<mat-form-field class="w-100">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TOKEN-PATH' | translate}}</mat-label>
|
||||||
</mat-form-field>
|
<input matInput type="text" name="authTokenPath" [formControl]="source.get('auth').get('authTokenPath')">
|
||||||
</div>
|
<mat-error *ngIf="source.get('auth').get('authTokenPath').hasError('required')">
|
||||||
<div class="col-6">
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<mat-form-field class="w-100">
|
</mat-form-field>
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUEST-BODY' | translate}}</mat-label>
|
</div>
|
||||||
<input matInput type="text" name="authRequestBody" [formControl]="source.get('auth').get('authRequestBody')">
|
<div class="col-6">
|
||||||
<mat-error *ngIf="source.get('auth').get('authRequestBody').hasError('required')">
|
<mat-form-field class="w-100">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.REQUEST-BODY' | translate}}</mat-label>
|
||||||
</mat-form-field>
|
<input matInput type="text" name="authRequestBody" [formControl]="source.get('auth').get('authRequestBody')">
|
||||||
</div>
|
<mat-error *ngIf="source.get('auth').get('authRequestBody').hasError('required')">
|
||||||
<div class="col-6">
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<mat-form-field class="w-100">
|
</mat-form-field>
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TYPE' | translate}}</mat-label>
|
</div>
|
||||||
<input matInput type="text" name="type" [formControl]="source.get('auth').get('type')">
|
<div class="col-6">
|
||||||
<mat-error *ngIf="source.get('auth').get('type').hasError('required')">
|
<mat-form-field class="w-100">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TYPE' | translate}}</mat-label>
|
||||||
</mat-form-field>
|
<input matInput type="text" name="type" [formControl]="source.get('auth').get('type')">
|
||||||
|
<mat-error *ngIf="source.get('auth').get('type').hasError('required')">
|
||||||
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Queries info -->
|
<!-- Queries info -->
|
||||||
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERIES' | translate}}
|
<h3 class="col-12">{{'REFERENCE-TYPE-EDITOR.FIELDS.QUERIES' | translate}}
|
||||||
|
@ -439,30 +423,10 @@
|
||||||
</div>
|
</div>
|
||||||
</mat-card-header>
|
</mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<!-- <div class="row" *ngIf="optionsIndex < systemFieldsMapping.length">
|
|
||||||
<div class="col-6">
|
|
||||||
<mat-form-field class="w-100">
|
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
|
||||||
<input matInput type="text" [readonly]="true" name="code" [formControl]="option.get('code')"[ngModel]="systemFieldsMapping[optionsIndex]">
|
|
||||||
<mat-error *ngIf="option.get('code').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<mat-form-field class="w-100">
|
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.VALUE' | translate}}</mat-label>
|
|
||||||
<input matInput type="text" name="value" [formControl]="option.get('value')">
|
|
||||||
<mat-error *ngIf="option.get('value').hasError('required')">
|
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row" *ngIf="optionsIndex >= systemFieldsMapping.length"> -->
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||||
<!-- <input matInput type="text" [readonly]="true" name="code" [formControl]="option.get('code')" [ngModel]="formGroup.get('definition').get('fields').value[optionsIndex - systemFieldsMapping.length].code"> -->
|
|
||||||
<input matInput type="text" [readonly]="option.get('code').disabled" name="code" [formControl]="option.get('code')">
|
<input matInput type="text" [readonly]="option.get('code').disabled" name="code" [formControl]="option.get('code')">
|
||||||
<mat-error *ngIf="option.get('code').hasError('required')">
|
<mat-error *ngIf="option.get('code').hasError('required')">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
@ -506,7 +470,7 @@
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.CODE' | translate}}</mat-label>
|
||||||
<mat-select [value] ="selectedReferenceTypeCode" (selectionChange)="selectedReferenceTypeChanged($event.value)" name="referenceTypeCode" [formControl]="dependency.get('referenceTypeCode')" required>
|
<mat-select (selectionChange)="selectedReferenceTypeChanged($event.value)" name="referenceTypeCode" [formControl]="dependency.get('referenceTypeCode')" required>
|
||||||
<mat-option *ngFor="let referenceType of referenceTypes" [value]="referenceType.code">
|
<mat-option *ngFor="let referenceType of referenceTypes" [value]="referenceType.code">
|
||||||
{{referenceType.code}}
|
{{referenceType.code}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
@ -519,7 +483,7 @@
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.KEY' | translate}}</mat-label>
|
||||||
<mat-select name = 'key' [formControl]="dependency.get('key')" required>
|
<mat-select name = 'key' [formControl]="dependency.get('key')" required>
|
||||||
<mat-option *ngFor="let key of sourceKeys" [value]="key">
|
<mat-option *ngFor="let key of sourceKeysMap.get(dependency.get('referenceTypeCode').value)" [value]="key">
|
||||||
{{key}}
|
{{key}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
|
@ -570,7 +534,7 @@
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TARGET' | translate}}</mat-label>
|
<mat-label>{{'REFERENCE-TYPE-EDITOR.FIELDS.TARGET' | translate}}</mat-label>
|
||||||
<mat-select name = 'target' [formControl]="property.get('target')" required>
|
<mat-select name = 'target' [formControl]="property.get('target')" required>
|
||||||
<mat-option *ngFor="let targetCode of targetPropertyCodes" [value]="targetCode">
|
<mat-option *ngFor="let targetCode of targetPropertyCodesMap.get(dependency.get('referenceTypeCode').value)" [value]="targetCode">
|
||||||
{{targetCode}}
|
{{targetCode}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
|
|
|
@ -29,7 +29,6 @@ import { DependencyPropertyEditorModel, QueryConfigEditorModel, ReferenceTypeEdi
|
||||||
import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type';
|
import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type';
|
||||||
import { ReferenceTypeSourceType } from '@app/core/common/enum/reference-type-source-type';
|
import { ReferenceTypeSourceType } from '@app/core/common/enum/reference-type-source-type';
|
||||||
import { ReferenceTypeExternalApiHTTPMethodType } from '@app/core/common/enum/reference-type-external-api-http-method-type';
|
import { ReferenceTypeExternalApiHTTPMethodType } from '@app/core/common/enum/reference-type-external-api-http-method-type';
|
||||||
import { ReferenceTypeLookup } from '@app/core/query/reference-type.lookup';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -50,10 +49,11 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
public referenceFieldDataTypeEnum = this.enumUtils.getEnumValues(ReferenceFieldDataType);
|
public referenceFieldDataTypeEnum = this.enumUtils.getEnumValues(ReferenceFieldDataType);
|
||||||
public referenceTypeExternalApiHTTPMethodTypeEnum = this.enumUtils.getEnumValues(ReferenceTypeExternalApiHTTPMethodType);
|
public referenceTypeExternalApiHTTPMethodTypeEnum = this.enumUtils.getEnumValues(ReferenceTypeExternalApiHTTPMethodType);
|
||||||
referenceTypes: ReferenceType[] = null;
|
referenceTypes: ReferenceType[] = null;
|
||||||
selectedReferenceTypeCode: string = null;
|
|
||||||
sourceKeys: string[] = [];
|
sourceKeys: string[] = [];
|
||||||
|
sourceKeysMap: Map<string, string[]> = new Map<string, string[]>();
|
||||||
propertyCodes: string[] = [];
|
propertyCodes: string[] = [];
|
||||||
targetPropertyCodes: string[] = [];
|
targetPropertyCodes: string[] = [];
|
||||||
|
targetPropertyCodesMap: Map<string, string[]> = new Map<string, string[]>();
|
||||||
|
|
||||||
protected get canDelete(): boolean {
|
protected get canDelete(): boolean {
|
||||||
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeleteReferenceType);
|
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeleteReferenceType);
|
||||||
|
@ -115,24 +115,16 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
this.editorModel = data ? new ReferenceTypeEditorModel().fromModel(data) : new ReferenceTypeEditorModel();
|
this.editorModel = data ? new ReferenceTypeEditorModel().fromModel(data) : new ReferenceTypeEditorModel();
|
||||||
|
|
||||||
this.getReferenceTypes(this.editorModel.id);
|
this.getReferenceTypes(this.editorModel.id);
|
||||||
|
this.propertyCodes = this.referenceTypeService.getSystemFields([]);
|
||||||
|
|
||||||
if(data){
|
if(data){
|
||||||
this.editorModel.definition.sources.forEach(source => source.dependencies.forEach(dependency => {
|
this.editorModel.definition.sources.forEach(source => source.dependencies.forEach(dependency => {
|
||||||
this.selectedReferenceTypeChanged(dependency.referenceTypeCode);
|
this.selectedReferenceTypeChanged(dependency.referenceTypeCode);
|
||||||
}));
|
}));
|
||||||
this.editorModel.definition.sources.forEach(source => {
|
|
||||||
if(source.type == ReferenceTypeSourceType.STATIC){
|
this.editorModel.definition.fields.forEach(field => {
|
||||||
source.options.forEach(option => {
|
if(!this.propertyCodes.includes(field.code)){
|
||||||
if(!this.propertyCodes.includes(option.code)){
|
this.propertyCodes.push(field.code);
|
||||||
this.propertyCodes.push(option.code);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
source.results.fieldsMapping.forEach(fieldMapping => {
|
|
||||||
if(!this.propertyCodes.includes(fieldMapping.code)){
|
|
||||||
this.propertyCodes.push(fieldMapping.code);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -394,50 +386,55 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(response => {
|
.subscribe(response => {
|
||||||
this.referenceTypes = response.items as ReferenceType[];
|
this.referenceTypes = response.items as ReferenceType[];
|
||||||
|
this.referenceTypes.forEach(referenceType =>{
|
||||||
|
this.sourceKeysMap.set(referenceType.code, []);
|
||||||
|
this.targetPropertyCodesMap.set(referenceType.code, []);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedReferenceTypeChanged(code: string): void{
|
selectedReferenceTypeChanged(code: string): void{
|
||||||
this.selectedReferenceTypeCode = code;
|
|
||||||
this.sourceKeys = [];
|
this.sourceKeys = [];
|
||||||
this.targetPropertyCodes = [];
|
this.targetPropertyCodes = [];
|
||||||
|
|
||||||
const lookup = ReferenceTypeService.DefaultReferenceTypeLookup();
|
this.referenceTypeService.getSingleWithCode(code, ReferenceTypeEditorResolver.lookupFields())
|
||||||
lookup.codes = [this.selectedReferenceTypeCode];
|
|
||||||
|
|
||||||
this.referenceTypeService.query(lookup)
|
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(response => {
|
.subscribe(data => {
|
||||||
if(response.count ==1){
|
const referenceType = data as ReferenceType;
|
||||||
const referenceType = response.items[0] as ReferenceType;
|
|
||||||
|
// source keys
|
||||||
referenceType.definition.sources.forEach(source => {
|
referenceType.definition.sources.forEach(source => {
|
||||||
if(!this.sourceKeys.includes(source.key)) this.sourceKeys.push(source.key)
|
if(!this.sourceKeys.includes(source.key)) this.sourceKeys.push(source.key)
|
||||||
if(source.type == ReferenceTypeSourceType.API){
|
|
||||||
source.results.fieldsMapping.forEach(target => {
|
|
||||||
if(!this.targetPropertyCodes.includes(target.code)) this.targetPropertyCodes.push(target.code)
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
source.options.forEach(target => {
|
|
||||||
if(!this.targetPropertyCodes.includes(target.code)) this.targetPropertyCodes.push(target.code)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
if(this.sourceKeysMap.has(code) && this.sourceKeysMap.get(code).length == 0){
|
||||||
|
this.sourceKeysMap.set(code, this.sourceKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// targetPropertyCodes
|
||||||
|
|
||||||
|
let fields = [];
|
||||||
|
if(referenceType.definition.fields) {
|
||||||
|
fields = this.referenceTypeService.getSystemFields(referenceType.definition.fields.map(x => x.code));
|
||||||
|
}else{
|
||||||
|
fields = this.referenceTypeService.getSystemFields(fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
fields.forEach(field => {
|
||||||
|
if(!this.targetPropertyCodes.includes(field)) this.targetPropertyCodes.push(field)
|
||||||
|
})
|
||||||
|
|
||||||
|
if(this.targetPropertyCodesMap.has(code) && this.targetPropertyCodesMap.get(code).length == 0){
|
||||||
|
this.targetPropertyCodesMap.set(code, this.targetPropertyCodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
addProperty(sourceIndex: number, dependencyIndex: number): void{
|
addProperty(sourceIndex: number, dependencyIndex: number): void{
|
||||||
|
|
||||||
const optionFormArray = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('options') as FormArray);
|
|
||||||
|
|
||||||
for(let i =0; i < optionFormArray.length; i++){
|
|
||||||
if(!this.propertyCodes.includes(optionFormArray.at(i).get('code').getRawValue())){
|
|
||||||
this.propertyCodes.push(optionFormArray.at(i).get('code').getRawValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('dependencies') as FormArray).at(dependencyIndex).get('referenceTypeCode').value == null){
|
if (((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('dependencies') as FormArray).at(dependencyIndex).get('referenceTypeCode').value == null){
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,7 +442,7 @@ export class ResultFieldsMappingConfigurationEditorModel implements ResultFields
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.formBuilder.group({
|
return this.formBuilder.group({
|
||||||
code: [{ value: "code", disabled: true }, context.getValidation('code').validators],
|
code: [{ value: this.code, disabled: true }, context.getValidation('code').validators],
|
||||||
responsePath: [{ value: this.responsePath, disabled: disabled }, context.getValidation('responsePath').validators],
|
responsePath: [{ value: this.responsePath, disabled: disabled }, context.getValidation('responsePath').validators],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -464,6 +464,7 @@ export class ResultFieldsMappingConfigurationEditorModel implements ResultFields
|
||||||
}
|
}
|
||||||
|
|
||||||
export class AuthenticationConfigurationEditorModel implements AuthenticationConfigurationPersist {
|
export class AuthenticationConfigurationEditorModel implements AuthenticationConfigurationPersist {
|
||||||
|
public enabled: boolean;
|
||||||
public authUrl: string;
|
public authUrl: string;
|
||||||
public authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
public authMethod: ReferenceTypeExternalApiHTTPMethodType;
|
||||||
public authTokenPath: string;
|
public authTokenPath: string;
|
||||||
|
@ -477,6 +478,7 @@ export class AuthenticationConfigurationEditorModel implements AuthenticationCon
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
fromModel(item: AuthenticationConfiguration): AuthenticationConfigurationEditorModel {
|
fromModel(item: AuthenticationConfiguration): AuthenticationConfigurationEditorModel {
|
||||||
|
this.enabled = item.enabled;
|
||||||
this.authUrl = item.authUrl;
|
this.authUrl = item.authUrl;
|
||||||
this.authMethod = item.authMethod;
|
this.authMethod = item.authMethod;
|
||||||
this.authTokenPath = item.authTokenPath;
|
this.authTokenPath = item.authTokenPath;
|
||||||
|
@ -500,6 +502,7 @@ export class AuthenticationConfigurationEditorModel implements AuthenticationCon
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.formBuilder.group({
|
return this.formBuilder.group({
|
||||||
|
enabled: [{ value: this.enabled, disabled: disabled }, context.getValidation('enabled').validators],
|
||||||
authUrl: [{ value: this.authUrl, disabled: disabled }, context.getValidation('authUrl').validators],
|
authUrl: [{ value: this.authUrl, disabled: disabled }, context.getValidation('authUrl').validators],
|
||||||
authMethod: [{ value: this.authMethod, disabled: disabled }, context.getValidation('authMethod').validators],
|
authMethod: [{ value: this.authMethod, disabled: disabled }, context.getValidation('authMethod').validators],
|
||||||
authTokenPath: [{ value: this.authTokenPath, disabled: disabled }, context.getValidation('authTokenPath').validators],
|
authTokenPath: [{ value: this.authTokenPath, disabled: disabled }, context.getValidation('authTokenPath').validators],
|
||||||
|
@ -516,6 +519,7 @@ export class AuthenticationConfigurationEditorModel implements AuthenticationCon
|
||||||
|
|
||||||
const baseContext: ValidationContext = new ValidationContext();
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
|
baseValidationArray.push({ key: 'enabled', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}enabled`)] });
|
||||||
baseValidationArray.push({ key: 'authUrl', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authUrl`)] });
|
baseValidationArray.push({ key: 'authUrl', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authUrl`)] });
|
||||||
baseValidationArray.push({ key: 'authMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authMethod`)] });
|
baseValidationArray.push({ key: 'authMethod', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authMethod`)] });
|
||||||
baseValidationArray.push({ key: 'authTokenPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authTokenPath`)] });
|
baseValidationArray.push({ key: 'authTokenPath', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}authTokenPath`)] });
|
||||||
|
|
|
@ -45,6 +45,7 @@ export class ReferenceTypeEditorResolver extends BaseEditorResolver {
|
||||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.requestBody)].join('.'),
|
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.requestBody)].join('.'),
|
||||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.filterType)].join('.'),
|
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.filterType)].join('.'),
|
||||||
|
|
||||||
|
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.enabled)].join('.'),
|
||||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
|
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authUrl)].join('.'),
|
||||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
|
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authMethod)].join('.'),
|
||||||
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
|
[nameof<ReferenceType>(x => x.definition), nameof<ReferenceTypeDefinition>(x => x.sources), nameof<ReferenceTypeSourceBaseConfiguration>(x => x.auth),nameof<AuthenticationConfiguration>(x => x.authTokenPath)].join('.'),
|
||||||
|
|
|
@ -1162,13 +1162,13 @@
|
||||||
"REMOVE-DEPENDENCY": "Remove Dependency",
|
"REMOVE-DEPENDENCY": "Remove Dependency",
|
||||||
"ADD-PROPERTY": "Add property",
|
"ADD-PROPERTY": "Add property",
|
||||||
"REMOVE-PROPERTY": "Remove property"
|
"REMOVE-PROPERTY": "Remove property"
|
||||||
|
},
|
||||||
|
"CONFIRM-DELETE-DIALOG": {
|
||||||
|
"MESSAGE": "Would you like to delete this Reference type?",
|
||||||
|
"CONFIRM-BUTTON": "Yes, delete",
|
||||||
|
"CANCEL-BUTTON": "No"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CONFIRM-DELETE-DIALOG": {
|
|
||||||
"MESSAGE": "Would you like to delete this Reference type?",
|
|
||||||
"CONFIRM-BUTTON": "Yes, delete",
|
|
||||||
"CANCEL-BUTTON": "No"
|
|
||||||
},
|
|
||||||
"DMP-BLUEPRINT-EDITOR": {
|
"DMP-BLUEPRINT-EDITOR": {
|
||||||
"TITLE": {
|
"TITLE": {
|
||||||
"NEW": "New DMP Blueprint",
|
"NEW": "New DMP Blueprint",
|
||||||
|
|
Loading…
Reference in New Issue