View Javadoc

1   /*
2    * Copyright (C) 2007 Alf Mikula
3    * 
4    * This file is part of PromoteGo.
5    *
6    * PromoteGo is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * PromoteGo is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with PromoteGo.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.promotego.beans;
20  
21  import javax.persistence.CascadeType;
22  import javax.persistence.Column;
23  import javax.persistence.Entity;
24  import javax.persistence.ManyToOne;
25  import javax.persistence.OneToOne;
26  import javax.persistence.Transient;
27  
28  import org.promotego.logic.storehours.NullStoreHours;
29  import org.promotego.logic.storehours.StoreHours;
30  
31  /***
32   * TODO use http://www.geonames.org/ to look up location time zones.
33   * 
34   * @author alf
35   *
36   */
37  @Entity
38  public class Location extends BeanSupport<Location>
39  {
40      private String m_name;
41      private Address m_address;
42      private User m_owner;
43      private LocationType m_type;
44      private String m_phoneNumber;
45      private StoreHours m_storeHours;
46      
47      public Location()
48      {
49          m_storeHours = NullStoreHours.getInstance();
50      }
51      
52      @OneToOne(cascade=CascadeType.ALL)
53      public Address getAddress()
54      {
55          return m_address;
56      }
57      
58      public void setAddress(Address address)
59      {
60          m_address = address;
61      }
62      
63      public String getName()
64      {
65          return m_name;
66      }
67      
68      public void setName(String name)
69      {
70          m_name = name;
71      }
72      
73      @OneToOne
74      public User getOwner()
75      {
76          return m_owner;
77      }
78      
79      public void setOwner(User owner)
80      {
81          m_owner = owner;
82      }
83      
84      @ManyToOne
85      public LocationType getType()
86      {
87          return m_type;
88      }
89      
90      public void setType(LocationType type)
91      {
92          m_type = type;
93      }
94  
95  	public String getPhoneNumber()
96  	{
97  		return m_phoneNumber;
98  	}
99  
100 	public void setPhoneNumber(String phoneNumber)
101 	{
102 		m_phoneNumber = phoneNumber;
103 	}
104 
105 	@Transient
106 	public StoreHours getStoreHours()
107 	{
108 		return m_storeHours;
109 	}
110 
111 	public void setStoreHours(StoreHours storeHours)
112 	{
113 		m_storeHours = storeHours;
114 	}
115 	
116 	@Column(name="STOREHOURS")
117 	public String getStoreHoursString()
118 	{
119 		if (m_storeHours == null)
120 		{
121 			return null;
122 		}
123 		else
124 		{
125 			return m_storeHours.toString();
126 		}
127 	}
128 	
129 	public void setStoreHoursString(String storeHoursString)
130 	{
131 		if (storeHoursString == null || storeHoursString.length() == 0)
132 		{
133 			m_storeHours = NullStoreHours.getInstance();
134 		}
135 		else
136 		{
137 			m_storeHours = new StoreHours(storeHoursString);
138 		}
139 	}
140 }