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 /** 080 * Default constructor.<p> 081 */ 082 public CmsResultItemBean() { 083 084 // empty default constructor 085 } 086 087 /** 088 * Returns the structured id.<p> 089 * 090 * @return the structured id 091 */ 092 public String getClientId() { 093 094 return m_clientId; 095 } 096 097 /** 098 * Returns the formatted last modification date.<p> 099 * 100 * @return the formatted last modification date 101 */ 102 public String getDateLastModified() { 103 104 return m_dateLastModified; 105 } 106 107 /** 108 * Returns the description.<p> 109 * 110 * @return the description 111 */ 112 public String getDescription() { 113 114 return m_description; 115 } 116 117 /** 118 * Returns the dimension.<p> 119 * 120 * @return the dimension 121 */ 122 public String getDimension() { 123 124 return m_dimension; 125 } 126 127 /** 128 * Returns the noEditReson.<p> 129 * 130 * @return the noEditReson 131 */ 132 public String getNoEditReson() { 133 134 return m_noEditReson; 135 } 136 137 /** 138 * Returns the resourcePath.<p> 139 * 140 * @return the resourcePath 141 */ 142 public String getPath() { 143 144 return m_path; 145 } 146 147 /** 148 * Gets the raw title, without status information attached.<p> 149 * 150 * @return the raw title 151 */ 152 public String getRawTitle() { 153 154 return m_rawTitle; 155 } 156 157 /** 158 * @see org.opencms.gwt.shared.CmsListInfoBean#getSubTitle() 159 */ 160 @Override 161 public String getSubTitle() { 162 163 String fieldSubTitle = super.getSubTitle(); 164 if (fieldSubTitle != null) { 165 return fieldSubTitle; 166 } 167 return m_userLastModified + " / " + m_dateLastModified; 168 } 169 170 /** 171 * Gets the name of the user who last modified the resource.<p> 172 * 173 * @return the name of the user who last modified the resource 174 */ 175 public String getUserLastModified() { 176 177 return m_userLastModified; 178 } 179 180 /** 181 * Gets the link for displaying the resource.<p> 182 * 183 * @return the link for displaying the resource 184 */ 185 public String getViewLink() { 186 187 return m_viewLink; 188 } 189 190 /** 191 * Returns true if the result resource is a copy model.<p> 192 * 193 * @return true if the resource is a copy model 194 */ 195 public boolean isCopyModel() { 196 197 return m_isCopyModel; 198 } 199 200 /** 201 * Returns if the represented resource is editable by the current user.<p> 202 * 203 * @return <code>true</code> if editable 204 */ 205 public boolean isEditable() { 206 207 return CmsStringUtil.isEmptyOrWhitespaceOnly(m_noEditReson); 208 } 209 210 /** 211 * True if this is result item corresponds to a preset value in the editor.<p> 212 * 213 * @return true if this corresponds to a preset value 214 */ 215 public boolean isPreset() { 216 217 return m_isPreset; 218 } 219 220 /** 221 * Returns if the result item resource is currently released and not expired.<p> 222 * 223 * @return <code>true</code> if the result item resource is currently released and not expired 224 */ 225 public boolean isReleasedAndNotExpired() { 226 227 return m_releasedAndNotExpired; 228 } 229 230 /** 231 * Sets the structure id.<p> 232 * 233 * @param clientId the structure id to set 234 */ 235 public void setClientId(String clientId) { 236 237 m_clientId = clientId; 238 } 239 240 /** 241 * Sets the formatted last modification date.<p> 242 * 243 * @param formattedDate the formatted last modification date 244 */ 245 public void setDateLastModified(String formattedDate) { 246 247 m_dateLastModified = formattedDate; 248 } 249 250 /** 251 * Sets the description.<p> 252 * 253 * Also used as sub-title.<p> 254 * 255 * @param description the description to set 256 */ 257 public void setDescription(String description) { 258 259 m_description = description; 260 } 261 262 /** 263 * Sets the dimension.<p> 264 * 265 * @param dimension the dimension to set 266 */ 267 public void setDimension(String dimension) { 268 269 m_dimension = dimension; 270 } 271 272 /** 273 * Sets the "copy model" status of this result bean.<p> 274 * 275 * @param isCopyModel true if this result should be marked as a copy model 276 */ 277 public void setIsCopyModel(boolean isCopyModel) { 278 279 m_isCopyModel = isCopyModel; 280 } 281 282 /** 283 * Sets the reason this resource may not be edited.<p> 284 * 285 * @param noEditReson the reason this resource may not be edited to set 286 */ 287 public void setNoEditReson(String noEditReson) { 288 289 m_noEditReson = noEditReson; 290 } 291 292 /** 293 * Sets the resource path.<p> 294 * 295 * @param path the resource path to set 296 */ 297 public void setPath(String path) { 298 299 m_path = path; 300 } 301 302 /** 303 * Sets the "is preset" flag.<p> 304 * 305 * @param preset the "is preset" flag 306 */ 307 public void setPreset(boolean preset) { 308 309 m_isPreset = preset; 310 } 311 312 /** 313 * Sets the raw title.<p> 314 * 315 * @param rawTitle the raw title 316 */ 317 public void setRawTitle(String rawTitle) { 318 319 m_rawTitle = rawTitle; 320 } 321 322 /** 323 * Sets if the result item resource is currently released and not expired.<p> 324 * 325 * @param releasedAndNotExpired if the result item resource is currently released and not expired 326 */ 327 public void setReleasedAndNotExpired(boolean releasedAndNotExpired) { 328 329 m_releasedAndNotExpired = releasedAndNotExpired; 330 } 331 332 /** 333 * Sets the resource type name.<p> 334 * 335 * @param type the resource type name to set 336 */ 337 public void setType(String type) { 338 339 setResourceType(type); 340 } 341 342 /** 343 * Sets the name of the user who last modified the resource.<p> 344 * 345 * @param userLastModified a user name 346 */ 347 public void setUserLastModified(String userLastModified) { 348 349 m_userLastModified = userLastModified; 350 } 351 352 /** 353 * Sets the link for displaying the resource.<p> 354 * 355 * @param viewLink the link for displaying the 356 */ 357 public void setViewLink(String viewLink) { 358 359 m_viewLink = viewLink; 360 } 361 362}