// Path: src/main/java/net/ftlines/blog/cdidemo/model/Team.java
// @Entity
// public class Team implements Serializable {
// 
//   @GeneratedValue
//   @Id
//   private Long id;
//   @Basic(optional = false)
//   private String name;
// 
//   @ManyToMany(cascade = CascadeType.PERSIST)
//   @OrderColumn
//   private List<Member> members = new ArrayList<Member>();
// 
//   public String getName() {
//     return name;
//   }
// 
//   public void setName(String name) {
//     this.name = name;
//   }
// 
//   public Long getId() {
//     return id;
//   }
// 
//   public List<Member> getMembers() {
//     return members;
//   }
// 
// }
// 
// Path: src/main/java/net/ftlines/blog/cdidemo/model/TeamsRepository.java
// @ApplicationScoped
// public class TeamsRepository {
// 
//   @Inject
//   private EntityManager em;
// 
//   public List<Team> list(int first, int max) {
//     return em.createQuery("FROM Team ORDER BY name").setFirstResult(first).setMaxResults(max).getResultList();
//   }
// 
//   public int count() {
//     return ((Long) em.createQuery("SELECT COUNT(*) FROM Team").getSingleResult()).intValue();
//   }
// 
// }
// 
// Path: src/main/java/net/ftlines/blog/cdidemo/web/EntityProvider.java
// public abstract class EntityProvider<T> extends SortableDataProvider<T> {
// 
//   public EntityProvider() {
//     CdiContainer.get().getNonContextualManager().inject(this);
//   }
// 
//   public IModel<T> model(T entity) {
//     return new EntityModel<T>(entity);
//   }
// 
// }


import java.util.Iterator;
import javax.inject.Inject;
import net.ftlines.blog.cdidemo.model.Team;
import net.ftlines.blog.cdidemo.model.TeamsRepository;
import net.ftlines.blog.cdidemo.web.EntityProvider;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

package net.ftlines.blog.cdidemo.web.app;





public class TeamsListPage extends BasePage {
  public TeamsListPage() {

    DataView<?> employees = new DataView<Team>("teams", new TeamsProvider()) {
      @Override
      protected void populateItem(Item<Team> item) {
        IModel<Team> team = item.getModel();
        item.add(new Label("name", new PropertyModel(team, "name")));
        item.add(new BookmarkablePageLink("edit", TeamEditPage.class, TeamEditPage.forTeam(team.getObject())));
      }
    };
    employees.setItemsPerPage(10);
    add(employees);
    add(new PagingNavigator("navigator", employees));
  }

  private class TeamsProvider extends EntityProvider<Team> {

    @Inject
    TeamsRepository teams;

    public Iterator<Team> iterator(int first, int count) {
      return teams.list(first, count).iterator();
    }


// Path: src/main/java/net/ftlines/blog/cdidemo/model/Team.java
// @Entity
// public class Team implements Serializable {
// 
//   @GeneratedValue
//   @Id
//   private Long id;
//   @Basic(optional = false)
//   private String name;
// 
//   @ManyToMany(cascade = CascadeType.PERSIST)
//   @OrderColumn
//   private List<Member> members = new ArrayList<Member>();
// 
//   public String getName() {
//     return name;
//   }
// 
//   public void setName(String name) {
//     this.name = name;
//   }
// 
//   public Long getId() {
//     return id;
//   }
// 
//   public List<Member> getMembers() {
//     return members;
//   }
// 
// }
// 
// Path: src/main/java/net/ftlines/blog/cdidemo/model/TeamsRepository.java
// @ApplicationScoped
// public class TeamsRepository {
// 
//   @Inject
//   private EntityManager em;
// 
//   public List<Team> list(int first, int max) {
//     return em.createQuery("FROM Team ORDER BY name").setFirstResult(first).setMaxResults(max).getResultList();
//   }
// 
//   public int count() {
//     return ((Long) em.createQuery("SELECT COUNT(*) FROM Team").getSingleResult()).intValue();
//   }
// 
// }
// 
// Path: src/main/java/net/ftlines/blog/cdidemo/web/EntityProvider.java
// public abstract class EntityProvider<T> extends SortableDataProvider<T> {
// 
//   public EntityProvider() {
//     CdiContainer.get().getNonContextualManager().inject(this);
//   }
// 
//   public IModel<T> model(T entity) {
//     return new EntityModel<T>(entity);
//   }
// 
// }


// Path: src/main/java/net/ftlines/blog/cdidemo/web/app/TeamsListPage.java
import java.util.Iterator;
import javax.inject.Inject;
import net.ftlines.blog.cdidemo.model.Team;
import net.ftlines.blog.cdidemo.model.TeamsRepository;
import net.ftlines.blog.cdidemo.web.EntityProvider;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

package net.ftlines.blog.cdidemo.web.app;





public class TeamsListPage extends BasePage {
  public TeamsListPage() {

    DataView<?> employees = new DataView<Team>("teams", new TeamsProvider()) {
      @Override
      protected void populateItem(Item<Team> item) {
        IModel<Team> team = item.getModel();
        item.add(new Label("name", new PropertyModel(team, "name")));
        item.add(new BookmarkablePageLink("edit", TeamEditPage.class, TeamEditPage.forTeam(team.getObject())));
      }
    };
    employees.setItemsPerPage(10);
    add(employees);
    add(new PagingNavigator("navigator", employees));
  }

  private class TeamsProvider extends EntityProvider<Team> {

    @Inject
    TeamsRepository teams;

    public Iterator<Team> iterator(int first, int count) {
      return teams.list(first, count).iterator();
    }


    public int size() {
