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
edda758c
Commit
edda758c
authored
Apr 08, 2020
by
Maxym Borodenko
Committed by
Matija Obreza
Apr 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce EmptyModel and EmptyModelFilter
parent
ab043cb3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
47 deletions
+106
-47
core/src/main/java/org/genesys/blocks/model/BasicModel.java
core/src/main/java/org/genesys/blocks/model/BasicModel.java
+1
-7
core/src/main/java/org/genesys/blocks/model/EmptyModel.java
core/src/main/java/org/genesys/blocks/model/EmptyModel.java
+36
-0
core/src/main/java/org/genesys/blocks/model/filters/BasicModelFilter.java
...va/org/genesys/blocks/model/filters/BasicModelFilter.java
+1
-40
core/src/main/java/org/genesys/blocks/model/filters/EmptyModelFilter.java
...va/org/genesys/blocks/model/filters/EmptyModelFilter.java
+68
-0
No files found.
core/src/main/java/org/genesys/blocks/model/BasicModel.java
View file @
edda758c
...
...
@@ -15,8 +15,6 @@
*/
package
org.genesys.blocks.model
;
import
java.io.Serializable
;
import
javax.persistence.Column
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
...
...
@@ -24,18 +22,14 @@ import javax.persistence.Id;
import
javax.persistence.MappedSuperclass
;
import
javax.persistence.Transient
;
import
org.genesys.blocks.util.JsonClassNameWriter
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonView
;
import
com.fasterxml.jackson.databind.annotation.JsonAppend
;
/**
* The Class BasicModel.
*/
@MappedSuperclass
@JsonAppend
(
props
=
{
@JsonAppend
.
Prop
(
name
=
"_class"
,
value
=
JsonClassNameWriter
.
class
,
type
=
String
.
class
)
})
public
class
BasicModel
implements
EntityId
,
Serializable
{
public
class
BasicModel
extends
EmptyModel
{
/** The Constant serialVersionUID. */
private
static
final
long
serialVersionUID
=
2709998920148999956L
;
...
...
core/src/main/java/org/genesys/blocks/model/EmptyModel.java
0 → 100644
View file @
edda758c
/*
* Copyright 2020 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.genesys.blocks.model
;
import
java.io.Serializable
;
import
javax.persistence.MappedSuperclass
;
import
org.genesys.blocks.util.JsonClassNameWriter
;
import
com.fasterxml.jackson.annotation.JsonIdentityInfo
;
import
com.fasterxml.jackson.annotation.ObjectIdGenerators
;
import
com.fasterxml.jackson.databind.annotation.JsonAppend
;
@MappedSuperclass
@JsonIdentityInfo
(
generator
=
ObjectIdGenerators
.
PropertyGenerator
.
class
,
property
=
"id"
)
@JsonAppend
(
props
=
{
@JsonAppend
.
Prop
(
name
=
"_class"
,
value
=
JsonClassNameWriter
.
class
,
type
=
String
.
class
)
})
public
abstract
class
EmptyModel
implements
EntityId
,
Serializable
{
/** The Constant serialVersionUID. */
private
static
final
long
serialVersionUID
=
5934941826741972456L
;
}
core/src/main/java/org/genesys/blocks/model/filters/BasicModelFilter.java
View file @
edda758c
...
...
@@ -15,16 +15,7 @@
*/
package
org.genesys.blocks.model.filters
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.genesys.blocks.model.BasicModel
;
import
org.genesys.blocks.model.QBasicModel
;
import
com.querydsl.core.types.Predicate
;
import
com.querydsl.core.types.dsl.EntityPathBase
;
/**
* {@link BasicModel} match by sample filters.
...
...
@@ -32,36 +23,6 @@ import com.querydsl.core.types.dsl.EntityPathBase;
* @param <T> the generic type
* @param <R> the generic type
*/
public
abstract
class
BasicModelFilter
<
T
extends
BasicModelFilter
<
T
,
R
>,
R
extends
BasicModel
>
extends
SuperModelFilter
<
T
,
R
>
{
/** The id. */
public
Set
<
Long
>
id
;
/**
* Collects list of filter predicates
*
* @param instance the instance of Q-type of <em>R</em>
* @param basicModel the basic model
* @return list of predicates
*/
protected
List
<
Predicate
>
collectPredicates
(
final
EntityPathBase
<
R
>
instance
,
final
QBasicModel
basicModel
)
{
List
<
Predicate
>
predicates
=
super
.
collectPredicates
(
instance
);
if
(
CollectionUtils
.
isNotEmpty
(
id
))
{
predicates
.
add
(
basicModel
.
id
.
in
(
id
));
}
return
predicates
;
}
/**
* Id.
*
* @return the sets the
*/
public
synchronized
Set
<
Long
>
id
()
{
if
(
id
==
null
)
{
id
=
new
HashSet
<>();
}
return
id
;
}
public
abstract
class
BasicModelFilter
<
T
extends
BasicModelFilter
<
T
,
R
>,
R
extends
BasicModel
>
extends
EmptyModelFilter
<
T
,
R
>
{
}
core/src/main/java/org/genesys/blocks/model/filters/EmptyModelFilter.java
0 → 100644
View file @
edda758c
/*
* Copyright 2020 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.genesys.blocks.model.filters
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.genesys.blocks.model.BasicModel
;
import
org.genesys.blocks.model.EmptyModel
;
import
org.genesys.blocks.model.QBasicModel
;
import
com.querydsl.core.types.Predicate
;
import
com.querydsl.core.types.dsl.EntityPathBase
;
/**
* {@link BasicModel} match by sample filters.
*
* @param <T> the generic type
* @param <R> the generic type
*/
public
abstract
class
EmptyModelFilter
<
T
extends
EmptyModelFilter
<
T
,
R
>,
R
extends
EmptyModel
>
extends
SuperModelFilter
<
T
,
R
>
{
/** The id. */
public
Set
<
Long
>
id
;
/**
* Collects list of filter predicates
*
* @param instance the instance of Q-type of <em>R</em>
* @param basicModel the basic model
* @return list of predicates
*/
protected
List
<
Predicate
>
collectPredicates
(
final
EntityPathBase
<
R
>
instance
,
final
QBasicModel
basicModel
)
{
List
<
Predicate
>
predicates
=
super
.
collectPredicates
(
instance
);
if
(
CollectionUtils
.
isNotEmpty
(
id
))
{
predicates
.
add
(
basicModel
.
id
.
in
(
id
));
}
return
predicates
;
}
/**
* Id.
*
* @return the sets the
*/
public
synchronized
Set
<
Long
>
id
()
{
if
(
id
==
null
)
{
id
=
new
HashSet
<>();
}
return
id
;
}
}
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