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