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.DDMStructureLink;
029    import com.liferay.portlet.dynamicdatamapping.model.DDMStructureLinkModel;
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 DDMStructureLink service. Represents a row in the "DDMStructureLink" 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.DDMStructureLinkModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DDMStructureLinkImpl}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see DDMStructureLinkImpl
049     * @see com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink
050     * @see com.liferay.portlet.dynamicdatamapping.model.DDMStructureLinkModel
051     * @generated
052     */
053    public class DDMStructureLinkModelImpl extends BaseModelImpl<DDMStructureLink>
054            implements DDMStructureLinkModel {
055            /*
056             * NOTE FOR DEVELOPERS:
057             *
058             * Never modify or reference this class directly. All methods that expect a d d m structure link model instance should use the {@link com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink} interface instead.
059             */
060            public static final String TABLE_NAME = "DDMStructureLink";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "structureLinkId", Types.BIGINT },
063                            { "classNameId", Types.BIGINT },
064                            { "classPK", Types.BIGINT },
065                            { "structureId", Types.BIGINT }
066                    };
067            public static final String TABLE_SQL_CREATE = "create table DDMStructureLink (structureLinkId LONG not null primary key,classNameId LONG,classPK LONG,structureId LONG)";
068            public static final String TABLE_SQL_DROP = "drop table DDMStructureLink";
069            public static final String DATA_SOURCE = "liferayDataSource";
070            public static final String SESSION_FACTORY = "liferaySessionFactory";
071            public static final String TX_MANAGER = "liferayTransactionManager";
072            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.entity.cache.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink"),
074                            true);
075            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.finder.cache.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink"),
077                            true);
078            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.column.bitmask.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink"),
080                            true);
081            public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
082            public static long CLASSPK_COLUMN_BITMASK = 2L;
083            public static long STRUCTUREID_COLUMN_BITMASK = 4L;
084            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
085                                    "lock.expiration.time.com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink"));
086    
087            public DDMStructureLinkModelImpl() {
088            }
089    
090            public long getPrimaryKey() {
091                    return _structureLinkId;
092            }
093    
094            public void setPrimaryKey(long primaryKey) {
095                    setStructureLinkId(primaryKey);
096            }
097    
098            public Serializable getPrimaryKeyObj() {
099                    return new Long(_structureLinkId);
100            }
101    
102            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
103                    setPrimaryKey(((Long)primaryKeyObj).longValue());
104            }
105    
106            public Class<?> getModelClass() {
107                    return DDMStructureLink.class;
108            }
109    
110            public String getModelClassName() {
111                    return DDMStructureLink.class.getName();
112            }
113    
114            @Override
115            public Map<String, Object> getModelAttributes() {
116                    Map<String, Object> attributes = new HashMap<String, Object>();
117    
118                    attributes.put("structureLinkId", getStructureLinkId());
119                    attributes.put("classNameId", getClassNameId());
120                    attributes.put("classPK", getClassPK());
121                    attributes.put("structureId", getStructureId());
122    
123                    return attributes;
124            }
125    
126            @Override
127            public void setModelAttributes(Map<String, Object> attributes) {
128                    Long structureLinkId = (Long)attributes.get("structureLinkId");
129    
130                    if (structureLinkId != null) {
131                            setStructureLinkId(structureLinkId);
132                    }
133    
134                    Long classNameId = (Long)attributes.get("classNameId");
135    
136                    if (classNameId != null) {
137                            setClassNameId(classNameId);
138                    }
139    
140                    Long classPK = (Long)attributes.get("classPK");
141    
142                    if (classPK != null) {
143                            setClassPK(classPK);
144                    }
145    
146                    Long structureId = (Long)attributes.get("structureId");
147    
148                    if (structureId != null) {
149                            setStructureId(structureId);
150                    }
151            }
152    
153            public long getStructureLinkId() {
154                    return _structureLinkId;
155            }
156    
157            public void setStructureLinkId(long structureLinkId) {
158                    _structureLinkId = structureLinkId;
159            }
160    
161            public String getClassName() {
162                    if (getClassNameId() <= 0) {
163                            return StringPool.BLANK;
164                    }
165    
166                    return PortalUtil.getClassName(getClassNameId());
167            }
168    
169            public void setClassName(String className) {
170                    long classNameId = 0;
171    
172                    if (Validator.isNotNull(className)) {
173                            classNameId = PortalUtil.getClassNameId(className);
174                    }
175    
176                    setClassNameId(classNameId);
177            }
178    
179            public long getClassNameId() {
180                    return _classNameId;
181            }
182    
183            public void setClassNameId(long classNameId) {
184                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
185    
186                    if (!_setOriginalClassNameId) {
187                            _setOriginalClassNameId = true;
188    
189                            _originalClassNameId = _classNameId;
190                    }
191    
192                    _classNameId = classNameId;
193            }
194    
195            public long getOriginalClassNameId() {
196                    return _originalClassNameId;
197            }
198    
199            public long getClassPK() {
200                    return _classPK;
201            }
202    
203            public void setClassPK(long classPK) {
204                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
205    
206                    if (!_setOriginalClassPK) {
207                            _setOriginalClassPK = true;
208    
209                            _originalClassPK = _classPK;
210                    }
211    
212                    _classPK = classPK;
213            }
214    
215            public long getOriginalClassPK() {
216                    return _originalClassPK;
217            }
218    
219            public long getStructureId() {
220                    return _structureId;
221            }
222    
223            public void setStructureId(long structureId) {
224                    _columnBitmask |= STRUCTUREID_COLUMN_BITMASK;
225    
226                    if (!_setOriginalStructureId) {
227                            _setOriginalStructureId = true;
228    
229                            _originalStructureId = _structureId;
230                    }
231    
232                    _structureId = structureId;
233            }
234    
235            public long getOriginalStructureId() {
236                    return _originalStructureId;
237            }
238    
239            public long getColumnBitmask() {
240                    return _columnBitmask;
241            }
242    
243            @Override
244            public ExpandoBridge getExpandoBridge() {
245                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
246                            DDMStructureLink.class.getName(), getPrimaryKey());
247            }
248    
249            @Override
250            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
251                    ExpandoBridge expandoBridge = getExpandoBridge();
252    
253                    expandoBridge.setAttributes(serviceContext);
254            }
255    
256            @Override
257            public DDMStructureLink toEscapedModel() {
258                    if (_escapedModel == null) {
259                            _escapedModel = (DDMStructureLink)ProxyUtil.newProxyInstance(_classLoader,
260                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
261                    }
262    
263                    return _escapedModel;
264            }
265    
266            public DDMStructureLink toUnescapedModel() {
267                    return (DDMStructureLink)this;
268            }
269    
270            @Override
271            public Object clone() {
272                    DDMStructureLinkImpl ddmStructureLinkImpl = new DDMStructureLinkImpl();
273    
274                    ddmStructureLinkImpl.setStructureLinkId(getStructureLinkId());
275                    ddmStructureLinkImpl.setClassNameId(getClassNameId());
276                    ddmStructureLinkImpl.setClassPK(getClassPK());
277                    ddmStructureLinkImpl.setStructureId(getStructureId());
278    
279                    ddmStructureLinkImpl.resetOriginalValues();
280    
281                    return ddmStructureLinkImpl;
282            }
283    
284            public int compareTo(DDMStructureLink ddmStructureLink) {
285                    long primaryKey = ddmStructureLink.getPrimaryKey();
286    
287                    if (getPrimaryKey() < primaryKey) {
288                            return -1;
289                    }
290                    else if (getPrimaryKey() > primaryKey) {
291                            return 1;
292                    }
293                    else {
294                            return 0;
295                    }
296            }
297    
298            @Override
299            public boolean equals(Object obj) {
300                    if (this == obj) {
301                            return true;
302                    }
303    
304                    if (!(obj instanceof DDMStructureLink)) {
305                            return false;
306                    }
307    
308                    DDMStructureLink ddmStructureLink = (DDMStructureLink)obj;
309    
310                    long primaryKey = ddmStructureLink.getPrimaryKey();
311    
312                    if (getPrimaryKey() == primaryKey) {
313                            return true;
314                    }
315                    else {
316                            return false;
317                    }
318            }
319    
320            @Override
321            public int hashCode() {
322                    return (int)getPrimaryKey();
323            }
324    
325            @Override
326            public void resetOriginalValues() {
327                    DDMStructureLinkModelImpl ddmStructureLinkModelImpl = this;
328    
329                    ddmStructureLinkModelImpl._originalClassNameId = ddmStructureLinkModelImpl._classNameId;
330    
331                    ddmStructureLinkModelImpl._setOriginalClassNameId = false;
332    
333                    ddmStructureLinkModelImpl._originalClassPK = ddmStructureLinkModelImpl._classPK;
334    
335                    ddmStructureLinkModelImpl._setOriginalClassPK = false;
336    
337                    ddmStructureLinkModelImpl._originalStructureId = ddmStructureLinkModelImpl._structureId;
338    
339                    ddmStructureLinkModelImpl._setOriginalStructureId = false;
340    
341                    ddmStructureLinkModelImpl._columnBitmask = 0;
342            }
343    
344            @Override
345            public CacheModel<DDMStructureLink> toCacheModel() {
346                    DDMStructureLinkCacheModel ddmStructureLinkCacheModel = new DDMStructureLinkCacheModel();
347    
348                    ddmStructureLinkCacheModel.structureLinkId = getStructureLinkId();
349    
350                    ddmStructureLinkCacheModel.classNameId = getClassNameId();
351    
352                    ddmStructureLinkCacheModel.classPK = getClassPK();
353    
354                    ddmStructureLinkCacheModel.structureId = getStructureId();
355    
356                    return ddmStructureLinkCacheModel;
357            }
358    
359            @Override
360            public String toString() {
361                    StringBundler sb = new StringBundler(9);
362    
363                    sb.append("{structureLinkId=");
364                    sb.append(getStructureLinkId());
365                    sb.append(", classNameId=");
366                    sb.append(getClassNameId());
367                    sb.append(", classPK=");
368                    sb.append(getClassPK());
369                    sb.append(", structureId=");
370                    sb.append(getStructureId());
371                    sb.append("}");
372    
373                    return sb.toString();
374            }
375    
376            public String toXmlString() {
377                    StringBundler sb = new StringBundler(16);
378    
379                    sb.append("<model><model-name>");
380                    sb.append(
381                            "com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink");
382                    sb.append("</model-name>");
383    
384                    sb.append(
385                            "<column><column-name>structureLinkId</column-name><column-value><![CDATA[");
386                    sb.append(getStructureLinkId());
387                    sb.append("]]></column-value></column>");
388                    sb.append(
389                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
390                    sb.append(getClassNameId());
391                    sb.append("]]></column-value></column>");
392                    sb.append(
393                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
394                    sb.append(getClassPK());
395                    sb.append("]]></column-value></column>");
396                    sb.append(
397                            "<column><column-name>structureId</column-name><column-value><![CDATA[");
398                    sb.append(getStructureId());
399                    sb.append("]]></column-value></column>");
400    
401                    sb.append("</model>");
402    
403                    return sb.toString();
404            }
405    
406            private static ClassLoader _classLoader = DDMStructureLink.class.getClassLoader();
407            private static Class<?>[] _escapedModelInterfaces = new Class[] {
408                            DDMStructureLink.class
409                    };
410            private long _structureLinkId;
411            private long _classNameId;
412            private long _originalClassNameId;
413            private boolean _setOriginalClassNameId;
414            private long _classPK;
415            private long _originalClassPK;
416            private boolean _setOriginalClassPK;
417            private long _structureId;
418            private long _originalStructureId;
419            private boolean _setOriginalStructureId;
420            private long _columnBitmask;
421            private DDMStructureLink _escapedModel;
422    }