argos/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts

793 lines
33 KiB
TypeScript
Raw Normal View History

2024-02-02 09:29:38 +01:00
import { FormControl, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
2023-12-06 22:10:01 +01:00
import { DescriptionStatus } from "@app/core/common/enum/description-status";
2024-02-02 09:29:38 +01:00
import { DescriptionTemplate, DescriptionTemplateFieldSet, DescriptionTemplateSection } from "@app/core/model/description-template/description-template";
import { Description, DescriptionField, DescriptionFieldPersist, DescriptionPersist, DescriptionPropertyDefinition, DescriptionPropertyDefinitionFieldSet, DescriptionPropertyDefinitionFieldSetItem, DescriptionPropertyDefinitionFieldSetItemPersist, DescriptionPropertyDefinitionFieldSetPersist, DescriptionPropertyDefinitionPersist, DescriptionReference, DescriptionReferencePersist } from "@app/core/model/description/description";
2023-12-06 22:10:01 +01:00
import { ReferencePersist } from "@app/core/model/reference/reference";
import { BaseEditorModel } from "@common/base/base-form-editor-model";
import { BackendErrorValidator } from '@common/forms/validation/custom-validator';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { Validation, ValidationContext } from '@common/forms/validation/validation-context';
import { Guid } from "@common/types/guid";
export class DescriptionEditorModel extends BaseEditorModel implements DescriptionPersist {
label: string;
dmpId: Guid;
dmpDescriptionTemplateId: Guid;
descriptionTemplateId: Guid;
status: DescriptionStatus;
description: string;
2024-01-25 19:55:42 +01:00
properties: DescriptionPropertyDefinitionEditorModel = new DescriptionPropertyDefinitionEditorModel();
2023-12-06 22:10:01 +01:00
tags: string[];
references: DescriptionReferenceEditorModel[];
permissions: string[];
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor() { super(); }
2024-01-25 19:55:42 +01:00
public fromModel(item: Description, descriptionTemplate?: DescriptionTemplate): DescriptionEditorModel {
2023-12-06 22:10:01 +01:00
if (item) {
super.fromModel(item);
this.label = item.label;
this.dmpId = item.dmp?.id;
this.dmpDescriptionTemplateId = item.dmpDescriptionTemplate?.id;
this.descriptionTemplateId = item.descriptionTemplate?.id;
this.status = item.status;
this.description = item.description;
this.tags = item.descriptionTags?.map(x => x.tag?.label);
2024-02-02 09:29:38 +01:00
this.properties = new DescriptionPropertyDefinitionEditorModel().fromModel(item.properties, descriptionTemplate);
2023-12-06 22:10:01 +01:00
//if (item.references) { item.references.map(x => this.references.push(new DescriptionReferenceEditorModel().fromModel(x))); }
}
return this;
}
buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup {
if (context == null) { context = this.createValidationContext(); }
return this.formBuilder.group({
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
dmpId: [{ value: this.dmpId, disabled: disabled }, context.getValidation('dmpId').validators],
dmpDescriptionTemplateId: [{ value: this.dmpDescriptionTemplateId, disabled: disabled }, context.getValidation('dmpDescriptionTemplateId').validators],
descriptionTemplateId: [{ value: this.descriptionTemplateId, disabled: disabled }, context.getValidation('descriptionTemplateId').validators],
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
tags: [{ value: this.tags, disabled: disabled }, context.getValidation('tags').validators],
2024-02-02 09:29:38 +01:00
properties: this.buildProperties(),
2023-12-06 22:10:01 +01:00
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
});
}
2024-02-02 09:29:38 +01:00
buildProperties() {
return this.properties.buildForm({
rootPath: `properties.`
});
}
2023-12-06 22:10:01 +01:00
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
baseValidationArray.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
baseValidationArray.push({ key: 'dmpId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'dmpId')] });
baseValidationArray.push({ key: 'dmpDescriptionTemplateId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'dmpDescriptionTemplateId')] });
baseValidationArray.push({ key: 'descriptionTemplateId', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'descriptionTemplateId')] });
baseValidationArray.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] });
baseValidationArray.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
baseValidationArray.push({ key: 'tags', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'tags')] });
baseValidationArray.push({ key: 'hash', validators: [] });
baseContext.validation = baseValidationArray;
return baseContext;
}
}
2024-02-02 09:29:38 +01:00
export class DescriptionPropertyDefinitionEditorModel implements DescriptionPropertyDefinitionPersist {
fieldSets: Map<string, DescriptionPropertyDefinitionFieldSetEditorModel> = new Map<string, DescriptionPropertyDefinitionFieldSetEditorModel>;
2023-12-06 22:10:01 +01:00
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
2024-02-02 09:29:38 +01:00
public fromModel(item: DescriptionPropertyDefinition, descriptionTemplate: DescriptionTemplate): DescriptionPropertyDefinitionEditorModel {
this.fieldSets = this.calculateProperties(item, descriptionTemplate);
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = DescriptionPropertyDefinitionEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
const formGroup = this.formBuilder.group({});
const fieldSetsFormGroup = this.formBuilder.group({});
if (this.fieldSets.size > 0) {
this.fieldSets.forEach((value, key) => fieldSetsFormGroup.addControl(key.toString(), value.buildForm({
rootPath: `${rootPath}fieldSets[${key}].`
})), context.getValidation('fieldSets'));
formGroup.addControl('fieldSets', fieldSetsFormGroup);
}
return formGroup;
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'fieldSets', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fieldSets`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
private calculateProperties(item: DescriptionPropertyDefinition, descriptionTemplate: DescriptionTemplate,): Map<string, DescriptionPropertyDefinitionFieldSetEditorModel> {
let result: Map<string, DescriptionPropertyDefinitionFieldSetEditorModel> = new Map<string, DescriptionPropertyDefinitionFieldSetEditorModel>();
if (descriptionTemplate) (
descriptionTemplate.definition.pages.forEach(definitionPage => {
definitionPage.sections.forEach(definitionSection => {
const sectionResult = this.calculateSectionProperties(definitionSection, item);
if (sectionResult != null) {
result = new Map([...result, ...sectionResult]);
}
})
})
)
return result;
}
private calculateSectionProperties(definitionSection: DescriptionTemplateSection, item: DescriptionPropertyDefinition): Map<string, DescriptionPropertyDefinitionFieldSetEditorModel> {
if (definitionSection == null) return null;
let result: Map<string, DescriptionPropertyDefinitionFieldSetEditorModel> = new Map<string, DescriptionPropertyDefinitionFieldSetEditorModel>();
definitionSection?.fieldSets?.forEach(definitionFieldSet => {
const fieldSetResult = this.calculateFieldSetProperties(definitionFieldSet, item);
if (fieldSetResult != null) {
2024-02-02 17:43:24 +01:00
result.set(definitionFieldSet.id, fieldSetResult);
2024-02-02 09:29:38 +01:00
}
});
if (definitionSection.sections != null && definitionSection.sections?.length > 0) {
definitionSection.sections.forEach(nestedDefinitionSection => {
const nestedSectionResult = this.calculateSectionProperties(nestedDefinitionSection, item);
if (nestedSectionResult != null) {
result = new Map([...result, ...nestedSectionResult]);
}
});
}
return result;
}
2024-02-02 17:43:24 +01:00
public calculateFieldSetProperties(definitionFieldSet: DescriptionTemplateFieldSet, item: DescriptionPropertyDefinition): DescriptionPropertyDefinitionFieldSetEditorModel {
2024-02-02 09:29:38 +01:00
if (definitionFieldSet == null) return null;
// current saved values
const fieldSetValue: DescriptionPropertyDefinitionFieldSet = item?.fieldSets[definitionFieldSet.id] ?? {};
// new item case, where we need to add controls for all the containing fields.
if (fieldSetValue.items == null || fieldSetValue.items?.length == 0) {
const fields = new Map<string, DescriptionField>();
definitionFieldSet.fields.forEach(definitionField => {
fields.set(definitionField.id, { value: undefined });
})
fieldSetValue.items = [{
fields: fields
} as DescriptionPropertyDefinitionFieldSetItem]
}
2024-02-02 17:43:24 +01:00
return new DescriptionPropertyDefinitionFieldSetEditorModel().fromModel(fieldSetValue);
2024-02-02 09:29:38 +01:00
}
}
export class DescriptionPropertyDefinitionFieldSetEditorModel implements DescriptionPropertyDefinitionFieldSetPersist {
items?: DescriptionPropertyDefinitionFieldSetItemEditorModel[] = [];
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
public fromModel(item: DescriptionPropertyDefinitionFieldSet): DescriptionPropertyDefinitionFieldSetEditorModel {
2023-12-06 22:10:01 +01:00
if (item) {
2024-02-02 09:29:38 +01:00
if (item.items) { item.items.map(x => this.items.push(new DescriptionPropertyDefinitionFieldSetItemEditorModel().fromModel(x))); }
2023-12-06 22:10:01 +01:00
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
2024-02-02 09:29:38 +01:00
context = DescriptionPropertyDefinitionFieldSetEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
items: this.formBuilder.array(
(this.items ?? []).map(
(item, index) => item.buildForm({
rootPath: `${rootPath}items[${index}].`
})
), context.getValidation('items')
)
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'items', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}items`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
}
export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements DescriptionPropertyDefinitionFieldSetItemPersist {
fields: Map<string, DescriptionFieldEditorModel> = new Map<string, DescriptionFieldEditorModel>;
comment?: string;
ordinal?: number;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
public fromModel(item: DescriptionPropertyDefinitionFieldSetItem): DescriptionPropertyDefinitionFieldSetItemEditorModel {
if (item) {
this.comment = item.comment;
this.ordinal = item.ordinal;
if (item.fields) { item.fields?.forEach((value, key) => this.fields.set(key, new DescriptionFieldEditorModel().fromModel(value))); }
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = DescriptionPropertyDefinitionFieldSetItemEditorModel.createValidationContext({
2023-12-06 22:10:01 +01:00
validationErrorModel: this.validationErrorModel,
rootPath
});
}
2023-12-20 08:20:38 +01:00
const formGroup = this.formBuilder.group({});
2024-02-02 17:43:24 +01:00
formGroup.addControl('comment', new FormControl({ value: 'this.comment', disabled: disabled }, context.getValidation('comment').validators));
formGroup.addControl('ordinal', new FormControl({ value: 5, disabled: disabled }, context.getValidation('ordinal').validators));
2024-02-02 09:29:38 +01:00
const fieldsFormGroup = this.formBuilder.group({});
this.fields.forEach((value, key) => fieldsFormGroup.addControl(key.toString(), value.buildForm({
rootPath: `${rootPath}fields[${key}].`
})), context.getValidation('fields')
2023-12-20 08:20:38 +01:00
)
2024-02-02 09:29:38 +01:00
formGroup.addControl('fields', fieldsFormGroup);
2023-12-20 08:20:38 +01:00
return formGroup;
2023-12-06 22:10:01 +01:00
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'fields', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}fields`)] });
2024-02-02 09:29:38 +01:00
baseValidationArray.push({ key: 'comment', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}comment`)] });
baseValidationArray.push({ key: 'ordinal', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}ordinal`)] });
2023-12-06 22:10:01 +01:00
baseContext.validation = baseValidationArray;
return baseContext;
}
}
export class DescriptionFieldEditorModel implements DescriptionFieldPersist {
value: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
public fromModel(item: DescriptionField): DescriptionFieldEditorModel {
if (item) {
this.value = item.value;
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = DescriptionFieldEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators]
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'value', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}value`)] });
baseContext.validation = baseValidationArray;
return baseContext;
}
}
export class DescriptionReferenceEditorModel implements DescriptionReferencePersist {
id: Guid;
reference?: ReferencePersist;
hash: string;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { }
fromModel(item: DescriptionReference): DescriptionReferenceEditorModel {
this.id = item.id;
this.reference = item.reference;
this.hash = item.hash;
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = DescriptionReferenceEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
return this.formBuilder.group({
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
reference: [{ value: this.reference, disabled: disabled }, context.getValidation('reference').validators],
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
});
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = new ValidationContext();
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] });
baseValidationArray.push({ key: 'reference', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}reference`)] });
baseValidationArray.push({ key: 'hash', validators: [] });
baseContext.validation = baseValidationArray;
return baseContext;
}
}
// export class DescriptionEditorModel {
// public id: string;
// public label: string;
// public profile: DescriptionProfileModel;
// public uri: String;
// public status: number;
// public description: String;
// public services: ExternalServiceEditorModel[] = [];
// public registries: ExternalRegistryEditorModel[] = [];
// public dataRepositories: ExternalDataRepositoryEditorModel[] = [];
// public tags: ExternalTagEditorModel[] = [];
// public externalDescriptions: ExternalDescriptionEditorModel[] = [];
// public dmp: DmpModel;
// public dmpSectionIndex: number;
// public descriptionProfileDefinition: DescriptionDescriptionFormEditorModel;
// public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
// public isProfileLatestVersion: Boolean;
// public modified: Date;
// fromModel(item: DescriptionModel): DescriptionEditorModel {
// this.id = item.id;
// this.label = item.label;
// this.profile = item.profile;
// this.uri = item.uri;
// this.status = item.status;
// this.description = item.description;
// if (item.services) { this.services = item.services.map(x => new ExternalServiceEditorModel().fromModel(x)); }
// if (item.registries) { this.registries = item.registries.map(x => new ExternalRegistryEditorModel().fromModel(x)); }
// if (item.dataRepositories) { this.dataRepositories = item.dataRepositories.map(x => new ExternalDataRepositoryEditorModel().fromModel(x)); }
// if (item.externalDescriptions) { this.externalDescriptions = item.externalDescriptions.map(x => new ExternalDescriptionEditorModel().fromModel(x)); }
// this.dmp = item.dmp;
// this.dmpSectionIndex = item.dmpSectionIndex;
// if (item.descriptionProfileDefinition) { this.descriptionProfileDefinition = new DescriptionDescriptionFormEditorModel().fromModel(item.descriptionProfileDefinition); }
// if (item.tags) { this.tags = item.tags.map(x => new ExternalTagEditorModel().fromModel(x)); }
// this.isProfileLatestVersion = item.isProfileLatestVersion;
// this.modified = new Date(item.modified);
// return this;
// }
// buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup {
// if (context == null) { context = this.createValidationContext(); }
// const formBuilder = new UntypedFormBuilder();
// const formGroup = formBuilder.group({
// id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
// label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
// uri: [{ value: this.uri, disabled: disabled }, context.getValidation('uri').validators],
// status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
// description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
// dmp: [{ value: this.dmp, disabled: disabled }, context.getValidation('dmp').validators],
// dmpSectionIndex: [{ value: this.dmpSectionIndex, disabled: disabled }, context.getValidation('dmpSectionIndex').validators],
// //externalDescriptions: [{ value: this.externalDescriptions, disabled: disabled }, context.getValidation('externalDescriptions').validators],
// tags: [{ value: this.tags, disabled: disabled }, context.getValidation('tags').validators],
// //registries: [{ value: this.registries, disabled: disabled }, context.getValidation('registries').validators],
// //dataRepositories: [{ value: this.dataRepositories, disabled: disabled }, context.getValidation('dataRepositories').validators],
// //services: [{ value: this.services, disabled: disabled }, context.getValidation('services').validators],
// profile: [{ value: this.profile, disabled: disabled }, context.getValidation('profile').validators],
// modified: [{value: this.modified, disabled: disabled}, context.getValidation('modified').validators]
// });
// const externalDescriptionsFormArray = new Array<UntypedFormGroup>();
// //if (this.externalDescriptions && this.externalDescriptions.length > 0) {
// this.externalDescriptions.forEach(item => {
// externalDescriptionsFormArray.push(item.buildForm(context.getValidation('externalDescriptions').descendantValidations, disabled));
// });
// // } else {
// // //externalDescriptionsFormArray.push(new ExternalDescriptionModel().buildForm(context.getValidation('externalDescriptions').descendantValidations, disabled));
// // }
// formGroup.addControl('externalDescriptions', formBuilder.array(externalDescriptionsFormArray));
// // const tagsFormArray = new Array<FormGroup>();
// // if (this.tags && this.tags.length > 0) {
// // this.tags.forEach(item => {
// // tagsFormArray.push(item.buildForm(context.getValidation('tags').descendantValidations, disabled));
// // });
// // } else {
// // //externalDescriptionsFormArray.push(new ExternalDescriptionModel().buildForm(context.getValidation('externalDescriptions').descendantValidations, disabled));
// // }
// // formGroup.addControl('tags', formBuilder.array(tagsFormArray));
// const registriesFormArray = new Array<UntypedFormGroup>();
// //if (this.registries && this.registries.length > 0) {
// this.registries.forEach(item => {
// registriesFormArray.push(item.buildForm(context.getValidation('registries').descendantValidations, disabled));
// });
// // } else {
// // //externalDescriptionsFormArray.push(new ExternalDescriptionModel().buildForm(context.getValidation('externalDescriptions').descendantValidations, disabled));
// // }
// formGroup.addControl('registries', formBuilder.array(registriesFormArray));
// const dataRepositoriesFormArray = new Array<UntypedFormGroup>();
// //if (this.dataRepositories && this.dataRepositories.length > 0) {
// this.dataRepositories.forEach(item => {
// dataRepositoriesFormArray.push(item.buildForm(context.getValidation('dataRepositories').descendantValidations, disabled));
// });
// // } else {
// // //externalDescriptionsFormArray.push(new ExternalDescriptionModel().buildForm(context.getValidation('externalDescriptions').descendantValidations, disabled));
// // }
// formGroup.addControl('dataRepositories', formBuilder.array(dataRepositoriesFormArray));
// const servicesFormArray = new Array<UntypedFormGroup>();
// // if (this.services && this.services.length > 0) {
// this.services.forEach(item => {
// servicesFormArray.push(item.buildForm(context.getValidation('services').descendantValidations, disabled));
// });
// // } else {
// // //externalDescriptionsFormArray.push(new ExternalDescriptionModel().buildForm(context.getValidation('externalDescriptions').descendantValidations, disabled));
// // }
// formGroup.addControl('services', formBuilder.array(servicesFormArray));
// // const tagsFormArray = new Array<FormGroup>();
// // this.tags.forEach(item => {
// // tagsFormArray.push(item.buildForm(context.getValidation('tags').descendantValidations, disabled));
// // });
// // formGroup.addControl('tags', formBuilder.array(tagsFormArray));
// if (this.descriptionProfileDefinition) { formGroup.addControl('descriptionProfileDefinition', this.descriptionProfileDefinition.buildForm()); }
// // formGroup.addControl('profile', this.profile.buildForm());
// return formGroup;
// }
// createValidationContext(): ValidationContext {
// const baseContext: ValidationContext = new ValidationContext();
// baseContext.validation.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
// baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
// baseContext.validation.push({ key: 'profile', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'profile')] });
// baseContext.validation.push({ key: 'uri', validators: [BackendErrorValidator(this.validationErrorModel, 'uri')] });
// baseContext.validation.push({ key: 'status', validators: [BackendErrorValidator(this.validationErrorModel, 'status')] });
// baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] });
// baseContext.validation.push({ key: 'services', validators: [BackendErrorValidator(this.validationErrorModel, 'services')] });
// baseContext.validation.push({ key: 'registries', validators: [BackendErrorValidator(this.validationErrorModel, 'registries')] });
// baseContext.validation.push({ key: 'dataRepositories', validators: [BackendErrorValidator(this.validationErrorModel, 'dataRepositories')] });
// baseContext.validation.push({ key: 'externalDescriptions', validators: [BackendErrorValidator(this.validationErrorModel, 'externalDescriptions')] });
// baseContext.validation.push({ key: 'dmp', validators: [BackendErrorValidator(this.validationErrorModel, 'dmp')] });
// baseContext.validation.push({ key: 'dmpSectionIndex', validators: [BackendErrorValidator(this.validationErrorModel, 'dmpSectionIndex')] });
// baseContext.validation.push({ key: 'descriptionProfileDefinition', validators: [BackendErrorValidator(this.validationErrorModel, 'descriptionProfileDefinition')] });
// baseContext.validation.push({ key: 'tags', validators: [BackendErrorValidator(this.validationErrorModel, 'descriptionProfileDefinition')] });
// baseContext.validation.push({ key: 'modified', validators: []});
// return baseContext;
// }
// }
// export class ExternalTagEditorModel {
// public abbreviation: String;
// public definition: String;
// public id: String;
// public name: String;
// public reference: String;
// public uri: String;
// constructor(id?: String, name?: String) {
// this.id = id;
// this.name = name;
// }
// fromModel(item: TagModel): ExternalTagEditorModel {
// this.id = item.id;
// this.name = item.name;
// return this;
// }
// buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup {
// return new UntypedFormBuilder().group({
// id: [this.id],
// name: [this.name]
// });
// }
// }
// export class ExternalServiceEditorModel {
// public id: String;
// public abbreviation: String;
// public definition: String;
// public uri: String;
// public label: String;
// public reference: String;
// public source: String;
// constructor(abbreviation?: String, definition?: String, id?: String, label?: String, reference?: String, uri?: String, source?: String) {
// this.id = id;
// this.abbreviation = abbreviation;
// this.definition = definition;
// this.uri = uri;
// this.label = label;
// this.reference = reference;
// this.source = source;
// }
// fromModel(item: ServiceModel): ExternalServiceEditorModel {
// this.id = item.id;
// this.abbreviation = item.abbreviation;
// this.definition = item.definition;
// this.uri = item.uri;
// this.label = item.label;
// this.reference = item.reference;
// this.source = item.source;
// return this;
// }
// buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup {
// return new UntypedFormBuilder().group({
// id: [this.id],
// abbreviation: [this.abbreviation],
// label: [this.label, Validators.required],
// reference: [this.reference],
// uri: [this.uri, Validators.required],
// definition: [this.definition],
// source: [this.source]
// });
// }
// }
// export class ExternalRegistryEditorModel {
// public abbreviation: String;
// public definition: String;
// public id: String;
// public label: String;
// public reference: String;
// public uri: String;
// public source: String
// constructor(abbreviation?: String, definition?: String, id?: String, label?: String, reference?: String, uri?: String, source?: String) {
// this.abbreviation = abbreviation;
// this.definition = definition;
// this.id = id;
// this.label = label;
// this.reference = reference;
// this.uri = uri;
// this.source = source;
// }
// fromModel(item: RegistryModel): ExternalRegistryEditorModel {
// this.abbreviation = item.abbreviation;
// this.definition = item.definition;
// this.id = item.id;
// this.label = item.label;
// this.reference = item.pid ? item.pid : item.reference;
// this.uri = item.uri;
// this.source = item.source
// return this;
// }
// buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup {
// return new UntypedFormBuilder().group({
// id: [this.id],
// abbreviation: [this.abbreviation],
// label: [this.label, Validators.required],
// reference: [this.reference],
// uri: [this.uri, Validators.required],
// definition: [this.definition],
// source: [this.source]
// });
// }
// }
// export class ExternalDescriptionEditorModel {
// public abbreviation: String;
// public id: String;
// public name: String;
// public reference: String;
// public type: ExternalDescriptionType;
// public info: String;
// public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
// public source: String;
// constructor(id?: string, abbreviation?: string, name?: string, reference?: string, source?: String, info?: string, type?: ExternalDescriptionType) {
// this.id = id;
// this.name = name;
// this.abbreviation = abbreviation;
// this.reference = reference;
// this.info = info;
// this.type = type;
// this.source = source;
// }
// fromModel(item: ExternalDescriptionModel): ExternalDescriptionEditorModel {
// this.abbreviation = item.abbreviation;
// this.id = item.id;
// this.name = item.name;
// this.reference = item.reference;
// this.type = item.type;
// this.info = item.info;
// this.source = item.source;
// return this;
// }
// buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup {
// return new UntypedFormBuilder().group({
// id: [this.id],
// abbreviation: [this.abbreviation],
// name: [this.name, Validators.required],
// reference: [this.reference],
// type: [this.type],
// info: [this.info],
// source: [this.source]
// });
// }
// }
// export class ExternalDataRepositoryEditorModel {
// public id: string;
// public name: string;
// public abbreviation: string;
// public uri: string;
// public reference: string;
// public info: string;
// public created: Date;
// public modified: Date;
// public source: string;
// constructor(id?: string, name?: string, abbreviation?: string, uri?: string, reference?: string, source?: string) {
// this.id = id;
// this.name = name;
// this.abbreviation = abbreviation;
// this.uri = uri;
// this.reference = reference;
// this.source = source;
// }
// fromModel(item: DataRepositoryModel): ExternalDataRepositoryEditorModel {
// this.id = item.id;
// this.name = item.name;
// this.abbreviation = item.abbreviation;
// this.uri = item.uri;
// this.info = item.info;
// this.reference = item.pid;
// this.source = item.source;
// return this;
// }
// buildForm(context: ValidationContext = null, disabled: boolean = false): UntypedFormGroup {
// return new UntypedFormBuilder().group({
// id: [this.id],
// name: [this.name, [Validators.required]],
// abbreviation: [this.abbreviation],
// uri: [this.uri, [Validators.required]],
// info: [this.info],
// reference: [this.reference],
// source: [this.source]
// });
// }
// }
// // export class TagModel implements Serializable<TagModel> {
// // public id: string;
// // public name: string;
// // constructor(id?: string, name?: string) {
// // this.id = id;
// // this.name = name;
// // }
// // fromJSONObject(item: any): TagModel {
// // this.id = item.id;
// // this.name = item.name;
// // return this;
// // }
// // buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
// // return new FormBuilder().group({
// // id: [this.id],
// // name: [this.name]
// // });
// // }
// // }