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("officesList")
public class OfficesList extends EntityQuery<Offices> {

	private static final String EJBQL = "select offices from Offices offices";

	private static final String[] RESTRICTIONS = {
			"lower(offices.officecode) like lower(concat(#{officesList.offices.officecode},'%'))",
			"lower(offices.city) like lower(concat(#{officesList.offices.city},'%'))",
			"lower(offices.phone) like lower(concat(#{officesList.offices.phone},'%'))",
			"lower(offices.addressline1) like lower(concat(#{officesList.offices.addressline1},'%'))",
			"lower(offices.addressline2) like lower(concat(#{officesList.offices.addressline2},'%'))",
			"lower(offices.state) like lower(concat(#{officesList.offices.state},'%'))",
			"lower(offices.country) like lower(concat(#{officesList.offices.country},'%'))",
			"lower(offices.postalcode) like lower(concat(#{officesList.offices.postalcode},'%'))",
			"lower(offices.territory) like lower(concat(#{officesList.offices.territory},'%'))", };

	private Offices offices = new Offices();

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

	public Offices getOffices() {
		return offices;
	}
}
