Commit 4d80d88f authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch 'gg-158' into 'master'

EmptyModelFilter: build id path for predicate

See merge request genesys-pgr/application-blocks!89
parents 1cd23c01 0bc0dc05
......@@ -19,10 +19,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.querydsl.core.types.dsl.PathBuilder;
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;
......@@ -42,13 +42,15 @@ public abstract class EmptyModelFilter<T extends EmptyModelFilter<T, R>, R exten
* 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) {
protected List<Predicate> collectPredicates(final EntityPathBase<R> instance) {
List<Predicate> predicates = super.collectPredicates(instance);
if (CollectionUtils.isNotEmpty(id)) {
predicates.add(basicModel.id.in(id));
if (CollectionUtils.isNotEmpty(this.id)) {
var entityPath = new PathBuilder<>(instance.getType(), instance.getMetadata());
PathBuilder<Long> idPath = entityPath.get("id", Long.class);
predicates.add(idPath.in(this.id));
}
return predicates;
}
......
......@@ -48,7 +48,7 @@ public abstract class VersionedModelFilter<T extends VersionedModelFilter<T, R>,
* @return list of predicates
*/
protected List<Predicate> collectPredicates(final EntityPathBase<R> instance, QVersionedModel versionedModel) {
List<Predicate> predicates = super.collectPredicates(instance, versionedModel._super);
List<Predicate> predicates = super.collectPredicates(instance);
if (CollectionUtils.isNotEmpty(version)) {
predicates.add(versionedModel.version.in(version));
}
......
......@@ -31,7 +31,7 @@ public class VersionedEntityFilter extends VersionedModelFilter<VersionedEntityF
}
public List<Predicate> collectPredicates(QVersionedEntity versionedEntity) {
final List<Predicate> predicates = super.collectPredicates(versionedEntity, versionedEntity._super._super);
final List<Predicate> predicates = super.collectPredicates(versionedEntity, versionedEntity._super);
if (name != null) {
predicates.add(name.buildQuery(versionedEntity.name));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment