@@ -48,7 +48,6 @@ public class AdminConstants {
|
|||||||
data.addItem(new SideNavItem(ComicConstants.COMICWORK, ComicWorkView.class));
|
data.addItem(new SideNavItem(ComicConstants.COMICWORK, ComicWorkView.class));
|
||||||
data.addItem(new SideNavItem(MediaConstants.MEDIAACTORFILE, MediaActorFileView.class));
|
data.addItem(new SideNavItem(MediaConstants.MEDIAACTORFILE, MediaActorFileView.class));
|
||||||
data.addItem(new SideNavItem(AUTHORIZATION, AssignmentView.class));
|
data.addItem(new SideNavItem(AUTHORIZATION, AssignmentView.class));
|
||||||
data.addItem(new SideNavItem("Data Import", ModuleDataView.class));
|
|
||||||
administration.addItem(data);
|
administration.addItem(data);
|
||||||
return administration;
|
return administration;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
-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);
|
|
||||||
}
|
|
||||||
@@ -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,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.context.event.ContextRefreshedEvent;
|
||||||
import org.springframework.stereotype.Component;
|
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.ArticleAuthorRepository;
|
||||||
import de.thpeetz.kontor.bookshelf.data.Author;
|
import de.thpeetz.kontor.bookshelf.data.Author;
|
||||||
import de.thpeetz.kontor.bookshelf.data.AuthorRepository;
|
import de.thpeetz.kontor.bookshelf.data.AuthorRepository;
|
||||||
@@ -36,47 +35,12 @@ public class SetupModuleBookshelf implements ApplicationListener<ContextRefreshe
|
|||||||
@Autowired
|
@Autowired
|
||||||
private BookAuthorRepository bookAuthorRepository;
|
private BookAuthorRepository bookAuthorRepository;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ModuleService moduleService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||||
if (alreadySetup) {
|
if (alreadySetup) {
|
||||||
log.info("SetupModuleBookshelf already executed, skipping");
|
log.info("SetupModuleBookshelf already executed, skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!moduleService.importData(BookshelfConstants.BOOKSHELF)) {
|
|
||||||
log.info("Module Bookshelf should not setup data");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("Set up Bookshelf data");
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,6 @@ import org.springframework.context.event.ContextRefreshedEvent;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import de.thpeetz.kontor.admin.services.AdminService;
|
import de.thpeetz.kontor.admin.services.AdminService;
|
||||||
import de.thpeetz.kontor.admin.services.ModuleService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -18,9 +17,6 @@ public class SetupModuleMedia implements ApplicationListener<ContextRefreshedEve
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AdminService adminService;
|
private AdminService adminService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ModuleService moduleService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||||
adminService.addPermission(MediaConstants.MEDIA_ROLE);
|
adminService.addPermission(MediaConstants.MEDIA_ROLE);
|
||||||
@@ -28,12 +24,6 @@ public class SetupModuleMedia implements ApplicationListener<ContextRefreshedEve
|
|||||||
log.info("SetupModuleMedia already executed, skipping");
|
log.info("SetupModuleMedia already executed, skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!moduleService.importData(MediaConstants.MEDIA)) {
|
|
||||||
log.info("Module media should not setup data");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("Set up Media data");
|
log.info("Set up Media data");
|
||||||
moduleService.setDataImported(MediaConstants.MEDIA);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import org.springframework.context.ApplicationListener;
|
|||||||
import org.springframework.context.event.ContextRefreshedEvent;
|
import org.springframework.context.event.ContextRefreshedEvent;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import de.thpeetz.kontor.admin.services.ModuleService;
|
|
||||||
import de.thpeetz.kontor.tysc.data.FieldPosition;
|
import de.thpeetz.kontor.tysc.data.FieldPosition;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@@ -54,440 +53,13 @@ public class SetupModuleTysc implements ApplicationListener<ContextRefreshedEven
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CardRepository cardRepository;
|
private CardRepository cardRepository;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ModuleService moduleService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||||
if (alreadySetup) {
|
if (alreadySetup) {
|
||||||
log.info("SetupDataLoader(TYSC) already executed, skipping");
|
log.info("SetupDataLoader(TYSC) already executed, skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!moduleService.importData(TyscConstants.TYSC)) {
|
|
||||||
log.info("Module TradeYourSportsCards should not setup data");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
log.info("Setp up TYSC data");
|
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;
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user