?? gbs_priceconditionaction.java
字號:
package ACTION;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import COMMON.BaseCommonCheck;
import COMMON.BaseDispatchAction;
import COMMON.MessageList;
import COMMON.ReturnValue;
import COMMON.SystemConstants;
import DataBean.GBS_LittleCountry_stBean;
import DataBean.GBS_LittlePriceCategory_stBean;
import DataBean.GBS_LittleProductCategory_stBean;
import DataBean.GBS_MCountry_stBean;
import DataBean.GBS_MWideUse_stBean;
import LOGIC.GBS_PriceCPCPriceListActionLogic;
import LOGIC.GBS_PriceConditionActionLogic;
import LOGIC.GBS_PriceHardwarePriceListActionLogic;
/**
* public class GBS_PriceConditionAction extends BaseDispatchAction implements SystemConstants
* created on 07-30-2004
* @author wxf
* @version 1.0
*/
public class GBS_PriceConditionAction extends BaseDispatchAction implements SystemConstants {
// --------------------------------------------------------- Instance Variables
// --------------------------------------------------------- Methods
/**
* init page
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws Exception
*/
public ActionForward init(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
log.info("[location info]GBS_UsermasterAction.init method!");
GBS_PriceConditionForm thisForm = (GBS_PriceConditionForm) form;
//get login user info from session
this.setUserInfoFromSession(request, thisForm);
//init combox, checkbox, radio
getComboxValueAndName(thisForm, request);
return (mapping.findForward(nextview));
}
/**
* Method search
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws Exception
*/
public ActionForward search(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
log.info("[location info]GBS_UsermasterAction.init method!");
GBS_PriceConditionForm thisForm = (GBS_PriceConditionForm) form;
//get login user info from session
this.setUserInfoFromSession(request, thisForm);
//init combox, checkbox, radio
getComboxValueAndName(thisForm, request);
MessageList errorMsg = new MessageList();
errorMsg = inputCheck(thisForm, request);
if (errorMsg.size() > 0) {
//save error to request
this.setMessage(errorMsg);
return (mapping.findForward(nextview));
}
GBS_PriceConditionActionLogic logic =
new GBS_PriceConditionActionLogic(this.getDataSource(request));
String[] price = thisForm.getPrice();
String[] productCategory = thisForm.getProductCategory();
String[] country = thisForm.getCountry();
String productCategoryCode = new String();
String countryCode = new String();
if (productCategory != null) {
for (int i = 0; i < productCategory.length; i++) {
if (i < productCategory.length - 1) {
if(productCategory[i].indexOf("'") > -1){
productCategory[i] = BaseCommonCheck.convertSql(productCategory[i]);
}
productCategoryCode += "'" + productCategory[i] + "',";
} else {
if(productCategory[i].indexOf("'") > -1){
productCategory[i] = BaseCommonCheck.convertSql(productCategory[i]);
}
productCategoryCode += "'" + productCategory[i] + "'";
}
}
} else {
ReturnValue ret = logic.getProductCAtegoryInfo(); //get product category information
ArrayList productCategoryList = (ArrayList) ret.getDataValue();
for (int i = 0; productCategoryList != null && i < productCategoryList.size(); i++) {
GBS_MWideUse_stBean mWideUse_st = new GBS_MWideUse_stBean();
mWideUse_st = (GBS_MWideUse_stBean) productCategoryList.get(i);
if (i < (productCategoryList.size() - 1)) {
productCategoryCode += "'" + mWideUse_st.getMainKey() + "',";
} else {
productCategoryCode += "'" + mWideUse_st.getMainKey() + "'";
}
}
}
if (country != null) {
for (int i = 0; i < country.length; i++) {
if (i < country.length - 1) {
if(country[i].indexOf("'") > -1){
country[i] = BaseCommonCheck.convertSql(country[i]);
}
countryCode += "'" + country[i] + "',";
} else {
if(country[i].indexOf("'") > -1){
country[i] = BaseCommonCheck.convertSql(country[i]);
}
countryCode += "'" + country[country.length - 1] + "'";
}
}
} else {
ReturnValue ret = logic.getCountryInfo(); // get Country Information
ArrayList countryList = (ArrayList) ret.getDataValue();
for (int i = 0; countryList != null && i < countryList.size(); i++) {
GBS_MCountry_stBean mCountry_st = new GBS_MCountry_stBean();
mCountry_st = (GBS_MCountry_stBean) countryList.get(i);
if (i < countryList.size() - 1) {
countryCode += "'" + mCountry_st.getCountryCode() + "',";
} else {
countryCode += "'" + mCountry_st.getCountryCode() + "'";
}
}
}
if (price[0].equals("CPC")) {
GBS_PriceCPCPriceListActionLogic cpcLogic =
new GBS_PriceCPCPriceListActionLogic(super.getDataSource());
ReturnValue ret = cpcLogic.getAllCPCPriceInfo(productCategoryCode, countryCode,thisForm.getLoginPlusHour());
// get all CPC price information
if (ret.isError()) {
if (ret.isBussinessError()) {
this.setMessage(ret.getMessageList());
}
//ErrorCode,ErrorMessage proccess
return (mapping.findForward(nextview));
} else {
GBS_PriceCPCPriceListForm priceCPCPriceListForm =
(GBS_PriceCPCPriceListForm) ret.getDataValue();
thisForm.setCPCData(priceCPCPriceListForm);
return (mapping.findForward(SEARCHCPCPRICELIST));
}
} else {
GBS_PriceHardwarePriceListActionLogic hardwareLogic =
new GBS_PriceHardwarePriceListActionLogic(super.getDataSource());
ReturnValue ret =
hardwareLogic.getAllHardwarePriceInfo(productCategoryCode, countryCode,thisForm.getLoginPlusHour());
// get all hardware price information
if (ret.isError()) {
if (ret.isBussinessError()) {
this.setMessage(ret.getMessageList());
}
//ErrorCode,ErrorMessage proccess
return (mapping.findForward(nextview));
} else {
GBS_PriceHardwarePriceListForm priceHardwarePriceListForm =
(GBS_PriceHardwarePriceListForm) ret.getDataValue();
thisForm.setHardwareData(priceHardwarePriceListForm);
return (mapping.findForward(SEARCHHARDWAREPRICELIST));
}
}
}
/**
* inputCheck
* @param GBS_PriceConditionForm thisForm
* @param HttpServletRequest request
* @throws Exception
* @return MessageList
*/
private MessageList inputCheck(GBS_PriceConditionForm thisForm, HttpServletRequest request)
throws Exception {
//create ErrorMessages to display error message
MessageList messages = new MessageList();
return messages;
}
/**
* getComboxValueAndName
* @param GBS_PriceConditionForm thisForm
* @param HttpServletRequest request
* @throws Exception
* @return
*/
private void getComboxValueAndName(GBS_PriceConditionForm thisForm, HttpServletRequest request)
throws Exception {
//get combox value from database
GBS_PriceConditionActionLogic logic =
new GBS_PriceConditionActionLogic(this.getDataSource(request));
ReturnValue ret = new ReturnValue();
//Countries List丂弶婜壔
ArrayList littlecountry_stList = new ArrayList();
ret = logic.getCountryInfo();
if (ret.isError()) {
if (ret.isBussinessError()) {
this.setMessage(ret.getMessageList());
}
} else {
ArrayList countryList = (ArrayList) ret.getDataValue();
for (int i = 0; countryList != null && i < countryList.size(); i++) {
GBS_MCountry_stBean country_st = (GBS_MCountry_stBean) countryList.get(i);
GBS_LittleCountry_stBean littleCountry_stList = new GBS_LittleCountry_stBean();
littleCountry_stList.setCountryCode(country_st.getCountryCode());
littleCountry_stList.setCountryName(country_st.getCountryName());
littlecountry_stList.add(littleCountry_stList);
if(findIt(country_st.getCountryCode(),thisForm.getCountry())){
ArrayList checked=thisForm.getCountryListChecked();
checked.add("Y");
thisForm.setCountryListChecked(checked) ;
}else{
ArrayList checked=thisForm.getCountryListChecked();
checked.add("N");
thisForm.setCountryListChecked(checked) ;
}
}
}
//Category List 弶婜壔
ret = logic.getProductCAtegoryInfo();
ArrayList categoryList = new ArrayList();
if (ret.isError()) {
if (ret.isBussinessError()) {
this.setMessage(ret.getMessageList());
}
} else {
ArrayList productCAtegoryList = (ArrayList) ret.getDataValue();
for (int i = 0; productCAtegoryList != null && i < productCAtegoryList.size(); i++) {
GBS_MWideUse_stBean mWideUse_st = (GBS_MWideUse_stBean) productCAtegoryList.get(i);
GBS_LittleProductCategory_stBean productCategroy_st =
new GBS_LittleProductCategory_stBean();
productCategroy_st.setProductCategory(mWideUse_st.getMainKey());
productCategroy_st.setProductCategoryName(mWideUse_st.getString1());
categoryList.add(productCategroy_st);
if(findIt(mWideUse_st.getMainKey(),thisForm.getProductCategory())){
ArrayList checked=thisForm.getProductCategoryListChecked();
checked.add("Y");
thisForm.setProductCategoryListChecked(checked) ;
}else{
ArrayList checked=thisForm.getProductCategoryListChecked();
checked.add("N");
thisForm.setProductCategoryListChecked(checked) ;
}
}
}
//PriceList List 弶婜壔
ArrayList priceList = new ArrayList();
GBS_LittlePriceCategory_stBean price_st = new GBS_LittlePriceCategory_stBean();
price_st.setPriceCategory("Hardware");
price_st.setPriceCategoryName("Hardware");
priceList.add(price_st);
price_st = new GBS_LittlePriceCategory_stBean();
price_st.setPriceCategory("CPC");
price_st.setPriceCategoryName("CPC");
priceList.add(price_st);
thisForm.setPriceList(priceList);
boolean allNoChecked = true;
for(int i = 0;i< thisForm.getPriceList().size();i++){
price_st=(GBS_LittlePriceCategory_stBean)thisForm.getPriceList().get(i);
ArrayList checked = thisForm.getPriceListChecked();
if(findIt(price_st.getPriceCategory(),thisForm.getPrice())){
checked.add("Y");
allNoChecked = false;
}else{
checked.add("N");
}
thisForm.setPriceListChecked(checked);
}
if(allNoChecked){
ArrayList checked = thisForm.getPriceListChecked();
checked.set(0,"Y");
thisForm.setPriceListChecked(checked);
}
thisForm.setCountryList(littlecountry_stList);
thisForm.setProductCategoryList(categoryList);
}
/**
* find it in there
* @param String it
* @param String[] there
* @return boolean
*/
private boolean findIt(String it,String[] there){
if(there !=null){
for(int i = 0;i < there.length;i++){
if(there[i].equals(it)){
return true;
}
}
}
return false;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -