001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.ade.galleries.shared;
029
030import org.opencms.gwt.shared.CmsListInfoBean;
031import org.opencms.gwt.shared.sort.I_CmsHasPath;
032import org.opencms.util.CmsStringUtil;
033
034/**
035 * A specific bean holding all info to be displayed in {@link org.opencms.ade.galleries.client.ui.CmsResultListItem}s.<p>
036 *
037 * @see org.opencms.ade.galleries.client.ui.CmsResultListItem
038 *
039 * @since 8.0.0
040 */
041public class CmsResultItemBean extends CmsListInfoBean implements I_CmsHasPath {
042
043    /** The structured id of the resource. */
044    private String m_clientId;
045
046    /** The formatted date of the last modification. */
047    private String m_dateLastModified;
048
049    /** The result item description. */
050    private String m_description;
051
052    /** The image dimensions. */
053    private String m_dimension;
054
055    /** Flag which indicates whether the resource for this result is a copy model. */
056    private boolean m_isCopyModel;
057
058    /** A flag which indicates whether this result item corresponds to a preset value in the editor.<p> */
059    private boolean m_isPreset;
060
061    /** The reason this resource may not be edited. Editable if empty. */
062    private String m_noEditReson;
063
064    /** The resource path as a unique resource id. */
065    private String m_path;
066
067    /** The raw title, without any status information attached. */
068    private String m_rawTitle = "";
069
070    /** Flag indicating if the result item resource is currently released and not expired. */
071    private boolean m_releasedAndNotExpired;
072
073    /** The name of the user who last modified the resource. */
074    private String m_userLastModified;
075
076    /** The link for displaying the resource. */
077    private String m_viewLink;
078
079    /** True if the result is deactivated. */
080    private boolean m_deactivated;
081
082    /**
083     * Default constructor.<p>
084     */
085    public CmsResultItemBean() {
086
087        // empty default constructor
088    }
089
090    /**
091     * Returns the structured id.<p>
092     *
093     * @return the structured id
094     */
095    public String getClientId() {
096
097        return m_clientId;
098    }
099
100    /**
101     * Returns the formatted last modification date.<p>
102     *
103     * @return the formatted last modification date
104     */
105    public String getDateLastModified() {
106
107        return m_dateLastModified;
108    }
109
110    /**
111     * Returns the description.<p>
112     *
113     * @return the description
114     */
115    public String getDescription() {
116
117        return m_description;
118    }
119
120    /**
121     * Returns the dimension.<p>
122     *
123     * @return the dimension
124     */
125    public String getDimension() {
126
127        return m_dimension;
128    }
129
130    /**
131     * Returns the noEditReson.<p>
132     *
133     * @return the noEditReson
134     */
135    public String getNoEditReson() {
136
137        return m_noEditReson;
138    }
139
140    /**
141     * Returns the resourcePath.<p>
142     *
143     * @return the resourcePath
144     */
145    public String getPath() {
146
147        return m_path;
148    }
149
150    /**
151     * Gets the raw title, without status information attached.<p>
152     *
153     * @return the raw title
154     */
155    public String getRawTitle() {
156
157        return m_rawTitle;
158    }
159
160    /**
161     * @see org.opencms.gwt.shared.CmsListInfoBean#getSubTitle()
162     */
163    @Override
164    public String getSubTitle() {
165
166        String fieldSubTitle = super.getSubTitle();
167        if (fieldSubTitle != null) {
168            return fieldSubTitle;
169        }
170        return m_userLastModified + " / " + m_dateLastModified;
171    }
172
173    /**
174     * Gets the name of the user who last modified the resource.<p>
175     *
176     * @return the name of the user who last modified the resource
177     */
178    public String getUserLastModified() {
179
180        return m_userLastModified;
181    }
182
183    /**
184     * Gets the link for displaying the resource.<p>
185     *
186     * @return the link for displaying the resource
187     */
188    public String getViewLink() {
189
190        return m_viewLink;
191    }
192
193    /**
194     * Returns true if the result resource is a copy model.<p>
195     *
196     * @return true if the resource is a copy model
197     */
198    public boolean isCopyModel() {
199
200        return m_isCopyModel;
201    }
202
203    /**
204     * Checks if the result is deactivated.
205     *
206     * @return true if the result is deactivated
207     */
208    public boolean isDeactivated() {
209
210        return m_deactivated;
211    }
212
213    /**
214     * Returns if the represented resource is editable by the current user.<p>
215     *
216     * @return <code>true</code> if editable
217     */
218    public boolean isEditable() {
219
220        return CmsStringUtil.isEmptyOrWhitespaceOnly(m_noEditReson);
221    }
222
223    /**
224     * True if this is result item corresponds to a preset value in the editor.<p>
225     *
226     * @return true if this corresponds to a preset value
227     */
228    public boolean isPreset() {
229
230        return m_isPreset;
231    }
232
233    /**
234     * Returns if the result item resource is currently released and not expired.<p>
235     *
236     * @return <code>true</code> if the result item resource is currently released and not expired
237     */
238    public boolean isReleasedAndNotExpired() {
239
240        return m_releasedAndNotExpired;
241    }
242
243    /**
244     * Sets the structure id.<p>
245     *
246     * @param clientId the structure id to set
247     */
248    public void setClientId(String clientId) {
249
250        m_clientId = clientId;
251    }
252
253    /**
254     * Sets the formatted last modification date.<p>
255     *
256     * @param formattedDate the formatted last modification date
257     */
258    public void setDateLastModified(String formattedDate) {
259
260        m_dateLastModified = formattedDate;
261    }
262
263    /**
264     * Sets the 'deactivated' state.
265     *
266     * @param deactivated the 'deactivated' state
267     */
268    public void setDeactivated(boolean deactivated) {
269
270        m_deactivated = deactivated;
271    }
272
273    /**
274     * Sets the description.<p>
275     *
276     * Also used as sub-title.<p>
277     *
278     * @param description the description to set
279     */
280    public void setDescription(String description) {
281
282        m_description = description;
283    }
284
285    /**
286     * Sets the dimension.<p>
287     *
288     * @param dimension the dimension to set
289     */
290    public void setDimension(String dimension) {
291
292        m_dimension = dimension;
293    }
294
295    /**
296     * Sets the "copy model" status of this result bean.<p>
297     *
298     * @param isCopyModel true if this result should be marked as a copy model
299     */
300    public void setIsCopyModel(boolean isCopyModel) {
301
302        m_isCopyModel = isCopyModel;
303    }
304
305    /**
306     * Sets the reason this resource may not be edited.<p>
307     *
308     * @param noEditReson the reason this resource may not be edited to set
309     */
310    public void setNoEditReson(String noEditReson) {
311
312        m_noEditReson = noEditReson;
313    }
314
315    /**
316     * Sets the resource path.<p>
317     *
318     * @param path the resource path to set
319     */
320    public void setPath(String path) {
321
322        m_path = path;
323    }
324
325    /**
326     * Sets the "is preset" flag.<p>
327     *
328     * @param preset the "is preset" flag
329     */
330    public void setPreset(boolean preset) {
331
332        m_isPreset = preset;
333    }
334
335    /**
336     * Sets the raw title.<p>
337     *
338     * @param rawTitle the raw title
339     */
340    public void setRawTitle(String rawTitle) {
341
342        m_rawTitle = rawTitle;
343    }
344
345    /**
346     * Sets if the result item resource is currently released and not expired.<p>
347     *
348     * @param releasedAndNotExpired if the result item resource is currently released and not expired
349     */
350    public void setReleasedAndNotExpired(boolean releasedAndNotExpired) {
351
352        m_releasedAndNotExpired = releasedAndNotExpired;
353    }
354
355    /**
356     * Sets the resource type name.<p>
357     *
358     * @param type the resource type name to set
359     */
360    public void setType(String type) {
361
362        setResourceType(type);
363    }
364
365    /**
366     * Sets the name of the user who last modified the resource.<p>
367     *
368     * @param userLastModified a user name
369     */
370    public void setUserLastModified(String userLastModified) {
371
372        m_userLastModified = userLastModified;
373    }
374
375    /**
376     * Sets the link for displaying the resource.<p>
377     *
378     * @param viewLink the link for displaying the
379     */
380    public void setViewLink(String viewLink) {
381
382        m_viewLink = viewLink;
383    }
384
385}