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.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.json.JSON;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.ProxyUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.model.CacheModel;
025    import com.liferay.portal.model.LayoutBranch;
026    import com.liferay.portal.model.LayoutBranchModel;
027    import com.liferay.portal.model.LayoutBranchSoap;
028    import com.liferay.portal.service.ServiceContext;
029    import com.liferay.portal.util.PortalUtil;
030    
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    
034    import java.io.Serializable;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.HashMap;
040    import java.util.List;
041    import java.util.Map;
042    
043    /**
044     * The base model implementation for the LayoutBranch service. Represents a row in the "LayoutBranch" database table, with each column mapped to a property of this class.
045     *
046     * <p>
047     * This implementation and its corresponding interface {@link com.liferay.portal.model.LayoutBranchModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link LayoutBranchImpl}.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see LayoutBranchImpl
052     * @see com.liferay.portal.model.LayoutBranch
053     * @see com.liferay.portal.model.LayoutBranchModel
054     * @generated
055     */
056    @JSON(strict = true)
057    public class LayoutBranchModelImpl extends BaseModelImpl<LayoutBranch>
058            implements LayoutBranchModel {
059            /*
060             * NOTE FOR DEVELOPERS:
061             *
062             * Never modify or reference this class directly. All methods that expect a layout branch model instance should use the {@link com.liferay.portal.model.LayoutBranch} interface instead.
063             */
064            public static final String TABLE_NAME = "LayoutBranch";
065            public static final Object[][] TABLE_COLUMNS = {
066                            { "LayoutBranchId", Types.BIGINT },
067                            { "groupId", Types.BIGINT },
068                            { "companyId", Types.BIGINT },
069                            { "userId", Types.BIGINT },
070                            { "userName", Types.VARCHAR },
071                            { "layoutSetBranchId", Types.BIGINT },
072                            { "plid", Types.BIGINT },
073                            { "name", Types.VARCHAR },
074                            { "description", Types.VARCHAR },
075                            { "master", Types.BOOLEAN }
076                    };
077            public static final String TABLE_SQL_CREATE = "create table LayoutBranch (LayoutBranchId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,layoutSetBranchId LONG,plid LONG,name VARCHAR(75) null,description STRING null,master BOOLEAN)";
078            public static final String TABLE_SQL_DROP = "drop table LayoutBranch";
079            public static final String ORDER_BY_JPQL = " ORDER BY layoutBranch.LayoutBranchId ASC";
080            public static final String ORDER_BY_SQL = " ORDER BY LayoutBranch.LayoutBranchId ASC";
081            public static final String DATA_SOURCE = "liferayDataSource";
082            public static final String SESSION_FACTORY = "liferaySessionFactory";
083            public static final String TX_MANAGER = "liferayTransactionManager";
084            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085                                    "value.object.entity.cache.enabled.com.liferay.portal.model.LayoutBranch"),
086                            true);
087            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
088                                    "value.object.finder.cache.enabled.com.liferay.portal.model.LayoutBranch"),
089                            true);
090            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
091                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.LayoutBranch"),
092                            true);
093            public static long LAYOUTSETBRANCHID_COLUMN_BITMASK = 1L;
094            public static long MASTER_COLUMN_BITMASK = 2L;
095            public static long NAME_COLUMN_BITMASK = 4L;
096            public static long PLID_COLUMN_BITMASK = 8L;
097            public static long LAYOUTBRANCHID_COLUMN_BITMASK = 16L;
098    
099            /**
100             * Converts the soap model instance into a normal model instance.
101             *
102             * @param soapModel the soap model instance to convert
103             * @return the normal model instance
104             */
105            public static LayoutBranch toModel(LayoutBranchSoap soapModel) {
106                    if (soapModel == null) {
107                            return null;
108                    }
109    
110                    LayoutBranch model = new LayoutBranchImpl();
111    
112                    model.setLayoutBranchId(soapModel.getLayoutBranchId());
113                    model.setGroupId(soapModel.getGroupId());
114                    model.setCompanyId(soapModel.getCompanyId());
115                    model.setUserId(soapModel.getUserId());
116                    model.setUserName(soapModel.getUserName());
117                    model.setLayoutSetBranchId(soapModel.getLayoutSetBranchId());
118                    model.setPlid(soapModel.getPlid());
119                    model.setName(soapModel.getName());
120                    model.setDescription(soapModel.getDescription());
121                    model.setMaster(soapModel.getMaster());
122    
123                    return model;
124            }
125    
126            /**
127             * Converts the soap model instances into normal model instances.
128             *
129             * @param soapModels the soap model instances to convert
130             * @return the normal model instances
131             */
132            public static List<LayoutBranch> toModels(LayoutBranchSoap[] soapModels) {
133                    if (soapModels == null) {
134                            return null;
135                    }
136    
137                    List<LayoutBranch> models = new ArrayList<LayoutBranch>(soapModels.length);
138    
139                    for (LayoutBranchSoap soapModel : soapModels) {
140                            models.add(toModel(soapModel));
141                    }
142    
143                    return models;
144            }
145    
146            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
147                                    "lock.expiration.time.com.liferay.portal.model.LayoutBranch"));
148    
149            public LayoutBranchModelImpl() {
150            }
151    
152            @Override
153            public long getPrimaryKey() {
154                    return _LayoutBranchId;
155            }
156    
157            @Override
158            public void setPrimaryKey(long primaryKey) {
159                    setLayoutBranchId(primaryKey);
160            }
161    
162            @Override
163            public Serializable getPrimaryKeyObj() {
164                    return _LayoutBranchId;
165            }
166    
167            @Override
168            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
169                    setPrimaryKey(((Long)primaryKeyObj).longValue());
170            }
171    
172            @Override
173            public Class<?> getModelClass() {
174                    return LayoutBranch.class;
175            }
176    
177            @Override
178            public String getModelClassName() {
179                    return LayoutBranch.class.getName();
180            }
181    
182            @Override
183            public Map<String, Object> getModelAttributes() {
184                    Map<String, Object> attributes = new HashMap<String, Object>();
185    
186                    attributes.put("LayoutBranchId", getLayoutBranchId());
187                    attributes.put("groupId", getGroupId());
188                    attributes.put("companyId", getCompanyId());
189                    attributes.put("userId", getUserId());
190                    attributes.put("userName", getUserName());
191                    attributes.put("layoutSetBranchId", getLayoutSetBranchId());
192                    attributes.put("plid", getPlid());
193                    attributes.put("name", getName());
194                    attributes.put("description", getDescription());
195                    attributes.put("master", getMaster());
196    
197                    return attributes;
198            }
199    
200            @Override
201            public void setModelAttributes(Map<String, Object> attributes) {
202                    Long LayoutBranchId = (Long)attributes.get("LayoutBranchId");
203    
204                    if (LayoutBranchId != null) {
205                            setLayoutBranchId(LayoutBranchId);
206                    }
207    
208                    Long groupId = (Long)attributes.get("groupId");
209    
210                    if (groupId != null) {
211                            setGroupId(groupId);
212                    }
213    
214                    Long companyId = (Long)attributes.get("companyId");
215    
216                    if (companyId != null) {
217                            setCompanyId(companyId);
218                    }
219    
220                    Long userId = (Long)attributes.get("userId");
221    
222                    if (userId != null) {
223                            setUserId(userId);
224                    }
225    
226                    String userName = (String)attributes.get("userName");
227    
228                    if (userName != null) {
229                            setUserName(userName);
230                    }
231    
232                    Long layoutSetBranchId = (Long)attributes.get("layoutSetBranchId");
233    
234                    if (layoutSetBranchId != null) {
235                            setLayoutSetBranchId(layoutSetBranchId);
236                    }
237    
238                    Long plid = (Long)attributes.get("plid");
239    
240                    if (plid != null) {
241                            setPlid(plid);
242                    }
243    
244                    String name = (String)attributes.get("name");
245    
246                    if (name != null) {
247                            setName(name);
248                    }
249    
250                    String description = (String)attributes.get("description");
251    
252                    if (description != null) {
253                            setDescription(description);
254                    }
255    
256                    Boolean master = (Boolean)attributes.get("master");
257    
258                    if (master != null) {
259                            setMaster(master);
260                    }
261            }
262    
263            @JSON
264            @Override
265            public long getLayoutBranchId() {
266                    return _LayoutBranchId;
267            }
268    
269            @Override
270            public void setLayoutBranchId(long LayoutBranchId) {
271                    _LayoutBranchId = LayoutBranchId;
272            }
273    
274            @JSON
275            @Override
276            public long getGroupId() {
277                    return _groupId;
278            }
279    
280            @Override
281            public void setGroupId(long groupId) {
282                    _groupId = groupId;
283            }
284    
285            @JSON
286            @Override
287            public long getCompanyId() {
288                    return _companyId;
289            }
290    
291            @Override
292            public void setCompanyId(long companyId) {
293                    _companyId = companyId;
294            }
295    
296            @JSON
297            @Override
298            public long getUserId() {
299                    return _userId;
300            }
301    
302            @Override
303            public void setUserId(long userId) {
304                    _userId = userId;
305            }
306    
307            @Override
308            public String getUserUuid() throws SystemException {
309                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
310            }
311    
312            @Override
313            public void setUserUuid(String userUuid) {
314                    _userUuid = userUuid;
315            }
316    
317            @JSON
318            @Override
319            public String getUserName() {
320                    if (_userName == null) {
321                            return StringPool.BLANK;
322                    }
323                    else {
324                            return _userName;
325                    }
326            }
327    
328            @Override
329            public void setUserName(String userName) {
330                    _userName = userName;
331            }
332    
333            @JSON
334            @Override
335            public long getLayoutSetBranchId() {
336                    return _layoutSetBranchId;
337            }
338    
339            @Override
340            public void setLayoutSetBranchId(long layoutSetBranchId) {
341                    _columnBitmask |= LAYOUTSETBRANCHID_COLUMN_BITMASK;
342    
343                    if (!_setOriginalLayoutSetBranchId) {
344                            _setOriginalLayoutSetBranchId = true;
345    
346                            _originalLayoutSetBranchId = _layoutSetBranchId;
347                    }
348    
349                    _layoutSetBranchId = layoutSetBranchId;
350            }
351    
352            public long getOriginalLayoutSetBranchId() {
353                    return _originalLayoutSetBranchId;
354            }
355    
356            @JSON
357            @Override
358            public long getPlid() {
359                    return _plid;
360            }
361    
362            @Override
363            public void setPlid(long plid) {
364                    _columnBitmask |= PLID_COLUMN_BITMASK;
365    
366                    if (!_setOriginalPlid) {
367                            _setOriginalPlid = true;
368    
369                            _originalPlid = _plid;
370                    }
371    
372                    _plid = plid;
373            }
374    
375            public long getOriginalPlid() {
376                    return _originalPlid;
377            }
378    
379            @JSON
380            @Override
381            public String getName() {
382                    if (_name == null) {
383                            return StringPool.BLANK;
384                    }
385                    else {
386                            return _name;
387                    }
388            }
389    
390            @Override
391            public void setName(String name) {
392                    _columnBitmask |= NAME_COLUMN_BITMASK;
393    
394                    if (_originalName == null) {
395                            _originalName = _name;
396                    }
397    
398                    _name = name;
399            }
400    
401            public String getOriginalName() {
402                    return GetterUtil.getString(_originalName);
403            }
404    
405            @JSON
406            @Override
407            public String getDescription() {
408                    if (_description == null) {
409                            return StringPool.BLANK;
410                    }
411                    else {
412                            return _description;
413                    }
414            }
415    
416            @Override
417            public void setDescription(String description) {
418                    _description = description;
419            }
420    
421            @JSON
422            @Override
423            public boolean getMaster() {
424                    return _master;
425            }
426    
427            @Override
428            public boolean isMaster() {
429                    return _master;
430            }
431    
432            @Override
433            public void setMaster(boolean master) {
434                    _columnBitmask |= MASTER_COLUMN_BITMASK;
435    
436                    if (!_setOriginalMaster) {
437                            _setOriginalMaster = true;
438    
439                            _originalMaster = _master;
440                    }
441    
442                    _master = master;
443            }
444    
445            public boolean getOriginalMaster() {
446                    return _originalMaster;
447            }
448    
449            public long getColumnBitmask() {
450                    return _columnBitmask;
451            }
452    
453            @Override
454            public ExpandoBridge getExpandoBridge() {
455                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
456                            LayoutBranch.class.getName(), getPrimaryKey());
457            }
458    
459            @Override
460            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
461                    ExpandoBridge expandoBridge = getExpandoBridge();
462    
463                    expandoBridge.setAttributes(serviceContext);
464            }
465    
466            @Override
467            public LayoutBranch toEscapedModel() {
468                    if (_escapedModel == null) {
469                            _escapedModel = (LayoutBranch)ProxyUtil.newProxyInstance(_classLoader,
470                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
471                    }
472    
473                    return _escapedModel;
474            }
475    
476            @Override
477            public Object clone() {
478                    LayoutBranchImpl layoutBranchImpl = new LayoutBranchImpl();
479    
480                    layoutBranchImpl.setLayoutBranchId(getLayoutBranchId());
481                    layoutBranchImpl.setGroupId(getGroupId());
482                    layoutBranchImpl.setCompanyId(getCompanyId());
483                    layoutBranchImpl.setUserId(getUserId());
484                    layoutBranchImpl.setUserName(getUserName());
485                    layoutBranchImpl.setLayoutSetBranchId(getLayoutSetBranchId());
486                    layoutBranchImpl.setPlid(getPlid());
487                    layoutBranchImpl.setName(getName());
488                    layoutBranchImpl.setDescription(getDescription());
489                    layoutBranchImpl.setMaster(getMaster());
490    
491                    layoutBranchImpl.resetOriginalValues();
492    
493                    return layoutBranchImpl;
494            }
495    
496            @Override
497            public int compareTo(LayoutBranch layoutBranch) {
498                    long primaryKey = layoutBranch.getPrimaryKey();
499    
500                    if (getPrimaryKey() < primaryKey) {
501                            return -1;
502                    }
503                    else if (getPrimaryKey() > primaryKey) {
504                            return 1;
505                    }
506                    else {
507                            return 0;
508                    }
509            }
510    
511            @Override
512            public boolean equals(Object obj) {
513                    if (this == obj) {
514                            return true;
515                    }
516    
517                    if (!(obj instanceof LayoutBranch)) {
518                            return false;
519                    }
520    
521                    LayoutBranch layoutBranch = (LayoutBranch)obj;
522    
523                    long primaryKey = layoutBranch.getPrimaryKey();
524    
525                    if (getPrimaryKey() == primaryKey) {
526                            return true;
527                    }
528                    else {
529                            return false;
530                    }
531            }
532    
533            @Override
534            public int hashCode() {
535                    return (int)getPrimaryKey();
536            }
537    
538            @Override
539            public void resetOriginalValues() {
540                    LayoutBranchModelImpl layoutBranchModelImpl = this;
541    
542                    layoutBranchModelImpl._originalLayoutSetBranchId = layoutBranchModelImpl._layoutSetBranchId;
543    
544                    layoutBranchModelImpl._setOriginalLayoutSetBranchId = false;
545    
546                    layoutBranchModelImpl._originalPlid = layoutBranchModelImpl._plid;
547    
548                    layoutBranchModelImpl._setOriginalPlid = false;
549    
550                    layoutBranchModelImpl._originalName = layoutBranchModelImpl._name;
551    
552                    layoutBranchModelImpl._originalMaster = layoutBranchModelImpl._master;
553    
554                    layoutBranchModelImpl._setOriginalMaster = false;
555    
556                    layoutBranchModelImpl._columnBitmask = 0;
557            }
558    
559            @Override
560            public CacheModel<LayoutBranch> toCacheModel() {
561                    LayoutBranchCacheModel layoutBranchCacheModel = new LayoutBranchCacheModel();
562    
563                    layoutBranchCacheModel.LayoutBranchId = getLayoutBranchId();
564    
565                    layoutBranchCacheModel.groupId = getGroupId();
566    
567                    layoutBranchCacheModel.companyId = getCompanyId();
568    
569                    layoutBranchCacheModel.userId = getUserId();
570    
571                    layoutBranchCacheModel.userName = getUserName();
572    
573                    String userName = layoutBranchCacheModel.userName;
574    
575                    if ((userName != null) && (userName.length() == 0)) {
576                            layoutBranchCacheModel.userName = null;
577                    }
578    
579                    layoutBranchCacheModel.layoutSetBranchId = getLayoutSetBranchId();
580    
581                    layoutBranchCacheModel.plid = getPlid();
582    
583                    layoutBranchCacheModel.name = getName();
584    
585                    String name = layoutBranchCacheModel.name;
586    
587                    if ((name != null) && (name.length() == 0)) {
588                            layoutBranchCacheModel.name = null;
589                    }
590    
591                    layoutBranchCacheModel.description = getDescription();
592    
593                    String description = layoutBranchCacheModel.description;
594    
595                    if ((description != null) && (description.length() == 0)) {
596                            layoutBranchCacheModel.description = null;
597                    }
598    
599                    layoutBranchCacheModel.master = getMaster();
600    
601                    return layoutBranchCacheModel;
602            }
603    
604            @Override
605            public String toString() {
606                    StringBundler sb = new StringBundler(21);
607    
608                    sb.append("{LayoutBranchId=");
609                    sb.append(getLayoutBranchId());
610                    sb.append(", groupId=");
611                    sb.append(getGroupId());
612                    sb.append(", companyId=");
613                    sb.append(getCompanyId());
614                    sb.append(", userId=");
615                    sb.append(getUserId());
616                    sb.append(", userName=");
617                    sb.append(getUserName());
618                    sb.append(", layoutSetBranchId=");
619                    sb.append(getLayoutSetBranchId());
620                    sb.append(", plid=");
621                    sb.append(getPlid());
622                    sb.append(", name=");
623                    sb.append(getName());
624                    sb.append(", description=");
625                    sb.append(getDescription());
626                    sb.append(", master=");
627                    sb.append(getMaster());
628                    sb.append("}");
629    
630                    return sb.toString();
631            }
632    
633            @Override
634            public String toXmlString() {
635                    StringBundler sb = new StringBundler(34);
636    
637                    sb.append("<model><model-name>");
638                    sb.append("com.liferay.portal.model.LayoutBranch");
639                    sb.append("</model-name>");
640    
641                    sb.append(
642                            "<column><column-name>LayoutBranchId</column-name><column-value><![CDATA[");
643                    sb.append(getLayoutBranchId());
644                    sb.append("]]></column-value></column>");
645                    sb.append(
646                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
647                    sb.append(getGroupId());
648                    sb.append("]]></column-value></column>");
649                    sb.append(
650                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
651                    sb.append(getCompanyId());
652                    sb.append("]]></column-value></column>");
653                    sb.append(
654                            "<column><column-name>userId</column-name><column-value><![CDATA[");
655                    sb.append(getUserId());
656                    sb.append("]]></column-value></column>");
657                    sb.append(
658                            "<column><column-name>userName</column-name><column-value><![CDATA[");
659                    sb.append(getUserName());
660                    sb.append("]]></column-value></column>");
661                    sb.append(
662                            "<column><column-name>layoutSetBranchId</column-name><column-value><![CDATA[");
663                    sb.append(getLayoutSetBranchId());
664                    sb.append("]]></column-value></column>");
665                    sb.append(
666                            "<column><column-name>plid</column-name><column-value><![CDATA[");
667                    sb.append(getPlid());
668                    sb.append("]]></column-value></column>");
669                    sb.append(
670                            "<column><column-name>name</column-name><column-value><![CDATA[");
671                    sb.append(getName());
672                    sb.append("]]></column-value></column>");
673                    sb.append(
674                            "<column><column-name>description</column-name><column-value><![CDATA[");
675                    sb.append(getDescription());
676                    sb.append("]]></column-value></column>");
677                    sb.append(
678                            "<column><column-name>master</column-name><column-value><![CDATA[");
679                    sb.append(getMaster());
680                    sb.append("]]></column-value></column>");
681    
682                    sb.append("</model>");
683    
684                    return sb.toString();
685            }
686    
687            private static ClassLoader _classLoader = LayoutBranch.class.getClassLoader();
688            private static Class<?>[] _escapedModelInterfaces = new Class[] {
689                            LayoutBranch.class
690                    };
691            private long _LayoutBranchId;
692            private long _groupId;
693            private long _companyId;
694            private long _userId;
695            private String _userUuid;
696            private String _userName;
697            private long _layoutSetBranchId;
698            private long _originalLayoutSetBranchId;
699            private boolean _setOriginalLayoutSetBranchId;
700            private long _plid;
701            private long _originalPlid;
702            private boolean _setOriginalPlid;
703            private String _name;
704            private String _originalName;
705            private String _description;
706            private boolean _master;
707            private boolean _originalMaster;
708            private boolean _setOriginalMaster;
709            private long _columnBitmask;
710            private LayoutBranch _escapedModel;
711    }