Package com.vst.model

Examples of com.vst.model.Photo


    public void setDao(PhotoDao dao) {
        this.dao = dao;
    }

    public Photo insertPhoto(CommonsMultipartFile file, String  currentPath) throws Exception {
       Photo photo=new Photo();
       if(file!=null && file.getSize()>0)
                {
                    Date date=new Date();
                    String wayToPhoto=String.valueOf(date.getTime())+".jpg";
                    OutputStream fl=new FileOutputStream(currentPath+wayToPhoto);
                    try {
                        fl.write(file.getBytes());
                        fl.close();
                        InputStream inputStream=new FileInputStream(currentPath+wayToPhoto);

                        photo.setPhotoPlob(Hibernate.createBlob(ImageUtil.scaleImage(inputStream)));
                        photo.setWayToPhoto(wayToPhoto);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
       dao.insert(photo);
View Full Code Here


       dao.update(photo);
       return photo;
    }

   public Photo insertPhoto(CommonsMultipartFile file, String  currentPath,int w,int h) throws Exception {
       Photo photo=new Photo();
       if(file!=null && file.getSize()>0)
                {
                    Date date=new Date();
                    String wayToPhoto=String.valueOf(date.getTime())+".jpg";
                    OutputStream fl=new FileOutputStream(currentPath+wayToPhoto);
                    try {
                        fl.write(file.getBytes());
                        fl.close();
                        InputStream inputStream=new FileInputStream(currentPath+wayToPhoto);

                        photo.setPhotoPlob(Hibernate.createBlob(ImageUtil.scaleImage(inputStream,w,h)));
                        photo.setWayToPhoto(wayToPhoto);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
       dao.insert(photo);
View Full Code Here


        if (companyLicense.getLicenseId() != null) {
            String comment = companyLicense.getPhoto().getComment();
            companyLicense = companyLicenseManager.getById(companyLicense.getLicenseId());
            Photo photo = photoManager.getByIdPhoto(companyLicense.getPhoto().getPhotoId());
            photo.setComment(comment);            
            photoManager.update(photo, file, FileHelper.getCurrentPath(request),400,400);
            companyLicenseManager.update(companyLicense);
            return new ModelAndView("redirect:/companyLicenseList.html");

        } else {
            if (file.getSize() > 0) {
                Photo photo = photoManager.insertPhoto(file, FileHelper.getCurrentPath(request),400,400);
                photo.setComment(companyLicense.getPhoto().getComment());
                companyLicense.setPhoto(photo);
            }
            companyLicenseManager.insert(companyLicense);
            mav.addObject("result", new Integer(1));
        }
View Full Code Here

      if (companyLicenseManager.getList(page) != null) {
            list = companyLicenseManager.getList(page);
            for (int i = 0; i < list.size(); i++) {
                CompanyLicense companyLicense = (CompanyLicense) list.get(i);

                Photo photo = photoManager.getByIdPhoto(companyLicense.getPhoto().getPhotoId());
                photoManager.prepareForOpen(photo, FileHelper.getCurrentPath(request));
                companyLicense.setPhoto(photo);
            }
        }
      return list;
View Full Code Here

        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"));
View Full Code Here

        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);
View Full Code Here

    public boolean supports(Class aClass) {
        return (Photo.class.isAssignableFrom(aClass));
    }

    public void validate(Object o, Errors errors) {
        Photo photo=(Photo)o;
        if ((photo.getFile()==null || photo.getFile().length==0) && photo.getPhotoId()==null){
            errors.rejectValue("file","expert.error.fileName");
        }
    }
View Full Code Here

TOP

Related Classes of com.vst.model.Photo

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.