public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
ModelAndView mav = new ModelAndView("lookDiameter");
String result = "";
if (httpServletRequest.getParameter("delete") != null) {
Integer id = (Integer) Integer.parseInt(httpServletRequest.getParameter("delete"));
Diameter diameter = diameterManager.getDiameterById(id);
List pipeList = detailManager.getPipeListByDiameterId(id);
List tapList = detailManager.getTapListByDiameterId(id);
List teeList = detailManager.getTeeListByDiameterId(id);
List transitionList = detailManager.getTransitionListByDiameterId(id);
List armatureList = detailManager.getArmatureListByDiameterId(id);
List oborList = detailManager.getOborudovaniListByDiameterId(id);
List zaglushkaList = detailManager.getZaglushkaListByDiameterId(id);
List flangeList = detailManager.getFlangeListByDiameterId(id);
int count = pipeList.size() + tapList.size() + teeList.size() + transitionList.size() + armatureList.size() + oborList.size() + zaglushkaList.size() + flangeList.size();
if (count > 0) {
result += "Диаметр не может быть удален, так как он используется " + count + " раз(а) в других справочниках:<br>";
result += "<table><tr><td>Спаравочник</td><td>Деталь</td></tr>";
for (int i = 0; i < pipeList.size(); i++) {
Pipe o = (Pipe) pipeList.get(i);
result += "<tr><td>" + o.getDetailTypes().getTypeName() + "</td><td><a href=\"" + httpServletRequest.getRequestURL().toString().replaceAll("/lookDiameter.html", "") + "/lookDetail.html?type=pipe\"><ul>" +
"<li>" + o.getGost().getGostName() +
"<li>Диаметр: " + o.getDiametr() +
"<li>Толщина: " + o.getThickness() +
"<li>Материал: " + o.getMaterial() + "</ul></a></td></tr>";
}
for (int i = 0; i < tapList.size(); i++) {
Tap o = (Tap) tapList.get(i);
result += "<tr><td>" + o.getDetailTypes().getTypeName() + "</td><td><a href=\"" + httpServletRequest.getRequestURL().toString().replaceAll("/lookDiameter.html", "") + "/lookDetail.html?type=tap\"><ul>" +
"<li>" + o.getGost().getGostName() +
"<li>Диаметр: " + o.getDiametr() +
"<li>Толщина: " + o.getThickness() +
"<li>Материал: " + o.getMaterial() +
"<li>Угол: " + o.getCorner() + "</ul></a></td></tr>";
}
for (int i = 0; i < transitionList.size(); i++) {
Transition o = (Transition) transitionList.get(i);
result += "<tr><td>" + o.getDetailTypes().getTypeName() + "</td><td><a href=\"" + httpServletRequest.getRequestURL().toString().replaceAll("/lookDiameter.html", "") + "/lookDetail.html?type=transition\"><ul>" +
"<li>" + o.getGost().getGostName() +
"<li>Первый диаметр: " + o.getFirstDiametr() +
"<li>Первая толщина: " + o.getFirstThickness() +
"<li>Второй длиаметр: " + o.getSecondDiametr() +
"<li>Вторая толщина: " + o.getSecondThickness() +
"<li>Материал: " + o.getMaterial() + "</ul></a></td></tr>";
}
for (int i = 0; i < teeList.size(); i++) {
Tee o = (Tee) teeList.get(i);
result += "<tr><td>" + o.getDetailTypes().getTypeName() + "</td><td><a href=\"" + httpServletRequest.getRequestURL().toString().replaceAll("/lookDiameter.html", "") + "/lookDetail.html?type=tee\"><ul>" +
"<li>" + o.getGost().getGostName() +
"<li>Первый диаметр: " + o.getFirstDiametr() +
"<li>Первая толщина: " + o.getFirstThickness() +
"<li>Второй длиаметр: " + o.getSecondDiametr() +
"<li>Вторая толщина: " + o.getSecondThickness() +
"<li>Материал: " + o.getMaterial() + "</ul></a></td></tr>";
}
for (int i = 0; i < zaglushkaList.size(); i++) {
Zaglushka o = (Zaglushka) zaglushkaList.get(i);
result += "<tr><td>" + o.getDetailTypes().getTypeName() + "</td><td><a href=\"" + httpServletRequest.getRequestURL().toString().replaceAll("/lookDiameter.html", "") + "/lookDetail.html?type=zaglushka\"><ul>" +
"<li>" + o.getGost().getGostName() +
"<li>Диаметр: " + o.getDiametr() +
"<li>Толщина: " + o.getThickness() +
"<li>Материал: " + o.getMaterial() + "</ul></a></td></tr>";
}
for (int i = 0; i < flangeList.size(); i++) {
Flange o = (Flange) flangeList.get(i);
result += "<tr><td>" + o.getDetailTypes().getTypeName() + "</td><td><a href=\"" + httpServletRequest.getRequestURL().toString().replaceAll("/lookDiameter.html", "") + "/lookDetail.html?type=flange\"><ul>" +
"<li>" + o.getGost().getGostName() +
"<li>Диаметр: " + o.getDiametr() +
"<li>Толщина: " + o.getThickness() +
"<li>Материал: " + o.getMaterial() +
"<li>Давление: " + o.getPressure() + "</ul></td></tr>";
}
for (int i = 0; i < armatureList.size(); i++) {
Armature o = (Armature) armatureList.get(i);
result += "<tr><td>" + o.getDetailTypes().getTypeName() + "</td><td><a href=\"" + httpServletRequest.getRequestURL().toString().replaceAll("/lookDiameter.html", "") + "/lookDetail.html?type=armature\"><ul>" +
"<li>" + o.getGost().getGostName() +
"<li>Название: " + o.getName() +
"<li>Диаметр: " + o.getDiametr() +
"<li>Материал: " + o.getMaterial() +
"<li>Маркировка: " + o.getMarks() +
"<li>Давление: " + o.getPressure() + "</ul</a></td></tr>";
}
for (int i = 0; i < oborList.size(); i++) {
Oborudovanie o = (Oborudovanie) oborList.get(i);
result += "<tr><td>" + o.getDetailTypes().getTypeName() + "</td><td><a href=\"" + httpServletRequest.getRequestURL().toString().replaceAll("/lookDiameter.html", "") + "/lookDetail.html?type=oborudovanie\"><ul>" +
"<li>" + o.getGost().getGostName() +
"<li>Диаметр: " + o.getDiametr() +
"<li>Название: " + o.getName() +
"<li>Стоимость: " + o.getExpenses() +
"<li>Давление: " + o.getPressure() + "</ul></a></td></tr>";
}
result += "</table>";
} else {
diameterManager.delete(diameter);
}
}
Integer page = new Integer(0);
Integer pageCount;
if (httpServletRequest.getParameter("page") != null) {
page = (Integer) Integer.parseInt(httpServletRequest.getParameter("page"));
}
List dList = diameterManager.getListDiameter(page);
List diameterList = new ArrayList();
for (int i = 0; i < dList.size(); i++) {
DiameterHelper diameterHelper = new DiameterHelper();
Diameter diameter = (Diameter) dList.get(i);
diameterHelper.setDiametrCount(diameter.getDiametrCount());
diameterHelper.setDiametrId(diameter.getDiametrId());
diameterHelper.setGost(diameter.getGost());
diameterHelper.setThicknessList(diameter.getThicknessList());
diameterHelper.setThCount(Integer.valueOf(diameter.getThicknessList().size()));
diameterList.add(diameterHelper);
}
mav.addObject("result", result);
mav.addObject("diameter", diameterList);