package com.yammer.stresstime.managers;

import com.yammer.stresstime.entities.Employee;
import com.yammer.stresstime.entities.Group;
import com.yammer.stresstime.entities.Membership;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;

import java.util.List;

public class MembershipManager extends EntityManager<Membership> {

    public MembershipManager(SessionFactory sessionFactory) {
        super(sessionFactory, Membership.class);
    }

    public Membership join(Group group, Employee employee) {
        // TODO: Validate uniqueness of (group, employee) in the group
        Membership membership = new Membership(employee, group);
        save(membership);
        return membership;
    }

    public Membership getByEmployeeIdAndGroupId(long employeeId, long groupId) {
        return getExactOne(currentSession()
                .createCriteria(Membership.class)
                .add(Restrictions.eq("employee.id", employeeId))
                .add(Restrictions.eq("group.id", groupId)));
    }

    public List<Membership> getGroupAdmins(long groupId) {
        return currentSession()
                .createCriteria(Membership.class)
                .add(Restrictions.eq("group.id", groupId))
                .add(Restrictions.eq("admin", true)).list();
    }

}

@@ -264,32 +264,8 @@
 s;%0A%0A
-import java.util.List;%0A%0A
 publ
@@ -1014,275 +1014,6 @@
   %7D%0A
-%0A    public List%3CMembership%3E getGroupAdmins(long groupId) %7B%0A        return currentSession()%0A                .createCriteria(Membership.class)%0A                .add(Restrictions.eq(%22group.id%22, groupId))%0A                .add(Restrictions.eq(%22admin%22, true)).list();%0A    %7D%0A%0A
 %7D%0A

Remove unused getGroupAdmins method