Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
App Blocks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Genesys PGR
App Blocks
Commits
87e12c2d
Commit
87e12c2d
authored
Jan 24, 2019
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed filter#buildQuery to #buildPredicate
- Copy filter to target class
parent
14e8e60b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
5 deletions
+27
-5
core/src/main/java/org/genesys/blocks/model/filters/BasicModelFilter.java
...va/org/genesys/blocks/model/filters/BasicModelFilter.java
+18
-4
core/src/main/java/org/genesys/blocks/model/filters/NumberFilter.java
...n/java/org/genesys/blocks/model/filters/NumberFilter.java
+8
-0
core/src/main/java/org/genesys/blocks/model/filters/VersionedModelFilter.java
...rg/genesys/blocks/model/filters/VersionedModelFilter.java
+1
-1
No files found.
core/src/main/java/org/genesys/blocks/model/filters/BasicModelFilter.java
View file @
87e12c2d
...
...
@@ -15,6 +15,7 @@
*/
package
org.genesys.blocks.model.filters
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.util.Set
;
...
...
@@ -60,11 +61,11 @@ public abstract class BasicModelFilter<T extends BasicModelFilter<T, R>, R exten
public
Set
<
String
>
NOTNULL
;
/**
* Builds the DSL
query
.
* Builds the DSL
predicate
.
*
* @return the predicate
*/
public
abstract
Predicate
build
Query
();
public
abstract
Predicate
build
Predicate
();
/**
* Builds the query.
...
...
@@ -73,7 +74,7 @@ public abstract class BasicModelFilter<T extends BasicModelFilter<T, R>, R exten
* @param basicModel the basic model
* @param builder the builder
*/
protected
void
build
Query
(
final
EntityPathBase
<
R
>
instance
,
final
QBasicModel
basicModel
,
final
BooleanBuilder
builder
)
{
protected
void
build
Predicate
(
final
EntityPathBase
<
R
>
instance
,
final
QBasicModel
basicModel
,
final
BooleanBuilder
builder
)
{
if
(
CollectionUtils
.
isNotEmpty
(
id
))
{
builder
.
and
(
basicModel
.
id
.
in
(
id
));
}
...
...
@@ -86,7 +87,7 @@ public abstract class BasicModelFilter<T extends BasicModelFilter<T, R>, R exten
NOTNULL
.
forEach
(
notNullProp
->
builder
.
and
(
getProperty
(
instance
,
clazz
,
notNullProp
).
isNotNull
()));
}
if
(
NOT
!=
null
)
{
builder
.
and
(
NOT
.
build
Query
().
not
());
builder
.
and
(
NOT
.
build
Predicate
().
not
());
}
}
...
...
@@ -126,6 +127,19 @@ public abstract class BasicModelFilter<T extends BasicModelFilter<T, R>, R exten
throw
new
RuntimeException
(
"Error accessing field "
+
nullProp
+
" for isNull() in "
+
instance
.
getClass
());
}
}
/**
* Copy by serializing to JSON and de-serializing to specified type.
*
* @param <X> the generic type
* @param targetType the target type
* @return the x
* @throws IOException Signals that an I/O exception has occurred.
*/
public
<
X
>
X
copy
(
Class
<
X
>
targetType
)
throws
IOException
{
return
jsonizer
.
readValue
(
jsonizer
.
writeValueAsString
(
this
),
targetType
);
}
@Override
public
String
toString
()
{
...
...
core/src/main/java/org/genesys/blocks/model/filters/NumberFilter.java
View file @
87e12c2d
...
...
@@ -49,6 +49,14 @@ public class NumberFilter<T extends Number & Comparable<?>> {
*/
public
T
[]
between
;
public
NumberFilter
()
{
}
public
NumberFilter
(
T
ge
,
T
le
)
{
this
.
ge
=
ge
;
this
.
le
=
le
;
}
/**
* Builds the query.
*
...
...
core/src/main/java/org/genesys/blocks/model/filters/VersionedModelFilter.java
View file @
87e12c2d
...
...
@@ -46,7 +46,7 @@ public abstract class VersionedModelFilter<T extends VersionedModelFilter<T, R>,
* @param builder the builder
*/
protected
void
buildQuery
(
final
EntityPathBase
<
R
>
instance
,
final
QVersionedModel
versionedModel
,
final
BooleanBuilder
builder
)
{
super
.
build
Query
(
instance
,
versionedModel
.
_super
,
builder
);
super
.
build
Predicate
(
instance
,
versionedModel
.
_super
,
builder
);
if
(
CollectionUtils
.
isNotEmpty
(
version
))
{
builder
.
and
(
versionedModel
.
version
.
in
(
version
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment