package cn.updev.Events.Group;

/**
 * Created by hypo on 15-11-17.
 */
public class EventGroupFactory {
}

@@ -29,79 +29,2516 @@
 p;%0A%0A
-/**%0A * Created by hypo on 15-11-17.%0A */%0Apublic class EventGroupFactory %7B
+import cn.updev.Database.HibernateSessionFactory;%0Aimport cn.updev.Events.Static.EventGroupWeight;%0Aimport cn.updev.Events.Static.IEvent;%0Aimport cn.updev.Events.Static.ITeamEvents;%0Aimport cn.updev.Events.Static.IUserEvents;%0Aimport org.hibernate.Session;%0Aimport org.hibernate.Transaction;%0A%0Aimport java.util.Date;%0Aimport java.util.List;%0A%0A/**%0A * Created by hypo on 15-11-17.%0A */%0Apublic class EventGroupFactory %7B%0A%0A    private Date groupExpect;%0A    private Integer groupId;%0A    private String groupTitle;%0A    private List%3CIEvent%3E list;%0A    private Integer ownerId;%0A    private EventGroupWeight weight;%0A%0A    public EventGroupFactory(Date groupExpect, String groupTitle, List%3CIEvent%3E list, Integer ownerId, EventGroupWeight weight) %7B%0A        this.groupExpect = groupExpect;%0A        this.groupTitle = groupTitle;%0A        this.list = list;%0A        this.ownerId = ownerId;%0A        this.weight = weight;%0A    %7D%0A%0A    private Date getGroupExpect() %7B%0A        return groupExpect;%0A    %7D%0A%0A    private Integer getGroupId() %7B%0A        return groupId;%0A    %7D%0A%0A    private String getGroupTitle() %7B%0A        if(groupTitle.length() %3E 20)%7B%0A            this.groupTitle = groupTitle.substring(0,20);%0A        %7D%0A        return groupTitle;%0A    %7D%0A%0A    private List%3CIEvent%3E getList() %7B%0A        return list;%0A    %7D%0A%0A    private Integer getOwnerId() %7B%0A        return ownerId;%0A    %7D%0A%0A    private EventGroupWeight getWeight() %7B%0A        return weight;%0A    %7D%0A%0A    private void save()%7B%0A%0A        Session session = HibernateSessionFactory.currentSession();%0A        Transaction transaction = session.beginTransaction();%0A%0A        for(IEvent event : getList())%7B%0A            EventsGroup eventsGroup = new EventsGroup(event.getEventId(), event.getGroupId(), event.getDoerId());%0A            session.save(eventsGroup);%0A        %7D%0A%0A        EventGroupInfo groupInfo = new EventGroupInfo(getGroupExpect(), getGroupTitle(), getOwnerId(), getWeight());%0A%0A        transaction.commit();%0A        HibernateSessionFactory.closeSession();%0A%0A        this.groupId = groupInfo.getGroupId();%0A    %7D%0A%0A    public IUserEvents getUserEvents()%7B%0A%0A        IUserEvents events = new UserEventGroup(getGroupExpect(), getGroupId(), getGroupTitle(),%0A                getList(), getOwnerId(), getWeight());%0A%0A        save();%0A%0A        return  events;%0A    %7D%0A%0A    public ITeamEvents getTeamEvents()%7B%0A%0A        ITeamEvents events = new TeamEventGroup(getGroupExpect(), getGroupId(), getGroupTitle(),%0A                getList(), getOwnerId(), getWeight());%0A%0A        save();%0A%0A        return  events;%0A    %7D
 %0A%7D%0A

add event group factory