diff --git a/src/main/kotlin/no/acntech/kollectiveq/Filter.kt b/src/main/kotlin/no/acntech/kollectiveq/Filter.kt index 2405b92..8773871 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/Filter.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/Filter.kt @@ -3,9 +3,9 @@ package no.acntech.kollectiveq import no.acntech.kollectiveq.antlr4.FilterGrammarBaseVisitor import no.acntech.kollectiveq.antlr4.FilterGrammarLexer import no.acntech.kollectiveq.antlr4.FilterGrammarParser -import no.acntech.kollectiveq.text.DetailedParseException -import no.acntech.kollectiveq.text.EQ -import no.acntech.kollectiveq.time.FlexibleInstantParser +import no.acntech.kollectiveq.util.text.EQ +import no.acntech.kollectiveq.util.time.DetailedParseException +import no.acntech.kollectiveq.util.time.FlexibleInstantParser import org.antlr.v4.runtime.CharStreams import org.antlr.v4.runtime.CommonTokenStream import org.antlr.v4.runtime.RecognitionException @@ -140,7 +140,6 @@ class Filter { } - /** * Represents a sealed class `Value` that can hold different types of values. * diff --git a/src/main/kotlin/no/acntech/kollectiveq/FilterPrintVisitor.kt b/src/main/kotlin/no/acntech/kollectiveq/FilterPrintVisitor.kt index f7e8d23..84c4dff 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/FilterPrintVisitor.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/FilterPrintVisitor.kt @@ -1,6 +1,7 @@ package no.acntech.kollectiveq -import no.acntech.kollectiveq.text.* +import no.acntech.kollectiveq.FilterPrintVisitor.PrintFormat +import no.acntech.kollectiveq.util.text.* /** * The FilterPrintVisitor class is responsible for visiting filter conditions and generating a formatted string representation diff --git a/src/main/kotlin/no/acntech/kollectiveq/FilterValidationVisitor.kt b/src/main/kotlin/no/acntech/kollectiveq/FilterValidationVisitor.kt index 8cbd439..a6f2fc6 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/FilterValidationVisitor.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/FilterValidationVisitor.kt @@ -1,6 +1,6 @@ package no.acntech.kollectiveq -import no.acntech.kollectiveq.lang.ValidationException +import no.acntech.kollectiveq.util.lang.ValidationException /** * This visitor validates that the filter does not contain any conditions that are not allowed. diff --git a/src/main/kotlin/no/acntech/kollectiveq/Pagination.kt b/src/main/kotlin/no/acntech/kollectiveq/Pagination.kt index 7a5e3f4..b75b69f 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/Pagination.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/Pagination.kt @@ -1,6 +1,6 @@ package no.acntech.kollectiveq -import no.acntech.kollectiveq.text.EQUALS +import no.acntech.kollectiveq.util.text.EQUALS import org.springframework.web.util.UriUtils import java.nio.charset.StandardCharsets diff --git a/src/main/kotlin/no/acntech/kollectiveq/Sorting.kt b/src/main/kotlin/no/acntech/kollectiveq/Sorting.kt index f4907f2..a73d2f9 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/Sorting.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/Sorting.kt @@ -1,6 +1,7 @@ package no.acntech.kollectiveq -import no.acntech.kollectiveq.text.* +import no.acntech.kollectiveq.util.text.* +import no.acntech.kollectiveq.util.time.DetailedParseException import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils diff --git a/src/main/kotlin/no/acntech/kollectiveq/jpql/JPQLTransformationFilterVisitor.kt b/src/main/kotlin/no/acntech/kollectiveq/jpql/JPQLTransformationFilterVisitor.kt index 66570d7..fda3518 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/jpql/JPQLTransformationFilterVisitor.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/jpql/JPQLTransformationFilterVisitor.kt @@ -6,14 +6,15 @@ import jakarta.persistence.metamodel.EntityType import jakarta.persistence.metamodel.Metamodel import no.acntech.kollectiveq.Filter import no.acntech.kollectiveq.FilterBaseVisitor -import no.acntech.kollectiveq.collections.mapFromPairs -import no.acntech.kollectiveq.collections.prettyPrint -import no.acntech.kollectiveq.lang.TransformFunction -import no.acntech.kollectiveq.lang.identityTransform import no.acntech.kollectiveq.persistence.PersistenceUtils import no.acntech.kollectiveq.persistence.PersistenceUtils.getInverseAttribute import no.acntech.kollectiveq.persistence.PersistenceUtils.getTargetEntityTypeForPluralAttribute -import no.acntech.kollectiveq.text.* +import no.acntech.kollectiveq.util.collections.mapFromPairs +import no.acntech.kollectiveq.util.collections.prettyPrint +import no.acntech.kollectiveq.util.lang.TransformFunction +import no.acntech.kollectiveq.util.lang.identityTransform +import no.acntech.kollectiveq.util.text.* +import no.acntech.kollectiveq.util.time.* import org.apache.commons.lang3.builder.ToStringBuilder import org.apache.commons.lang3.builder.ToStringStyle import org.slf4j.Logger diff --git a/src/main/kotlin/no/acntech/kollectiveq/jpql/JPQLTransformationSortingVisitor.kt b/src/main/kotlin/no/acntech/kollectiveq/jpql/JPQLTransformationSortingVisitor.kt index daa308e..05ef7cf 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/jpql/JPQLTransformationSortingVisitor.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/jpql/JPQLTransformationSortingVisitor.kt @@ -3,12 +3,12 @@ package no.acntech.kollectiveq.jpql import no.acntech.kollectiveq.Sorting import no.acntech.kollectiveq.SortingVisitor -import no.acntech.kollectiveq.lang.TransformFunction -import no.acntech.kollectiveq.lang.identityTransform -import no.acntech.kollectiveq.text.COMMA_SPACE -import no.acntech.kollectiveq.text.DetailedParseException -import no.acntech.kollectiveq.text.EMPTY_STRING -import no.acntech.kollectiveq.text.SPACE +import no.acntech.kollectiveq.util.lang.TransformFunction +import no.acntech.kollectiveq.util.lang.identityTransform +import no.acntech.kollectiveq.util.text.COMMA_SPACE +import no.acntech.kollectiveq.util.text.EMPTY_STRING +import no.acntech.kollectiveq.util.text.SPACE +import no.acntech.kollectiveq.util.time.DetailedParseException /** * Visitor that transforms a [Sorting] to a JPQL ORDER BY clause. diff --git a/src/main/kotlin/no/acntech/kollectiveq/persistence/DefaultFilterRepository.kt b/src/main/kotlin/no/acntech/kollectiveq/persistence/DefaultFilterRepository.kt index 217cace..6bfd221 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/persistence/DefaultFilterRepository.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/persistence/DefaultFilterRepository.kt @@ -6,9 +6,9 @@ import no.acntech.kollectiveq.Pagination import no.acntech.kollectiveq.Sorting import no.acntech.kollectiveq.jpql.JPQLTransformationFilterVisitor import no.acntech.kollectiveq.jpql.JPQLTransformationSortingVisitor -import no.acntech.kollectiveq.lang.TransformFunction -import no.acntech.kollectiveq.lang.snakeToCamelTransformer -import no.acntech.kollectiveq.text.EMPTY_STRING +import no.acntech.kollectiveq.util.lang.TransformFunction +import no.acntech.kollectiveq.util.lang.snakeToCamelTransformer +import no.acntech.kollectiveq.util.text.EMPTY_STRING import org.slf4j.LoggerFactory import org.springframework.data.domain.Page import org.springframework.data.domain.PageImpl diff --git a/src/main/kotlin/no/acntech/kollectiveq/persistence/FilterRepository.kt b/src/main/kotlin/no/acntech/kollectiveq/persistence/FilterRepository.kt index 61261e8..3c6b254 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/persistence/FilterRepository.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/persistence/FilterRepository.kt @@ -4,8 +4,8 @@ import com.google.common.base.CaseFormat import no.acntech.kollectiveq.Filter import no.acntech.kollectiveq.Pagination import no.acntech.kollectiveq.Sorting -import no.acntech.kollectiveq.lang.TransformFunction -import no.acntech.kollectiveq.lang.createCaseFormatTransformFunction +import no.acntech.kollectiveq.util.lang.TransformFunction +import no.acntech.kollectiveq.util.lang.createCaseFormatTransformFunction import org.springframework.data.domain.Page import org.springframework.data.jpa.repository.JpaRepository import org.springframework.data.repository.NoRepositoryBean diff --git a/src/main/kotlin/no/acntech/kollectiveq/persistence/PersistenceUtils.kt b/src/main/kotlin/no/acntech/kollectiveq/persistence/PersistenceUtils.kt index 9b8f9a4..4f08dbe 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/persistence/PersistenceUtils.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/persistence/PersistenceUtils.kt @@ -2,8 +2,8 @@ package no.acntech.kollectiveq.persistence import jakarta.persistence.* import jakarta.persistence.metamodel.* -import no.acntech.kollectiveq.text.DOT -import no.acntech.kollectiveq.text.PERIOD +import no.acntech.kollectiveq.util.text.DOT +import no.acntech.kollectiveq.util.text.PERIOD import java.lang.reflect.Field import java.lang.reflect.Member import java.lang.reflect.Method diff --git a/src/main/kotlin/no/acntech/kollectiveq/collections/CollectionExtentions.kt b/src/main/kotlin/no/acntech/kollectiveq/util/collections/Extentions.kt similarity index 89% rename from src/main/kotlin/no/acntech/kollectiveq/collections/CollectionExtentions.kt rename to src/main/kotlin/no/acntech/kollectiveq/util/collections/Extentions.kt index 2ad10f3..20fab6e 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/collections/CollectionExtentions.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/util/collections/Extentions.kt @@ -1,8 +1,8 @@ -package no.acntech.kollectiveq.collections +package no.acntech.kollectiveq.util.collections -import no.acntech.kollectiveq.text.EMPTY_STRING -import no.acntech.kollectiveq.text.NEW_LINE -import no.acntech.kollectiveq.text.SPACE +import no.acntech.kollectiveq.util.text.EMPTY_STRING +import no.acntech.kollectiveq.util.text.NEW_LINE +import no.acntech.kollectiveq.util.text.SPACE fun List<*>.prettyPrint(indentation: Int = 0): String { val indent = SPACE.repeat(indentation) diff --git a/src/main/kotlin/no/acntech/kollectiveq/lang/Functions.kt b/src/main/kotlin/no/acntech/kollectiveq/util/lang/Functions.kt similarity index 95% rename from src/main/kotlin/no/acntech/kollectiveq/lang/Functions.kt rename to src/main/kotlin/no/acntech/kollectiveq/util/lang/Functions.kt index cfb7d52..14751fa 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/lang/Functions.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/util/lang/Functions.kt @@ -1,7 +1,7 @@ -package no.acntech.kollectiveq.lang +package no.acntech.kollectiveq.util.lang import com.google.common.base.CaseFormat -import no.acntech.kollectiveq.collections.prettyPrint +import no.acntech.kollectiveq.util.collections.prettyPrint import kotlin.reflect.full.memberProperties import kotlin.reflect.jvm.isAccessible diff --git a/src/main/kotlin/no/acntech/kollectiveq/lang/ValidationException.kt b/src/main/kotlin/no/acntech/kollectiveq/util/lang/ValidationException.kt similarity index 88% rename from src/main/kotlin/no/acntech/kollectiveq/lang/ValidationException.kt rename to src/main/kotlin/no/acntech/kollectiveq/util/lang/ValidationException.kt index 3c8f77d..7c6c29d 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/lang/ValidationException.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/util/lang/ValidationException.kt @@ -1,4 +1,4 @@ -package no.acntech.kollectiveq.lang +package no.acntech.kollectiveq.util.lang /** * Thrown to indicate a validation problem. diff --git a/src/main/kotlin/no/acntech/kollectiveq/text/StringConstants.kt b/src/main/kotlin/no/acntech/kollectiveq/util/text/StringConstants.kt similarity index 96% rename from src/main/kotlin/no/acntech/kollectiveq/text/StringConstants.kt rename to src/main/kotlin/no/acntech/kollectiveq/util/text/StringConstants.kt index 00b8c50..5754e29 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/text/StringConstants.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/util/text/StringConstants.kt @@ -1,4 +1,4 @@ -package no.acntech.kollectiveq.text +package no.acntech.kollectiveq.util.text const val EMPTY_STRING = "" diff --git a/src/main/kotlin/no/acntech/kollectiveq/text/DetailedParseException.kt b/src/main/kotlin/no/acntech/kollectiveq/util/time/DetailedParseException.kt similarity index 96% rename from src/main/kotlin/no/acntech/kollectiveq/text/DetailedParseException.kt rename to src/main/kotlin/no/acntech/kollectiveq/util/time/DetailedParseException.kt index 8d2b817..7e80fd4 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/text/DetailedParseException.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/util/time/DetailedParseException.kt @@ -1,4 +1,4 @@ -package no.acntech.kollectiveq.text +package no.acntech.kollectiveq.util.time import org.apache.commons.lang3.builder.ToStringBuilder import org.apache.commons.lang3.builder.ToStringStyle diff --git a/src/main/kotlin/no/acntech/kollectiveq/time/FlexibleInstantParser.kt b/src/main/kotlin/no/acntech/kollectiveq/util/time/FlexibleInstantParser.kt similarity index 98% rename from src/main/kotlin/no/acntech/kollectiveq/time/FlexibleInstantParser.kt rename to src/main/kotlin/no/acntech/kollectiveq/util/time/FlexibleInstantParser.kt index 0a850b6..6a537ac 100644 --- a/src/main/kotlin/no/acntech/kollectiveq/time/FlexibleInstantParser.kt +++ b/src/main/kotlin/no/acntech/kollectiveq/util/time/FlexibleInstantParser.kt @@ -1,4 +1,4 @@ -package no.acntech.kollectiveq.time +package no.acntech.kollectiveq.util.time /** * Parses a string into an [Instant] using a highly flexible formatter (parser) supporting a wide range of formats. diff --git a/src/test/kotlin/no/acntech/kollectiveq/test/app/util/json/FlexibleInstantDeserializer.kt b/src/test/kotlin/no/acntech/kollectiveq/test/app/util/json/FlexibleInstantDeserializer.kt index 60fda0a..a57cbcb 100644 --- a/src/test/kotlin/no/acntech/kollectiveq/test/app/util/json/FlexibleInstantDeserializer.kt +++ b/src/test/kotlin/no/acntech/kollectiveq/test/app/util/json/FlexibleInstantDeserializer.kt @@ -3,7 +3,7 @@ package no.acntech.kollectiveq.test.app.util.json import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.JsonDeserializer -import no.acntech.kollectiveq.time.FlexibleInstantParser +import no.acntech.kollectiveq.util.time.FlexibleInstantParser import java.time.Instant import java.time.format.DateTimeParseException diff --git a/src/test/kotlin/no/acntech/kollectiveq/test/apptest/domain/repostitory/MiscRepoTests.kt b/src/test/kotlin/no/acntech/kollectiveq/test/apptest/domain/repostitory/MiscRepoTests.kt index 813ef16..584f669 100644 --- a/src/test/kotlin/no/acntech/kollectiveq/test/apptest/domain/repostitory/MiscRepoTests.kt +++ b/src/test/kotlin/no/acntech/kollectiveq/test/apptest/domain/repostitory/MiscRepoTests.kt @@ -4,12 +4,12 @@ import jakarta.persistence.TypedQuery import no.acntech.kollectiveq.Filter import no.acntech.kollectiveq.Pagination import no.acntech.kollectiveq.Sorting -import no.acntech.kollectiveq.collections.prettyPrint import no.acntech.kollectiveq.jpql.JPQLTransformationFilterVisitor -import no.acntech.kollectiveq.lang.snakeToCamelTransformer import no.acntech.kollectiveq.test.app.domain.model.Department import no.acntech.kollectiveq.test.app.domain.model.Employee import no.acntech.kollectiveq.test.apptest.domain.repostitory.BaseRepositoryTest +import no.acntech.kollectiveq.util.collections.prettyPrint +import no.acntech.kollectiveq.util.lang.snakeToCamelTransformer import org.junit.jupiter.api.* import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.params.ParameterizedTest @@ -79,7 +79,7 @@ class MiscRepoTests : BaseRepositoryTest() { "'','name\$like:P*\$and:\$having:AVG(employees.year_of_birth)\$gte:2000', '', 'SELECT de_0 FROM Department de_0 WHERE (LOWER(de_0.name) LIKE LOWER('P%') AND de_0.id IN (SELECT em_0.department.id FROM Employee em_0 GROUP BY em_0.department.id HAVING AVG(em_0.yearOfBirth) >= 2000))'", "'','\$having:AVG(employees.year_of_birth)\$gte:2000', '', 'SELECT de_0 FROM Department de_0 WHERE de_0.id IN (SELECT em_0.department.id FROM Employee em_0 GROUP BY em_0.department.id HAVING AVG(em_0.yearOfBirth) >= 2000)'", - ) + ) fun testHavingClause(paginationVal: String, filterVal: String, sortVal: String, expectedJpqlQuery: String) { // Select all departments that have employees with first name starting with J val filter = Filter.of(filterVal, true) @@ -93,7 +93,7 @@ class MiscRepoTests : BaseRepositoryTest() { ) filter.accept(visitor) - val query: String = visitor.toQuery() + val query: String = visitor.toQuery() println("whereClause: ${visitor.toWhereClause()}") println("Query: $query")