add enable prefilling property in description templates

This commit is contained in:
Bernaldo Mihasi 2023-10-06 09:36:35 +03:00
parent 10d0f1fb0e
commit c238615b50
20 changed files with 85 additions and 1 deletions

View File

@ -21,6 +21,7 @@ public class AdminManager {
public static DescriptionTemplate generateViewStyleDefinition(DatasetProfile profile, ApiContext apiContext) throws Exception {
ViewStyleModel viewStyleModel = new ViewStyleModel();
viewStyleModel.setEnablePrefilling(profile.isEnablePrefilling());
viewStyleModel.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section.class));
viewStyleModel.setPages(new ModelBuilder().toViewStyleDefinition(profile.getPages(), eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Page.class));
Document viewStyleDoc = XmlBuilder.getDocument();

View File

@ -37,6 +37,7 @@ public class ExportXmlBuilderDatasetProfile {
pages.setAttribute("description", datasetProfile.getDescription());
pages.setAttribute("language", datasetProfile.getLanguage());
pages.setAttribute("type", datasetProfile.getType());
pages.setAttribute("enablePrefilling", String.valueOf(datasetProfile.isEnablePrefilling()));
String xml = XmlBuilder.generateXml(xmlDoc);
writer.write(xml);
writer.close();

View File

@ -15,6 +15,7 @@ public class DatasetProfile {
private String description;
private String language;
private String type;
private boolean enablePrefilling;
private List<Page> page;
@ -54,6 +55,15 @@ public class DatasetProfile {
this.type = type;
}
@XmlAttribute(name = "enablePrefilling")
public boolean isEnablePrefilling() {
return enablePrefilling;
}
public void setEnablePrefilling(boolean enablePrefilling) {
this.enablePrefilling = enablePrefilling;
}
public eu.eudat.models.data.admin.composite.DatasetProfile toAdminCompositeModel(String label){
eu.eudat.models.data.admin.composite.DatasetProfile newDatasetEntityProfile = new eu.eudat.models.data.admin.composite.DatasetProfile();
newDatasetEntityProfile.setLabel(label);
@ -61,6 +71,7 @@ public class DatasetProfile {
newDatasetEntityProfile.setDescription(description);
newDatasetEntityProfile.setLanguage(language);
newDatasetEntityProfile.setType(type);
newDatasetEntityProfile.setEnablePrefilling(enablePrefilling);
List<eu.eudat.models.data.admin.components.datasetprofile.Page> pagesDatasetEntity = new LinkedList<>();
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionDatasetEntity = new LinkedList<>();
for (Page xmlPage: page) {

View File

@ -14,6 +14,7 @@ public class DatasetProfile {
private String label;
private String description;
private String type;
private boolean enablePrefilling;
private List<Page> pages;
private List<Section> sections;
private Short status;
@ -43,6 +44,13 @@ public class DatasetProfile {
this.type = type;
}
public boolean isEnablePrefilling() {
return enablePrefilling;
}
public void setEnablePrefilling(boolean enablePrefilling) {
this.enablePrefilling = enablePrefilling;
}
public List<Page> getPages() {
return pages;
}
@ -80,6 +88,7 @@ public class DatasetProfile {
}
public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) {
this.enablePrefilling = viewStyle.isEnablePrefilling();
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
}
@ -89,6 +98,7 @@ public class DatasetProfile {
shortProfile.setLabel(this.label);
shortProfile.setDescription(this.description);
shortProfile.setType(this.type);
shortProfile.setEnablePrefilling(this.enablePrefilling);
List<Section> shortSection = new LinkedList<>();
for (Section toshortSection : this.getSections()) {
shortSection.add(toshortSection.toShort());

View File

@ -11,9 +11,18 @@ import java.util.LinkedList;
import java.util.List;
public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
private boolean enablePrefilling;
private List<Section> sections;
private List<Page> pages;
public boolean isEnablePrefilling() {
return enablePrefilling;
}
public void setEnablePrefilling(boolean enablePrefilling) {
this.enablePrefilling = enablePrefilling;
}
public List<Section> getSections() {
return sections;
}
@ -33,6 +42,8 @@ public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("root");
Element prefilling = doc.createElement("enablePrefilling");
prefilling.setTextContent(String.valueOf(this.enablePrefilling));
Element sections = doc.createElement("sections");
Element pages = doc.createElement("pages");
for (Section section : this.sections) {
@ -44,6 +55,7 @@ public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
pages.appendChild(page.toXml(doc));
}
root.appendChild(prefilling);
root.appendChild(pages);
root.appendChild(sections);
return root;
@ -52,6 +64,12 @@ public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
@Override
public ViewStyleModel fromXml(Element element) {
this.enablePrefilling = true;
Element prefilling = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "enablePrefilling");
if (prefilling != null) {
this.enablePrefilling = Boolean.parseBoolean(prefilling.getChildNodes().item(0).getNodeValue());
}
this.sections = new LinkedList();
Element sections = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "sections");
if (sections != null) {

View File

@ -13,6 +13,7 @@ public class DatasetProfile implements PropertiesModelBuilder {
private String description;
private String language;
private String type;
private boolean enablePrefilling;
private List<Section> sections;
private List<Rule> rules;
private List<Page> pages;
@ -42,6 +43,14 @@ public class DatasetProfile implements PropertiesModelBuilder {
this.type = type;
}
public boolean isEnablePrefilling() {
return enablePrefilling;
}
public void setEnablePrefilling(boolean enablePrefilling) {
this.enablePrefilling = enablePrefilling;
}
public List<Section> getSections() {
return sections;
}
@ -76,6 +85,7 @@ public class DatasetProfile implements PropertiesModelBuilder {
}
public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) {
this.enablePrefilling = viewStyle.isEnablePrefilling();
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
this.rules = ModelBuilderCollector.collectRules(viewStyle.getSections());

View File

@ -4,6 +4,7 @@ import { UserInfoListingModel } from "../../user/user-info-listing";
export interface DatasetProfile {
label: string;
type: string;
enablePrefilling: boolean;
sections: Section[];
pages: Page[];
status: number;

View File

@ -16,6 +16,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
public version: number;
private description: string;
private type: string;
public enablePrefilling: boolean;
private language: string;
private users: UserInfoListingModel[] = [];
@ -24,6 +25,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
if (item.pages) { this.pages = item.pages.map(x => new PageEditorModel().fromModel(x)); }
this.label = item.label;
this.type = item.type;
this.enablePrefilling = item.enablePrefilling;
this.status = item.status;
this.version = item.version;
this.description = item.description;
@ -37,6 +39,7 @@ export class DatasetProfileEditorModel extends BaseFormModel {
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.label')) }, [Validators.required]],
description: [{ value: this.description, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.description')) }, [Validators.required]],
type: [{ value: this.type, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.type')) }, [Validators.required]],
enablePrefilling: [{ value: this.enablePrefilling, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.enablePrefilling')) }, []],
language: [{ value: this.language, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.language')) }, [Validators.required]],
status: [{ value: this.status, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.status')) }],
version: [{ value: this.version, disabled: (disabled && !skipDisable.includes('DatasetProfileEditorModel.version')) }],

View File

@ -170,7 +170,15 @@
</mat-form-field>
</div>
<div class="col-12">
<div class="heading">1.5 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}</div>
<div class="heading">1.5 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-PREFILLING'| translate}}</div>
<div class="full-width basic-info-input">
<mat-checkbox [formControl]="form.get('enablePrefilling')">
{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-ENABLE-PREFILLING'| translate}}
</mat-checkbox>
</div>
</div>
<div class="col-12">
<div class="heading">1.6 {{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS'| translate}}</div>
<div class="hint">{{'DATASET-PROFILE-EDITOR.STEPS.GENERAL-INFO.DATASET-TEMPLATE-USERS-HINT'| translate}}</div>
<div class="full-width basic-info-input">
<table class="col-12 user-table">

View File

@ -214,6 +214,7 @@ export class DatasetProfileEditorComponent extends CheckDeactivateBaseComponent
);
} else {
this.dataModel = new DatasetProfileEditorModel();
this.dataModel.enablePrefilling = true;
this.form = this.dataModel.buildForm();
// this.form.setValidators([EditorCustomValidators.atLeastOneElementListValidator('pages'), EditorCustomValidators.pagesHaveAtLeastOneSection('pages', 'sections')]);

View File

@ -310,6 +310,8 @@
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DESCRIPTION-TEMPLATE-PREFILLING": "Prefilling",
"DESCRIPTION-TEMPLATE-ENABLE-PREFILLING": "Enable prefilling",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",

View File

@ -310,6 +310,8 @@
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DESCRIPTION-TEMPLATE-PREFILLING": "Prefilling",
"DESCRIPTION-TEMPLATE-ENABLE-PREFILLING": "Enable prefilling",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",

View File

@ -310,6 +310,8 @@
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Seleccione un idioma",
"DESCRIPTION-TEMPLATE-PREFILLING": "Prefilling",
"DESCRIPTION-TEMPLATE-ENABLE-PREFILLING": "Enable prefilling",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",

View File

@ -310,6 +310,8 @@
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DESCRIPTION-TEMPLATE-PREFILLING": "Prefilling",
"DESCRIPTION-TEMPLATE-ENABLE-PREFILLING": "Enable prefilling",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",

View File

@ -310,6 +310,8 @@
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Izaberi jezik predloška",
"DESCRIPTION-TEMPLATE-PREFILLING": "Prefilling",
"DESCRIPTION-TEMPLATE-ENABLE-PREFILLING": "Enable prefilling",
"DATASET-TEMPLATE-USERS": "Korisnici predloška",
"DATASET-TEMPLATE-USERS-HINT": "Kako biste obavijestili korisnike, dodajte korisnike i spremite promjene.",
"DATASET-TEMPLATE-REMOVE-USER": "Izbriši korisnika",

View File

@ -310,6 +310,8 @@
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Wybierz język",
"DESCRIPTION-TEMPLATE-PREFILLING": "Prefilling",
"DESCRIPTION-TEMPLATE-ENABLE-PREFILLING": "Enable prefilling",
"DATASET-TEMPLATE-USERS": "Redaktorzy",
"DATASET-TEMPLATE-USERS-HINT": "Dodaj redaktorów i zapisz zmiany, aby ich powiadomić.",
"DATASET-TEMPLATE-REMOVE-USER": "Usuń redaktora",

View File

@ -310,6 +310,8 @@
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Selecione o idioma",
"DESCRIPTION-TEMPLATE-PREFILLING": "Prefilling",
"DESCRIPTION-TEMPLATE-ENABLE-PREFILLING": "Enable prefilling",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",

View File

@ -310,6 +310,8 @@
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DESCRIPTION-TEMPLATE-PREFILLING": "Prefilling",
"DESCRIPTION-TEMPLATE-ENABLE-PREFILLING": "Enable prefilling",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",

View File

@ -310,6 +310,8 @@
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DESCRIPTION-TEMPLATE-PREFILLING": "Prefilling",
"DESCRIPTION-TEMPLATE-ENABLE-PREFILLING": "Enable prefilling",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",

View File

@ -310,6 +310,8 @@
"DESCRIPTION-TEMPLATE-SELECT-TYPE": "Select a type",
"DATASET-TEMPLATE-LANGUAGE": "Description template language",
"DATASET-TEMPLATE-SELECT-LANGUAGE": "Select a language",
"DESCRIPTION-TEMPLATE-PREFILLING": "Prefilling",
"DESCRIPTION-TEMPLATE-ENABLE-PREFILLING": "Enable prefilling",
"DATASET-TEMPLATE-USERS": "Editors",
"DATASET-TEMPLATE-USERS-HINT": "Add editors and save changes to notify them.",
"DATASET-TEMPLATE-REMOVE-USER": "Remove Editor",