View Javadoc

1   /**
2    * This file Copyright (c) 2011 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      @Override
67      public String getId() {
68          return this.id;
69      }
70  
71      @Override
72      public void setId(String id) {
73          this.id = id;
74      }
75  
76      @Override
77      public String getName() {
78          return this.name;
79      }
80  
81      @Override
82      public String getTitle() {
83          return this.title;
84      }
85  
86      @Override
87      public String getTemplateScript() {
88          return this.templateScript;
89      }
90  
91      @Override
92      public String getRenderType() {
93          return renderType;
94      }
95  
96      @Override
97      public String getDescription() {
98          return this.description;
99      }
100 
101     public void setDescription(String description) {
102         this.description = description;
103     }
104 
105     public void setName(String name) {
106         this.name = name;
107     }
108 
109     public void setTemplateScript(String templateScript) {
110         this.templateScript = templateScript;
111     }
112 
113     public void setRenderType(String renderType) {
114         this.renderType = renderType;
115     }
116 
117     public void setTitle(String title) {
118         this.title = title;
119     }
120 
121     @Override
122     public String getI18nBasename() {
123         return this.i18nBasename;
124     }
125 
126     public void setI18nBasename(String basename) {
127         this.i18nBasename = basename;
128     }
129 
130     @Override
131     @SuppressWarnings("rawtypes")
132     public Class getModelClass() {
133         return this.modelClass;
134     }
135 
136     public void setModelClass(Class modelClass) {
137         this.modelClass = modelClass;
138     }
139 
140     @Override
141     public Map<String, RenderableDefinition> getVariations() {
142         return variations;
143     }
144 
145     public void setVariations(Map<String, RenderableDefinition> variations) {
146         this.variations = variations;
147     }
148 
149     public void addVariation(String name, RenderableDefinition variation) {
150         variations.put(name, variation);
151     }
152 
153     @Override
154     public Map<String, Object> getParameters() {
155         return this.parameters;
156     }
157 
158     public void setParameters(Map<String, Object> params) {
159         this.parameters = params;
160     }
161 
162     public void addParameter(String name, Object parameter) {
163         this.parameters.put(name, parameter);
164     }
165 
166     @Override
167     public AutoGenerationConfiguration getAutoGeneration() {
168         return this.autoGeneration;
169     }
170 
171     public void setAutoGeneration(AutoGenerationConfiguration autoGeneration) {
172         this.autoGeneration = autoGeneration;
173     }
174 
175     @Override
176     public String toString() {
177         return new ToStringBuilder(this)
178         .append("id", this.id)
179         .append("name", this.name)
180         .append("renderType", this.renderType)
181         .append("description", this.description)
182         .append("title", this.title)
183         .append("templateScript", this.templateScript)
184         .append("autoGeneration", this.autoGeneration)
185         .toString();
186     }
187 }