/** * 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 de.uhh.l2g.plugins.migration.model; import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.util.ProxyUtil; import com.liferay.portal.kernel.util.StringBundler; import com.liferay.portal.model.BaseModel; import com.liferay.portal.model.impl.BaseModelImpl; import de.uhh.l2g.plugins.migration.service.ClpSerializer; import de.uhh.l2g.plugins.migration.service.LegacyLastVideoListLocalServiceUtil; import java.io.Serializable; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; /** * @author unihh */ public class LegacyLastVideoListClp extends BaseModelImpl<LegacyLastVideoList> implements LegacyLastVideoList { public LegacyLastVideoListClp() { } @Override public Class<?> getModelClass() { return LegacyLastVideoList.class; } @Override public String getModelClassName() { return LegacyLastVideoList.class.getName(); } @Override public int getPrimaryKey() { return _id; } @Override public void setPrimaryKey(int primaryKey) { setId(primaryKey); } @Override public Serializable getPrimaryKeyObj() { return _id; } @Override public void setPrimaryKeyObj(Serializable primaryKeyObj) { setPrimaryKey(((Integer)primaryKeyObj).intValue()); } @Override public Map<String, Object> getModelAttributes() { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("id", getId()); attributes.put("videoId", getVideoId()); return attributes; } @Override public void setModelAttributes(Map<String, Object> attributes) { Integer id = (Integer)attributes.get("id"); if (id != null) { setId(id); } Long videoId = (Long)attributes.get("videoId"); if (videoId != null) { setVideoId(videoId); } } @Override public int getId() { return _id; } @Override public void setId(int id) { _id = id; if (_legacyLastVideoListRemoteModel != null) { try { Class<?> clazz = _legacyLastVideoListRemoteModel.getClass(); Method method = clazz.getMethod("setId", int.class); method.invoke(_legacyLastVideoListRemoteModel, id); } catch (Exception e) { throw new UnsupportedOperationException(e); } } } @Override public long getVideoId() { return _videoId; } @Override public void setVideoId(long videoId) { _videoId = videoId; if (_legacyLastVideoListRemoteModel != null) { try { Class<?> clazz = _legacyLastVideoListRemoteModel.getClass(); Method method = clazz.getMethod("setVideoId", long.class); method.invoke(_legacyLastVideoListRemoteModel, videoId); } catch (Exception e) { throw new UnsupportedOperationException(e); } } } public BaseModel<?> getLegacyLastVideoListRemoteModel() { return _legacyLastVideoListRemoteModel; } public void setLegacyLastVideoListRemoteModel( BaseModel<?> legacyLastVideoListRemoteModel) { _legacyLastVideoListRemoteModel = legacyLastVideoListRemoteModel; } public Object invokeOnRemoteModel(String methodName, Class<?>[] parameterTypes, Object[] parameterValues) throws Exception { Object[] remoteParameterValues = new Object[parameterValues.length]; for (int i = 0; i < parameterValues.length; i++) { if (parameterValues[i] != null) { remoteParameterValues[i] = ClpSerializer.translateInput(parameterValues[i]); } } Class<?> remoteModelClass = _legacyLastVideoListRemoteModel.getClass(); ClassLoader remoteModelClassLoader = remoteModelClass.getClassLoader(); Class<?>[] remoteParameterTypes = new Class[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { if (parameterTypes[i].isPrimitive()) { remoteParameterTypes[i] = parameterTypes[i]; } else { String parameterTypeName = parameterTypes[i].getName(); remoteParameterTypes[i] = remoteModelClassLoader.loadClass(parameterTypeName); } } Method method = remoteModelClass.getMethod(methodName, remoteParameterTypes); Object returnValue = method.invoke(_legacyLastVideoListRemoteModel, remoteParameterValues); if (returnValue != null) { returnValue = ClpSerializer.translateOutput(returnValue); } return returnValue; } @Override public void persist() throws SystemException { if (this.isNew()) { LegacyLastVideoListLocalServiceUtil.addLegacyLastVideoList(this); } else { LegacyLastVideoListLocalServiceUtil.updateLegacyLastVideoList(this); } } @Override public LegacyLastVideoList toEscapedModel() { return (LegacyLastVideoList)ProxyUtil.newProxyInstance(LegacyLastVideoList.class.getClassLoader(), new Class[] { LegacyLastVideoList.class }, new AutoEscapeBeanHandler(this)); } @Override public Object clone() { LegacyLastVideoListClp clone = new LegacyLastVideoListClp(); clone.setId(getId()); clone.setVideoId(getVideoId()); return clone; } @Override public int compareTo(LegacyLastVideoList legacyLastVideoList) { int primaryKey = legacyLastVideoList.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 LegacyLastVideoListClp)) { return false; } LegacyLastVideoListClp legacyLastVideoList = (LegacyLastVideoListClp)obj; int primaryKey = legacyLastVideoList.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } } public Class<?> getClpSerializerClass() { return _clpSerializerClass; } @Override public int hashCode() { return getPrimaryKey(); } @Override public String toString() { StringBundler sb = new StringBundler(5); sb.append("{id="); sb.append(getId()); sb.append(", videoId="); sb.append(getVideoId()); sb.append("}"); return sb.toString(); } @Override public String toXmlString() { StringBundler sb = new StringBundler(10); sb.append("<model><model-name>"); sb.append("de.uhh.l2g.plugins.migration.model.LegacyLastVideoList"); sb.append("</model-name>"); sb.append( "<column><column-name>id</column-name><column-value><![CDATA["); sb.append(getId()); sb.append("]]></column-value></column>"); sb.append( "<column><column-name>videoId</column-name><column-value><![CDATA["); sb.append(getVideoId()); sb.append("]]></column-value></column>"); sb.append("</model>"); return sb.toString(); } private int _id; private long _videoId; private BaseModel<?> _legacyLastVideoListRemoteModel; private Class<?> _clpSerializerClass = de.uhh.l2g.plugins.migration.service.ClpSerializer.class; }