01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.product.store;
19:
20: import java.io.Writer;
21: import java.util.Map;
22:
23: import org.ofbiz.base.util.UtilValidate;
24: import org.ofbiz.content.survey.SurveyWrapper;
25: import org.ofbiz.entity.GenericValue;
26:
27: /**
28: * Product Store Survey Wrapper
29: */
30: public class ProductStoreSurveyWrapper extends SurveyWrapper {
31:
32: public static final String module = ProductStoreSurveyWrapper.class
33: .getName();
34:
35: protected GenericValue productStoreSurveyAppl = null;
36: protected String surveyTemplate = null;
37: protected String resultTemplate = null;
38: protected boolean callResult = false;
39:
40: protected ProductStoreSurveyWrapper() {
41: }
42:
43: public ProductStoreSurveyWrapper(
44: GenericValue productStoreSurveyAppl, String partyId,
45: Map passThru) {
46: this .productStoreSurveyAppl = productStoreSurveyAppl;
47:
48: this .passThru = passThru;
49: if (this .productStoreSurveyAppl != null) {
50: this .partyId = partyId;
51: this .delegator = productStoreSurveyAppl.getDelegator();
52: this .surveyId = productStoreSurveyAppl
53: .getString("surveyId");
54: this .surveyTemplate = productStoreSurveyAppl
55: .getString("surveyTemplate");
56: this .resultTemplate = productStoreSurveyAppl
57: .getString("resultTemplate");
58: } else {
59: throw new IllegalArgumentException(
60: "Required parameter productStoreSurveyAppl missing");
61: }
62: this .checkParameters();
63: }
64:
65: public void callResult(boolean b) {
66: this .callResult = b;
67: }
68:
69: public Writer render() throws SurveyWrapperException {
70: if (canRespond() && !callResult) {
71: return renderSurvey();
72: } else if (!UtilValidate.isEmpty(resultTemplate)) {
73: return renderResult();
74: } else {
75: throw new SurveyWrapperException(
76: "Error template not implemented yet; cannot update survey; no result template defined!");
77: }
78: }
79:
80: public Writer renderSurvey() throws SurveyWrapperException {
81: return this .render(surveyTemplate);
82: }
83:
84: public Writer renderResult() throws SurveyWrapperException {
85: return this.render(resultTemplate);
86: }
87: }
|