/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */

package com.liferay.portal.model.impl;

import com.liferay.portal.LocaleException;
import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.lar.StagedModelType;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.LocalizationUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.Layout;
import com.liferay.portal.model.LayoutModel;
import com.liferay.portal.model.LayoutSoap;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

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

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

/**
 * The base model implementation for the Layout service. Represents a row in the &quot;Layout&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.liferay.portal.model.LayoutModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link LayoutImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see LayoutImpl
 * @see com.liferay.portal.model.Layout
 * @see com.liferay.portal.model.LayoutModel
 * @generated
 */
@JSON(strict = true)
public class LayoutModelImpl extends BaseModelImpl<Layout>
	implements LayoutModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a layout model instance should use the {@link com.liferay.portal.model.Layout} interface instead.
	 */
	public static final String TABLE_NAME = "Layout";
	public static final Object[][] TABLE_COLUMNS = {
			{ "uuid_", Types.VARCHAR },
			{ "plid", Types.BIGINT },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "userId", Types.BIGINT },
			{ "userName", Types.VARCHAR },
			{ "createDate", Types.TIMESTAMP },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "privateLayout", Types.BOOLEAN },
			{ "layoutId", Types.BIGINT },
			{ "parentLayoutId", Types.BIGINT },
			{ "name", Types.VARCHAR },
			{ "title", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "keywords", Types.VARCHAR },
			{ "robots", Types.VARCHAR },
			{ "type_", Types.VARCHAR },
			{ "typeSettings", Types.CLOB },
			{ "hidden_", Types.BOOLEAN },
			{ "friendlyURL", Types.VARCHAR },
			{ "iconImage", Types.BOOLEAN },
			{ "iconImageId", Types.BIGINT },
			{ "themeId", Types.VARCHAR },
			{ "colorSchemeId", Types.VARCHAR },
			{ "wapThemeId", Types.VARCHAR },
			{ "wapColorSchemeId", Types.VARCHAR },
			{ "css", Types.CLOB },
			{ "priority", Types.INTEGER },
			{ "layoutPrototypeUuid", Types.VARCHAR },
			{ "layoutPrototypeLinkEnabled", Types.BOOLEAN },
			{ "sourcePrototypeLayoutUuid", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table Layout (uuid_ VARCHAR(75) null,plid LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,privateLayout BOOLEAN,layoutId LONG,parentLayoutId LONG,name STRING null,title STRING null,description STRING null,keywords STRING null,robots STRING null,type_ VARCHAR(75) null,typeSettings TEXT null,hidden_ BOOLEAN,friendlyURL VARCHAR(255) null,iconImage BOOLEAN,iconImageId LONG,themeId VARCHAR(75) null,colorSchemeId VARCHAR(75) null,wapThemeId VARCHAR(75) null,wapColorSchemeId VARCHAR(75) null,css TEXT null,priority INTEGER,layoutPrototypeUuid VARCHAR(75) null,layoutPrototypeLinkEnabled BOOLEAN,sourcePrototypeLayoutUuid VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table Layout";
	public static final String ORDER_BY_JPQL = " ORDER BY layout.parentLayoutId ASC, layout.priority ASC";
	public static final String ORDER_BY_SQL = " ORDER BY Layout.parentLayoutId ASC, Layout.priority 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.liferay.portal.util.PropsUtil.get(
				"value.object.entity.cache.enabled.com.liferay.portal.model.Layout"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
				"value.object.finder.cache.enabled.com.liferay.portal.model.Layout"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
				"value.object.column.bitmask.enabled.com.liferay.portal.model.Layout"),
			true);
	public static long COMPANYID_COLUMN_BITMASK = 1L;
	public static long FRIENDLYURL_COLUMN_BITMASK = 2L;
	public static long GROUPID_COLUMN_BITMASK = 4L;
	public static long ICONIMAGEID_COLUMN_BITMASK = 8L;
	public static long LAYOUTID_COLUMN_BITMASK = 16L;
	public static long LAYOUTPROTOTYPEUUID_COLUMN_BITMASK = 32L;
	public static long PARENTLAYOUTID_COLUMN_BITMASK = 64L;
	public static long PRIORITY_COLUMN_BITMASK = 128L;
	public static long PRIVATELAYOUT_COLUMN_BITMASK = 256L;
	public static long SOURCEPROTOTYPELAYOUTUUID_COLUMN_BITMASK = 512L;
	public static long TYPE_COLUMN_BITMASK = 1024L;
	public static long UUID_COLUMN_BITMASK = 2048L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static Layout toModel(LayoutSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		Layout model = new LayoutImpl();

		model.setUuid(soapModel.getUuid());
		model.setPlid(soapModel.getPlid());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setUserId(soapModel.getUserId());
		model.setUserName(soapModel.getUserName());
		model.setCreateDate(soapModel.getCreateDate());
		model.setModifiedDate(soapModel.getModifiedDate());
		model.setPrivateLayout(soapModel.getPrivateLayout());
		model.setLayoutId(soapModel.getLayoutId());
		model.setParentLayoutId(soapModel.getParentLayoutId());
		model.setName(soapModel.getName());
		model.setTitle(soapModel.getTitle());
		model.setDescription(soapModel.getDescription());
		model.setKeywords(soapModel.getKeywords());
		model.setRobots(soapModel.getRobots());
		model.setType(soapModel.getType());
		model.setTypeSettings(soapModel.getTypeSettings());
		model.setHidden(soapModel.getHidden());
		model.setFriendlyURL(soapModel.getFriendlyURL());
		model.setIconImage(soapModel.getIconImage());
		model.setIconImageId(soapModel.getIconImageId());
		model.setThemeId(soapModel.getThemeId());
		model.setColorSchemeId(soapModel.getColorSchemeId());
		model.setWapThemeId(soapModel.getWapThemeId());
		model.setWapColorSchemeId(soapModel.getWapColorSchemeId());
		model.setCss(soapModel.getCss());
		model.setPriority(soapModel.getPriority());
		model.setLayoutPrototypeUuid(soapModel.getLayoutPrototypeUuid());
		model.setLayoutPrototypeLinkEnabled(soapModel.getLayoutPrototypeLinkEnabled());
		model.setSourcePrototypeLayoutUuid(soapModel.getSourcePrototypeLayoutUuid());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<Layout> toModels(LayoutSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<Layout> models = new ArrayList<Layout>(soapModels.length);

		for (LayoutSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
				"lock.expiration.time.com.liferay.portal.model.Layout"));

	public LayoutModelImpl() {
	}

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

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

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

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

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

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

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

		attributes.put("uuid", getUuid());
		attributes.put("plid", getPlid());
		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("privateLayout", getPrivateLayout());
		attributes.put("layoutId", getLayoutId());
		attributes.put("parentLayoutId", getParentLayoutId());
		attributes.put("name", getName());
		attributes.put("title", getTitle());
		attributes.put("description", getDescription());
		attributes.put("keywords", getKeywords());
		attributes.put("robots", getRobots());
		attributes.put("type", getType());
		attributes.put("typeSettings", getTypeSettings());
		attributes.put("hidden", getHidden());
		attributes.put("friendlyURL", getFriendlyURL());
		attributes.put("iconImage", getIconImage());
		attributes.put("iconImageId", getIconImageId());
		attributes.put("themeId", getThemeId());
		attributes.put("colorSchemeId", getColorSchemeId());
		attributes.put("wapThemeId", getWapThemeId());
		attributes.put("wapColorSchemeId", getWapColorSchemeId());
		attributes.put("css", getCss());
		attributes.put("priority", getPriority());
		attributes.put("layoutPrototypeUuid", getLayoutPrototypeUuid());
		attributes.put("layoutPrototypeLinkEnabled",
			getLayoutPrototypeLinkEnabled());
		attributes.put("sourcePrototypeLayoutUuid",
			getSourcePrototypeLayoutUuid());

		return attributes;
	}

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

		if (uuid != null) {
			setUuid(uuid);
		}

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

		if (plid != null) {
			setPlid(plid);
		}

		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);
		}

		Boolean privateLayout = (Boolean)attributes.get("privateLayout");

		if (privateLayout != null) {
			setPrivateLayout(privateLayout);
		}

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

		if (layoutId != null) {
			setLayoutId(layoutId);
		}

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

		if (parentLayoutId != null) {
			setParentLayoutId(parentLayoutId);
		}

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

		if (name != null) {
			setName(name);
		}

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

		if (title != null) {
			setTitle(title);
		}

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

		if (description != null) {
			setDescription(description);
		}

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

		if (keywords != null) {
			setKeywords(keywords);
		}

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

		if (robots != null) {
			setRobots(robots);
		}

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

		if (type != null) {
			setType(type);
		}

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

		if (typeSettings != null) {
			setTypeSettings(typeSettings);
		}

		Boolean hidden = (Boolean)attributes.get("hidden");

		if (hidden != null) {
			setHidden(hidden);
		}

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

		if (friendlyURL != null) {
			setFriendlyURL(friendlyURL);
		}

		Boolean iconImage = (Boolean)attributes.get("iconImage");

		if (iconImage != null) {
			setIconImage(iconImage);
		}

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

		if (iconImageId != null) {
			setIconImageId(iconImageId);
		}

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

		if (themeId != null) {
			setThemeId(themeId);
		}

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

		if (colorSchemeId != null) {
			setColorSchemeId(colorSchemeId);
		}

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

		if (wapThemeId != null) {
			setWapThemeId(wapThemeId);
		}

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

		if (wapColorSchemeId != null) {
			setWapColorSchemeId(wapColorSchemeId);
		}

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

		if (css != null) {
			setCss(css);
		}

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

		if (priority != null) {
			setPriority(priority);
		}

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

		if (layoutPrototypeUuid != null) {
			setLayoutPrototypeUuid(layoutPrototypeUuid);
		}

		Boolean layoutPrototypeLinkEnabled = (Boolean)attributes.get(
				"layoutPrototypeLinkEnabled");

		if (layoutPrototypeLinkEnabled != null) {
			setLayoutPrototypeLinkEnabled(layoutPrototypeLinkEnabled);
		}

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

		if (sourcePrototypeLayoutUuid != null) {
			setSourcePrototypeLayoutUuid(sourcePrototypeLayoutUuid);
		}
	}

	@JSON
	@Override
	public String getUuid() {
		if (_uuid == null) {
			return StringPool.BLANK;
		}
		else {
			return _uuid;
		}
	}

	@Override
	public void setUuid(String uuid) {
		if (_originalUuid == null) {
			_originalUuid = _uuid;
		}

		_uuid = uuid;
	}

	public String getOriginalUuid() {
		return GetterUtil.getString(_originalUuid);
	}

	@JSON
	@Override
	public long getPlid() {
		return _plid;
	}

	@Override
	public void setPlid(long plid) {
		_plid = plid;
	}

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

	@Override
	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

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

	@Override
	public void setCompanyId(long companyId) {
		_columnBitmask |= COMPANYID_COLUMN_BITMASK;

		if (!_setOriginalCompanyId) {
			_setOriginalCompanyId = true;

			_originalCompanyId = _companyId;
		}

		_companyId = companyId;
	}

	public long getOriginalCompanyId() {
		return _originalCompanyId;
	}

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

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

	@Override
	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	@Override
	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

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

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

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

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

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

	@Override
	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	@JSON
	@Override
	public boolean getPrivateLayout() {
		return _privateLayout;
	}

	@Override
	public boolean isPrivateLayout() {
		return _privateLayout;
	}

	@Override
	public void setPrivateLayout(boolean privateLayout) {
		_columnBitmask |= PRIVATELAYOUT_COLUMN_BITMASK;

		if (!_setOriginalPrivateLayout) {
			_setOriginalPrivateLayout = true;

			_originalPrivateLayout = _privateLayout;
		}

		_privateLayout = privateLayout;
	}

	public boolean getOriginalPrivateLayout() {
		return _originalPrivateLayout;
	}

	@JSON
	@Override
	public long getLayoutId() {
		return _layoutId;
	}

	@Override
	public void setLayoutId(long layoutId) {
		_columnBitmask |= LAYOUTID_COLUMN_BITMASK;

		if (!_setOriginalLayoutId) {
			_setOriginalLayoutId = true;

			_originalLayoutId = _layoutId;
		}

		_layoutId = layoutId;
	}

	public long getOriginalLayoutId() {
		return _originalLayoutId;
	}

	@JSON
	@Override
	public long getParentLayoutId() {
		return _parentLayoutId;
	}

	@Override
	public void setParentLayoutId(long parentLayoutId) {
		_columnBitmask = -1L;

		if (!_setOriginalParentLayoutId) {
			_setOriginalParentLayoutId = true;

			_originalParentLayoutId = _parentLayoutId;
		}

		_parentLayoutId = parentLayoutId;
	}

	public long getOriginalParentLayoutId() {
		return _originalParentLayoutId;
	}

	@JSON
	@Override
	public String getName() {
		if (_name == null) {
			return StringPool.BLANK;
		}
		else {
			return _name;
		}
	}

	@Override
	public String getName(Locale locale) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getName(languageId);
	}

	@Override
	public String getName(Locale locale, boolean useDefault) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getName(languageId, useDefault);
	}

	@Override
	public String getName(String languageId) {
		return LocalizationUtil.getLocalization(getName(), languageId);
	}

	@Override
	public String getName(String languageId, boolean useDefault) {
		return LocalizationUtil.getLocalization(getName(), languageId,
			useDefault);
	}

	@Override
	public String getNameCurrentLanguageId() {
		return _nameCurrentLanguageId;
	}

	@JSON
	@Override
	public String getNameCurrentValue() {
		Locale locale = getLocale(_nameCurrentLanguageId);

		return getName(locale);
	}

	@Override
	public Map<Locale, String> getNameMap() {
		return LocalizationUtil.getLocalizationMap(getName());
	}

	@Override
	public void setName(String name) {
		_name = name;
	}

	@Override
	public void setName(String name, Locale locale) {
		setName(name, locale, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setName(String name, Locale locale, Locale defaultLocale) {
		String languageId = LocaleUtil.toLanguageId(locale);
		String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

		if (Validator.isNotNull(name)) {
			setName(LocalizationUtil.updateLocalization(getName(), "Name",
					name, languageId, defaultLanguageId));
		}
		else {
			setName(LocalizationUtil.removeLocalization(getName(), "Name",
					languageId));
		}
	}

	@Override
	public void setNameCurrentLanguageId(String languageId) {
		_nameCurrentLanguageId = languageId;
	}

	@Override
	public void setNameMap(Map<Locale, String> nameMap) {
		setNameMap(nameMap, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setNameMap(Map<Locale, String> nameMap, Locale defaultLocale) {
		if (nameMap == null) {
			return;
		}

		setName(LocalizationUtil.updateLocalization(nameMap, getName(), "Name",
				LocaleUtil.toLanguageId(defaultLocale)));
	}

	@JSON
	@Override
	public String getTitle() {
		if (_title == null) {
			return StringPool.BLANK;
		}
		else {
			return _title;
		}
	}

	@Override
	public String getTitle(Locale locale) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getTitle(languageId);
	}

	@Override
	public String getTitle(Locale locale, boolean useDefault) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getTitle(languageId, useDefault);
	}

	@Override
	public String getTitle(String languageId) {
		return LocalizationUtil.getLocalization(getTitle(), languageId);
	}

	@Override
	public String getTitle(String languageId, boolean useDefault) {
		return LocalizationUtil.getLocalization(getTitle(), languageId,
			useDefault);
	}

	@Override
	public String getTitleCurrentLanguageId() {
		return _titleCurrentLanguageId;
	}

	@JSON
	@Override
	public String getTitleCurrentValue() {
		Locale locale = getLocale(_titleCurrentLanguageId);

		return getTitle(locale);
	}

	@Override
	public Map<Locale, String> getTitleMap() {
		return LocalizationUtil.getLocalizationMap(getTitle());
	}

	@Override
	public void setTitle(String title) {
		_title = title;
	}

	@Override
	public void setTitle(String title, Locale locale) {
		setTitle(title, locale, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setTitle(String title, Locale locale, Locale defaultLocale) {
		String languageId = LocaleUtil.toLanguageId(locale);
		String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

		if (Validator.isNotNull(title)) {
			setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
					title, languageId, defaultLanguageId));
		}
		else {
			setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
					languageId));
		}
	}

	@Override
	public void setTitleCurrentLanguageId(String languageId) {
		_titleCurrentLanguageId = languageId;
	}

	@Override
	public void setTitleMap(Map<Locale, String> titleMap) {
		setTitleMap(titleMap, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {
		if (titleMap == null) {
			return;
		}

		setTitle(LocalizationUtil.updateLocalization(titleMap, getTitle(),
				"Title", LocaleUtil.toLanguageId(defaultLocale)));
	}

	@JSON
	@Override
	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	@Override
	public String getDescription(Locale locale) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getDescription(languageId);
	}

	@Override
	public String getDescription(Locale locale, boolean useDefault) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getDescription(languageId, useDefault);
	}

	@Override
	public String getDescription(String languageId) {
		return LocalizationUtil.getLocalization(getDescription(), languageId);
	}

	@Override
	public String getDescription(String languageId, boolean useDefault) {
		return LocalizationUtil.getLocalization(getDescription(), languageId,
			useDefault);
	}

	@Override
	public String getDescriptionCurrentLanguageId() {
		return _descriptionCurrentLanguageId;
	}

	@JSON
	@Override
	public String getDescriptionCurrentValue() {
		Locale locale = getLocale(_descriptionCurrentLanguageId);

		return getDescription(locale);
	}

	@Override
	public Map<Locale, String> getDescriptionMap() {
		return LocalizationUtil.getLocalizationMap(getDescription());
	}

	@Override
	public void setDescription(String description) {
		_description = description;
	}

	@Override
	public void setDescription(String description, Locale locale) {
		setDescription(description, locale, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setDescription(String description, Locale locale,
		Locale defaultLocale) {
		String languageId = LocaleUtil.toLanguageId(locale);
		String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

		if (Validator.isNotNull(description)) {
			setDescription(LocalizationUtil.updateLocalization(
					getDescription(), "Description", description, languageId,
					defaultLanguageId));
		}
		else {
			setDescription(LocalizationUtil.removeLocalization(
					getDescription(), "Description", languageId));
		}
	}

	@Override
	public void setDescriptionCurrentLanguageId(String languageId) {
		_descriptionCurrentLanguageId = languageId;
	}

	@Override
	public void setDescriptionMap(Map<Locale, String> descriptionMap) {
		setDescriptionMap(descriptionMap, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setDescriptionMap(Map<Locale, String> descriptionMap,
		Locale defaultLocale) {
		if (descriptionMap == null) {
			return;
		}

		setDescription(LocalizationUtil.updateLocalization(descriptionMap,
				getDescription(), "Description",
				LocaleUtil.toLanguageId(defaultLocale)));
	}

	@JSON
	@Override
	public String getKeywords() {
		if (_keywords == null) {
			return StringPool.BLANK;
		}
		else {
			return _keywords;
		}
	}

	@Override
	public String getKeywords(Locale locale) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getKeywords(languageId);
	}

	@Override
	public String getKeywords(Locale locale, boolean useDefault) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getKeywords(languageId, useDefault);
	}

	@Override
	public String getKeywords(String languageId) {
		return LocalizationUtil.getLocalization(getKeywords(), languageId);
	}

	@Override
	public String getKeywords(String languageId, boolean useDefault) {
		return LocalizationUtil.getLocalization(getKeywords(), languageId,
			useDefault);
	}

	@Override
	public String getKeywordsCurrentLanguageId() {
		return _keywordsCurrentLanguageId;
	}

	@JSON
	@Override
	public String getKeywordsCurrentValue() {
		Locale locale = getLocale(_keywordsCurrentLanguageId);

		return getKeywords(locale);
	}

	@Override
	public Map<Locale, String> getKeywordsMap() {
		return LocalizationUtil.getLocalizationMap(getKeywords());
	}

	@Override
	public void setKeywords(String keywords) {
		_keywords = keywords;
	}

	@Override
	public void setKeywords(String keywords, Locale locale) {
		setKeywords(keywords, locale, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setKeywords(String keywords, Locale locale, Locale defaultLocale) {
		String languageId = LocaleUtil.toLanguageId(locale);
		String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

		if (Validator.isNotNull(keywords)) {
			setKeywords(LocalizationUtil.updateLocalization(getKeywords(),
					"Keywords", keywords, languageId, defaultLanguageId));
		}
		else {
			setKeywords(LocalizationUtil.removeLocalization(getKeywords(),
					"Keywords", languageId));
		}
	}

	@Override
	public void setKeywordsCurrentLanguageId(String languageId) {
		_keywordsCurrentLanguageId = languageId;
	}

	@Override
	public void setKeywordsMap(Map<Locale, String> keywordsMap) {
		setKeywordsMap(keywordsMap, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setKeywordsMap(Map<Locale, String> keywordsMap,
		Locale defaultLocale) {
		if (keywordsMap == null) {
			return;
		}

		setKeywords(LocalizationUtil.updateLocalization(keywordsMap,
				getKeywords(), "Keywords",
				LocaleUtil.toLanguageId(defaultLocale)));
	}

	@JSON
	@Override
	public String getRobots() {
		if (_robots == null) {
			return StringPool.BLANK;
		}
		else {
			return _robots;
		}
	}

	@Override
	public String getRobots(Locale locale) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getRobots(languageId);
	}

	@Override
	public String getRobots(Locale locale, boolean useDefault) {
		String languageId = LocaleUtil.toLanguageId(locale);

		return getRobots(languageId, useDefault);
	}

	@Override
	public String getRobots(String languageId) {
		return LocalizationUtil.getLocalization(getRobots(), languageId);
	}

	@Override
	public String getRobots(String languageId, boolean useDefault) {
		return LocalizationUtil.getLocalization(getRobots(), languageId,
			useDefault);
	}

	@Override
	public String getRobotsCurrentLanguageId() {
		return _robotsCurrentLanguageId;
	}

	@JSON
	@Override
	public String getRobotsCurrentValue() {
		Locale locale = getLocale(_robotsCurrentLanguageId);

		return getRobots(locale);
	}

	@Override
	public Map<Locale, String> getRobotsMap() {
		return LocalizationUtil.getLocalizationMap(getRobots());
	}

	@Override
	public void setRobots(String robots) {
		_robots = robots;
	}

	@Override
	public void setRobots(String robots, Locale locale) {
		setRobots(robots, locale, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setRobots(String robots, Locale locale, Locale defaultLocale) {
		String languageId = LocaleUtil.toLanguageId(locale);
		String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

		if (Validator.isNotNull(robots)) {
			setRobots(LocalizationUtil.updateLocalization(getRobots(),
					"Robots", robots, languageId, defaultLanguageId));
		}
		else {
			setRobots(LocalizationUtil.removeLocalization(getRobots(),
					"Robots", languageId));
		}
	}

	@Override
	public void setRobotsCurrentLanguageId(String languageId) {
		_robotsCurrentLanguageId = languageId;
	}

	@Override
	public void setRobotsMap(Map<Locale, String> robotsMap) {
		setRobotsMap(robotsMap, LocaleUtil.getSiteDefault());
	}

	@Override
	public void setRobotsMap(Map<Locale, String> robotsMap, Locale defaultLocale) {
		if (robotsMap == null) {
			return;
		}

		setRobots(LocalizationUtil.updateLocalization(robotsMap, getRobots(),
				"Robots", LocaleUtil.toLanguageId(defaultLocale)));
	}

	@JSON
	@Override
	public String getType() {
		if (_type == null) {
			return StringPool.BLANK;
		}
		else {
			return _type;
		}
	}

	@Override
	public void setType(String type) {
		_columnBitmask |= TYPE_COLUMN_BITMASK;

		if (_originalType == null) {
			_originalType = _type;
		}

		_type = type;
	}

	public String getOriginalType() {
		return GetterUtil.getString(_originalType);
	}

	@JSON
	@Override
	public String getTypeSettings() {
		if (_typeSettings == null) {
			return StringPool.BLANK;
		}
		else {
			return _typeSettings;
		}
	}

	@Override
	public void setTypeSettings(String typeSettings) {
		_typeSettings = typeSettings;
	}

	@JSON
	@Override
	public boolean getHidden() {
		return _hidden;
	}

	@Override
	public boolean isHidden() {
		return _hidden;
	}

	@Override
	public void setHidden(boolean hidden) {
		_hidden = hidden;
	}

	@JSON
	@Override
	public String getFriendlyURL() {
		if (_friendlyURL == null) {
			return StringPool.BLANK;
		}
		else {
			return _friendlyURL;
		}
	}

	@Override
	public void setFriendlyURL(String friendlyURL) {
		_columnBitmask |= FRIENDLYURL_COLUMN_BITMASK;

		if (_originalFriendlyURL == null) {
			_originalFriendlyURL = _friendlyURL;
		}

		_friendlyURL = friendlyURL;
	}

	public String getOriginalFriendlyURL() {
		return GetterUtil.getString(_originalFriendlyURL);
	}

	@JSON
	@Override
	public boolean getIconImage() {
		return _iconImage;
	}

	@Override
	public boolean isIconImage() {
		return _iconImage;
	}

	@Override
	public void setIconImage(boolean iconImage) {
		_iconImage = iconImage;
	}

	@JSON
	@Override
	public long getIconImageId() {
		return _iconImageId;
	}

	@Override
	public void setIconImageId(long iconImageId) {
		_columnBitmask |= ICONIMAGEID_COLUMN_BITMASK;

		if (!_setOriginalIconImageId) {
			_setOriginalIconImageId = true;

			_originalIconImageId = _iconImageId;
		}

		_iconImageId = iconImageId;
	}

	public long getOriginalIconImageId() {
		return _originalIconImageId;
	}

	@JSON
	@Override
	public String getThemeId() {
		if (_themeId == null) {
			return StringPool.BLANK;
		}
		else {
			return _themeId;
		}
	}

	@Override
	public void setThemeId(String themeId) {
		_themeId = themeId;
	}

	@JSON
	@Override
	public String getColorSchemeId() {
		if (_colorSchemeId == null) {
			return StringPool.BLANK;
		}
		else {
			return _colorSchemeId;
		}
	}

	@Override
	public void setColorSchemeId(String colorSchemeId) {
		_colorSchemeId = colorSchemeId;
	}

	@JSON
	@Override
	public String getWapThemeId() {
		if (_wapThemeId == null) {
			return StringPool.BLANK;
		}
		else {
			return _wapThemeId;
		}
	}

	@Override
	public void setWapThemeId(String wapThemeId) {
		_wapThemeId = wapThemeId;
	}

	@JSON
	@Override
	public String getWapColorSchemeId() {
		if (_wapColorSchemeId == null) {
			return StringPool.BLANK;
		}
		else {
			return _wapColorSchemeId;
		}
	}

	@Override
	public void setWapColorSchemeId(String wapColorSchemeId) {
		_wapColorSchemeId = wapColorSchemeId;
	}

	@JSON
	@Override
	public String getCss() {
		if (_css == null) {
			return StringPool.BLANK;
		}
		else {
			return _css;
		}
	}

	@Override
	public void setCss(String css) {
		_css = css;
	}

	@JSON
	@Override
	public int getPriority() {
		return _priority;
	}

	@Override
	public void setPriority(int priority) {
		_columnBitmask = -1L;

		if (!_setOriginalPriority) {
			_setOriginalPriority = true;

			_originalPriority = _priority;
		}

		_priority = priority;
	}

	public int getOriginalPriority() {
		return _originalPriority;
	}

	@JSON
	@Override
	public String getLayoutPrototypeUuid() {
		if (_layoutPrototypeUuid == null) {
			return StringPool.BLANK;
		}
		else {
			return _layoutPrototypeUuid;
		}
	}

	@Override
	public void setLayoutPrototypeUuid(String layoutPrototypeUuid) {
		_columnBitmask |= LAYOUTPROTOTYPEUUID_COLUMN_BITMASK;

		if (_originalLayoutPrototypeUuid == null) {
			_originalLayoutPrototypeUuid = _layoutPrototypeUuid;
		}

		_layoutPrototypeUuid = layoutPrototypeUuid;
	}

	public String getOriginalLayoutPrototypeUuid() {
		return GetterUtil.getString(_originalLayoutPrototypeUuid);
	}

	@JSON
	@Override
	public boolean getLayoutPrototypeLinkEnabled() {
		return _layoutPrototypeLinkEnabled;
	}

	@Override
	public boolean isLayoutPrototypeLinkEnabled() {
		return _layoutPrototypeLinkEnabled;
	}

	@Override
	public void setLayoutPrototypeLinkEnabled(
		boolean layoutPrototypeLinkEnabled) {
		_layoutPrototypeLinkEnabled = layoutPrototypeLinkEnabled;
	}

	@JSON
	@Override
	public String getSourcePrototypeLayoutUuid() {
		if (_sourcePrototypeLayoutUuid == null) {
			return StringPool.BLANK;
		}
		else {
			return _sourcePrototypeLayoutUuid;
		}
	}

	@Override
	public void setSourcePrototypeLayoutUuid(String sourcePrototypeLayoutUuid) {
		_columnBitmask |= SOURCEPROTOTYPELAYOUTUUID_COLUMN_BITMASK;

		if (_originalSourcePrototypeLayoutUuid == null) {
			_originalSourcePrototypeLayoutUuid = _sourcePrototypeLayoutUuid;
		}

		_sourcePrototypeLayoutUuid = sourcePrototypeLayoutUuid;
	}

	public String getOriginalSourcePrototypeLayoutUuid() {
		return GetterUtil.getString(_originalSourcePrototypeLayoutUuid);
	}

	@Override
	public StagedModelType getStagedModelType() {
		return new StagedModelType(PortalUtil.getClassNameId(
				Layout.class.getName()));
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

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

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

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public String[] getAvailableLanguageIds() {
		Set<String> availableLanguageIds = new TreeSet<String>();

		Map<Locale, String> nameMap = getNameMap();

		for (Map.Entry<Locale, String> entry : nameMap.entrySet()) {
			Locale locale = entry.getKey();
			String value = entry.getValue();

			if (Validator.isNotNull(value)) {
				availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
			}
		}

		Map<Locale, String> titleMap = getTitleMap();

		for (Map.Entry<Locale, String> entry : titleMap.entrySet()) {
			Locale locale = entry.getKey();
			String value = entry.getValue();

			if (Validator.isNotNull(value)) {
				availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
			}
		}

		Map<Locale, String> descriptionMap = getDescriptionMap();

		for (Map.Entry<Locale, String> entry : descriptionMap.entrySet()) {
			Locale locale = entry.getKey();
			String value = entry.getValue();

			if (Validator.isNotNull(value)) {
				availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
			}
		}

		Map<Locale, String> keywordsMap = getKeywordsMap();

		for (Map.Entry<Locale, String> entry : keywordsMap.entrySet()) {
			Locale locale = entry.getKey();
			String value = entry.getValue();

			if (Validator.isNotNull(value)) {
				availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
			}
		}

		Map<Locale, String> robotsMap = getRobotsMap();

		for (Map.Entry<Locale, String> entry : robotsMap.entrySet()) {
			Locale locale = entry.getKey();
			String value = entry.getValue();

			if (Validator.isNotNull(value)) {
				availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
			}
		}

		return availableLanguageIds.toArray(new String[availableLanguageIds.size()]);
	}

	@Override
	public String getDefaultLanguageId() {
		String xml = getName();

		if (xml == null) {
			return StringPool.BLANK;
		}

		Locale defaultLocale = LocaleUtil.getSiteDefault();

		return LocalizationUtil.getDefaultLanguageId(xml, defaultLocale);
	}

	@Override
	public void prepareLocalizedFieldsForImport() throws LocaleException {
		prepareLocalizedFieldsForImport(null);
	}

	@Override
	@SuppressWarnings("unused")
	public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
		throws LocaleException {
		Locale defaultLocale = LocaleUtil.getSiteDefault();

		String modelDefaultLanguageId = getDefaultLanguageId();

		String name = getName(defaultLocale);

		if (Validator.isNull(name)) {
			setName(getName(modelDefaultLanguageId), defaultLocale);
		}
		else {
			setName(getName(defaultLocale), defaultLocale, defaultLocale);
		}

		String title = getTitle(defaultLocale);

		if (Validator.isNull(title)) {
			setTitle(getTitle(modelDefaultLanguageId), defaultLocale);
		}
		else {
			setTitle(getTitle(defaultLocale), defaultLocale, defaultLocale);
		}

		String description = getDescription(defaultLocale);

		if (Validator.isNull(description)) {
			setDescription(getDescription(modelDefaultLanguageId), defaultLocale);
		}
		else {
			setDescription(getDescription(defaultLocale), defaultLocale,
				defaultLocale);
		}

		String keywords = getKeywords(defaultLocale);

		if (Validator.isNull(keywords)) {
			setKeywords(getKeywords(modelDefaultLanguageId), defaultLocale);
		}
		else {
			setKeywords(getKeywords(defaultLocale), defaultLocale, defaultLocale);
		}

		String robots = getRobots(defaultLocale);

		if (Validator.isNull(robots)) {
			setRobots(getRobots(modelDefaultLanguageId), defaultLocale);
		}
		else {
			setRobots(getRobots(defaultLocale), defaultLocale, defaultLocale);
		}
	}

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

		return _escapedModel;
	}

	@Override
	public Object clone() {
		LayoutImpl layoutImpl = new LayoutImpl();

		layoutImpl.setUuid(getUuid());
		layoutImpl.setPlid(getPlid());
		layoutImpl.setGroupId(getGroupId());
		layoutImpl.setCompanyId(getCompanyId());
		layoutImpl.setUserId(getUserId());
		layoutImpl.setUserName(getUserName());
		layoutImpl.setCreateDate(getCreateDate());
		layoutImpl.setModifiedDate(getModifiedDate());
		layoutImpl.setPrivateLayout(getPrivateLayout());
		layoutImpl.setLayoutId(getLayoutId());
		layoutImpl.setParentLayoutId(getParentLayoutId());
		layoutImpl.setName(getName());
		layoutImpl.setTitle(getTitle());
		layoutImpl.setDescription(getDescription());
		layoutImpl.setKeywords(getKeywords());
		layoutImpl.setRobots(getRobots());
		layoutImpl.setType(getType());
		layoutImpl.setTypeSettings(getTypeSettings());
		layoutImpl.setHidden(getHidden());
		layoutImpl.setFriendlyURL(getFriendlyURL());
		layoutImpl.setIconImage(getIconImage());
		layoutImpl.setIconImageId(getIconImageId());
		layoutImpl.setThemeId(getThemeId());
		layoutImpl.setColorSchemeId(getColorSchemeId());
		layoutImpl.setWapThemeId(getWapThemeId());
		layoutImpl.setWapColorSchemeId(getWapColorSchemeId());
		layoutImpl.setCss(getCss());
		layoutImpl.setPriority(getPriority());
		layoutImpl.setLayoutPrototypeUuid(getLayoutPrototypeUuid());
		layoutImpl.setLayoutPrototypeLinkEnabled(getLayoutPrototypeLinkEnabled());
		layoutImpl.setSourcePrototypeLayoutUuid(getSourcePrototypeLayoutUuid());

		layoutImpl.resetOriginalValues();

		return layoutImpl;
	}

	@Override
	public int compareTo(Layout layout) {
		int value = 0;

		if (getParentLayoutId() < layout.getParentLayoutId()) {
			value = -1;
		}
		else if (getParentLayoutId() > layout.getParentLayoutId()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		if (getPriority() < layout.getPriority()) {
			value = -1;
		}
		else if (getPriority() > layout.getPriority()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		return 0;
	}

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

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

		Layout layout = (Layout)obj;

		long primaryKey = layout.getPrimaryKey();

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

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

	@Override
	public void resetOriginalValues() {
		LayoutModelImpl layoutModelImpl = this;

		layoutModelImpl._originalUuid = layoutModelImpl._uuid;

		layoutModelImpl._originalGroupId = layoutModelImpl._groupId;

		layoutModelImpl._setOriginalGroupId = false;

		layoutModelImpl._originalCompanyId = layoutModelImpl._companyId;

		layoutModelImpl._setOriginalCompanyId = false;

		layoutModelImpl._originalPrivateLayout = layoutModelImpl._privateLayout;

		layoutModelImpl._setOriginalPrivateLayout = false;

		layoutModelImpl._originalLayoutId = layoutModelImpl._layoutId;

		layoutModelImpl._setOriginalLayoutId = false;

		layoutModelImpl._originalParentLayoutId = layoutModelImpl._parentLayoutId;

		layoutModelImpl._setOriginalParentLayoutId = false;

		layoutModelImpl._originalType = layoutModelImpl._type;

		layoutModelImpl._originalFriendlyURL = layoutModelImpl._friendlyURL;

		layoutModelImpl._originalIconImageId = layoutModelImpl._iconImageId;

		layoutModelImpl._setOriginalIconImageId = false;

		layoutModelImpl._originalPriority = layoutModelImpl._priority;

		layoutModelImpl._setOriginalPriority = false;

		layoutModelImpl._originalLayoutPrototypeUuid = layoutModelImpl._layoutPrototypeUuid;

		layoutModelImpl._originalSourcePrototypeLayoutUuid = layoutModelImpl._sourcePrototypeLayoutUuid;

		layoutModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<Layout> toCacheModel() {
		LayoutCacheModel layoutCacheModel = new LayoutCacheModel();

		layoutCacheModel.uuid = getUuid();

		String uuid = layoutCacheModel.uuid;

		if ((uuid != null) && (uuid.length() == 0)) {
			layoutCacheModel.uuid = null;
		}

		layoutCacheModel.plid = getPlid();

		layoutCacheModel.groupId = getGroupId();

		layoutCacheModel.companyId = getCompanyId();

		layoutCacheModel.userId = getUserId();

		layoutCacheModel.userName = getUserName();

		String userName = layoutCacheModel.userName;

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

		Date createDate = getCreateDate();

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

		Date modifiedDate = getModifiedDate();

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

		layoutCacheModel.privateLayout = getPrivateLayout();

		layoutCacheModel.layoutId = getLayoutId();

		layoutCacheModel.parentLayoutId = getParentLayoutId();

		layoutCacheModel.name = getName();

		String name = layoutCacheModel.name;

		if ((name != null) && (name.length() == 0)) {
			layoutCacheModel.name = null;
		}

		layoutCacheModel.title = getTitle();

		String title = layoutCacheModel.title;

		if ((title != null) && (title.length() == 0)) {
			layoutCacheModel.title = null;
		}

		layoutCacheModel.description = getDescription();

		String description = layoutCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			layoutCacheModel.description = null;
		}

		layoutCacheModel.keywords = getKeywords();

		String keywords = layoutCacheModel.keywords;

		if ((keywords != null) && (keywords.length() == 0)) {
			layoutCacheModel.keywords = null;
		}

		layoutCacheModel.robots = getRobots();

		String robots = layoutCacheModel.robots;

		if ((robots != null) && (robots.length() == 0)) {
			layoutCacheModel.robots = null;
		}

		layoutCacheModel.type = getType();

		String type = layoutCacheModel.type;

		if ((type != null) && (type.length() == 0)) {
			layoutCacheModel.type = null;
		}

		layoutCacheModel.typeSettings = getTypeSettings();

		String typeSettings = layoutCacheModel.typeSettings;

		if ((typeSettings != null) && (typeSettings.length() == 0)) {
			layoutCacheModel.typeSettings = null;
		}

		layoutCacheModel.hidden = getHidden();

		layoutCacheModel.friendlyURL = getFriendlyURL();

		String friendlyURL = layoutCacheModel.friendlyURL;

		if ((friendlyURL != null) && (friendlyURL.length() == 0)) {
			layoutCacheModel.friendlyURL = null;
		}

		layoutCacheModel.iconImage = getIconImage();

		layoutCacheModel.iconImageId = getIconImageId();

		layoutCacheModel.themeId = getThemeId();

		String themeId = layoutCacheModel.themeId;

		if ((themeId != null) && (themeId.length() == 0)) {
			layoutCacheModel.themeId = null;
		}

		layoutCacheModel.colorSchemeId = getColorSchemeId();

		String colorSchemeId = layoutCacheModel.colorSchemeId;

		if ((colorSchemeId != null) && (colorSchemeId.length() == 0)) {
			layoutCacheModel.colorSchemeId = null;
		}

		layoutCacheModel.wapThemeId = getWapThemeId();

		String wapThemeId = layoutCacheModel.wapThemeId;

		if ((wapThemeId != null) && (wapThemeId.length() == 0)) {
			layoutCacheModel.wapThemeId = null;
		}

		layoutCacheModel.wapColorSchemeId = getWapColorSchemeId();

		String wapColorSchemeId = layoutCacheModel.wapColorSchemeId;

		if ((wapColorSchemeId != null) && (wapColorSchemeId.length() == 0)) {
			layoutCacheModel.wapColorSchemeId = null;
		}

		layoutCacheModel.css = getCss();

		String css = layoutCacheModel.css;

		if ((css != null) && (css.length() == 0)) {
			layoutCacheModel.css = null;
		}

		layoutCacheModel.priority = getPriority();

		layoutCacheModel.layoutPrototypeUuid = getLayoutPrototypeUuid();

		String layoutPrototypeUuid = layoutCacheModel.layoutPrototypeUuid;

		if ((layoutPrototypeUuid != null) &&
				(layoutPrototypeUuid.length() == 0)) {
			layoutCacheModel.layoutPrototypeUuid = null;
		}

		layoutCacheModel.layoutPrototypeLinkEnabled = getLayoutPrototypeLinkEnabled();

		layoutCacheModel.sourcePrototypeLayoutUuid = getSourcePrototypeLayoutUuid();

		String sourcePrototypeLayoutUuid = layoutCacheModel.sourcePrototypeLayoutUuid;

		if ((sourcePrototypeLayoutUuid != null) &&
				(sourcePrototypeLayoutUuid.length() == 0)) {
			layoutCacheModel.sourcePrototypeLayoutUuid = null;
		}

		return layoutCacheModel;
	}

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

		sb.append("{uuid=");
		sb.append(getUuid());
		sb.append(", plid=");
		sb.append(getPlid());
		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(", privateLayout=");
		sb.append(getPrivateLayout());
		sb.append(", layoutId=");
		sb.append(getLayoutId());
		sb.append(", parentLayoutId=");
		sb.append(getParentLayoutId());
		sb.append(", name=");
		sb.append(getName());
		sb.append(", title=");
		sb.append(getTitle());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", keywords=");
		sb.append(getKeywords());
		sb.append(", robots=");
		sb.append(getRobots());
		sb.append(", type=");
		sb.append(getType());
		sb.append(", typeSettings=");
		sb.append(getTypeSettings());
		sb.append(", hidden=");
		sb.append(getHidden());
		sb.append(", friendlyURL=");
		sb.append(getFriendlyURL());
		sb.append(", iconImage=");
		sb.append(getIconImage());
		sb.append(", iconImageId=");
		sb.append(getIconImageId());
		sb.append(", themeId=");
		sb.append(getThemeId());
		sb.append(", colorSchemeId=");
		sb.append(getColorSchemeId());
		sb.append(", wapThemeId=");
		sb.append(getWapThemeId());
		sb.append(", wapColorSchemeId=");
		sb.append(getWapColorSchemeId());
		sb.append(", css=");
		sb.append(getCss());
		sb.append(", priority=");
		sb.append(getPriority());
		sb.append(", layoutPrototypeUuid=");
		sb.append(getLayoutPrototypeUuid());
		sb.append(", layoutPrototypeLinkEnabled=");
		sb.append(getLayoutPrototypeLinkEnabled());
		sb.append(", sourcePrototypeLayoutUuid=");
		sb.append(getSourcePrototypeLayoutUuid());
		sb.append("}");

		return sb.toString();
	}

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

		sb.append("<model><model-name>");
		sb.append("com.liferay.portal.model.Layout");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>uuid</column-name><column-value><![CDATA[");
		sb.append(getUuid());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>plid</column-name><column-value><![CDATA[");
		sb.append(getPlid());
		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>privateLayout</column-name><column-value><![CDATA[");
		sb.append(getPrivateLayout());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>layoutId</column-name><column-value><![CDATA[");
		sb.append(getLayoutId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>parentLayoutId</column-name><column-value><![CDATA[");
		sb.append(getParentLayoutId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>title</column-name><column-value><![CDATA[");
		sb.append(getTitle());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>keywords</column-name><column-value><![CDATA[");
		sb.append(getKeywords());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>robots</column-name><column-value><![CDATA[");
		sb.append(getRobots());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>type</column-name><column-value><![CDATA[");
		sb.append(getType());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>typeSettings</column-name><column-value><![CDATA[");
		sb.append(getTypeSettings());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>hidden</column-name><column-value><![CDATA[");
		sb.append(getHidden());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>friendlyURL</column-name><column-value><![CDATA[");
		sb.append(getFriendlyURL());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>iconImage</column-name><column-value><![CDATA[");
		sb.append(getIconImage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>iconImageId</column-name><column-value><![CDATA[");
		sb.append(getIconImageId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>themeId</column-name><column-value><![CDATA[");
		sb.append(getThemeId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>colorSchemeId</column-name><column-value><![CDATA[");
		sb.append(getColorSchemeId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>wapThemeId</column-name><column-value><![CDATA[");
		sb.append(getWapThemeId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>wapColorSchemeId</column-name><column-value><![CDATA[");
		sb.append(getWapColorSchemeId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>css</column-name><column-value><![CDATA[");
		sb.append(getCss());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>priority</column-name><column-value><![CDATA[");
		sb.append(getPriority());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>layoutPrototypeUuid</column-name><column-value><![CDATA[");
		sb.append(getLayoutPrototypeUuid());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>layoutPrototypeLinkEnabled</column-name><column-value><![CDATA[");
		sb.append(getLayoutPrototypeLinkEnabled());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>sourcePrototypeLayoutUuid</column-name><column-value><![CDATA[");
		sb.append(getSourcePrototypeLayoutUuid());
		sb.append("]]></column-value></column>");

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

		return sb.toString();
	}

	private static ClassLoader _classLoader = Layout.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] { Layout.class };
	private String _uuid;
	private String _originalUuid;
	private long _plid;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _companyId;
	private long _originalCompanyId;
	private boolean _setOriginalCompanyId;
	private long _userId;
	private String _userUuid;
	private String _userName;
	private Date _createDate;
	private Date _modifiedDate;
	private boolean _privateLayout;
	private boolean _originalPrivateLayout;
	private boolean _setOriginalPrivateLayout;
	private long _layoutId;
	private long _originalLayoutId;
	private boolean _setOriginalLayoutId;
	private long _parentLayoutId;
	private long _originalParentLayoutId;
	private boolean _setOriginalParentLayoutId;
	private String _name;
	private String _nameCurrentLanguageId;
	private String _title;
	private String _titleCurrentLanguageId;
	private String _description;
	private String _descriptionCurrentLanguageId;
	private String _keywords;
	private String _keywordsCurrentLanguageId;
	private String _robots;
	private String _robotsCurrentLanguageId;
	private String _type;
	private String _originalType;
	private String _typeSettings;
	private boolean _hidden;
	private String _friendlyURL;
	private String _originalFriendlyURL;
	private boolean _iconImage;
	private long _iconImageId;
	private long _originalIconImageId;
	private boolean _setOriginalIconImageId;
	private String _themeId;
	private String _colorSchemeId;
	private String _wapThemeId;
	private String _wapColorSchemeId;
	private String _css;
	private int _priority;
	private int _originalPriority;
	private boolean _setOriginalPriority;
	private String _layoutPrototypeUuid;
	private String _originalLayoutPrototypeUuid;
	private boolean _layoutPrototypeLinkEnabled;
	private String _sourcePrototypeLayoutUuid;
	private String _originalSourcePrototypeLayoutUuid;
	private long _columnBitmask;
	private Layout _escapedModel;
}