1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.Organization;
26  import com.liferay.portal.model.OrganizationSoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="OrganizationModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>Organization</code> table
47   * in the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portal.model.Organization
53   * @see com.liferay.portal.model.OrganizationModel
54   * @see com.liferay.portal.model.impl.OrganizationImpl
55   *
56   */
57  public class OrganizationModelImpl extends BaseModelImpl {
58      public static final String TABLE_NAME = "Organization_";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "organizationId", new Integer(Types.BIGINT) },
61              
62  
63              { "companyId", new Integer(Types.BIGINT) },
64              
65  
66              { "parentOrganizationId", new Integer(Types.BIGINT) },
67              
68  
69              { "name", new Integer(Types.VARCHAR) },
70              
71  
72              { "location", new Integer(Types.BOOLEAN) },
73              
74  
75              { "recursable", new Integer(Types.BOOLEAN) },
76              
77  
78              { "regionId", new Integer(Types.BIGINT) },
79              
80  
81              { "countryId", new Integer(Types.BIGINT) },
82              
83  
84              { "statusId", new Integer(Types.INTEGER) },
85              
86  
87              { "comments", new Integer(Types.VARCHAR) }
88          };
89      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)";
90      public static final String TABLE_SQL_DROP = "drop table Organization_";
91      public static final String DATA_SOURCE = "liferayDataSource";
92      public static final String SESSION_FACTORY = "liferaySessionFactory";
93      public static final String TX_MANAGER = "liferayTransactionManager";
94      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
95                  "value.object.finder.cache.enabled.com.liferay.portal.model.Organization"),
96              true);
97  
98      public static Organization toModel(OrganizationSoap soapModel) {
99          Organization model = new OrganizationImpl();
100 
101         model.setOrganizationId(soapModel.getOrganizationId());
102         model.setCompanyId(soapModel.getCompanyId());
103         model.setParentOrganizationId(soapModel.getParentOrganizationId());
104         model.setName(soapModel.getName());
105         model.setLocation(soapModel.getLocation());
106         model.setRecursable(soapModel.getRecursable());
107         model.setRegionId(soapModel.getRegionId());
108         model.setCountryId(soapModel.getCountryId());
109         model.setStatusId(soapModel.getStatusId());
110         model.setComments(soapModel.getComments());
111 
112         return model;
113     }
114 
115     public static List<Organization> toModels(OrganizationSoap[] soapModels) {
116         List<Organization> models = new ArrayList<Organization>(soapModels.length);
117 
118         for (OrganizationSoap soapModel : soapModels) {
119             models.add(toModel(soapModel));
120         }
121 
122         return models;
123     }
124 
125     public static final boolean CACHE_ENABLED_GROUPS_ORGS = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_ORGS;
126     public static final boolean CACHE_ENABLED_USERS_ORGS = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_ORGS;
127     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
128                 "lock.expiration.time.com.liferay.portal.model.Organization"));
129 
130     public OrganizationModelImpl() {
131     }
132 
133     public long getPrimaryKey() {
134         return _organizationId;
135     }
136 
137     public void setPrimaryKey(long pk) {
138         setOrganizationId(pk);
139     }
140 
141     public Serializable getPrimaryKeyObj() {
142         return new Long(_organizationId);
143     }
144 
145     public long getOrganizationId() {
146         return _organizationId;
147     }
148 
149     public void setOrganizationId(long organizationId) {
150         if (organizationId != _organizationId) {
151             _organizationId = organizationId;
152         }
153     }
154 
155     public long getCompanyId() {
156         return _companyId;
157     }
158 
159     public void setCompanyId(long companyId) {
160         if (companyId != _companyId) {
161             _companyId = companyId;
162         }
163     }
164 
165     public long getParentOrganizationId() {
166         return _parentOrganizationId;
167     }
168 
169     public void setParentOrganizationId(long parentOrganizationId) {
170         if (parentOrganizationId != _parentOrganizationId) {
171             _parentOrganizationId = parentOrganizationId;
172         }
173     }
174 
175     public String getName() {
176         return GetterUtil.getString(_name);
177     }
178 
179     public void setName(String name) {
180         if (((name == null) && (_name != null)) ||
181                 ((name != null) && (_name == null)) ||
182                 ((name != null) && (_name != null) && !name.equals(_name))) {
183             _name = name;
184         }
185     }
186 
187     public boolean getLocation() {
188         return _location;
189     }
190 
191     public boolean isLocation() {
192         return _location;
193     }
194 
195     public void setLocation(boolean location) {
196         if (location != _location) {
197             _location = location;
198         }
199     }
200 
201     public boolean getRecursable() {
202         return _recursable;
203     }
204 
205     public boolean isRecursable() {
206         return _recursable;
207     }
208 
209     public void setRecursable(boolean recursable) {
210         if (recursable != _recursable) {
211             _recursable = recursable;
212         }
213     }
214 
215     public long getRegionId() {
216         return _regionId;
217     }
218 
219     public void setRegionId(long regionId) {
220         if (regionId != _regionId) {
221             _regionId = regionId;
222         }
223     }
224 
225     public long getCountryId() {
226         return _countryId;
227     }
228 
229     public void setCountryId(long countryId) {
230         if (countryId != _countryId) {
231             _countryId = countryId;
232         }
233     }
234 
235     public int getStatusId() {
236         return _statusId;
237     }
238 
239     public void setStatusId(int statusId) {
240         if (statusId != _statusId) {
241             _statusId = statusId;
242         }
243     }
244 
245     public String getComments() {
246         return GetterUtil.getString(_comments);
247     }
248 
249     public void setComments(String comments) {
250         if (((comments == null) && (_comments != null)) ||
251                 ((comments != null) && (_comments == null)) ||
252                 ((comments != null) && (_comments != null) &&
253                 !comments.equals(_comments))) {
254             _comments = comments;
255         }
256     }
257 
258     public Organization toEscapedModel() {
259         if (isEscapedModel()) {
260             return (Organization)this;
261         }
262         else {
263             Organization model = new OrganizationImpl();
264 
265             model.setNew(isNew());
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 }