From 2eaf1bb157a8fc8d7b16aca8ac66c57e18a2cd07 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Wed, 12 Jan 2022 17:39:22 +0300 Subject: [PATCH] release-0.1.0 --- .gitignore | 85 +++++++++ pom.xml | 175 ++++++++++++++++++ .../haiti/filter/quarkus/CriteriaFilter.java | 93 ++++++++++ 3 files changed, 353 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/dev/struchkov/haiti/filter/quarkus/CriteriaFilter.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a0d6e2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,85 @@ +*.class +*.log +*.ctxt +.mtj.tmp/ +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar +hs_err_pid* +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 +.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 +*~ +.fuse_hidden* +.directory +.Trash-* +.nfs* +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db +*.stackdump +[Dd]esktop.ini +$RECYCLE.BIN/ +*.cab +*.msi +*.msix +*.msm +*.msp +*.lnk +.DS_Store +.AppleDouble +.LSOverride +Icon +._* +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..2b33d12 --- /dev/null +++ b/pom.xml @@ -0,0 +1,175 @@ + + + 4.0.0 + + dev.struchkov.haiti.filter.quarkus + haiti-filter-quarkus-reactive + 0.1.0 + + Haiti Filter Reactive Quarkus + JOOQ based filtering module + https://github.com/haiti-projects/haiti-filter-reactive-quarkus + + + BSD 3-Clause License + + + + + 11 + 11 + + 2.5.1.Final + 0.1.0 + + + + + + io.quarkus.platform + quarkus-bom + ${quarkus.platform.version} + pom + import + + + + + + + dev.struchkov.haiti.filter + haiti-filter-jooq + ${haiti.filter.jooq.version} + + + io.smallrye.reactive + smallrye-mutiny-vertx-pg-client + + + + + scm:git:https://github.com/haiti-projects/haiti-filter-reactive-quarkus.git + https://github.com/haiti-projects/haiti-filter-reactive-quarkus + scm:git:https://github.com/haiti-projects/haiti-filter-reactive-quarkus.git + + + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + ${plugin.nexus.staging.ver} + true + + ossrh + https://s01.oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-source-plugin + ${plugin.maven.source.ver} + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${plugin.maven.javadoc.ver} + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + ${plugin.maven.gpg.ver} + + + sign-artifacts + verify + + sign + + + + + + --pinentry-mode + loopback + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 11 + 11 + + + + + + + + release + + + + org.sonatype.plugins + nexus-staging-maven-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-gpg-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + + + + + + uPagge + Struchkov Mark + https://mark.struchkov.dev + mark@struchkov.dev + + + + \ No newline at end of file diff --git a/src/main/java/dev/struchkov/haiti/filter/quarkus/CriteriaFilter.java b/src/main/java/dev/struchkov/haiti/filter/quarkus/CriteriaFilter.java new file mode 100644 index 0000000..c00651b --- /dev/null +++ b/src/main/java/dev/struchkov/haiti/filter/quarkus/CriteriaFilter.java @@ -0,0 +1,93 @@ +package dev.struchkov.haiti.filter.quarkus; + +import dev.struchkov.haiti.filter.Filter; +import dev.struchkov.haiti.filter.FilterQuery; +import dev.struchkov.haiti.filter.jooq.CriteriaJooqFilter; +import dev.struchkov.haiti.filter.jooq.JoinTable; +import io.smallrye.mutiny.Multi; +import io.vertx.mutiny.pgclient.PgPool; +import io.vertx.mutiny.sqlclient.Row; +import lombok.NonNull; +import org.jooq.DSLContext; +import org.jooq.Query; +import org.jooq.conf.ParamType; + +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.StreamSupport; + +public class CriteriaFilter implements Filter { + + private final PgPool pgPool; + private final CriteriaJooqFilter jooqFilter; + private final Function mapper; + + private CriteriaFilter(PgPool pgPool, String table, DSLContext dslContext, Function mapper) { + dslContext.settings().withParamType(ParamType.NAMED_OR_INLINED); + this.pgPool = pgPool; + this.mapper = mapper; + this.jooqFilter = CriteriaJooqFilter.create(table, dslContext); + } + + public static CriteriaFilter create(PgPool pgPool, String table, DSLContext dslContext, Function mapper) { + return new CriteriaFilter<>(pgPool, table, dslContext, mapper); + } + + @Override + public Filter and(FilterQuery filterQuery) { + jooqFilter.and(filterQuery); + return this; + } + + @Override + public Filter and(Consumer query) { + jooqFilter.and(query); + return this; + } + + @Override + public Filter or(FilterQuery filterQuery) { + jooqFilter.or(filterQuery); + return this; + } + + @Override + public Filter or(Consumer query) { + jooqFilter.or(query); + return this; + } + + @Override + public Filter not(FilterQuery filterQuery) { + jooqFilter.not(filterQuery); + return this; + } + + @Override + public Filter not(Consumer query) { + jooqFilter.not(query); + return this; + } + + public CriteriaFilter page(@NonNull String fieldOrder, Object id, int pageSize) { + jooqFilter.page(fieldOrder, id, pageSize); + return this; + } + + public CriteriaFilter join(@NonNull JoinTable... joinTables) { + jooqFilter.join(joinTables); + return this; + } + + @Override + public Multi build() { + final Query query = jooqFilter.build(); + return pgPool.preparedQuery(query.getSQL()) + .execute() + .onItem() + .transformToMulti(rows -> Multi.createFrom().items( + StreamSupport.stream(rows.spliterator(), false) + )) + .map(mapper); + } +}