package org.domain.zzzzzz2.session;

import org.domain.zzzzzz2.entity.*;
import java.util.ArrayList;
import java.util.List;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("customersHome")
public class CustomersHome extends EntityHome<Customers> {

	@In(create = true)
	EmployeesHome employeesHome;

	public void setCustomersCustomernumber(Integer id) {
		setId(id);
	}

	public Integer getCustomersCustomernumber() {
		return (Integer) getId();
	}

	@Override
	protected Customers createInstance() {
		Customers customers = new Customers();
		return customers;
	}

	public void load() {
		if (isIdDefined()) {
			wire();
		}
	}

	public void wire() {
		getInstance();
		Employees employees = employeesHome.getDefinedInstance();
		if (employees != null) {
			getInstance().setEmployees(employees);
		}
	}

	public boolean isWired() {
		return true;
	}

	public Customers getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

	public List<Payments> getPaymentses() {
		return getInstance() == null ? null : new ArrayList<Payments>(
				getInstance().getPaymentses());
	}

	public List<Orders> getOrderses() {
		return getInstance() == null ? null : new ArrayList<Orders>(
				getInstance().getOrderses());
	}

}
