package org.domain.zzzzzz2.session;

import org.domain.zzzzzz2.entity.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("orderdetailsHome")
public class OrderdetailsHome extends EntityHome<Orderdetails> {

	@In(create = true)
	ProductsHome productsHome;
	@In(create = true)
	OrdersHome ordersHome;

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

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

	@Override
	protected Orderdetails createInstance() {
		Orderdetails orderdetails = new Orderdetails();
		return orderdetails;
	}

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

	public void wire() {
		getInstance();
		Products products = productsHome.getDefinedInstance();
		if (products != null) {
			getInstance().setProducts(products);
		}
		Orders orders = ordersHome.getDefinedInstance();
		if (orders != null) {
			getInstance().setOrders(orders);
		}
	}

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

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

}
