1 24 package org.ofbiz.product.store; 25 26 import java.io.Writer ; 27 import java.util.Map ; 28 29 import org.ofbiz.base.util.UtilValidate; 30 import org.ofbiz.content.survey.SurveyWrapper; 31 import org.ofbiz.entity.GenericValue; 32 33 40 public class ProductStoreSurveyWrapper extends SurveyWrapper { 41 42 public static final String module = ProductStoreSurveyWrapper.class.getName(); 43 44 protected GenericValue productStoreSurveyAppl = null; 45 protected String surveyTemplate = null; 46 protected String resultTemplate = null; 47 protected boolean callResult = false; 48 49 protected ProductStoreSurveyWrapper() {} 50 51 public ProductStoreSurveyWrapper(GenericValue productStoreSurveyAppl, String partyId, Map 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 ("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 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 renderSurvey() throws SurveyWrapperException { 82 return this.render(surveyTemplate); 83 } 84 85 public Writer renderResult() throws SurveyWrapperException { 86 return this.render(resultTemplate); 87 } 88 } 89 | Popular Tags |