Subversion Repositories general

Rev

Rev 12 | Rev 16 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package ak.kickup.core.model;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import ak.kickup.util.ModelException;
import ak.kickup.util.ModelSecurityException;

/**
 *
 * @hibernate.class table="events"
 */
public class Event
        extends GeneralModelObject
{
        private String     name;
        private String     place;
        private String     address;
        private String     transportDesc;
        private Date       start;
        private Date       stop;
        private Date       lastRegister;
        private Date       lastUnregister;
        private BigDecimal price;
        private String     moneyAccount;
        private Boolean    enabled;
        private String     comment;
        private Collection acts;                          // Collection(EventAct)
    private Map        actsMap = new HashMap();       // Map(Long id -> EventAct)
        private Collection apartments;                    // Collection(EventApartment)
    private Map        apartmentsMap = new HashMap(); // Map(Long id -> EventApartment)

        protected Event()
        {
        }

        protected void init()
        {
                acts = new ArrayList();
        }

        /**
         *
         * @hibernate.property
         */
        public String getName()
        {
                return name;
        }

        public void setName(String name)
        {
                this.name = name;
        }

        /**
         *
         * @hibernate.property
         */
        public String getPlace()
        {
                return place;
        }

        public void setPlace(String place)
        {
                this.place = place;
        }

        /**
         *
         * @hibernate.property
         */
        public String getAddress()
        {
                return address;
        }

        public void setAddress(String address)
        {
                this.address = address;
        }

        /**
         *
         * @hibernate.property column="transport_desc"
         */
        public String getTransportDesc()
        {
                return transportDesc;
        }

        public void setTransportDesc(String transportDesc)
        {
                this.transportDesc = transportDesc;
        }

        /**
         *
         * @hibernate.property
         */
        public Date getStart()
        {
                return start;
        }

        public void setStart(Date start)
        {
                this.start = start;
        }

        /**
         *
         * @hibernate.property
         */
        public Date getStop()
        {
                return stop;
        }

        public void setStop(Date stop)
        {
                this.stop = stop;
        }

        /**
         *
         * @hibernate.property column="last_register"
         */
        public Date getLastRegister()
        {
                return lastRegister;
        }

        public void setLastRegister(Date lastRegister)
        {
                this.lastRegister = lastRegister;
        }

        /**
         *
         * @hibernate.property column="last_unregister"
         */
        public Date getLastUnregister()
        {
                return lastUnregister;
        }

        public void setLastUnregister(Date lastUnregister)
        {
                this.lastUnregister = lastUnregister;
        }

        /**
         *
         * @hibernate.property
         */
        public BigDecimal getPrice()
        {
                return price;
        }

        public void setPrice(BigDecimal price)
        {
                this.price = price;
        }

        /**
         *
         * @hibernate.property column="money_account"
         */
        public String getMoneyAccount()
        {
                return moneyAccount;
        }

        public void setMoneyAccount(String moneyAccount)
        {
                this.moneyAccount = moneyAccount;
        }

        /**
         *
         * @hibernate.property
         */
        public Boolean getEnabled()
        {
                return enabled;
        }

        public void setEnabled(Boolean enabled)
        {
                this.enabled = enabled;
        }

        /**
         *
         * @hibernate.property
         */
        public String getComment()
        {
                return comment;
        }

        public void setComment(String comment)
        {
                this.comment = comment;
        }

        /**
         * @return Collection(EventAct)
         *
         * @hibernate.bag inverse="true" cascade="all-delete-orphan" lazy="true"
         * @hibernate.collection-key column="event"
     * @hibernate.collection-one-to-many class="ak.kickup.core.model.EventAct"
     */
        protected Collection getActs()
        {
                return acts;
        }

        public Collection getActCollection()
        {
                return Collections.unmodifiableCollection(acts);
        }

        /**
         * @param destinations Collection(EventAct)
         */
        protected void setActs(Collection acts)
        {
                this.acts = acts;

                actsMap.clear();
                if(acts != null) {
                        for(Iterator i = acts.iterator(); i.hasNext(); ) {
                                EventAct a = (EventAct)i.next();
                                actsMap.put(a.getAct().getId(), a);
                        }
                }
        }

        public EventAct getAct(Long actId)
        {
                return (EventAct)actsMap.get(actId);
        }

        public void addAct(EventAct act)
        {
                acts.add(act);
                actsMap.put(act.getAct().getId(), act);
        }

        public void removeAct(EventAct act)
        {
                acts.remove(act);
                actsMap.remove(act.getAct().getId());
        }

        /**
         * @return Collection(EventApartment)
         *
         * @hibernate.bag inverse="true" cascade="all-delete-orphan" lazy="true"
         * @hibernate.collection-key column="event"
     * @hibernate.collection-one-to-many class="ak.kickup.core.model.EventApartment"
     */
        protected Collection getApartments()
        {
                return apartments;
        }

        public Collection getApartmentCollection()
        {
                return Collections.unmodifiableCollection(apartments);
        }

        /**
         * @param destinations Collection(EventApartment)
         */
        protected void setApartments(Collection apartments)
        {
                this.apartments = apartments;

                apartmentsMap.clear();
                if(apartments != null) {
                        for(Iterator i = apartments.iterator(); i.hasNext(); ) {
                                EventApartment a = (EventApartment)i.next();
                                apartmentsMap.put(a.getApartment().getId(), a);
                        }
                }
        }

        public EventApartment getApartment(Long apartmentId)
        {
                return (EventApartment)apartmentsMap.get(apartmentId);
        }

        public void addApartment(EventApartment apartment)
        {
                apartments.add(apartment);
                apartmentsMap.put(apartment.getApartment().getId(), apartment);
        }

        public void removeApartment(EventApartment apartment)
        {
                apartments.remove(apartment);
                apartmentsMap.remove(apartment.getApartment().getId());
        }
}