Package com.vst.model

Examples of com.vst.model.ObjectConstruction


        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());
                objectConstruction.addConstructionExample(constructionExample);
                objectConstructionManager.saveObjectConstruction(objectConstruction);
            } else {
              System.out.println("editing example"+constructionExample.getExampleId());
                constructionExampleManager.saveConstructionExample(constructionExample);
            }
View Full Code Here


        // process references
        Map<Integer, ObjectConstruction> coMap =
          new HashMap<Integer, ObjectConstruction>();
        for (Object o : crows) {
          Object[] cols = (Object[]) o;
          ObjectConstruction oc = new ObjectConstruction(
              (Integer) cols[0],
              (String) cols[1], new ConstructionType());
          oc.setObjectId((Integer) cols[2]);
//          oc.setConstructionExamples(new ArrayList<ConstructionExample>());
          coMap.put(oc.getTypeId(), oc);
          Material m = new Material();
          m.setMaterialId((Integer) cols[3]);
          m.setMaterialName((String) cols[4]);

          ConstructionType ct = oc.getConstructionType();
          ct.setConstructionTypeId((Integer) cols[5]);
          ct.setName((String) cols[6]);

           oc.setNumberInObject(getExampleNumberByConstructionType(oc.getTypeId().toString(),oc.getObjectId().toString()).intValue());
            //System.out.println("NIO:"+oc.getNumberInObject()); 
      
          BuildingObject bo = ceMap.get(oc.getObjectId());
          if (bo !=null) {
            bo.getConstructionTypes().add(oc);
          }
        }

        //process examples
        List<?> allExamples = getAllExamplesList();
        for (Object o : allExamples) {
          ConstructionExample ce =
            (ConstructionExample) o;

          ObjectConstruction oc = coMap.get(ce.getObjectConstructionId());
          if(oc != null){
            oc.getConstructionExamples().add(ce);
          }
        }

        return bdList;
    }
View Full Code Here

TOP

Related Classes of com.vst.model.ObjectConstruction

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.