Ejemplo n.º 1
0
 /*
  * start enum list
  * */
 public InsuranceType[] getItypes() {
   return InsuranceType.values();
 }
Ejemplo n.º 2
0
 @SuppressWarnings("unchecked")
 @Action(
     value = "customer-save",
     results = {
       @Result(name = "success", location = "/WEB-INF/content/ajax/customer/customer-result.jsp"),
       @Result(name = "input", location = "/WEB-INF/content/ajax/customer/customer-result.jsp")
     })
 public String customersave() {
   boolean check = true;
   try {
     imageList = (List<Image>) session.get("imageList");
     if (customer.getId() != null) {
       Customer c = (Customer) session.get("customer");
       customer.setConfirm(c.getConfirm());
     }
     customer.setImageOfList(imageList);
     if (customer.getCnumber().equals("")) {
       addFieldError("cnumber", Messages.getString("inputEmpty"));
       addFieldError("cnumberEdit", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getColor().equals("")) {
       addFieldError("color", Messages.getString("inputEmpty"));
       addFieldError("colorEdit", Messages.getString("inputEmpty"));
       check = false;
     } else {
       if (customer.getColor().matches("[0-9]{4}[А-ЯӨҮ]{3}")) {
         addFieldError("color", Messages.getString("cnumber"));
         check = false;
       }
     }
     if (customer.getVinNumber().equals("")) {
       addFieldError("vinNumber", Messages.getString("inputEmpty"));
       addFieldError("vinNumberEdit", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getOwnerName().equals("")) {
       addFieldError("ownerName", Messages.getString("inputEmpty"));
       addFieldError("ownerNameEdit", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getOwnerAddress().equals("")) {
       addFieldError("ownerAddress", Messages.getString("inputEmpty"));
       addFieldError("ownerAddressEdit", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getOwnerPhoneNumber().equals("")) {
       addFieldError("ownerPhoneNumberEdit", Messages.getString("inputEmpty"));
       addFieldError("ownerPhoneNumber", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getEstPoint().equals("")) {
       addFieldError("estPointEdit", Messages.getString("inputEmpty"));
       addFieldError("estPoint", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getMarketPrice().equals("")) {
       addFieldError("marketPrice", Messages.getString("inputEmpty"));
       addFieldError("marketPriceEdit", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getConsumer().equals("")) {
       addFieldError("consumer", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getDefendant().equals("")) {
       addFieldError("defendant", Messages.getString("inputEmpty"));
       addFieldError("defendantEdit", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getAgentConsumer().equals("")) {
       addFieldError("agentConsumerEdit", Messages.getString("inputEmpty"));
       addFieldError("agentConsumer", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getEstimateMaterial().equals("")) {
       addFieldError("estimateMaterial", Messages.getString("inputEmpty"));
       addFieldError("estimateMaterialEdit", Messages.getString("inputEmpty"));
     }
     if (companyStr.trim().equals("")) {
       addFieldError("companyStrEdit", Messages.getString("inputEmpty"));
       addFieldError("companyStr", Messages.getString("inputEmpty"));
       check = false;
     } else {
       try {
         customer.setCompany(companyService.get(Long.parseLong(companyStr)));
       } catch (Exception e) {
         addFieldError("companyStrEdit", e.getMessage());
         addFieldError("companyStr", e.getMessage());
         check = false;
       }
     }
     if (!itypeStr.equals("")) {
       customer.setItype(InsuranceType.get(itypeStr));
     } else {
       addFieldError("itypeStr", Messages.getString("inputEmpty"));
       addFieldError("itypeStrEdit", Messages.getString("inputEmpty"));
       check = false;
     }
     if (dateStr.equals("")) {
       addFieldError("dateStr", Messages.getString("inputEmpty"));
       addFieldError("dateStrEdit", Messages.getString("inputEmpty"));
       check = false;
     } else {
       customer.setDate(EstimaterStaticFunctions.strToDate(dateStr));
     }
     if (factoryStr.equals("")) {
       addFieldError("factoryStr", Messages.getString("inputEmpty"));
       addFieldError("factoryStrEdit", Messages.getString("inputEmpty"));
       check = false;
     } else {
       try {
         customer.setCarFactory(carFactoryService.get(Long.parseLong(factoryStr)));
       } catch (Exception e) {
         addFieldError("factoryStr", e.getMessage());
         addFieldError("factoryStrEdit", e.getMessage());
         check = false;
       }
     }
     if (markStr.equals("")) {
       addFieldError("markStr", Messages.getString("inputEmpty"));
       addFieldError("markStrEdit", Messages.getString("inputEmpty"));
       check = false;
     } else {
       try {
         customer.setCarMark(carMarkService.get(Long.parseLong(markStr)));
       } catch (Exception e) {
         addFieldError("markStrEdit", e.getMessage());
         addFieldError("markStr", e.getMessage());
         check = false;
       }
     }
     if (customer.getFactoryDate().equals("")) {
       addFieldError("factoryDateEdit", Messages.getString("inputEmpty"));
       addFieldError("factoryDate", Messages.getString("inputEmpty"));
       check = false;
     }
     if (customer.getImportedDate().equals("")) {
       addFieldError("importedDate", Messages.getString("inputEmpty"));
       addFieldError("importedDateEdit", Messages.getString("inputEmpty"));
       check = false;
     }
     if (emp1Str.equals("")) {
       addFieldError("emp1Str", Messages.getString("inputEmpty"));
       addFieldError("emp1StrEdit", Messages.getString("inputEmpty"));
       check = false;
     } else {
       customer.setEmp1(employeeService.get(Long.parseLong(emp1Str)));
     }
     if (emp2Str.equals("")) {
       addFieldError("emp2Str", Messages.getString("inputEmpty"));
       addFieldError("emp2StrEdit", Messages.getString("inputEmpty"));
       check = false;
     } else {
       customer.setEmp2(employeeService.get(Long.parseLong(emp2Str)));
     }
     if (mainStr.equals("")) {
       addFieldError("mainStr", Messages.getString("inputEmpty"));
       addFieldError("mainStrEdit", Messages.getString("inputEmpty"));
       check = false;
     } else {
       customer.setMainEmp(employeeService.get(Long.parseLong(mainStr)));
     }
     if (carTypeStr.equals("")) {
       addFieldError("carTypeStr", Messages.getString("inputEmpty"));
       addFieldError("carTypeStrEdit", Messages.getString("inputEmpty"));
       check = false;
     } else {
       customer.setCarType(CarType.get(carTypeStr));
     }
     if (!customer.getRegNumber().matches("[А-ЯӨҮ]{2}[0-9]{8}")) {
       addFieldError("regnumber", Messages.getString("cnumber"));
       addFieldError("regnumberEdit", Messages.getString("cnumber"));
       check = false;
     }
     if (check) {
       defectList = (List<Defect>) session.get("defectList");
       for (Defect d : defectList) {
         defectService.saveOrUpdate(d);
       }
       customer.setDefectList(defectList);
       costList = (List<Cost>) session.get("costList");
       for (Cost c : costList) {
         costService.saveOrUpdate(c);
       }
       customer.setCostList(costList);
       customerService.saveOrUpdate(customer);
       request.setAttribute("successMarkDialog", "true");
       return SUCCESS;
     }
     return INPUT;
   } catch (Exception e) {
     addFieldError("mainStr", e.getMessage());
   }
   return INPUT;
 }