/it-ru/trunk/src/ak/itru/core/model/EventAct.java |
---|
0,0 → 1,92 |
package ak.itru.core.model; |
import java.util.Date; |
import ak.itru.util.ModelException; |
import ak.itru.util.ModelSecurityException; |
/** |
* |
* @hibernate.class table="event_acts" |
*/ |
public class EventAct |
{ |
private Long id; |
private Long eventId; |
private Long actId; |
private String comment; |
private Date modStamp; |
protected EventAct() |
{ |
} |
/** |
* |
* @hibernate.id generator-class="native" |
*/ |
public Long getId() |
{ |
return id; |
} |
protected void setId(Long id) |
{ |
this.id = id; |
} |
/** |
* |
* @hibernate.property |
*/ |
public Long getEventId() |
{ |
return eventId; |
} |
public void setEventId(Long eventId) |
{ |
this.eventId = eventId; |
} |
/** |
* |
* @hibernate.property |
*/ |
public Long getActId() |
{ |
return actId; |
} |
public void setActId(Long actId) |
{ |
this.actId = actId; |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getComment() |
{ |
return comment; |
} |
public void setComment(String comment) |
{ |
this.comment = comment; |
} |
/** |
* |
* @hibernate.timestamp column="mod_stamp" |
*/ |
public Date getModStamp() |
{ |
return modStamp; |
} |
public void setModStamp(Date modStamp) |
{ |
this.modStamp = modStamp; |
} |
} |
/it-ru/trunk/src/ak/itru/core/model/Apartment.java |
---|
0,0 → 1,101 |
package ak.itru.core.model; |
import java.math.BigDecimal; |
import ak.itru.util.ModelException; |
import ak.itru.util.ModelSecurityException; |
/** |
* |
* @hibernate.class table="apartments" |
*/ |
public class Apartment |
extends GeneralModelObject |
{ |
private String name; |
private String address; |
private BigDecimal price; |
private String url; |
private String comment; |
protected Apartment() |
{ |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getName() |
{ |
return name; |
} |
public void setName(String name) |
{ |
this.name = name; |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getAddress() |
{ |
return address; |
} |
public void setAddress(String address) |
{ |
this.address = address; |
} |
/** |
* |
* @hibernate.property |
*/ |
public BigDecimal getPrice() |
{ |
return price; |
} |
public void setPrice(BigDecimal price) |
{ |
this.price = price; |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getUrl() |
{ |
return url; |
} |
public void setUrl(String url) |
{ |
this.url = url; |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getComment() |
{ |
return comment; |
} |
public void setComment(String comment) |
{ |
this.comment = comment; |
} |
public boolean equals(Object o) |
{ |
if(o == null || !(o instanceof Apartment)) return false; |
Apartment a = (Apartment)o; |
return (getId() != null) && (a.getId() != null) && (getId().equals(a.getId())); |
} |
} |
/it-ru/trunk/src/ak/itru/core/model/EventManager.java |
---|
0,0 → 1,190 |
package ak.itru.core.model; |
import java.util.*; |
import net.sf.hibernate.*; |
import net.sf.hibernate.type.Type; |
import ak.itru.util.HibernateUtil; |
import ak.itru.util.ModelException; |
import ak.itru.util.ModelSecurityException; |
public class EventManager |
{ |
private static EventManager eventManager = null; |
private static boolean registered = false; |
public static EventManager getInstance() |
{ |
return eventManager; |
} |
protected static void register() |
{ |
synchronized(EventManager.class) { |
if(registered) return; |
registered = true; |
try { |
HibernateUtil.getConfiguration().addResource( |
"ak/itru/core/model/Event.hbm.xml"); |
HibernateUtil.getConfiguration().addResource( |
"ak/itru/core/model/EventAct.hbm.xml"); |
eventManager = new EventManager(); |
} |
catch(Exception ex) { |
ex.printStackTrace(); |
throw new RuntimeException(ex.getMessage()); |
} |
} |
} |
static { |
register(); |
} |
private EventManager() |
{ |
} |
public Event create() |
throws ModelException |
{ |
Event e = new Event(); |
e.init(); |
return e; |
} |
public Event get(Long id) |
throws ModelException |
{ |
try { |
return (Event)HibernateUtil.currentSession().load(Event.class, id); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public boolean nameExists(Event event, String name) |
throws ModelException |
{ |
try { |
if(event.getId() == null) |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from Event where name = ?", |
name, Hibernate.STRING) |
.next()).intValue() > 0; |
else |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from Event e where name = ? and e != ?", |
new Object[] { name, event }, |
new Type[] { Hibernate.STRING, Hibernate.entity(Event.class) } ) |
.next()).intValue() > 0; |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public void save(Event event) |
throws ModelException |
{ |
try { |
HibernateUtil.currentSession().saveOrUpdate(event); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public void delete(Event event) |
throws ModelException |
{ |
try { |
HibernateUtil.currentSession().delete(event); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public Collection listEvents(boolean enabledOnly) |
throws ModelException |
{ |
try { |
if(enabledOnly) { |
return HibernateUtil.currentSession().find( |
"from Event where enabled=?", |
Boolean.TRUE, Hibernate.BOOLEAN); |
} |
else { |
return HibernateUtil.currentSession().find("from Event"); |
} |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public static final Comparator NAME_COMPARATOR = new NameComparator(); |
public static final Comparator START_COMPARATOR = new StartComparator(); |
private static class NameComparator |
implements Comparator |
{ |
public int compare(Object o1, Object o2) |
{ |
if(!(o1 instanceof Event) || !(o2 instanceof Event)) |
throw new ClassCastException("not a Event"); |
Event a1 = (Event)o1; |
Event a2 = (Event)o2; |
if(a1 == null && a2 == null) |
return 0; |
else if(a1 == null && a2 != null) |
return -1; |
else if(a1 != null && a2 == null) |
return 1; |
else |
return a1.getName().compareToIgnoreCase(a2.getName()); |
} |
public boolean equals(Object obj) |
{ |
return (obj instanceof NameComparator); |
} |
} |
private static class StartComparator |
implements Comparator |
{ |
public int compare(Object o1, Object o2) |
{ |
if(!(o1 instanceof Event) || !(o2 instanceof Event)) |
throw new ClassCastException("not a Event"); |
Event a1 = (Event)o1; |
Event a2 = (Event)o2; |
if((a1 == null || a1.getStart() == null) && (a2 == null || a2.getStart() == null)) |
return 0; |
else if((a1 == null || a1.getStart() == null) && (a2 != null && a2.getStart() != null)) |
return -1; |
else if((a1 != null && a1.getStart() != null) && (a2 == null || a2.getStart() == null)) |
return 1; |
else |
return a1.getStart().compareTo(a2.getStart()); |
} |
public boolean equals(Object obj) |
{ |
return (obj instanceof StartComparator); |
} |
} |
} |
/it-ru/trunk/src/ak/itru/core/model/Participant.java |
---|
0,0 → 1,100 |
package ak.itru.core.model; |
import ak.itru.util.ModelException; |
import ak.itru.util.ModelSecurityException; |
/** |
* |
* @hibernate.class table="participants" |
*/ |
public class Participant |
extends GeneralModelObject |
{ |
private String nick; |
private String email; |
private String name; |
private String phone; |
private String comment; |
protected Participant() |
{ |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getNick() |
{ |
return nick; |
} |
public void setNick(String nick) |
{ |
this.nick = nick; |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getEmail() |
{ |
return email; |
} |
public void setEmail(String email) |
{ |
this.email = email; |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getName() |
{ |
return name; |
} |
public void setName(String name) |
{ |
this.name = name; |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getPhone() |
{ |
return phone; |
} |
public void setPhone(String phone) |
{ |
this.phone = phone; |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getComment() |
{ |
return comment; |
} |
public void setComment(String comment) |
{ |
this.comment = comment; |
} |
public boolean equals(Object o) |
{ |
if(o == null || !(o instanceof Participant)) return false; |
Participant p = (Participant)o; |
return (getId() != null) && (p.getId() != null) && (getId().equals(p.getId())); |
} |
} |
/it-ru/trunk/src/ak/itru/core/model/Event.java |
---|
0,0 → 1,242 |
package ak.itru.core.model; |
import java.math.BigDecimal; |
import java.util.Collection; |
import java.util.ArrayList; |
import java.util.Iterator; |
import java.util.Date; |
import java.util.Map; |
import java.util.HashMap; |
import ak.itru.util.ModelException; |
import ak.itru.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(); |
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="eventid" |
* @hibernate.collection-one-to-many class="ak.itru.core.model.EventAct" |
*/ |
public Collection getActs() |
{ |
return acts; |
} |
/** |
* @param destinations Collection(EventAct) |
*/ |
public void setActs(Collection acts) |
{ |
this.acts = acts; |
actsMap.clear(); |
for(Iterator i = acts.iterator(); i.hasNext(); ) { |
EventAct a = (EventAct)i.next(); |
actsMap.put(a.getActId(), a); |
} |
} |
public EventAct getAct(Long actId) |
{ |
return (EventAct)actsMap.get(actId); |
} |
} |
/it-ru/trunk/src/ak/itru/core/model/ActManager.java |
---|
0,0 → 1,151 |
package ak.itru.core.model; |
import java.util.*; |
import net.sf.hibernate.*; |
import net.sf.hibernate.type.Type; |
import ak.itru.util.HibernateUtil; |
import ak.itru.util.ModelException; |
import ak.itru.util.ModelSecurityException; |
public class ActManager |
{ |
private static ActManager actManager = null; |
private static boolean registered = false; |
public static ActManager getInstance() |
{ |
return actManager; |
} |
protected static void register() |
{ |
synchronized(ActManager.class) { |
if(registered) return; |
registered = true; |
try { |
HibernateUtil.getConfiguration().addResource( |
"ak/itru/core/model/Act.hbm.xml"); |
actManager = new ActManager(); |
} |
catch(Exception ex) { |
ex.printStackTrace(); |
throw new RuntimeException(ex.getMessage()); |
} |
} |
} |
static { |
register(); |
} |
private ActManager() |
{ |
} |
public Act create() |
throws ModelException |
{ |
return new Act(); |
} |
public Act get(Long id) |
throws ModelException |
{ |
try { |
return (Act)HibernateUtil.currentSession().load(Act.class, id); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public boolean nameExists(Act act, String name) |
throws ModelException |
{ |
try { |
if(act.getId() == null) |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from Act where name = ?", |
name, Hibernate.STRING) |
.next()).intValue() > 0; |
else |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from Act a where name = ? and a != ?", |
new Object[] { name, act }, |
new Type[] { Hibernate.STRING, Hibernate.entity(Act.class) } ) |
.next()).intValue() > 0; |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public void save(Act act) |
throws ModelException |
{ |
try { |
HibernateUtil.currentSession().saveOrUpdate(act); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public void delete(Act act) |
throws ModelException |
{ |
try { |
HibernateUtil.currentSession().delete(act); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public Collection listActs() |
throws ModelException |
{ |
try { |
return HibernateUtil.currentSession().find("from Act"); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public static final Comparator NAME_COMPARATOR = new NameComparator(); |
private static class NameComparator |
implements Comparator |
{ |
public int compare(Object o1, Object o2) |
{ |
if(!(o1 instanceof Act) || !(o2 instanceof Act)) |
throw new ClassCastException("not a Act"); |
Act a1 = (Act)o1; |
Act a2 = (Act)o2; |
if(a1 == null && a2 == null) |
return 0; |
else if(a1 == null && a2 != null) |
return -1; |
else if(a1 != null && a2 == null) |
return 1; |
else |
return a1.getName().compareToIgnoreCase(a2.getName()); |
} |
public boolean equals(Object obj) |
{ |
return (obj instanceof NameComparator); |
} |
} |
} |
/it-ru/trunk/src/ak/itru/core/model/GeneralModelObject.java |
---|
0,0 → 1,37 |
package ak.itru.core.model; |
import java.util.Date; |
public abstract class GeneralModelObject |
{ |
private Long id; |
private Date modStamp; |
/** |
* |
* @hibernate.id generator-class="native" |
*/ |
public Long getId() |
{ |
return id; |
} |
protected void setId(Long id) |
{ |
this.id = id; |
} |
/** |
* |
* @hibernate.timestamp column="mod_stamp" |
*/ |
public Date getModStamp() |
{ |
return modStamp; |
} |
public void setModStamp(Date modStamp) |
{ |
this.modStamp = modStamp; |
} |
} |
/it-ru/trunk/src/ak/itru/core/model/ApartmentManager.java |
---|
0,0 → 1,151 |
package ak.itru.core.model; |
import java.util.*; |
import net.sf.hibernate.*; |
import net.sf.hibernate.type.Type; |
import ak.itru.util.HibernateUtil; |
import ak.itru.util.ModelException; |
import ak.itru.util.ModelSecurityException; |
public class ApartmentManager |
{ |
private static ApartmentManager apartmentManager = null; |
private static boolean registered = false; |
public static ApartmentManager getInstance() |
{ |
return apartmentManager; |
} |
protected static void register() |
{ |
synchronized(ApartmentManager.class) { |
if(registered) return; |
registered = true; |
try { |
HibernateUtil.getConfiguration().addResource( |
"ak/itru/core/model/Apartment.hbm.xml"); |
apartmentManager = new ApartmentManager(); |
} |
catch(Exception ex) { |
ex.printStackTrace(); |
throw new RuntimeException(ex.getMessage()); |
} |
} |
} |
static { |
register(); |
} |
private ApartmentManager() |
{ |
} |
public Apartment create() |
throws ModelException |
{ |
return new Apartment(); |
} |
public Apartment get(Long id) |
throws ModelException |
{ |
try { |
return (Apartment)HibernateUtil.currentSession().load(Apartment.class, id); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public boolean nameExists(Apartment apartment, String name) |
throws ModelException |
{ |
try { |
if(apartment.getId() == null) |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from Apartment where name = ?", |
name, Hibernate.STRING) |
.next()).intValue() > 0; |
else |
return ((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from Apartment a where name = ? and a != ?", |
new Object[] { name, apartment }, |
new Type[] { Hibernate.STRING, Hibernate.entity(Apartment.class) } ) |
.next()).intValue() > 0; |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public void save(Apartment apartment) |
throws ModelException |
{ |
try { |
HibernateUtil.currentSession().saveOrUpdate(apartment); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public void delete(Apartment apartment) |
throws ModelException |
{ |
try { |
HibernateUtil.currentSession().delete(apartment); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public Collection listApartments() |
throws ModelException |
{ |
try { |
return HibernateUtil.currentSession().find("from Apartment"); |
} |
catch(HibernateException ex) |
{ |
throw new ModelException(ex); |
} |
} |
public static final Comparator NAME_COMPARATOR = new NameComparator(); |
private static class NameComparator |
implements Comparator |
{ |
public int compare(Object o1, Object o2) |
{ |
if(!(o1 instanceof Apartment) || !(o2 instanceof Apartment)) |
throw new ClassCastException("not a Apartment"); |
Apartment a1 = (Apartment)o1; |
Apartment a2 = (Apartment)o2; |
if(a1 == null && a2 == null) |
return 0; |
else if(a1 == null && a2 != null) |
return -1; |
else if(a1 != null && a2 == null) |
return 1; |
else |
return a1.getName().compareToIgnoreCase(a2.getName()); |
} |
public boolean equals(Object obj) |
{ |
return (obj instanceof NameComparator); |
} |
} |
} |
/it-ru/trunk/src/ak/itru/core/model/Act.java |
---|
0,0 → 1,56 |
package ak.itru.core.model; |
import java.util.Date; |
import ak.itru.util.ModelException; |
import ak.itru.util.ModelSecurityException; |
/** |
* |
* @hibernate.class table="acts" |
*/ |
public class Act |
extends GeneralModelObject |
{ |
private String name; |
private String comment; |
protected Act() |
{ |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getName() |
{ |
return name; |
} |
public void setName(String name) |
{ |
this.name = name; |
} |
/** |
* |
* @hibernate.property |
*/ |
public String getComment() |
{ |
return comment; |
} |
public void setComment(String comment) |
{ |
this.comment = comment; |
} |
public boolean equals(Object o) |
{ |
if(o == null || !(o instanceof Act)) return false; |
Act a = (Act)o; |
return (getId() != null) && (a.getId() != null) && (getId().equals(a.getId())); |
} |
} |