1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.Organization;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.Html;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="OrganizationModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>Organization</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.Organization
54   * @see com.liferay.portal.service.model.OrganizationModel
55   * @see com.liferay.portal.service.model.impl.OrganizationImpl
56   *
57   */
58  public class OrganizationModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "Organization_";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "organizationId", new Integer(Types.BIGINT) },
62              
63  
64              { "companyId", new Integer(Types.BIGINT) },
65              
66  
67              { "parentOrganizationId", new Integer(Types.BIGINT) },
68              
69  
70              { "name", new Integer(Types.VARCHAR) },
71              
72  
73              { "location", new Integer(Types.BOOLEAN) },
74              
75  
76              { "recursable", new Integer(Types.BOOLEAN) },
77              
78  
79              { "regionId", new Integer(Types.BIGINT) },
80              
81  
82              { "countryId", new Integer(Types.BIGINT) },
83              
84  
85              { "statusId", new Integer(Types.INTEGER) },
86              
87  
88              { "comments", new Integer(Types.VARCHAR) }
89          };
90      public static final String TABLE_SQL_CREATE = "create table Organization_ (organizationId LONG not null primary key,companyId LONG,parentOrganizationId LONG,name VARCHAR(100) null,location BOOLEAN,recursable BOOLEAN,regionId LONG,countryId LONG,statusId INTEGER,comments STRING null)";
91      public static final String TABLE_SQL_DROP = "drop table Organization_";
92      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
93                  "value.object.finder.cache.enabled.com.liferay.portal.model.Organization"),
94              true);
95      public static final boolean CACHE_ENABLED_GROUPS_ORGS = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_ORGS;
96      public static final boolean CACHE_ENABLED_USERS_ORGS = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_ORGS;
97      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
98                  "lock.expiration.time.com.liferay.portal.model.Organization"));
99  
100     public OrganizationModelImpl() {
101     }
102 
103     public long getPrimaryKey() {
104         return _organizationId;
105     }
106 
107     public void setPrimaryKey(long pk) {
108         setOrganizationId(pk);
109     }
110 
111     public Serializable getPrimaryKeyObj() {
112         return new Long(_organizationId);
113     }
114 
115     public long getOrganizationId() {
116         return _organizationId;
117     }
118 
119     public void setOrganizationId(long organizationId) {
120         if (organizationId != _organizationId) {
121             _organizationId = organizationId;
122         }
123     }
124 
125     public long getCompanyId() {
126         return _companyId;
127     }
128 
129     public void setCompanyId(long companyId) {
130         if (companyId != _companyId) {
131             _companyId = companyId;
132         }
133     }
134 
135     public long getParentOrganizationId() {
136         return _parentOrganizationId;
137     }
138 
139     public void setParentOrganizationId(long parentOrganizationId) {
140         if (parentOrganizationId != _parentOrganizationId) {
141             _parentOrganizationId = parentOrganizationId;
142         }
143     }
144 
145     public String getName() {
146         return GetterUtil.getString(_name);
147     }
148 
149     public void setName(String name) {
150         if (((name == null) && (_name != null)) ||
151                 ((name != null) && (_name == null)) ||
152                 ((name != null) && (_name != null) && !name.equals(_name))) {
153             _name = name;
154         }
155     }
156 
157     public boolean getLocation() {
158         return _location;
159     }
160 
161     public boolean isLocation() {
162         return _location;
163     }
164 
165     public void setLocation(boolean location) {
166         if (location != _location) {
167             _location = location;
168         }
169     }
170 
171     public boolean getRecursable() {
172         return _recursable;
173     }
174 
175     public boolean isRecursable() {
176         return _recursable;
177     }
178 
179     public void setRecursable(boolean recursable) {
180         if (recursable != _recursable) {
181             _recursable = recursable;
182         }
183     }
184 
185     public long getRegionId() {
186         return _regionId;
187     }
188 
189     public void setRegionId(long regionId) {
190         if (regionId != _regionId) {
191             _regionId = regionId;
192         }
193     }
194 
195     public long getCountryId() {
196         return _countryId;
197     }
198 
199     public void setCountryId(long countryId) {
200         if (countryId != _countryId) {
201             _countryId = countryId;
202         }
203     }
204 
205     public int getStatusId() {
206         return _statusId;
207     }
208 
209     public void setStatusId(int statusId) {
210         if (statusId != _statusId) {
211             _statusId = statusId;
212         }
213     }
214 
215     public String getComments() {
216         return GetterUtil.getString(_comments);
217     }
218 
219     public void setComments(String comments) {
220         if (((comments == null) && (_comments != null)) ||
221                 ((comments != null) && (_comments == null)) ||
222                 ((comments != null) && (_comments != null) &&
223                 !comments.equals(_comments))) {
224             _comments = comments;
225         }
226     }
227 
228     public Organization toEscapedModel() {
229         if (isEscapedModel()) {
230             return (Organization)this;
231         }
232         else {
233             Organization model = new OrganizationImpl();
234 
235             model.setEscapedModel(true);
236 
237             model.setOrganizationId(getOrganizationId());
238             model.setCompanyId(getCompanyId());
239             model.setParentOrganizationId(getParentOrganizationId());
240             model.setName(Html.escape(getName()));
241             model.setLocation(getLocation());
242             model.setRecursable(getRecursable());
243             model.setRegionId(getRegionId());
244             model.setCountryId(getCountryId());
245             model.setStatusId(getStatusId());
246             model.setComments(Html.escape(getComments()));
247 
248             model = (Organization)Proxy.newProxyInstance(Organization.class.getClassLoader(),
249                     new Class[] { Organization.class },
250                     new ReadOnlyBeanHandler(model));
251 
252             return model;
253         }
254     }
255 
256     public Object clone() {
257         OrganizationImpl clone = new OrganizationImpl();
258 
259         clone.setOrganizationId(getOrganizationId());
260         clone.setCompanyId(getCompanyId());
261         clone.setParentOrganizationId(getParentOrganizationId());
262         clone.setName(getName());
263         clone.setLocation(getLocation());
264         clone.setRecursable(getRecursable());
265         clone.setRegionId(getRegionId());
266         clone.setCountryId(getCountryId());
267         clone.setStatusId(getStatusId());
268         clone.setComments(getComments());
269 
270         return clone;
271     }
272 
273     public int compareTo(Object obj) {
274         if (obj == null) {
275             return -1;
276         }
277 
278         OrganizationImpl organization = (OrganizationImpl)obj;
279 
280         int value = 0;
281 
282         value = getName().compareTo(organization.getName());
283 
284         if (value != 0) {
285             return value;
286         }
287 
288         return 0;
289     }
290 
291     public boolean equals(Object obj) {
292         if (obj == null) {
293             return false;
294         }
295 
296         OrganizationImpl organization = null;
297 
298         try {
299             organization = (OrganizationImpl)obj;
300         }
301         catch (ClassCastException cce) {
302             return false;
303         }
304 
305         long pk = organization.getPrimaryKey();
306 
307         if (getPrimaryKey() == pk) {
308             return true;
309         }
310         else {
311             return false;
312         }
313     }
314 
315     public int hashCode() {
316         return (int)getPrimaryKey();
317     }
318 
319     private long _organizationId;
320     private long _companyId;
321     private long _parentOrganizationId;
322     private String _name;
323     private boolean _location;
324     private boolean _recursable;
325     private long _regionId;
326     private long _countryId;
327     private int _statusId;
328     private String _comments;
329 }