4 * Copyright (C) 2001, 2002, 2003 The Mir-coders group
6 * This file is part of Mir.
8 * Mir is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Mir is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Mir; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * In addition, as a special exception, The Mir-coders gives permission to link
23 * the code of this program with any library licensed under the Apache Software License,
24 * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
25 * (or with modified versions of the above that use the same license as the above),
26 * and distribute linked combinations including the two. You must obey the
27 * GNU General Public License in all respects for all of the code used other than
28 * the above mentioned libraries. If you modify this file, you may extend this
29 * exception to your version of the file, but you are not obligated to do so.
30 * If you do not wish to do so, delete this exception statement from your version.
32 package mir.core.model;
34 import java.io.Serializable;
35 import java.sql.Connection;
36 import java.sql.SQLException;
38 import net.sf.hibernate.CallbackException;
39 import net.sf.hibernate.HibernateException;
40 import net.sf.hibernate.Lifecycle;
41 import net.sf.hibernate.Session;
43 import org.apache.commons.lang.builder.ToStringBuilder;
44 import org.postgresql.PGConnection;
45 import org.postgresql.largeobject.LargeObject;
46 import org.postgresql.largeobject.LargeObjectManager;
52 * @version $Id: Image.java,v 1.3 2003/08/17 19:13:19 idfx Exp $
54 public class Image extends UploadedMedia
55 implements Serializable, Lifecycle {
57 /** nullable persistent field */
58 private int imageData;
60 /** nullable persistent field */
63 /** nullable persistent field */
66 /** nullable persistent field */
67 private short imgWidth;
69 /** nullable persistent field */
70 private short imgHeight;
72 /** persistent field */
73 private short imgFormat;
75 /** persistent field */
76 private short imgLayout;
78 /** persistent field */
79 private short imgType;
81 /** persistent field */
82 private short imgColor;
84 /** nullable persistent field */
85 private short iconWidth;
87 /** nullable persistent field */
88 private short iconHeight;
90 /** default constructor */
94 public int getImageData() {
95 return this.imageData;
98 public void setImageData(int imageData) {
99 this.imageData = imageData;
102 public int getIconData() {
103 return this.iconData;
106 public void setIconData(int iconData) {
107 this.iconData = iconData;
110 public java.lang.String getYear() {
114 public void setYear(java.lang.String year) {
118 public short getImgWidth() {
119 return this.imgWidth;
122 public void setImgWidth(short imgWidth) {
123 this.imgWidth = imgWidth;
126 public short getImgHeight() {
127 return this.imgHeight;
130 public void setImgHeight(short imgHeight) {
131 this.imgHeight = imgHeight;
134 public short getImgFormat() {
135 return this.imgFormat;
138 public void setImgFormat(short imgFormat) {
139 this.imgFormat = imgFormat;
142 public short getImgLayout() {
143 return this.imgLayout;
146 public void setImgLayout(short imgLayout) {
147 this.imgLayout = imgLayout;
150 public short getImgType() {
154 public void setImgType(short imgType) {
155 this.imgType = imgType;
158 public short getImgColor() {
159 return this.imgColor;
162 public void setImgColor(short imgColor) {
163 this.imgColor = imgColor;
166 public short getIconWidth() {
167 return this.iconWidth;
170 public void setIconWidth(short iconWidth) {
171 this.iconWidth = iconWidth;
174 public short getIconHeight() {
175 return this.iconHeight;
178 public void setIconHeight(short iconHeight) {
179 this.iconHeight = iconHeight;
182 public String toString() {
183 return new ToStringBuilder(this)
184 .append("id", getId())
189 * @see net.sf.hibernate.Lifecycle#onSave(net.sf.hibernate.Session)
191 public boolean onSave(Session arg0) throws CallbackException {
192 // TODO Auto-generated method stub
197 * @see net.sf.hibernate.Lifecycle#onUpdate(net.sf.hibernate.Session)
199 public boolean onUpdate(Session arg0) throws CallbackException {
200 // TODO Auto-generated method stub
205 * @see net.sf.hibernate.Lifecycle#onDelete(net.sf.hibernate.Session)
207 public boolean onDelete(Session arg0) throws CallbackException {
208 // TODO Auto-generated method stub
213 * @see net.sf.hibernate.Lifecycle#onLoad(net.sf.hibernate.Session, java.io.Serializable)
215 public void onLoad(Session session, Serializable arg1) {
216 // TODO Auto-generated method stub
217 System.out.println("hello: ");
219 Connection connection = session.connection();
220 if(connection instanceof PGConnection){
221 PGConnection pgcon = (PGConnection)connection;
222 LargeObjectManager largeObjectManager = pgcon.getLargeObjectAPI();
223 LargeObject image = largeObjectManager.open(getImageData());
224 System.out.println("juppii" + image.size() + " " + this.getMediaType().getId());
226 } catch (HibernateException e) {
227 // TODO Auto-generated catch block
229 } catch (SQLException e) {
230 // TODO Auto-generated catch block