Реструктуризация
This commit is contained in:
parent
34e72edbe0
commit
d153dc1c35
142
haiti-bom/pom.xml
Normal file
142
haiti-bom/pom.xml
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
|
<artifactId>haiti-bom</artifactId>
|
||||||
|
<version>0.0.1-RELEASE</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>Haiti BOM</name>
|
||||||
|
<description>Fast development to keep time on the beach</description>
|
||||||
|
<url>https://github.com/haiti-projects/haiti-framework</url>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>Apache License 2.0</name>
|
||||||
|
<url>https://github.com/haiti-projects/haiti-framework/blob/master/LICENSE</url>
|
||||||
|
<distribution>repo</distribution>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<connection>scm:git:https://github.com/haiti-projects/haiti-framework.git</connection>
|
||||||
|
<url>https://github.com/haiti-projects/haiti-framework</url>
|
||||||
|
<developerConnection>scm:git:https://github.com/haiti-projects/haiti-framework.git</developerConnection>
|
||||||
|
</scm>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>ossrh</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
</distributionManagement>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
|
||||||
|
<sadtech.haiti.context.version>0.0.1-RELEASE</sadtech.haiti.context.version>
|
||||||
|
<sadtech.haiti.core.version>0.0.1-RELEASE</sadtech.haiti.core.version>
|
||||||
|
<sadtech.haiti.filter.version>0.0.1-RELEASE</sadtech.haiti.filter.version>
|
||||||
|
<sadtech.haiti.filter.api.version>0.0.1-RELEASE</sadtech.haiti.filter.api.version>
|
||||||
|
<sadtech.haiti.filter.criteria.version>0.0.1-RELEASE</sadtech.haiti.filter.criteria.version>
|
||||||
|
<sadtech.haiti.database.version>0.0.1-RELEASE</sadtech.haiti.database.version>
|
||||||
|
|
||||||
|
<spring.data.elasticsearch.version>4.1.0</spring.data.elasticsearch.version>
|
||||||
|
<spring.data.jpa.version>2.4.0</spring.data.jpa.version>
|
||||||
|
<spring.data.commons.version>2.4.0</spring.data.commons.version>
|
||||||
|
|
||||||
|
<elasticsearch.version>7.9.3</elasticsearch.version>
|
||||||
|
<lombok.version>1.18.16</lombok.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
|
<artifactId>haiti-context</artifactId>
|
||||||
|
<version>${sadtech.haiti.context.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
|
<artifactId>haiti-core</artifactId>
|
||||||
|
<version>${sadtech.haiti.core.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
|
<artifactId>haiti-filter</artifactId>
|
||||||
|
<version>${sadtech.haiti.filter.api.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${lombok.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.elasticsearch</groupId>
|
||||||
|
<artifactId>elasticsearch</artifactId>
|
||||||
|
<version>${elasticsearch.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.persistence</groupId>
|
||||||
|
<artifactId>javax.persistence-api</artifactId>
|
||||||
|
<version>2.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- spring -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-elasticsearch</artifactId>
|
||||||
|
<version>${spring.data.elasticsearch.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-commons</artifactId>
|
||||||
|
<version>${spring.data.commons.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.data</groupId>
|
||||||
|
<artifactId>spring-data-jpa</artifactId>
|
||||||
|
<version>${spring.data.jpa.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>8</source>
|
||||||
|
<target>8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>uPagge</id>
|
||||||
|
<name>Struchkov Mark</name>
|
||||||
|
<email>upagge@ya.ru</email>
|
||||||
|
<organization>SADTECH</organization>
|
||||||
|
<url>https://upagge.sadtech.org</url>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
@ -6,11 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sadtech.haiti</groupId>
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
<artifactId>haiti</artifactId>
|
<artifactId>haiti</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>haiti-context</artifactId>
|
<artifactId>haiti-context</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-RELEASE</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sadtech.haiti</groupId>
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
<artifactId>haiti</artifactId>
|
<artifactId>haiti</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>haiti-core</artifactId>
|
<artifactId>haiti-core</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-RELEASE</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -19,8 +19,8 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.sadtech.haiti.filter</groupId>
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
<artifactId>filter-api</artifactId>
|
<artifactId>haiti-filter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
51
haiti-database/.gitignore
vendored
51
haiti-database/.gitignore
vendored
@ -1,51 +0,0 @@
|
|||||||
# Created by .ignore support plugin (hsz.mobi)
|
|
||||||
target/
|
|
||||||
pom.xml.tag
|
|
||||||
pom.xml.releaseBackup
|
|
||||||
pom.xml.versionsBackup
|
|
||||||
pom.xml.next
|
|
||||||
release.properties
|
|
||||||
dependency-reduced-pom.xml
|
|
||||||
buildNumber.properties
|
|
||||||
.mvn/timing.properties
|
|
||||||
.mvn/wrapper/maven-wrapper.jar
|
|
||||||
*.class
|
|
||||||
*.log
|
|
||||||
*.ctxt
|
|
||||||
.mtj.tmp/
|
|
||||||
*.jar
|
|
||||||
*.war
|
|
||||||
*.nar
|
|
||||||
*.ear
|
|
||||||
*.zip
|
|
||||||
*.tar.gz
|
|
||||||
*.rar
|
|
||||||
hs_err_pid*
|
|
||||||
.idea/**/workspace.xml
|
|
||||||
.idea/**/tasks.xml
|
|
||||||
.idea/**/usage.statistics.xml
|
|
||||||
.idea/**/dictionaries
|
|
||||||
.idea/**/shelf
|
|
||||||
.idea/**/contentModel.xml
|
|
||||||
.idea/**/dataSources/
|
|
||||||
.idea/**/dataSources.ids
|
|
||||||
.idea/**/dataSources.local.xml
|
|
||||||
.idea/**/sqlDataSources.xml
|
|
||||||
.idea/**/dynamic.xml
|
|
||||||
.idea/**/uiDesigner.xml
|
|
||||||
.idea/**/dbnavigator.xml
|
|
||||||
.idea/**/gradle.xml
|
|
||||||
.idea/**/libraries
|
|
||||||
cmake-build-*/
|
|
||||||
.idea/**/mongoSettings.xml
|
|
||||||
*.iws
|
|
||||||
out/
|
|
||||||
.idea_modules/
|
|
||||||
atlassian-ide-plugin.xml
|
|
||||||
.idea/replstate.xml
|
|
||||||
com_crashlytics_export_strings.xml
|
|
||||||
crashlytics.properties
|
|
||||||
crashlytics-build.properties
|
|
||||||
fabric.properties
|
|
||||||
.idea/httpRequests
|
|
||||||
.idea/caches/build_file_checksums.ser
|
|
@ -1,24 +0,0 @@
|
|||||||
package org.sadtech.haiti.database.entity;
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.MappedSuperclass;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@MappedSuperclass
|
|
||||||
@EqualsAndHashCode(of = "id")
|
|
||||||
public abstract class BasicEntity {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
@Column(name = "id", updatable = false, nullable = false)
|
|
||||||
protected Long id;
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package org.sadtech.haiti.database.repository;
|
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.sadtech.haiti.context.repository.simple.CrudOperation;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public abstract class AbstractCrudOperation<T, K> implements CrudOperation<T, K> {
|
|
||||||
|
|
||||||
private final JpaRepository<T, K> jpaRepository;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T save(@NonNull T entity) {
|
|
||||||
return OperationJpa.save(jpaRepository, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<T> findById(@NonNull K primaryKey) {
|
|
||||||
return OperationJpa.findById(jpaRepository, primaryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean existsById(@NonNull K primaryKey) {
|
|
||||||
return OperationJpa.existsById(jpaRepository, primaryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteById(@NonNull K primaryKey) {
|
|
||||||
OperationJpa.deleteById(jpaRepository, primaryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
package org.sadtech.haiti.database.repository;
|
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.sadtech.haiti.context.page.Pagination;
|
|
||||||
import org.sadtech.haiti.context.page.Sheet;
|
|
||||||
import org.sadtech.haiti.filter.Filter;
|
|
||||||
import org.sadtech.haiti.filter.FilterOperation;
|
|
||||||
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public abstract class AbstractFilterOperation<T, K> implements FilterOperation<T> {
|
|
||||||
|
|
||||||
private final JpaRepositoryImplementation<T, K> jpaRepository;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Sheet<T> findAll(@NonNull Filter filter, @NonNull Pagination pagination) {
|
|
||||||
return OperationJpa.findAll(jpaRepository, filter.build(), pagination);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<T> findFirst(@NonNull Filter filter) {
|
|
||||||
return OperationJpa.findFirst(jpaRepository, filter.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean exists(@NonNull Filter filter) {
|
|
||||||
return OperationJpa.exists(jpaRepository, filter.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count(@NonNull Filter filter) {
|
|
||||||
return OperationJpa.count(jpaRepository, filter.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package org.sadtech.haiti.database.repository;
|
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.sadtech.haiti.context.repository.simple.MultipleOperation;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public abstract class AbstractMultipleOperation<T, K> implements MultipleOperation<T, K> {
|
|
||||||
|
|
||||||
private final JpaRepository<T, K> jpaRepository;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<T> saveAll(@NonNull Collection<T> entities) {
|
|
||||||
return OperationJpa.saveAll(jpaRepository, entities);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteAllById(@NonNull Collection<K> primaryKeys) {
|
|
||||||
OperationJpa.deleteAllById(jpaRepository, primaryKeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
package org.sadtech.haiti.database.repository;
|
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.sadtech.haiti.context.page.Pagination;
|
|
||||||
import org.sadtech.haiti.context.page.Sheet;
|
|
||||||
import org.sadtech.haiti.context.repository.simple.PagingOperation;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public abstract class AbstractPagingOperation<T, K> implements PagingOperation<T> {
|
|
||||||
|
|
||||||
private final JpaRepository<T, K> jpaRepository;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Sheet<T> findAll(@NonNull Pagination pagination) {
|
|
||||||
return OperationJpa.findAll(jpaRepository, pagination);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
package org.sadtech.haiti.database.repository;
|
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import org.sadtech.haiti.context.page.Pagination;
|
|
||||||
import org.sadtech.haiti.context.page.Sheet;
|
|
||||||
import org.sadtech.haiti.database.util.Converter;
|
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class OperationJpa {
|
|
||||||
|
|
||||||
public static <T, K> T save(JpaRepository<T, K> jpaRepository, T entity) {
|
|
||||||
return jpaRepository.save(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, K> Optional<T> findById(JpaRepository<T, K> jpaRepository, K primaryKey) {
|
|
||||||
return jpaRepository.findById(primaryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <K, T> boolean existsById(JpaRepository<T, K> jpaRepository, K primaryKey) {
|
|
||||||
return jpaRepository.existsById(primaryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <K, T> void deleteById(JpaRepository<T, K> jpaRepository, K primaryKey) {
|
|
||||||
jpaRepository.deleteById(primaryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, K> Sheet<T> findAll(JpaRepository<T, K> jpaRepository, Pagination pagination) {
|
|
||||||
return Converter.page(
|
|
||||||
jpaRepository.findAll(
|
|
||||||
Converter.pagination(pagination)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, K> List<T> saveAll(JpaRepository<T, K> jpaRepository, Collection<T> entities) {
|
|
||||||
return jpaRepository.saveAll(entities);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <K, T> void deleteAllById(JpaRepository<T, K> jpaRepository, Collection<K> primaryKeys) {
|
|
||||||
primaryKeys.forEach(jpaRepository::deleteById);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, K> Optional<T> findFirst(JpaRepositoryImplementation<T, K> jpaRepository, Specification<T> specification) {
|
|
||||||
return jpaRepository.findOne(specification);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <K, T> boolean exists(JpaRepositoryImplementation<T, K> jpaRepository, Specification<T> specification) {
|
|
||||||
return jpaRepository.count(specification) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, K> List<T> findAll(JpaRepositoryImplementation<T, K> jpaRepository, Specification<T> specification) {
|
|
||||||
return jpaRepository.findAll(specification);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, K> Sheet<T> findAll(JpaRepositoryImplementation<T, K> jpaRepository, Specification<T> specification, Pagination pagination) {
|
|
||||||
return Converter.page(
|
|
||||||
jpaRepository.findAll(specification, Converter.pagination(pagination))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, K> long count(JpaRepositoryImplementation<T, K> jpaRepository, Specification<T> specification) {
|
|
||||||
return jpaRepository.count(specification);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package org.sadtech.haiti.database.repository.manager;
|
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.sadtech.haiti.database.repository.OperationJpa;
|
|
||||||
import org.sadtech.haiti.context.page.Pagination;
|
|
||||||
import org.sadtech.haiti.context.page.Sheet;
|
|
||||||
import org.sadtech.haiti.context.repository.SimpleManagerRepository;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public abstract class AbstractSimpleManagerRepository<T, K> implements SimpleManagerRepository<T, K> {
|
|
||||||
|
|
||||||
private final JpaRepository<T, K> jpaRepository;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T save(@NonNull T entity) {
|
|
||||||
return OperationJpa.save(jpaRepository, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<T> findById(@NonNull K primaryKey) {
|
|
||||||
return OperationJpa.findById(jpaRepository, primaryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean existsById(@NonNull K primaryKey) {
|
|
||||||
return OperationJpa.existsById(jpaRepository, primaryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteById(@NonNull K primaryKey) {
|
|
||||||
OperationJpa.deleteById(jpaRepository, primaryKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<T> saveAll(@NonNull Collection<T> entities) {
|
|
||||||
return OperationJpa.saveAll(jpaRepository, entities);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteAllById(@NonNull Collection<K> primaryKeys) {
|
|
||||||
OperationJpa.deleteAllById(jpaRepository, primaryKeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Sheet<T> findAll(@NonNull Pagination pagination) {
|
|
||||||
return OperationJpa.findAll(jpaRepository, pagination);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package org.sadtech.haiti.database.repository.manager;
|
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.sadtech.haiti.context.page.Pagination;
|
|
||||||
import org.sadtech.haiti.context.page.Sheet;
|
|
||||||
import org.sadtech.haiti.database.repository.OperationJpa;
|
|
||||||
import org.sadtech.haiti.filter.Filter;
|
|
||||||
import org.sadtech.haiti.filter.FilterOperation;
|
|
||||||
import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
|
||||||
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public abstract class FilterManagerRepository<T, K> extends AbstractSimpleManagerRepository<T, K> implements FilterOperation<T> {
|
|
||||||
|
|
||||||
private final JpaRepositoryImplementation<T, K> jpaRepositoryImplementation;
|
|
||||||
|
|
||||||
public FilterManagerRepository(JpaRepositoryImplementation<T, K> jpaRepository) {
|
|
||||||
super(jpaRepository);
|
|
||||||
this.jpaRepositoryImplementation = jpaRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Sheet<T> findAll(@NonNull Filter filter, @NonNull Pagination pagination) {
|
|
||||||
return OperationJpa.findAll(jpaRepositoryImplementation, filter.build(), pagination);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<T> findFirst(@NonNull Filter filter) {
|
|
||||||
try {
|
|
||||||
return OperationJpa.findFirst(jpaRepositoryImplementation, filter.build());
|
|
||||||
} catch (InvalidDataAccessResourceUsageException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean exists(@NonNull Filter filter) {
|
|
||||||
try {
|
|
||||||
return OperationJpa.exists(jpaRepositoryImplementation, filter.build());
|
|
||||||
} catch (InvalidDataAccessResourceUsageException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count(@NonNull Filter filter) {
|
|
||||||
try {
|
|
||||||
return OperationJpa.count(jpaRepositoryImplementation, filter.build());
|
|
||||||
} catch (InvalidDataAccessResourceUsageException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package org.sadtech.haiti.database.util;
|
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import org.sadtech.haiti.context.enums.TypeSort;
|
|
||||||
import org.sadtech.haiti.context.page.Pagination;
|
|
||||||
import org.sadtech.haiti.context.page.Sheet;
|
|
||||||
import org.sadtech.haiti.core.page.SheetImpl;
|
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
|
|
||||||
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
|
||||||
public class Converter {
|
|
||||||
|
|
||||||
public static Pageable pagination(@NonNull Pagination pagination) {
|
|
||||||
if (pagination.getTypeSort() != null) {
|
|
||||||
return PageRequest.of(
|
|
||||||
pagination.getPage(),
|
|
||||||
pagination.getSize(),
|
|
||||||
TypeSort.ASC.equals(pagination.getTypeSort()) ? Sort.Direction.ASC : Sort.Direction.DESC,
|
|
||||||
pagination.getFieldSort()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return PageRequest.of(pagination.getPage(), pagination.getSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Sheet<T> page(@NonNull Page<T> page) {
|
|
||||||
return SheetImpl.<T>builder()
|
|
||||||
.totalPage(page.getTotalPages())
|
|
||||||
.totalElement(page.getTotalElements())
|
|
||||||
.size(page.getSize())
|
|
||||||
.number(page.getNumber())
|
|
||||||
.content(page.getContent())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -6,11 +6,11 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sadtech.haiti</groupId>
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
<artifactId>haiti</artifactId>
|
<artifactId>haiti</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>haiti-database</artifactId>
|
<artifactId>haiti-filter</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-RELEASE</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -20,18 +20,18 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.sadtech.haiti</groupId>
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
<artifactId>haiti-core</artifactId>
|
<artifactId>haiti-context</artifactId>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.sadtech.haiti.filter</groupId>
|
|
||||||
<artifactId>criteria-filter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-jpa</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>uPagge</id>
|
||||||
|
<name>Struchkov Mark</name>
|
||||||
|
<email>upagge@ya.ru</email>
|
||||||
|
<organization>SADTECH</organization>
|
||||||
|
<url>https://t.me/uPagge</url>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
</project>
|
</project>
|
161
pom.xml
161
pom.xml
@ -6,107 +6,110 @@
|
|||||||
|
|
||||||
<groupId>org.sadtech.haiti</groupId>
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
<artifactId>haiti</artifactId>
|
<artifactId>haiti</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-RELEASE</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>haiti-context</module>
|
<module>haiti-context</module>
|
||||||
<module>haiti-core</module>
|
<module>haiti-core</module>
|
||||||
<module>haiti-database</module>
|
<module>haiti-filter</module>
|
||||||
|
<module>haiti-bom</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<profiles>
|
||||||
<java.version>1.8</java.version>
|
<profile>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<id>release</id>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<build>
|
||||||
|
<plugins>
|
||||||
<sadtech.haiti.context.version>0.0.1-SNAPSHOT</sadtech.haiti.context.version>
|
<plugin>
|
||||||
<sadtech.haiti.core.version>0.0.1-SNAPSHOT</sadtech.haiti.core.version>
|
<groupId>org.sonatype.plugins</groupId>
|
||||||
<sadtech.haiti.filter.api.version>0.0.1-SNAPSHOT</sadtech.haiti.filter.api.version>
|
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||||
<sadtech.haiti.filter.criteria.version>0.0.1-SNAPSHOT</sadtech.haiti.filter.criteria.version>
|
<version>1.6.7</version>
|
||||||
|
<extensions>true</extensions>
|
||||||
<spring.data.elasticsearch.version>4.1.0</spring.data.elasticsearch.version>
|
<configuration>
|
||||||
<spring.data.jpa.version>2.4.0</spring.data.jpa.version>
|
<serverId>ossrh</serverId>
|
||||||
<spring.data.commons.version>2.4.0</spring.data.commons.version>
|
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||||
|
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||||
<elasticsearch.version>7.9.3</elasticsearch.version>
|
</configuration>
|
||||||
<lombok.version>1.18.16</lombok.version>
|
</plugin>
|
||||||
</properties>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>2.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>2.9.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-javadocs</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
|
<version>1.5</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>sign-artifacts</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>sign</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.sadtech.haiti</groupId>
|
<groupId>org.sadtech.haiti</groupId>
|
||||||
<artifactId>haiti-context</artifactId>
|
<artifactId>haiti-bom</artifactId>
|
||||||
<version>${sadtech.haiti.context.version}</version>
|
<version>0.0.1-RELEASE</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.sadtech.haiti</groupId>
|
|
||||||
<artifactId>haiti-core</artifactId>
|
|
||||||
<version>${sadtech.haiti.core.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.sadtech.haiti.filter</groupId>
|
|
||||||
<artifactId>criteria-filter</artifactId>
|
|
||||||
<version>${sadtech.haiti.filter.criteria.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>${lombok.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.sadtech.haiti.filter</groupId>
|
|
||||||
<artifactId>filter-api</artifactId>
|
|
||||||
<version>${sadtech.haiti.filter.api.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.elasticsearch</groupId>
|
|
||||||
<artifactId>elasticsearch</artifactId>
|
|
||||||
<version>${elasticsearch.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.persistence</groupId>
|
|
||||||
<artifactId>javax.persistence-api</artifactId>
|
|
||||||
<version>2.2</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- spring -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-elasticsearch</artifactId>
|
|
||||||
<version>${spring.data.elasticsearch.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-commons</artifactId>
|
|
||||||
<version>${spring.data.commons.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-jpa</artifactId>
|
|
||||||
<version>${spring.data.jpa.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>8</source>
|
||||||
|
<target>8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>uPagge</id>
|
<id>uPagge</id>
|
||||||
<name>Struchkov Mark</name>
|
<name>Struchkov Mark</name>
|
||||||
<email>upagge@ya.ru</email>
|
<email>upagge@ya.ru</email>
|
||||||
<organization>SADTECH</organization>
|
<organization>SADTECH</organization>
|
||||||
<url>https://t.me/uPagge</url>
|
<url>https://uPagge.sadtech.org</url>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user