Package com.vst.model

Examples of com.vst.model.ConstructionDefect


        // getting defect categories for constructiontype in the current object
        List constructionDefects = buildingObjectDao.getConstructionDefectsOfType(constructionTypeId,buildingObjectId);
        //getting defect category for the current construction defect
        Set defectCategorySet = new HashSet();
        for (int i = 0; i < constructionDefects.size(); i++) {
            ConstructionDefect constructionDefect = (ConstructionDefect) constructionDefects.get(i);
            DefectCategory defectCategory = defectCategoryDao.getDefectCategoryByConstructionDefect(constructionDefect.getConstructionDefectId().toString(),constructionTypeId);
            if (defectCategory != null) {
                defectCategorySet.add(defectCategory);
            }
        }
View Full Code Here


        request = newGet("/editConstructionDefect.html");
        request.addParameter("constructionDefectId", "1");

        mv = c.handleRequest(request, new MockHttpServletResponse());

        ConstructionDefect constructionDefect = (ConstructionDefect) mv.getModel().get(c.getCommandName());
        assertNotNull(constructionDefect);
        request = newPost("/editConstructionDefect.html");
        super.objectToRequestParameters(constructionDefect, request);

        // update the form's fields and add it back to the request
View Full Code Here

        return ConstructionDefect.class.isAssignableFrom(candidate);
    }

    public void validate(Object obj, Errors errors) {

        ConstructionDefect constructionDefect = (ConstructionDefect) obj;
        if (constructionDefect.getDangerCategory().getDangerCategoryId().equals(new Long(-1))) {
            errors.rejectValue("dangerCategory", "constructionDefect.noDangerCategory");
        }

        if (constructionDefect.getDefectType().getDefectTypeId().equals(new Long(-1))) {
            errors.rejectValue("defectType", "constructionDefect.noDefectType");
        } else {
            //checking if all defect parameters were filled
            List defectParameterList = constructionDefect.getDefectParameters();
            for (int i = 0; i < defectParameterList.size(); i++) {
                DefectParameter defectParameter = (DefectParameter) defectParameterList.get(i);
                if (defectParameter.getParameterValue() == 0.0) {
                    errors.rejectValue("defectParameters[" + i + "]", "constructionDefect.noDefectParameterValue");

                }
            }
        }
        if (constructionDefect.getDefectVarity().getVarityId().equals(new Long(-1))) {
            errors.rejectValue("defectVarity", "constructionDefect.noDefectVarity");
        }
        if (constructionDefect.getDefectZone().getDefectZoneId().equals(new Long(-1))) {
            errors.rejectValue("defectZone", "constructionDefect.noDefectZone");
        }


    }
View Full Code Here

        String exId = request.getParameter("exampleId");
        ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(exId);

        if (request.getParameter("type").equals("simple")) {

            ConstructionDefect constructionDefect = constructionDefectManager.getConstructionDefect(constructionDefectId);
            ConstructionDefect newConstructionDefect = (ConstructionDefect) elementCopyManager.getNewObject(constructionDefect);

            constructionExample.getExampleDefects().add(newConstructionDefect);
            constructionDefectManager.saveConstructionDefect(newConstructionDefect);
            constructionExampleManager.saveConstructionExample(constructionExample);
View Full Code Here

        if (extractDefectTypeParam(request).equals("simple")) {


            boolean hasFatalError = false;
            try {
                ConstructionDefect constructionDefect = constructionDefectManager.getConstructionDefect(constructionDefectId);
                ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(constructionDefect.getExampleId().toString());
                constructionExample.getExampleDefects().remove(constructionDefect);
                constructionExampleManager.saveConstructionExample(constructionExample);
                request.getSession().setAttribute("madeChanges", new Boolean(true));
                request.setAttribute("message", bundle.getString("constructionDefect.deleted"));

                ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(constructionExample.getObjectConstructionId().toString());
        try {
          doDeleteDefectSymbols(request, objectConstruction.getWayToDefectMap(),
              constructionDefect);
        } catch (IOException e) {

        }

            } catch (Exception e) {
                hasFatalError = true;
            }
            if (hasFatalError) {
                request.setAttribute("errormessage", bundle.getString("commonMistake"));
            }

        } else if (extractDefectTypeParam(request).equals("zone")) {

            ConstructionDefectZone constructionDefect = constructionDefectManager.getConstructionDefectZone(constructionDefectId);
            ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(constructionDefect.getExampleId().toString());
            constructionExample.getExampleDefectsZone().remove(constructionDefect);
            constructionExampleManager.saveConstructionExample(constructionExample);
            constructionDefectManager.deleteConstructionDefectZone(constructionDefect);
            request.getSession().setAttribute("madeChanges", new Boolean(true));
            request.setAttribute("message", bundle.getString("constructionDefect.deleted"));
View Full Code Here

        String objectConstructionId = extractConstructionIdParam(request);
        if (extractExampleIdParam(request) != null) {
            constructionDefects = constructionDefectManager.getConstructionDefectsByExampleId(exampleId);
            for (int i = 0; i < constructionDefects.size(); i++) {
                ConstructionDefect constructionDefect = (ConstructionDefect) constructionDefects.get(i);
                constructionDefect.setObjectConstructionId(objectConstructionId);
            }
        }

        int size = constructionDefects.size();

        if (constructionDefects.isEmpty()) {
            constructionDefects = constructionDefectManager.getConstructionDefectsZoneByExampleId(exampleId);
            for (int i = 0; i < constructionDefects.size(); i++) {
                ConstructionDefectZone constructionDefect = (ConstructionDefectZone) constructionDefects.get(i);
                constructionDefect.setObjectConstructionId(objectConstructionId);
            }
        } else {
            constructionDefects.addAll(constructionDefectManager.getConstructionDefectsZoneByExampleId(exampleId));
            for (int i = size; i < constructionDefects.size(); i++) {
                ConstructionDefectZone constructionDefect = (ConstructionDefectZone) constructionDefects.get(i);
                constructionDefect.setObjectConstructionId(objectConstructionId);
            }
        }
        return constructionDefects;
  }
View Full Code Here

        constructionDefectManager = null;
    }

    public void testGetConstructionDefects() throws Exception {
        List results = new ArrayList();
        ConstructionDefect constructionDefect = new ConstructionDefect();
        results.add(constructionDefect);

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

    }

    public void testGetConstructionDefect() throws Exception {
        // set expected behavior on dao
        constructionDefectDao.expects(once()).method("getConstructionDefect")
            .will(returnValue(new ConstructionDefect()));
        ConstructionDefect constructionDefect = constructionDefectManager.getConstructionDefect(constructionDefectId);
        assertTrue(constructionDefect != null);
        constructionDefectDao.verify();
    }
View Full Code Here

        assertTrue(constructionDefect != null);
        constructionDefectDao.verify();
    }

    public void testSaveConstructionDefect() throws Exception {
        ConstructionDefect constructionDefect = new ConstructionDefect();

        // set expected behavior on dao
        constructionDefectDao.expects(once()).method("saveConstructionDefect")
            .with(same(constructionDefect)).isVoid();
View Full Code Here

        constructionDefectManager.saveConstructionDefect(constructionDefect);
        constructionDefectDao.verify();
    }

    public void testAddAndRemoveConstructionDefect() throws Exception {
        ConstructionDefect constructionDefect = new ConstructionDefect();

        // set required fields

        // set expected behavior on dao
        constructionDefectDao.expects(once()).method("saveConstructionDefect")
            .with(same(constructionDefect)).isVoid();
        constructionDefectManager.saveConstructionDefect(constructionDefect);
        constructionDefectDao.verify();

        // reset expectations
        constructionDefectDao.reset();

        constructionDefectDao.expects(once()).method("removeConstructionDefect").with(eq(new Long(constructionDefectId)));
        constructionDefectManager.removeConstructionDefect(constructionDefectId);
        constructionDefectDao.verify();

        // reset expectations
        constructionDefectDao.reset();
        // remove
        Exception ex = new ObjectRetrievalFailureException(ConstructionDefect.class, constructionDefect.getConstructionDefectId());
        constructionDefectDao.expects(once()).method("removeConstructionDefect").isVoid();
        constructionDefectDao.expects(once()).method("getConstructionDefect").will(throwException(ex));
        constructionDefectManager.removeConstructionDefect(constructionDefectId);
        try {
            constructionDefectManager.getConstructionDefect(constructionDefectId);
View Full Code Here

TOP

Related Classes of com.vst.model.ConstructionDefect

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.