Package com.vst.model

Examples of com.vst.model.Strength


        request = newGet("/editStrength.html");
        request.addParameter("pointId", "1");

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

        Strength strength = (Strength) mv.getModel().get(c.getCommandName());
        assertNotNull(strength);
        request = newPost("/editStrength.html");
        super.objectToRequestParameters(strength, request);

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


        if (request.getParameter("delete") != null) {
            String strengthId = request.getParameter("id");
            ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");
            boolean hasFatalError = false;
            try {
                Strength strength = strengthManager.getStrength(strengthId);
                ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(strength.getExampleId().toString());
                constructionExample.getStrengthPoints().remove(strength);



                ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(constructionExample.getObjectConstructionId().toString());
                                                     try {

                                                         ObjectInputStream in = new ObjectInputStream(new FileInputStream(FileHelper.getCurrentPath(request)+objectConstruction.getWayToDefectMap()));
                                                         ObjectPicture objectPicture=new ObjectPicture();
                                                         try {
                                                             objectPicture = (ObjectPicture) in.readObject();

                                                             if (objectPicture != null) {
                                                                List list=objectPicture.getObjectList();



                                                                 for (int l=0; l<list.size(); l++){
                                                                        if (list.get(l) instanceof Symbols){
                                                                             Symbols symbols=(Symbols)list.get(l);



                                                                                if (symbols.getType().equals("point") && symbols.getStrength().getPointId()!=null && symbols.getStrength().getPointId().equals(strength.getPointId())){


                                                                                    objectPicture.deleteObject(symbols);
                                                                                }
                                                                        }
View Full Code Here

            strengthPoints.remove(strengthPoints.size() - 1);
        }
        Float averageValue = 0f;
        //counting the average value from the rest of the points
        for (int i = 0; i < strengthPoints.size(); i++) {
            Strength strength = (Strength) strengthPoints.get(i);
            averageValue += strength.getStrengthValue();
        }
        averageValue = averageValue / strengthPoints.size();

        return averageValue;
View Full Code Here

            throws Exception {


        String pointId = request.getParameter("pointId");
        String exampleId = request.getParameter("exampleId");
        Strength strength = null;


        if (!StringUtils.isEmpty(pointId)) {
            strength = strengthManager.getStrength(pointId);
            strengthManager.evict(strength);
        } else {
            strength = new Strength();
            //generating the number of point
            strength.setPointRelativeNumber(new Integer(strengthManager.getPointNumber(exampleId)));
        }

        if (!StringUtils.isEmpty(exampleId)) {
            strength.setExampleId(new Integer(exampleId));
        }
        if (request.getParameter("edited") != null) {
            request.setAttribute("addition", "?edited=1");
            strength.setEdited(true);
        }

        //checking if the esciz already exists
        if (strength.getWayToEskiz() == null || strength.getWayToEskiz().equals("")) {
            //loading eskiz from objectconstruction
            ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(strength.getExampleId().toString());
            constructionExampleManager.evict(constructionExample);
            strength.setWayToEskiz(constructionExample.getWayToPowerEsckiz());
        }
        request.setAttribute("saveWay", strength.getWayToEskiz());
        request.setAttribute("loadWay", strength.getWayToEskiz());
        strength.setDocLocation(request.getParameter("docLocation"));

        return strength;

    }
View Full Code Here

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

        Strength strength = (Strength) command;
        boolean isNew = (strength.getPointId() == null);
        Locale locale = request.getLocale();

        if (request.getParameter("delete") != null) {
            Integer exampleId = strength.getExampleId();
            //    strengthManager.removeStrength(strength.getPointId().toString());
            ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(exampleId.toString());
            constructionExample.getStrengthPoints().remove(strength);
//            constructionExampleManager.saveConstructionExample(constructionExample);
            saveMessage(request, getText("strength.deleted", locale));
        } else {
            //adding this point to the list of the construction example
            ConstructionExample constructionExample1 = constructionExampleManager.getConstructionExample(strength.getExampleId().toString());
            if (constructionExample1.getWayToPowerEsckiz() != null) {
                File eskizFile = new File(FileHelper.getCurrentPath(request) + constructionExample1.getWayToPowerEsckiz());
                if (eskizFile.exists()) {
                    constructionExample1.setPowerEsckizBlob(Hibernate.createBlob(new FileInputStream(FileHelper.getCurrentPath(request) + constructionExample1.getWayToPowerEsckiz())));
                }
            }
            constructionExampleManager.saveConstructionExample(constructionExample1);
            constructionExampleManager.evict(constructionExample1);
            if (isNew) {
                Integer exampleId = strength.getExampleId();
                ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(exampleId.toString());
//                BuildingObject buildingObject=buildingObjectManager.getBuildingObject(constructionExample.getObjectId().toString());
                constructionExample.getStrengthPoints().add(strength);
                constructionExampleManager.saveConstructionExample(constructionExample);
//                buildingObjectManager.saveBuildingObject(buildingObject);
//                constructionExampleManager.saveConstructionExample(constructionExample);

                ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(constructionExample.getObjectConstructionId().toString());
                String fileName = FileHelper.getCurrentPath(request) + objectConstruction.getWayToDefectMap();
                paintStrength(constructionExample, strength, fileName,"save");


            } else {
                strengthManager.saveStrength(strength);


                Integer exampleId = strength.getExampleId();
                ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(exampleId.toString());
                ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(constructionExample.getObjectConstructionId().toString());
                String fileName = FileHelper.getCurrentPath(request) + objectConstruction.getWayToDefectMap();
                paintStrength(constructionExample, strength, fileName,"update");


            }
            String key = (isNew) ? "strength.added" : "strength.updated";
            saveMessage(request, getText(key, locale));
            if (strength.isEdited()) {
                return new ModelAndView("redirect:updating.html?id=" + strength.getPointId() + "&fieldId=" + request.getParameter("fieldId"));
            }
        }

        return new ModelAndView("redirect:" + strength.getDocLocation());
    }
View Full Code Here

        strengthManager = null;
    }

    public void testGetStrengths() throws Exception {
        List results = new ArrayList();
        Strength strength = new Strength();
        results.add(strength);

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

    }

    public void testGetStrength() throws Exception {
        // set expected behavior on dao
        strengthDao.expects(once()).method("getStrength")
            .will(returnValue(new Strength()));
        Strength strength = strengthManager.getStrength(strengthId);
        assertTrue(strength != null);
        strengthDao.verify();
    }
View Full Code Here

        assertTrue(strength != null);
        strengthDao.verify();
    }

    public void testSaveStrength() throws Exception {
        Strength strength = new Strength();

        // set expected behavior on dao
        strengthDao.expects(once()).method("saveStrength")
            .with(same(strength)).isVoid();
View Full Code Here

        strengthManager.saveStrength(strength);
        strengthDao.verify();
    }

    public void testAddAndRemoveStrength() throws Exception {
        Strength strength = new Strength();

        // set required fields

        // set expected behavior on dao
        strengthDao.expects(once()).method("saveStrength")
            .with(same(strength)).isVoid();
        strengthManager.saveStrength(strength);
        strengthDao.verify();

        // reset expectations
        strengthDao.reset();

        strengthDao.expects(once()).method("removeStrength").with(eq(new Long(strengthId)));
        strengthManager.removeStrength(strengthId);
        strengthDao.verify();

        // reset expectations
        strengthDao.reset();
        // remove
        Exception ex = new ObjectRetrievalFailureException(Strength.class, strength.getPointId());
        strengthDao.expects(once()).method("removeStrength").isVoid();
        strengthDao.expects(once()).method("getStrength").will(throwException(ex));
        strengthManager.removeStrength(strengthId);
        try {
            strengthManager.getStrength(strengthId);
View Full Code Here

* To change this template use File | Settings | File Templates.
*/
public class StrengthComparator implements Comparator {

    public int compare(Object o1, Object o2) {
        Strength strength1=(Strength)o1;
        Strength strength2=(Strength)o2;
        if(strength1.getStrengthValue()<=strength2.getStrengthValue()){
            return 0;
        }
        return 1//To change body of implemented methods use File | Settings | File Templates.
    }
View Full Code Here

TOP

Related Classes of com.vst.model.Strength

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.