All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.document.library.content.model.impl.DLContentModelImpl Maven / Gradle / Ivy

There is a newer version: 4.0.39
Show newest version
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

package com.liferay.document.library.content.model.impl;

import com.liferay.document.library.content.model.DLContent;
import com.liferay.document.library.content.model.DLContentDataBlobModel;
import com.liferay.document.library.content.model.DLContentModel;
import com.liferay.document.library.content.service.DLContentLocalServiceUtil;
import com.liferay.expando.kernel.model.ExpandoBridge;
import com.liferay.expando.kernel.util.ExpandoBridgeFactoryUtil;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.model.CacheModel;
import com.liferay.portal.kernel.model.ModelWrapper;
import com.liferay.portal.kernel.model.impl.BaseModelImpl;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;

import java.io.Serializable;

import java.lang.reflect.InvocationHandler;

import java.sql.Blob;
import java.sql.Types;

import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiConsumer;
import java.util.function.Function;

/**
 * The base model implementation for the DLContent service. Represents a row in the "DLContent" database table, with each column mapped to a property of this class.
 *
 * 

* This implementation and its corresponding interface DLContentModel exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DLContentImpl}. *

* * @author Brian Wing Shun Chan * @see DLContentImpl * @generated */ public class DLContentModelImpl extends BaseModelImpl implements DLContentModel { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. All methods that expect a document library content model instance should use the DLContent interface instead. */ public static final String TABLE_NAME = "DLContent"; public static final Object[][] TABLE_COLUMNS = { {"mvccVersion", Types.BIGINT}, {"ctCollectionId", Types.BIGINT}, {"contentId", Types.BIGINT}, {"groupId", Types.BIGINT}, {"companyId", Types.BIGINT}, {"repositoryId", Types.BIGINT}, {"path_", Types.VARCHAR}, {"version", Types.VARCHAR}, {"data_", Types.BLOB}, {"size_", Types.BIGINT} }; public static final Map TABLE_COLUMNS_MAP = new HashMap(); static { TABLE_COLUMNS_MAP.put("mvccVersion", Types.BIGINT); TABLE_COLUMNS_MAP.put("ctCollectionId", Types.BIGINT); TABLE_COLUMNS_MAP.put("contentId", Types.BIGINT); TABLE_COLUMNS_MAP.put("groupId", Types.BIGINT); TABLE_COLUMNS_MAP.put("companyId", Types.BIGINT); TABLE_COLUMNS_MAP.put("repositoryId", Types.BIGINT); TABLE_COLUMNS_MAP.put("path_", Types.VARCHAR); TABLE_COLUMNS_MAP.put("version", Types.VARCHAR); TABLE_COLUMNS_MAP.put("data_", Types.BLOB); TABLE_COLUMNS_MAP.put("size_", Types.BIGINT); } public static final String TABLE_SQL_CREATE = "create table DLContent (mvccVersion LONG default 0 not null,ctCollectionId LONG default 0 not null,contentId LONG not null,groupId LONG,companyId LONG,repositoryId LONG,path_ VARCHAR(255) null,version VARCHAR(75) null,data_ BLOB,size_ LONG,primary key (contentId, ctCollectionId))"; public static final String TABLE_SQL_DROP = "drop table DLContent"; public static final String ORDER_BY_JPQL = " ORDER BY dlContent.version DESC"; public static final String ORDER_BY_SQL = " ORDER BY DLContent.version DESC"; public static final String DATA_SOURCE = "liferayDataSource"; public static final String SESSION_FACTORY = "liferaySessionFactory"; public static final String TX_MANAGER = "liferayTransactionManager"; /** * @deprecated As of Athanasius (7.3.x), replaced by {@link #getColumnBitmask(String)} */ @Deprecated public static final long COMPANYID_COLUMN_BITMASK = 1L; /** * @deprecated As of Athanasius (7.3.x), replaced by {@link #getColumnBitmask(String)} */ @Deprecated public static final long PATH_COLUMN_BITMASK = 2L; /** * @deprecated As of Athanasius (7.3.x), replaced by {@link #getColumnBitmask(String)} */ @Deprecated public static final long REPOSITORYID_COLUMN_BITMASK = 4L; /** * @deprecated As of Athanasius (7.3.x), replaced by {@link #getColumnBitmask(String)} */ @Deprecated public static final long VERSION_COLUMN_BITMASK = 8L; /** * @deprecated As of Athanasius (7.3.x), with no direct replacement */ @Deprecated public static void setEntityCacheEnabled(boolean entityCacheEnabled) { } /** * @deprecated As of Athanasius (7.3.x), with no direct replacement */ @Deprecated public static void setFinderCacheEnabled(boolean finderCacheEnabled) { } public DLContentModelImpl() { } @Override public long getPrimaryKey() { return _contentId; } @Override public void setPrimaryKey(long primaryKey) { setContentId(primaryKey); } @Override public Serializable getPrimaryKeyObj() { return _contentId; } @Override public void setPrimaryKeyObj(Serializable primaryKeyObj) { setPrimaryKey(((Long)primaryKeyObj).longValue()); } @Override public Class getModelClass() { return DLContent.class; } @Override public String getModelClassName() { return DLContent.class.getName(); } @Override public Map getModelAttributes() { Map attributes = new HashMap(); Map> attributeGetterFunctions = getAttributeGetterFunctions(); for (Map.Entry> entry : attributeGetterFunctions.entrySet()) { String attributeName = entry.getKey(); Function attributeGetterFunction = entry.getValue(); attributes.put( attributeName, attributeGetterFunction.apply((DLContent)this)); } return attributes; } @Override public void setModelAttributes(Map attributes) { Map> attributeSetterBiConsumers = getAttributeSetterBiConsumers(); for (Map.Entry entry : attributes.entrySet()) { String attributeName = entry.getKey(); BiConsumer attributeSetterBiConsumer = attributeSetterBiConsumers.get(attributeName); if (attributeSetterBiConsumer != null) { attributeSetterBiConsumer.accept( (DLContent)this, entry.getValue()); } } } public Map> getAttributeGetterFunctions() { return AttributeGetterFunctionsHolder._attributeGetterFunctions; } public Map> getAttributeSetterBiConsumers() { return AttributeSetterBiConsumersHolder._attributeSetterBiConsumers; } private static class AttributeGetterFunctionsHolder { private static final Map> _attributeGetterFunctions; static { Map> attributeGetterFunctions = new LinkedHashMap>(); attributeGetterFunctions.put( "mvccVersion", DLContent::getMvccVersion); attributeGetterFunctions.put( "ctCollectionId", DLContent::getCtCollectionId); attributeGetterFunctions.put("contentId", DLContent::getContentId); attributeGetterFunctions.put("groupId", DLContent::getGroupId); attributeGetterFunctions.put("companyId", DLContent::getCompanyId); attributeGetterFunctions.put( "repositoryId", DLContent::getRepositoryId); attributeGetterFunctions.put("path", DLContent::getPath); attributeGetterFunctions.put("version", DLContent::getVersion); attributeGetterFunctions.put("data", DLContent::getData); attributeGetterFunctions.put("size", DLContent::getSize); _attributeGetterFunctions = Collections.unmodifiableMap( attributeGetterFunctions); } } private static class AttributeSetterBiConsumersHolder { private static final Map> _attributeSetterBiConsumers; static { Map> attributeSetterBiConsumers = new LinkedHashMap>(); attributeSetterBiConsumers.put( "mvccVersion", (BiConsumer)DLContent::setMvccVersion); attributeSetterBiConsumers.put( "ctCollectionId", (BiConsumer)DLContent::setCtCollectionId); attributeSetterBiConsumers.put( "contentId", (BiConsumer)DLContent::setContentId); attributeSetterBiConsumers.put( "groupId", (BiConsumer)DLContent::setGroupId); attributeSetterBiConsumers.put( "companyId", (BiConsumer)DLContent::setCompanyId); attributeSetterBiConsumers.put( "repositoryId", (BiConsumer)DLContent::setRepositoryId); attributeSetterBiConsumers.put( "path", (BiConsumer)DLContent::setPath); attributeSetterBiConsumers.put( "version", (BiConsumer)DLContent::setVersion); attributeSetterBiConsumers.put( "data", (BiConsumer)DLContent::setData); attributeSetterBiConsumers.put( "size", (BiConsumer)DLContent::setSize); _attributeSetterBiConsumers = Collections.unmodifiableMap( (Map)attributeSetterBiConsumers); } } @Override public long getMvccVersion() { return _mvccVersion; } @Override public void setMvccVersion(long mvccVersion) { if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } _mvccVersion = mvccVersion; } @Override public long getCtCollectionId() { return _ctCollectionId; } @Override public void setCtCollectionId(long ctCollectionId) { if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } _ctCollectionId = ctCollectionId; } @Override public long getContentId() { return _contentId; } @Override public void setContentId(long contentId) { if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } _contentId = contentId; } @Override public long getGroupId() { return _groupId; } @Override public void setGroupId(long groupId) { if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } _groupId = groupId; } @Override public long getCompanyId() { return _companyId; } @Override public void setCompanyId(long companyId) { if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } _companyId = companyId; } /** * @deprecated As of Athanasius (7.3.x), replaced by {@link * #getColumnOriginalValue(String)} */ @Deprecated public long getOriginalCompanyId() { return GetterUtil.getLong( this.getColumnOriginalValue("companyId")); } @Override public long getRepositoryId() { return _repositoryId; } @Override public void setRepositoryId(long repositoryId) { if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } _repositoryId = repositoryId; } /** * @deprecated As of Athanasius (7.3.x), replaced by {@link * #getColumnOriginalValue(String)} */ @Deprecated public long getOriginalRepositoryId() { return GetterUtil.getLong( this.getColumnOriginalValue("repositoryId")); } @Override public String getPath() { if (_path == null) { return ""; } else { return _path; } } @Override public void setPath(String path) { if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } _path = path; } /** * @deprecated As of Athanasius (7.3.x), replaced by {@link * #getColumnOriginalValue(String)} */ @Deprecated public String getOriginalPath() { return getColumnOriginalValue("path_"); } @Override public String getVersion() { if (_version == null) { return ""; } else { return _version; } } @Override public void setVersion(String version) { if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } _version = version; } /** * @deprecated As of Athanasius (7.3.x), replaced by {@link * #getColumnOriginalValue(String)} */ @Deprecated public String getOriginalVersion() { return getColumnOriginalValue("version"); } @Override public Blob getData() { if (_dataBlobModel == null) { try { _dataBlobModel = DLContentLocalServiceUtil.getDataBlobModel( getPrimaryKey()); } catch (Exception exception) { } } Blob blob = null; if (_dataBlobModel != null) { blob = _dataBlobModel.getDataBlob(); } return blob; } @Override public void setData(Blob data) { if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } if (_dataBlobModel == null) { _dataBlobModel = new DLContentDataBlobModel(getPrimaryKey(), data); } else { _dataBlobModel.setDataBlob(data); } } @Override public long getSize() { return _size; } @Override public void setSize(long size) { if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } _size = size; } public long getColumnBitmask() { if (_columnBitmask > 0) { return _columnBitmask; } if ((_columnOriginalValues == null) || (_columnOriginalValues == Collections.EMPTY_MAP)) { return 0; } for (Map.Entry entry : _columnOriginalValues.entrySet()) { if (!Objects.equals( entry.getValue(), getColumnValue(entry.getKey()))) { _columnBitmask |= _columnBitmasks.get(entry.getKey()); } } return _columnBitmask; } @Override public ExpandoBridge getExpandoBridge() { return ExpandoBridgeFactoryUtil.getExpandoBridge( getCompanyId(), DLContent.class.getName(), getPrimaryKey()); } @Override public void setExpandoBridgeAttributes(ServiceContext serviceContext) { ExpandoBridge expandoBridge = getExpandoBridge(); expandoBridge.setAttributes(serviceContext); } @Override public DLContent toEscapedModel() { if (_escapedModel == null) { Function escapedModelProxyProviderFunction = EscapedModelProxyProviderFunctionHolder. _escapedModelProxyProviderFunction; _escapedModel = escapedModelProxyProviderFunction.apply( new AutoEscapeBeanHandler(this)); } return _escapedModel; } @Override public Object clone() { DLContentImpl dlContentImpl = new DLContentImpl(); dlContentImpl.setMvccVersion(getMvccVersion()); dlContentImpl.setCtCollectionId(getCtCollectionId()); dlContentImpl.setContentId(getContentId()); dlContentImpl.setGroupId(getGroupId()); dlContentImpl.setCompanyId(getCompanyId()); dlContentImpl.setRepositoryId(getRepositoryId()); dlContentImpl.setPath(getPath()); dlContentImpl.setVersion(getVersion()); dlContentImpl.setSize(getSize()); dlContentImpl.resetOriginalValues(); return dlContentImpl; } @Override public DLContent cloneWithOriginalValues() { DLContentImpl dlContentImpl = new DLContentImpl(); dlContentImpl.setMvccVersion( this.getColumnOriginalValue("mvccVersion")); dlContentImpl.setCtCollectionId( this.getColumnOriginalValue("ctCollectionId")); dlContentImpl.setContentId( this.getColumnOriginalValue("contentId")); dlContentImpl.setGroupId(this.getColumnOriginalValue("groupId")); dlContentImpl.setCompanyId( this.getColumnOriginalValue("companyId")); dlContentImpl.setRepositoryId( this.getColumnOriginalValue("repositoryId")); dlContentImpl.setPath(this.getColumnOriginalValue("path_")); dlContentImpl.setVersion( this.getColumnOriginalValue("version")); dlContentImpl.setSize(this.getColumnOriginalValue("size_")); return dlContentImpl; } @Override public int compareTo(DLContent dlContent) { int value = 0; value = getVersion().compareTo(dlContent.getVersion()); value = value * -1; if (value != 0) { return value; } return 0; } @Override public boolean equals(Object object) { if (this == object) { return true; } if (!(object instanceof DLContent)) { return false; } DLContent dlContent = (DLContent)object; long primaryKey = dlContent.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } } @Override public int hashCode() { return (int)getPrimaryKey(); } /** * @deprecated As of Athanasius (7.3.x), with no direct replacement */ @Deprecated @Override public boolean isEntityCacheEnabled() { return true; } /** * @deprecated As of Athanasius (7.3.x), with no direct replacement */ @Deprecated @Override public boolean isFinderCacheEnabled() { return true; } @Override public void resetOriginalValues() { _columnOriginalValues = Collections.emptyMap(); _dataBlobModel = null; _columnBitmask = 0; } @Override public CacheModel toCacheModel() { DLContentCacheModel dlContentCacheModel = new DLContentCacheModel(); dlContentCacheModel.mvccVersion = getMvccVersion(); dlContentCacheModel.ctCollectionId = getCtCollectionId(); dlContentCacheModel.contentId = getContentId(); dlContentCacheModel.groupId = getGroupId(); dlContentCacheModel.companyId = getCompanyId(); dlContentCacheModel.repositoryId = getRepositoryId(); dlContentCacheModel.path = getPath(); String path = dlContentCacheModel.path; if ((path != null) && (path.length() == 0)) { dlContentCacheModel.path = null; } dlContentCacheModel.version = getVersion(); String version = dlContentCacheModel.version; if ((version != null) && (version.length() == 0)) { dlContentCacheModel.version = null; } dlContentCacheModel.size = getSize(); return dlContentCacheModel; } @Override public String toString() { StringBundler sb = new StringBundler(21); sb.append("{\"mvccVersion\": "); sb.append(getMvccVersion()); sb.append(", \"ctCollectionId\": "); sb.append(getCtCollectionId()); sb.append(", \"contentId\": "); sb.append(getContentId()); sb.append(", \"groupId\": "); sb.append(getGroupId()); sb.append(", \"companyId\": "); sb.append(getCompanyId()); sb.append(", \"repositoryId\": "); sb.append(getRepositoryId()); sb.append(", \"path\": "); sb.append("\"" + getPath() + "\""); sb.append(", \"version\": "); sb.append("\"" + getVersion() + "\""); sb.append(", \"size\": "); sb.append(getSize()); sb.append("}"); return sb.toString(); } private static class EscapedModelProxyProviderFunctionHolder { private static final Function _escapedModelProxyProviderFunction = ProxyUtil.getProxyProviderFunction( DLContent.class, ModelWrapper.class); } private long _mvccVersion; private long _ctCollectionId; private long _contentId; private long _groupId; private long _companyId; private long _repositoryId; private String _path; private String _version; private DLContentDataBlobModel _dataBlobModel; private long _size; public T getColumnValue(String columnName) { columnName = _attributeNames.getOrDefault(columnName, columnName); Function function = AttributeGetterFunctionsHolder._attributeGetterFunctions.get( columnName); if (function == null) { throw new IllegalArgumentException( "No attribute getter function found for " + columnName); } return (T)function.apply((DLContent)this); } public T getColumnOriginalValue(String columnName) { if (_columnOriginalValues == null) { return null; } if (_columnOriginalValues == Collections.EMPTY_MAP) { _setColumnOriginalValues(); } return (T)_columnOriginalValues.get(columnName); } private void _setColumnOriginalValues() { _columnOriginalValues = new HashMap(); _columnOriginalValues.put("mvccVersion", _mvccVersion); _columnOriginalValues.put("ctCollectionId", _ctCollectionId); _columnOriginalValues.put("contentId", _contentId); _columnOriginalValues.put("groupId", _groupId); _columnOriginalValues.put("companyId", _companyId); _columnOriginalValues.put("repositoryId", _repositoryId); _columnOriginalValues.put("path_", _path); _columnOriginalValues.put("version", _version); _columnOriginalValues.put("size_", _size); } private static final Map _attributeNames; static { Map attributeNames = new HashMap<>(); attributeNames.put("path_", "path"); attributeNames.put("data_", "data"); attributeNames.put("size_", "size"); _attributeNames = Collections.unmodifiableMap(attributeNames); } private transient Map _columnOriginalValues; public static long getColumnBitmask(String columnName) { return _columnBitmasks.get(columnName); } private static final Map _columnBitmasks; static { Map columnBitmasks = new HashMap<>(); columnBitmasks.put("mvccVersion", 1L); columnBitmasks.put("ctCollectionId", 2L); columnBitmasks.put("contentId", 4L); columnBitmasks.put("groupId", 8L); columnBitmasks.put("companyId", 16L); columnBitmasks.put("repositoryId", 32L); columnBitmasks.put("path_", 64L); columnBitmasks.put("version", 128L); columnBitmasks.put("data_", 256L); columnBitmasks.put("size_", 512L); _columnBitmasks = Collections.unmodifiableMap(columnBitmasks); } private long _columnBitmask; private DLContent _escapedModel; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy