KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > product > store > ProductStoreSurveyWrapper


1 /*
2  * $Id: ProductStoreSurveyWrapper.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */

24 package org.ofbiz.product.store;
25
26 import java.io.Writer JavaDoc;
27 import java.util.Map JavaDoc;
28
29 import org.ofbiz.base.util.UtilValidate;
30 import org.ofbiz.content.survey.SurveyWrapper;
31 import org.ofbiz.entity.GenericValue;
32
33 /**
34  * Product Store Survey Wrapper
35  *
36  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
37  * @version $Rev: 5462 $
38  * @since 3.0
39  */

40 public class ProductStoreSurveyWrapper extends SurveyWrapper {
41
42     public static final String JavaDoc module = ProductStoreSurveyWrapper.class.getName();
43
44     protected GenericValue productStoreSurveyAppl = null;
45     protected String JavaDoc surveyTemplate = null;
46     protected String JavaDoc resultTemplate = null;
47     protected boolean callResult = false;
48
49     protected ProductStoreSurveyWrapper() {}
50
51     public ProductStoreSurveyWrapper(GenericValue productStoreSurveyAppl, String JavaDoc partyId, Map JavaDoc passThru) {
52         this.productStoreSurveyAppl = productStoreSurveyAppl;
53
54         this.passThru = passThru;
55         if (this.productStoreSurveyAppl != null) {
56             this.partyId = partyId;
57             this.delegator = productStoreSurveyAppl.getDelegator();
58             this.surveyId = productStoreSurveyAppl.getString("surveyId");
59             this.surveyTemplate = productStoreSurveyAppl.getString("surveyTemplate");
60             this.resultTemplate = productStoreSurveyAppl.getString("resultTemplate");
61         } else {
62             throw new IllegalArgumentException JavaDoc("Required parameter productStoreSurveyAppl missing");
63         }
64         this.checkParameters();
65     }
66
67     public void callResult(boolean b) {
68         this.callResult = b;
69     }
70
71     public Writer JavaDoc render() throws SurveyWrapperException {
72         if (canRespond() && !callResult) {
73             return renderSurvey();
74         } else if (!UtilValidate.isEmpty(resultTemplate)) {
75             return renderResult();
76         } else {
77             throw new SurveyWrapperException("Error template not implemented yet; cannot update survey; no result template defined!");
78         }
79     }
80
81     public Writer JavaDoc renderSurvey() throws SurveyWrapperException {
82         return this.render(surveyTemplate);
83     }
84
85     public Writer JavaDoc renderResult() throws SurveyWrapperException {
86         return this.render(resultTemplate);
87     }
88 }
89
Popular Tags