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("ordersHome")
public class OrdersHome extends EntityHome<Orders> {

	@In(create = true)
	CustomersHome customersHome;

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

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

	@Override
	protected Orders createInstance() {
		Orders orders = new Orders();
		return orders;
	}

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

	public void wire() {
		getInstance();
		Customers customers = customersHome.getDefinedInstance();
		if (customers != null) {
			getInstance().setCustomers(customers);
		}
	}

	public boolean isWired() {
		if (getInstance().getCustomers() == null)
			return false;
		return true;
	}

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

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

}
