001/* 002 * Copyright 2013 Anyware Services 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 */ 016package org.ametys.plugins.cart; 017 018import java.util.Calendar; 019import java.util.Collections; 020import java.util.Date; 021import java.util.List; 022 023import org.ametys.core.user.UserIdentity; 024import org.ametys.runtime.i18n.I18nizableText; 025 026/** 027 * Implementation of a {@link CartElement} wrapping a search query 028 * 029 */ 030public class QueryElement implements CartElement 031{ 032 private String _id; 033 private String _query; 034 private UserIdentity _author; 035 private String _title; 036 private Calendar _date; 037 038 /** 039 * Constructor 040 * @param id The id 041 * @param query The query 042 * @param author The author 043 * @param creationDate The creation date 044 * @param title The query title 045 */ 046 public QueryElement (String id, String query, UserIdentity author, Calendar creationDate, String title) 047 { 048 _id = id; 049 _query = query; 050 _author = author; 051 _date = creationDate; 052 _title = title; 053 } 054 055 @Override 056 public String getId() 057 { 058 return _id; 059 } 060 061 @Override 062 public I18nizableText getTitle() 063 { 064 return new I18nizableText(_title); 065 } 066 067 @Override 068 public I18nizableText getDescription() 069 { 070 return new I18nizableText(_query); 071 } 072 073 @Override 074 public List<I18nizableText> getGroups() 075 { 076 return Collections.singletonList(new I18nizableText("plugin.cart", "PLUGINS_CART_UITOOL_CART_QUERIES_GROUP")); 077 } 078 079 @Override 080 public Date getLastModified() 081 { 082 return _date.getTime(); 083 } 084 085 @Override 086 public UserIdentity getLastContributor() 087 { 088 return _author; 089 } 090 091 @Override 092 public String getType() 093 { 094 return "cartQuery"; 095 } 096 097 public String getGlyphIcon() 098 { 099 return "ametysicon-magnifier12"; 100 } 101 102 @Override 103 public String getSmallIcon() 104 { 105 return null; 106 } 107 108 @Override 109 public String getMediumIcon() 110 { 111 return null; 112 } 113}