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