FORWARD_final = FORWARD_save;
if (actionType != null && actionType.equals("ADD")){
AccountHelperHome home = (AccountHelperHome)CVUtility.getHomeObject("com.centraview.account.helper.AccountHelperHome", "AccountHelper");
try {
AccountHelper remote = home.create();
remote.setDataSource(dataSource);
if (taxClassValue != null && ! taxClassValue.equals("")) {
remote.insertTaxClassOrJurisdiction(taxClassValue,"taxClass");
}
if (taxJurisdictionsValue != null && !taxJurisdictionsValue.equals("")) {
remote.insertTaxClassOrJurisdiction(taxJurisdictionsValue,"taxJurisdiction");
}
} catch (Exception e) {
logger.error("[Exception] ViewSourceSettingHandler.Execute Handler ", e);
}
}
if (actionType != null && actionType.equals("REMOVE")) {
AccountHelperHome home = (AccountHelperHome)CVUtility.getHomeObject("com.centraview.account.helper.AccountHelperHome", "AccountHelper");
try {
AccountHelper remote = home.create();
remote.setDataSource(dataSource);
if (tempTaxClassID != null && !tempTaxClassID.equals("")) {
int taxClassID = Integer.parseInt(tempTaxClassID);
remote.removeTaxClassOrJurisdiction(taxClassID, "taxClass");
}
if (tempTaxJurisdictionsID != null && !tempTaxJurisdictionsID.equals("")) {
int taxJurisdictionsID = Integer.parseInt(tempTaxJurisdictionsID);
remote.removeTaxClassOrJurisdiction(taxJurisdictionsID,"taxJurisdiction");
}
} catch (Exception e) {
logger.error("[Exception] ViewSourceSettingHandler.Execute Handler ", e);
}
}
if (actionType != null && actionType.startsWith("SAVE")) {
AccountHelperHome home = (AccountHelperHome)CVUtility.getHomeObject("com.centraview.account.helper.AccountHelperHome", "AccountHelper");
try {
AccountHelper remote = home.create();
remote.setDataSource(dataSource);
Vector taxClass = remote.getTaxClasses();
Vector taxJurisdiction = remote.getTaxJurisdiction();
ArrayList taxMatrixValue = new ArrayList();
if (taxJurisdiction != null && taxJurisdiction.size() != 0) {
for (int i = 0; i < taxJurisdiction.size(); i++) {
DDNameValue taxJurisdictionNameValue = (DDNameValue)taxJurisdiction.get(i);
if (taxJurisdictionNameValue != null) {
int taxJurisdictionID = taxJurisdictionNameValue.getId();
String taxJurisdictionName = taxJurisdictionNameValue.getName();
if (taxClass != null && taxClass.size() != 0) {
for (int j = 0; j < taxClass.size(); j++) {
DDNameValue taxClassNameValue = (DDNameValue)taxClass.get(j);
if (taxClassNameValue != null) {
int taxClassID = taxClassNameValue.getId();
String taxClassName = taxClassNameValue.getName();
String textBoxName = "J" + taxJurisdictionID + "C" + taxClassID;
String taxRate = request.getParameter(textBoxName);
if (taxRate == null || taxRate.length() <= 0) {
allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", taxJurisdictionName+"/"+taxClassName));
} else {
float floatTaxRate = Float.parseFloat(taxRate);
if (floatTaxRate < 0 || floatTaxRate > 100) {
allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.rangeField", taxJurisdictionName+"/"+taxClassName));
}
taxMatrixValue.add(new TaxMartixForm(taxClassID,taxJurisdictionID,floatTaxRate));
}
}
}
}
}
}
}
if (! allErrors.isEmpty()) {
saveErrors(request, allErrors);
return(mapping.findForward(FORWARD_save));
}
if (actionType != null && actionType.equals("SAVEANDCLOSE")){
FORWARD_final = FORWARD_saveandclose;
}
remote.setTaxMatrix(taxMatrixValue);
} catch (Exception e) {
logger.error("[Exception] ViewSourceSettingHandler.Execute Handler ", e);
e.printStackTrace();
}
}