ModelAndView mav = new ModelAndView(getSuccessView());
PipeLineElement pipeLineElement=(PipeLineElement)command;
Integer objectId=(Integer)request.getSession().getAttribute("objectId");
if(request.getParameter("cansel")!=null){
return new ModelAndView("redirect:/lookPipeLineElement.html?detailType="+request.getParameter("newDetailType")+"&objectId="+objectId);
}
Integer detailType=pipeLineElement.getDetailType().getTypeId();
pipeLineElement.setDetailType(detailManager.getDetailTypesById(detailType));
if(request.getParameter("newDetailType")!=null){
if (detailType.equals(new Integer(1))){
mav.addObject("detailList",detailManager.getAllPipe());
}
if (detailType.equals(new Integer(2))){
mav.addObject("detailList",detailManager.getAllTap());
}
if (detailType.equals(new Integer(3))){
mav.addObject("detailList",detailManager.getAllTransition());
}
if (detailType.equals(new Integer(4))){
mav.addObject("detailList",detailManager.getAllTee());
}
if (detailType.equals(new Integer(5))){
mav.addObject("detailList",detailManager.getAllZaglushka());
}
if (detailType.equals(new Integer(6))){
mav.addObject("detailList",detailManager.getAllFlange());
}
if (detailType.equals(new Integer(7))){
mav.addObject("detailList",detailManager.getAllArmature());
}
if (detailType.equals(new Integer(8))){
mav.addObject("detailList",detailManager.getAllOborudovanie());
}
mav.addObject("detailType",detailType);
mav.addObject("pipe",pipeLineElement);
return mav;
}
if (detailType.equals(new Integer(1))){
pipeLineElement.setDetail(detailManager.getPipeById(pipeLineElement.getDetail().getDetailId()));
}
if (detailType.equals(new Integer(2))){
pipeLineElement.setDetail(detailManager.getTapById(pipeLineElement.getDetail().getDetailId()));
}
if (detailType.equals(new Integer(3))){
pipeLineElement.setDetail(detailManager.getTransitionById(pipeLineElement.getDetail().getDetailId()));
}
if (detailType.equals(new Integer(4))){
pipeLineElement.setDetail(detailManager.getTeeById(pipeLineElement.getDetail().getDetailId()));
}
if (detailType.equals(new Integer(5))){
pipeLineElement.setDetail(detailManager.getZaglushkaById(pipeLineElement.getDetail().getDetailId()));
}
if (detailType.equals(new Integer(6))){
pipeLineElement.setDetail(detailManager.getFlangeById(pipeLineElement.getDetail().getDetailId()));
}
if (detailType.equals(new Integer(7))){
pipeLineElement.setDetail(detailManager.getArmatureById(pipeLineElement.getDetail().getDetailId()));
}
if (detailType.equals(new Integer(8))){
pipeLineElement.setDetail(detailManager.getOborudovanieById(pipeLineElement.getDetail().getDetailId()));
}
if (pipeLineElement.getIdElement()!=null){
pipeLineElementManager.update(pipeLineElement);
return new ModelAndView("redirect:/lookPipeLineElement.html?detailType="+detailType+"&objectId="+objectId);
}
else{
VisualInspection visualInspection=new VisualInspection();
visualInspection.setInspectionDescription("");
visualInspection.setInspectionValidity(false);
visualInspectionManager.insert(visualInspection);
pipeLineElement.setVisualInspection(visualInspection);
pipeLineElementManager.insert(pipeLineElement);
ObjectInspection objectInspection=objectInspectionManager.getObjectInspectionBy(objectId);
objectInspection.getPipeLineList().add(pipeLineElement);
objectInspectionManager.updateObjectInspection(objectInspection);
return new ModelAndView("redirect:/lookPipeLineElement.html?detailType="+detailType+"&objectId="+objectId);