View Javadoc
1   /**
2    * This file Copyright (c) 2011-2015 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  import info.magnolia.rendering.template.fragment.FragmentDefinition;
39  
40  import java.util.HashMap;
41  import java.util.Map;
42  
43  import org.apache.commons.lang3.builder.ToStringBuilder;
44  
45  /**
46   * A {@link RenderableDefinition} configured in the configuration workspace.
47   */
48  public class ConfiguredRenderableDefinition implements RenderableDefinition {
49  
50      private String id;
51      private String name;
52      private String title;
53      private String templateScript;
54      private String renderType;
55      private String description;
56      private String i18nBasename;
57      // TODO: use generics again once we get rid of templating-compatibility module
58      private Class modelClass;
59      private AutoGenerationConfiguration autoGeneration = new ConfiguredAutoGeneration();
60      private Map<String, RenderableDefinition> variations = new HashMap<String, RenderableDefinition>();
61  
62      private Boolean autoPopulateFromRequest;
63  
64      private FragmentDefinition fragmentDefinition;
65  
66      protected Map<String, Object> parameters = new HashMap<String, Object>();
67  
68  
69      @Override
70      public String getId() {
71          return this.id;
72      }
73  
74      @Override
75      public void setId(String id) {
76          this.id = id;
77      }
78  
79      @Override
80      public String getName() {
81          return this.name;
82      }
83  
84      @Override
85      public String getTitle() {
86          return this.title;
87      }
88  
89      @Override
90      public String getTemplateScript() {
91          return this.templateScript;
92      }
93  
94      @Override
95      public String getRenderType() {
96          return renderType;
97      }
98  
99      @Override
100     public String getDescription() {
101         return this.description;
102     }
103 
104     public void setDescription(String description) {
105         this.description = description;
106     }
107 
108     public void setName(String name) {
109         this.name = name;
110     }
111 
112     public void setTemplateScript(String templateScript) {
113         this.templateScript = templateScript;
114     }
115 
116     public void setRenderType(String renderType) {
117         this.renderType = renderType;
118     }
119 
120     public void setTitle(String title) {
121         this.title = title;
122     }
123 
124     @Override
125     public String getI18nBasename() {
126         return this.i18nBasename;
127     }
128 
129     public void setI18nBasename(String basename) {
130         this.i18nBasename = basename;
131     }
132 
133     @Override
134     @SuppressWarnings("rawtypes")
135     public Class getModelClass() {
136         return this.modelClass;
137     }
138 
139     public void setModelClass(Class modelClass) {
140         this.modelClass = modelClass;
141     }
142 
143     @Override
144     public Map<String, RenderableDefinition> getVariations() {
145         return variations;
146     }
147 
148     public void setVariations(Map<String, RenderableDefinition> variations) {
149         this.variations = variations;
150     }
151 
152     public void addVariation(String name, RenderableDefinition variation) {
153         variations.put(name, variation);
154     }
155 
156     @Override
157     public Map<String, Object> getParameters() {
158         return this.parameters;
159     }
160 
161     public void setParameters(Map<String, Object> params) {
162         this.parameters = params;
163     }
164 
165     public void addParameter(String name, Object parameter) {
166         this.parameters.put(name, parameter);
167     }
168 
169     @Override
170     public AutoGenerationConfiguration getAutoGeneration() {
171         return this.autoGeneration;
172     }
173 
174     public void setAutoGeneration(AutoGenerationConfiguration autoGeneration) {
175         this.autoGeneration = autoGeneration;
176     }
177 
178     @Override
179     public String toString() {
180         return new ToStringBuilder(this)
181                 .append("id", this.id)
182                 .append("name", this.name)
183                 .append("renderType", this.renderType)
184                 .append("description", this.description)
185                 .append("title", this.title)
186                 .append("templateScript", this.templateScript)
187                 .append("autoGeneration", this.autoGeneration)
188                 .toString();
189     }
190 
191     @Override
192     public Boolean getAutoPopulateFromRequest() {
193         return autoPopulateFromRequest;
194     }
195 
196     public void setAutoPopulateFromRequest(Boolean autoPopulateFromRequest) {
197         this.autoPopulateFromRequest = autoPopulateFromRequest;
198     }
199 
200     @Override
201     public FragmentDefinition getFragmentDefinition() {
202         return fragmentDefinition;
203     }
204 
205     public void setFragmentDefinition(FragmentDefinition fragmentDefinition) {
206         this.fragmentDefinition = fragmentDefinition;
207     }
208 }