com.bemis.portal.twofa.device.manager.model.impl.DeviceCodeModelImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.bemis.portal.twofa.device.manager.model.impl.DeviceCodeModelImpl.java

Source

/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.bemis.portal.twofa.device.manager.model.impl;

import aQute.bnd.annotation.ProviderType;

import com.bemis.portal.twofa.device.manager.model.DeviceCode;
import com.bemis.portal.twofa.device.manager.model.DeviceCodeModel;

import com.liferay.expando.kernel.model.ExpandoBridge;
import com.liferay.expando.kernel.util.ExpandoBridgeFactoryUtil;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.model.CacheModel;
import com.liferay.portal.kernel.model.User;
import com.liferay.portal.kernel.model.impl.BaseModelImpl;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.UserLocalServiceUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the DeviceCode service. Represents a row in the "Bemis_DeviceCode" database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link DeviceCodeModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DeviceCodeImpl}.
 * </p>
 *
 * @author Prathima Shreenath
 * @see DeviceCodeImpl
 * @see DeviceCode
 * @see DeviceCodeModel
 * @generated
 */
@ProviderType
public class DeviceCodeModelImpl extends BaseModelImpl<DeviceCode> implements DeviceCodeModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a device code model instance should use the {@link DeviceCode} interface instead.
     */
    public static final String TABLE_NAME = "Bemis_DeviceCode";
    public static final Object[][] TABLE_COLUMNS = { { "deviceCodeId", Types.BIGINT }, { "groupId", Types.BIGINT },
            { "companyId", Types.BIGINT }, { "userId", Types.BIGINT }, { "userName", Types.VARCHAR },
            { "createDate", Types.TIMESTAMP }, { "modifiedDate", Types.TIMESTAMP },
            { "portalUserId", Types.BIGINT }, { "portalUserName", Types.VARCHAR },
            { "emailAddress", Types.VARCHAR }, { "deviceCode", Types.VARCHAR }, { "deviceIP", Types.VARCHAR },
            { "validationCode", Types.INTEGER } };
    public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();

    static {
        TABLE_COLUMNS_MAP.put("deviceCodeId", Types.BIGINT);
        TABLE_COLUMNS_MAP.put("groupId", Types.BIGINT);
        TABLE_COLUMNS_MAP.put("companyId", Types.BIGINT);
        TABLE_COLUMNS_MAP.put("userId", Types.BIGINT);
        TABLE_COLUMNS_MAP.put("userName", Types.VARCHAR);
        TABLE_COLUMNS_MAP.put("createDate", Types.TIMESTAMP);
        TABLE_COLUMNS_MAP.put("modifiedDate", Types.TIMESTAMP);
        TABLE_COLUMNS_MAP.put("portalUserId", Types.BIGINT);
        TABLE_COLUMNS_MAP.put("portalUserName", Types.VARCHAR);
        TABLE_COLUMNS_MAP.put("emailAddress", Types.VARCHAR);
        TABLE_COLUMNS_MAP.put("deviceCode", Types.VARCHAR);
        TABLE_COLUMNS_MAP.put("deviceIP", Types.VARCHAR);
        TABLE_COLUMNS_MAP.put("validationCode", Types.INTEGER);
    }

    public static final String TABLE_SQL_CREATE = "create table Bemis_DeviceCode (deviceCodeId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,portalUserId LONG,portalUserName VARCHAR(75) null,emailAddress VARCHAR(75) null,deviceCode VARCHAR(75) null,deviceIP VARCHAR(75) null,validationCode INTEGER)";
    public static final String TABLE_SQL_DROP = "drop table Bemis_DeviceCode";
    public static final String ORDER_BY_JPQL = " ORDER BY deviceCode.deviceCodeId ASC";
    public static final String ORDER_BY_SQL = " ORDER BY Bemis_DeviceCode.deviceCodeId ASC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(
            com.bemis.portal.twofa.device.manager.service.util.PropsUtil.get(
                    "value.object.entity.cache.enabled.com.bemis.portal.twofa.device.manager.model.DeviceCode"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(
            com.bemis.portal.twofa.device.manager.service.util.PropsUtil.get(
                    "value.object.finder.cache.enabled.com.bemis.portal.twofa.device.manager.model.DeviceCode"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(
            com.bemis.portal.twofa.device.manager.service.util.PropsUtil.get(
                    "value.object.column.bitmask.enabled.com.bemis.portal.twofa.device.manager.model.DeviceCode"),
            true);
    public static final long EMAILADDRESS_COLUMN_BITMASK = 1L;
    public static final long PORTALUSERID_COLUMN_BITMASK = 2L;
    public static final long DEVICECODEID_COLUMN_BITMASK = 4L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil
            .getLong(com.bemis.portal.twofa.device.manager.service.util.PropsUtil
                    .get("lock.expiration.time.com.bemis.portal.twofa.device.manager.model.DeviceCode"));

    public DeviceCodeModelImpl() {
    }

    @Override
    public long getPrimaryKey() {
        return _deviceCodeId;
    }

    @Override
    public void setPrimaryKey(long primaryKey) {
        setDeviceCodeId(primaryKey);
    }

    @Override
    public Serializable getPrimaryKeyObj() {
        return _deviceCodeId;
    }

    @Override
    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    @Override
    public Class<?> getModelClass() {
        return DeviceCode.class;
    }

    @Override
    public String getModelClassName() {
        return DeviceCode.class.getName();
    }

    @Override
    public Map<String, Object> getModelAttributes() {
        Map<String, Object> attributes = new HashMap<String, Object>();

        attributes.put("deviceCodeId", getDeviceCodeId());
        attributes.put("groupId", getGroupId());
        attributes.put("companyId", getCompanyId());
        attributes.put("userId", getUserId());
        attributes.put("userName", getUserName());
        attributes.put("createDate", getCreateDate());
        attributes.put("modifiedDate", getModifiedDate());
        attributes.put("portalUserId", getPortalUserId());
        attributes.put("portalUserName", getPortalUserName());
        attributes.put("emailAddress", getEmailAddress());
        attributes.put("deviceCode", getDeviceCode());
        attributes.put("deviceIP", getDeviceIP());
        attributes.put("validationCode", getValidationCode());

        attributes.put("entityCacheEnabled", isEntityCacheEnabled());
        attributes.put("finderCacheEnabled", isFinderCacheEnabled());

        return attributes;
    }

    @Override
    public void setModelAttributes(Map<String, Object> attributes) {
        Long deviceCodeId = (Long) attributes.get("deviceCodeId");

        if (deviceCodeId != null) {
            setDeviceCodeId(deviceCodeId);
        }

        Long groupId = (Long) attributes.get("groupId");

        if (groupId != null) {
            setGroupId(groupId);
        }

        Long companyId = (Long) attributes.get("companyId");

        if (companyId != null) {
            setCompanyId(companyId);
        }

        Long userId = (Long) attributes.get("userId");

        if (userId != null) {
            setUserId(userId);
        }

        String userName = (String) attributes.get("userName");

        if (userName != null) {
            setUserName(userName);
        }

        Date createDate = (Date) attributes.get("createDate");

        if (createDate != null) {
            setCreateDate(createDate);
        }

        Date modifiedDate = (Date) attributes.get("modifiedDate");

        if (modifiedDate != null) {
            setModifiedDate(modifiedDate);
        }

        Long portalUserId = (Long) attributes.get("portalUserId");

        if (portalUserId != null) {
            setPortalUserId(portalUserId);
        }

        String portalUserName = (String) attributes.get("portalUserName");

        if (portalUserName != null) {
            setPortalUserName(portalUserName);
        }

        String emailAddress = (String) attributes.get("emailAddress");

        if (emailAddress != null) {
            setEmailAddress(emailAddress);
        }

        String deviceCode = (String) attributes.get("deviceCode");

        if (deviceCode != null) {
            setDeviceCode(deviceCode);
        }

        String deviceIP = (String) attributes.get("deviceIP");

        if (deviceIP != null) {
            setDeviceIP(deviceIP);
        }

        Integer validationCode = (Integer) attributes.get("validationCode");

        if (validationCode != null) {
            setValidationCode(validationCode);
        }
    }

    @Override
    public long getDeviceCodeId() {
        return _deviceCodeId;
    }

    @Override
    public void setDeviceCodeId(long deviceCodeId) {
        _deviceCodeId = deviceCodeId;
    }

    @Override
    public long getGroupId() {
        return _groupId;
    }

    @Override
    public void setGroupId(long groupId) {
        _groupId = groupId;
    }

    @Override
    public long getCompanyId() {
        return _companyId;
    }

    @Override
    public void setCompanyId(long companyId) {
        _companyId = companyId;
    }

    @Override
    public long getUserId() {
        return _userId;
    }

    @Override
    public void setUserId(long userId) {
        _userId = userId;
    }

    @Override
    public String getUserUuid() {
        try {
            User user = UserLocalServiceUtil.getUserById(getUserId());

            return user.getUuid();
        } catch (PortalException pe) {
            return StringPool.BLANK;
        }
    }

    @Override
    public void setUserUuid(String userUuid) {
    }

    @Override
    public String getUserName() {
        if (_userName == null) {
            return StringPool.BLANK;
        } else {
            return _userName;
        }
    }

    @Override
    public void setUserName(String userName) {
        _userName = userName;
    }

    @Override
    public Date getCreateDate() {
        return _createDate;
    }

    @Override
    public void setCreateDate(Date createDate) {
        _createDate = createDate;
    }

    @Override
    public Date getModifiedDate() {
        return _modifiedDate;
    }

    public boolean hasSetModifiedDate() {
        return _setModifiedDate;
    }

    @Override
    public void setModifiedDate(Date modifiedDate) {
        _setModifiedDate = true;

        _modifiedDate = modifiedDate;
    }

    @Override
    public long getPortalUserId() {
        return _portalUserId;
    }

    @Override
    public void setPortalUserId(long portalUserId) {
        _columnBitmask |= PORTALUSERID_COLUMN_BITMASK;

        if (!_setOriginalPortalUserId) {
            _setOriginalPortalUserId = true;

            _originalPortalUserId = _portalUserId;
        }

        _portalUserId = portalUserId;
    }

    @Override
    public String getPortalUserUuid() {
        try {
            User user = UserLocalServiceUtil.getUserById(getPortalUserId());

            return user.getUuid();
        } catch (PortalException pe) {
            return StringPool.BLANK;
        }
    }

    @Override
    public void setPortalUserUuid(String portalUserUuid) {
    }

    public long getOriginalPortalUserId() {
        return _originalPortalUserId;
    }

    @Override
    public String getPortalUserName() {
        if (_portalUserName == null) {
            return StringPool.BLANK;
        } else {
            return _portalUserName;
        }
    }

    @Override
    public void setPortalUserName(String portalUserName) {
        _portalUserName = portalUserName;
    }

    @Override
    public String getEmailAddress() {
        if (_emailAddress == null) {
            return StringPool.BLANK;
        } else {
            return _emailAddress;
        }
    }

    @Override
    public void setEmailAddress(String emailAddress) {
        _columnBitmask |= EMAILADDRESS_COLUMN_BITMASK;

        if (_originalEmailAddress == null) {
            _originalEmailAddress = _emailAddress;
        }

        _emailAddress = emailAddress;
    }

    public String getOriginalEmailAddress() {
        return GetterUtil.getString(_originalEmailAddress);
    }

    @Override
    public String getDeviceCode() {
        if (_deviceCode == null) {
            return StringPool.BLANK;
        } else {
            return _deviceCode;
        }
    }

    @Override
    public void setDeviceCode(String deviceCode) {
        _deviceCode = deviceCode;
    }

    @Override
    public String getDeviceIP() {
        if (_deviceIP == null) {
            return StringPool.BLANK;
        } else {
            return _deviceIP;
        }
    }

    @Override
    public void setDeviceIP(String deviceIP) {
        _deviceIP = deviceIP;
    }

    @Override
    public int getValidationCode() {
        return _validationCode;
    }

    @Override
    public void setValidationCode(int validationCode) {
        _validationCode = validationCode;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(), DeviceCode.class.getName(),
                getPrimaryKey());
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        ExpandoBridge expandoBridge = getExpandoBridge();

        expandoBridge.setAttributes(serviceContext);
    }

    @Override
    public DeviceCode toEscapedModel() {
        if (_escapedModel == null) {
            _escapedModel = (DeviceCode) ProxyUtil.newProxyInstance(_classLoader, _escapedModelInterfaces,
                    new AutoEscapeBeanHandler(this));
        }

        return _escapedModel;
    }

    @Override
    public Object clone() {
        DeviceCodeImpl deviceCodeImpl = new DeviceCodeImpl();

        deviceCodeImpl.setDeviceCodeId(getDeviceCodeId());
        deviceCodeImpl.setGroupId(getGroupId());
        deviceCodeImpl.setCompanyId(getCompanyId());
        deviceCodeImpl.setUserId(getUserId());
        deviceCodeImpl.setUserName(getUserName());
        deviceCodeImpl.setCreateDate(getCreateDate());
        deviceCodeImpl.setModifiedDate(getModifiedDate());
        deviceCodeImpl.setPortalUserId(getPortalUserId());
        deviceCodeImpl.setPortalUserName(getPortalUserName());
        deviceCodeImpl.setEmailAddress(getEmailAddress());
        deviceCodeImpl.setDeviceCode(getDeviceCode());
        deviceCodeImpl.setDeviceIP(getDeviceIP());
        deviceCodeImpl.setValidationCode(getValidationCode());

        deviceCodeImpl.resetOriginalValues();

        return deviceCodeImpl;
    }

    @Override
    public int compareTo(DeviceCode deviceCode) {
        long primaryKey = deviceCode.getPrimaryKey();

        if (getPrimaryKey() < primaryKey) {
            return -1;
        } else if (getPrimaryKey() > primaryKey) {
            return 1;
        } else {
            return 0;
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (!(obj instanceof DeviceCode)) {
            return false;
        }

        DeviceCode deviceCode = (DeviceCode) obj;

        long primaryKey = deviceCode.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public boolean isEntityCacheEnabled() {
        return ENTITY_CACHE_ENABLED;
    }

    @Override
    public boolean isFinderCacheEnabled() {
        return FINDER_CACHE_ENABLED;
    }

    @Override
    public void resetOriginalValues() {
        DeviceCodeModelImpl deviceCodeModelImpl = this;

        deviceCodeModelImpl._setModifiedDate = false;

        deviceCodeModelImpl._originalPortalUserId = deviceCodeModelImpl._portalUserId;

        deviceCodeModelImpl._setOriginalPortalUserId = false;

        deviceCodeModelImpl._originalEmailAddress = deviceCodeModelImpl._emailAddress;

        deviceCodeModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<DeviceCode> toCacheModel() {
        DeviceCodeCacheModel deviceCodeCacheModel = new DeviceCodeCacheModel();

        deviceCodeCacheModel.deviceCodeId = getDeviceCodeId();

        deviceCodeCacheModel.groupId = getGroupId();

        deviceCodeCacheModel.companyId = getCompanyId();

        deviceCodeCacheModel.userId = getUserId();

        deviceCodeCacheModel.userName = getUserName();

        String userName = deviceCodeCacheModel.userName;

        if ((userName != null) && (userName.length() == 0)) {
            deviceCodeCacheModel.userName = null;
        }

        Date createDate = getCreateDate();

        if (createDate != null) {
            deviceCodeCacheModel.createDate = createDate.getTime();
        } else {
            deviceCodeCacheModel.createDate = Long.MIN_VALUE;
        }

        Date modifiedDate = getModifiedDate();

        if (modifiedDate != null) {
            deviceCodeCacheModel.modifiedDate = modifiedDate.getTime();
        } else {
            deviceCodeCacheModel.modifiedDate = Long.MIN_VALUE;
        }

        deviceCodeCacheModel.portalUserId = getPortalUserId();

        deviceCodeCacheModel.portalUserName = getPortalUserName();

        String portalUserName = deviceCodeCacheModel.portalUserName;

        if ((portalUserName != null) && (portalUserName.length() == 0)) {
            deviceCodeCacheModel.portalUserName = null;
        }

        deviceCodeCacheModel.emailAddress = getEmailAddress();

        String emailAddress = deviceCodeCacheModel.emailAddress;

        if ((emailAddress != null) && (emailAddress.length() == 0)) {
            deviceCodeCacheModel.emailAddress = null;
        }

        deviceCodeCacheModel.deviceCode = getDeviceCode();

        String deviceCode = deviceCodeCacheModel.deviceCode;

        if ((deviceCode != null) && (deviceCode.length() == 0)) {
            deviceCodeCacheModel.deviceCode = null;
        }

        deviceCodeCacheModel.deviceIP = getDeviceIP();

        String deviceIP = deviceCodeCacheModel.deviceIP;

        if ((deviceIP != null) && (deviceIP.length() == 0)) {
            deviceCodeCacheModel.deviceIP = null;
        }

        deviceCodeCacheModel.validationCode = getValidationCode();

        return deviceCodeCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(27);

        sb.append("{deviceCodeId=");
        sb.append(getDeviceCodeId());
        sb.append(", groupId=");
        sb.append(getGroupId());
        sb.append(", companyId=");
        sb.append(getCompanyId());
        sb.append(", userId=");
        sb.append(getUserId());
        sb.append(", userName=");
        sb.append(getUserName());
        sb.append(", createDate=");
        sb.append(getCreateDate());
        sb.append(", modifiedDate=");
        sb.append(getModifiedDate());
        sb.append(", portalUserId=");
        sb.append(getPortalUserId());
        sb.append(", portalUserName=");
        sb.append(getPortalUserName());
        sb.append(", emailAddress=");
        sb.append(getEmailAddress());
        sb.append(", deviceCode=");
        sb.append(getDeviceCode());
        sb.append(", deviceIP=");
        sb.append(getDeviceIP());
        sb.append(", validationCode=");
        sb.append(getValidationCode());
        sb.append("}");

        return sb.toString();
    }

    @Override
    public String toXmlString() {
        StringBundler sb = new StringBundler(43);

        sb.append("<model><model-name>");
        sb.append("com.bemis.portal.twofa.device.manager.model.DeviceCode");
        sb.append("</model-name>");

        sb.append("<column><column-name>deviceCodeId</column-name><column-value><![CDATA[");
        sb.append(getDeviceCodeId());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>groupId</column-name><column-value><![CDATA[");
        sb.append(getGroupId());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>companyId</column-name><column-value><![CDATA[");
        sb.append(getCompanyId());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>userId</column-name><column-value><![CDATA[");
        sb.append(getUserId());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>userName</column-name><column-value><![CDATA[");
        sb.append(getUserName());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>createDate</column-name><column-value><![CDATA[");
        sb.append(getCreateDate());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
        sb.append(getModifiedDate());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>portalUserId</column-name><column-value><![CDATA[");
        sb.append(getPortalUserId());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>portalUserName</column-name><column-value><![CDATA[");
        sb.append(getPortalUserName());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>emailAddress</column-name><column-value><![CDATA[");
        sb.append(getEmailAddress());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>deviceCode</column-name><column-value><![CDATA[");
        sb.append(getDeviceCode());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>deviceIP</column-name><column-value><![CDATA[");
        sb.append(getDeviceIP());
        sb.append("]]></column-value></column>");
        sb.append("<column><column-name>validationCode</column-name><column-value><![CDATA[");
        sb.append(getValidationCode());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }

    private static final ClassLoader _classLoader = DeviceCode.class.getClassLoader();
    private static final Class<?>[] _escapedModelInterfaces = new Class[] { DeviceCode.class };
    private long _deviceCodeId;
    private long _groupId;
    private long _companyId;
    private long _userId;
    private String _userName;
    private Date _createDate;
    private Date _modifiedDate;
    private boolean _setModifiedDate;
    private long _portalUserId;
    private long _originalPortalUserId;
    private boolean _setOriginalPortalUserId;
    private String _portalUserName;
    private String _emailAddress;
    private String _originalEmailAddress;
    private String _deviceCode;
    private String _deviceIP;
    private int _validationCode;
    private long _columnBitmask;
    private DeviceCode _escapedModel;
}