1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.asset.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.kernel.util.StringPool;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.service.ServiceContext;
24  import com.liferay.portal.util.PortalUtil;
25  
26  import com.liferay.portlet.asset.model.AssetLink;
27  import com.liferay.portlet.asset.model.AssetLinkSoap;
28  import com.liferay.portlet.expando.model.ExpandoBridge;
29  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
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.Date;
39  import java.util.List;
40  
41  /**
42   * <a href="AssetLinkModelImpl.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 interface is a model that represents the AssetLink table in the
51   * database.
52   * </p>
53   *
54   * @author    Brian Wing Shun Chan
55   * @see       AssetLinkImpl
56   * @see       com.liferay.portlet.asset.model.AssetLink
57   * @see       com.liferay.portlet.asset.model.AssetLinkModel
58   * @generated
59   */
60  public class AssetLinkModelImpl extends BaseModelImpl<AssetLink> {
61      public static final String TABLE_NAME = "AssetLink";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "linkId", new Integer(Types.BIGINT) },
64              { "companyId", new Integer(Types.BIGINT) },
65              { "userId", new Integer(Types.BIGINT) },
66              { "userName", new Integer(Types.VARCHAR) },
67              { "createDate", new Integer(Types.TIMESTAMP) },
68              { "entryId1", new Integer(Types.BIGINT) },
69              { "entryId2", new Integer(Types.BIGINT) },
70              { "type_", new Integer(Types.INTEGER) },
71              { "weight", new Integer(Types.INTEGER) }
72          };
73      public static final String TABLE_SQL_CREATE = "create table AssetLink (linkId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,entryId1 LONG,entryId2 LONG,type_ INTEGER,weight INTEGER)";
74      public static final String TABLE_SQL_DROP = "drop table AssetLink";
75      public static final String ORDER_BY_JPQL = " ORDER BY assetLink.weight ASC";
76      public static final String ORDER_BY_SQL = " ORDER BY AssetLink.weight ASC";
77      public static final String DATA_SOURCE = "liferayDataSource";
78      public static final String SESSION_FACTORY = "liferaySessionFactory";
79      public static final String TX_MANAGER = "liferayTransactionManager";
80      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetLink"),
82              true);
83      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
84                  "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetLink"),
85              true);
86  
87      public static AssetLink toModel(AssetLinkSoap soapModel) {
88          AssetLink model = new AssetLinkImpl();
89  
90          model.setLinkId(soapModel.getLinkId());
91          model.setCompanyId(soapModel.getCompanyId());
92          model.setUserId(soapModel.getUserId());
93          model.setUserName(soapModel.getUserName());
94          model.setCreateDate(soapModel.getCreateDate());
95          model.setEntryId1(soapModel.getEntryId1());
96          model.setEntryId2(soapModel.getEntryId2());
97          model.setType(soapModel.getType());
98          model.setWeight(soapModel.getWeight());
99  
100         return model;
101     }
102 
103     public static List<AssetLink> toModels(AssetLinkSoap[] soapModels) {
104         List<AssetLink> models = new ArrayList<AssetLink>(soapModels.length);
105 
106         for (AssetLinkSoap soapModel : soapModels) {
107             models.add(toModel(soapModel));
108         }
109 
110         return models;
111     }
112 
113     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
114                 "lock.expiration.time.com.liferay.portlet.asset.model.AssetLink"));
115 
116     public AssetLinkModelImpl() {
117     }
118 
119     public long getPrimaryKey() {
120         return _linkId;
121     }
122 
123     public void setPrimaryKey(long pk) {
124         setLinkId(pk);
125     }
126 
127     public Serializable getPrimaryKeyObj() {
128         return new Long(_linkId);
129     }
130 
131     public long getLinkId() {
132         return _linkId;
133     }
134 
135     public void setLinkId(long linkId) {
136         _linkId = linkId;
137     }
138 
139     public long getCompanyId() {
140         return _companyId;
141     }
142 
143     public void setCompanyId(long companyId) {
144         _companyId = companyId;
145     }
146 
147     public long getUserId() {
148         return _userId;
149     }
150 
151     public void setUserId(long userId) {
152         _userId = userId;
153     }
154 
155     public String getUserUuid() throws SystemException {
156         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
157     }
158 
159     public void setUserUuid(String userUuid) {
160         _userUuid = userUuid;
161     }
162 
163     public String getUserName() {
164         if (_userName == null) {
165             return StringPool.BLANK;
166         }
167         else {
168             return _userName;
169         }
170     }
171 
172     public void setUserName(String userName) {
173         _userName = userName;
174     }
175 
176     public Date getCreateDate() {
177         return _createDate;
178     }
179 
180     public void setCreateDate(Date createDate) {
181         _createDate = createDate;
182     }
183 
184     public long getEntryId1() {
185         return _entryId1;
186     }
187 
188     public void setEntryId1(long entryId1) {
189         _entryId1 = entryId1;
190     }
191 
192     public long getEntryId2() {
193         return _entryId2;
194     }
195 
196     public void setEntryId2(long entryId2) {
197         _entryId2 = entryId2;
198     }
199 
200     public int getType() {
201         return _type;
202     }
203 
204     public void setType(int type) {
205         _type = type;
206     }
207 
208     public int getWeight() {
209         return _weight;
210     }
211 
212     public void setWeight(int weight) {
213         _weight = weight;
214     }
215 
216     public AssetLink toEscapedModel() {
217         if (isEscapedModel()) {
218             return (AssetLink)this;
219         }
220         else {
221             return (AssetLink)Proxy.newProxyInstance(AssetLink.class.getClassLoader(),
222                 new Class[] { AssetLink.class }, new AutoEscapeBeanHandler(this));
223         }
224     }
225 
226     public ExpandoBridge getExpandoBridge() {
227         if (_expandoBridge == null) {
228             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
229                     AssetLink.class.getName(), getPrimaryKey());
230         }
231 
232         return _expandoBridge;
233     }
234 
235     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
236         getExpandoBridge().setAttributes(serviceContext);
237     }
238 
239     public Object clone() {
240         AssetLinkImpl clone = new AssetLinkImpl();
241 
242         clone.setLinkId(getLinkId());
243         clone.setCompanyId(getCompanyId());
244         clone.setUserId(getUserId());
245         clone.setUserName(getUserName());
246         clone.setCreateDate(getCreateDate());
247         clone.setEntryId1(getEntryId1());
248         clone.setEntryId2(getEntryId2());
249         clone.setType(getType());
250         clone.setWeight(getWeight());
251 
252         return clone;
253     }
254 
255     public int compareTo(AssetLink assetLink) {
256         int value = 0;
257 
258         if (getWeight() < assetLink.getWeight()) {
259             value = -1;
260         }
261         else if (getWeight() > assetLink.getWeight()) {
262             value = 1;
263         }
264         else {
265             value = 0;
266         }
267 
268         if (value != 0) {
269             return value;
270         }
271 
272         return 0;
273     }
274 
275     public boolean equals(Object obj) {
276         if (obj == null) {
277             return false;
278         }
279 
280         AssetLink assetLink = null;
281 
282         try {
283             assetLink = (AssetLink)obj;
284         }
285         catch (ClassCastException cce) {
286             return false;
287         }
288 
289         long pk = assetLink.getPrimaryKey();
290 
291         if (getPrimaryKey() == pk) {
292             return true;
293         }
294         else {
295             return false;
296         }
297     }
298 
299     public int hashCode() {
300         return (int)getPrimaryKey();
301     }
302 
303     public String toString() {
304         StringBundler sb = new StringBundler(19);
305 
306         sb.append("{linkId=");
307         sb.append(getLinkId());
308         sb.append(", companyId=");
309         sb.append(getCompanyId());
310         sb.append(", userId=");
311         sb.append(getUserId());
312         sb.append(", userName=");
313         sb.append(getUserName());
314         sb.append(", createDate=");
315         sb.append(getCreateDate());
316         sb.append(", entryId1=");
317         sb.append(getEntryId1());
318         sb.append(", entryId2=");
319         sb.append(getEntryId2());
320         sb.append(", type=");
321         sb.append(getType());
322         sb.append(", weight=");
323         sb.append(getWeight());
324         sb.append("}");
325 
326         return sb.toString();
327     }
328 
329     public String toXmlString() {
330         StringBundler sb = new StringBundler(31);
331 
332         sb.append("<model><model-name>");
333         sb.append("com.liferay.portlet.asset.model.AssetLink");
334         sb.append("</model-name>");
335 
336         sb.append(
337             "<column><column-name>linkId</column-name><column-value><![CDATA[");
338         sb.append(getLinkId());
339         sb.append("]]></column-value></column>");
340         sb.append(
341             "<column><column-name>companyId</column-name><column-value><![CDATA[");
342         sb.append(getCompanyId());
343         sb.append("]]></column-value></column>");
344         sb.append(
345             "<column><column-name>userId</column-name><column-value><![CDATA[");
346         sb.append(getUserId());
347         sb.append("]]></column-value></column>");
348         sb.append(
349             "<column><column-name>userName</column-name><column-value><![CDATA[");
350         sb.append(getUserName());
351         sb.append("]]></column-value></column>");
352         sb.append(
353             "<column><column-name>createDate</column-name><column-value><![CDATA[");
354         sb.append(getCreateDate());
355         sb.append("]]></column-value></column>");
356         sb.append(
357             "<column><column-name>entryId1</column-name><column-value><![CDATA[");
358         sb.append(getEntryId1());
359         sb.append("]]></column-value></column>");
360         sb.append(
361             "<column><column-name>entryId2</column-name><column-value><![CDATA[");
362         sb.append(getEntryId2());
363         sb.append("]]></column-value></column>");
364         sb.append(
365             "<column><column-name>type</column-name><column-value><![CDATA[");
366         sb.append(getType());
367         sb.append("]]></column-value></column>");
368         sb.append(
369             "<column><column-name>weight</column-name><column-value><![CDATA[");
370         sb.append(getWeight());
371         sb.append("]]></column-value></column>");
372 
373         sb.append("</model>");
374 
375         return sb.toString();
376     }
377 
378     private long _linkId;
379     private long _companyId;
380     private long _userId;
381     private String _userUuid;
382     private String _userName;
383     private Date _createDate;
384     private long _entryId1;
385     private long _entryId2;
386     private int _type;
387     private int _weight;
388     private transient ExpandoBridge _expandoBridge;
389 }