package eu.eudat.data.query.items.table.datasetprofile;

import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;

import java.util.UUID;

public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DatasetProfile, UUID> {
    @Override
    public QueryableList<DatasetProfile> applyCriteria() {
        QueryableList<DatasetProfile> query = this.getQuery();
        if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
            query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
        return query;
    }

    @Override
    public QueryableList<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) {
        return null;
    }
}
