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.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.Organization;
29  import com.liferay.portal.model.OrganizationSoap;
30  import com.liferay.portal.util.PropsUtil;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="OrganizationModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>Organization</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.Organization
57   * @see com.liferay.portal.service.model.OrganizationModel
58   * @see com.liferay.portal.service.model.impl.OrganizationImpl
59   *
60   */
61  public class OrganizationModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "Organization_";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "organizationId", new Integer(Types.BIGINT) },
65              
66  
67              { "companyId", new Integer(Types.BIGINT) },
68              
69  
70              { "parentOrganizationId", new Integer(Types.BIGINT) },
71              
72  
73              { "name", new Integer(Types.VARCHAR) },
74              
75  
76              { "location", new Integer(Types.BOOLEAN) },
77              
78  
79              { "recursable", new Integer(Types.BOOLEAN) },
80              
81  
82              { "regionId", new Integer(Types.BIGINT) },
83              
84  
85              { "countryId", new Integer(Types.BIGINT) },
86              
87  
88              { "statusId", new Integer(Types.INTEGER) },
89              
90  
91              { "comments", new Integer(Types.VARCHAR) }
92          };
93      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)";
94      public static final String TABLE_SQL_DROP = "drop table Organization_";
95      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
96                  "value.object.finder.cache.enabled.com.liferay.portal.model.Organization"),
97              true);
98  
99      public static Organization toModel(OrganizationSoap soapModel) {
100         Organization model = new OrganizationImpl();
101 
102         model.setOrganizationId(soapModel.getOrganizationId());
103         model.setCompanyId(soapModel.getCompanyId());
104         model.setParentOrganizationId(soapModel.getParentOrganizationId());
105         model.setName(soapModel.getName());
106         model.setLocation(soapModel.getLocation());
107         model.setRecursable(soapModel.getRecursable());
108         model.setRegionId(soapModel.getRegionId());
109         model.setCountryId(soapModel.getCountryId());
110         model.setStatusId(soapModel.getStatusId());
111         model.setComments(soapModel.getComments());
112 
113         return model;
114     }
115 
116     public static List<Organization> toModels(OrganizationSoap[] soapModels) {
117         List<Organization> models = new ArrayList<Organization>(soapModels.length);
118 
119         for (OrganizationSoap soapModel : soapModels) {
120             models.add(toModel(soapModel));
121         }
122 
123         return models;
124     }
125 
126     public static final boolean CACHE_ENABLED_GROUPS_ORGS = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_ORGS;
127     public static final boolean CACHE_ENABLED_USERS_ORGS = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_ORGS;
128     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
129                 "lock.expiration.time.com.liferay.portal.model.Organization"));
130 
131     public OrganizationModelImpl() {
132     }
133 
134     public long getPrimaryKey() {
135         return _organizationId;
136     }
137 
138     public void setPrimaryKey(long pk) {
139         setOrganizationId(pk);
140     }
141 
142     public Serializable getPrimaryKeyObj() {
143         return new Long(_organizationId);
144     }
145 
146     public long getOrganizationId() {
147         return _organizationId;
148     }
149 
150     public void setOrganizationId(long organizationId) {
151         if (organizationId != _organizationId) {
152             _organizationId = organizationId;
153         }
154     }
155 
156     public long getCompanyId() {
157         return _companyId;
158     }
159 
160     public void setCompanyId(long companyId) {
161         if (companyId != _companyId) {
162             _companyId = companyId;
163         }
164     }
165 
166     public long getParentOrganizationId() {
167         return _parentOrganizationId;
168     }
169 
170     public void setParentOrganizationId(long parentOrganizationId) {
171         if (parentOrganizationId != _parentOrganizationId) {
172             _parentOrganizationId = parentOrganizationId;
173         }
174     }
175 
176     public String getName() {
177         return GetterUtil.getString(_name);
178     }
179 
180     public void setName(String name) {
181         if (((name == null) && (_name != null)) ||
182                 ((name != null) && (_name == null)) ||
183                 ((name != null) && (_name != null) && !name.equals(_name))) {
184             _name = name;
185         }
186     }
187 
188     public boolean getLocation() {
189         return _location;
190     }
191 
192     public boolean isLocation() {
193         return _location;
194     }
195 
196     public void setLocation(boolean location) {
197         if (location != _location) {
198             _location = location;
199         }
200     }
201 
202     public boolean getRecursable() {
203         return _recursable;
204     }
205 
206     public boolean isRecursable() {
207         return _recursable;
208     }
209 
210     public void setRecursable(boolean recursable) {
211         if (recursable != _recursable) {
212             _recursable = recursable;
213         }
214     }
215 
216     public long getRegionId() {
217         return _regionId;
218     }
219 
220     public void setRegionId(long regionId) {
221         if (regionId != _regionId) {
222             _regionId = regionId;
223         }
224     }
225 
226     public long getCountryId() {
227         return _countryId;
228     }
229 
230     public void setCountryId(long countryId) {
231         if (countryId != _countryId) {
232             _countryId = countryId;
233         }
234     }
235 
236     public int getStatusId() {
237         return _statusId;
238     }
239 
240     public void setStatusId(int statusId) {
241         if (statusId != _statusId) {
242             _statusId = statusId;
243         }
244     }
245 
246     public String getComments() {
247         return GetterUtil.getString(_comments);
248     }
249 
250     public void setComments(String comments) {
251         if (((comments == null) && (_comments != null)) ||
252                 ((comments != null) && (_comments == null)) ||
253                 ((comments != null) && (_comments != null) &&
254                 !comments.equals(_comments))) {
255             _comments = comments;
256         }
257     }
258 
259     public Organization toEscapedModel() {
260         if (isEscapedModel()) {
261             return (Organization)this;
262         }
263         else {
264             Organization model = new OrganizationImpl();
265 
266             model.setEscapedModel(true);
267 
268             model.setOrganizationId(getOrganizationId());
269             model.setCompanyId(getCompanyId());
270             model.setParentOrganizationId(getParentOrganizationId());
271             model.setName(HtmlUtil.escape(getName()));
272             model.setLocation(getLocation());
273             model.setRecursable(getRecursable());
274             model.setRegionId(getRegionId());
275             model.setCountryId(getCountryId());
276             model.setStatusId(getStatusId());
277             model.setComments(HtmlUtil.escape(getComments()));
278 
279             model = (Organization)Proxy.newProxyInstance(Organization.class.getClassLoader(),
280                     new Class[] { Organization.class },
281                     new ReadOnlyBeanHandler(model));
282 
283             return model;
284         }
285     }
286 
287     public Object clone() {
288         OrganizationImpl clone = new OrganizationImpl();
289 
290         clone.setOrganizationId(getOrganizationId());
291         clone.setCompanyId(getCompanyId());
292         clone.setParentOrganizationId(getParentOrganizationId());
293         clone.setName(getName());
294         clone.setLocation(getLocation());
295         clone.setRecursable(getRecursable());
296         clone.setRegionId(getRegionId());
297         clone.setCountryId(getCountryId());
298         clone.setStatusId(getStatusId());
299         clone.setComments(getComments());
300 
301         return clone;
302     }
303 
304     public int compareTo(Object obj) {
305         if (obj == null) {
306             return -1;
307         }
308 
309         OrganizationImpl organization = (OrganizationImpl)obj;
310 
311         int value = 0;
312 
313         value = getName().compareTo(organization.getName());
314 
315         if (value != 0) {
316             return value;
317         }
318 
319         return 0;
320     }
321 
322     public boolean equals(Object obj) {
323         if (obj == null) {
324             return false;
325         }
326 
327         OrganizationImpl organization = null;
328 
329         try {
330             organization = (OrganizationImpl)obj;
331         }
332         catch (ClassCastException cce) {
333             return false;
334         }
335 
336         long pk = organization.getPrimaryKey();
337 
338         if (getPrimaryKey() == pk) {
339             return true;
340         }
341         else {
342             return false;
343         }
344     }
345 
346     public int hashCode() {
347         return (int)getPrimaryKey();
348     }
349 
350     private long _organizationId;
351     private long _companyId;
352     private long _parentOrganizationId;
353     private String _name;
354     private boolean _location;
355     private boolean _recursable;
356     private long _regionId;
357     private long _countryId;
358     private int _statusId;
359     private String _comments;
360 }