--- /dev/null
+/**
+ * Copyright (c) 2000-2012 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.pentila.entSavoie.internalMessaging.model;
+
+import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
+import com.liferay.portal.kernel.exception.SystemException;
+import com.liferay.portal.kernel.util.StringBundler;
+import com.liferay.portal.model.BaseModel;
+import com.liferay.portal.model.impl.BaseModelImpl;
+import com.liferay.portal.util.PortalUtil;
+
+import com.pentila.entSavoie.internalMessaging.service.AttachmentLocalServiceUtil;
+
+import java.io.Serializable;
+
+import java.lang.reflect.Proxy;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Igor Barma - Mathieu Amblard
+ */
+public class AttachmentClp extends BaseModelImpl<Attachment>
+ implements Attachment {
+ public AttachmentClp() {
+ }
+
+ public Class<?> getModelClass() {
+ return Attachment.class;
+ }
+
+ public String getModelClassName() {
+ return Attachment.class.getName();
+ }
+
+ public long getPrimaryKey() {
+ return _attachmentId;
+ }
+
+ public void setPrimaryKey(long primaryKey) {
+ setAttachmentId(primaryKey);
+ }
+
+ public Serializable getPrimaryKeyObj() {
+ return new Long(_attachmentId);
+ }
+
+ public void setPrimaryKeyObj(Serializable primaryKeyObj) {
+ setPrimaryKey(((Long)primaryKeyObj).longValue());
+ }
+
+ @Override
+ public Map<String, Object> getModelAttributes() {
+ Map<String, Object> attributes = new HashMap<String, Object>();
+
+ attributes.put("attachmentId", getAttachmentId());
+ attributes.put("companyId", getCompanyId());
+ attributes.put("userId", getUserId());
+ attributes.put("accountId", getAccountId());
+ attributes.put("folderId", getFolderId());
+ attributes.put("messageId", getMessageId());
+ attributes.put("contentPath", getContentPath());
+ attributes.put("fileName", getFileName());
+ attributes.put("size", getSize());
+
+ return attributes;
+ }
+
+ @Override
+ public void setModelAttributes(Map<String, Object> attributes) {
+ Long attachmentId = (Long)attributes.get("attachmentId");
+
+ if (attachmentId != null) {
+ setAttachmentId(attachmentId);
+ }
+
+ Long companyId = (Long)attributes.get("companyId");
+
+ if (companyId != null) {
+ setCompanyId(companyId);
+ }
+
+ Long userId = (Long)attributes.get("userId");
+
+ if (userId != null) {
+ setUserId(userId);
+ }
+
+ Long accountId = (Long)attributes.get("accountId");
+
+ if (accountId != null) {
+ setAccountId(accountId);
+ }
+
+ Long folderId = (Long)attributes.get("folderId");
+
+ if (folderId != null) {
+ setFolderId(folderId);
+ }
+
+ Long messageId = (Long)attributes.get("messageId");
+
+ if (messageId != null) {
+ setMessageId(messageId);
+ }
+
+ String contentPath = (String)attributes.get("contentPath");
+
+ if (contentPath != null) {
+ setContentPath(contentPath);
+ }
+
+ String fileName = (String)attributes.get("fileName");
+
+ if (fileName != null) {
+ setFileName(fileName);
+ }
+
+ Long size = (Long)attributes.get("size");
+
+ if (size != null) {
+ setSize(size);
+ }
+ }
+
+ public long getAttachmentId() {
+ return _attachmentId;
+ }
+
+ public void setAttachmentId(long attachmentId) {
+ _attachmentId = attachmentId;
+ }
+
+ public long getCompanyId() {
+ return _companyId;
+ }
+
+ public void setCompanyId(long companyId) {
+ _companyId = companyId;
+ }
+
+ public long getUserId() {
+ return _userId;
+ }
+
+ public void setUserId(long userId) {
+ _userId = userId;
+ }
+
+ public String getUserUuid() throws SystemException {
+ return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
+ }
+
+ public void setUserUuid(String userUuid) {
+ _userUuid = userUuid;
+ }
+
+ public long getAccountId() {
+ return _accountId;
+ }
+
+ public void setAccountId(long accountId) {
+ _accountId = accountId;
+ }
+
+ public long getFolderId() {
+ return _folderId;
+ }
+
+ public void setFolderId(long folderId) {
+ _folderId = folderId;
+ }
+
+ public long getMessageId() {
+ return _messageId;
+ }
+
+ public void setMessageId(long messageId) {
+ _messageId = messageId;
+ }
+
+ public String getContentPath() {
+ return _contentPath;
+ }
+
+ public void setContentPath(String contentPath) {
+ _contentPath = contentPath;
+ }
+
+ public String getFileName() {
+ return _fileName;
+ }
+
+ public void setFileName(String fileName) {
+ _fileName = fileName;
+ }
+
+ public long getSize() {
+ return _size;
+ }
+
+ public void setSize(long size) {
+ _size = size;
+ }
+
+ public BaseModel<?> getAttachmentRemoteModel() {
+ return _attachmentRemoteModel;
+ }
+
+ public void setAttachmentRemoteModel(BaseModel<?> attachmentRemoteModel) {
+ _attachmentRemoteModel = attachmentRemoteModel;
+ }
+
+ public void persist() throws SystemException {
+ if (this.isNew()) {
+ AttachmentLocalServiceUtil.addAttachment(this);
+ }
+ else {
+ AttachmentLocalServiceUtil.updateAttachment(this);
+ }
+ }
+
+ @Override
+ public Attachment toEscapedModel() {
+ return (Attachment)Proxy.newProxyInstance(Attachment.class.getClassLoader(),
+ new Class[] { Attachment.class }, new AutoEscapeBeanHandler(this));
+ }
+
+ @Override
+ public Object clone() {
+ AttachmentClp clone = new AttachmentClp();
+
+ clone.setAttachmentId(getAttachmentId());
+ clone.setCompanyId(getCompanyId());
+ clone.setUserId(getUserId());
+ clone.setAccountId(getAccountId());
+ clone.setFolderId(getFolderId());
+ clone.setMessageId(getMessageId());
+ clone.setContentPath(getContentPath());
+ clone.setFileName(getFileName());
+ clone.setSize(getSize());
+
+ return clone;
+ }
+
+ public int compareTo(Attachment attachment) {
+ long primaryKey = attachment.getPrimaryKey();
+
+ if (getPrimaryKey() < primaryKey) {
+ return -1;
+ }
+ else if (getPrimaryKey() > primaryKey) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+
+ AttachmentClp attachment = null;
+
+ try {
+ attachment = (AttachmentClp)obj;
+ }
+ catch (ClassCastException cce) {
+ return false;
+ }
+
+ long primaryKey = attachment.getPrimaryKey();
+
+ if (getPrimaryKey() == primaryKey) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return (int)getPrimaryKey();
+ }
+
+ @Override
+ public String toString() {
+ StringBundler sb = new StringBundler(19);
+
+ sb.append("{attachmentId=");
+ sb.append(getAttachmentId());
+ sb.append(", companyId=");
+ sb.append(getCompanyId());
+ sb.append(", userId=");
+ sb.append(getUserId());
+ sb.append(", accountId=");
+ sb.append(getAccountId());
+ sb.append(", folderId=");
+ sb.append(getFolderId());
+ sb.append(", messageId=");
+ sb.append(getMessageId());
+ sb.append(", contentPath=");
+ sb.append(getContentPath());
+ sb.append(", fileName=");
+ sb.append(getFileName());
+ sb.append(", size=");
+ sb.append(getSize());
+ sb.append("}");
+
+ return sb.toString();
+ }
+
+ public String toXmlString() {
+ StringBundler sb = new StringBundler(31);
+
+ sb.append("<model><model-name>");
+ sb.append("com.pentila.entSavoie.internalMessaging.model.Attachment");
+ sb.append("</model-name>");
+
+ sb.append(
+ "<column><column-name>attachmentId</column-name><column-value><![CDATA[");
+ sb.append(getAttachmentId());
+ 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>accountId</column-name><column-value><![CDATA[");
+ sb.append(getAccountId());
+ sb.append("]]></column-value></column>");
+ sb.append(
+ "<column><column-name>folderId</column-name><column-value><![CDATA[");
+ sb.append(getFolderId());
+ sb.append("]]></column-value></column>");
+ sb.append(
+ "<column><column-name>messageId</column-name><column-value><![CDATA[");
+ sb.append(getMessageId());
+ sb.append("]]></column-value></column>");
+ sb.append(
+ "<column><column-name>contentPath</column-name><column-value><![CDATA[");
+ sb.append(getContentPath());
+ sb.append("]]></column-value></column>");
+ sb.append(
+ "<column><column-name>fileName</column-name><column-value><![CDATA[");
+ sb.append(getFileName());
+ sb.append("]]></column-value></column>");
+ sb.append(
+ "<column><column-name>size</column-name><column-value><![CDATA[");
+ sb.append(getSize());
+ sb.append("]]></column-value></column>");
+
+ sb.append("</model>");
+
+ return sb.toString();
+ }
+
+ private long _attachmentId;
+ private long _companyId;
+ private long _userId;
+ private String _userUuid;
+ private long _accountId;
+ private long _folderId;
+ private long _messageId;
+ private String _contentPath;
+ private String _fileName;
+ private long _size;
+ private BaseModel<?> _attachmentRemoteModel;
+}
\ No newline at end of file