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