001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $
020 */
021
022package org.nuxeo.ecm.platform.picture.api;
023
024import java.io.Serializable;
025import java.util.HashMap;
026import java.util.Map;
027
028import org.nuxeo.ecm.core.api.Blob;
029
030public class PictureViewImpl implements PictureView {
031
032    int width;
033
034    int height;
035
036    String title;
037
038    String description;
039
040    String tag;
041
042    String filename;
043
044    Blob content;
045
046    Blob blob;
047
048    ImageInfo imageInfo;
049
050    /**
051     * @since 5.7
052     */
053    public PictureViewImpl() {
054    }
055
056    /**
057     * @since 5.7
058     */
059    public PictureViewImpl(Map<String, Serializable> m) {
060        title = (String) m.get(PictureView.FIELD_TITLE);
061        description = (String) m.get(PictureView.FIELD_DESCRIPTION);
062        tag = (String) m.get(PictureView.FIELD_TAG);
063        filename = (String) m.get(PictureView.FIELD_FILENAME);
064        blob = (Blob) m.get(PictureView.FIELD_CONTENT);
065        imageInfo = (ImageInfo) m.get(PictureView.FIELD_INFO);
066
067        Integer w = (Integer) m.get(PictureView.FIELD_WIDTH);
068        if (w != null) {
069            width = w;
070        }
071        Integer h = (Integer) m.get(PictureView.FIELD_HEIGHT);
072        if (h != null) {
073            height = h;
074        }
075
076    }
077
078    @Override
079    public int getWidth() {
080        return width;
081    }
082
083    @Override
084    public void setWidth(int width) {
085        this.width = width;
086    }
087
088    @Override
089    public String getTitle() {
090        return title;
091    }
092
093    @Override
094    public void setTitle(String title) {
095        this.title = title;
096    }
097
098    @Override
099    public String getDescription() {
100        return description;
101    }
102
103    @Override
104    public void setDescription(String description) {
105        this.description = description;
106    }
107
108    @Override
109    public String getTag() {
110        return tag;
111    }
112
113    @Override
114    public void setTag(String tag) {
115        this.tag = tag;
116    }
117
118    @Override
119    public String getFilename() {
120        return filename;
121    }
122
123    @Override
124    public void setFilename(String filename) {
125        this.filename = filename;
126    }
127
128    @Override
129    public Blob getContent() {
130        return blob;
131    }
132
133    @Override
134    public int getHeight() {
135        return height;
136    }
137
138    @Override
139    public void setHeight(int height) {
140        this.height = height;
141    }
142
143    @Override
144    public Blob getBlob() {
145        return blob;
146    }
147
148    @Override
149    public void setBlob(Blob blob) {
150        this.blob = blob;
151    }
152
153    @Override
154    public ImageInfo getImageInfo() {
155        return imageInfo;
156    }
157
158    @Override
159    public void setImageInfo(ImageInfo info) {
160        this.imageInfo = info;
161    }
162
163    @Override
164    public Map<String, Serializable> asMap() {
165        Map<String, Serializable> m = new HashMap<String, Serializable>();
166        m.put(PictureView.FIELD_TITLE, getTitle());
167        m.put(PictureView.FIELD_DESCRIPTION, getDescription());
168        m.put(PictureView.FIELD_TAG, getTag());
169        m.put(PictureView.FIELD_HEIGHT, getHeight());
170        m.put(PictureView.FIELD_WIDTH, getWidth());
171        m.put(PictureView.FIELD_FILENAME, getFilename());
172        m.put(PictureView.FIELD_CONTENT, (Serializable) blob);
173        m.put(PictureView.FIELD_INFO, (Serializable) imageInfo.toMap());
174        return m;
175    }
176}