Vorbereitung Release 0.2.0
This commit is contained in:
@@ -3,15 +3,17 @@ package de.thpeetz.kontor.admin;
|
||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||
import com.vaadin.flow.component.sidenav.SideNavItem;
|
||||
import com.vaadin.flow.router.RouterLink;
|
||||
import de.thpeetz.kontor.admin.views.*;
|
||||
import de.thpeetz.kontor.admin.views.AssignmentView;
|
||||
import de.thpeetz.kontor.admin.views.PermissionView;
|
||||
import de.thpeetz.kontor.admin.views.ProfileView;
|
||||
import de.thpeetz.kontor.comics.ComicConstants;
|
||||
import de.thpeetz.kontor.comics.views.ComicWorkView;
|
||||
import de.thpeetz.kontor.comics.views.IssueWorkView;
|
||||
import de.thpeetz.kontor.media.MediaConstants;
|
||||
import de.thpeetz.kontor.media.views.MediaActorFileView;
|
||||
|
||||
public class AdminConstants {
|
||||
|
||||
|
||||
private AdminConstants() {
|
||||
// private constructor to hide the implicit public one
|
||||
}
|
||||
@@ -46,10 +48,9 @@ public class AdminConstants {
|
||||
administration.addItem(new SideNavItem(PERMISSION, PermissionView.class));
|
||||
SideNavItem data = new SideNavItem(DATA, ASSIGNMENT_ROUTE, VaadinIcon.DATABASE.create());
|
||||
data.addItem(new SideNavItem(ComicConstants.COMICWORK, ComicWorkView.class));
|
||||
data.addItem(new SideNavItem(ComicConstants.ISSUEWORK, IssueWorkView.class));
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package de.thpeetz.kontor.admin;
|
||||
|
||||
import de.thpeetz.kontor.admin.data.*;
|
||||
import de.thpeetz.kontor.admin.repository.*;
|
||||
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.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;
|
||||
@@ -38,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) {
|
||||
@@ -58,8 +58,6 @@ public class SetupModuleAdmin implements ApplicationListener<ContextRefreshedEve
|
||||
}
|
||||
log.info("MailProperties: {}", mailProperties);
|
||||
initMail(mailProperties);
|
||||
|
||||
initMetaData();
|
||||
}
|
||||
|
||||
private void initMail(MailProperties mailProperties) {
|
||||
@@ -125,310 +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", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaArticleTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaArticleTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaArticleTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaArticleTable, "url", "link_url", "TEXT", "UNIQUE", 5, Boolean.TRUE, "URL", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaArticleTable, "review", "review", "BOOLEAN", null, 6, Boolean.TRUE, "Review", Boolean.TRUE, "Review");
|
||||
metaDataService.getColumn(mediaArticleTable, "title", "title", "TEXT", null, 7, Boolean.TRUE, "Title", Boolean.FALSE, null);
|
||||
MetaDataTable mediaVideoTable = metaDataService.getTable("media_video");
|
||||
metaDataService.getColumn(mediaVideoTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaVideoTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaVideoTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaVideoTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaVideoTable, "url", "link_url", "TEXT", "UNIQUE", 5, Boolean.TRUE, "URL", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaVideoTable, "review", "review", "BOOLEAN", null, 6, Boolean.TRUE, "Review", Boolean.TRUE, "Review");
|
||||
metaDataService.getColumn(mediaVideoTable, "should_download", "should_download", "BOOLEAN", null, 7, Boolean.TRUE, "Download", Boolean.TRUE, "Download");
|
||||
metaDataService.getColumn(mediaVideoTable, "title", "title", "TEXT", null, 8, Boolean.TRUE, "Title", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaVideoTable, "file_name", "file_name", "TEXT", null, 9, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaVideoTable, "path", "path", "TEXT", null, 10, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaVideoTable, "cloud_link", "cloud_link", "TEXT", null, 11, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable mediaFileTable = metaDataService.getTable("media_file");
|
||||
metaDataService.getColumn(mediaFileTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaFileTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaFileTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaFileTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaFileTable, "url", "link_url", "TEXT", "UNIQUE", 5, Boolean.TRUE, "URL", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaFileTable, "review", "review", "BOOLEAN", null, 6, Boolean.TRUE, "Review", Boolean.TRUE, "Review");
|
||||
metaDataService.getColumn(mediaFileTable, "should_download", "should_download", "BOOLEAN", null, 7, Boolean.TRUE, "Download", Boolean.TRUE, "Download");
|
||||
metaDataService.getColumn(mediaFileTable, "title", "title", "TEXT", null, 8, Boolean.TRUE, "Title", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaFileTable, "file_name", "file_name", "TEXT", null, 9, Boolean.TRUE, "Dateiname", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaFileTable, "path", "path", "TEXT", null, 10, Boolean.TRUE, "Verzeichnis", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaFileTable, "cloud_link", "cloud_link", "TEXT", null, 11, Boolean.TRUE, "Cloud Link", Boolean.FALSE, null);
|
||||
MetaDataTable mediaActorTable = metaDataService.getTable("media_actor");
|
||||
metaDataService.getColumn(mediaActorTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaActorTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaActorTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaActorTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaActorTable, "name", "name", "TEXT", "UNIQUE", 5, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
MetaDataTable mediaActorFileTable = metaDataService.getTable("media_actor_file");
|
||||
metaDataService.getColumn(mediaActorFileTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaActorFileTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "Created", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaActorFileTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "Modified", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaActorFileTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "Version", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mediaActorFileTable, "media_actor_id", "media_actor_id", "TEXT", null, 5, Boolean.TRUE, "Actor", Boolean.FALSE, null, "name");
|
||||
metaDataService.getColumn(mediaActorFileTable, "media_file_id", "media_file_id", "TEXT", null, 6, Boolean.TRUE, "File", Boolean.FALSE, null, "title");
|
||||
MetaDataTable artistTable = metaDataService.getTable("artist");
|
||||
metaDataService.getColumn(artistTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(artistTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(artistTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(artistTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(artistTable, "name", "name", "TEXT", "UNIQUE", 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable publisherTable = metaDataService.getTable("publisher");
|
||||
metaDataService.getColumn(publisherTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(publisherTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(publisherTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(publisherTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(publisherTable, "name", "name", "TEXT", "UNIQUE", 5, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
MetaDataTable comicTable = metaDataService.getTable("comic");
|
||||
metaDataService.getColumn(comicTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "ID", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(comicTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(comicTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(comicTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
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, "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);
|
||||
metaDataService.getColumn(issueTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(issueTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
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, "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);
|
||||
metaDataService.getColumn(volumeTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(volumeTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(volumeTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(volumeTable, "name", "name", "TEXT", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(volumeTable, "comic_id", "comic_id", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable tpbTable = metaDataService.getTable("trade_paperback");
|
||||
metaDataService.getColumn(tpbTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(tpbTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(tpbTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(tpbTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
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, "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);
|
||||
metaDataService.getColumn(storyArcTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(storyArcTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(storyArcTable, "name", "name", "TEXT", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(storyArcTable, "comic_id", "comic_id", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable worktypeTable = metaDataService.getTable("worktype");
|
||||
metaDataService.getColumn(worktypeTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(worktypeTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(worktypeTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(worktypeTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(worktypeTable, "name", "name", "TEXT", "UNIQUE", 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable comicworkTable = metaDataService.getTable("comic_work");
|
||||
metaDataService.getColumn(comicworkTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(comicworkTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(comicworkTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(comicworkTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(comicworkTable, "artist_id", "artist_id", "TEXT", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(comicworkTable, "comic_id", "comic_id", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(comicworkTable, "work_type_id", "work_type_id", "TEXT", null, 7, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable authorTable = metaDataService.getTable("author");
|
||||
metaDataService.getColumn(authorTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(authorTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(authorTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(authorTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(authorTable, "first_name", "first_name", "TEXT", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(authorTable, "last_name", "last_name", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable articleTable = metaDataService.getTable("article");
|
||||
metaDataService.getColumn(articleTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(articleTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(articleTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(articleTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(articleTable, "title", "title", "TEXT", "UNIQUE", 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable articleAuthorTable = metaDataService.getTable("article_author");
|
||||
metaDataService.getColumn(articleAuthorTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(articleAuthorTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(articleAuthorTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(articleAuthorTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(articleAuthorTable, "article_id", "article_id", "TEXT", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(articleAuthorTable, "author_id", "author_id", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable bookTable = metaDataService.getTable("book");
|
||||
metaDataService.getColumn(bookTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookTable, "isbn", "isbn", "TEXT", "UNIQUE", 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookTable, "title", "title", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookTable, "year", "year", "LONG", null, 7, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookTable, "publisher_id", "publisher_id", "TEXT", null, 8, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable bookAuthorTable = metaDataService.getTable("book_author");
|
||||
metaDataService.getColumn(bookAuthorTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookAuthorTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookAuthorTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookAuthorTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookAuthorTable, "author_id", "author_id", "TEXT", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookAuthorTable, "book_id", "book_id", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable bookshelfPublisherTable = metaDataService.getTable("bookshelf_publisher");
|
||||
metaDataService.getColumn(bookshelfPublisherTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookshelfPublisherTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookshelfPublisherTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookshelfPublisherTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(bookshelfPublisherTable, "name", "name", "TEXT", "UNIQUE", 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable sportTable = metaDataService.getTable("sport");
|
||||
metaDataService.getColumn(sportTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(sportTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(sportTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(sportTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(sportTable, "name", "name", "TEXT", "UNIQUE", 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable playerTable = metaDataService.getTable("player");
|
||||
metaDataService.getColumn(playerTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(playerTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(playerTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(playerTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(playerTable, "first_name", "first_name", "TEXT", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(playerTable, "last_name", "last_name", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable teamTable = metaDataService.getTable("team");
|
||||
metaDataService.getColumn(teamTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(teamTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(teamTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(teamTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(teamTable, "name", "name", "TEXT", "UNIQUE", 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(teamTable, "short_name", "short_name", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(teamTable, "sport_id", "sport_id", "TEXT", null, 7, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable vendorTable = metaDataService.getTable("vendor");
|
||||
metaDataService.getColumn(vendorTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(vendorTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(vendorTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(vendorTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(vendorTable, "name", "name", "TEXT", "UNIQUE", 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable fieldPositionTable = metaDataService.getTable("field_position");
|
||||
metaDataService.getColumn(fieldPositionTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(fieldPositionTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(fieldPositionTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(fieldPositionTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(fieldPositionTable, "name", "name", "TEXT", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(fieldPositionTable, "short_name", "short_name", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(fieldPositionTable, "sport_id", "sport_id", "TEXT", null, 7, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable roosterTable = metaDataService.getTable("rooster");
|
||||
metaDataService.getColumn(roosterTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(roosterTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(roosterTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(roosterTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(roosterTable, "year", "year", "LONG", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(roosterTable, "player_id", "player_id", "TEXT", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(roosterTable, "position_id", "position_id", "TEXT", null, 7, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(roosterTable, "team_id", "team_id", "TEXT", null, 8, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable cardSetTable = metaDataService.getTable("card_set");
|
||||
metaDataService.getColumn(cardSetTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardSetTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardSetTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardSetTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardSetTable, "insert_set", "insert_set", "BOOLEAN", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardSetTable, "parallel_set", "parallel_set", "BOOLEAN", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardSetTable, "name", "name", "TEXT", null, 7, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardSetTable, "vendor_id", "vendor_id", "TEXT", null, 8, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable cardTable = metaDataService.getTable("card");
|
||||
metaDataService.getColumn(cardTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardTable, "card_number", "card_number", "LONG", null, 5, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardTable, "year", "year", "LONG", null, 6, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardTable, "card_set_id", "card_set_id", "TEXT", null, 7, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardTable, "rooster_id", "rooster_id", "TEXT", null, 8, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(cardTable, "vendor_id", "vendor_id", "TEXT", null, 9, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
MetaDataTable profileTable = metaDataService.getTable("profile");
|
||||
metaDataService.getColumn(profileTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(profileTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(profileTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(profileTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(profileTable, "first_name", "first_name", "TEXT", null, 5, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(profileTable, "last_name", "last_name", "TEXT", null, 6, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(profileTable, "user_name", "user_name", "TEXT", "UNIQUE", 7, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(profileTable, "email", "email", "TEXT", null, 8, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(profileTable, "password", "password", "TEXT", null, 9, Boolean.FALSE, "Password", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(profileTable, "enabled", "enabled", "BOOLEAN", null, 10, Boolean.TRUE, "", Boolean.TRUE, null);
|
||||
MetaDataTable tokenTable = metaDataService.getTable("token");
|
||||
metaDataService.getColumn(tokenTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(tokenTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(tokenTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(tokenTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(tokenTable, "token", "token", "TEXT", null, 5, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(tokenTable, "name", "name", "TEXT", null, 6, Boolean.TRUE, "Name", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(tokenTable, "last_used_date", "used", "TIMESTAMP", null, 7, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(tokenTable, "enabled", "enabled", "BOOLEAN", null, 8, Boolean.TRUE, "", Boolean.TRUE, "Enabled");
|
||||
metaDataService.getColumn(tokenTable, "profile_id", "profile_id", "TEXT", null, 9, Boolean.TRUE, "Profile", Boolean.FALSE, null, "user_name");
|
||||
MetaDataTable permissionTable = metaDataService.getTable("permission");
|
||||
metaDataService.getColumn(permissionTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(permissionTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(permissionTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(permissionTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(permissionTable, "name", "name", "TEXT", null, 5, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
MetaDataTable AssignmentTable = metaDataService.getTable("assignment");
|
||||
metaDataService.getColumn(AssignmentTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(AssignmentTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(AssignmentTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(AssignmentTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(AssignmentTable, "profile_id", "profile_id", "TEXT", null, 5, Boolean.TRUE, "Profile", Boolean.FALSE, null, "user_name");
|
||||
metaDataService.getColumn(AssignmentTable, "permission_id", "permission_id", "TEXT", null, 6, Boolean.TRUE, "Permission", Boolean.FALSE, null, "name");
|
||||
MetaDataTable moduleDataTable = metaDataService.getTable("module_data");
|
||||
metaDataService.getColumn(moduleDataTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(moduleDataTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(moduleDataTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(moduleDataTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(moduleDataTable, "module_name", "module_name", "TEXT", "UNIQUE", 5, Boolean.TRUE, "Module", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(moduleDataTable, "import_data", "import_data", "BOOLEAN", null, 6, Boolean.TRUE, "Import Data?", Boolean.TRUE, "Import Data");
|
||||
MetaDataTable mailAccountTable = metaDataService.getTable("mail_account");
|
||||
metaDataService.getColumn(mailAccountTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailAccountTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailAccountTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailAccountTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailAccountTable, "host", "host", "TEXT", null, 5, Boolean.TRUE, "Host", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailAccountTable, "port", "port", "LONG", null, 6, Boolean.TRUE, "Port", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailAccountTable, "protocol", "protocol", "TEXT", null, 7, Boolean.TRUE, "Protocol", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailAccountTable, "user_name", "user_name", "TEXT", null, 8, Boolean.TRUE, "Username", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailAccountTable, "password", "password", "TEXT", null, 9, Boolean.FALSE, "Password", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailAccountTable, "start_tls", "start_tls", "BOOLEAN", null, 10, Boolean.TRUE, "StartTLS", Boolean.TRUE, "StartTLS");
|
||||
MetaDataTable mailTable = metaDataService.getTable("mail");
|
||||
metaDataService.getColumn(mailTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailTable, "folder", "folder", "TEXT", null, 5, Boolean.TRUE, "Folder", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailTable, "subject", "subject", "TEXT", null, 6, Boolean.TRUE, "Subject", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailTable, "body", "body", "TEXT", null, 7, Boolean.FALSE, "Body", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailTable, "sent_date", "created", "TIMESTAMP", null, 8, Boolean.FALSE, "Gesendet", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(mailTable, "received_date", "created", "TIMESTAMP", null, 9, Boolean.FALSE, "Empfangen", Boolean.FALSE, null);
|
||||
MetaDataTable metaDataTableTable = metaDataService.getTable("meta_data_table");
|
||||
metaDataService.getColumn(metaDataTableTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.TRUE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataTableTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataTableTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataTableTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataTableTable, "table_name", "table_name", "TEXT", "UNIQUE", 5, Boolean.TRUE, "Table", Boolean.FALSE, null);
|
||||
MetaDataTable metaDataColumnTable = metaDataService.getTable("meta_data_column");
|
||||
metaDataService.getColumn(metaDataColumnTable, "id", "identifier", "TEXT", "PRIMARY KEY", 1, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "created_date", "created", "TIMESTAMP", null, 2, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "last_modified_date", "modified", "TIMESTAMP", null, 3, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "version", "version", "LONG", null, 4, Boolean.FALSE, "", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "column_name", "column_name", "TEXT", null, 5, Boolean.TRUE, "Column", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "column_sync_name", "column_sync_name", "TEXT", null, 6, Boolean.TRUE, "SQLite Column", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "column_type", "column_type", "TEXT", null, 7, Boolean.TRUE, "Type", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "column_modifier", "column_modifier", "TEXT", null, 8, Boolean.TRUE, "Modifier", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "column_order", "column_order", "LONG", null, 9, Boolean.TRUE, "Order", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "is_shown", "is_shown", "BOOLEAN", null, 10, Boolean.TRUE, "Is Shown", Boolean.TRUE, "Is Shown");
|
||||
metaDataService.getColumn(metaDataColumnTable, "column_label", "column_label", "TEXT", null, 11, Boolean.TRUE, "Label", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "show_filter", "show_filter", "BOOLEAN", null, 12, Boolean.TRUE, "Show Filter", Boolean.TRUE, "Show Filter");
|
||||
metaDataService.getColumn(metaDataColumnTable, "filter_label", "filter_label", "TEXT", null, 13, Boolean.TRUE, "Filter Label", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "ref_column", "ref_column", "TEXT", null, 14, Boolean.TRUE, "Ref Column", Boolean.FALSE, null);
|
||||
metaDataService.getColumn(metaDataColumnTable, "table_id", "table_id", "TEXT", null, 15, Boolean.TRUE, "Table", Boolean.FALSE, null, "table_name");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +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 columnSyncName;
|
||||
|
||||
private String columnType;
|
||||
|
||||
@Nullable
|
||||
private String columnModifier;
|
||||
|
||||
private Integer columnOrder;
|
||||
|
||||
private Boolean isShown;
|
||||
|
||||
private String columnLabel;
|
||||
|
||||
private Boolean showFilter = Boolean.FALSE;
|
||||
|
||||
private String filterLabel;
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
public String updateColumnSyncName(String value) {
|
||||
if (!this.getColumnSyncName().equals(value)) {
|
||||
this.setColumnSyncName(value);
|
||||
log.info("update columnSyncName");
|
||||
return "updated " + this.getId() + " with " + value + "\n";
|
||||
}
|
||||
return "no changes for " + this.getId() + "\n";
|
||||
}
|
||||
}
|
||||
@@ -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,25 +0,0 @@
|
||||
package de.thpeetz.kontor.admin.data;
|
||||
|
||||
import de.thpeetz.kontor.common.data.AbstractEntity;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Index;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@Table(
|
||||
indexes = @Index(columnList = "moduleName"),
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"moduleName"})
|
||||
)
|
||||
public class ModuleData extends AbstractEntity {
|
||||
|
||||
@NotEmpty
|
||||
private String moduleName;
|
||||
|
||||
private Boolean importData;
|
||||
}
|
||||
-18
@@ -1,18 +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);
|
||||
|
||||
@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);
|
||||
}
|
||||
-9
@@ -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);
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package de.thpeetz.kontor.admin.repository;
|
||||
|
||||
import de.thpeetz.kontor.admin.data.ModuleData;
|
||||
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 ModuleDataRepository extends JpaRepository<ModuleData, String> {
|
||||
|
||||
@Query("select m from ModuleData m where lower(m.moduleName) like lower(concat('%', :searchTerm, '%')) ")
|
||||
List<ModuleData> search(@Param("searchTerm") String searchTerm);
|
||||
|
||||
ModuleData findByModuleName(String moduleName);
|
||||
}
|
||||
+7
-3
@@ -1,7 +1,11 @@
|
||||
package de.thpeetz.kontor.admin.services;
|
||||
|
||||
import de.thpeetz.kontor.admin.data.*;
|
||||
import de.thpeetz.kontor.admin.repository.*;
|
||||
import de.thpeetz.kontor.admin.data.Assignment;
|
||||
import de.thpeetz.kontor.admin.data.Profile;
|
||||
import de.thpeetz.kontor.admin.data.Permission;
|
||||
import de.thpeetz.kontor.admin.repository.AssignmentRepository;
|
||||
import de.thpeetz.kontor.admin.repository.ProfileRepository;
|
||||
import de.thpeetz.kontor.admin.repository.PermissionRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
@@ -21,7 +25,7 @@ import java.util.stream.Collectors;
|
||||
@Service("userDetailsService")
|
||||
public class KontorUserDetailsService implements UserDetailsService {
|
||||
|
||||
private static SecureRandom random = new SecureRandom();
|
||||
private static final SecureRandom random = new SecureRandom();
|
||||
|
||||
@Autowired
|
||||
private ProfileRepository profileRepository;
|
||||
|
||||
@@ -1,243 +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 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);
|
||||
if (!column.getColumnName().equals(columnName)) {
|
||||
log.debug("columnName has to be changed to {}", columnName);
|
||||
column.setColumnName(columnName);
|
||||
}
|
||||
if (!column.getColumnSyncName().equals(columnSyncName)) {
|
||||
log.debug("columnSyncName has to be changed to {}", columnSyncName);
|
||||
column.setColumnSyncName(columnSyncName);
|
||||
}
|
||||
if (!column.getColumnType().equals(columnType)) {
|
||||
log.debug("columnType has to be changed to {}", columnType);
|
||||
column.setColumnType(columnType);
|
||||
}
|
||||
if (columnModifier != null && !columnModifier.equals(column.getColumnModifier())) {
|
||||
log.debug("columnModifier has to be changed to {}", columnModifier);
|
||||
column.setColumnModifier(columnModifier);
|
||||
}
|
||||
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);
|
||||
}
|
||||
metaDataColumnRepository.save(column);
|
||||
} else {
|
||||
log.info("Column {} of table {} not found, will create it", columnName, table.getTableName());
|
||||
MetaDataColumn column = new MetaDataColumn();
|
||||
column.setTable(table);
|
||||
column.setColumnName(columnName);
|
||||
column.setColumnSyncName(columnSyncName);
|
||||
column.setColumnType(columnType);
|
||||
column.setColumnModifier(columnModifier);
|
||||
column.setColumnOrder(columnOrder);
|
||||
column.setIsShown(Boolean.FALSE);
|
||||
metaDataColumnRepository.save(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.setColumnSyncName(fields.get("column_sync_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;
|
||||
case "column_sync_name":
|
||||
status.append(metaDataColumn.updateColumnSyncName(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,76 +0,0 @@
|
||||
package de.thpeetz.kontor.admin.services;
|
||||
|
||||
import de.thpeetz.kontor.admin.data.ModuleData;
|
||||
import de.thpeetz.kontor.admin.repository.ModuleDataRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ModuleService {
|
||||
|
||||
private final ModuleDataRepository moduleDataRepository;
|
||||
|
||||
public ModuleService(ModuleDataRepository moduleDataRepository) {
|
||||
this.moduleDataRepository = moduleDataRepository;
|
||||
}
|
||||
|
||||
public List<ModuleData> findAll(String stringFilter) {
|
||||
if (stringFilter == null || stringFilter.isEmpty()) {
|
||||
return moduleDataRepository.findAll();
|
||||
} else {
|
||||
return moduleDataRepository.search(stringFilter);
|
||||
}
|
||||
}
|
||||
|
||||
public ModuleData findByName(String moduleName) {
|
||||
if (moduleName == null || moduleName.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return moduleDataRepository.findByModuleName(moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean importData(String moduleName) {
|
||||
ModuleData module = moduleDataRepository.findByModuleName(moduleName);
|
||||
if (module != null) {
|
||||
return module.getImportData();
|
||||
} else {
|
||||
log.info("Module {} not found, should import data", moduleName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDataImported(String moduleName) {
|
||||
ModuleData module = moduleDataRepository.findByModuleName(moduleName);
|
||||
if (module == null) {
|
||||
log.info("Module {} not found, will create it", moduleName);
|
||||
module = new ModuleData();
|
||||
module.setModuleName(moduleName);
|
||||
module.setImportData(false);
|
||||
moduleDataRepository.save(module);
|
||||
} else {
|
||||
log.info("Module {} found, change import data", module);
|
||||
module.setImportData(false);
|
||||
moduleDataRepository.save(module);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveModuleData(ModuleData moduleData) {
|
||||
if (moduleData == null) {
|
||||
log.warn("ModuleData is null, can't save it.");
|
||||
} else {
|
||||
moduleDataRepository.save(moduleData);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteModuleData(ModuleData moduleData) {
|
||||
if (moduleData == null) {
|
||||
log.warn("ModuleData is null, can't delete it.");
|
||||
} else {
|
||||
moduleDataRepository.delete(moduleData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,123 +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 java.util.List;
|
||||
|
||||
public class MetaDataForm extends FormLayout {
|
||||
|
||||
ComboBox<MetaDataTable> table = new ComboBox<>("Table");
|
||||
TextField columnName = new TextField("Column Name");
|
||||
TextField columnSyncName = new TextField("Column Sync Name");
|
||||
TextField columnModifier = new TextField("Column Modifier");
|
||||
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, columnSyncName, columnModifier, 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);
|
||||
}
|
||||
|
||||
public abstract static class MetaDataFormEvent extends ComponentEvent<MetaDataForm> {
|
||||
private MetaDataColumn metaDataColumn;
|
||||
|
||||
protected MetaDataFormEvent(MetaDataForm source, MetaDataColumn metaDataColumn) {
|
||||
super(source, false);
|
||||
this.metaDataColumn = metaDataColumn;
|
||||
}
|
||||
|
||||
public MetaDataColumn getMetaDataColumn() {
|
||||
return 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,193 +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.contextmenu.ContextMenu;
|
||||
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||
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> columnSyncNameColumn = grid.addColumn(MetaDataColumn::getColumnSyncName)
|
||||
.setHeader("Column Sync Name").setResizable(true).setSortable(true);
|
||||
Grid.Column<MetaDataColumn> columnTypeColumn = grid.addColumn(MetaDataColumn::getColumnType)
|
||||
.setHeader("Column Type").setResizable(true).setSortable(true);
|
||||
Grid.Column<MetaDataColumn> columnModifierColumn = grid.addColumn(MetaDataColumn::getColumnModifier)
|
||||
.setHeader("Column Modifier").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(columnSyncNameColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(columnTypeColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(columnModifierColumn);
|
||||
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,100 +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.formlayout.FormLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
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.ModuleData;
|
||||
|
||||
public class ModuleDataForm extends FormLayout {
|
||||
TextField moduleName = new TextField("Module Name");
|
||||
Checkbox importData = new Checkbox("Import Data");
|
||||
|
||||
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<ModuleData> binder = new BeanValidationBinder<>(ModuleData.class);
|
||||
|
||||
public ModuleDataForm() {
|
||||
addClassName("moduleData-form");
|
||||
binder.bindInstanceFields(this);
|
||||
add(moduleName, importData, 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 ModuleDataForm.DeleteEvent(this, binder.getBean())));
|
||||
close.addClickListener(event -> fireEvent(new ModuleDataForm.CloseEvent(this)));
|
||||
|
||||
binder.addStatusChangeListener(e -> save.setEnabled(binder.isValid()));
|
||||
return new HorizontalLayout(save, delete, close);
|
||||
}
|
||||
|
||||
private void validateAndSave() {
|
||||
if (binder.isValid()) {
|
||||
fireEvent(new ModuleDataForm.SaveEvent(this, binder.getBean()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setModuleData(ModuleData moduleData) {
|
||||
binder.setBean(moduleData);
|
||||
}
|
||||
|
||||
public abstract static class ModuleDataFormEvent extends ComponentEvent<ModuleDataForm> {
|
||||
private ModuleData moduleData;
|
||||
|
||||
protected ModuleDataFormEvent(ModuleDataForm source, ModuleData moduleData) {
|
||||
super(source, false);
|
||||
this.moduleData = moduleData;
|
||||
}
|
||||
|
||||
public ModuleData getModuleData() {
|
||||
return moduleData;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SaveEvent extends ModuleDataForm.ModuleDataFormEvent {
|
||||
SaveEvent(ModuleDataForm source, ModuleData moduleData) {
|
||||
super(source, moduleData);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DeleteEvent extends ModuleDataForm.ModuleDataFormEvent {
|
||||
DeleteEvent(ModuleDataForm source, ModuleData moduleData) {
|
||||
super(source, moduleData);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CloseEvent extends ModuleDataForm.ModuleDataFormEvent {
|
||||
CloseEvent(ModuleDataForm source) {
|
||||
super(source, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void addDeleteListener(ComponentEventListener<ModuleDataForm.DeleteEvent> listener) {
|
||||
addListener(ModuleDataForm.DeleteEvent.class, listener);
|
||||
}
|
||||
|
||||
public void addSaveListener(ComponentEventListener<ModuleDataForm.SaveEvent> listener) {
|
||||
addListener(ModuleDataForm.SaveEvent.class, listener);
|
||||
}
|
||||
|
||||
public void addCloseListener(ComponentEventListener<ModuleDataForm.CloseEvent> listener) {
|
||||
addListener(ModuleDataForm.CloseEvent.class, listener);
|
||||
}
|
||||
}
|
||||
@@ -1,140 +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.contextmenu.ContextMenu;
|
||||
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
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.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.data.ModuleData;
|
||||
import de.thpeetz.kontor.admin.services.ModuleService;
|
||||
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;
|
||||
|
||||
@Slf4j
|
||||
@SpringComponent
|
||||
@Scope("prototype")
|
||||
@RolesAllowed("ROLE_ADMIN")
|
||||
@Route(value = "admin/module", layout = MainLayout.class)
|
||||
@PageTitle("Module Data | Admin | Kontor")
|
||||
public class ModuleDataView extends VerticalLayout {
|
||||
|
||||
Grid<ModuleData> grid = new Grid<>(ModuleData.class, false);
|
||||
Grid.Column<ModuleData> idColumn = grid.addColumn(ModuleData::getId)
|
||||
.setHeader("ID").setResizable(true).setSortable(true);
|
||||
Grid.Column<ModuleData> nameColumn = grid.addColumn(ModuleData::getModuleName)
|
||||
.setHeader("Name").setResizable(true).setSortable(true);
|
||||
Grid.Column<ModuleData> importColumn = grid.addComponentColumn(moduleData -> StatusIcon.create(moduleData.getImportData()))
|
||||
.setHeader("Import Data").setWidth("6rem").setSortable(true);
|
||||
|
||||
TextField filterText = new TextField();
|
||||
@Getter
|
||||
ModuleDataForm form;
|
||||
ModuleService service;
|
||||
|
||||
public ModuleDataView(ModuleService service) {
|
||||
this.service = service;
|
||||
addClassName("moduleData-view");
|
||||
setSizeFull();
|
||||
configureGrid();
|
||||
configureForm();
|
||||
|
||||
add(getToolbar(), getContent());
|
||||
updateList();
|
||||
}
|
||||
|
||||
private void configureGrid() {
|
||||
grid.addClassName("moduleData-grid");
|
||||
grid.setSizeFull();
|
||||
grid.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||
grid.asSingleSelect().addValueChangeListener(event -> editModuleData(event.getValue()));
|
||||
}
|
||||
|
||||
private void configureForm() {
|
||||
form = new ModuleDataForm();
|
||||
form.setWidth("25em");
|
||||
form.setVisible(false);
|
||||
form.addSaveListener(this::saveModuleData);
|
||||
form.addDeleteListener(this::deleteModuleData);
|
||||
form.addCloseListener(e -> closeEditor());
|
||||
}
|
||||
|
||||
private void saveModuleData(ModuleDataForm.SaveEvent event) {
|
||||
ModuleData moduleData = event.getModuleData();
|
||||
service.saveModuleData(moduleData);
|
||||
updateList();
|
||||
closeEditor();
|
||||
}
|
||||
|
||||
private void deleteModuleData(ModuleDataForm.DeleteEvent event) {
|
||||
service.deleteModuleData(event.getModuleData());
|
||||
updateList();
|
||||
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() {
|
||||
filterText.setPlaceholder("Filter by module name...");
|
||||
filterText.setClearButtonVisible(true);
|
||||
filterText.setValueChangeMode(ValueChangeMode.LAZY);
|
||||
filterText.addValueChangeListener(e -> updateList());
|
||||
Button addModuleDataButton = new Button("Add module", click -> addModuleData());
|
||||
|
||||
Button menuButton = new Button("Show/Hide Columns");
|
||||
menuButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
ColumnToggleContextMenu<ModuleData> columnToggleContextMenu = new ColumnToggleContextMenu<>(menuButton);
|
||||
columnToggleContextMenu.addColumnToggleItem(idColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(nameColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(importColumn);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addModuleDataButton, menuButton);
|
||||
toolbar.addClassName("toolbar");
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
public void editModuleData(ModuleData moduleData) {
|
||||
if (moduleData == null) {
|
||||
closeEditor();
|
||||
} else {
|
||||
form.setModuleData(moduleData);
|
||||
form.setVisible(true);
|
||||
addClassName("editing");
|
||||
}
|
||||
}
|
||||
|
||||
public void closeEditor() {
|
||||
form.setModuleData(null);
|
||||
form.setVisible(false);
|
||||
removeClassName("editing");
|
||||
}
|
||||
|
||||
private void addModuleData() {
|
||||
grid.asSingleSelect().clear();
|
||||
editModuleData(new ModuleData());
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
grid.setItems(service.findAll(filterText.getValue()));
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import de.thpeetz.kontor.admin.services.ModuleService;
|
||||
import de.thpeetz.kontor.bookshelf.data.ArticleAuthorRepository;
|
||||
import de.thpeetz.kontor.bookshelf.data.Author;
|
||||
import de.thpeetz.kontor.bookshelf.data.AuthorRepository;
|
||||
@@ -36,47 +35,12 @@ public class SetupModuleBookshelf implements ApplicationListener<ContextRefreshe
|
||||
@Autowired
|
||||
private BookAuthorRepository bookAuthorRepository;
|
||||
|
||||
@Autowired
|
||||
private ModuleService moduleService;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
if (alreadySetup) {
|
||||
log.info("SetupModuleBookshelf already executed, skipping");
|
||||
return;
|
||||
}
|
||||
if (!moduleService.importData(BookshelfConstants.BOOKSHELF)) {
|
||||
log.info("Module Bookshelf should not setup data");
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("Set up Bookshelf data");
|
||||
Author douglasadams = createAuthorIfNotFound("Douglas", "Adams");
|
||||
moduleService.setDataImported(BookshelfConstants.BOOKSHELF);
|
||||
}
|
||||
|
||||
private Author createAuthorIfNotFound(String firstName, String lastName) {
|
||||
log.info("createAuthorIfNotFound {} {}", firstName, lastName);
|
||||
Author author = authorRepository.findByFirstNameAndLastName(firstName, lastName);
|
||||
if (author == null) {
|
||||
log.info("Author {} {} not found, will create it", firstName, lastName);
|
||||
author = new Author();
|
||||
author.setFirstName(firstName);
|
||||
author.setLastName(lastName);
|
||||
authorRepository.save(author);
|
||||
}
|
||||
return author;
|
||||
}
|
||||
|
||||
private BookshelfPublisher createPublisherIfNotFound(String publisherName) {
|
||||
log.info("createPublisherIfNotFound {}", publisherName);
|
||||
BookshelfPublisher publisher = publisherRepository.findByName(publisherName);
|
||||
if (publisher == null) {
|
||||
log.info("Publisher {} not found, will create it", publisherName);
|
||||
publisher = new BookshelfPublisher();
|
||||
publisher.setName(publisherName);
|
||||
publisherRepository.save(publisher);
|
||||
}
|
||||
return publisher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import de.thpeetz.kontor.comics.views.ArtistView;
|
||||
import de.thpeetz.kontor.comics.views.ComicView;
|
||||
import de.thpeetz.kontor.comics.views.ComicWorkView;
|
||||
import de.thpeetz.kontor.comics.views.IssueView;
|
||||
import de.thpeetz.kontor.comics.views.IssueWorkView;
|
||||
import de.thpeetz.kontor.comics.views.PublisherView;
|
||||
import de.thpeetz.kontor.comics.views.StoryArcView;
|
||||
import de.thpeetz.kontor.comics.views.TradePaperbackView;
|
||||
@@ -25,7 +26,9 @@ public class ComicConstants {
|
||||
public static final String PUBLISHER = "Publisher";
|
||||
public static final String PUBLISHER_ROUTE = "comics/publisher";
|
||||
public static final String COMICWORK = "ComicWork";
|
||||
public static final String ISSUEWORK = "IssueWork";
|
||||
public static final String COMICWORK_ROUTE = "comics/comicwork";
|
||||
public static final String ISSUEWORK_ROUTE = "comics/issuework";
|
||||
public static final String WORKTYPE = "Worktype";
|
||||
public static final String WORKTYPE_ROUTE = "comics/worktype";
|
||||
public static final String ARTIST = "Artist";
|
||||
@@ -55,6 +58,10 @@ public class ComicConstants {
|
||||
return new RouterLink(COMICWORK, ComicWorkView.class);
|
||||
}
|
||||
|
||||
public static RouterLink getIssueWorkLink() {
|
||||
return new RouterLink(ISSUEWORK, IssueWorkView.class);
|
||||
}
|
||||
|
||||
public static RouterLink getIssueLink() {
|
||||
return new RouterLink(ISSUE, IssueView.class);
|
||||
}
|
||||
@@ -84,6 +91,7 @@ public class ComicConstants {
|
||||
comics.addItem(new SideNavItem(TPB, TradePaperbackView.class));
|
||||
comics.addItem(new SideNavItem(STORYARC, StoryArcView.class));
|
||||
comics.addItem(new SideNavItem(VOLUME, VolumeView.class));
|
||||
comics.addItem(new SideNavItem(WORKTYPE, WorktypeView.class));
|
||||
return comics;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,6 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@@ -31,10 +30,16 @@ public class Artist extends AbstractEntity {
|
||||
@Column(unique = true)
|
||||
private String name;
|
||||
|
||||
private String weblink;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "artist", cascade = CascadeType.REFRESH, orphanRemoval = true)
|
||||
@Nullable
|
||||
List<ComicWork> comicWorks = new LinkedList<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "artist", cascade = CascadeType.REFRESH, orphanRemoval = true)
|
||||
@Nullable
|
||||
List<IssueWork> issueWorks = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("Artist{");
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import de.thpeetz.kontor.common.data.AbstractEntity;
|
||||
import io.micrometer.common.lang.Nullable;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -19,7 +19,6 @@ import jakarta.validation.constraints.NotNull;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* Represents a comic entity.
|
||||
@@ -44,6 +43,9 @@ public class Comic extends AbstractEntity {
|
||||
|
||||
private Boolean completed = false;
|
||||
|
||||
@Nullable
|
||||
private String weblink;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "comic", cascade = CascadeType.REFRESH, orphanRemoval = true)
|
||||
@Nullable
|
||||
List<ComicWork> comicWorks;
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface ComicRepository extends JpaRepository<Comic, String> {
|
||||
@Query("select c from Comic c " +
|
||||
"where lower(c.title) like lower(concat('%', :searchTerm, '%')) ")
|
||||
List<Comic> search(@Param("searchTerm") String searchTerm);
|
||||
|
||||
Comic findByTitleAndPublisher(String title, Publisher publisher);
|
||||
|
||||
List<Comic> findByTitle(String title);
|
||||
|
||||
List<Comic> findByTitleIgnoreCase(String title);
|
||||
}
|
||||
@@ -2,21 +2,22 @@ package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import de.thpeetz.kontor.common.data.AbstractEntity;
|
||||
import io.micrometer.common.lang.Nullable;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import de.thpeetz.kontor.common.data.*;
|
||||
import io.hypersistence.utils.hibernate.type.basic.YearMonthDateType;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import java.time.YearMonth;
|
||||
import java.util.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
public class Issue extends AbstractEntity {
|
||||
@@ -33,14 +34,75 @@ public class Issue extends AbstractEntity {
|
||||
@Nullable
|
||||
private Volume volume;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "storyArc_id")
|
||||
@JsonIgnoreProperties({ "issues" })
|
||||
@Nullable
|
||||
private StoryArc storyArc;
|
||||
|
||||
@NotEmpty
|
||||
private String issueNumber;
|
||||
|
||||
@Nullable
|
||||
private String title;
|
||||
|
||||
@Nullable
|
||||
@Type(YearMonthDateType.class)
|
||||
@Column(name = "published_on", columnDefinition = "date")
|
||||
private YearMonth publishedOn;
|
||||
|
||||
private Boolean isRead;
|
||||
|
||||
private Boolean inStock;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "issue", cascade = CascadeType.REFRESH, orphanRemoval = true)
|
||||
@Nullable
|
||||
List<IssueWork> issueWorks;
|
||||
|
||||
public String getComicTitle() {
|
||||
return comic.getTitle();
|
||||
}
|
||||
|
||||
public String getVolumeName() {
|
||||
if (volume != null) {
|
||||
return volume.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getFullTitle() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(this.getComic().getTitle());
|
||||
stringBuilder.append(" #");
|
||||
stringBuilder.append(this.getIssueNumber());
|
||||
if (this.title !=null && !this.title.isEmpty()) {
|
||||
stringBuilder.append(": ");
|
||||
stringBuilder.append(this.title);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("Issue{");
|
||||
result.append("comic=");
|
||||
result.append(comic);
|
||||
result.append(", volume=");
|
||||
result.append(volume);
|
||||
result.append(", storyArc=");
|
||||
result.append(storyArc);
|
||||
result.append(", issueNumber='");
|
||||
result.append(issueNumber);
|
||||
result.append(", title='");
|
||||
result.append(title);
|
||||
result.append(", publishedOn=");
|
||||
result.append(publishedOn);
|
||||
result.append(", isRead=");
|
||||
result.append(isRead);
|
||||
result.append(", inStock=");
|
||||
result.append(inStock);
|
||||
result.append("}");
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import de.thpeetz.kontor.common.data.AbstractEntity;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Index;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(indexes = {@Index(columnList = "issue_id, artist_id, workType_id") },
|
||||
uniqueConstraints = @UniqueConstraint(columnNames = {"issue_id", "artist_id", "workType_id" })
|
||||
)
|
||||
public class IssueWork extends AbstractEntity {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "issue_id")
|
||||
@NotNull
|
||||
private Issue issue;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "artist_id")
|
||||
@NotNull
|
||||
private Artist artist;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "workType_id")
|
||||
@NotNull
|
||||
private Worktype workType;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("IssueWork{");
|
||||
sb.append("issue=").append(issue);
|
||||
sb.append(", artist=").append(artist);
|
||||
sb.append(", workType=").append(workType);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,21 @@ package de.thpeetz.kontor.comics.data;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import de.thpeetz.kontor.common.data.AbstractEntity;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -26,10 +29,30 @@ public class Publisher extends AbstractEntity {
|
||||
@Column(unique = true)
|
||||
private String name;
|
||||
|
||||
private String weblink;
|
||||
|
||||
@JsonBackReference
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "parent_publisher_id")
|
||||
@Nullable
|
||||
@JsonIgnoreProperties({ "comics" })
|
||||
private Publisher parentCompany;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "parentCompany", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@Nullable
|
||||
private List<Publisher> imprints = new LinkedList<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "publisher", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@Nullable
|
||||
private List<Comic> comics = new LinkedList<>();
|
||||
|
||||
public String getParentCompanyName() {
|
||||
if (parentCompany != null) {
|
||||
return parentCompany.name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("Publisher{");
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import jakarta.annotation.Nullable;
|
||||
import de.thpeetz.kontor.common.data.AbstractEntity;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -13,6 +16,8 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@@ -28,4 +33,14 @@ public class StoryArc extends AbstractEntity {
|
||||
@NotNull
|
||||
@JsonIgnoreProperties({ "storyArcs" })
|
||||
private Comic comic;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "volume_id")
|
||||
@JsonIgnoreProperties({ "storyArcs" })
|
||||
@Nullable
|
||||
private Volume volume;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "storyArc", cascade = CascadeType.REMOVE, orphanRemoval = true)
|
||||
@Nullable
|
||||
private List<Issue> issues = new LinkedList<>();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import de.thpeetz.kontor.common.data.AbstractEntity;
|
||||
import io.micrometer.common.lang.Nullable;
|
||||
import jakarta.annotation.*;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
@@ -18,11 +18,9 @@ import jakarta.validation.constraints.NotNull;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
public class Volume extends AbstractEntity {
|
||||
@@ -36,7 +34,22 @@ public class Volume extends AbstractEntity {
|
||||
@JsonIgnoreProperties({ "volumes" })
|
||||
private Comic comic;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "volume", cascade = CascadeType.REMOVE, orphanRemoval = true)
|
||||
@Nullable
|
||||
private List<StoryArc> storyArcs = new LinkedList<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "volume", cascade = CascadeType.REMOVE, orphanRemoval = true)
|
||||
@Nullable
|
||||
private List<Issue> issues = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder result = new StringBuilder("Volume{");
|
||||
result.append("name=");
|
||||
result.append(name);
|
||||
result.append("comic=Comic{title=");
|
||||
result.append(comic.getTitle());
|
||||
result.append("}}");
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* Represents a work type in the application.
|
||||
@@ -34,6 +33,10 @@ public class Worktype extends AbstractEntity {
|
||||
@Nullable
|
||||
List<ComicWork> comicWorks = new LinkedList<>();
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "workType", cascade = CascadeType.REFRESH, orphanRemoval = true)
|
||||
@Nullable
|
||||
List<IssueWork> issueWorks = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("Worktype{");
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
@@ -0,0 +1,39 @@
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface ComicRepository extends JpaRepository<Comic, String> {
|
||||
@Query("select c from Comic c " +
|
||||
"where lower(c.title) like lower(concat('%', :searchTerm, '%')) ")
|
||||
List<Comic> search(@Param("searchTerm") String searchTerm);
|
||||
|
||||
@Query("select c from Comic c " +
|
||||
"where lower(c.title) like lower(concat('%', :searchTerm, '%')) " +
|
||||
"AND c.currentOrder=:currentOrder AND c.completed=:completed")
|
||||
List<Comic> search(@Param("searchTerm") String searchTerm, Boolean currentOrder, Boolean completed);
|
||||
|
||||
Comic findByTitleAndPublisher(String title, Publisher publisher);
|
||||
|
||||
List<Comic> findByTitle(String title);
|
||||
|
||||
List<Comic> findByTitleIgnoreCase(String title);
|
||||
|
||||
List<Comic> findByCurrentOrderAndCompleted(Boolean currentOrder, Boolean completed);
|
||||
|
||||
List<Comic> findByCurrentOrder(Boolean currentOrder);
|
||||
|
||||
List<Comic> findByCompleted(Boolean completed);
|
||||
|
||||
@Query("select c from Comic c " +
|
||||
"where lower(c.title) like lower(concat('%', :searchTerm, '%')) AND c.currentOrder=:currentOrder")
|
||||
List<Comic> searchAndFilterByCurrentOrder(String searchTerm, Boolean currentOrder);
|
||||
|
||||
@Query("select c from Comic c " +
|
||||
"where lower(c.title) like lower(concat('%', :searchTerm, '%')) AND c.completed=:completed")
|
||||
List<Comic> searchAndFilterByCompleted(String searchTerm, Boolean completed);
|
||||
}
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.springframework.data.jpa.repository.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface IssueWorkRepository extends JpaRepository<IssueWork, String> {
|
||||
|
||||
@Query("SELECT i from IssueWork i where i.issue = ?1 and i.artist = ?2 and i.workType = ?3")
|
||||
IssueWork findbyIssueAndArtistAndWorktype(Issue issue, Artist artist, Worktype worktype);
|
||||
|
||||
@Query("select i from IssueWork i where i.issue = ?1")
|
||||
List<IssueWork> findByIssue(Issue issue);
|
||||
}
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface VolumeRepository extends JpaRepository<Volume, String> {
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
@@ -2,26 +2,12 @@ package de.thpeetz.kontor.comics.services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import de.thpeetz.kontor.comics.repository.*;
|
||||
import de.thpeetz.kontor.common.views.FilterOption;
|
||||
import de.thpeetz.kontor.common.views.SearchFilter;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.Artist;
|
||||
import de.thpeetz.kontor.comics.data.ArtistRepository;
|
||||
import de.thpeetz.kontor.comics.data.Comic;
|
||||
import de.thpeetz.kontor.comics.data.ComicRepository;
|
||||
import de.thpeetz.kontor.comics.data.ComicWork;
|
||||
import de.thpeetz.kontor.comics.data.ComicWorkRepository;
|
||||
import de.thpeetz.kontor.comics.data.Issue;
|
||||
import de.thpeetz.kontor.comics.data.IssueRepository;
|
||||
import de.thpeetz.kontor.comics.data.Publisher;
|
||||
import de.thpeetz.kontor.comics.data.PublisherRepository;
|
||||
import de.thpeetz.kontor.comics.data.StoryArc;
|
||||
import de.thpeetz.kontor.comics.data.StoryArcRepository;
|
||||
import de.thpeetz.kontor.comics.data.TradePaperback;
|
||||
import de.thpeetz.kontor.comics.data.TradePaperbackRepository;
|
||||
import de.thpeetz.kontor.comics.data.Volume;
|
||||
import de.thpeetz.kontor.comics.data.VolumeRepository;
|
||||
import de.thpeetz.kontor.comics.data.Worktype;
|
||||
import de.thpeetz.kontor.comics.data.WorktypeRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@@ -35,12 +21,13 @@ public class ComicService {
|
||||
private final StoryArcRepository storyArcRepository;
|
||||
private final TradePaperbackRepository tradePaperbackRepository;
|
||||
private final ComicWorkRepository comicWorkRepository;
|
||||
private final IssueWorkRepository issueWorkRepository;
|
||||
private final VolumeRepository volumeRepository;
|
||||
private final WorktypeRepository worktypeRepository;
|
||||
|
||||
public ComicService(PublisherRepository publisherRepository, ComicRepository comicRepository,
|
||||
ArtistRepository artistRepository, IssueRepository issueRepository, StoryArcRepository storyArcRepository,
|
||||
TradePaperbackRepository tradePaperbackRepository, ComicWorkRepository comicWorkRepository,
|
||||
TradePaperbackRepository tradePaperbackRepository, ComicWorkRepository comicWorkRepository, IssueWorkRepository issueWorkRepository,
|
||||
VolumeRepository volumeRepository, WorktypeRepository worktypeRepository) {
|
||||
|
||||
this.publisherRepository = publisherRepository;
|
||||
@@ -50,6 +37,7 @@ public class ComicService {
|
||||
this.storyArcRepository = storyArcRepository;
|
||||
this.tradePaperbackRepository = tradePaperbackRepository;
|
||||
this.comicWorkRepository = comicWorkRepository;
|
||||
this.issueWorkRepository = issueWorkRepository;
|
||||
this.volumeRepository = volumeRepository;
|
||||
this.worktypeRepository = worktypeRepository;
|
||||
}
|
||||
@@ -85,6 +73,38 @@ public class ComicService {
|
||||
return comicRepository.search(stringFilter);
|
||||
}
|
||||
}
|
||||
public List<Comic> findAllComicsByFilter(SearchFilter searchFilter) {
|
||||
if (searchFilter == null) return comicRepository.findAll();
|
||||
if (searchFilter.getFilterOptions().isEmpty()) return comicRepository.search(searchFilter.getSearchTerm());
|
||||
if (searchFilter.getFilterOptions().size() == 1) {
|
||||
FilterOption option = searchFilter.getFilterOptions().getFirst();
|
||||
if (searchFilter.getSearchTerm() != null && !searchFilter.getSearchTerm().isEmpty()) {
|
||||
switch (option.getName()) {
|
||||
case "Bestellung":
|
||||
return comicRepository.searchAndFilterByCurrentOrder(searchFilter.getSearchTerm(), option.getValue());
|
||||
case "Abgeschlossen":
|
||||
return comicRepository.searchAndFilterByCompleted(searchFilter.getSearchTerm(), option.getValue());
|
||||
}
|
||||
}
|
||||
switch (option.getName()) {
|
||||
case "Bestellung":
|
||||
return comicRepository.findByCurrentOrder(option.getValue());
|
||||
case "Abgeschlossen":
|
||||
return comicRepository.findByCompleted(option.getValue());
|
||||
}
|
||||
}
|
||||
if (searchFilter.getFilterOptions().size() == 2) {
|
||||
if (searchFilter.getSearchTerm() != null && !searchFilter.getSearchTerm().isEmpty()) {
|
||||
return comicRepository.search(searchFilter.getSearchTerm(),
|
||||
searchFilter.getFilter("Bestellung").getValue(),
|
||||
searchFilter.getFilter("Abgeschlossen").getValue());
|
||||
}
|
||||
return comicRepository.findByCurrentOrderAndCompleted(searchFilter.getFilter("Bestellung").getValue(),
|
||||
searchFilter.getFilter("Abgeschlossen").getValue());
|
||||
}
|
||||
return comicRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
public Comic findComicByTitle(String title) {
|
||||
List<Comic> comics = comicRepository.findByTitle(title);
|
||||
@@ -231,6 +251,31 @@ public class ComicService {
|
||||
comicWorkRepository.delete(comicWork);
|
||||
}
|
||||
|
||||
public List<IssueWork> findAllIssueWorks() {
|
||||
return issueWorkRepository.findAll();
|
||||
}
|
||||
|
||||
public void saveIssueWork(IssueWork issueWork) {
|
||||
if (issueWork == null) {
|
||||
log.warn("IssueWork is null. Are you sure you have connected your form to the application?");
|
||||
return;
|
||||
}
|
||||
issueWorkRepository.save(issueWork);
|
||||
}
|
||||
|
||||
public void deleteIssueWork(IssueWork issueWork) {
|
||||
Issue issue = issueWork.getIssue();
|
||||
issue.getIssueWorks().remove(issueWork);
|
||||
issueRepository.save(issue);
|
||||
Artist artist = issueWork.getArtist();
|
||||
artist.getIssueWorks().remove(issueWork);
|
||||
artistRepository.save(artist);
|
||||
Worktype worktype = issueWork.getWorkType();
|
||||
worktype.getIssueWorks().remove(issueWork);
|
||||
worktypeRepository.save(worktype);
|
||||
issueWorkRepository.delete(issueWork);
|
||||
}
|
||||
|
||||
public List<Volume> findAllVolumes() {
|
||||
return volumeRepository.findAll();
|
||||
}
|
||||
@@ -285,14 +330,23 @@ public class ComicService {
|
||||
|
||||
public void deleteWorktype(Worktype worktype) {
|
||||
List<ComicWork> comicWorks = worktype.getComicWorks();
|
||||
List<IssueWork> issueWorks = worktype.getIssueWorks();
|
||||
if (comicWorks == null) {
|
||||
log.warn("reference to ComicWork is null");
|
||||
return;
|
||||
} else {
|
||||
log.info("found {} references to ComicWork", comicWorks.size());
|
||||
comicWorks.forEach(comicWork -> {
|
||||
comicWork.setWorkType(null);
|
||||
});
|
||||
}
|
||||
if (issueWorks == null) {
|
||||
log.warn("reference to ComicWork is null");
|
||||
} else {
|
||||
log.info("found {} references to IssueWork", issueWorks.size());
|
||||
issueWorks.forEach(issueWork -> {
|
||||
issueWork.setWorkType(null);
|
||||
});
|
||||
}
|
||||
log.info("found {} references to ComicWork", comicWorks.size());
|
||||
comicWorks.forEach(comicWork -> {
|
||||
comicWork.setWorkType(null);
|
||||
});
|
||||
log.info("delete Worktype: {}", worktype);
|
||||
worktypeRepository.delete(worktype);
|
||||
}
|
||||
|
||||
@@ -16,12 +16,14 @@ import com.vaadin.flow.data.binder.Binder;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.Artist;
|
||||
import de.thpeetz.kontor.comics.data.ComicWork;
|
||||
import lombok.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class ArtistForm extends FormLayout {
|
||||
|
||||
TextField name = new TextField("Name");
|
||||
TextField weblink = new TextField("Link");
|
||||
Grid<ComicWork> comicWorks = new Grid<>(ComicWork.class);
|
||||
|
||||
Button save = new Button("Save");
|
||||
@@ -38,7 +40,7 @@ public class ArtistForm extends FormLayout {
|
||||
comicWorks.getColumnByKey("workType.name").setHeader("Work type");
|
||||
comicWorks.getColumnByKey("comic.title").setHeader("Comic");
|
||||
comicWorks.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||
add(name, comicWorks, createButtonsLayout());
|
||||
add(name, weblink, comicWorks, createButtonsLayout());
|
||||
}
|
||||
|
||||
private HorizontalLayout createButtonsLayout() {
|
||||
@@ -72,17 +74,15 @@ public class ArtistForm extends FormLayout {
|
||||
this.comicWorks.setItems(works);
|
||||
}
|
||||
|
||||
@Getter
|
||||
public abstract static class ArtistFormEvent extends ComponentEvent<ArtistForm> {
|
||||
private Artist artist;
|
||||
private final Artist artist;
|
||||
|
||||
protected ArtistFormEvent(ArtistForm source, Artist artist) {
|
||||
super(source, false);
|
||||
this.artist = artist;
|
||||
}
|
||||
|
||||
public Artist getArtist() {
|
||||
return artist;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SaveEvent extends ArtistFormEvent {
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.thpeetz.kontor.comics.views;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -29,6 +30,7 @@ public class ComicForm extends FormLayout {
|
||||
|
||||
TextField title = new TextField("Title");
|
||||
ComboBox<Publisher> publisher = new ComboBox<>("Publisher");
|
||||
TextField weblink = new TextField("Link");
|
||||
Checkbox currentOrder = new Checkbox("Current order");
|
||||
Checkbox completed = new Checkbox("Completed");
|
||||
Grid<ComicWork> comicWorks = new Grid<>(ComicWork.class);
|
||||
@@ -51,7 +53,7 @@ public class ComicForm extends FormLayout {
|
||||
comicWorks.getColumnByKey("workType.name").setHeader("Work type");
|
||||
comicWorks.getColumnByKey("artist.name").setHeader("Artist");
|
||||
comicWorks.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||
add(title, publisher, currentOrder, completed, comicWorks, createButtonsLayout());
|
||||
add(title, publisher, weblink, currentOrder, completed, comicWorks, createButtonsLayout());
|
||||
}
|
||||
|
||||
private HorizontalLayout createButtonsLayout() {
|
||||
@@ -85,17 +87,15 @@ public class ComicForm extends FormLayout {
|
||||
comicWorks.setItems(works);
|
||||
}
|
||||
|
||||
@Getter
|
||||
public abstract static class ComicFormEvent extends ComponentEvent<ComicForm> {
|
||||
private Comic comic;
|
||||
private final Comic comic;
|
||||
|
||||
protected ComicFormEvent(ComicForm source, Comic comic) {
|
||||
super(source, false);
|
||||
this.comic = comic;
|
||||
}
|
||||
|
||||
public Comic getComic() {
|
||||
return comic;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SaveEvent extends ComicFormEvent {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package de.thpeetz.kontor.comics.views;
|
||||
|
||||
import de.thpeetz.kontor.common.views.ColumnToggleContextMenu;
|
||||
import de.thpeetz.kontor.common.views.MainLayout;
|
||||
import de.thpeetz.kontor.common.views.SearchFilterField;
|
||||
import de.thpeetz.kontor.common.views.StatusIcon;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
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.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.value.ValueChangeMode;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
@@ -19,9 +19,6 @@ import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
import de.thpeetz.kontor.comics.ComicConstants;
|
||||
import de.thpeetz.kontor.comics.data.Comic;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
import de.thpeetz.kontor.common.views.ColumnToggleContextMenu;
|
||||
import de.thpeetz.kontor.common.views.MainLayout;
|
||||
import de.thpeetz.kontor.common.views.StatusIcon;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -50,7 +47,9 @@ public class ComicView extends VerticalLayout {
|
||||
.setHeader("Bestellung").setWidth("6rem").setSortable(true);
|
||||
Grid.Column<Comic> completedColumn = grid.addComponentColumn(comic -> StatusIcon.create(comic.getCompleted()))
|
||||
.setHeader("Abgeschlossen").setWidth("6rem").setSortable(true);
|
||||
TextField filterText = new TextField();
|
||||
Grid.Column<Comic> weblinkColumn = grid.addColumn(Comic::getWeblink)
|
||||
.setHeader("Link").setResizable(true).setSortable(true);
|
||||
SearchFilterField searchFilterField = new SearchFilterField();
|
||||
@Getter
|
||||
ComicForm form;
|
||||
ComicService service;
|
||||
@@ -104,11 +103,9 @@ public class ComicView extends VerticalLayout {
|
||||
}
|
||||
|
||||
private HorizontalLayout getToolbar() {
|
||||
filterText.setPlaceholder("Filter by name...");
|
||||
filterText.setClearButtonVisible(true);
|
||||
filterText.setPrefixComponent(new Icon(VaadinIcon.SEARCH));
|
||||
filterText.setValueChangeMode(ValueChangeMode.LAZY);
|
||||
filterText.addValueChangeListener(e -> updateList());
|
||||
searchFilterField.addFilter("Bestellung");
|
||||
searchFilterField.addFilter("Abgeschlossen");
|
||||
searchFilterField.addValueChangeListener(e -> updateList());
|
||||
|
||||
Button addComicButton = new Button("Add comic");
|
||||
addComicButton.addClickListener(click -> addComic());
|
||||
@@ -123,7 +120,8 @@ public class ComicView extends VerticalLayout {
|
||||
columnToggleContextMenu.addColumnToggleItem(publisherColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(currentOrderColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(completedColumn);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addComicButton, menuButton);
|
||||
columnToggleContextMenu.addColumnToggleItem(weblinkColumn);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(searchFilterField, addComicButton, menuButton);
|
||||
toolbar.addClassName("toolbar");
|
||||
return toolbar;
|
||||
}
|
||||
@@ -156,6 +154,6 @@ public class ComicView extends VerticalLayout {
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
grid.setItems(service.findAllComics(filterText.getValue()));
|
||||
grid.setItems(service.findAllComicsByFilter(searchFilterField.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,22 +10,30 @@ 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.grid.*;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
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.comics.data.Comic;
|
||||
import de.thpeetz.kontor.comics.data.Issue;
|
||||
import de.thpeetz.kontor.comics.data.IssueWork;
|
||||
import de.thpeetz.kontor.comics.data.Volume;
|
||||
import de.thpeetz.kontor.common.views.YearMonthField;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class IssueForm extends FormLayout {
|
||||
|
||||
ComboBox<Comic> comic = new ComboBox<>("Comic");
|
||||
ComboBox<Volume> volume = new ComboBox<>("Volume");
|
||||
TextField issueNumber = new TextField("Issue number");
|
||||
TextField title = new TextField("Full Title");
|
||||
YearMonthField publishedOn = new YearMonthField();
|
||||
Checkbox isRead = new Checkbox("Read");
|
||||
Checkbox inStock = new Checkbox("In stock");
|
||||
Grid<IssueWork> issueWorks = new Grid<>(IssueWork.class);
|
||||
|
||||
Button save = new Button("Save");
|
||||
Button delete = new Button("Delete");
|
||||
@@ -33,13 +41,26 @@ public class IssueForm extends FormLayout {
|
||||
|
||||
Binder<Issue> binder = new BeanValidationBinder<>(Issue.class);
|
||||
|
||||
public IssueForm(List<Comic> comics) {
|
||||
public IssueForm(List<Comic> comics, List<Volume> volumes) {
|
||||
addClassName("issue-form");
|
||||
binder.bindInstanceFields(this);
|
||||
|
||||
comic.setItems(comics);
|
||||
comic.addValueChangeListener(event -> {
|
||||
if (event.getValue() != null) {
|
||||
volume.setItems(event.getValue().getVolumes());
|
||||
} else {
|
||||
volume.clear();
|
||||
}
|
||||
});
|
||||
comic.setItemLabelGenerator(Comic::getTitle);
|
||||
add(comic, issueNumber, isRead, inStock, createButtonsLayout());
|
||||
volume.setItems(volumes);
|
||||
volume.setItemLabelGenerator(Volume::getName);
|
||||
issueWorks.setColumns("workType.name", "artist.name");
|
||||
issueWorks.getColumnByKey("workType.name").setHeader("Work type");
|
||||
issueWorks.getColumnByKey("artist.name").setHeader("Artist");
|
||||
issueWorks.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||
add(comic, volume, issueNumber, title, publishedOn, isRead, inStock,issueWorks, createButtonsLayout());
|
||||
}
|
||||
|
||||
private HorizontalLayout createButtonsLayout() {
|
||||
@@ -65,20 +86,36 @@ public class IssueForm extends FormLayout {
|
||||
}
|
||||
|
||||
public void setIssue(Issue issue) {
|
||||
log.debug("IssueForm.setIssue: {}", issue);
|
||||
Volume issueVolume = null;
|
||||
if (issue != null) {
|
||||
issueVolume = issue.getVolume();
|
||||
}
|
||||
binder.setBean(issue);
|
||||
if (issue != null && issue.getComic() != null) {
|
||||
log.debug("populate list of volumes");
|
||||
volume.setItems(issue.getComic().getVolumes());
|
||||
log.debug("Issue.Volume= {}", issue.getVolume());
|
||||
if (issueVolume != null) {
|
||||
log.debug("Set volume {} for issue: {}", issueVolume, issue);
|
||||
volume.setValue(issueVolume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setIssueWorks(List<IssueWork> works) {
|
||||
log.info("Setting issue works: {}", works);
|
||||
issueWorks.setItems(works);
|
||||
}
|
||||
|
||||
public abstract static class IssueFormEvent extends ComponentEvent<IssueForm> {
|
||||
private Issue issue;
|
||||
@lombok.Getter
|
||||
private final Issue issue;
|
||||
|
||||
protected IssueFormEvent(IssueForm source, Issue issue) {
|
||||
super(source, false);
|
||||
this.issue = issue;
|
||||
}
|
||||
|
||||
public Issue getIssue() {
|
||||
return issue;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SaveEvent extends IssueFormEvent {
|
||||
|
||||
@@ -49,8 +49,14 @@ public class IssueView extends VerticalLayout {
|
||||
.setHeader("Version").setResizable(true).setSortable(true);
|
||||
Grid.Column<Issue> titleColumn = grid.addColumn(Issue::getComicTitle)
|
||||
.setHeader("Comic").setResizable(true).setSortable(true);
|
||||
Grid.Column<Issue> volumeColumn = grid.addColumn(Issue::getVolumeName)
|
||||
.setHeader("Volume").setResizable(true).setSortable(true);
|
||||
Grid.Column<Issue> issueNumberColumn = grid.addColumn(Issue::getIssueNumber)
|
||||
.setHeader("Heft Nummer").setResizable(true).setSortable(true);
|
||||
Grid.Column<Issue> issueTitleColumn = grid.addColumn(Issue::getTitle)
|
||||
.setHeader("Full Title").setResizable(true).setSortable(true);
|
||||
Grid.Column<Issue> publishedOncolumn = grid.addColumn(Issue::getPublishedOn)
|
||||
.setHeader("Published").setResizable(true).setSortable(true);
|
||||
Grid.Column<Issue> isReadColumn = grid.addComponentColumn(issueColumn -> StatusIcon.create(issueColumn.getIsRead()))
|
||||
.setHeader("Gelesen?").setWidth("6rem").setSortable(true);
|
||||
Grid.Column<Issue> inStockColumn = grid.addComponentColumn(issueColumn -> StatusIcon.create(issueColumn.getInStock()))
|
||||
@@ -88,7 +94,7 @@ public class IssueView extends VerticalLayout {
|
||||
}
|
||||
|
||||
private void configureForm() {
|
||||
form = new IssueForm(service.findAllComics(null));
|
||||
form = new IssueForm(service.findAllComics(null), service.findAllVolumes());
|
||||
form.setWidth("25em");
|
||||
form.setVisible(false);
|
||||
form.addSaveListener(this::saveIssue);
|
||||
@@ -122,7 +128,10 @@ public class IssueView extends VerticalLayout {
|
||||
columnToggleContextMenu.addColumnToggleItem(modifiedColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(versionColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(titleColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(volumeColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(issueNumberColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(issueTitleColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(publishedOncolumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(isReadColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(inStockColumn);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(comicFilter, addIssueButton, menuButton);
|
||||
@@ -147,6 +156,12 @@ public class IssueView extends VerticalLayout {
|
||||
closeEditor();
|
||||
} else {
|
||||
form.setIssue(issue);
|
||||
if (issue.getIssueWorks() == null) {
|
||||
log.info("No issue works");
|
||||
} else {
|
||||
log.info("Issue works sze: {}", issue.getIssueWorks().size());
|
||||
}
|
||||
form.setIssueWorks(issue.getIssueWorks());
|
||||
form.setVisible(true);
|
||||
addClassName("editing");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package de.thpeetz.kontor.comics.views;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.formlayout.FormLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||
import com.vaadin.flow.data.binder.Binder;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.Artist;
|
||||
import de.thpeetz.kontor.comics.data.Comic;
|
||||
import de.thpeetz.kontor.comics.data.IssueWork;
|
||||
import de.thpeetz.kontor.comics.data.Worktype;
|
||||
import de.thpeetz.kontor.common.views.ComicIssueField;
|
||||
|
||||
public class IssueWorkForm extends FormLayout {
|
||||
ComicIssueField issue = new ComicIssueField("Issue");
|
||||
ComboBox<Artist> artist = new ComboBox<>("Artist");
|
||||
ComboBox<Worktype> workType = new ComboBox<>("Worktype");
|
||||
|
||||
Button save = new Button("Save");
|
||||
Button delete = new Button("Delete");
|
||||
Button close = new Button("Cancel");
|
||||
|
||||
Binder<IssueWork> binder = new BeanValidationBinder<>(IssueWork.class);
|
||||
|
||||
public IssueWorkForm(List<Comic> comics, List<Artist> artists, List<Worktype> workTypes) {
|
||||
addClassName("issuework-form");
|
||||
binder.bindInstanceFields(this);
|
||||
|
||||
issue.setComics(comics);
|
||||
//issue.setItems(issues);
|
||||
//issue.setItemLabelGenerator(Issue::getIssueNumber);
|
||||
artist.setItems(artists);
|
||||
artist.setItemLabelGenerator(Artist::getName);
|
||||
workType.setItems(workTypes);
|
||||
workType.setItemLabelGenerator(Worktype::getName);
|
||||
add(issue, artist, workType, 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 DeleteEvent(this, binder.getBean())));
|
||||
close.addClickListener(event -> fireEvent(new CloseEvent(this)));
|
||||
|
||||
binder.addStatusChangeListener(e -> save.setEnabled(binder.isValid()));
|
||||
return new HorizontalLayout(save, delete, close);
|
||||
}
|
||||
|
||||
private void validateAndSave() {
|
||||
if (binder.isValid()) {
|
||||
fireEvent(new SaveEvent(this, binder.getBean()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setIssueWork(IssueWork issueWork) {
|
||||
binder.setBean(issueWork);
|
||||
}
|
||||
|
||||
public abstract static class IssueWorkFormEvent extends ComponentEvent<IssueWorkForm> {
|
||||
private IssueWork issueWork;
|
||||
|
||||
protected IssueWorkFormEvent(IssueWorkForm source, IssueWork issueWork) {
|
||||
super(source, false);
|
||||
this.issueWork = issueWork;
|
||||
}
|
||||
|
||||
public IssueWork getIssueWork() {
|
||||
return issueWork;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SaveEvent extends IssueWorkFormEvent {
|
||||
SaveEvent(IssueWorkForm source, IssueWork issueWork) {
|
||||
super(source, issueWork);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DeleteEvent extends IssueWorkFormEvent {
|
||||
DeleteEvent(IssueWorkForm source, IssueWork issueWork) {
|
||||
super(source, issueWork);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CloseEvent extends IssueWorkFormEvent {
|
||||
CloseEvent(IssueWorkForm source) {
|
||||
super(source, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void addDeleteListener(ComponentEventListener<DeleteEvent> listener) {
|
||||
addListener(DeleteEvent.class, listener);
|
||||
}
|
||||
|
||||
public void addSaveListener(ComponentEventListener<SaveEvent> listener) {
|
||||
addListener(SaveEvent.class, listener);
|
||||
}
|
||||
|
||||
public void addCloseListener(ComponentEventListener<CloseEvent> listener) {
|
||||
addListener(CloseEvent.class, listener);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package de.thpeetz.kontor.comics.views;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.Issue;
|
||||
import de.thpeetz.kontor.comics.data.IssueWork;
|
||||
import lombok.Getter;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
|
||||
import de.thpeetz.kontor.comics.ComicConstants;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
import de.thpeetz.kontor.common.views.MainLayout;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
|
||||
@SpringComponent
|
||||
@Scope("prototype")
|
||||
@PermitAll
|
||||
@Route(value = ComicConstants.ISSUEWORK_ROUTE, layout = MainLayout.class)
|
||||
@PageTitle("IssueWork | Comics | Kontor")
|
||||
public class IssueWorkView extends VerticalLayout {
|
||||
|
||||
@Getter
|
||||
Grid<IssueWork> grid = new Grid<>(IssueWork.class);
|
||||
@Getter
|
||||
IssueWorkForm form;
|
||||
ComicService service;
|
||||
|
||||
public IssueWorkView(ComicService service) {
|
||||
this.service = service;
|
||||
addClassName("issueWork-view");
|
||||
setSizeFull();
|
||||
configureGrid();
|
||||
configureForm();
|
||||
|
||||
add(getToolbar(), getContent());
|
||||
updateList();
|
||||
}
|
||||
|
||||
private void configureGrid() {
|
||||
grid.addClassName("issue-grid");
|
||||
grid.setSizeFull();
|
||||
grid.setColumns("issue.fullTitle", "artist.name", "workType.name");
|
||||
grid.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||
grid.asSingleSelect().addValueChangeListener(event -> editIssueWork(event.getValue()));
|
||||
}
|
||||
|
||||
private void configureForm() {
|
||||
form = new IssueWorkForm(service.findAllComics(null), service.findAllArtists(null),
|
||||
service.findAllWorktypes(null));
|
||||
form.setWidth("25em");
|
||||
form.setVisible(false);
|
||||
form.addSaveListener(this::saveIssueWork);
|
||||
form.addDeleteListener(this::deleteIssueWork);
|
||||
form.addCloseListener(e -> closeEditor());
|
||||
}
|
||||
|
||||
private void saveIssueWork(IssueWorkForm.SaveEvent event) {
|
||||
service.saveIssueWork(event.getIssueWork());
|
||||
updateList();
|
||||
closeEditor();
|
||||
}
|
||||
|
||||
private void deleteIssueWork(IssueWorkForm.DeleteEvent event) {
|
||||
service.deleteIssueWork(event.getIssueWork());
|
||||
updateList();
|
||||
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() {
|
||||
Button addIssueButton = new Button("Add IssueWork");
|
||||
addIssueButton.addClickListener(click -> addIssueWork());
|
||||
|
||||
HorizontalLayout toolbar = new HorizontalLayout(addIssueButton);
|
||||
toolbar.addClassName("toolbar");
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
public void editIssueWork(IssueWork issueWork) {
|
||||
if (issueWork == null) {
|
||||
closeEditor();
|
||||
} else {
|
||||
form.setIssueWork(issueWork);
|
||||
form.setVisible(true);
|
||||
addClassName("editing");
|
||||
}
|
||||
}
|
||||
|
||||
private void closeEditor() {
|
||||
form.setIssueWork(null);
|
||||
form.setVisible(false);
|
||||
removeClassName("editing");
|
||||
}
|
||||
|
||||
private void addIssueWork() {
|
||||
grid.asSingleSelect().clear();
|
||||
editIssueWork(new IssueWork());
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
grid.setItems(service.findAllIssueWorks());
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ 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.combobox.*;
|
||||
import com.vaadin.flow.component.formlayout.FormLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
@@ -12,9 +13,14 @@ import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||
import com.vaadin.flow.data.binder.Binder;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.Publisher;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class PublisherForm extends FormLayout {
|
||||
public TextField name = new TextField("Name");
|
||||
public TextField weblink = new TextField("Link");
|
||||
ComboBox<Publisher> parentCompany = new ComboBox<>("Parent Company");
|
||||
|
||||
Button save = new Button("Save");
|
||||
Button delete = new Button("Delete");
|
||||
@@ -22,11 +28,13 @@ public class PublisherForm extends FormLayout {
|
||||
|
||||
Binder<Publisher> binder = new BeanValidationBinder<>(Publisher.class);
|
||||
|
||||
public PublisherForm() {
|
||||
public PublisherForm(List<Publisher> publishers) {
|
||||
addClassName("publisher-form");
|
||||
binder.bindInstanceFields(this);
|
||||
|
||||
add(name, createButtonsLayout());
|
||||
parentCompany.setItems(publishers);
|
||||
parentCompany.setItemLabelGenerator(Publisher::getName);
|
||||
add(name, weblink, parentCompany, createButtonsLayout());
|
||||
}
|
||||
|
||||
private HorizontalLayout createButtonsLayout() {
|
||||
@@ -55,17 +63,15 @@ public class PublisherForm extends FormLayout {
|
||||
binder.setBean(publisher);
|
||||
}
|
||||
|
||||
@Getter
|
||||
public abstract static class PublisherFormEvent extends ComponentEvent<PublisherForm> {
|
||||
private Publisher publisher;
|
||||
private final Publisher publisher;
|
||||
|
||||
protected PublisherFormEvent(PublisherForm source, Publisher publisher) {
|
||||
super(source, false);
|
||||
this.publisher = publisher;
|
||||
}
|
||||
|
||||
public Publisher getPublisher() {
|
||||
return publisher;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SaveEvent extends PublisherFormEvent {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package de.thpeetz.kontor.comics.views;
|
||||
|
||||
import com.vaadin.flow.component.button.*;
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import de.thpeetz.kontor.common.views.*;
|
||||
import lombok.*;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
@@ -14,9 +17,7 @@ import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
|
||||
import de.thpeetz.kontor.comics.ComicConstants;
|
||||
import de.thpeetz.kontor.comics.data.Publisher;
|
||||
import de.thpeetz.kontor.comics.services.ComicService;
|
||||
import de.thpeetz.kontor.common.views.MainLayout;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
|
||||
@SpringComponent
|
||||
@@ -26,8 +27,24 @@ import jakarta.annotation.security.PermitAll;
|
||||
@PageTitle("Publisher | Comics | Kontor")
|
||||
public class PublisherView extends VerticalLayout {
|
||||
|
||||
Grid<Publisher> grid = new Grid<>(Publisher.class);
|
||||
@Getter
|
||||
Grid<Publisher> grid = new Grid<>(Publisher.class, false);
|
||||
Grid.Column<Publisher> idColumn = grid.addColumn(Publisher::getId)
|
||||
.setHeader("ID").setResizable(true).setSortable(true);
|
||||
Grid.Column<Publisher> createdColumn = grid.addColumn(Publisher::getCreatedDate)
|
||||
.setHeader("Erstellt").setResizable(true).setSortable(true);
|
||||
Grid.Column<Publisher> modifiedColumn = grid.addColumn(Publisher::getLastModifiedDate)
|
||||
.setHeader("Geändert").setResizable(true).setSortable(true);
|
||||
Grid.Column<Publisher> nameColumn = grid.addColumn(Publisher::getName)
|
||||
.setHeader("Titel").setResizable(true).setSortable(true);
|
||||
Grid.Column<Publisher> parentCompanyColumn = grid.addColumn(Publisher::getParentCompanyName)
|
||||
.setHeader("Parent Company").setResizable(true).setSortable(true);
|
||||
Grid.Column<Publisher> imprintColumn = grid.addComponentColumn(publisher -> StatusIcon.create(publisher.getParentCompany() != null))
|
||||
.setHeader("Imprint").setWidth("6rem").setSortable(true);
|
||||
Grid.Column<Publisher> weblinkColumn = grid.addColumn(Publisher::getWeblink)
|
||||
.setHeader("Link").setResizable(true).setSortable(true);
|
||||
TextField filterText = new TextField();
|
||||
@Getter
|
||||
PublisherForm form;
|
||||
|
||||
ComicService service;
|
||||
@@ -46,13 +63,12 @@ public class PublisherView extends VerticalLayout {
|
||||
private void configureGrid() {
|
||||
grid.addClassName("publisher-grid");
|
||||
grid.setSizeFull();
|
||||
grid.setColumns("name");
|
||||
grid.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||
grid.asSingleSelect().addValueChangeListener(event -> editPublisher(event.getValue()));
|
||||
}
|
||||
|
||||
private void configureForm() {
|
||||
form = new PublisherForm();
|
||||
form = new PublisherForm(service.findAllPublishers(null));
|
||||
form.setWidth("25em");
|
||||
form.setVisible(false);
|
||||
form.addSaveListener(this::savePublisher);
|
||||
@@ -72,14 +88,6 @@ public class PublisherView extends VerticalLayout {
|
||||
closeEditor();
|
||||
}
|
||||
|
||||
public Grid<Publisher> getGrid() {
|
||||
return grid;
|
||||
}
|
||||
|
||||
public PublisherForm getForm() {
|
||||
return form;
|
||||
}
|
||||
|
||||
private Component getContent() {
|
||||
HorizontalLayout content = new HorizontalLayout(grid, form);
|
||||
content.setFlexGrow(2, grid);
|
||||
@@ -98,7 +106,17 @@ public class PublisherView extends VerticalLayout {
|
||||
Button addPublisherButton = new Button("Add publisher");
|
||||
addPublisherButton.addClickListener(click -> addPublisher());
|
||||
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addPublisherButton);
|
||||
Button menuButton = new Button("Show/Hide Columns");
|
||||
menuButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
ColumnToggleContextMenu<Publisher> columnToggleContextMenu = new ColumnToggleContextMenu<>(menuButton);
|
||||
columnToggleContextMenu.addColumnToggleItem(idColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(createdColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(modifiedColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(nameColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(parentCompanyColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(imprintColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(weblinkColumn);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addPublisherButton, menuButton);
|
||||
toolbar.addClassName("toolbar");
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.thpeetz.kontor.comics.views;
|
||||
|
||||
import lombok.*;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
import com.vaadin.flow.component.Component;
|
||||
@@ -26,8 +27,10 @@ import jakarta.annotation.security.PermitAll;
|
||||
@PageTitle("Worktype | Comics | Kontor")
|
||||
public class WorktypeView extends VerticalLayout {
|
||||
|
||||
@Getter
|
||||
Grid<Worktype> grid = new Grid<>(Worktype.class);
|
||||
TextField filterText = new TextField();
|
||||
@Getter
|
||||
WorktypeForm form;
|
||||
ComicService service;
|
||||
|
||||
@@ -42,10 +45,6 @@ public class WorktypeView extends VerticalLayout {
|
||||
updateList();
|
||||
}
|
||||
|
||||
public Grid<Worktype> getGrid() {
|
||||
return grid;
|
||||
}
|
||||
|
||||
private void configureGrid() {
|
||||
grid.addClassName("worktype-grid");
|
||||
grid.setSizeFull();
|
||||
@@ -54,13 +53,9 @@ public class WorktypeView extends VerticalLayout {
|
||||
grid.asSingleSelect().addValueChangeListener(event -> editWorktype(event.getValue()));
|
||||
}
|
||||
|
||||
public WorktypeForm getForm() {
|
||||
return form;
|
||||
}
|
||||
|
||||
private void configureForm() {
|
||||
form = new WorktypeForm();
|
||||
form.setWidth("25em");
|
||||
form.setWidth("45em");
|
||||
form.setVisible(false);
|
||||
form.addSaveListener(this::saveWorktype);
|
||||
form.addDeleteListener(this::deleteWorktype);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package de.thpeetz.kontor.common.views;
|
||||
|
||||
import com.vaadin.flow.component.Unit;
|
||||
import com.vaadin.flow.component.customfield.CustomField;
|
||||
import com.vaadin.flow.component.select.Select;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.Comic;
|
||||
import de.thpeetz.kontor.comics.data.Issue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class ComicIssueField extends CustomField<Issue> {
|
||||
|
||||
public final Select<Comic> comic = new Select<>();
|
||||
public final Select<Issue> issue = new Select<>();
|
||||
|
||||
public ComicIssueField(String caption) {
|
||||
comic.setEnabled(false);
|
||||
comic.setWidth(9, Unit.EM);
|
||||
comic.setItemLabelGenerator(Comic::getTitle);
|
||||
comic.addValueChangeListener(e -> {
|
||||
updateIssues();
|
||||
});
|
||||
issue.setEnabled(false);
|
||||
issue.setWidth(9, Unit.EM);
|
||||
issue.setItemLabelGenerator(Issue::getIssueNumber);
|
||||
add(comic, issue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Issue generateModelValue() {
|
||||
log.info("ComicIssueField.generateModelValue: {}", issue.getValue());
|
||||
return issue.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPresentationValue(Issue newPresentationValue) {
|
||||
log.info("ComicIssueField.setPresentationValue({})", newPresentationValue);
|
||||
if (newPresentationValue == null) return;
|
||||
comic.setValue(newPresentationValue.getComic());
|
||||
log.info("setPresentationValue: set Comic select = {}", comic.getValue());
|
||||
issue.setValue(newPresentationValue);
|
||||
}
|
||||
|
||||
public void setComics(List<Comic> comics) {
|
||||
log.info("ComicIssueField.setComics");
|
||||
comic.setItems(comics);
|
||||
comic.setEnabled(true);
|
||||
}
|
||||
|
||||
private void updateIssues() {
|
||||
log.info("ComicIssueField.updateIssues");
|
||||
if (comic.getValue() == null) {
|
||||
issue.setValue(null);
|
||||
issue.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
issue.setItems(comic.getValue().getIssues());
|
||||
issue.setEnabled(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package de.thpeetz.kontor.common.views;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
public class FilterOption {
|
||||
@Getter
|
||||
@Setter
|
||||
private String name;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Boolean value;
|
||||
|
||||
public FilterOption(String name, Boolean value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -19,17 +19,19 @@ import de.thpeetz.kontor.bookshelf.BookshelfConstants;
|
||||
import de.thpeetz.kontor.comics.ComicConstants;
|
||||
import de.thpeetz.kontor.security.SecurityService;
|
||||
import de.thpeetz.kontor.tysc.TyscConstants;
|
||||
import lombok.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class KontorLayoutUtil {
|
||||
|
||||
private final AppLayout appLayout;
|
||||
@Setter
|
||||
private HorizontalLayout secondaryNavigation;
|
||||
|
||||
private AdminService adminService;
|
||||
private final AdminService adminService;
|
||||
|
||||
private SecurityService securityService;
|
||||
private final SecurityService securityService;
|
||||
|
||||
public KontorLayoutUtil(AppLayout layout, AdminService adminService, SecurityService securityService) {
|
||||
this.adminService = adminService;
|
||||
@@ -37,10 +39,6 @@ public class KontorLayoutUtil {
|
||||
this.appLayout = layout;
|
||||
}
|
||||
|
||||
public void setSecondaryNavigation(HorizontalLayout secondaryNavigation) {
|
||||
this.secondaryNavigation = secondaryNavigation;
|
||||
}
|
||||
|
||||
public void createHeader(String titleName) {
|
||||
appLayout.addToDrawer(createTitle(), getScroller());
|
||||
appLayout.addToNavbar(getHeader(titleName));
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package de.thpeetz.kontor.common.views;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
public class SearchFilter {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String searchTerm;
|
||||
|
||||
@Getter
|
||||
private List<FilterOption> filterOptions = new LinkedList<>();
|
||||
|
||||
private final Map<String, FilterOption> filterMap = new HashMap<>();
|
||||
|
||||
public SearchFilter() {
|
||||
|
||||
}
|
||||
|
||||
public void addFilter(FilterOption option) {
|
||||
filterOptions.add(option);
|
||||
filterMap.put(option.getName(), option);
|
||||
}
|
||||
|
||||
public FilterOption getFilter(String optionName) {
|
||||
return filterMap.get(optionName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package de.thpeetz.kontor.common.views;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.vaadin.flow.component.combobox.MultiSelectComboBox;
|
||||
import com.vaadin.flow.component.combobox.MultiSelectComboBox.AutoExpandMode;
|
||||
import com.vaadin.flow.component.customfield.CustomField;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class SearchFilterField extends CustomField<SearchFilter> {
|
||||
|
||||
private final TextField searchField = new TextField();
|
||||
private final MultiSelectComboBox<FilterOption> filterField = new MultiSelectComboBox<>();
|
||||
private final List<FilterOption> filterOptions = new LinkedList<>();
|
||||
|
||||
public SearchFilterField() {
|
||||
searchField.setPlaceholder("Search");
|
||||
searchField.setClearButtonVisible(true);
|
||||
filterField.setPlaceholder("Filter");
|
||||
filterField.setClearButtonVisible(true);
|
||||
filterField.setItemLabelGenerator(FilterOption::getName);
|
||||
filterField.setAutoExpand(AutoExpandMode.BOTH);
|
||||
add(searchField, filterField);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SearchFilter generateModelValue() {
|
||||
SearchFilter filter = new SearchFilter();
|
||||
if (searchField.getValue() != null) {
|
||||
filter.setSearchTerm(searchField.getValue());
|
||||
}
|
||||
Set<FilterOption> filterOptions = filterField.getValue();
|
||||
for (FilterOption filterOption : filterOptions) {
|
||||
filter.addFilter(filterOption);
|
||||
}
|
||||
log.info("use searchfilter: {}", filter);
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPresentationValue(SearchFilter searchFilter) {
|
||||
log.info("display filter: {}", searchFilter);
|
||||
if (searchFilter == null) return;
|
||||
searchField.setValue(searchFilter.getSearchTerm());
|
||||
}
|
||||
|
||||
public void addFilter(String optionName) {
|
||||
FilterOption filterOption = new FilterOption(optionName, true);
|
||||
filterOptions.add(filterOption);
|
||||
filterField.setItems(filterOptions);
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,7 @@ import de.thpeetz.kontor.security.SecurityService;
|
||||
|
||||
public class SeparateMainLayout extends AppLayout {
|
||||
|
||||
private final AdminService adminService;
|
||||
|
||||
private final SecurityService securityService;
|
||||
|
||||
public SeparateMainLayout(AdminService adminService, SecurityService securityService) {
|
||||
this.adminService = adminService;
|
||||
this.securityService = securityService;
|
||||
|
||||
KontorLayoutUtil layout = new KontorLayoutUtil(this, adminService, securityService);
|
||||
layout.setSecondaryNavigation(getSecondaryNavigation());
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package de.thpeetz.kontor.common.views;
|
||||
|
||||
import com.vaadin.flow.component.Unit;
|
||||
import com.vaadin.flow.component.customfield.CustomField;
|
||||
import com.vaadin.flow.component.select.Select;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
import java.time.YearMonth;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Slf4j
|
||||
public class YearMonthField extends CustomField<YearMonth> {
|
||||
|
||||
private final Select<Integer> year = new Select<>();;
|
||||
private final Select<Month> month = new Select<>();
|
||||
|
||||
public YearMonthField() {
|
||||
LocalDate now = LocalDate.now(ZoneId.systemDefault());
|
||||
List<Integer> selectableYears = IntStream.range(1970, now.getYear()).boxed().toList();
|
||||
year.setItems(selectableYears);
|
||||
year.setWidth(6, Unit.EM);
|
||||
month.setItems(Month.values());
|
||||
month.setItemLabelGenerator(m -> m.getDisplayName(TextStyle.FULL, Locale.getDefault()));
|
||||
month.setWidth(9, Unit.EM);
|
||||
add(year, month);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected YearMonth generateModelValue() {
|
||||
if (year.getValue() != null && month.getValue() != null) {
|
||||
int yearValue = year.getValue();
|
||||
int monthValue = month.getValue().getValue();
|
||||
YearMonth result = YearMonth.of(yearValue, monthValue);
|
||||
log.debug("YearMonthField.generateModelValue() = {}", result);
|
||||
return result;
|
||||
} else {
|
||||
log.debug("YearMonthField.generateModelValue() = null");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPresentationValue(YearMonth yearMonth) {
|
||||
if (yearMonth == null) return;
|
||||
year.setValue(yearMonth.getYear());
|
||||
month.setValue(yearMonth.getMonth());
|
||||
}
|
||||
}
|
||||
-13
@@ -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:
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package de.thpeetz.kontor.integration.routes;
|
||||
|
||||
import de.thpeetz.kontor.integration.services.AddLinkProcessor;
|
||||
import de.thpeetz.kontor.media.services.MediaFileService;
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AddLinkFromQueue extends RouteBuilder {
|
||||
|
||||
@Autowired
|
||||
private final MediaFileService mediaFileService;
|
||||
|
||||
@Autowired
|
||||
public AddLinkFromQueue(MediaFileService mediaFileService) {
|
||||
this.mediaFileService = mediaFileService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
from("jms:queue:add_link_file")
|
||||
.routeId("read-queue-add-link_file")
|
||||
.log("${body}")
|
||||
.process(new AddLinkProcessor(mediaFileService))
|
||||
.to("jms:queue:update_title");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package de.thpeetz.kontor.integration.routes;
|
||||
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ReadQueueRoute extends RouteBuilder {
|
||||
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
from("jms:queue:KontorMediaFile")
|
||||
.routeId("add-link-from-queue")
|
||||
.trace(true)
|
||||
.log(">>> ${body}");
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package de.thpeetz.kontor.integration.services;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import de.thpeetz.kontor.media.data.MediaFile;
|
||||
import de.thpeetz.kontor.media.services.MediaFileService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Processor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class AddLinkProcessor implements Processor {
|
||||
|
||||
private final MediaFileService mediaFileService;
|
||||
|
||||
public AddLinkProcessor(MediaFileService mediaFileService) {
|
||||
this.mediaFileService = mediaFileService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(Exchange exchange) throws Exception {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
HashMap<String,String> myMap = objectMapper.readValue(exchange.getIn().getBody().toString(), new TypeReference<HashMap<String,String>>() {});
|
||||
String url = myMap.get("url");
|
||||
log.info("found url: {}", url);
|
||||
MediaFile mediaFile = mediaFileService.findAllMediaFilesByUrl(url);
|
||||
if (mediaFile == null) {
|
||||
log.info("URL not found, create MediaFile");
|
||||
mediaFile = new MediaFile();
|
||||
mediaFile.setUrl(url);
|
||||
mediaFile.setReview(true);
|
||||
mediaFile.setShouldDownload(true);
|
||||
MediaFile mediaFileResult = mediaFileService.saveMediaFile(mediaFile);
|
||||
log.info("created MediaFile with {}", mediaFileResult.getId());
|
||||
exchange.getMessage().getHeaders().put("mediafile_id", mediaFileResult.getId());
|
||||
}
|
||||
log.info("found MediaFile: {}", mediaFile);
|
||||
Map<String, Object> map = exchange.getMessage().getHeaders();
|
||||
log.info("Headers: {}", map);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.thpeetz.kontor.integration.services;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AddLinkService {
|
||||
|
||||
public void fromQueue(String messageBody) throws JsonProcessingException {
|
||||
log.info("get body: {}", messageBody);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
HashMap<String,String> myMap = objectMapper.readValue(messageBody, new TypeReference<HashMap<String,String>>() {});
|
||||
String url = myMap.get("url");
|
||||
log.info("found url: {}", url);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import de.thpeetz.kontor.admin.services.AdminService;
|
||||
import de.thpeetz.kontor.admin.services.ModuleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@@ -18,9 +17,6 @@ public class SetupModuleMedia implements ApplicationListener<ContextRefreshedEve
|
||||
@Autowired
|
||||
private AdminService adminService;
|
||||
|
||||
@Autowired
|
||||
private ModuleService moduleService;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
adminService.addPermission(MediaConstants.MEDIA_ROLE);
|
||||
@@ -28,12 +24,6 @@ public class SetupModuleMedia implements ApplicationListener<ContextRefreshedEve
|
||||
log.info("SetupModuleMedia already executed, skipping");
|
||||
return;
|
||||
}
|
||||
if (!moduleService.importData(MediaConstants.MEDIA)) {
|
||||
log.info("Module media should not setup data");
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("Set up Media data");
|
||||
moduleService.setDataImported(MediaConstants.MEDIA);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ public class MediaActor extends AbstractEntity {
|
||||
@Column(unique = true)
|
||||
private String name;
|
||||
|
||||
@Nullable
|
||||
private String url;
|
||||
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "media_actor", cascade = CascadeType.REFRESH, orphanRemoval = true)
|
||||
@Nullable
|
||||
List<MediaActorFile> mediaActorFiles = new LinkedList<>();
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.List;
|
||||
@Setter
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "url" }) })
|
||||
public class MediaFile extends AbstractEntity {
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package de.thpeetz.kontor.media.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface MediaFileRepository extends JpaRepository<MediaFile, String> {
|
||||
@Query("select m from MediaFile m " +
|
||||
"where lower(m.url) like lower(concat('%', :searchTerm, '%')) or lower(m.title) like lower(concat('%', :searchTerm, '%'))")
|
||||
List<MediaFile> search(@Param("searchTerm") String searchTerm);
|
||||
|
||||
}
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
package de.thpeetz.kontor.media.data;
|
||||
package de.thpeetz.kontor.media.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import de.thpeetz.kontor.media.data.MediaActorFile;
|
||||
|
||||
public interface MediaActorFileRepository extends JpaRepository<MediaActorFile, String> {
|
||||
}
|
||||
+3
-1
@@ -1,9 +1,11 @@
|
||||
package de.thpeetz.kontor.media.data;
|
||||
package de.thpeetz.kontor.media.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import de.thpeetz.kontor.media.data.MediaActor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MediaActorRepository extends JpaRepository<MediaActor, String> {
|
||||
+3
-1
@@ -1,9 +1,11 @@
|
||||
package de.thpeetz.kontor.media.data;
|
||||
package de.thpeetz.kontor.media.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import de.thpeetz.kontor.media.data.MediaArticle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MediaArticleRepository extends JpaRepository<MediaArticle, String> {
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package de.thpeetz.kontor.media.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import de.thpeetz.kontor.media.data.MediaFile;
|
||||
|
||||
public interface MediaFileRepository extends JpaRepository<MediaFile, String> {
|
||||
@Query("select m from MediaFile m " +
|
||||
"where lower(m.url) like lower(concat('%', :searchTerm, '%')) or lower(m.title) like lower(concat('%', :searchTerm, '%'))")
|
||||
List<MediaFile> search(@Param("searchTerm") String searchTerm);
|
||||
|
||||
List<MediaFile> findByShouldDownload(Boolean shouldDownload);
|
||||
|
||||
List<MediaFile> findByReview(Boolean review);
|
||||
|
||||
List<MediaFile> findByReviewAndShouldDownload(Boolean review, Boolean shouldDownload);
|
||||
|
||||
MediaFile findByUrl(String url);
|
||||
|
||||
@Query("select m from MediaFile m " +
|
||||
"where lower(m.url) like lower(concat('%', :searchTerm, '%')) or lower(m.title) like lower(concat('%', :searchTerm, '%')) " +
|
||||
"AND m.review=:review AND m.shouldDownload=:download")
|
||||
List<MediaFile> search(
|
||||
@Param("searchTerm") String searchTerm,
|
||||
@Param("review") boolean searchReview,
|
||||
@Param("download") boolean searchDownload);
|
||||
}
|
||||
+3
-1
@@ -1,9 +1,11 @@
|
||||
package de.thpeetz.kontor.media.data;
|
||||
package de.thpeetz.kontor.media.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import de.thpeetz.kontor.media.data.MediaVideo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MediaVideoRepository extends JpaRepository<MediaVideo, String> {
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package de.thpeetz.kontor.media.services;
|
||||
|
||||
import de.thpeetz.kontor.media.data.MediaArticle;
|
||||
import de.thpeetz.kontor.media.data.MediaArticleRepository;
|
||||
import de.thpeetz.kontor.media.repository.MediaArticleRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package de.thpeetz.kontor.media.services;
|
||||
|
||||
import de.thpeetz.kontor.media.data.*;
|
||||
import de.thpeetz.kontor.common.views.SearchFilter;
|
||||
import de.thpeetz.kontor.media.data.MediaActor;
|
||||
import de.thpeetz.kontor.media.data.MediaActorFile;
|
||||
import de.thpeetz.kontor.media.data.MediaFile;
|
||||
import de.thpeetz.kontor.media.repository.MediaActorFileRepository;
|
||||
import de.thpeetz.kontor.media.repository.MediaActorRepository;
|
||||
import de.thpeetz.kontor.media.repository.MediaFileRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class MediaFileService {
|
||||
@@ -20,7 +28,7 @@ public class MediaFileService {
|
||||
this.mediaActorFileRepository = mediaActorFileRepository;
|
||||
}
|
||||
|
||||
public List<MediaFile> findAllMediaFiles(String stringFilter) {
|
||||
public List<MediaFile> findAllMediaFilesByString(String stringFilter) {
|
||||
List<MediaFile> results;
|
||||
if (stringFilter == null || stringFilter.isEmpty()) {
|
||||
results = mediaFileRepository.findAll();
|
||||
@@ -31,12 +39,52 @@ public class MediaFileService {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void saveMediaFile(MediaFile mediaFile) {
|
||||
public MediaFile findAllMediaFilesByUrl(String url) {
|
||||
return mediaFileRepository.findByUrl(url);
|
||||
}
|
||||
|
||||
public List<MediaFile> findAllMediaFiles(SearchFilter searchFilter) {
|
||||
if (searchFilter == null) {
|
||||
return mediaFileRepository.findAll();
|
||||
} else {
|
||||
if (searchFilter.getSearchTerm() != null && searchFilter.getFilterOptions().isEmpty()) {
|
||||
log.info("find MediaFiles by using searchTerm: {}", searchFilter.getSearchTerm());
|
||||
List<MediaFile> results = mediaFileRepository.search(searchFilter.getSearchTerm());
|
||||
log.info("found {} entries", results.size());
|
||||
return results;
|
||||
}
|
||||
if (searchFilter.getFilterOptions().size() == 1) {
|
||||
log.info("using searchFilter: {}", searchFilter);
|
||||
String filter = searchFilter.getFilterOptions().get(0).getName();
|
||||
Boolean filterValue = searchFilter.getFilterOptions().get(0).getValue();
|
||||
if (filter == "Überprüfung") {
|
||||
List<MediaFile> results = mediaFileRepository.findByReview(filterValue);
|
||||
log.info("found {} entries", results.size());
|
||||
return results;
|
||||
}
|
||||
if (filter == "Download") {
|
||||
List<MediaFile> results = mediaFileRepository.findByShouldDownload(filterValue);
|
||||
log.info("found {} entries", results.size());
|
||||
return results;
|
||||
}
|
||||
}
|
||||
if (searchFilter.getFilterOptions().size() == 2) {
|
||||
log.info("using searchFilter: {}", searchFilter);
|
||||
List<MediaFile> results = mediaFileRepository.search(searchFilter.getSearchTerm(), searchFilter.getFilterOptions().get(0).getValue(), searchFilter.getFilterOptions().get(1).getValue());
|
||||
log.info("found {} entries", results.size());
|
||||
return results;
|
||||
}
|
||||
}
|
||||
log.info("noch filter used");
|
||||
return mediaFileRepository.findAll();
|
||||
}
|
||||
|
||||
public MediaFile saveMediaFile(MediaFile mediaFile) {
|
||||
if (mediaFile == null) {
|
||||
log.warn("MediaFile is null. Are you sure you have connected your form to the application?");
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
mediaFileRepository.save(mediaFile);
|
||||
return mediaFileRepository.save(mediaFile);
|
||||
}
|
||||
|
||||
public void deleteMediaFile(MediaFile mediaFile) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.thpeetz.kontor.media.services;
|
||||
|
||||
import de.thpeetz.kontor.media.data.MediaVideo;
|
||||
import de.thpeetz.kontor.media.data.MediaVideoRepository;
|
||||
import de.thpeetz.kontor.media.repository.MediaVideoRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.button.ButtonVariant;
|
||||
import com.vaadin.flow.component.formlayout.FormLayout;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.listbox.MultiSelectListBox;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
import com.vaadin.flow.data.binder.BeanValidationBinder;
|
||||
@@ -22,6 +21,7 @@ import java.util.List;
|
||||
public class MediaActorForm extends FormLayout {
|
||||
|
||||
TextField name = new TextField("Name");
|
||||
TextField url = new TextField("URL");
|
||||
Grid<MediaActorFile> mediaActorFiles = new Grid<>(MediaActorFile.class);
|
||||
|
||||
Button save = new Button("Save");
|
||||
@@ -37,6 +37,7 @@ public class MediaActorForm extends FormLayout {
|
||||
mediaActorFiles.setColumns("media_file.title");
|
||||
mediaActorFiles.getColumnByKey("media_file.title").setHeader("File Title");
|
||||
add(name, 2);
|
||||
add(url, 2);
|
||||
add(mediaActorFiles, 2);
|
||||
add(createButtonsLayout());
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.thpeetz.kontor.media.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.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
@@ -10,9 +11,12 @@ 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.common.views.ColumnToggleContextMenu;
|
||||
import de.thpeetz.kontor.common.views.MainLayout;
|
||||
import de.thpeetz.kontor.media.MediaConstants;
|
||||
import de.thpeetz.kontor.media.data.MediaActor;
|
||||
import de.thpeetz.kontor.media.data.MediaFile;
|
||||
import de.thpeetz.kontor.media.services.MediaFileService;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import lombok.Getter;
|
||||
@@ -26,7 +30,17 @@ import org.springframework.context.annotation.Scope;
|
||||
public class MediaActorView extends VerticalLayout {
|
||||
|
||||
@Getter
|
||||
Grid<MediaActor> grid = new Grid<>(MediaActor.class);
|
||||
Grid<MediaActor> grid = new Grid<>(MediaActor.class, false);
|
||||
Grid.Column<MediaActor> idColumn = grid.addColumn(MediaActor::getId)
|
||||
.setHeader("ID").setResizable(true).setSortable(true);
|
||||
Grid.Column<MediaActor> createdColumn = grid.addColumn(MediaActor::getCreatedDate)
|
||||
.setHeader("Erstellt").setResizable(true).setSortable(true);
|
||||
Grid.Column<MediaActor> modifiedColumn = grid.addColumn(MediaActor::getLastModifiedDate)
|
||||
.setHeader("Geändert").setResizable(true).setSortable(true);
|
||||
Grid.Column<MediaActor> nameColumn = grid.addColumn(MediaActor::getName)
|
||||
.setHeader("Name").setResizable(true).setSortable(true);
|
||||
Grid.Column<MediaActor> urlColumn = grid.addColumn(MediaActor::getUrl)
|
||||
.setHeader("URL").setResizable(true).setSortable(true);
|
||||
TextField filterText = new TextField();
|
||||
@Getter
|
||||
MediaActorForm form;
|
||||
@@ -46,7 +60,6 @@ public class MediaActorView extends VerticalLayout {
|
||||
private void configureGrid() {
|
||||
grid.addClassName("media-actor-grid");
|
||||
grid.setSizeFull();
|
||||
grid.setColumns("name");
|
||||
grid.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||
grid.asSingleSelect().addValueChangeListener(event -> editMediaActor(event.getValue()));
|
||||
}
|
||||
@@ -90,7 +103,15 @@ public class MediaActorView extends VerticalLayout {
|
||||
Button addMediaActorButton = new Button("Add actor");
|
||||
addMediaActorButton.addClickListener(click -> addMediaActor());
|
||||
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addMediaActorButton);
|
||||
Button menuButton = new Button("Show/Hide Columns");
|
||||
menuButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
ColumnToggleContextMenu<MediaActor> columnToggleContextMenu = new ColumnToggleContextMenu<>(menuButton);
|
||||
columnToggleContextMenu.addColumnToggleItem(idColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(createdColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(modifiedColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(nameColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(urlColumn);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addMediaActorButton, menuButton);
|
||||
toolbar.addClassName("toolbar");
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
@@ -3,21 +3,13 @@ package de.thpeetz.kontor.media.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.contextmenu.ContextMenu;
|
||||
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
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.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.common.views.ColumnToggleContextMenu;
|
||||
import de.thpeetz.kontor.common.views.MainLayout;
|
||||
import de.thpeetz.kontor.common.views.StatusIcon;
|
||||
import de.thpeetz.kontor.common.views.*;
|
||||
import de.thpeetz.kontor.media.data.MediaFile;
|
||||
import de.thpeetz.kontor.media.services.MediaFileService;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
@@ -53,7 +45,7 @@ public class MediaFileView extends VerticalLayout {
|
||||
setHeader("Überprüfung").setWidth("6rem").setSortable(true);
|
||||
Grid.Column<MediaFile> shouldDownloadColumn = grid.addComponentColumn(mediafile -> StatusIcon.create(mediafile.isShouldDownload())).
|
||||
setHeader("Download?").setWidth("6rem").setSortable(true);
|
||||
TextField searchField = new TextField();
|
||||
SearchFilterField searchFilterField = new SearchFilterField();
|
||||
@Getter
|
||||
MediaFileForm form;
|
||||
MediaFileService service;
|
||||
@@ -108,11 +100,9 @@ public class MediaFileView extends VerticalLayout {
|
||||
}
|
||||
|
||||
private HorizontalLayout getToolbar() {
|
||||
searchField.setPlaceholder("Search");
|
||||
searchField.setClearButtonVisible(true);
|
||||
searchField.setPrefixComponent(new Icon(VaadinIcon.SEARCH));
|
||||
searchField.setValueChangeMode(ValueChangeMode.EAGER);
|
||||
searchField.addValueChangeListener(e -> updateList());
|
||||
searchFilterField.addFilter("Überprüfung");
|
||||
searchFilterField.addFilter("Download");
|
||||
searchFilterField.addValueChangeListener(e -> updateList());
|
||||
|
||||
Button addMediaFileButton = new Button("Add MediaFile");
|
||||
addMediaFileButton.addClickListener(click -> addMediaFile());
|
||||
@@ -129,7 +119,7 @@ public class MediaFileView extends VerticalLayout {
|
||||
columnToggleContextMenu.addColumnToggleItem(cloudLinkColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(reviewColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(shouldDownloadColumn);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(searchField, addMediaFileButton, menuButton);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(searchFilterField, addMediaFileButton, menuButton);
|
||||
toolbar.addClassName("toolbar");
|
||||
return toolbar;
|
||||
}
|
||||
@@ -162,6 +152,7 @@ public class MediaFileView extends VerticalLayout {
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
grid.setItems(service.findAllMediaFiles(searchField.getValue()));
|
||||
log.info("searchFilterField: {}", searchFilterField.getValue());
|
||||
grid.setItems(service.findAllMediaFiles(searchFilterField.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.oauth2.jose.jws.JwsAlgorithms;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
|
||||
@EnableWebSecurity
|
||||
@Configuration
|
||||
@@ -36,8 +34,9 @@ public class SecurityConfig extends VaadinWebSecurity {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeHttpRequests(auth -> auth.requestMatchers(
|
||||
AntPathRequestMatcher.antMatcher(HttpMethod.GET, "/images/*.png")).permitAll());
|
||||
http.authorizeHttpRequests(auth -> auth
|
||||
.requestMatchers("/images/*.png").permitAll()
|
||||
.requestMatchers("/actuator/**").permitAll());
|
||||
super.configure(http);
|
||||
setLoginView(http, LoginView.class);
|
||||
setStatelessAuthentication(http, new SecretKeySpec(Base64.getDecoder().decode(authSecret), JwsAlgorithms.HS256),
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import de.thpeetz.kontor.admin.services.ModuleService;
|
||||
import de.thpeetz.kontor.tysc.data.FieldPosition;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -54,440 +53,13 @@ public class SetupModuleTysc implements ApplicationListener<ContextRefreshedEven
|
||||
@Autowired
|
||||
private CardRepository cardRepository;
|
||||
|
||||
@Autowired
|
||||
private ModuleService moduleService;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
if (alreadySetup) {
|
||||
log.info("SetupDataLoader(TYSC) already executed, skipping");
|
||||
return;
|
||||
}
|
||||
if (!moduleService.importData(TyscConstants.TYSC)) {
|
||||
log.info("Module TradeYourSportsCards should not setup data");
|
||||
return;
|
||||
}
|
||||
log.info("Setp up TYSC data");
|
||||
Sport football = createSportIfNotFound("Football");
|
||||
Sport baseball = createSportIfNotFound("Baseball");
|
||||
Sport basketball = createSportIfNotFound("Basketball");
|
||||
Sport hockey = createSportIfNotFound("Hockey");
|
||||
createTeamIfNotFound(football, "Buffalo Bills", "Bills");
|
||||
Team colts = createTeamIfNotFound(football, "Indianapolis Colts", "Colts");
|
||||
createTeamIfNotFound(football, "Miami Dolphins", "Dolphins");
|
||||
Team patriots = createTeamIfNotFound(football, "New England Patriots", "Patriots");
|
||||
createTeamIfNotFound(football, "New York Jets", "Jets");
|
||||
Team ravens = createTeamIfNotFound(football, "Baltimore Ravens", "Ravens");
|
||||
createTeamIfNotFound(football, "Cincinnati Bengals", "Bengals");
|
||||
Team browns = createTeamIfNotFound(football, "Cleveland Browns", "Browns");
|
||||
createTeamIfNotFound(football, "Jacksonville Jaguars", "Jaguars");
|
||||
Team steelers = createTeamIfNotFound(football, "Pittsburgh Steelers", "Steelers");
|
||||
createTeamIfNotFound(football, "Tennessee Titans", "Titans");
|
||||
createTeamIfNotFound(football, "Denver Broncos", "Broncos");
|
||||
Team chiefs = createTeamIfNotFound(football, "Kansas City Chiefs", "Chiefs");
|
||||
Team raiders = createTeamIfNotFound(football, "Oakland Raiders", "Raiders");
|
||||
createTeamIfNotFound(football, "San Diego Chargers", "Chargers");
|
||||
Team seahawks = createTeamIfNotFound(football, "Seattle Seahawks", "Seahawks");
|
||||
createTeamIfNotFound(football, "Arizona Cardinals", "Cardinals");
|
||||
Team cowboys = createTeamIfNotFound(football, "Dallas Cowboys", "Cowboys");
|
||||
Team giants = createTeamIfNotFound(football, "New York Giants", "Giants");
|
||||
Team eagles = createTeamIfNotFound(football, "Philadelphia Eagles", "Eagles");
|
||||
Team redskins = createTeamIfNotFound(football, "Washington Redskins", "Redskins");
|
||||
createTeamIfNotFound(football, "Chicago Bears", "Bears");
|
||||
createTeamIfNotFound(football, "Detroit Lions", "Lions");
|
||||
createTeamIfNotFound(football, "Green Bay Packers", "Packers");
|
||||
createTeamIfNotFound(football, "Minnesota Vikings", "Vikings");
|
||||
createTeamIfNotFound(football, "Tampa Bay Buccaneers", "Buccaneers");
|
||||
Team falcons = createTeamIfNotFound(football, "Atlanta Falcons", "Falcons");
|
||||
createTeamIfNotFound(football, "Carolina Panthers", "Panthers");
|
||||
Team saints = createTeamIfNotFound(football, "New Orleans Saints", "Saints");
|
||||
Team rams = createTeamIfNotFound(football, "St.Louis Rams", "Rams");
|
||||
Team sf49ers = createTeamIfNotFound(football, "San Francisco 49ers", "49ers");
|
||||
createTeamIfNotFound(football, "Houston Texans", "Texans");
|
||||
createTeamIfNotFound(football, "Houston Oilers", "Oilers");
|
||||
createTeamIfNotFound(baseball, "Baltimore Orioles", "Orioles");
|
||||
createTeamIfNotFound(baseball, "Boston Red Sox", "Red Sox");
|
||||
createTeamIfNotFound(baseball, "New York Yankees", "Yankees");
|
||||
createTeamIfNotFound(baseball, "Tampa Bay Devil Rays", "Devil Rays");
|
||||
createTeamIfNotFound(baseball, "Toronto Blue Jays", "Blue Jays");
|
||||
createTeamIfNotFound(baseball, "Chicago White Sox", "White Sox");
|
||||
createTeamIfNotFound(baseball, "Cleveland Indians", "Indians");
|
||||
createTeamIfNotFound(baseball, "Detroit Tigers", "Tigers");
|
||||
createTeamIfNotFound(baseball, "Kansas City Royals", "Royals");
|
||||
createTeamIfNotFound(baseball, "Minnesota Twins", "Twins");
|
||||
createTeamIfNotFound(baseball, "Anaheim Angels", "Angels");
|
||||
createTeamIfNotFound(baseball, "Oakland Athletics", "Athletics");
|
||||
createTeamIfNotFound(baseball, "Seattle Mariners", "Mariners");
|
||||
createTeamIfNotFound(baseball, "Texas Rangers", "Rangers");
|
||||
createTeamIfNotFound(baseball, "Atlanta Braves", "Braves");
|
||||
createTeamIfNotFound(baseball, "Florida Marlins", "Marlins");
|
||||
createTeamIfNotFound(baseball, "Montreal Expos", "Expos");
|
||||
createTeamIfNotFound(baseball, "New York Mets", "Mets");
|
||||
createTeamIfNotFound(baseball, "Philadelphia Phillies", "Phillies");
|
||||
createTeamIfNotFound(baseball, "Chicago Cubs", "Cubs");
|
||||
createTeamIfNotFound(baseball, "Cincinnati Reds", "Reds");
|
||||
createTeamIfNotFound(baseball, "Houston Astros", "Astros");
|
||||
createTeamIfNotFound(baseball, "Milwaukee Brewers", "Brewers");
|
||||
createTeamIfNotFound(baseball, "Pittsburgh Pirates", "Pirates");
|
||||
createTeamIfNotFound(baseball, "St.Louis Cardinals", "Cardinals");
|
||||
createTeamIfNotFound(baseball, "Arizona Diamondbacks", "Diamondbacks");
|
||||
createTeamIfNotFound(baseball, "Colorado Rockies", "Rockies");
|
||||
createTeamIfNotFound(baseball, "Los Angeles Dodgers", "Dodgers");
|
||||
createTeamIfNotFound(baseball, "San Diego Padres", "Padres");
|
||||
createTeamIfNotFound(baseball, "San Francisco Giants", "Giants");
|
||||
createTeamIfNotFound(basketball, "Boston Celtics", "Celtics");
|
||||
createTeamIfNotFound(basketball, "Miami Heat", "Heat");
|
||||
createTeamIfNotFound(basketball, "New Jersey Nets", "Mets");
|
||||
createTeamIfNotFound(basketball, "New York Knicks", "Knicks");
|
||||
createTeamIfNotFound(basketball, "Orlando Magic", "Magic");
|
||||
createTeamIfNotFound(basketball, "Philadelphia 76ers", "76ers");
|
||||
createTeamIfNotFound(basketball, "Washington Wizards", "Wizards");
|
||||
createTeamIfNotFound(basketball, "Atlanta Hawks", "Hawks");
|
||||
createTeamIfNotFound(basketball, "Charlotte Hornets", "Hornets");
|
||||
createTeamIfNotFound(basketball, "Chicago Bulls", "Bulls");
|
||||
createTeamIfNotFound(basketball, "Cleveland Cavaliers", "Cavaliers");
|
||||
createTeamIfNotFound(basketball, "Detroit Pistons", "Pistons");
|
||||
createTeamIfNotFound(basketball, "Indiana Pacers", "Pacers");
|
||||
createTeamIfNotFound(basketball, "Milwaukee Bucks", "Bucks");
|
||||
createTeamIfNotFound(basketball, "Toronto Raptors", "Raptors");
|
||||
createTeamIfNotFound(basketball, "Dallas Mavericks", "Mavericks");
|
||||
createTeamIfNotFound(basketball, "Denver Nuggets", "Nuggets");
|
||||
createTeamIfNotFound(basketball, "Houston Rockets", "Rockets");
|
||||
createTeamIfNotFound(basketball, "Minnesota Timberwolves", "Timberwolves");
|
||||
createTeamIfNotFound(basketball, "San Antonio Spurs", "Spurs");
|
||||
createTeamIfNotFound(basketball, "Utah Jazz", "Jazz");
|
||||
createTeamIfNotFound(basketball, "Vancouver Grizzlies", "Grizzlies");
|
||||
createTeamIfNotFound(basketball, "Golden State Warriors", "Warriors");
|
||||
createTeamIfNotFound(basketball, "Los Angeles Clippers", "Clippers");
|
||||
createTeamIfNotFound(basketball, "Los Angeles Lakers", "Lakers");
|
||||
createTeamIfNotFound(basketball, "Phoenix Suns", "Suns");
|
||||
createTeamIfNotFound(basketball, "Portland Trail Blazers", "Blazers");
|
||||
createTeamIfNotFound(basketball, "Sacramento Kings", "Kings");
|
||||
createTeamIfNotFound(basketball, "Seattle SuperSonics", "SuperSonics");
|
||||
createTeamIfNotFound(hockey, "Boston Bruins", "Bruins");
|
||||
createTeamIfNotFound(hockey, "Buffalo Sabres", "Sabres");
|
||||
createTeamIfNotFound(hockey, "Montreal Canadiens", "Canadiens");
|
||||
createTeamIfNotFound(hockey, "Ottawa Senators", "Senators");
|
||||
createTeamIfNotFound(hockey, "Toronto Maple Leafs", "Maple Leafs");
|
||||
createTeamIfNotFound(hockey, "New Jersey Devils", "Devils");
|
||||
createTeamIfNotFound(hockey, "New York Islanders", "Islanders");
|
||||
createTeamIfNotFound(hockey, "New York Rangers", "Rangers");
|
||||
createTeamIfNotFound(hockey, "Philadelphia Flyers", "Flyers");
|
||||
createTeamIfNotFound(hockey, "Pittsburgh Penguins", "Penguins");
|
||||
createTeamIfNotFound(hockey, "Atlanta Trashers", "Trashers");
|
||||
createTeamIfNotFound(hockey, "Carolina Hurricanes", "Hurricanes");
|
||||
createTeamIfNotFound(hockey, "Florida Panthers", "Panthers");
|
||||
createTeamIfNotFound(hockey, "Tampa Bay Lightnings", "Lightnings");
|
||||
createTeamIfNotFound(hockey, "Washington Capitals", "Capitals");
|
||||
createTeamIfNotFound(hockey, "Chicago Blackhawks", "Blackhawks");
|
||||
createTeamIfNotFound(hockey, "Columbus Blue Jackets", "Blue Jackets");
|
||||
createTeamIfNotFound(hockey, "Detroit Red Wings", "Red Wings");
|
||||
createTeamIfNotFound(hockey, "Nashville Predators", "Predators");
|
||||
createTeamIfNotFound(hockey, "St.Louis Blues", "Blues");
|
||||
createTeamIfNotFound(hockey, "Calgary Flames", "Flames");
|
||||
createTeamIfNotFound(hockey, "Colorado Avalanche", "Avalanche");
|
||||
createTeamIfNotFound(hockey, "Edmonton Oilers", "Oilers");
|
||||
createTeamIfNotFound(hockey, "Minnesota Wild", "Wild");
|
||||
createTeamIfNotFound(hockey, "Vancouver Canucks", "Canucks");
|
||||
createTeamIfNotFound(hockey, "Anaheim Mighty Ducks", "Mighty Ducks");
|
||||
createTeamIfNotFound(hockey, "Dallas Stars", "Stars");
|
||||
createTeamIfNotFound(hockey, "Los Angeles Kings", "Kings");
|
||||
createTeamIfNotFound(hockey, "Phoenix Coyotes", "Coyotes");
|
||||
createTeamIfNotFound(hockey, "San Jose Sharks", "Sharks");
|
||||
FieldPosition qb = createPosition(football, "QB", "Quarterback");
|
||||
FieldPosition rb = createPosition(football, "RB", "Running Back");
|
||||
FieldPosition wr = createPosition(football, "WR", "Wide Receiver");
|
||||
FieldPosition te = createPosition(football, "TE", "Tight End");
|
||||
FieldPosition fb = createPosition(football, "FB", "Fullback");
|
||||
createPosition(football, "OL", "Offensive Line");
|
||||
createPosition(football, "DL", "Defensive Line");
|
||||
FieldPosition lb = createPosition(football, "LB", "Linebacker");
|
||||
createPosition(football, "DB", "Defensive Back");
|
||||
createPosition(football, "DE", "Defensive End");
|
||||
createPosition(football, "K", "Kicker");
|
||||
createPosition(football, "P", "Punter");
|
||||
createPosition(football, "S", "Safety");
|
||||
createPosition(football, "KR", "Kick Returner");
|
||||
createPosition(football, "PR", "Punt Returner");
|
||||
createPosition(football, "LS", "Long Snapper");
|
||||
createPosition(football, "LG", "Left Guard");
|
||||
createPosition(football, "RG", "Right Guard");
|
||||
createPosition(football, "OF", "Offensive Tackle");
|
||||
createPosition(football, "DB", "Defensive Back");
|
||||
createPosition(football, "CB", "Cornerback");
|
||||
createPosition(football, "DT", "Defensive Tackle");
|
||||
createPosition(football, "NT", "Nose Tackle");
|
||||
createPosition(football, "OLB", "Outside Linebacker");
|
||||
createPosition(football, "ILB", "Inside Linebacker");
|
||||
createPosition(football, "SS", "Strong Safety");
|
||||
createPosition(baseball, "P", "Pitcher");
|
||||
createPosition(baseball, "C", "Catcher");
|
||||
createPosition(baseball, "1B", "First Base");
|
||||
createPosition(baseball, "2B", "Second Base");
|
||||
createPosition(baseball, "3B", "Third Base");
|
||||
createPosition(baseball, "SS", "Shortstop");
|
||||
createPosition(baseball, "LF", "Left Field");
|
||||
createPosition(baseball, "CF", "Center Field");
|
||||
createPosition(baseball, "RF", "Right Field");
|
||||
createPosition(basketball, "PG", "Point Guard");
|
||||
createPosition(basketball, "SG", "Shooting Guard");
|
||||
createPosition(basketball, "SF", "Small Forward");
|
||||
createPosition(basketball, "PF", "Power Forward");
|
||||
createPosition(basketball, "C", "Center");
|
||||
createPosition(hockey, "G", "Goalie");
|
||||
createPosition(hockey, "D", "Defense");
|
||||
createPosition(hockey, "LW", "Left Wing");
|
||||
createPosition(hockey, "RW", "Right Wing");
|
||||
createPosition(hockey, "C", "Center");
|
||||
Vendor pacific = createVendorIfNotFound("Pacific");
|
||||
Vendor fleer = createVendorIfNotFound("Fleer");
|
||||
Vendor bowman = createVendorIfNotFound("Bowman");
|
||||
Vendor leaf = createVendorIfNotFound("Leaf");
|
||||
Vendor upperdeck = createVendorIfNotFound("Upper Deck");
|
||||
createVendorIfNotFound("Topps");
|
||||
createVendorIfNotFound("Donruss");
|
||||
createVendorIfNotFound("Score");
|
||||
createVendorIfNotFound("Flair");
|
||||
createCardSetIfNotFound("Mystique Big Buzz", fleer, false, true);
|
||||
createCardSetIfNotFound("Mystique Gold", fleer, true, false);
|
||||
createCardSetIfNotFound("Pacific Copper", pacific, true, false);
|
||||
createCardSetIfNotFound("Pacific Gold", pacific, true, false);
|
||||
CardSet pacificbase = createCardSetIfNotFound(pacific.getName(), pacific, false, false);
|
||||
createCardSetIfNotFound(fleer.getName(), fleer, false, false);
|
||||
createCardSetIfNotFound(bowman.getName(), bowman, false, false);
|
||||
createCardSetIfNotFound(leaf.getName(), leaf, false, false);
|
||||
createCardSetIfNotFound("Ultra", fleer, false, false);
|
||||
createCardSetIfNotFound("Mystique", fleer, false, false);
|
||||
createCardSetIfNotFound("Finest Hour", pacific, false, false);
|
||||
createCardSetIfNotFound("SP", upperdeck, false, false);
|
||||
createCardSetIfNotFound("SPX", upperdeck, false, false);
|
||||
createCardSetIfNotFound("SP Authentic", upperdeck, false, false);
|
||||
createCardSetIfNotFound("Black Diamond", upperdeck, false, false);
|
||||
Player jeromepathon = createPlayerIfNotFound("Jerome", "Pathon");
|
||||
Player bruschi = createPlayerIfNotFound("Tedy", "Bruschi");
|
||||
Player couch = createPlayerIfNotFound("Tim", "Couch");
|
||||
Player shea = createPlayerIfNotFound("Aaron", "Shea");
|
||||
Player jamallewis = createPlayerIfNotFound("Jamal", "Lewis");
|
||||
Player jermainelewis = createPlayerIfNotFound("Jermaine", "Lewis");
|
||||
Player tonybanks = createPlayerIfNotFound("Tony", "Banks");
|
||||
Player chrisfuamatu = createPlayerIfNotFound("Chris", "Fuamatu-Ma'afala");
|
||||
Player jeromebettis = createPlayerIfNotFound("Jerome", "Bettis");
|
||||
Player kordellstewart = createPlayerIfNotFound("Kordell", "Stewart");
|
||||
Player warrenmoon = createPlayerIfNotFound("Warren", "Moon");
|
||||
Player kevinlockett = createPlayerIfNotFound("Kevin", "Lockett");
|
||||
Player richgannon = createPlayerIfNotFound("Rich", "Gannon");
|
||||
Player jamesjett = createPlayerIfNotFound("James", "Jett");
|
||||
Player mackstrong = createPlayerIfNotFound("Mack", "Strong");
|
||||
Player brockhuard = createPlayerIfNotFound("Brock", "Huard");
|
||||
Player rickywatters = createPlayerIfNotFound("Ricky", "Watters");
|
||||
Player troyaikman = createPlayerIfNotFound("Troy", "Aikman");
|
||||
Player davidlafleur = createPlayerIfNotFound("David", "LaFleur");
|
||||
Player chrisbrazzell = createPlayerIfNotFound("Chris", "Brazzell");
|
||||
Player rondayne = createPlayerIfNotFound("Ron", "Dayne");
|
||||
Player nabrowne = createPlayerIfNotFound("Na", "Brown");
|
||||
Player torrancesmall = createPlayerIfNotFound("Torrance", "Small");
|
||||
Player chadlewis = createPlayerIfNotFound("Chad", "Lewis");
|
||||
Player adrianmurrell = createPlayerIfNotFound("Adrian", "Murrell");
|
||||
Player mauricesmith = createPlayerIfNotFound("Maurice", "Smith");
|
||||
Player chrischandler = createPlayerIfNotFound("Chris", "Chandler");
|
||||
Player dannykenell = createPlayerIfNotFound("Danny", "Kanell");
|
||||
Player rickywilliams = createPlayerIfNotFound("Ricky", "Williams");
|
||||
Player jeffgarcia = createPlayerIfNotFound("Jeff", "Garcia");
|
||||
Player taistreets = createPlayerIfNotFound("Tai", "Streets");
|
||||
Player charliegarner = createPlayerIfNotFound("Charlie", "Garner");
|
||||
Player drewbledsoe = createPlayerIfNotFound("Drew", "Bledsoe");
|
||||
createPlayerIfNotFound("Antowain", "Smith");
|
||||
createPlayerIfNotFound("Terry", "Glenn");
|
||||
Player jerryrice = createPlayerIfNotFound("Jerry", "Rice");
|
||||
Player terrellowens = createPlayerIfNotFound("Terrell", "Owens");
|
||||
Player isaacbruce = createPlayerIfNotFound("Isaac", "Bruce");
|
||||
Player trungcanidate = createPlayerIfNotFound("Trung", "Canidate");
|
||||
Rooster pathoncoltswr2001 = createRoosterIfNotFound(jeromepathon, colts, wr, 2001);
|
||||
Rooster bruschipatriotslb2001 = createRoosterIfNotFound(bruschi, patriots, lb, 2001);
|
||||
Rooster couchbrownsqb2001 = createRoosterIfNotFound(couch, browns, qb, 2001);
|
||||
Rooster sheabrownste2001 = createRoosterIfNotFound(shea, browns, te, 2001);
|
||||
Rooster jamallewisravensrb2001 = createRoosterIfNotFound(jamallewis, ravens, rb, 2001);
|
||||
Rooster jermainelewisravenswr2001 = createRoosterIfNotFound(jermainelewis, ravens, wr, 2001);
|
||||
Rooster tonybanksravensqb2001 = createRoosterIfNotFound(tonybanks, ravens, qb, 2001);
|
||||
createRoosterIfNotFound(tonybanks, redskins, qb, 2002);
|
||||
Rooster chrisfuamatusteelersfb2001 = createRoosterIfNotFound(chrisfuamatu, steelers, fb, 2001);
|
||||
Rooster jeromebettissteelersrb2001 = createRoosterIfNotFound(jeromebettis, steelers, rb, 2001);
|
||||
Rooster kordellstewartsteelersqb2001 = createRoosterIfNotFound(kordellstewart, steelers, qb, 2001);
|
||||
Rooster warrenmoonchiefsqb2001 = createRoosterIfNotFound(warrenmoon, chiefs, qb, 2001);
|
||||
Rooster kevinlockettchiefswr2001 = createRoosterIfNotFound(kevinlockett, chiefs, wr, 2001);
|
||||
Rooster richgannonqbraidersqb2001 = createRoosterIfNotFound(richgannon, raiders, qb, 2001);
|
||||
Rooster jamesjettraiderswr2001 = createRoosterIfNotFound(jamesjett, raiders, wr,2001);
|
||||
Rooster mackstrongseahawksfb2001 = createRoosterIfNotFound(mackstrong, seahawks, fb, 2001);
|
||||
Rooster brockhuardseahawksqb2001 = createRoosterIfNotFound(brockhuard, seahawks, qb, 2001);
|
||||
Rooster rickywattersseahawksrb2001 = createRoosterIfNotFound(rickywatters, seahawks, rb, 2001);
|
||||
Rooster troyaikmancowboysqb2001 = createRoosterIfNotFound(troyaikman, cowboys, qb, 2001);
|
||||
Rooster davidlafleurcowboyste2001 = createRoosterIfNotFound(davidlafleur, cowboys, te, 2001);
|
||||
Rooster chrisbrazzellcowboyswr2001 = createRoosterIfNotFound(chrisbrazzell, cowboys, wr, 2001);
|
||||
Rooster rondaynegiantsrb2001 = createRoosterIfNotFound(rondayne, giants, rb, 2001);
|
||||
Rooster nabrownegiantswr2001 = createRoosterIfNotFound(nabrowne, giants, wr, 2001);
|
||||
Rooster torrancesmalleagleswr2001 = createRoosterIfNotFound(torrancesmall, eagles, wr, 2001);
|
||||
Rooster chadlewiseagleste2001 = createRoosterIfNotFound(chadlewis, eagles, te, 2001);
|
||||
Rooster adrianmurrellredskinsrb2001 = createRoosterIfNotFound(adrianmurrell, redskins, rb, 2001);
|
||||
Rooster mauricesmithfalconsrb2001 = createRoosterIfNotFound(mauricesmith, falcons, rb, 2001);
|
||||
Rooster chrischandlerfalconsqb2001 = createRoosterIfNotFound(chrischandler, falcons, qb, 2001);
|
||||
Rooster dannykanellfalconsqb2001 = createRoosterIfNotFound(dannykenell, falcons, qb, 2001);
|
||||
Rooster rickywilliamssaintsrb2001 = createRoosterIfNotFound(rickywilliams, saints, rb, 2001);
|
||||
Rooster jeffgarcia49ersqb2001 = createRoosterIfNotFound(jeffgarcia, sf49ers, qb, 2001);
|
||||
Rooster taistreets49erswr2001 = createRoosterIfNotFound(taistreets, sf49ers, wr, 2001);
|
||||
Rooster charliegarner49ersrb2001 = createRoosterIfNotFound(charliegarner, sf49ers, rb, 2001);
|
||||
Rooster jerryrice49erswr2001 = createRoosterIfNotFound(jerryrice, sf49ers, wr, 2001);
|
||||
Rooster terrelowens49erswr2001 = createRoosterIfNotFound(terrellowens, sf49ers, wr, 2001);
|
||||
Rooster isaacbruseramswr2001 = createRoosterIfNotFound(isaacbruce, rams, wr, 2001);
|
||||
Rooster trungcanidateramsrb2001 = createRoosterIfNotFound(trungcanidate, rams, rb, 2001);
|
||||
createCardIfNotFound(185, 2001, pacific, pacificbase, pathoncoltswr2001);
|
||||
createCardIfNotFound(250, 2001, pacific, pacificbase, bruschipatriotslb2001);
|
||||
createCardIfNotFound(103, 2001, pacific, pacificbase, couchbrownsqb2001);
|
||||
createCardIfNotFound(112, 2001, pacific, pacificbase, sheabrownste2001);
|
||||
createCardIfNotFound(37, 2001, pacific, pacificbase, jamallewisravensrb2001);
|
||||
createCardIfNotFound(38, 2001, pacific, pacificbase, jermainelewisravenswr2001);
|
||||
createCardIfNotFound(31, 2001, pacific, pacificbase, tonybanksravensqb2001);
|
||||
createCardIfNotFound(338, 2001, pacific, pacificbase, chrisfuamatusteelersfb2001);
|
||||
createCardIfNotFound(335, 2001, pacific, pacificbase, jeromebettissteelersrb2001);
|
||||
createCardIfNotFound(345, 2001, pacific, pacificbase, kordellstewartsteelersqb2001);
|
||||
createCardIfNotFound(213, 2001, pacific, pacificbase, warrenmoonchiefsqb2001);
|
||||
createCardIfNotFound(212, 2001, pacific, pacificbase, kevinlockettchiefswr2001);
|
||||
createCardIfNotFound(311, 2001, pacific, pacificbase, richgannonqbraidersqb2001);
|
||||
createCardIfNotFound(312, 2001, pacific, pacificbase, jamesjettraiderswr2001);
|
||||
createCardIfNotFound(403, 2001, pacific, pacificbase, mackstrongseahawksfb2001);
|
||||
createCardIfNotFound(397, 2001, pacific, pacificbase, brockhuardseahawksqb2001);
|
||||
createCardIfNotFound(404, 2001, pacific, pacificbase, rickywattersseahawksrb2001);
|
||||
createCardIfNotFound(116, 2001, pacific, pacificbase, troyaikmancowboysqb2001);
|
||||
createCardIfNotFound(122, 2001, pacific, pacificbase, davidlafleurcowboyste2001);
|
||||
createCardIfNotFound(117, 2001, pacific, pacificbase, chrisbrazzellcowboyswr2001);
|
||||
createCardIfNotFound(281, 2001, pacific, pacificbase, rondaynegiantsrb2001);
|
||||
createCardIfNotFound(321, 2001, pacific, pacificbase, nabrownegiantswr2001);
|
||||
createCardIfNotFound(331, 2001, pacific, pacificbase, torrancesmalleagleswr2001);
|
||||
createCardIfNotFound(324, 2001, pacific, pacificbase, chadlewiseagleste2001);
|
||||
createCardIfNotFound(445, 2001, pacific, pacificbase, adrianmurrellredskinsrb2001);
|
||||
createCardIfNotFound(28, 2001, pacific, pacificbase, mauricesmithfalconsrb2001);
|
||||
createCardIfNotFound(17, 2001, pacific, pacificbase, chrischandlerfalconsqb2001);
|
||||
createCardIfNotFound(23, 2001, pacific, pacificbase, dannykanellfalconsqb2001);
|
||||
createCardIfNotFound(273, 2001, pacific, pacificbase, rickywilliamssaintsrb2001);
|
||||
createCardIfNotFound(380, 2001, pacific, pacificbase, jeffgarcia49ersqb2001);
|
||||
createCardIfNotFound(390, 2001, pacific, pacificbase, taistreets49erswr2001);
|
||||
createCardIfNotFound(381, 2001, pacific, pacificbase, charliegarner49ersrb2001);
|
||||
createCardIfNotFound(387, 2001, pacific, pacificbase, jerryrice49erswr2001);
|
||||
createCardIfNotFound(386, 2001, pacific, pacificbase, terrelowens49erswr2001);
|
||||
createCardIfNotFound(349, 2001, pacific, pacificbase, isaacbruseramswr2001);
|
||||
createCardIfNotFound(350, 2001, pacific, pacificbase, trungcanidateramsrb2001);
|
||||
|
||||
alreadySetup = true;
|
||||
moduleService.setDataImported(TyscConstants.TYSC);
|
||||
}
|
||||
|
||||
private Sport createSportIfNotFound(String sport) {
|
||||
log.info("createSportIfNotFound: {}", sport);
|
||||
Sport sportEntity = sportRepository.findByName(sport);
|
||||
if (sportEntity == null) {
|
||||
log.info("Sport {} not found, will create it", sport);
|
||||
sportEntity = new Sport();
|
||||
sportEntity.setName(sport);
|
||||
sportRepository.save(sportEntity);
|
||||
}
|
||||
return sportEntity;
|
||||
}
|
||||
|
||||
private Team createTeamIfNotFound(Sport football, String name, String shortName) {
|
||||
log.info("createTeamIfNotFound: {}", name);
|
||||
Team team = teamRepository.findByName(name);
|
||||
if (team == null) {
|
||||
log.info("Team {} not found, will create it", name);
|
||||
team = new Team();
|
||||
team.setName(name);
|
||||
team.setShortName(shortName);
|
||||
team.setSport(football);
|
||||
teamRepository.save(team);
|
||||
}
|
||||
return team;
|
||||
}
|
||||
|
||||
private FieldPosition createPosition(Sport sport, String shortName, String name) {
|
||||
log.info("createPosition: {} for Sport {}", name, sport.getName());
|
||||
FieldPosition fieldPosition = fieldPositionRepository.findByShortNameAndSport(shortName, sport);
|
||||
if (fieldPosition == null) {
|
||||
log.info("Position {} not found, will create it", name);
|
||||
fieldPosition = new FieldPosition();
|
||||
fieldPosition.setShortName(shortName);
|
||||
fieldPosition.setName(name);
|
||||
fieldPosition.setSport(sport);
|
||||
fieldPositionRepository.save(fieldPosition);
|
||||
}
|
||||
return fieldPosition;
|
||||
}
|
||||
|
||||
private Vendor createVendorIfNotFound(String name) {
|
||||
log.info("createVendorIfNotFound: {}", name);
|
||||
Vendor vendor = vendorRepository.findByName(name);
|
||||
if (vendor == null) {
|
||||
log.info("Vendor {} not found, will create it", name);
|
||||
vendor = new Vendor();
|
||||
vendor.setName(name);
|
||||
vendorRepository.save(vendor);
|
||||
}
|
||||
return vendor;
|
||||
}
|
||||
|
||||
private Player createPlayerIfNotFound(String firstName, String lastName) {
|
||||
log.info("createPlayerIfNotFound: {} {}", firstName, lastName);
|
||||
Player player = playerRepository.findByFirstNameAndLastName(firstName, lastName);
|
||||
if (player == null) {
|
||||
log.info("Player {} {} not found, will create it", firstName, lastName);
|
||||
player = new Player();
|
||||
player.setFirstName(firstName);
|
||||
player.setLastName(lastName);
|
||||
playerRepository.save(player);
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
private CardSet createCardSetIfNotFound(String setname, Vendor vendor, boolean parallelSet, boolean insertSet) {
|
||||
log.info("createCardSetIfNotFound: {} {}", setname, vendor.getName());
|
||||
CardSet cardSet = cardSetRepository.findByNameAndVendor(setname, vendor);
|
||||
if (cardSet == null) {
|
||||
log.info("CardType {} not found, will create it", cardSet);
|
||||
cardSet = new CardSet();
|
||||
cardSet.setName(setname);
|
||||
cardSet.setVendor(vendor);
|
||||
cardSet.setParallelSet(parallelSet);
|
||||
cardSet.setInsertSet(insertSet);
|
||||
cardSetRepository.save(cardSet);
|
||||
}
|
||||
return cardSet;
|
||||
}
|
||||
|
||||
private Rooster createRoosterIfNotFound(Player player, Team team, FieldPosition fieldPosition, int year) {
|
||||
log.info("createRoosterIfNotFound; {} {} {} {}", player.getFirstName(), player.getLastName(), team.getName(),
|
||||
year);
|
||||
Rooster rooster = roosterRepository.findByReferences(player, team, fieldPosition, year);
|
||||
if (rooster == null) {
|
||||
log.info("Rooster {} not found, will create it", player);
|
||||
rooster = new Rooster();
|
||||
rooster.setPlayer(player);
|
||||
rooster.setTeam(team);
|
||||
rooster.setPosition(fieldPosition);
|
||||
rooster.setYear(year);
|
||||
roosterRepository.save(rooster);
|
||||
}
|
||||
return rooster;
|
||||
}
|
||||
|
||||
private void createCardIfNotFound(int cardNumber, int year, Vendor vendor, CardSet cardset, Rooster rooster) {
|
||||
log.info("createCardIfNotFound: vendor={} cardset={} rooster={} cardNumber={} year={}", vendor, cardset,
|
||||
rooster, cardNumber, year);
|
||||
Card card = cardRepository.search(vendor, cardset, rooster, cardNumber, year);
|
||||
if (card == null) {
|
||||
card = new Card();
|
||||
card.setVendor(vendor);
|
||||
card.setCardSet(cardset);
|
||||
card.setRooster(rooster);
|
||||
card.setCardNumber(cardNumber);
|
||||
card.setYear(year);
|
||||
cardRepository.save(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +38,8 @@ public class CardSet extends AbstractEntity {
|
||||
private boolean parallelSet = false;
|
||||
|
||||
private boolean insertSet = false;
|
||||
|
||||
public String getVendorName() {
|
||||
return vendor.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,19 +11,17 @@ import jakarta.validation.constraints.NotNull;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(indexes = {@Index(columnList = "team_id, player_id, position_id")},
|
||||
uniqueConstraints = {@UniqueConstraint(name = "uniqueRooster", columnNames = {"year", "team_id", "player_id", "position_id"})}
|
||||
)
|
||||
@Table(indexes = { @Index(columnList = "team_id, player_id, position_id") }, uniqueConstraints = {
|
||||
@UniqueConstraint(name = "uniqueRooster", columnNames = { "year", "team_id", "player_id", "position_id" }) })
|
||||
public class Rooster extends AbstractEntity {
|
||||
|
||||
private int year;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "team_id")
|
||||
@NotNull
|
||||
|
||||
@@ -14,19 +14,15 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* Represents a vendor entity.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(indexes = {@Index(columnList = "name")},
|
||||
uniqueConstraints = {@UniqueConstraint(columnNames = "name")}
|
||||
)
|
||||
@Table(indexes = { @Index(columnList = "name") }, uniqueConstraints = { @UniqueConstraint(columnNames = "name") })
|
||||
public class Vendor extends AbstractEntity {
|
||||
|
||||
@NotEmpty
|
||||
@@ -35,4 +31,9 @@ public class Vendor extends AbstractEntity {
|
||||
@OneToMany(fetch = FetchType.EAGER, mappedBy = "vendor")
|
||||
@Nullable
|
||||
private List<CardSet> cardSets;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Vendor{id=" + this.getId() + ", name=" + name + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import de.thpeetz.kontor.admin.data.MetaDataTable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -177,7 +176,7 @@ public class SportService {
|
||||
}
|
||||
|
||||
private String updateSportFields(Sport sport, Map<String, String> fields) {
|
||||
String status = "";
|
||||
StringBuilder status = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : fields.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
@@ -185,11 +184,11 @@ public class SportService {
|
||||
case "id", "created_date", "last_modified_date", "version":
|
||||
break;
|
||||
case "table_name":
|
||||
status += sport.updateName(value);
|
||||
status.append(sport.updateName(value));
|
||||
default:
|
||||
log.info("field {} is unknown for table {}", key, sport.getClass().getName());
|
||||
}
|
||||
}
|
||||
return status;
|
||||
return status.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package de.thpeetz.kontor.tysc.views;
|
||||
|
||||
import com.vaadin.flow.component.button.*;
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import de.thpeetz.kontor.common.views.*;
|
||||
import lombok.*;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
@@ -13,12 +16,13 @@ import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
|
||||
import de.thpeetz.kontor.common.views.MainLayout;
|
||||
import de.thpeetz.kontor.tysc.TyscConstants;
|
||||
import de.thpeetz.kontor.tysc.data.CardSet;
|
||||
import de.thpeetz.kontor.tysc.services.CardService;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@SpringComponent
|
||||
@Scope("prototype")
|
||||
@PermitAll
|
||||
@@ -26,8 +30,26 @@ import jakarta.annotation.security.PermitAll;
|
||||
@PageTitle("CardSet | Tysc | Kontor")
|
||||
public class CardSetView extends VerticalLayout {
|
||||
|
||||
Grid<CardSet> grid = new Grid<>(CardSet.class);
|
||||
@Getter
|
||||
Grid<CardSet> grid = new Grid<>(CardSet.class, false);
|
||||
Grid.Column<CardSet> idColumn = grid.addColumn(CardSet::getId)
|
||||
.setHeader("ID").setResizable(true).setSortable(true);
|
||||
Grid.Column<CardSet> createdColumn = grid.addColumn(CardSet::getCreatedDate)
|
||||
.setHeader("Erstellt").setResizable(true).setSortable(true);
|
||||
Grid.Column<CardSet> modifiedColumn = grid.addColumn(CardSet::getLastModifiedDate)
|
||||
.setHeader("Geändert").setResizable(true).setSortable(true);
|
||||
Grid.Column<CardSet> versionColumn = grid.addColumn(CardSet::getVersion)
|
||||
.setHeader("Version").setResizable(true).setSortable(true);
|
||||
Grid.Column<CardSet> nameColumn = grid.addColumn(CardSet::getName)
|
||||
.setHeader("Comic").setResizable(true).setSortable(true);
|
||||
Grid.Column<CardSet> vendorNameColumn = grid.addColumn(CardSet::getVendorName)
|
||||
.setHeader("Hersteller").setResizable(true).setSortable(true);
|
||||
Grid.Column<CardSet> parallelSetColumn = grid.addComponentColumn(parallelSet -> StatusIcon.create(parallelSet.isParallelSet()))
|
||||
.setHeader("Parallelset?").setWidth("6rem").setSortable(true);
|
||||
Grid.Column<CardSet> insertSetColumn = grid.addComponentColumn(insertSet -> StatusIcon.create(insertSet.isInsertSet()))
|
||||
.setHeader("Parallelset?").setWidth("6rem").setSortable(true);
|
||||
TextField filterText = new TextField();
|
||||
@Getter
|
||||
CardSetForm form;
|
||||
CardService service;
|
||||
|
||||
@@ -42,22 +64,18 @@ public class CardSetView extends VerticalLayout {
|
||||
updateList();
|
||||
}
|
||||
|
||||
public Grid<CardSet> getGrid() {
|
||||
return grid;
|
||||
}
|
||||
|
||||
private void configureGrid() {
|
||||
grid.addClassName("cardSet-grid");
|
||||
grid.setSizeFull();
|
||||
grid.setColumns("name", "vendor.name", "parallelSet", "insertSet");
|
||||
//grid.setColumns("name", "vendor.name", "parallelSet", "insertSet");
|
||||
grid.getColumns().forEach(col -> col.setAutoWidth(true));
|
||||
idColumn.setVisible(false);
|
||||
createdColumn.setVisible(false);
|
||||
modifiedColumn.setVisible(false);
|
||||
versionColumn.setVisible(false);
|
||||
grid.asSingleSelect().addValueChangeListener(event -> editCardSet(event.getValue()));
|
||||
}
|
||||
|
||||
public CardSetForm getForm() {
|
||||
return form;
|
||||
}
|
||||
|
||||
private void configureForm() {
|
||||
form = new CardSetForm();
|
||||
form.setWidth("25em");
|
||||
@@ -67,18 +85,6 @@ public class CardSetView extends VerticalLayout {
|
||||
form.addCloseListener(e -> closeEditor());
|
||||
}
|
||||
|
||||
private void saveCardSet(CardSetForm.SaveEvent event) {
|
||||
service.saveCardSet(event.getCardSet());
|
||||
updateList();
|
||||
closeEditor();
|
||||
}
|
||||
|
||||
private void deleteCardSet(CardSetForm.DeleteEvent event) {
|
||||
service.deleteCardSet(event.getCardSet());
|
||||
updateList();
|
||||
closeEditor();
|
||||
}
|
||||
|
||||
private Component getContent() {
|
||||
HorizontalLayout content = new HorizontalLayout(grid, form);
|
||||
content.setFlexGrow(2, grid);
|
||||
@@ -97,11 +103,34 @@ public class CardSetView extends VerticalLayout {
|
||||
Button addCardSetButton = new Button("Add cardSet");
|
||||
addCardSetButton.addClickListener(click -> addCardSet());
|
||||
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addCardSetButton);
|
||||
Button menuButton = new Button("Show/Hide Columns");
|
||||
menuButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||
ColumnToggleContextMenu<CardSet> columnToggleContextMenu = new ColumnToggleContextMenu<>(menuButton);
|
||||
columnToggleContextMenu.addColumnToggleItem(idColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(createdColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(modifiedColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(versionColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(nameColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(vendorNameColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(parallelSetColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(insertSetColumn);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addCardSetButton, menuButton);
|
||||
toolbar.addClassName("toolbar");
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
private void saveCardSet(CardSetForm.SaveEvent event) {
|
||||
service.saveCardSet(event.getCardSet());
|
||||
updateList();
|
||||
closeEditor();
|
||||
}
|
||||
|
||||
private void deleteCardSet(CardSetForm.DeleteEvent event) {
|
||||
service.deleteCardSet(event.getCardSet());
|
||||
updateList();
|
||||
closeEditor();
|
||||
}
|
||||
|
||||
public void editCardSet(CardSet cardSet) {
|
||||
if (cardSet == null) {
|
||||
closeEditor();
|
||||
|
||||
@@ -51,7 +51,6 @@ public class CardView extends VerticalLayout {
|
||||
.setHeader("Inserts").setWidth("6rem").setSortable(true);
|
||||
Grid.Column<Card> parallelSetColumn = grid.addComponentColumn(card -> StatusIcon.create(card.getCardSet().isParallelSet()))
|
||||
.setHeader("Parallels").setWidth("6rem").setSortable(true);
|
||||
|
||||
Grid.Column<Card> playerColumn = grid.addColumn(Card::getPlayerName).setHeader("Spieler").setResizable(true).setSortable(true);
|
||||
TextField filterText = new TextField();
|
||||
@Getter
|
||||
@@ -128,9 +127,10 @@ public class CardView extends VerticalLayout {
|
||||
columnToggleContextMenu.addColumnToggleItem(yearColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(vendorColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(cardSetColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(insertSetColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(parallelSetColumn);
|
||||
columnToggleContextMenu.addColumnToggleItem(playerColumn);
|
||||
HorizontalLayout toolbar = new HorizontalLayout(filterText, addCardButton, menuButton);
|
||||
|
||||
toolbar.addClassName("toolbar");
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ spring:
|
||||
ddl-auto: update
|
||||
#ddl-auto: create-drop
|
||||
show-sql: false
|
||||
properties:
|
||||
hibernate:
|
||||
#dialect: org.hibernate.dialect.PostgreSQLDialect
|
||||
sql:
|
||||
init:
|
||||
mode: never
|
||||
@@ -21,14 +24,25 @@ spring:
|
||||
multipart:
|
||||
max-file-size: 10MB
|
||||
max-request-size: 10MB
|
||||
camel:
|
||||
cloud:
|
||||
enabled: true
|
||||
springboot:
|
||||
routes-reload-enabled: true
|
||||
routes-reload-directory: routes
|
||||
routes-relaod-pattern: "*.xml"
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
include: health,info,metrics,prometheus,camelroutes
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
probes:
|
||||
enabled: true
|
||||
prometheus:
|
||||
enabled: true
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
@@ -36,6 +50,10 @@ logging:
|
||||
hibernate: INFO
|
||||
springframework:
|
||||
web: INFO
|
||||
jms: DEBUG
|
||||
apache:
|
||||
activemq:
|
||||
artemis: DEBUG
|
||||
guru:
|
||||
springframework:
|
||||
controllers: DEBUG
|
||||
@@ -55,12 +73,16 @@ spring:
|
||||
activate:
|
||||
on-profile: prod
|
||||
datasource:
|
||||
driverClassName: org.mariadb.jdbc.Driver
|
||||
url: jdbc:mariadb://mariadb:3306/kontor
|
||||
url: jdbc:postgresql://postgres:5432/kontor
|
||||
username: 'kontor'
|
||||
password: 'kontor'
|
||||
artemis:
|
||||
mode: native
|
||||
broker-url: tcp://activemq:61616
|
||||
user: artemis
|
||||
password: artemis
|
||||
server:
|
||||
port: 8000
|
||||
port: 8100
|
||||
---
|
||||
spring:
|
||||
config:
|
||||
@@ -69,19 +91,13 @@ spring:
|
||||
devtools:
|
||||
add-properties: false
|
||||
datasource:
|
||||
driverClassName: org.mariadb.jdbc.Driver
|
||||
url: jdbc:mariadb://localhost:3306/kontor
|
||||
username: 'kontor'
|
||||
password: 'kontor'
|
||||
#driverClassName: org.hsqldb.jdbc.JDBCDriver
|
||||
#url: jdbc:hsqldb:file:kontorHSQLDB
|
||||
#username: 'sa'
|
||||
#password: 'sa'
|
||||
#driverClassName: org.sqlite.JDBC
|
||||
#url: "jdbc:sqlite:file:./kontorDb?cache=shared"
|
||||
#username=sa
|
||||
#password=sa
|
||||
#jpa
|
||||
#database-platform: org.hibernate.community.dialect.SQLiteDialect
|
||||
url: jdbc:postgresql://localhost:5432/kontor
|
||||
username: kontor
|
||||
password: kontor
|
||||
artemis:
|
||||
mode: native
|
||||
broker-url: tcp://localhost:61616
|
||||
user: artemis
|
||||
password: artemis
|
||||
server:
|
||||
port: 8085
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<property name="LOGS" value="./logs" />
|
||||
<property name="LOGS" value="logs" />
|
||||
|
||||
<appender name="Console"
|
||||
class="ch.qos.logback.core.ConsoleAppender">
|
||||
|
||||
@@ -1,11 +1,30 @@
|
||||
package de.thpeetz.kontor;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SpringBootTest
|
||||
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.builder.NotifyBuilder;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
|
||||
@CamelSpringBootTest
|
||||
@SpringBootTest(classes = Application.class)
|
||||
class ApplicationTests {
|
||||
@Autowired
|
||||
private CamelContext camelContext;
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void shouldProduceMessages() throws Exception {
|
||||
NotifyBuilder notify = new NotifyBuilder(camelContext).whenDone(1).create();
|
||||
assertTrue(notify.matches(10, TimeUnit.SECONDS));
|
||||
}
|
||||
@Test
|
||||
void contextLoads() {
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.repository.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@@ -4,8 +4,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import de.thpeetz.kontor.comics.repository.*;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
@@ -13,7 +12,6 @@ import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
|
||||
@@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.repository.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import de.thpeetz.kontor.comics.repository.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@@ -2,8 +2,7 @@ package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.repository.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import de.thpeetz.kontor.comics.repository.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@@ -2,8 +2,7 @@ package de.thpeetz.kontor.comics.data;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.repository.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.repository.*;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -11,7 +12,6 @@ import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.orm.jpa.JpaSystemException;
|
||||
import org.springframework.transaction.TransactionSystemException;
|
||||
|
||||
import de.thpeetz.kontor.comics.TestConstants;
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
@@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package de.thpeetz.kontor.comics.data;
|
||||
package de.thpeetz.kontor.comics.repository;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.thpeetz.kontor.comics.data.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user