Commit a5837401 authored by Matija Obreza's avatar Matija Obreza

Subset filters by owner Partner

parent 722200bb
......@@ -22,6 +22,7 @@ import java.util.Set;
import org.genesys.blocks.model.filters.StringFilter;
import org.genesys.blocks.model.filters.UuidModelFilter;
import org.genesys.catalog.model.filters.PartnerFilter;
import org.genesys2.server.model.PublishState;
import org.genesys2.server.model.impl.Subset;
......@@ -36,59 +37,64 @@ import com.querydsl.core.types.Predicate;
*/
public class SubsetFilter extends UuidModelFilter<SubsetFilter, Subset> {
/** The title. */
public StringFilter title;
/** The description. */
public StringFilter description;
/** The publisher. */
public Set<String> publisher;
/** The date created. */
public StringFilter dateCreated;
/** Institutes. */
public Set<String> institutes;
/** The publish state. */
public Set<PublishState> state;
public Set<String> crop;
/**
* Builds the query.
*
* @return the predicate
*/
public Predicate buildPredicate() {
final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(subset, subset._super, and);
if ((institutes != null) && !institutes.isEmpty()) {
and.and(subset.institute.code.in(institutes));
}
if (title != null) {
and.and(title.buildQuery(subset.title));
}
if (description != null) {
and.and(description.buildQuery(subset.description));
}
if ((publisher != null) && !publisher.isEmpty()) {
and.and(subset.publisher.in(publisher));
}
if (dateCreated != null) {
and.and(dateCreated.buildQuery(subset.dateCreated));
}
if (state != null && !state.isEmpty()) {
and.and(subset.state.in(state));
}
if (crop != null && !crop.isEmpty()) {
and.and(subset.crops.any().in(crop));
}
return and;
}
/** The owner. */
public PartnerFilter owner;
/** The title. */
public StringFilter title;
/** The description. */
public StringFilter description;
/** The publisher. */
public Set<String> publisher;
/** The date created. */
public StringFilter dateCreated;
/** Institutes. */
public Set<String> institutes;
/** The publish state. */
public Set<PublishState> state;
public Set<String> crop;
/**
* Builds the query.
*
* @return the predicate
*/
public Predicate buildPredicate() {
final BooleanBuilder and = new BooleanBuilder();
super.buildQuery(subset, subset._super, and);
if (owner != null) {
and.and(owner.buildQuery(subset.owner));
}
if ((institutes != null) && !institutes.isEmpty()) {
and.and(subset.institute.code.in(institutes));
}
if (title != null) {
and.and(title.buildQuery(subset.title));
}
if (description != null) {
and.and(description.buildQuery(subset.description));
}
if ((publisher != null) && !publisher.isEmpty()) {
and.and(subset.publisher.in(publisher));
}
if (dateCreated != null) {
and.and(dateCreated.buildQuery(subset.dateCreated));
}
if (state != null && !state.isEmpty()) {
and.and(subset.state.in(state));
}
if (crop != null && !crop.isEmpty()) {
and.and(subset.crops.any().in(crop));
}
return and;
}
public SubsetFilter state(PublishState ... state) {
if (this.state == null) {
......
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