SystemActionFilter.java

/*
 * Copyright 2026 Global Crop Diversity Trust
 * Licensed under the Apache License, Version 2.0
 * See LICENSE file in project root folder or http://www.apache.org/licenses/LICENSE-2.0
 */

package org.gringlobal.service.filter;

import java.util.List;

import org.genesys.blocks.model.filters.StringFilter;

import org.gringlobal.model.QSystemAction;
import org.gringlobal.model.SystemAction;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import com.querydsl.core.types.Predicate;

/**
 * Filters for {@link SystemAction}
 */
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(fluent = true)
public class SystemActionFilter extends ActionFilter<SystemActionFilter, SystemAction, QSystemAction> {

	private static final long serialVersionUID = 2836452198696093524L;

	/** The note. */
	public StringFilter note;

	@Override
	public List<Predicate> collectPredicates() {
		return collectPredicates(QSystemAction.systemAction);
	}

	public List<Predicate> collectPredicates(QSystemAction systemAction) {
		var predicates =  super.collectSuperPredicates(systemAction, systemAction._super);
		if (note != null) {
			predicates.add(note.buildQuery(systemAction.note));
		}
		return predicates;
	}
}