001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.dynamicdatamapping.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.ProxyUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.kernel.util.Validator;
023    import com.liferay.portal.model.CacheModel;
024    import com.liferay.portal.model.impl.BaseModelImpl;
025    import com.liferay.portal.service.ServiceContext;
026    import com.liferay.portal.util.PortalUtil;
027    
028    import com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink;
029    import com.liferay.portlet.dynamicdatamapping.model.DDMStorageLinkModel;
030    import com.liferay.portlet.expando.model.ExpandoBridge;
031    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
032    
033    import java.io.Serializable;
034    
035    import java.sql.Types;
036    
037    import java.util.HashMap;
038    import java.util.Map;
039    
040    /**
041     * The base model implementation for the DDMStorageLink service. Represents a row in the "DDMStorageLink" database table, with each column mapped to a property of this class.
042     *
043     * <p>
044     * This implementation and its corresponding interface {@link com.liferay.portlet.dynamicdatamapping.model.DDMStorageLinkModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DDMStorageLinkImpl}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see DDMStorageLinkImpl
049     * @see com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink
050     * @see com.liferay.portlet.dynamicdatamapping.model.DDMStorageLinkModel
051     * @generated
052     */
053    public class DDMStorageLinkModelImpl extends BaseModelImpl<DDMStorageLink>
054            implements DDMStorageLinkModel {
055            /*
056             * NOTE FOR DEVELOPERS:
057             *
058             * Never modify or reference this class directly. All methods that expect a d d m storage link model instance should use the {@link com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink} interface instead.
059             */
060            public static final String TABLE_NAME = "DDMStorageLink";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "uuid_", Types.VARCHAR },
063                            { "storageLinkId", Types.BIGINT },
064                            { "classNameId", Types.BIGINT },
065                            { "classPK", Types.BIGINT },
066                            { "structureId", Types.BIGINT }
067                    };
068            public static final String TABLE_SQL_CREATE = "create table DDMStorageLink (uuid_ VARCHAR(75) null,storageLinkId LONG not null primary key,classNameId LONG,classPK LONG,structureId LONG)";
069            public static final String TABLE_SQL_DROP = "drop table DDMStorageLink";
070            public static final String DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink"),
078                            true);
079            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.column.bitmask.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink"),
081                            true);
082            public static long CLASSPK_COLUMN_BITMASK = 1L;
083            public static long STRUCTUREID_COLUMN_BITMASK = 2L;
084            public static long UUID_COLUMN_BITMASK = 4L;
085            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
086                                    "lock.expiration.time.com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink"));
087    
088            public DDMStorageLinkModelImpl() {
089            }
090    
091            public long getPrimaryKey() {
092                    return _storageLinkId;
093            }
094    
095            public void setPrimaryKey(long primaryKey) {
096                    setStorageLinkId(primaryKey);
097            }
098    
099            public Serializable getPrimaryKeyObj() {
100                    return new Long(_storageLinkId);
101            }
102    
103            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
104                    setPrimaryKey(((Long)primaryKeyObj).longValue());
105            }
106    
107            public Class<?> getModelClass() {
108                    return DDMStorageLink.class;
109            }
110    
111            public String getModelClassName() {
112                    return DDMStorageLink.class.getName();
113            }
114    
115            @Override
116            public Map<String, Object> getModelAttributes() {
117                    Map<String, Object> attributes = new HashMap<String, Object>();
118    
119                    attributes.put("uuid", getUuid());
120                    attributes.put("storageLinkId", getStorageLinkId());
121                    attributes.put("classNameId", getClassNameId());
122                    attributes.put("classPK", getClassPK());
123                    attributes.put("structureId", getStructureId());
124    
125                    return attributes;
126            }
127    
128            @Override
129            public void setModelAttributes(Map<String, Object> attributes) {
130                    String uuid = (String)attributes.get("uuid");
131    
132                    if (uuid != null) {
133                            setUuid(uuid);
134                    }
135    
136                    Long storageLinkId = (Long)attributes.get("storageLinkId");
137    
138                    if (storageLinkId != null) {
139                            setStorageLinkId(storageLinkId);
140                    }
141    
142                    Long classNameId = (Long)attributes.get("classNameId");
143    
144                    if (classNameId != null) {
145                            setClassNameId(classNameId);
146                    }
147    
148                    Long classPK = (Long)attributes.get("classPK");
149    
150                    if (classPK != null) {
151                            setClassPK(classPK);
152                    }
153    
154                    Long structureId = (Long)attributes.get("structureId");
155    
156                    if (structureId != null) {
157                            setStructureId(structureId);
158                    }
159            }
160    
161            public String getUuid() {
162                    if (_uuid == null) {
163                            return StringPool.BLANK;
164                    }
165                    else {
166                            return _uuid;
167                    }
168            }
169    
170            public void setUuid(String uuid) {
171                    if (_originalUuid == null) {
172                            _originalUuid = _uuid;
173                    }
174    
175                    _uuid = uuid;
176            }
177    
178            public String getOriginalUuid() {
179                    return GetterUtil.getString(_originalUuid);
180            }
181    
182            public long getStorageLinkId() {
183                    return _storageLinkId;
184            }
185    
186            public void setStorageLinkId(long storageLinkId) {
187                    _storageLinkId = storageLinkId;
188            }
189    
190            public String getClassName() {
191                    if (getClassNameId() <= 0) {
192                            return StringPool.BLANK;
193                    }
194    
195                    return PortalUtil.getClassName(getClassNameId());
196            }
197    
198            public void setClassName(String className) {
199                    long classNameId = 0;
200    
201                    if (Validator.isNotNull(className)) {
202                            classNameId = PortalUtil.getClassNameId(className);
203                    }
204    
205                    setClassNameId(classNameId);
206            }
207    
208            public long getClassNameId() {
209                    return _classNameId;
210            }
211    
212            public void setClassNameId(long classNameId) {
213                    _classNameId = classNameId;
214            }
215    
216            public long getClassPK() {
217                    return _classPK;
218            }
219    
220            public void setClassPK(long classPK) {
221                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
222    
223                    if (!_setOriginalClassPK) {
224                            _setOriginalClassPK = true;
225    
226                            _originalClassPK = _classPK;
227                    }
228    
229                    _classPK = classPK;
230            }
231    
232            public long getOriginalClassPK() {
233                    return _originalClassPK;
234            }
235    
236            public long getStructureId() {
237                    return _structureId;
238            }
239    
240            public void setStructureId(long structureId) {
241                    _columnBitmask |= STRUCTUREID_COLUMN_BITMASK;
242    
243                    if (!_setOriginalStructureId) {
244                            _setOriginalStructureId = true;
245    
246                            _originalStructureId = _structureId;
247                    }
248    
249                    _structureId = structureId;
250            }
251    
252            public long getOriginalStructureId() {
253                    return _originalStructureId;
254            }
255    
256            public long getColumnBitmask() {
257                    return _columnBitmask;
258            }
259    
260            @Override
261            public ExpandoBridge getExpandoBridge() {
262                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
263                            DDMStorageLink.class.getName(), getPrimaryKey());
264            }
265    
266            @Override
267            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
268                    ExpandoBridge expandoBridge = getExpandoBridge();
269    
270                    expandoBridge.setAttributes(serviceContext);
271            }
272    
273            @Override
274            public DDMStorageLink toEscapedModel() {
275                    if (_escapedModel == null) {
276                            _escapedModel = (DDMStorageLink)ProxyUtil.newProxyInstance(_classLoader,
277                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
278                    }
279    
280                    return _escapedModel;
281            }
282    
283            public DDMStorageLink toUnescapedModel() {
284                    return (DDMStorageLink)this;
285            }
286    
287            @Override
288            public Object clone() {
289                    DDMStorageLinkImpl ddmStorageLinkImpl = new DDMStorageLinkImpl();
290    
291                    ddmStorageLinkImpl.setUuid(getUuid());
292                    ddmStorageLinkImpl.setStorageLinkId(getStorageLinkId());
293                    ddmStorageLinkImpl.setClassNameId(getClassNameId());
294                    ddmStorageLinkImpl.setClassPK(getClassPK());
295                    ddmStorageLinkImpl.setStructureId(getStructureId());
296    
297                    ddmStorageLinkImpl.resetOriginalValues();
298    
299                    return ddmStorageLinkImpl;
300            }
301    
302            public int compareTo(DDMStorageLink ddmStorageLink) {
303                    long primaryKey = ddmStorageLink.getPrimaryKey();
304    
305                    if (getPrimaryKey() < primaryKey) {
306                            return -1;
307                    }
308                    else if (getPrimaryKey() > primaryKey) {
309                            return 1;
310                    }
311                    else {
312                            return 0;
313                    }
314            }
315    
316            @Override
317            public boolean equals(Object obj) {
318                    if (this == obj) {
319                            return true;
320                    }
321    
322                    if (!(obj instanceof DDMStorageLink)) {
323                            return false;
324                    }
325    
326                    DDMStorageLink ddmStorageLink = (DDMStorageLink)obj;
327    
328                    long primaryKey = ddmStorageLink.getPrimaryKey();
329    
330                    if (getPrimaryKey() == primaryKey) {
331                            return true;
332                    }
333                    else {
334                            return false;
335                    }
336            }
337    
338            @Override
339            public int hashCode() {
340                    return (int)getPrimaryKey();
341            }
342    
343            @Override
344            public void resetOriginalValues() {
345                    DDMStorageLinkModelImpl ddmStorageLinkModelImpl = this;
346    
347                    ddmStorageLinkModelImpl._originalUuid = ddmStorageLinkModelImpl._uuid;
348    
349                    ddmStorageLinkModelImpl._originalClassPK = ddmStorageLinkModelImpl._classPK;
350    
351                    ddmStorageLinkModelImpl._setOriginalClassPK = false;
352    
353                    ddmStorageLinkModelImpl._originalStructureId = ddmStorageLinkModelImpl._structureId;
354    
355                    ddmStorageLinkModelImpl._setOriginalStructureId = false;
356    
357                    ddmStorageLinkModelImpl._columnBitmask = 0;
358            }
359    
360            @Override
361            public CacheModel<DDMStorageLink> toCacheModel() {
362                    DDMStorageLinkCacheModel ddmStorageLinkCacheModel = new DDMStorageLinkCacheModel();
363    
364                    ddmStorageLinkCacheModel.uuid = getUuid();
365    
366                    String uuid = ddmStorageLinkCacheModel.uuid;
367    
368                    if ((uuid != null) && (uuid.length() == 0)) {
369                            ddmStorageLinkCacheModel.uuid = null;
370                    }
371    
372                    ddmStorageLinkCacheModel.storageLinkId = getStorageLinkId();
373    
374                    ddmStorageLinkCacheModel.classNameId = getClassNameId();
375    
376                    ddmStorageLinkCacheModel.classPK = getClassPK();
377    
378                    ddmStorageLinkCacheModel.structureId = getStructureId();
379    
380                    return ddmStorageLinkCacheModel;
381            }
382    
383            @Override
384            public String toString() {
385                    StringBundler sb = new StringBundler(11);
386    
387                    sb.append("{uuid=");
388                    sb.append(getUuid());
389                    sb.append(", storageLinkId=");
390                    sb.append(getStorageLinkId());
391                    sb.append(", classNameId=");
392                    sb.append(getClassNameId());
393                    sb.append(", classPK=");
394                    sb.append(getClassPK());
395                    sb.append(", structureId=");
396                    sb.append(getStructureId());
397                    sb.append("}");
398    
399                    return sb.toString();
400            }
401    
402            public String toXmlString() {
403                    StringBundler sb = new StringBundler(19);
404    
405                    sb.append("<model><model-name>");
406                    sb.append("com.liferay.portlet.dynamicdatamapping.model.DDMStorageLink");
407                    sb.append("</model-name>");
408    
409                    sb.append(
410                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
411                    sb.append(getUuid());
412                    sb.append("]]></column-value></column>");
413                    sb.append(
414                            "<column><column-name>storageLinkId</column-name><column-value><![CDATA[");
415                    sb.append(getStorageLinkId());
416                    sb.append("]]></column-value></column>");
417                    sb.append(
418                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
419                    sb.append(getClassNameId());
420                    sb.append("]]></column-value></column>");
421                    sb.append(
422                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
423                    sb.append(getClassPK());
424                    sb.append("]]></column-value></column>");
425                    sb.append(
426                            "<column><column-name>structureId</column-name><column-value><![CDATA[");
427                    sb.append(getStructureId());
428                    sb.append("]]></column-value></column>");
429    
430                    sb.append("</model>");
431    
432                    return sb.toString();
433            }
434    
435            private static ClassLoader _classLoader = DDMStorageLink.class.getClassLoader();
436            private static Class<?>[] _escapedModelInterfaces = new Class[] {
437                            DDMStorageLink.class
438                    };
439            private String _uuid;
440            private String _originalUuid;
441            private long _storageLinkId;
442            private long _classNameId;
443            private long _classPK;
444            private long _originalClassPK;
445            private boolean _setOriginalClassPK;
446            private long _structureId;
447            private long _originalStructureId;
448            private boolean _setOriginalStructureId;
449            private long _columnBitmask;
450            private DDMStorageLink _escapedModel;
451    }