remove MetaDataTable and MetaDataColumn to cleanup schema

This commit is contained in:
Thomas Peetz
2025-05-23 18:21:41 +02:00
parent 8cfb60f9a1
commit 456162da44
34 changed files with 536 additions and 1354 deletions
@@ -49,7 +49,6 @@ public class AdminConstants {
data.addItem(new SideNavItem(MediaConstants.MEDIAACTORFILE, MediaActorFileView.class));
data.addItem(new SideNavItem(AUTHORIZATION, AssignmentView.class));
data.addItem(new SideNavItem("Data Import", ModuleDataView.class));
data.addItem(new SideNavItem("Meta Data", MetaDataView.class));
administration.addItem(data);
return administration;
}
@@ -3,13 +3,10 @@ package de.thpeetz.kontor.admin;
import de.thpeetz.kontor.admin.data.Permission;
import de.thpeetz.kontor.admin.data.Profile;
import de.thpeetz.kontor.admin.data.Assignment;
import de.thpeetz.kontor.admin.data.MetaDataTable;
import de.thpeetz.kontor.admin.repository.AssignmentRepository;
import de.thpeetz.kontor.admin.repository.ProfileRepository;
import de.thpeetz.kontor.admin.repository.MailAccountRepository;
import de.thpeetz.kontor.admin.services.AdminService;
import de.thpeetz.kontor.admin.services.MetaDataService;
import de.thpeetz.kontor.mailclient.data.MailAccount;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -44,9 +41,6 @@ public class SetupModuleAdmin implements ApplicationListener<ContextRefreshedEve
@Autowired
private AdminService adminService;
@Autowired
private MetaDataService metaDataService;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (alreadySetup) {
@@ -64,8 +58,6 @@ public class SetupModuleAdmin implements ApplicationListener<ContextRefreshedEve
}
log.info("MailProperties: {}", mailProperties);
initMail(mailProperties);
initMetaData();
}
private void initMail(MailProperties mailProperties) {
@@ -131,315 +123,4 @@ public class SetupModuleAdmin implements ApplicationListener<ContextRefreshedEve
}
return admin;
}
private void initMetaData() {
log.info("initMetaData");
MetaDataTable mediaArticleTable = metaDataService.getTable("media_article");
metaDataService.getColumn(mediaArticleTable, "id", "TEXT", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(mediaArticleTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(mediaArticleTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(mediaArticleTable, "version", "LONG", 4, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(mediaArticleTable, "url", "TEXT", 5, Boolean.TRUE, "URL", Boolean.FALSE, null);
metaDataService.getColumn(mediaArticleTable, "review", "BOOLEAN", 6, Boolean.TRUE, "Review", Boolean.TRUE, "Review");
metaDataService.getColumn(mediaArticleTable, "title", "TEXT", 7, Boolean.TRUE, "Title", Boolean.FALSE, null);
MetaDataTable mediaVideoTable = metaDataService.getTable("media_video");
metaDataService.getColumn(mediaVideoTable, "id", "TEXT", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(mediaVideoTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(mediaVideoTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(mediaVideoTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(mediaVideoTable, "url", "TEXT", 5, Boolean.TRUE, "URL", Boolean.FALSE, null);
metaDataService.getColumn(mediaVideoTable, "review", "BOOLEAN", 6, Boolean.TRUE, "Review", Boolean.TRUE, "Review");
metaDataService.getColumn(mediaVideoTable, "should_download", "BOOLEAN", 7, Boolean.TRUE, "Download", Boolean.TRUE, "Download");
metaDataService.getColumn(mediaVideoTable, "title", "TEXT", 8, Boolean.TRUE, "Title", Boolean.FALSE, null);
metaDataService.getColumn(mediaVideoTable, "file_name", "TEXT", 9, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(mediaVideoTable, "path", "TEXT", 10, Boolean.FALSE, "", Boolean.FALSE, null);
metaDataService.getColumn(mediaVideoTable, "cloud_link", "TEXT", 11, Boolean.FALSE, "", Boolean.FALSE, null);
MetaDataTable mediaFileTable = metaDataService.getTable("media_file");
metaDataService.getColumn(mediaFileTable, "id", "TEXT", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(mediaFileTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(mediaFileTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(mediaFileTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(mediaFileTable, "url", "TEXT" , 5, Boolean.TRUE, "URL", Boolean.FALSE, null);
metaDataService.getColumn(mediaFileTable, "review", "BOOLEAN" , 6, Boolean.TRUE, "Review", Boolean.TRUE, "Review");
metaDataService.getColumn(mediaFileTable, "should_download", "BOOLEAN" , 7, Boolean.TRUE, "Download", Boolean.TRUE, "Download");
metaDataService.getColumn(mediaFileTable, "title", "TEXT" , 8, Boolean.TRUE, "Title", Boolean.FALSE, null);
metaDataService.getColumn(mediaFileTable, "file_name", "TEXT" , 9, Boolean.TRUE, "Dateiname", Boolean.FALSE, null);
metaDataService.getColumn(mediaFileTable, "path", "TEXT" , 10, Boolean.TRUE, "Verzeichnis", Boolean.FALSE, null);
metaDataService.getColumn(mediaFileTable, "cloud_link", "TEXT" , 11, Boolean.TRUE, "Cloud Link", Boolean.FALSE, null);
MetaDataTable mediaActorTable = metaDataService.getTable("media_actor");
metaDataService.getColumn(mediaActorTable, "id", "TEXT" , 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(mediaActorTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(mediaActorTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(mediaActorTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(mediaActorTable, "name", "TEXT" , 5, Boolean.TRUE, "", Boolean.FALSE, null);
MetaDataTable mediaActorFileTable = metaDataService.getTable("media_actor_file");
metaDataService.getColumn(mediaActorFileTable, "id", "TEXT" , 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(mediaActorFileTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(mediaActorFileTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(mediaActorFileTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(mediaActorFileTable, "media_actor_id", "TEXT" , 5, Boolean.TRUE, "Actor", Boolean.FALSE, null, "name");
metaDataService.getColumn(mediaActorFileTable, "media_file_id", "TEXT" , 6, Boolean.TRUE, "File", Boolean.FALSE, null, "title");
MetaDataTable artistTable = metaDataService.getTable("artist");
metaDataService.getColumn(artistTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(artistTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(artistTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(artistTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(artistTable, "name", "TEXT" , 5, Boolean.FALSE, "Name", Boolean.FALSE, null);
metaDataService.getColumn(artistTable, "weblink", "TEXT" , 6, Boolean.TRUE, "Link", Boolean.FALSE, null);
MetaDataTable publisherTable = metaDataService.getTable("publisher");
metaDataService.getColumn(publisherTable, "id", "TEXT" , 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(publisherTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(publisherTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(publisherTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(publisherTable, "name", "TEXT" , 5, Boolean.TRUE, "Name", Boolean.FALSE, null);
metaDataService.getColumn(publisherTable, "weblink", "TEXT" , 6, Boolean.TRUE, "Link", Boolean.FALSE, null);
metaDataService.getColumn(publisherTable, "parent_publisher_id", "TEXT" , 7, Boolean.TRUE, "Parent Company", Boolean.FALSE, null, "name");
MetaDataTable comicTable = metaDataService.getTable("comic");
metaDataService.getColumn(comicTable, "id", "TEXT" , 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(comicTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(comicTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(comicTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(comicTable, "completed", "BOOLEAN" , 5, Boolean.TRUE, "Complete", Boolean.TRUE, "Complete");
metaDataService.getColumn(comicTable, "current_order", "BOOLEAN" , 6, Boolean.TRUE, "Bestellung", Boolean.TRUE, "Bestellung");
metaDataService.getColumn(comicTable, "title", "TEXT" , 7, Boolean.TRUE, "Title", Boolean.FALSE, null);
metaDataService.getColumn(comicTable, "publisher_id", "TEXT" , 8, Boolean.TRUE, "Verlag", Boolean.FALSE, null, "name");
metaDataService.getColumn(comicTable, "weblink", "TEXT" , 9, Boolean.TRUE, "Link", Boolean.FALSE, null);
MetaDataTable issueTable = metaDataService.getTable("issue");
metaDataService.getColumn(issueTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "in_stock", "BOOLEAN" , 5, Boolean.FALSE, "Auf Lager", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "is_read", "BOOLEAN" , 6, Boolean.FALSE, "Gelesen", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "issue_number", "TEXT" , 7, Boolean.FALSE, "Heft", Boolean.FALSE, null);
metaDataService.getColumn(issueTable, "comic_id", "TEXT" , 8, Boolean.FALSE, "Comic", Boolean.FALSE, null, "title");
metaDataService.getColumn(issueTable, "volume_id", "TEXT" , 9, Boolean.FALSE, "Volume", Boolean.FALSE, null, "name");
metaDataService.getColumn(issueTable, "story_arc_id", "TEXT" , 10, Boolean.FALSE, "Story Arc", Boolean.FALSE, null, "name");
MetaDataTable volumeTable = metaDataService.getTable("volume");
metaDataService.getColumn(volumeTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(volumeTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(volumeTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(volumeTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(volumeTable, "name", "TEXT" , 5, Boolean.FALSE, "Name", Boolean.FALSE, null);
metaDataService.getColumn(volumeTable, "comic_id", "TEXT" , 6, Boolean.FALSE, "Comic", Boolean.FALSE, null, "title");
MetaDataTable tpbTable = metaDataService.getTable("trade_paperback");
metaDataService.getColumn(tpbTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "issue_start", "LONG" , 5, Boolean.FALSE, "Anfang", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "issue_end", "LONG" , 6, Boolean.FALSE, "Ende", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "name", "TEXT" , 7, Boolean.FALSE, "Name", Boolean.FALSE, null);
metaDataService.getColumn(tpbTable, "comic_id", "TEXT" , 8, Boolean.FALSE, "Comic", Boolean.FALSE, null, "title");
MetaDataTable storyArcTable = metaDataService.getTable("story_arc");
metaDataService.getColumn(storyArcTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(storyArcTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(storyArcTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(storyArcTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(storyArcTable, "name", "TEXT" , 5, Boolean.FALSE, "Name", Boolean.FALSE, null);
metaDataService.getColumn(storyArcTable, "comic_id", "TEXT" , 6, Boolean.FALSE, "Comic", Boolean.FALSE, null, "title");
metaDataService.getColumn(storyArcTable, "volume_id", "TEXT" , 7, Boolean.FALSE, "Volume", Boolean.FALSE, null, "name");
MetaDataTable worktypeTable = metaDataService.getTable("worktype");
metaDataService.getColumn(worktypeTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(worktypeTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(worktypeTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(worktypeTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(worktypeTable, "name", "TEXT" , 5, Boolean.FALSE, "Name", Boolean.FALSE, null);
MetaDataTable comicworkTable = metaDataService.getTable("comic_work");
metaDataService.getColumn(comicworkTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(comicworkTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(comicworkTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(comicworkTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(comicworkTable, "artist_id", "TEXT" , 5, Boolean.FALSE, "Artist", Boolean.FALSE, null, "name");
metaDataService.getColumn(comicworkTable, "comic_id", "TEXT" , 6, Boolean.FALSE, "Comic", Boolean.FALSE, null, "title");
metaDataService.getColumn(comicworkTable, "work_type_id", "TEXT" , 7, Boolean.FALSE, "Arbeit", Boolean.FALSE, null, "name");
MetaDataTable authorTable = metaDataService.getTable("author");
metaDataService.getColumn(authorTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(authorTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(authorTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(authorTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(authorTable, "first_name", "TEXT" , 5, Boolean.FALSE, "Vorname", Boolean.FALSE, null);
metaDataService.getColumn(authorTable, "last_name", "TEXT" , 6, Boolean.FALSE, "Nachname", Boolean.FALSE, null);
MetaDataTable articleTable = metaDataService.getTable("article");
metaDataService.getColumn(articleTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(articleTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(articleTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(articleTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(articleTable, "title", "TEXT" , 5, Boolean.FALSE, "Titel", Boolean.FALSE, null);
MetaDataTable articleAuthorTable = metaDataService.getTable("article_author");
metaDataService.getColumn(articleAuthorTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(articleAuthorTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(articleAuthorTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(articleAuthorTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(articleAuthorTable, "article_id", "TEXT" , 5, Boolean.FALSE, "Artikel", Boolean.FALSE, null, "title");
metaDataService.getColumn(articleAuthorTable, "author_id", "TEXT" , 6, Boolean.FALSE, "Autor", Boolean.FALSE, null, "name");
MetaDataTable bookTable = metaDataService.getTable("book");
metaDataService.getColumn(bookTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(bookTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(bookTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(bookTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(bookTable, "isbn", "TEXT" , 5, Boolean.FALSE, "ISBN", Boolean.FALSE, null);
metaDataService.getColumn(bookTable, "title", "TEXT" , 6, Boolean.FALSE, "Titel", Boolean.FALSE, null);
metaDataService.getColumn(bookTable, "year", "LONG" , 7, Boolean.FALSE, "Jahr", Boolean.FALSE, null);
metaDataService.getColumn(bookTable, "publisher_id", "TEXT" , 8, Boolean.FALSE, "Verlag", Boolean.FALSE, null, "name");
MetaDataTable bookAuthorTable = metaDataService.getTable("book_author");
metaDataService.getColumn(bookAuthorTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(bookAuthorTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(bookAuthorTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(bookAuthorTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(bookAuthorTable, "author_id", "TEXT" , 5, Boolean.FALSE, "Autor", Boolean.FALSE, null, "name");
metaDataService.getColumn(bookAuthorTable, "book_id", "TEXT" , 6, Boolean.FALSE, "Buch", Boolean.FALSE, null, "title");
MetaDataTable bookshelfPublisherTable = metaDataService.getTable("bookshelf_publisher");
metaDataService.getColumn(bookshelfPublisherTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(bookshelfPublisherTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(bookshelfPublisherTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(bookshelfPublisherTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(bookshelfPublisherTable, "name", "TEXT" , 5, Boolean.FALSE, "Name", Boolean.FALSE, null);
MetaDataTable sportTable = metaDataService.getTable("sport");
metaDataService.getColumn(sportTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(sportTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(sportTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(sportTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(sportTable, "name", "TEXT" , 5, Boolean.FALSE, "Name", Boolean.FALSE, null);
MetaDataTable playerTable = metaDataService.getTable("player");
metaDataService.getColumn(playerTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(playerTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(playerTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(playerTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(playerTable, "first_name", "TEXT" , 5, Boolean.FALSE, "Vorname", Boolean.FALSE, null);
metaDataService.getColumn(playerTable, "last_name", "TEXT" , 6, Boolean.FALSE, "Nachname", Boolean.FALSE, null);
MetaDataTable teamTable = metaDataService.getTable("team");
metaDataService.getColumn(teamTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(teamTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(teamTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(teamTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(teamTable, "name", "TEXT" , 5, Boolean.FALSE, "Name", Boolean.FALSE, null);
metaDataService.getColumn(teamTable, "short_name", "TEXT" , 6, Boolean.FALSE, "Kurzname", Boolean.FALSE, null);
metaDataService.getColumn(teamTable, "sport_id", "TEXT" , 7, Boolean.FALSE, "Sport", Boolean.FALSE, null, "name");
MetaDataTable vendorTable = metaDataService.getTable("vendor");
metaDataService.getColumn(vendorTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(vendorTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(vendorTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(vendorTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(vendorTable, "name", "TEXT" , 5, Boolean.FALSE, "Name", Boolean.FALSE, null);
MetaDataTable fieldPositionTable = metaDataService.getTable("field_position");
metaDataService.getColumn(fieldPositionTable, "id", "TEXT" , 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(fieldPositionTable, "created_date", "TIMESTAMP" , 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(fieldPositionTable, "last_modified_date", "TIMESTAMP" , 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(fieldPositionTable, "version", "LONG" , 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(fieldPositionTable, "name", "TEXT" , 5, Boolean.FALSE, "Name", Boolean.FALSE, null);
metaDataService.getColumn(fieldPositionTable, "short_name", "TEXT" , 6, Boolean.FALSE, "Kurzname", Boolean.FALSE, null);
metaDataService.getColumn(fieldPositionTable, "sport_id", "TEXT" , 7, Boolean.FALSE, "Sport", Boolean.FALSE, null, "name");
MetaDataTable roosterTable = metaDataService.getTable("rooster");
metaDataService.getColumn(roosterTable, "id", "TEXT", 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(roosterTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(roosterTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(roosterTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(roosterTable, "year", "LONG", 5, Boolean.FALSE, "Jahr", Boolean.FALSE, null);
metaDataService.getColumn(roosterTable, "player_id", "TEXT", 6, Boolean.FALSE, "Spieler", Boolean.FALSE, null, "last_name");
metaDataService.getColumn(roosterTable, "position_id", "TEXT", 7, Boolean.FALSE, "Position", Boolean.FALSE, null, "short_name");
metaDataService.getColumn(roosterTable, "team_id", "TEXT", 8, Boolean.FALSE, "Team", Boolean.FALSE, null, "name");
MetaDataTable cardSetTable = metaDataService.getTable("card_set");
metaDataService.getColumn(cardSetTable, "id", "TEXT", 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(cardSetTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(cardSetTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(cardSetTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(cardSetTable, "insert_set", "BOOLEAN", 5, Boolean.FALSE, "Insertset?", Boolean.FALSE, null);
metaDataService.getColumn(cardSetTable, "parallel_set", "BOOLEAN", 6, Boolean.FALSE, "Parallelset?", Boolean.FALSE, null);
metaDataService.getColumn(cardSetTable, "name", "TEXT", 7, Boolean.FALSE, "Name", Boolean.FALSE, null);
metaDataService.getColumn(cardSetTable, "vendor_id", "TEXT", 8, Boolean.FALSE, "Hersteller", Boolean.FALSE, null, "name");
MetaDataTable cardTable = metaDataService.getTable("card");
metaDataService.getColumn(cardTable, "id", "TEXT", 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(cardTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(cardTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(cardTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(cardTable, "card_number", "LONG", 5, Boolean.FALSE, "Nummmer", Boolean.FALSE, null);
metaDataService.getColumn(cardTable, "year", "LONG", 6, Boolean.FALSE, "Jahr", Boolean.FALSE, null);
metaDataService.getColumn(cardTable, "card_set_id", "TEXT", 7, Boolean.FALSE, "Set", Boolean.FALSE, null, "name");
metaDataService.getColumn(cardTable, "rooster_id", "TEXT", 8, Boolean.FALSE, "Spieler", Boolean.FALSE, null, "name");
metaDataService.getColumn(cardTable, "vendor_id", "TEXT", 9, Boolean.FALSE, "Hersteller", Boolean.FALSE, null, "name");
MetaDataTable profileTable = metaDataService.getTable("profile");
metaDataService.getColumn(profileTable, "id", "TEXT", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(profileTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(profileTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(profileTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(profileTable, "first_name", "TEXT", 5, Boolean.TRUE, "Vorname", Boolean.FALSE, null);
metaDataService.getColumn(profileTable, "last_name", "TEXT", 6, Boolean.TRUE, "Nachname", Boolean.FALSE, null);
metaDataService.getColumn(profileTable, "user_name", "TEXT", 7, Boolean.TRUE, "Login", Boolean.FALSE, null);
metaDataService.getColumn(profileTable, "email", "TEXT", 8, Boolean.TRUE, "Email", Boolean.FALSE, null);
metaDataService.getColumn(profileTable, "password", "TEXT", 9, Boolean.FALSE, "Password", Boolean.FALSE, null);
metaDataService.getColumn(profileTable, "enabled", "BOOLEAN", 10, Boolean.TRUE, "Aktiv?", Boolean.TRUE, null);
MetaDataTable tokenTable = metaDataService.getTable("token");
metaDataService.getColumn(tokenTable, "id", "TEXT"
, 1, Boolean.TRUE, "", Boolean.FALSE, null);
metaDataService.getColumn(tokenTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(tokenTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(tokenTable, "version", "LONG", 4, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(tokenTable, "token", "TEXT", 5, Boolean.TRUE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(tokenTable, "name", "TEXT", 6, Boolean.TRUE, "Name", Boolean.FALSE, null);
metaDataService.getColumn(tokenTable, "last_used_date", "TIMESTAMP", 7, Boolean.FALSE, "Verwendet", Boolean.FALSE, null);
metaDataService.getColumn(tokenTable, "enabled", "BOOLEAN", 8, Boolean.TRUE, "Aktiv", Boolean.TRUE, "Enabled");
metaDataService.getColumn(tokenTable, "profile_id", "TEXT", 9, Boolean.TRUE, "Profile", Boolean.FALSE, null, "user_name");
MetaDataTable permissionTable = metaDataService.getTable("permission");
metaDataService.getColumn(permissionTable, "id", "TEXT", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(permissionTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(permissionTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(permissionTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(permissionTable, "name", "TEXT", 5, Boolean.TRUE, "Name", Boolean.FALSE, null);
MetaDataTable AssignmentTable = metaDataService.getTable("assignment");
metaDataService.getColumn(AssignmentTable, "id", "TEXT", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(AssignmentTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(AssignmentTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(AssignmentTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(AssignmentTable, "profile_id", "TEXT", 5, Boolean.TRUE, "Profile", Boolean.FALSE, null, "user_name");
metaDataService.getColumn(AssignmentTable, "permission_id", "TEXT", 6, Boolean.TRUE, "Permission", Boolean.FALSE, null, "name");
MetaDataTable moduleDataTable = metaDataService.getTable("module_data");
metaDataService.getColumn(moduleDataTable, "id", "TEXT", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(moduleDataTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(moduleDataTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(moduleDataTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(moduleDataTable, "module_name", "TEXT", 5, Boolean.TRUE, "Module", Boolean.FALSE, null);
metaDataService.getColumn(moduleDataTable, "import_data", "BOOLEAN", 6, Boolean.TRUE, "Import Data?", Boolean.TRUE, "Import Data");
MetaDataTable mailAccountTable = metaDataService.getTable("mail_account");
metaDataService.getColumn(mailAccountTable, "id", "TEXT", 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(mailAccountTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(mailAccountTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(mailAccountTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(mailAccountTable, "host", "TEXT", 5, Boolean.TRUE, "Host", Boolean.FALSE, null);
metaDataService.getColumn(mailAccountTable, "port", "LONG", 6, Boolean.TRUE, "Port", Boolean.FALSE, null);
metaDataService.getColumn(mailAccountTable, "protocol", "TEXT", 7, Boolean.TRUE, "Protocol", Boolean.FALSE, null);
metaDataService.getColumn(mailAccountTable, "user_name", "TEXT", 8, Boolean.TRUE, "Username", Boolean.FALSE, null);
metaDataService.getColumn(mailAccountTable, "password", "TEXT", 9, Boolean.FALSE, "Password", Boolean.FALSE, null);
metaDataService.getColumn(mailAccountTable, "start_tls", "BOOLEAN", 10, Boolean.TRUE, "StartTLS", Boolean.TRUE, "StartTLS");
MetaDataTable mailTable = metaDataService.getTable("mail");
metaDataService.getColumn(mailTable, "id", "TEXT", 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(mailTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(mailTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(mailTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(mailTable, "folder", "TEXT", 5, Boolean.TRUE, "Folder", Boolean.FALSE, null);
metaDataService.getColumn(mailTable, "subject", "TEXT", 6, Boolean.TRUE, "Subject", Boolean.FALSE, null);
metaDataService.getColumn(mailTable, "body", "TEXT", 7, Boolean.FALSE, "Body", Boolean.FALSE, null);
metaDataService.getColumn(mailTable, "sent_date", "TIMESTAMP", 8, Boolean.FALSE, "Gesendet", Boolean.FALSE, null);
metaDataService.getColumn(mailTable, "received_date", "TIMESTAMP", 9, Boolean.FALSE, "Empfangen", Boolean.FALSE, null);
MetaDataTable metaDataTableTable = metaDataService.getTable("meta_data_table");
metaDataService.getColumn(metaDataTableTable, "id", "TEXT", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(metaDataTableTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(metaDataTableTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(metaDataTableTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(metaDataTableTable, "table_name", "TEXT", 5, Boolean.TRUE, "Table", Boolean.FALSE, null);
MetaDataTable metaDataColumnTable = metaDataService.getTable("meta_data_column");
metaDataService.getColumn(metaDataColumnTable, "id", "TEXT", 1, Boolean.FALSE, "ID", Boolean.FALSE, null);
metaDataService.getColumn(metaDataColumnTable, "created_date", "TIMESTAMP", 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
metaDataService.getColumn(metaDataColumnTable, "last_modified_date", "TIMESTAMP", 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
metaDataService.getColumn(metaDataColumnTable, "version", "LONG", 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
metaDataService.getColumn(metaDataColumnTable, "column_name", "TEXT", 5, Boolean.TRUE, "Column", Boolean.FALSE, null);
metaDataService.getColumn(metaDataColumnTable, "column_type", "TEXT", 7, Boolean.TRUE, "Type", Boolean.FALSE, null);
metaDataService.getColumn(metaDataColumnTable, "column_order", "LONG", 9, Boolean.TRUE, "Order", Boolean.FALSE, null);
metaDataService.getColumn(metaDataColumnTable, "is_shown", "BOOLEAN", 10, Boolean.TRUE, "Is Shown", Boolean.TRUE, "Is Shown");
metaDataService.getColumn(metaDataColumnTable, "column_label", "TEXT", 11, Boolean.TRUE, "Label", Boolean.FALSE, null);
metaDataService.getColumn(metaDataColumnTable, "show_filter", "BOOLEAN", 12, Boolean.TRUE, "Show Filter", Boolean.TRUE, "Show Filter");
metaDataService.getColumn(metaDataColumnTable, "filter_label", "TEXT", 13, Boolean.TRUE, "Filter Label", Boolean.FALSE, null);
metaDataService.getColumn(metaDataColumnTable, "ref_column", "TEXT", 14, Boolean.TRUE, "Ref Column", Boolean.FALSE, null);
metaDataService.getColumn(metaDataColumnTable, "table_id", "TEXT", 15, Boolean.TRUE, "Table", Boolean.FALSE, null, "table_name");
}
}
@@ -1,61 +0,0 @@
package de.thpeetz.kontor.admin.data;
import de.thpeetz.kontor.common.data.AbstractEntity;
import jakarta.annotation.Nullable;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Entity
@Getter
@Setter
@Table(
indexes = @Index(columnList = "columnName, table_id"),
uniqueConstraints = @UniqueConstraint(columnNames = {"table_id", "columnOrder"})
)
public class MetaDataColumn extends AbstractEntity {
@NotNull
private String columnName;
private String columnType;
private Integer columnOrder;
private Boolean isShown;
private String columnLabel;
private Boolean showFilter = Boolean.FALSE;
private String filterLabel;
@Nullable
private String refColumn;
@ManyToOne
@JoinColumn(name = "table_id")
@NotNull
private MetaDataTable table;
public String getTableName() {
return table.getTableName();
}
public String updateColumnName(String value) {
if (!this.getColumnName().equals(value)) {
this.setColumnName(value);
log.info("update columnName");
return "updated " + this.getId() + " with " + value + "\n";
}
return "no changes for " + this.getId() + "\n";
}
@Override
public String toString() {
return "MetaDataColumn{id=" + getId() + ", columnName=" + columnName + ", table=" + table.getTableName() +'}';
}
}
@@ -1,40 +0,0 @@
package de.thpeetz.kontor.admin.data;
import de.thpeetz.kontor.common.data.AbstractEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@Slf4j
@Entity
@Getter
@Setter
@Table(
indexes = @Index(columnList = "tableName"),
uniqueConstraints = @UniqueConstraint(columnNames = {"tableName"})
)
public class MetaDataTable extends AbstractEntity {
@NotNull
private String tableName;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "table")
private List<MetaDataColumn> tableColumns = new LinkedList<>();
public String updateTableName(String value) {
if (!this.getTableName().equals(value)) {
this.setTableName(value);
log.info("update tableName");
return "updated " + this.getId() + " with " + value;
}
return "no changes for " + this.getId();
}
}
@@ -1,20 +0,0 @@
package de.thpeetz.kontor.admin.repository;
import de.thpeetz.kontor.admin.data.MetaDataColumn;
import de.thpeetz.kontor.admin.data.MetaDataTable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
public interface MetaDataColumnRepository extends JpaRepository<MetaDataColumn, String> {
List<MetaDataColumn> findByTable(MetaDataTable table);
List<MetaDataColumn> findByTableAndColumnName(MetaDataTable table, String column_name);
@Query("select m from MetaDataColumn m " +
"where lower(m.columnName) like lower(concat('%', :searchTerm, '%')) or lower(m.columnLabel) like lower(concat('%', :searchTerm, '%'))")
List<MetaDataColumn> search(@Param("searchTerm") String searchTerm);
}
@@ -1,9 +0,0 @@
package de.thpeetz.kontor.admin.repository;
import de.thpeetz.kontor.admin.data.MetaDataTable;
import org.springframework.data.jpa.repository.JpaRepository;
public interface MetaDataTableRepository extends JpaRepository<MetaDataTable, String> {
MetaDataTable findByTableName(String tableName);
}
@@ -1,245 +0,0 @@
package de.thpeetz.kontor.admin.services;
import org.springframework.stereotype.Service;
import de.thpeetz.kontor.admin.data.MetaDataColumn;
import de.thpeetz.kontor.admin.repository.MetaDataColumnRepository;
import de.thpeetz.kontor.admin.data.MetaDataTable;
import de.thpeetz.kontor.admin.repository.MetaDataTableRepository;
import lombok.extern.slf4j.Slf4j;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
@Slf4j
@Service
public class MetaDataService {
private final MetaDataTableRepository metaDataTableRepository;
private final MetaDataColumnRepository metaDataColumnRepository;
public MetaDataService(MetaDataTableRepository metaDataTableRepository, MetaDataColumnRepository metaDataColumnRepository) {
this.metaDataTableRepository = metaDataTableRepository;
this.metaDataColumnRepository = metaDataColumnRepository;
}
public List<MetaDataTable> findAllTables() {
return metaDataTableRepository.findAll();
}
public MetaDataTable getTable(String tableName) {
MetaDataTable table = metaDataTableRepository.findByTableName(tableName);
if (table == null) {
log.info("Metadata for table {} not found, will create it", tableName);
table = new MetaDataTable();
table.setTableName(tableName);
metaDataTableRepository.save(table);
}
return table;
}
private void deleteTable(MetaDataTable metaDataTable) {
List<MetaDataColumn> columns = metaDataTable.getTableColumns();
List<MetaDataColumn> columnsToDelete = new LinkedList<>();
for (MetaDataColumn column: columns) {
try {
columnsToDelete.add(column);
metaDataColumnRepository.delete(column);
} catch (Exception e) {
log.info("Exception {} thrown, just go on", e.getMessage());
}
}
for (MetaDataColumn column: columnsToDelete) {
metaDataTable.getTableColumns().remove(column);
}
try {
metaDataTableRepository.delete(metaDataTable);
} catch (Exception e) {
log.info("could not delete MetaDataTable: {}", e.getMessage());
}
}
public void getColumn(MetaDataTable table, String columnName, String columnType, Integer columnOrder, Boolean isShown, String columnLabel, Boolean showFilter, String filterLabel) {
this.getColumn(table, columnName, columnType, columnOrder, isShown, columnLabel, showFilter, filterLabel, null);
}
public void checkColumnValues(MetaDataTable table, MetaDataColumn column, String columnName, String columnType, Integer columnOrder, Boolean isShown, String columnLabel, Boolean showFilter, String filterLabel, String refColumn) {
log.debug("Column {} with name {} of table {} found, check Values", columnOrder, columnName, table.getTableName());
if (!column.getColumnName().equals(columnName)) {
log.debug("columnName has to be changed to {}", columnName);
column.setColumnName(columnName);
}
if (!column.getColumnType().equals(columnType)) {
log.debug("columnType has to be changed to {}", columnType);
column.setColumnType(columnType);
}
if (isShown != null && !isShown.equals(column.getIsShown())) {
log.debug("isShown has to be change to {}}", isShown);
column.setIsShown(isShown);
}
if (columnLabel != null && !columnLabel.equals(column.getColumnLabel())) {
log.debug("columnLabel has to be change to {}}", columnLabel);
column.setColumnLabel(columnLabel);
}
if (showFilter != null &&!showFilter.equals(column.getShowFilter())) {
log.debug("showFilter has to be change to {}}", showFilter);
column.setShowFilter(showFilter);
}
if (filterLabel != null && !filterLabel.equals(column.getFilterLabel())) {
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);
}
saveMetaDataColumn(column);
}
public void getColumn(MetaDataTable table, String columnName, String columnType, Integer columnOrder, Boolean isShown, String columnLabel, Boolean showFilter, String filterLabel, String refColumn) {
log.info("check if column {} of table {} exists", columnName, table.getTableName());
boolean columnNameExists = table.getTableColumns().stream().anyMatch(column -> column.getColumnName().equals(columnName));
boolean columnOrderExists = false;
if (table.getTableColumns().size() > columnOrder-1) {
columnOrderExists = table.getTableColumns().get(columnOrder-1) != null;
}
List<MetaDataColumn> metaDataColumns = metaDataColumnRepository.findByTableAndColumnName(table, columnName);
log.debug("column found: name: {}, order: {}: table.columns: {}", columnNameExists, columnOrderExists, metaDataColumns);
if (columnOrderExists) {
MetaDataColumn column = table.getTableColumns().get(columnOrder-1);
checkColumnValues(table, column, columnName, columnType, columnOrder, isShown, columnLabel, showFilter, filterLabel, refColumn);
} else {
log.info("Column {} of table {} not found, will create it", columnName, table.getTableName());
addColumn(table, columnName, columnType, columnOrder, isShown, refColumn);
}
}
private void addColumn(MetaDataTable table, String columnName, String columnType, Integer columnOrder, Boolean isShown, String refColumn) {
MetaDataColumn column = new MetaDataColumn();
column.setTable(table);
column.setColumnName(columnName);
column.setColumnType(columnType);
column.setColumnOrder(columnOrder);
column.setIsShown(isShown);
column.setRefColumn(refColumn);
saveMetaDataColumn(column);
}
public List<MetaDataColumn> findAllMetaDataColumns(String stringFilter) {
if (stringFilter == null || stringFilter.isEmpty()) {
log.debug("Found " + metaDataColumnRepository.count()+ " entries");
return metaDataColumnRepository.findAll();
} else {
List<MetaDataColumn> results = metaDataColumnRepository.search(stringFilter);
log.debug("Found " + results.size() + " entries");
return results;
}
}
public void deleteMetaDataColumn(MetaDataColumn metaDataColumn) {
if (metaDataColumn == null) {
log.warn("MetaDataColumn is null, can't delete it");
return;
}
log.debug("deleteMetaDataColumn: MetaDataColumn={}", metaDataColumn);
metaDataColumnRepository.delete(metaDataColumn);
}
public void saveMetaDataColumn(MetaDataColumn metaDataColumn) {
if (metaDataColumn == null) {
log.warn("MetaDataColumn is null, can't save it");
return;
}
log.debug("saveMetaDataColumn: MetaDataColumn={}", metaDataColumn);
metaDataColumnRepository.save(metaDataColumn);
}
public String importTableData(Map<String, String> fields) {
AtomicReference<String> status = new AtomicReference<>("unknown");
String id = fields.get("id");
Optional<MetaDataTable> optional = metaDataTableRepository.findById(id);
if (optional.isEmpty()) {
log.info(" not found: {} with {}", id, fields);
status.set(id + "not found");
MetaDataTable checkExisting = metaDataTableRepository.findByTableName(fields.get("table_name"));
if (checkExisting != null) {
log.info("entry already there with different id ({}), will be deleted", checkExisting.getId());
deleteTable(checkExisting);
}
MetaDataTable metaDataTable = new MetaDataTable();
metaDataTable.setId(id);
metaDataTable.setTableName(fields.get("table_name"));
metaDataTableRepository.save(metaDataTable);
} else {
optional.ifPresent( entry -> {
log.info(" found: {}", entry.getTableName());
String updateStatus = updateTableFields(entry, fields);
metaDataTableRepository.save(entry);
status.set(updateStatus);
});
}
return status.get();
}
public String importColumnData(String tableName, Map<String, String> fields) {
AtomicReference<String> status = new AtomicReference<>("unknown");
String id = fields.get("id");
Optional<MetaDataColumn> optional = metaDataColumnRepository.findById(id);
if (optional.isEmpty()) {
log.info(" not found: {} with {}", id, fields);
status.set(id + "not found");
MetaDataColumn metaDataColumn = new MetaDataColumn();
metaDataColumn.setId(id);
metaDataColumn.setColumnName(fields.get("column_name"));
metaDataColumn.setColumnType(fields.get("column_type"));
metaDataColumnRepository.save(metaDataColumn);
} else {
optional.ifPresent( entry -> {
log.info(" found: {}", entry.getTableName());
String updateStatus = updateColumnFields(entry, tableName, fields);
metaDataColumnRepository.save(entry);
status.set(updateStatus);
});
}
return status.get();
}
private String updateColumnFields(MetaDataColumn metaDataColumn, String tableName, Map<String, String> fields) {
StringBuilder status = new StringBuilder();
for (Map.Entry<String, String> entry : fields.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
switch (key) {
case "id", "created_date", "last_modified_date", "version":
break;
case "column_name":
status.append(metaDataColumn.updateColumnName(value));
break;
default:
log.info("field {} is unknown for table {}", key, tableName);
}
}
return status.toString();
}
private String updateTableFields(MetaDataTable metaDataTable, Map<String, String> fields) {
String status = "";
for (Map.Entry<String, String> entry : fields.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
switch (key) {
case "id", "created_date", "last_modified_date", "version":
break;
case "table_name":
status += metaDataTable.updateTableName(value);
default:
log.info("field {} is unknown for table {}", key, MetaDataTable.class.getName());
}
}
return status;
}
}
@@ -1,120 +0,0 @@
package de.thpeetz.kontor.admin.views;
import com.vaadin.flow.component.ComponentEvent;
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.Key;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.checkbox.Checkbox;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.textfield.IntegerField;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.BeanValidationBinder;
import com.vaadin.flow.data.binder.Binder;
import de.thpeetz.kontor.admin.data.MetaDataColumn;
import de.thpeetz.kontor.admin.data.MetaDataTable;
import lombok.*;
import java.util.List;
public class MetaDataForm extends FormLayout {
ComboBox<MetaDataTable> table = new ComboBox<>("Table");
TextField columnName = new TextField("Column Name");
IntegerField columnOrder = new IntegerField("Column Order");
Checkbox isShown = new Checkbox("Is Shown");
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");
Button close = new Button("Cancel");
Binder<MetaDataColumn> binder = new BeanValidationBinder<>(MetaDataColumn.class);
public MetaDataForm(List<MetaDataTable> tables) {
addClassName("metaData-form");
binder.bindInstanceFields(this);
table.setItems(tables);
table.setItemLabelGenerator(MetaDataTable::getTableName);
add(table, columnName, columnOrder);
add(isShown, columnLabel);
isShown.addClickListener(click -> columnLabel.setEnabled(isShown.getValue()));
add(showFilter, filterLabel);
showFilter.addClickListener(click -> filterLabel.setEnabled(showFilter.getValue()));
add(refColumn);
add(createButtonsLayout());
}
private HorizontalLayout createButtonsLayout() {
save.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
delete.addThemeVariants(ButtonVariant.LUMO_ERROR);
close.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
save.addClickShortcut(Key.ENTER);
close.addClickShortcut(Key.ESCAPE);
save.addClickListener(event -> validateAndSave());
delete.addClickListener(event -> fireEvent(new MetaDataForm.DeleteEvent(this, binder.getBean())));
close.addClickListener(event -> fireEvent(new MetaDataForm.CloseEvent(this)));
binder.addStatusChangeListener(e -> save.setEnabled(binder.isValid()));
return new HorizontalLayout(save, delete, close);
}
private void validateAndSave() {
if (binder.isValid()) {
fireEvent(new MetaDataForm.SaveEvent(this, binder.getBean()));
}
}
public void setMetaDataColumn(MetaDataColumn metaDataColumn) {
binder.setBean(metaDataColumn);
}
@Getter
public abstract static class MetaDataFormEvent extends ComponentEvent<MetaDataForm> {
private final MetaDataColumn metaDataColumn;
protected MetaDataFormEvent(MetaDataForm source, MetaDataColumn metaDataColumn) {
super(source, false);
this.metaDataColumn = metaDataColumn;
}
}
public static class SaveEvent extends MetaDataForm.MetaDataFormEvent {
SaveEvent(MetaDataForm source, MetaDataColumn metaDataColumn) {
super(source, metaDataColumn);
}
}
public static class DeleteEvent extends MetaDataForm.MetaDataFormEvent {
DeleteEvent(MetaDataForm source, MetaDataColumn metaDataColumn) {
super(source, metaDataColumn);
}
}
public static class CloseEvent extends MetaDataForm.MetaDataFormEvent {
CloseEvent(MetaDataForm source) {
super(source, null);
}
}
public void addDeleteListener(ComponentEventListener<MetaDataForm.DeleteEvent> listener) {
addListener(MetaDataForm.DeleteEvent.class, listener);
}
public void addSaveListener(ComponentEventListener<MetaDataForm.SaveEvent> listener) {
addListener(MetaDataForm.SaveEvent.class, listener);
}
public void addCloseListener(ComponentEventListener<MetaDataForm.CloseEvent> listener) {
addListener(MetaDataForm.CloseEvent.class, listener);
}
}
@@ -1,185 +0,0 @@
package de.thpeetz.kontor.admin.views;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.grid.GridSortOrder;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.provider.SortDirection;
import com.vaadin.flow.data.value.ValueChangeMode;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.spring.annotation.SpringComponent;
import de.thpeetz.kontor.admin.AdminConstants;
import de.thpeetz.kontor.admin.data.MetaDataColumn;
import de.thpeetz.kontor.admin.services.MetaDataService;
import de.thpeetz.kontor.common.views.MainLayout;
import de.thpeetz.kontor.common.views.ColumnToggleContextMenu;
import de.thpeetz.kontor.common.views.StatusIcon;
import jakarta.annotation.security.RolesAllowed;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@SpringComponent
@Scope("prototype")
@RolesAllowed("ROLE_ADMIN")
@Route(value = AdminConstants.METADATA_ROUTE, layout = MainLayout.class)
@PageTitle("Meta Data | Admin | Kontor")
public class MetaDataView extends VerticalLayout {
Grid<MetaDataColumn> grid = new Grid<>(MetaDataColumn.class, false);
Grid.Column<MetaDataColumn> idColumn = grid.addColumn(MetaDataColumn::getId)
.setHeader("ID").setResizable(true).setSortable(true);
Grid.Column<MetaDataColumn> createdColumn = grid.addColumn(MetaDataColumn::getCreatedDate)
.setHeader("Erstellt").setResizable(true).setSortable(true);
Grid.Column<MetaDataColumn> modifiedColumn = grid.addColumn(MetaDataColumn::getLastModifiedDate)
.setHeader("Geändert").setResizable(true).setSortable(true);
Grid.Column<MetaDataColumn> versionColumn = grid.addColumn(MetaDataColumn::getVersion)
.setHeader("Version").setResizable(true).setSortable(true);
Grid.Column<MetaDataColumn> tableColumn = grid.addColumn(MetaDataColumn::getTableName)
.setHeader("Table").setResizable(true).setSortable(true);
Grid.Column<MetaDataColumn> columnNameColumn = grid.addColumn(MetaDataColumn::getColumnName)
.setHeader("Column Name").setResizable(true).setSortable(true);
Grid.Column<MetaDataColumn> columnTypeColumn = grid.addColumn(MetaDataColumn::getColumnType)
.setHeader("Column Type").setResizable(true).setSortable(true);
Grid.Column<MetaDataColumn> columnOrderColumn = grid.addColumn(MetaDataColumn::getColumnOrder)
.setHeader("Column Order").setResizable(true).setSortable(true);
Grid.Column<MetaDataColumn> isShownColumn = grid.addComponentColumn(metaDataColumn -> StatusIcon.create(metaDataColumn.getIsShown())).
setHeader("Anzeige?").setWidth("6rem").setSortable(true);
Grid.Column<MetaDataColumn> columnLabelColumn = grid.addColumn(MetaDataColumn::getColumnLabel)
.setHeader("Spaltenname").setResizable(true).setSortable(true);
Grid.Column<MetaDataColumn> showFilterColumn = grid.addComponentColumn(metaDataColumn -> StatusIcon.create(metaDataColumn.getShowFilter())).
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;
MetaDataService service;
public MetaDataView(MetaDataService service) {
this.service = service;
addClassName("metadata-view");
setSizeFull();
configureGrid();
configureForm();
add(getToolbar(), getContent());
updateList();
}
private void configureGrid() {
grid.addClassName("metadata-grid");
grid.setSizeFull();
grid.getColumns().forEach(col -> col.setAutoWidth(true));
idColumn.setVisible(false);
createdColumn.setVisible(false);
modifiedColumn.setVisible(false);
versionColumn.setVisible(false);
grid.setMultiSort(true);
List<GridSortOrder<MetaDataColumn>> sortOrder = new ArrayList<>();
sortOrder.add(new GridSortOrder<MetaDataColumn>(tableColumn, SortDirection.ASCENDING));
sortOrder.add(new GridSortOrder<MetaDataColumn>(columnOrderColumn, SortDirection.ASCENDING));
grid.sort(sortOrder);
grid.asSingleSelect().addValueChangeListener(event -> editMetaData(event.getValue()));
}
private void configureForm() {
form = new MetaDataForm(service.findAllTables());
form.setWidth("25em");
form.setVisible(false);
form.addSaveListener(this::saveMetaData);
form.addDeleteListener(this::deleteMetaData);
form.addCloseListener(e -> closeEditor());
}
private Component getContent() {
HorizontalLayout content = new HorizontalLayout(grid, form);
content.setFlexGrow(2, grid);
content.setFlexGrow(1, form);
content.addClassName("content");
content.setSizeFull();
return content;
}
private HorizontalLayout getToolbar() {
searchField.setPlaceholder("Search");
searchField.setClearButtonVisible(true);
searchField.setPrefixComponent(new Icon(VaadinIcon.SEARCH));
searchField.setValueChangeMode(ValueChangeMode.EAGER);
searchField.addValueChangeListener(e -> updateList());
Button addMetaDataButton = new Button("Add Meta Data");
addMetaDataButton.addClickListener(click -> addMetaDataColumn());
Button menuButton = new Button("Show/Hide Columns");
menuButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
ColumnToggleContextMenu<MetaDataColumn> columnToggleContextMenu = new ColumnToggleContextMenu<>(menuButton);
columnToggleContextMenu.addColumnToggleItem(idColumn);
columnToggleContextMenu.addColumnToggleItem(createdColumn);
columnToggleContextMenu.addColumnToggleItem(modifiedColumn);
columnToggleContextMenu.addColumnToggleItem(versionColumn);
columnToggleContextMenu.addColumnToggleItem(tableColumn);
columnToggleContextMenu.addColumnToggleItem(columnNameColumn);
columnToggleContextMenu.addColumnToggleItem(columnTypeColumn);
columnToggleContextMenu.addColumnToggleItem(columnOrderColumn);
columnToggleContextMenu.addColumnToggleItem(isShownColumn);
columnToggleContextMenu.addColumnToggleItem(columnLabelColumn);
columnToggleContextMenu.addColumnToggleItem(showFilterColumn);
columnToggleContextMenu.addColumnToggleItem(filterLabelColumn);
columnToggleContextMenu.addColumnToggleItem(refColumnColumn);
HorizontalLayout toolbar = new HorizontalLayout(searchField, addMetaDataButton, menuButton);
toolbar.addClassName("toolbar");
return toolbar;
}
private void saveMetaData(MetaDataForm.SaveEvent event) {
MetaDataColumn metaDataColumn = event.getMetaDataColumn();
service.saveMetaDataColumn(metaDataColumn);
updateList();
closeEditor();
}
private void deleteMetaData(MetaDataForm.DeleteEvent event) {
service.deleteMetaDataColumn(event.getMetaDataColumn());
updateList();
closeEditor();
}
public void editMetaData(MetaDataColumn metaDataColumn) {
if (metaDataColumn == null) {
closeEditor();
} else {
form.setMetaDataColumn(metaDataColumn);
form.setVisible(true);
addClassName("editing");
}
}
public void closeEditor() {
form.setMetaDataColumn(null);
form.setVisible(false);
removeClassName("editing");
}
private void addMetaDataColumn() {
grid.asSingleSelect().clear();
editMetaData(new MetaDataColumn());
}
private void updateList() {
grid.setItems(service.findAllMetaDataColumns(searchField.getValue()));
}
}
@@ -1,24 +1,17 @@
package de.thpeetz.kontor.data.services;
import de.thpeetz.kontor.admin.data.MetaDataTable;
import de.thpeetz.kontor.admin.repository.MetaDataTableRepository;
import de.thpeetz.kontor.admin.services.MetaDataService;
import de.thpeetz.kontor.tysc.services.SportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
@Slf4j
@Service
public class DataManagementService {
@Autowired
MetaDataService metaDataService;
@Autowired
SportService sportService;
@@ -29,12 +22,6 @@ public class DataManagementService {
public String getEntry(String nodeName, Map<String, String> fields) {
AtomicReference<String> status = new AtomicReference<>("unknown");
switch (nodeName) {
case "meta_data_table":
status.set(metaDataService.importTableData(fields));
break;
case "meta_data_column":
status.set(metaDataService.importColumnData(nodeName, fields));
break;
case "sport":
status.set(sportService.importData(fields));
default: