Package com.vst.model

Examples of com.vst.model.PipeLineElementDefect


    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        ModelAndView modelAndView = new ModelAndView("pipeLineElementDefectList");
        Integer elementId = Integer.valueOf(httpServletRequest.getParameter("pipeElementId"));
        if (httpServletRequest.getParameter("delete") != null) {
            Integer deleteId = Integer.valueOf(httpServletRequest.getParameter("delete"));
            PipeLineElementDefect pipeLineElementDefect = pipeLineElementDefectManager.getPipeLineElementDefectById(deleteId);
            Integer fphotoId = pipeLineElementDefect.getFirstPhoto().getPhotoId();
            Integer sphotoId = pipeLineElementDefect.getSecondPhoto().getPhotoId();
            PipeLineElement pipeLineElement = pipeLineElementManager.getPipeLineElementById(elementId);
            pipeLineElement.getPipeLineElementDefectList().remove(pipeLineElementDefect);
            pipeLineElementDefectManager.delete(pipeLineElementDefect);
            if (fphotoId != null) {
                photoManager.delete(photoManager.getByIdPhoto(fphotoId));
            }
            if (sphotoId != null) {
                photoManager.delete(photoManager.getByIdPhoto(sphotoId));
            }

        }

        List list = pipeLineElementDefectManager.getPipeLineElementDefectByPipeLineElement(elementId, FileHelper.getCurrentPath(httpServletRequest));

        for (int i = 0; i < list.size(); i++) {
            PipeLineElementDefect pipe = (PipeLineElementDefect) list.get(i);
            pipe = pipeLineElementDefectManager.getPipeLineElementDefectById(pipe.getDefectId());

            Photo photo = photoManager.getByIdPhoto(pipe.getFirstPhoto().getPhotoId());
            if (photo.getPhotoPlob()!= null && photo.getPhotoPlob().length()>0 && !photo.getWayToPhoto().trim().equals("")) {
                photoManager.prepareForOpen(photo, FileHelper.getCurrentPath(httpServletRequest));
            else{
                photo.setWayToPhoto("no photo");
            }
            pipe.setFirstPhoto(photo);

            photo = photoManager.getByIdPhoto(pipe.getSecondPhoto().getPhotoId());
            if (photo.getPhotoPlob()!= null && photo.getPhotoPlob().length()>0 && !photo.getWayToPhoto().trim().equals("")) {
                photoManager.prepareForOpen(photo, FileHelper.getCurrentPath(httpServletRequest));
            }else{
                photo.setWayToPhoto("no photo");
            }
            pipe.setSecondPhoto(photo);
            list.set(i, pipe);
        }
        modelAndView.addObject("objectId", httpServletRequest.getParameter("objectId"));
        modelAndView.addObject("detailType", httpServletRequest.getParameter("detailType"));
        modelAndView.addObject("pipeElementId", elementId);
View Full Code Here


        if (!isFormSubmission(request)) {
            request.getSession().setAttribute("objectId", request.getParameter("objectId"));
            request.getSession().setAttribute("detailType", request.getParameter("detailType"));
            request.getSession().setAttribute("pipeElementId", request.getParameter("pipeElementId"));
            PipeLineElementDefect pipeLineElementDefect = new PipeLineElementDefect();
            if (request.getParameter("update") != null) {
                pipeLineElementDefect = pipeLineElementDefectManager.getPipeLineElementDefectById(Integer.valueOf(request.getParameter("update")));
            }
            return pipeLineElementDefect;
        }
View Full Code Here

                                 HttpServletResponse response,
                                 Object command,
                                 BindException errors) throws Exception, SQLException {

        ModelAndView mav = new ModelAndView(getSuccessView());
        PipeLineElementDefect pipeLineElementDefect = (PipeLineElementDefect) command;

        Integer elementId = Integer.valueOf(request.getSession().getAttribute("pipeElementId").toString());
        PipeLineElement pipeLineElement = pipeLineElementManager.getPipeLineElementById(elementId);
        pipeLineElementDefect.setDangerCategory(dangerCategoryManager.getDangerCategory(String.valueOf(pipeLineElementDefect.getDangerCategory().getDangerCategoryId())));
        pipeLineElementDefect.setDefectType(defectTypeManager.getDefectType(String.valueOf(pipeLineElementDefect.getDefectType().getDefectTypeId())));
        if (pipeLineElementDefect.getDefectVarity().getVarityId()!=null && pipeLineElementDefect.getDefectVarity().getVarityId().longValue()!=-1){
            pipeLineElementDefect.setDefectVarity(defectVarityManager.getDefectVarity(String.valueOf(pipeLineElementDefect.getDefectVarity().getVarityId())));            
        }


        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;

        CommonsMultipartFile ffile = (CommonsMultipartFile) multipartRequest.getFile("firstPhoto.file");
        CommonsMultipartFile sfile = (CommonsMultipartFile) multipartRequest.getFile("secondPhoto.file");

        if (pipeLineElementDefect.getDefectId() != null) {
            pipeLineElementDefect = pipeLineElementDefectManager.getPipeLineElementDefectById(pipeLineElementDefect.getDefectId());
            Photo photo = photoManager.getByIdPhoto(pipeLineElementDefect.getFirstPhoto().getPhotoId());
            photoManager.update(photo, ffile, FileHelper.getCurrentPath(request));
            photo = photoManager.getByIdPhoto(pipeLineElementDefect.getSecondPhoto().getPhotoId());
            photoManager.update(photo, sfile, FileHelper.getCurrentPath(request));
            pipeLineElementDefectManager.update(pipeLineElementDefect);
            return new ModelAndView("redirect:/pipeLineElementDefectList.html?objectId=" + request.getParameter("objectId") + "&detailType=" + request.getParameter("detailType") + "&pipeElementId=" + elementId);
        } else {

            if (ffile != null && ffile.getSize() > 0) {
                Photo photo = photoManager.insertPhoto(ffile, FileHelper.getCurrentPath(request));
                pipeLineElementDefect.setFirstPhoto(photo);
            } else {
                Photo photo = new Photo();
                photo.setWayToPhoto("no photo");
                photoManager.insert(photo);
                pipeLineElementDefect.setFirstPhoto(photo);
            }
            if (sfile != null && sfile.getSize() > 0) {
                Photo photo = photoManager.insertPhoto(sfile, FileHelper.getCurrentPath(request));
                pipeLineElementDefect.setSecondPhoto(photo);
            } else {
                Photo photo = new Photo();
                photo.setWayToPhoto("no photo");
                photoManager.insert(photo);
                pipeLineElementDefect.setSecondPhoto(photo);
            }
          
            pipeLineElementDefectManager.insert(pipeLineElementDefect);

            pipeLineElement.getPipeLineElementDefectList().add(pipeLineElementDefect);

            pipeLineElementManager.update(pipeLineElement);

           mav.addObject("result", new Integer(1));
        }

        mav.addObject("objectId", request.getParameter("objectId"));
        mav.addObject("detailType", request.getParameter("detailType"));
        mav.addObject("pipeElementId", elementId);
        mav.addObject("pipeLineElementDefect", new PipeLineElementDefect());

        return mav;
    }
View Full Code Here

        List list = new ArrayList();
        try {
            ResultSet resultSet = connection.createStatement().executeQuery("select * from pipelineelementdefect where idElement=" + id);

            while (resultSet.next()) {
                PipeLineElementDefect pipeLineElementDefect = new PipeLineElementDefect();
                pipeLineElementDefect.setDefectId((Integer) resultSet.getInt(1));
                pipeLineElementDefect.setDefectType(defectTypeDao.getDefectType((Integer) resultSet.getInt(2)));
                pipeLineElementDefect.setDefectVarity(defectVarityDao.getDefectVarity((Integer) resultSet.getInt(3)));
                pipeLineElementDefect.setDangerCategory(dangerCategoryDao.getDangerCategory((Integer) resultSet.getInt(4)));
                pipeLineElementDefect.setComment(resultSet.getString(5));
                list.add(pipeLineElementDefect);
            }
            resultSet.close();
        } catch (SQLException e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
View Full Code Here

TOP

Related Classes of com.vst.model.PipeLineElementDefect

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.