001/* 002 * Copyright 2012 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.web.service; 017 018import java.util.Collections; 019import java.util.LinkedHashMap; 020import java.util.Map; 021 022import org.ametys.runtime.i18n.I18nizableText; 023 024/** 025 * Definition of a {@link Service} parameter repeater. 026 */ 027public class ServiceParameterRepeater implements ServiceParameterOrRepeater 028{ 029 private String _id; 030 private String _pluginName; 031 private I18nizableText _label; 032 private I18nizableText _description; 033 034 private int _initialSize; 035 private int _minSize; 036 private int _maxSize; 037 private I18nizableText _addLabel; 038 private I18nizableText _editLabel; 039 private I18nizableText _delLabel; 040 private String _addIcon; 041 private String _editIcon; 042 private String _delIcon; 043 044 private Map<String, ServiceParameter> _parameters; 045 046 /** 047 * Get the id. 048 * @return Returns the id. 049 */ 050 public String getId() 051 { 052 return _id; 053 } 054 055 /** 056 * Set the id. 057 * @param id the id. 058 */ 059 public void setId(String id) 060 { 061 _id = id; 062 } 063 064 /** 065 * Retrieves the name of the plugin declaring this parameter. 066 * @return the plugin name. 067 */ 068 public String getPluginName() 069 { 070 return _pluginName; 071 } 072 073 /** 074 * Set the name of the plugin declaring this parameter. 075 * @param pluginName the plugin name. 076 */ 077 public void setPluginName(String pluginName) 078 { 079 _pluginName = pluginName; 080 } 081 082 /** 083 * Retrieves the label. 084 * @return the label. 085 */ 086 public I18nizableText getLabel() 087 { 088 return _label; 089 } 090 091 /** 092 * Set the label. 093 * @param label the label. 094 */ 095 public void setLabel(I18nizableText label) 096 { 097 _label = label; 098 } 099 100 /** 101 * Retrieves the description. 102 * @return the description. 103 */ 104 public I18nizableText getDescription() 105 { 106 return _description; 107 } 108 109 /** 110 * Set the description. 111 * @param description the description. 112 */ 113 public void setDescription(I18nizableText description) 114 { 115 _description = description; 116 } 117 118 /** 119 * Retrieves the initial size. 120 * @return the initial size. 121 */ 122 public int getInitialSize() 123 { 124 return _initialSize; 125 } 126 127 /** 128 * Set the initial size. 129 * @param size the initial size. 130 */ 131 public void setInitialSize(int size) 132 { 133 _initialSize = size; 134 } 135 136 /** 137 * Retrieves the minimum size. 138 * @return the minimum size. 139 */ 140 public int getMinSize() 141 { 142 return _minSize; 143 } 144 145 /** 146 * Set the minimum size. 147 * @param size the minimum size. 148 */ 149 public void setMinSize(int size) 150 { 151 _minSize = size; 152 } 153 154 /** 155 * Retrieves the maximum size. 156 * @return the maximum size or <code>-1</code> if unbounded. 157 */ 158 public int getMaxSize() 159 { 160 return _maxSize; 161 } 162 163 /** 164 * Set the maximum size. 165 * @param size the maximum size or <code>-1</code> if unbounded. 166 */ 167 public void setMaxSize(int size) 168 { 169 _maxSize = size; 170 } 171 172 /** 173 * Retrieves the add label. 174 * @return the add label or <code>null</code> if none. 175 */ 176 public I18nizableText getAddLabel() 177 { 178 return _addLabel; 179 } 180 181 /** 182 * Set the add label. 183 * @param label the add label or <code>null</code> if none. 184 */ 185 public void setAddLabel(I18nizableText label) 186 { 187 _addLabel = label; 188 } 189 190 /** 191 * Retrieves the edit label. 192 * @return the edit label or <code>null</code> if none. 193 */ 194 public I18nizableText getEditLabel() 195 { 196 return _editLabel; 197 } 198 199 200 /** 201 * Set the edit label. 202 * @param label the edit label or <code>null</code> if none. 203 */ 204 public void setEditLabel(I18nizableText label) 205 { 206 _editLabel = label; 207 } 208 209 /** 210 * Retrieves the delete label. 211 * @return the delete label or <code>null</code> if none. 212 */ 213 public I18nizableText getDeleteLabel() 214 { 215 return _delLabel; 216 } 217 218 /** 219 * Set the delete label. 220 * @param label the delete label or <code>null</code> if none. 221 */ 222 public void setDeleteLabel(I18nizableText label) 223 { 224 _delLabel = label; 225 } 226 227 /** 228 * Set the add label. 229 * @param addIcon the add icon 230 */ 231 public void setAddIcon(String addIcon) 232 { 233 _addIcon = addIcon; 234 } 235 236 /** 237 * Set the add icon 238 * @return the add icon 239 */ 240 public String getAddIcon () 241 { 242 return _addIcon; 243 } 244 245 /** 246 * Set the edit label. 247 * @param editIcon the edit icon 248 */ 249 public void setEditIcon(String editIcon) 250 { 251 _editIcon = editIcon; 252 } 253 254 /** 255 * Set the edit icon 256 * @return the edit icon 257 */ 258 public String getEditIcon () 259 { 260 return _editIcon; 261 } 262 263 /** 264 * Set the delete label. 265 * @param delIcon the delete icon 266 */ 267 public void setDeleteIcon(String delIcon) 268 { 269 _delIcon = delIcon; 270 } 271 272 /** 273 * Set the delete icon 274 * @return the delete icon 275 */ 276 public String getDeleteIcon () 277 { 278 return _delIcon; 279 } 280 281 /** 282 * Get the children parameters. 283 * @return the children parameters. 284 */ 285 public Map<String, ServiceParameter> getChildrenParameters() 286 { 287 return Collections.unmodifiableMap(_parameters); 288 } 289 290 /** 291 * Set the children parameters. 292 * @param parameters the children parameters, indexed by parameter ID. 293 */ 294 public void setChildrenParameters(Map<String, ServiceParameter> parameters) 295 { 296 _parameters = new LinkedHashMap<>(parameters); 297 } 298 299 @Override 300 public String toString() 301 { 302 return "SERVICE PARAMETER REPEATER [" + _id + ", '" + getLabel().toString() + "', " + _parameters.size() + " parameters]"; 303 } 304 305}