extend MetaDataColumn by adding column for name of column for referenced tables

This commit is contained in:
Thomas Peetz
2025-01-12 02:41:40 +01:00
parent a3652cc9b8
commit bf14c9a020
11 changed files with 203 additions and 25 deletions
@@ -179,7 +179,7 @@ public class SetupModuleAdmin implements ApplicationListener<ContextRefreshedEve
metaDataService.getColumn(comicTable, "completed", "completed", "BOOLEAN", null, 5, Boolean.TRUE, "Complete", Boolean.TRUE, "Complete");
metaDataService.getColumn(comicTable, "current_order", "current_order", "BOOLEAN", null, 6, Boolean.TRUE, "Bestellung", Boolean.TRUE, "Bestellung");
metaDataService.getColumn(comicTable, "title", "title", "TEXT", "UNIQUE", 7, Boolean.TRUE, "Title", Boolean.FALSE, null);
metaDataService.getColumn(comicTable, "publisher_id", "publisher_id", "TEXT", null, 8, Boolean.TRUE, "Verlag", Boolean.FALSE, null);
metaDataService.getColumn(comicTable, "publisher_id", "publisher_id", "TEXT", null, 8, Boolean.TRUE, "Verlag", Boolean.FALSE, null, "name");
MetaDataTable issueTable = metaDataService.getTable("issue");
metaDataService.getColumn(issueTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
@@ -188,7 +188,7 @@ public class SetupModuleAdmin implements ApplicationListener<ContextRefreshedEve
metaDataService.getColumn(issueTable, "in_stock", "in_stock", "BOOLEAN", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "is_read", "is_read", "BOOLEAN", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "issue_number", "issue_number", "TEXT", null, 7, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "comic_id", "comic_id", "TEXT", null, 8, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "comic_id", "comic_id", "TEXT", null, 8, Boolean.FALSE, "", Boolean.FALSE, null, "title");
metaDataService.getColumn(issueTable, "volume_id", "volume_id", "TEXT", null, 9, Boolean.FALSE, "", Boolean.FALSE, null);
MetaDataTable volumeTable = metaDataService.getTable("volume");
metaDataService.getColumn(volumeTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
@@ -205,7 +205,7 @@ public class SetupModuleAdmin implements ApplicationListener<ContextRefreshedEve
metaDataService.getColumn(tpbTable, "issue_start", "issue_start", "LONG", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "issue_end", "issue_end", "LONG", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "name", "name", "TEXT", null, 7, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "comic_id", "comic_id", "TEXT", null, 8, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "comic_id", "comic_id", "TEXT", null, 8, Boolean.FALSE, "", Boolean.FALSE, null, "title");
MetaDataTable storyArcTable = metaDataService.getTable("story_arc");
metaDataService.getColumn(storyArcTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(storyArcTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
@@ -36,6 +36,8 @@ public class MetaDataColumn extends AbstractEntity {
private String filterLabel;
private String refColumn;
@ManyToOne
@JoinColumn(name = "table_id")
@NotNull
@@ -35,6 +35,10 @@ public class MetaDataService {
}
public void getColumn(MetaDataTable table, String columnName, String columnSyncName, String columnType, String columnModifier, Integer columnOrder, Boolean isShown, String columnLabel, Boolean showFilter, String filterLabel) {
this.getColumn(table, columnName, columnSyncName, columnType, columnModifier, columnOrder, isShown, columnLabel, showFilter, filterLabel, null);
}
public void getColumn(MetaDataTable table, String columnName, String columnSyncName, String columnType, String columnModifier, Integer columnOrder, Boolean isShown, String columnLabel, Boolean showFilter, String filterLabel, String refColumn) {
if (table.getTableColumns().stream().anyMatch(column -> column.getColumnName().equals(columnName))) {
log.debug("Column {} with name {} of table {} found, check Values", columnOrder, columnName, table.getTableName());
MetaDataColumn column = table.getTableColumns().get(columnOrder.intValue()-1);
@@ -70,6 +74,10 @@ public class MetaDataService {
log.debug("filterLabel has to be change to {}}", filterLabel);
column.setFilterLabel(filterLabel);
}
if (refColumn != null && !refColumn.equals(column.getRefColumn())) {
log.debug("refColumn has to be change to {}}", filterLabel);
column.setRefColumn(refColumn);
}
metaDataColumnRepository.save(column);
} else {
log.info("Column {} of table {} not found, will create it", columnName, table.getTableName());
@@ -85,6 +93,7 @@ public class MetaDataService {
}
}
public List<MetaDataColumn> findAllMetaDataColumns(String stringFilter) {
if (stringFilter == null || stringFilter.isEmpty()) {
log.debug("Found " + metaDataColumnRepository.count()+ " entries");
@@ -29,6 +29,7 @@ public class MetaDataForm extends FormLayout {
TextField columnLabel = new TextField("Column Label");
Checkbox showFilter = new Checkbox("Show Filter");
TextField filterLabel = new TextField("Filter Label");
TextField refColumn = new TextField("Ref Column");
Button save = new com.vaadin.flow.component.button.Button("Save");
Button delete = new com.vaadin.flow.component.button.Button("Delete");
@@ -47,6 +48,7 @@ public class MetaDataForm extends FormLayout {
isShown.addClickListener(click -> columnLabel.setEnabled(isShown.getValue()));
add(showFilter, filterLabel);
showFilter.addClickListener(click -> filterLabel.setEnabled(showFilter.getValue()));
add(refColumn);
add(createButtonsLayout());
}
@@ -66,6 +66,8 @@ public class MetaDataView extends VerticalLayout {
setHeader("Zeige Filter").setWidth("6rem").setSortable(true);
Grid.Column<MetaDataColumn> filterLabelColumn = grid.addColumn(MetaDataColumn::getFilterLabel)
.setHeader("Filter Name").setResizable(true).setSortable(true);
Grid.Column<MetaDataColumn> refColumnColumn = grid.addColumn(MetaDataColumn::getRefColumn)
.setHeader("Ref Column Name").setResizable(true).setSortable(true);
TextField searchField = new TextField();
@Getter
MetaDataForm form;
@@ -186,7 +188,7 @@ public class MetaDataView extends VerticalLayout {
columnToggleContextMenu.addColumnToggleItem(columnLabelColumn.getHeaderText(), columnLabelColumn);
columnToggleContextMenu.addColumnToggleItem(showFilterColumn.getHeaderText(), showFilterColumn);
columnToggleContextMenu.addColumnToggleItem(filterLabelColumn.getHeaderText(), filterLabelColumn);
columnToggleContextMenu.addColumnToggleItem(refColumnColumn.getHeaderText(), refColumnColumn);
HorizontalLayout toolbar = new HorizontalLayout(searchField, addMetaDataButton, menuButton);
toolbar.addClassName("toolbar");
return toolbar;