package org.fedorahosted.flies.repository.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToMany;

import org.fedorahosted.flies.core.model.AbstractFliesEntity;
import org.hibernate.annotations.IndexColumn;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Entity
public class ProjectContainer extends AbstractFliesEntity{

	private List<ContainerItem> items = new ArrayList<ContainerItem>();
	
	@IndexColumn(name="pos")
	@OneToMany(mappedBy="container",cascade=CascadeType.ALL)
	@OnDelete(action=OnDeleteAction.CASCADE)
	public List<ContainerItem> getItems() {
		return items;
	}
	
	public void setItems(List<ContainerItem> items) {
		this.items = items;
	}
}

@@ -402,16 +402,93 @@
 eAction;
+%0Aimport org.hibernate.annotations.Where;%0Aimport org.hibernate.envers.Audited;
 %0A%0A@Entit
@@ -618,16 +618,88 @@
 tem%3E();%0A
+%09private List%3CContainerItem%3E itemTree = new ArrayList%3CContainerItem%3E();%0A
 %09%0A%09@Inde
@@ -953,13 +953,303 @@
  items;%0A
-
 %09%7D%0A
+%0A%09@OneToMany(mappedBy=%22container%22)%0A%09@Where(clause=%22parent=null%22)%0A%09@IndexColumn(name=%22pos%22)%0A%09@OnDelete(action=OnDeleteAction.CASCADE)%0A%09public List%3CContainerItem%3E getItemTree() %7B%0A%09%09return itemTree;%0A%09%7D%0A%09%0A%09public void setItemTree(List%3CContainerItem%3E itemTree) %7B%0A%09%09this.itemTree = itemTree;%0A%09%7D%0A%0A
 %7D%0A

allow fetching only immediate child-items from ProjectContainer