-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dsl): dsl extension for postgrest specific operators (#1)
* feat(dsl): dsl extension for postgrest specific operators --------- Co-authored-by: Yves MENGELLE <yves.mengelle@ouest-france.fr>
- Loading branch information
1 parent
b769bb8
commit 4b4b33c
Showing
24 changed files
with
214 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/fr/ouestfrance/querydsl/postgrest/PostgrestFilterOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package fr.ouestfrance.querydsl.postgrest; | ||
|
||
import fr.ouestfrance.querydsl.FilterOperation; | ||
import fr.ouestfrance.querydsl.service.validators.ValidatedBy; | ||
import fr.ouestfrance.querydsl.service.validators.impl.StringValidator; | ||
|
||
public interface PostgrestFilterOperation { | ||
/** | ||
* Case-insensitive like | ||
*/ | ||
@ValidatedBy(StringValidator.class) | ||
class ILIKE implements FilterOperation { | ||
} | ||
|
||
/** | ||
* Contains for JSON/Range datatype | ||
*/ | ||
@ValidatedBy(StringValidator.class) | ||
class CS implements FilterOperation { | ||
} | ||
|
||
/** | ||
* Contained for JSON/Range datatype | ||
*/ | ||
@ValidatedBy(StringValidator.class) | ||
class CD implements FilterOperation { | ||
} | ||
} |
7 changes: 3 additions & 4 deletions
7
src/main/java/fr/ouestfrance/querydsl/postgrest/criterias/ByIds.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
package fr.ouestfrance.querydsl.postgrest.criterias; | ||
|
||
import java.util.List; | ||
|
||
import fr.ouestfrance.querydsl.FilterField; | ||
import fr.ouestfrance.querydsl.FilterOperation; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
record ByIds(@FilterField(operation = FilterOperation.IN) | ||
record ByIds(@FilterField(operation = FilterOperation.IN.class) | ||
List<Comparable<?>> id) { | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/fr/ouestfrance/querydsl/postgrest/mappers/CaseInsensitiveLikeMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package fr.ouestfrance.querydsl.postgrest.mappers; | ||
|
||
import fr.ouestfrance.querydsl.FilterOperation; | ||
import fr.ouestfrance.querydsl.postgrest.PostgrestFilterOperation; | ||
import fr.ouestfrance.querydsl.postgrest.model.Filter; | ||
import fr.ouestfrance.querydsl.postgrest.model.impl.QueryFilter; | ||
|
||
|
||
/** | ||
* Concrete mapping for like | ||
*/ | ||
public class CaseInsensitiveLikeMapper extends AbstractMapper { | ||
|
||
@Override | ||
public Filter getFilter(String field, Object value) { | ||
return QueryFilter.of(field, Operators.ILIKE, value); | ||
} | ||
|
||
|
||
@Override | ||
public Class<? extends FilterOperation> operation() { | ||
return PostgrestFilterOperation.ILIKE.class; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/fr/ouestfrance/querydsl/postgrest/mappers/ContainedMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package fr.ouestfrance.querydsl.postgrest.mappers; | ||
|
||
import fr.ouestfrance.querydsl.FilterOperation; | ||
import fr.ouestfrance.querydsl.postgrest.PostgrestFilterOperation; | ||
import fr.ouestfrance.querydsl.postgrest.model.Filter; | ||
import fr.ouestfrance.querydsl.postgrest.model.impl.QueryFilter; | ||
|
||
|
||
/** | ||
* Concrete mapping for equals | ||
*/ | ||
public class ContainedMapper extends AbstractMapper { | ||
|
||
@Override | ||
public Filter getFilter(String field, Object value) { | ||
return QueryFilter.of(field, Operators.CONTAINED, value); | ||
} | ||
|
||
@Override | ||
public Class<? extends FilterOperation> operation() { | ||
return PostgrestFilterOperation.CD.class; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/fr/ouestfrance/querydsl/postgrest/mappers/ContainsMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package fr.ouestfrance.querydsl.postgrest.mappers; | ||
|
||
import fr.ouestfrance.querydsl.FilterOperation; | ||
import fr.ouestfrance.querydsl.postgrest.PostgrestFilterOperation; | ||
import fr.ouestfrance.querydsl.postgrest.model.Filter; | ||
import fr.ouestfrance.querydsl.postgrest.model.impl.QueryFilter; | ||
|
||
|
||
/** | ||
* Concrete mapping for equals | ||
*/ | ||
public class ContainsMapper extends AbstractMapper { | ||
|
||
@Override | ||
public Filter getFilter(String field, Object value) { | ||
return QueryFilter.of(field, Operators.CONTAINS, value); | ||
} | ||
|
||
@Override | ||
public Class<? extends FilterOperation> operation() { | ||
return PostgrestFilterOperation.CS.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.