View Javadoc

1   /**
2    * This file Copyright (c) 2011-2013 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.rendering.template.configured;
35  
36  import info.magnolia.rendering.template.AutoGenerationConfiguration;
37  import info.magnolia.rendering.template.RenderableDefinition;
38  
39  import java.util.HashMap;
40  import java.util.Map;
41  
42  import org.apache.commons.lang.builder.ToStringBuilder;
43  
44  
45  /**
46   * A {@link RenderableDefinition} configured in the configuration workspace.
47   *
48   * @version $Id$
49   */
50  public class ConfiguredRenderableDefinition implements RenderableDefinition {
51  
52      private String id;
53      private String name;
54      private String title;
55      private String templateScript;
56      private String renderType;
57      private String description;
58      private String i18nBasename;
59      //TODO: use generics again once we get rid of templating-compatibility module
60      private Class modelClass;
61      private AutoGenerationConfiguration autoGeneration = new ConfiguredAutoGeneration();
62      private Map<String, RenderableDefinition> variations = new HashMap<String, RenderableDefinition>();
63  
64      protected Map<String, Object> parameters = new HashMap<String, Object>();
65  
66      private Boolean autoPopulateFromRequest;
67  
68      @Override
69      public String getId() {
70          return this.id;
71      }
72  
73      @Override
74      public void setId(String id) {
75          this.id = id;
76      }
77  
78      @Override
79      public String getName() {
80          return this.name;
81      }
82  
83      @Override
84      public String getTitle() {
85          return this.title;
86      }
87  
88      @Override
89      public String getTemplateScript() {
90          return this.templateScript;
91      }
92  
93      @Override
94      public String getRenderType() {
95          return renderType;
96      }
97  
98      @Override
99      public String getDescription() {
100         return this.description;
101     }
102 
103     public void setDescription(String description) {
104         this.description = description;
105     }
106 
107     public void setName(String name) {
108         this.name = name;
109     }
110 
111     public void setTemplateScript(String templateScript) {
112         this.templateScript = templateScript;
113     }
114 
115     public void setRenderType(String renderType) {
116         this.renderType = renderType;
117     }
118 
119     public void setTitle(String title) {
120         this.title = title;
121     }
122 
123     @Override
124     public String getI18nBasename() {
125         return this.i18nBasename;
126     }
127 
128     public void setI18nBasename(String basename) {
129         this.i18nBasename = basename;
130     }
131 
132     @Override
133     @SuppressWarnings("rawtypes")
134     public Class getModelClass() {
135         return this.modelClass;
136     }
137 
138     public void setModelClass(Class modelClass) {
139         this.modelClass = modelClass;
140     }
141 
142     @Override
143     public Map<String, RenderableDefinition> getVariations() {
144         return variations;
145     }
146 
147     public void setVariations(Map<String, RenderableDefinition> variations) {
148         this.variations = variations;
149     }
150 
151     public void addVariation(String name, RenderableDefinition variation) {
152         variations.put(name, variation);
153     }
154 
155     @Override
156     public Map<String, Object> getParameters() {
157         return this.parameters;
158     }
159 
160     public void setParameters(Map<String, Object> params) {
161         this.parameters = params;
162     }
163 
164     public void addParameter(String name, Object parameter) {
165         this.parameters.put(name, parameter);
166     }
167 
168     @Override
169     public AutoGenerationConfiguration getAutoGeneration() {
170         return this.autoGeneration;
171     }
172 
173     public void setAutoGeneration(AutoGenerationConfiguration autoGeneration) {
174         this.autoGeneration = autoGeneration;
175     }
176 
177     @Override
178     public String toString() {
179         return new ToStringBuilder(this)
180         .append("id", this.id)
181         .append("name", this.name)
182         .append("renderType", this.renderType)
183         .append("description", this.description)
184         .append("title", this.title)
185         .append("templateScript", this.templateScript)
186         .append("autoGeneration", this.autoGeneration)
187         .toString();
188     }
189 
190     public Boolean getAutoPopulateFromRequest() {
191         return autoPopulateFromRequest;
192     }
193 
194     public void setAutoPopulateFromRequest(Boolean autoPopulateFromRequest) {
195         this.autoPopulateFromRequest = autoPopulateFromRequest;
196     }
197 }