Package com.vst.model

Examples of com.vst.model.ConstructionExample


        boolean noPhoto = true;
        if (objectConstructionId != null) {
            ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(objectConstructionId);
            List constructionExampleList = objectConstruction.getConstructionExamples();
            for (int i = 0; i < constructionExampleList.size(); i++) {
                ConstructionExample constructionExample = (ConstructionExample) constructionExampleList.get(i);
                if (constructionExample.getWayToDefectEsckiz() != null && !"".equals(constructionExample.getWayToDefectEsckiz()) && constructionExample.getDefectEsckizBlob() != null) {
                    noPhoto = false;
                    File file = new File(FileHelper.getCurrentPath(request) + constructionExample.getWayToDefectEsckiz());
                    if (file.exists()) {
                        file.delete();
                    }
                    file.createNewFile();
                    FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + constructionExample.getWayToDefectEsckiz());
                    Blob blob = constructionExample.getDefectEsckizBlob();
                    byte[] bufer = new byte[62000];
                    InputStream inputStream = blob.getBinaryStream();
                    while (inputStream.read(bufer) != -1) {
                        fileOutputStream.write(bufer);
                    }
                    inputStream.close();
                    fileOutputStream.close();
                }
                wayMap = new HashMap();
                wayMap.put("way", constructionExample.getWayToDefectEsckiz());
                wayMap.put("comment", constructionExample.getExampleName() == null ? String.valueOf(constructionExample.getExampleRelativeNumber()) : constructionExample.getExampleName());
                waysToEskiz.add(wayMap);
            }
            request.setAttribute("noPhoto", new Boolean(noPhoto));
            return new ModelAndView("allExamplesEskiz", Constants.EXAMPLE_ESKIZ_WAYS, waysToEskiz);
View Full Code Here


         return ConstructionExample.class.isAssignableFrom(candidate);
     }

     public void validate(Object obj, Errors errors) {

         ConstructionExample constructionExample=(ConstructionExample)obj;


         }
View Full Code Here

            log.debug("entering 'handleRequest' method...");
        }

        String exampleId = request.getParameter("exampleId");
        if (exampleId != null) {
            ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(exampleId);
            if (constructionExample.getWayToDefectEsckiz() != null && !"".equals(constructionExample.getWayToDefectEsckiz())) {
                File file = new File(FileHelper.getCurrentPath(request) + constructionExample.getWayToDefectEsckiz());
                if (file.exists()) {
                    file.delete();
                }
                file.createNewFile();
                FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + constructionExample.getWayToDefectEsckiz());
                Blob blob = constructionExample.getDefectEsckizBlob();
                byte[] bufer = new byte[62000];
                InputStream inputStream = blob.getBinaryStream();
                while (inputStream.read(bufer) != -1) {
                    fileOutputStream.write(bufer);
                }
                inputStream.close();
                fileOutputStream.close();
            } else {
                request.setAttribute("noPhoto", "true");
            }

            if (constructionExample.getWayToPowerEsckiz() != null && !"".equals(constructionExample.getWayToPowerEsckiz())) {
                File file = new File(FileHelper.getCurrentPath(request) + constructionExample.getWayToPowerEsckiz());
                if (file.exists()) {
                    file.delete();
                }
                file.createNewFile();
                FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + constructionExample.getWayToPowerEsckiz());
                Blob blob = constructionExample.getPowerEsckizBlob();
                byte[] bufer = new byte[62000];
                InputStream inputStream = blob.getBinaryStream();
                while (inputStream.read(bufer) != -1) {
                    fileOutputStream.write(bufer);
                }
                inputStream.close();
                fileOutputStream.close();
            } else {
                request.setAttribute("noPowerPhoto", "true");
            }
            request.setAttribute("defectPhoto", constructionExample.getWayToDefectEsckiz());
            request.setAttribute("powerPhoto", constructionExample.getWayToPowerEsckiz());
            return new ModelAndView("examplePicture");

        } else {
            request.setAttribute("noObjectConstruction", "true");
        }
View Full Code Here

    }

    public List fillConstractionExampleData(List constructionExamples , Integer exampleId){
        for (int i = 0; i < constructionExamples.size(); i++) {

            ConstructionExample constructionExample =  (ConstructionExample)constructionExamples.get(i);

            if(constructionExample.getExampleId().equals(exampleId))    {
               constructionExample.setExampleDefects(dao.getExampleDefectsById(exampleId));
               constructionExample.setExampleDefectsZone(dao.getExampleDefectsZoneById(exampleId));
            }
            long size=dao.getExampleDefectCount(constructionExample.getExampleId().toString()).longValue()+dao.getExampleDefectZoneCount(constructionExample.getExampleId().toString()).longValue();
                constructionExample.setDefectCount((int)size);
                constructionExample.setRecommendedDangerCategory(getConstructionRecommendedDangerCategory(constructionExample.getExampleId().toString()));

         }
        return constructionExamples;
    }
View Full Code Here

    protected Object formBackingObject(HttpServletRequest request)
            throws Exception {
        if (!isFormSubmission(request)) {
            String exampleId = request.getParameter("exampleId");
            ConstructionExample constructionExample = null;
            String typeId = "-1";
            if(request.getParameter("typeId") != null)
              typeId = request.getParameter("typeId");
            else if(request.getAttribute("typeId") != null)
              typeId = request.getAttribute("typeId").toString();
             
            request.setAttribute("dangerCategoryList", dangerCategoryManager.getDangerCategorys(null));
            if (!StringUtils.isEmpty(exampleId)) {
                constructionExample = constructionExampleManager.getConstructionExample(exampleId);
                //constructionExampleManager.evict(constructionExample);
            } else {
                constructionExample = new ConstructionExample();

                //generating the unique number of construction
                Integer number =constructionExampleManager.getExampleNumberByConstructionObjectId(new Integer(typeId));
                constructionExample.setExampleRelativeNumber(number);


            }


            if (typeId != null) {
                //   constructionExample.setConstructionType(((ObjectConstruction)objectConstructionManager.getObjectConstruction(typeId)).getConstructionType());
                constructionExample.setObjectConstructionId(new Integer(typeId));
            }
            constructionExampleManager.makeNotNull(constructionExample);
            if (request.getParameter("edited") != null) {
                request.setAttribute("addition", "?edited=1");
                constructionExample.setEdited(true);
            }

            //checking esciz
            if (constructionExample.getWayToDefectEsckiz() == null || constructionExample.getWayToDefectEsckiz().equals("")) {
                //retrieving esciz from object construction
                ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(constructionExample.getObjectConstructionId().toString());
                //esciz for defects
                if (objectConstruction.getEsckizBlob() != null && objectConstruction.getWayToEsckiz() != null && !objectConstruction.getWayToEsckiz().equals("")) {
                    String wayToDefectEskiz = ImageUtil.getUniqueJPEGFile(request);
                    constructionExample.setWayToDefectEsckiz(wayToDefectEskiz);
                    objectConstruction.getEsckizBlob();
                    File file = new File(FileHelper.getCurrentPath(request) + wayToDefectEskiz);
                    file.createNewFile();
                    FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + wayToDefectEskiz);
                    Blob blob = objectConstruction.getEsckizBlob();
                    byte[] bufer = new byte[62000];
                    InputStream inputStream = blob.getBinaryStream();
                    while (inputStream.read(bufer) != -1) {
                        fileOutputStream.write(bufer);
                    }
                    inputStream.close();
                    fileOutputStream.close();

                    //esciz for power points
                    String wayToPowerEskiz = ImageUtil.getUniqueJPEGFile(request);
                    constructionExample.setWayToPowerEsckiz(wayToPowerEskiz);
                    objectConstruction.getEsckizBlob();
                    file = new File(FileHelper.getCurrentPath(request) + wayToPowerEskiz);
                    if (file.exists()) {
                        file.delete();
                    }
                    file.createNewFile();
                    fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + wayToPowerEskiz);
                    blob = objectConstruction.getEsckizBlob();
                    byte[] powerBufer = new byte[62000];
                    inputStream = blob.getBinaryStream();
                    while (inputStream.read(powerBufer) != -1) {
                        fileOutputStream.write(powerBufer);
                    }
                    inputStream.close();
                    fileOutputStream.close();
                }
            }
            constructionExample.setDocLocation(request.getParameter("docLocation"));

            return constructionExample;
        } else {
            return super.formBackingObject(request);
        }
View Full Code Here

            throws Exception {
        if (log.isDebugEnabled()) {
            log.debug("entering 'onSubmit' method...");
        }

        ConstructionExample constructionExample = (ConstructionExample) command;
        boolean isNew = (constructionExample.getExampleId() == null);
        Locale locale = request.getLocale();

        if (request.getParameter("delete") != null) {
            ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(constructionExample.getObjectConstructionId().toString());

            objectConstruction.getConstructionExamples().remove(constructionExample);
            objectConstructionManager.saveObjectConstruction(objectConstruction);
            saveMessage(request, getText("constructionExample.deleted", locale));
        } else {
            Integer dangerId = constructionExample.getDangerCategory().getDangerCategoryId();
            if (!dangerId.equals(new Integer(-1))) {
                constructionExample.setDangerCategory(dangerCategoryManager.getDangerCategory(dangerId.toString()));
            } else {
                constructionExample.setDangerCategory(null);
            }
            ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(constructionExample.getObjectConstructionId().toString());
            objectConstructionManager.evict(objectConstruction);
            constructionExample.setConstructionType(objectConstruction.getConstructionType());
            if (constructionExample.getWayToPowerEsckiz() != null && !constructionExample.getWayToPowerEsckiz().equals("") && (new File(FileHelper.getCurrentPath(request) + constructionExample.getWayToDefectEsckiz())).exists()) {

                constructionExample.setDefectEsckizBlob(Hibernate.createBlob(new FileInputStream(FileHelper.getCurrentPath(request) + constructionExample.getWayToDefectEsckiz())));
            }
            if (constructionExample.getWayToPowerEsckiz() != null && !constructionExample.getWayToPowerEsckiz().equals("") && (new File(FileHelper.getCurrentPath(request) + constructionExample.getWayToPowerEsckiz())).exists()) {
                constructionExample.setPowerEsckizBlob(Hibernate.createBlob(new FileInputStream(FileHelper.getCurrentPath(request) + constructionExample.getWayToPowerEsckiz())));
            }
            //restoring construction examples associations
            if (!isNew) {
                ConstructionExample oldConstructionExample = constructionExampleManager.getConstructionExample(constructionExample.getExampleId().toString());
                constructionExample.setExampleDefects(oldConstructionExample.getExampleDefects());
                constructionExample.setConstructionType(oldConstructionExample.getConstructionType());
                constructionExample.setStrengthPoints(oldConstructionExample.getStrengthPoints());
                constructionExample.setDefectEsckizBlob(oldConstructionExample.getDefectEsckizBlob());
                constructionExample.setWayToDefectEsckiz(oldConstructionExample.getWayToDefectEsckiz());
                constructionExample.setWayToPowerEsckiz(oldConstructionExample.getWayToPowerEsckiz());
                constructionExample.setPowerEsckizBlob(oldConstructionExample.getPowerEsckizBlob());
                constructionExampleManager.evict(oldConstructionExample);
            }

            if (isNew) {
                constructionExample.setBuildObjectId(objectConstruction.getObjectId());
View Full Code Here

    public ModelAndView processFormSubmission(HttpServletRequest request,
                                              HttpServletResponse response,
                                              Object command,
                                              BindException errors)
            throws Exception {
        ConstructionExample constructionExample = (ConstructionExample) command;
        if (request.getParameter("cancel") != null) {
            String addition = "";
            if (constructionExample.getExampleId() != null) {
                addition = "&exampleId=" + constructionExample.getExampleId();
            }
            return new ModelAndView("redirect: constructionExamples.html?typeId=" + constructionExample.getObjectConstructionId() + addition);
        }

        return super.processFormSubmission(request, response, command, errors);
    }
View Full Code Here

        constructionExampleManager = null;
    }

    public void testGetConstructionExamples() throws Exception {
        List results = new ArrayList();
        ConstructionExample constructionExample = new ConstructionExample();
        results.add(constructionExample);

        // set expected behavior on dao
        constructionExampleDao.expects(once()).method("getConstructionExamples")
            .will(returnValue(results));
View Full Code Here

    }

    public void testGetConstructionExample() throws Exception {
        // set expected behavior on dao
        constructionExampleDao.expects(once()).method("getConstructionExample")
            .will(returnValue(new ConstructionExample()));
        ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(constructionExampleId);
        assertTrue(constructionExample != null);
        constructionExampleDao.verify();
    }
View Full Code Here

        assertTrue(constructionExample != null);
        constructionExampleDao.verify();
    }

    public void testSaveConstructionExample() throws Exception {
        ConstructionExample constructionExample = new ConstructionExample();

        // set expected behavior on dao
        constructionExampleDao.expects(once()).method("saveConstructionExample")
            .with(same(constructionExample)).isVoid();
View Full Code Here

TOP

Related Classes of com.vst.model.ConstructionExample

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.