This commit is contained in:
Francesco 2023-09-22 16:55:50 +02:00
parent 4e0ecb7ef3
commit 72aa1417f3
31 changed files with 96 additions and 94 deletions

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin;
package tech.ailef.dbadmin.external;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@ -28,13 +28,13 @@ import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.PersistenceContext;
import tech.ailef.dbadmin.annotations.DisplayFormat;
import tech.ailef.dbadmin.dbmapping.AdvancedJpaRepository;
import tech.ailef.dbadmin.dbmapping.DbField;
import tech.ailef.dbadmin.dbmapping.DbFieldType;
import tech.ailef.dbadmin.dbmapping.DbObjectSchema;
import tech.ailef.dbadmin.exceptions.DbAdminException;
import tech.ailef.dbadmin.misc.Utils;
import tech.ailef.dbadmin.external.annotations.DisplayFormat;
import tech.ailef.dbadmin.external.dbmapping.AdvancedJpaRepository;
import tech.ailef.dbadmin.external.dbmapping.DbField;
import tech.ailef.dbadmin.external.dbmapping.DbFieldType;
import tech.ailef.dbadmin.external.dbmapping.DbObjectSchema;
import tech.ailef.dbadmin.external.exceptions.DbAdminException;
import tech.ailef.dbadmin.external.misc.Utils;
/**
* The main DbAdmin class responsible for the initialization phase. This class scans

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin;
package tech.ailef.dbadmin.external;
import java.util.Properties;
@ -21,7 +21,7 @@ import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import jakarta.persistence.EntityManager;
import tech.repo.Action;
import tech.ailef.dbadmin.internal.model.Action;
@ConditionalOnProperty(name = "dbadmin.enabled", matchIfMissing = true)
@ComponentScan
@ -30,7 +30,7 @@ import tech.repo.Action;
@EnableJpaRepositories(
entityManagerFactoryRef = "internalEntityManagerFactory",
transactionManagerRef = "internalTransactionManager",
basePackages = { "tech.repo" }
basePackages = { "tech.ailef.dbadmin.internal.repository" }
)
@EnableTransactionManagement
public class DbAdminAutoConfiguration {
@ -52,7 +52,7 @@ public class DbAdminAutoConfiguration {
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
factoryBean.setDataSource(internalDataSource());
factoryBean.setPersistenceUnitName("internal");
factoryBean.setPackagesToScan("tech.repo"); // , "tech.ailef.dbadmin.repository");
factoryBean.setPackagesToScan("tech.ailef.dbadmin.internal.model"); // , "tech.ailef.dbadmin.repository");
factoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
Properties properties = new Properties();
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin;
package tech.ailef.dbadmin.external;
import java.util.HashMap;
import java.util.Map;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.annotations;
package tech.ailef.dbadmin.external.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.annotations;
package tech.ailef.dbadmin.external.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.annotations;
package tech.ailef.dbadmin.external.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.annotations;
package tech.ailef.dbadmin.external.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.annotations;
package tech.ailef.dbadmin.external.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.controller;
package tech.ailef.dbadmin.external.controller;
import java.util.ArrayList;
import java.util.HashMap;
@ -32,18 +32,18 @@ import jakarta.persistence.PersistenceContext;
import jakarta.persistence.PersistenceUnit;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import tech.ailef.dbadmin.DbAdmin;
import tech.ailef.dbadmin.DbAdminProperties;
import tech.ailef.dbadmin.dbmapping.DbAdminRepository;
import tech.ailef.dbadmin.dbmapping.DbObject;
import tech.ailef.dbadmin.dbmapping.DbObjectSchema;
import tech.ailef.dbadmin.dto.CompareOperator;
import tech.ailef.dbadmin.dto.PaginatedResult;
import tech.ailef.dbadmin.dto.QueryFilter;
import tech.ailef.dbadmin.exceptions.InvalidPageException;
import tech.ailef.dbadmin.misc.Utils;
import tech.repo.Action;
import tech.repo.ActionRepository;
import tech.ailef.dbadmin.external.DbAdmin;
import tech.ailef.dbadmin.external.DbAdminProperties;
import tech.ailef.dbadmin.external.dbmapping.DbAdminRepository;
import tech.ailef.dbadmin.external.dbmapping.DbObject;
import tech.ailef.dbadmin.external.dbmapping.DbObjectSchema;
import tech.ailef.dbadmin.external.dto.CompareOperator;
import tech.ailef.dbadmin.external.dto.PaginatedResult;
import tech.ailef.dbadmin.external.dto.QueryFilter;
import tech.ailef.dbadmin.external.exceptions.InvalidPageException;
import tech.ailef.dbadmin.external.misc.Utils;
import tech.ailef.dbadmin.internal.model.Action;
import tech.ailef.dbadmin.internal.repository.ActionRepository;
/**
* The main DbAdmin controller that register most of the routes of the web interface.

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.controller;
package tech.ailef.dbadmin.external.controller;
import java.util.Optional;
@ -17,12 +17,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.server.ResponseStatusException;
import tech.ailef.dbadmin.DbAdmin;
import tech.ailef.dbadmin.dbmapping.DbAdminRepository;
import tech.ailef.dbadmin.dbmapping.DbFieldValue;
import tech.ailef.dbadmin.dbmapping.DbObject;
import tech.ailef.dbadmin.dbmapping.DbObjectSchema;
import tech.ailef.dbadmin.exceptions.DbAdminException;
import tech.ailef.dbadmin.external.DbAdmin;
import tech.ailef.dbadmin.external.dbmapping.DbAdminRepository;
import tech.ailef.dbadmin.external.dbmapping.DbFieldValue;
import tech.ailef.dbadmin.external.dbmapping.DbObject;
import tech.ailef.dbadmin.external.dbmapping.DbObjectSchema;
import tech.ailef.dbadmin.external.exceptions.DbAdminException;
/**
* Controller to serve file or images (`@DisplayImage`)

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.controller;
package tech.ailef.dbadmin.external.controller;
import java.util.Map;
@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;
import jakarta.servlet.http.HttpServletRequest;
import tech.ailef.dbadmin.DbAdminProperties;
import tech.ailef.dbadmin.external.DbAdminProperties;
/**
* This class registers some ModelAttribute objects that are

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.controller.rest;
package tech.ailef.dbadmin.external.controller.rest;
import java.util.List;
import java.util.stream.Collectors;
@ -11,10 +11,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tech.ailef.dbadmin.DbAdmin;
import tech.ailef.dbadmin.dbmapping.DbAdminRepository;
import tech.ailef.dbadmin.dbmapping.DbObjectSchema;
import tech.ailef.dbadmin.dto.AutocompleteSearchResult;
import tech.ailef.dbadmin.external.DbAdmin;
import tech.ailef.dbadmin.external.dbmapping.DbAdminRepository;
import tech.ailef.dbadmin.external.dbmapping.DbObjectSchema;
import tech.ailef.dbadmin.external.dto.AutocompleteSearchResult;
/**
* API controller for autocomplete results

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.controller.rest;
package tech.ailef.dbadmin.external.controller.rest;
import java.util.HashMap;
import java.util.List;
@ -14,12 +14,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tech.ailef.dbadmin.DbAdmin;
import tech.ailef.dbadmin.DbAdminProperties;
import tech.ailef.dbadmin.dbmapping.DbAdminRepository;
import tech.ailef.dbadmin.dbmapping.DbObjectSchema;
import tech.ailef.dbadmin.dto.PaginatedResult;
import tech.ailef.dbadmin.exceptions.DbAdminException;
import tech.ailef.dbadmin.external.DbAdmin;
import tech.ailef.dbadmin.external.DbAdminProperties;
import tech.ailef.dbadmin.external.dbmapping.DbAdminRepository;
import tech.ailef.dbadmin.external.dbmapping.DbObjectSchema;
import tech.ailef.dbadmin.external.dto.PaginatedResult;
import tech.ailef.dbadmin.external.exceptions.DbAdminException;
@RestController
@RequestMapping(value = {"/${dbadmin.baseUrl}/api", "/${dbadmin.baseUrl}/api/"})

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.dbmapping;
package tech.ailef.dbadmin.external.dbmapping;
import java.io.IOException;
import java.time.LocalDate;
@ -21,9 +21,9 @@ import jakarta.persistence.criteria.CriteriaUpdate;
import jakarta.persistence.criteria.Path;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import tech.ailef.dbadmin.dto.CompareOperator;
import tech.ailef.dbadmin.dto.QueryFilter;
import tech.ailef.dbadmin.exceptions.DbAdminException;
import tech.ailef.dbadmin.external.dto.CompareOperator;
import tech.ailef.dbadmin.external.dto.QueryFilter;
import tech.ailef.dbadmin.external.exceptions.DbAdminException;
@SuppressWarnings("rawtypes")
public class AdvancedJpaRepository extends SimpleJpaRepository {

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.dbmapping;
package tech.ailef.dbadmin.external.dbmapping;
import java.io.IOException;
import java.util.ArrayList;
@ -21,11 +21,11 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import tech.ailef.dbadmin.dto.PaginatedResult;
import tech.ailef.dbadmin.dto.PaginationInfo;
import tech.ailef.dbadmin.dto.QueryFilter;
import tech.ailef.dbadmin.exceptions.DbAdminException;
import tech.ailef.dbadmin.exceptions.InvalidPageException;
import tech.ailef.dbadmin.external.dto.PaginatedResult;
import tech.ailef.dbadmin.external.dto.PaginationInfo;
import tech.ailef.dbadmin.external.dto.QueryFilter;
import tech.ailef.dbadmin.external.exceptions.DbAdminException;
import tech.ailef.dbadmin.external.exceptions.InvalidPageException;
/**
* Implements the basic CRUD operations (and some more)

View File

@ -1,10 +1,10 @@
package tech.ailef.dbadmin.dbmapping;
package tech.ailef.dbadmin.external.dbmapping;
import java.lang.reflect.Field;
import com.fasterxml.jackson.annotation.JsonIgnore;
import tech.ailef.dbadmin.annotations.DisplayImage;
import tech.ailef.dbadmin.external.annotations.DisplayImage;
public class DbField {
protected String dbName;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.dbmapping;
package tech.ailef.dbadmin.external.dbmapping;
import java.io.IOException;
import java.math.BigDecimal;
@ -11,8 +11,8 @@ import org.springframework.web.multipart.MultipartFile;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import tech.ailef.dbadmin.dto.CompareOperator;
import tech.ailef.dbadmin.exceptions.DbAdminException;
import tech.ailef.dbadmin.external.dto.CompareOperator;
import tech.ailef.dbadmin.external.exceptions.DbAdminException;
public enum DbFieldType {
INTEGER {

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.dbmapping;
package tech.ailef.dbadmin.external.dbmapping;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.dbmapping;
package tech.ailef.dbadmin.external.dbmapping;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -11,9 +11,9 @@ import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import tech.ailef.dbadmin.annotations.DisplayName;
import tech.ailef.dbadmin.exceptions.DbAdminException;
import tech.ailef.dbadmin.misc.Utils;
import tech.ailef.dbadmin.external.annotations.DisplayName;
import tech.ailef.dbadmin.external.exceptions.DbAdminException;
import tech.ailef.dbadmin.external.misc.Utils;
public class DbObject {
private Object instance;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.dbmapping;
package tech.ailef.dbadmin.external.dbmapping;
import java.lang.reflect.Method;
import java.util.ArrayList;
@ -16,11 +16,11 @@ import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import tech.ailef.dbadmin.DbAdmin;
import tech.ailef.dbadmin.annotations.ComputedColumn;
import tech.ailef.dbadmin.annotations.Filterable;
import tech.ailef.dbadmin.exceptions.DbAdminException;
import tech.ailef.dbadmin.misc.Utils;
import tech.ailef.dbadmin.external.DbAdmin;
import tech.ailef.dbadmin.external.annotations.ComputedColumn;
import tech.ailef.dbadmin.external.annotations.Filterable;
import tech.ailef.dbadmin.external.exceptions.DbAdminException;
import tech.ailef.dbadmin.external.misc.Utils;
public class DbObjectSchema {
/**

View File

@ -1,6 +1,6 @@
package tech.ailef.dbadmin.dto;
package tech.ailef.dbadmin.external.dto;
import tech.ailef.dbadmin.dbmapping.DbObject;
import tech.ailef.dbadmin.external.dbmapping.DbObject;
public class AutocompleteSearchResult {
private Object id;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.dto;
package tech.ailef.dbadmin.external.dto;
public enum CompareOperator {
GT {

View File

@ -1,3 +1,4 @@
package tech.ailef.dbadmin.external.dto;
//package tech.ailef.dbadmin.dto;
//
//import java.util.Set;

View File

@ -1,8 +1,8 @@
package tech.ailef.dbadmin.dto;
package tech.ailef.dbadmin.external.dto;
import java.util.List;
import tech.ailef.dbadmin.dbmapping.DbObject;
import tech.ailef.dbadmin.external.dbmapping.DbObject;
public class PaginatedResult {
private PaginationInfo pagination;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.dto;
package tech.ailef.dbadmin.external.dto;
import java.util.ArrayList;
import java.util.List;
@ -8,7 +8,7 @@ import java.util.stream.IntStream;
import org.springframework.util.MultiValueMap;
import tech.ailef.dbadmin.misc.Utils;
import tech.ailef.dbadmin.external.misc.Utils;
/**
* Attached as output to requests that have a paginated response,

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.dto;
package tech.ailef.dbadmin.external.dto;
import java.util.Objects;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.exceptions;
package tech.ailef.dbadmin.external.exceptions;
public class DbAdminException extends RuntimeException {
private static final long serialVersionUID = 8120227031645804467L;

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.exceptions;
package tech.ailef.dbadmin.external.exceptions;
/**
* Thrown during the computation of pagination if the requested

View File

@ -1,4 +1,4 @@
package tech.ailef.dbadmin.misc;
package tech.ailef.dbadmin.external.misc;
import java.util.ArrayList;
import java.util.HashSet;
@ -8,9 +8,9 @@ import java.util.Set;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import tech.ailef.dbadmin.dto.CompareOperator;
import tech.ailef.dbadmin.dto.QueryFilter;
import tech.ailef.dbadmin.exceptions.DbAdminException;
import tech.ailef.dbadmin.external.dto.CompareOperator;
import tech.ailef.dbadmin.external.dto.QueryFilter;
import tech.ailef.dbadmin.external.exceptions.DbAdminException;
public interface Utils {
public static String camelToSnake(String v) {

View File

@ -1,4 +1,4 @@
package tech.repo;
package tech.ailef.dbadmin.internal.model;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;

View File

@ -1,4 +1,4 @@
package tech.repo;
package tech.ailef.dbadmin.internal.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;
@ -6,6 +6,7 @@ import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import jakarta.persistence.EntityManager;
import tech.ailef.dbadmin.internal.model.Action;
@Repository
public interface ActionRepository extends JpaRepository<Action, Integer> {