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