package org.domain.zzzzzz2.session;

import org.domain.zzzzzz2.entity.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("customersList")
public class CustomersList extends EntityQuery<Customers> {

	private static final String EJBQL = "select customers from Customers customers";

	private static final String[] RESTRICTIONS = {
			"lower(customers.customername) like lower(concat(#{customersList.customers.customername},'%'))",
			"lower(customers.contactlastname) like lower(concat(#{customersList.customers.contactlastname},'%'))",
			"lower(customers.contactfirstname) like lower(concat(#{customersList.customers.contactfirstname},'%'))",
			"lower(customers.phone) like lower(concat(#{customersList.customers.phone},'%'))",
			"lower(customers.addressline1) like lower(concat(#{customersList.customers.addressline1},'%'))",
			"lower(customers.addressline2) like lower(concat(#{customersList.customers.addressline2},'%'))",
			"lower(customers.city) like lower(concat(#{customersList.customers.city},'%'))",
			"lower(customers.state) like lower(concat(#{customersList.customers.state},'%'))",
			"lower(customers.postalcode) like lower(concat(#{customersList.customers.postalcode},'%'))",
			"lower(customers.country) like lower(concat(#{customersList.customers.country},'%'))", };

	private Customers customers = new Customers();

	public CustomersList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	public Customers getCustomers() {
		return customers;
	}
}
