Examples of BuildingObject


Examples of com.vst.model.BuildingObject

        BuildingObjectTypeDTO buildingObjectTypeDTO = new BuildingObjectTypeDTO();

        /////

        for (int i = 0; i < buildingObjects.size(); i++) {
            BuildingObject buildingObject = (BuildingObject) buildingObjects.get(i);
            if (i == 0 || (!currentRegion.equals(buildingObject.getRegion()) && !(currentRegion == null) && !currentRegion.trim().equals(""))) {
                if (i != 0) {
                    buildingObjectTypes.add(buildingObjectTypeDTO);
                }
                buildingObjectTypeDTO = new BuildingObjectTypeDTO();
                currentRegion = buildingObject.getRegion();
                buildingObjectTypeDTO.setObjectType(currentRegion);

            }
            buildingObjectTypeDTO.getBuildingObjects().add(buildingObject);
        }
View Full Code Here

Examples of com.vst.model.BuildingObject

    }
 
 
   private void prepareForView(List<BuildingObject> buildingObjects){
        for (int i = 0; i < buildingObjects.size(); i++) {
              BuildingObject buildingObject = (BuildingObject) buildingObjects.get(i);
              List<?> objectConstructionList =  buildingObject.getConstructionTypes();
                // OLD buildingObjectManager.getConstructionTypesForTree(buildingObject);
              for (int j = 0; j < objectConstructionList.size(); j++) {
                  ObjectConstruction objectConstruction = (ObjectConstruction) objectConstructionList.get(j);
                  objectConstruction.setBriefDescription(reduceDescription(objectConstruction.getDescription()));
//                  objectConstruction.setConstructionExamples(
View Full Code Here

Examples of com.vst.model.BuildingObject

            Integer buildingObjectId = null;
            if(objectConstruction.getObjectId()!=null)
                    buildingObjectId = objectConstruction.getObjectId();

            //setting the object to the context
            BuildingObject buildingObject = buildingObjectManager.getBuildingObjectForBreadCrump(buildingObjectId.toString());
            //buildingObjectManager.evict(buildingObject);
            request.getSession().setAttribute("buildingObjectName", buildingObject.getName());
            request.getSession().setAttribute("buildingObjectNameRef", "buildingObjects.html?objectId=" + buildingObject.getObjectId());

        }
    }
View Full Code Here

Examples of com.vst.model.BuildingObject

    }
  }

  private BuildingObject processParamObjectId(HttpServletRequest request,
      HttpServletResponse response) {
    BuildingObject buildingObject = null;
    String objectId = request.getParameter("objectId");
    if (objectId != null) {
      // setting the object to the context
      // buildingObject =
      // buildingObjectManager.getBuildingObject(objectId);
      buildingObject = buildingObjectManager
          .getBuildingObjectForList(new Integer(objectId));
      //buildingObjectManager.evict(buildingObject);
      request.setAttribute("currentObjectUserId", buildingObject
          .getUser().getId());
    }

    if (request.getParameter("objectId") != null) {
      // setting the object to the context
      request.getSession().setAttribute("buildingObjectName",
          buildingObject.getName());
      request.getSession().setAttribute(
          "buildingObjectNameRef",
          "buildingObjects.html?objectId="
              + buildingObject.getObjectId());
    } else {
      // destroying object breadcrump refference
      request.getSession().setAttribute("buildingObjectName", "");
      request.getSession().setAttribute("buildingObjectNameRef", "");
View Full Code Here

Examples of com.vst.model.BuildingObject

  private void doCacheBuildingImages(HttpServletRequest request,
      HttpServletResponse response, List<BuildingObject> buildingObjects)
      throws IOException, SQLException {
    // retrieving the first photo
    for (int i = 0; i < buildingObjects.size(); i++) {
      BuildingObject curObject = (BuildingObject) buildingObjects.get(i);
      List<ObjectPhoto> photoes = buildingObjectManager
          .getObjectPhotoes(curObject.getObjectId());
      if (photoes.size() > 0) {
        ObjectPhoto objectPhoto = (ObjectPhoto) photoes.get(0);
        File file = new File(FileHelper.getCurrentPath(request)
            + objectPhoto.getWayToPhoto());
        if (file.exists()) {
View Full Code Here

Examples of com.vst.model.BuildingObject

    }
  }

  private List<?> findBuildingObjectsForView(HttpServletRequest request,
      HttpServletResponse response) {
    BuildingObject buildingObject;
    List buildingObjects = new ArrayList();
    request.setAttribute("searchWord", request.getParameter("searchWord"));
    buildingObject = new BuildingObject();
    buildingObject.setName(request.getParameter("searchWord"));
    if (("1".equals(request.getParameter("byFragments")))) {
      request.setAttribute("byFragments", "true");
      buildingObject.setByFragments(true);
    }

    if (isOnlyOneObjectInList(request)) {
      if (request.getParameter("objectId") != null) {
        buildingObjects.add(buildingObject);
View Full Code Here

Examples of com.vst.model.BuildingObject

        ObjectConstruction objectConstruction = (ObjectConstruction) command;
        boolean isNew = (objectConstruction.getTypeId() == null);
        Locale locale = request.getLocale();
        //getting the object
        if (request.getParameter("delete") != null) {
            BuildingObject buildingObject = buildingObjectManager.getBuildingObject(objectConstruction.getObjectId().toString());
            buildingObject.getConstructionTypes().remove(objectConstruction);
            buildingObjectManager.saveBuildingObject(buildingObject);
            //      objectConstructionManager.removeObjectConstruction(objectConstruction.getTypeId().toString());

            saveMessage(request, getText("objectConstruction.deleted", locale));
        } else {
            Integer constructionTypeId = objectConstruction.getConstructionType().getConstructionTypeId();
            Integer materialId = objectConstruction.getMaterial().getMaterialId();

            if (!constructionTypeId.equals(new Integer(-1))) {
                objectConstruction.setConstructionType(constructionTypeManager.getConstructionType(constructionTypeId.toString()));
            }


            objectConstruction.setMaterial(null);
            File eskizFile = new File(FileHelper.getCurrentPath(request) + objectConstruction.getWayToEsckiz());
//            //setting escizBlob if it's not empty
            boolean hasEskiz = false;
            if (objectConstruction.getWayToEsckiz() != null && !objectConstruction.getWayToEsckiz().equals("") && eskizFile.exists()) {
                objectConstruction.setEsckizBlob(Hibernate.createBlob(new FileInputStream(FileHelper.getCurrentPath(request) + objectConstruction.getWayToEsckiz())));
                hasEskiz = true;
            }

            if (!isNew) {
                ObjectConstruction oldObjectConstruction = objectConstructionManager.getObjectConstruction(objectConstruction.getTypeId().toString());
                objectConstruction.setDocumentationQuestions(oldObjectConstruction.getDocumentationQuestions());
                objectConstruction.setConstructionExamples(oldObjectConstruction.getConstructionExamples());
                objectConstruction.setConstructionType(oldObjectConstruction.getConstructionType());
                objectConstructionManager.evict(oldObjectConstruction);

            }

            MultipartHttpServletRequest multipartRequest =
                    (MultipartHttpServletRequest) request;
            CommonsMultipartFile file =
                    (CommonsMultipartFile) multipartRequest.getFile("file");
            if (file.getSize() > 0) {
                String fileName = ImageUtil.getUniqueJPEGFile(request);
                FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileName);
                fileOutputStream.write(file.getBytes());
                fileOutputStream.close();
                InputStream imageStream = ImageUtil.scaleImage(new FileInputStream(FileHelper.getCurrentPath(request) + fileName), 200, 200);

                fileOutputStream = new FileOutputStream(fileName);
                byte[] bufer = new byte[62000];
                while (imageStream.read(bufer) != -1) {
                    fileOutputStream.write(bufer);
                }
                fileOutputStream.close();
                objectConstruction.setWayToPhoto(fileName);
                objectConstruction.setPhotoBlob(Hibernate.createBlob(new FileInputStream(FileHelper.getCurrentPath(request) + fileName)));

            } else {
                //restoring old blob if new picture wasn't added
                if (!isNew) {
                    ObjectConstruction oldObjectConstruction = objectConstructionManager.getObjectConstruction(objectConstruction.getTypeId().toString());
                    objectConstructionManager.evict(oldObjectConstruction);
                    objectConstruction.setPhotoBlob(oldObjectConstruction.getPhotoBlob());
                    objectConstruction.setWayToPhoto(oldObjectConstruction.getWayToPhoto());
                }
            }

            if (isNew) {
                BuildingObject buildingObject = buildingObjectManager.getBuildingObject(objectConstruction.getObjectId().toString());
                objectConstruction.setObjectId(buildingObject.getObjectId());
                buildingObject.getConstructionTypes().add(objectConstruction);
                buildingObjectManager.saveBuildingObject(buildingObject);
            } else {
                objectConstructionManager.saveObjectConstruction(objectConstruction);
                //setting eskiz to all examples if it didn't exist before
                if (hasEskiz) {
View Full Code Here

Examples of com.vst.model.BuildingObject

      if (log.isDebugEnabled()) {
        log.debug("setting the object to the context");
      }
      // setting the object to the context
      BuildingObject buildingObject = buildingObjectManager
          .getBuildingObjectForBreadCrump(request
              .getParameter("objectId"));
      request.getSession().setAttribute("buildingObjectName",
          buildingObject.getName());
      request.getSession().setAttribute(
          "buildingObjectNameRef",
          "buildingObjects.html?objectId="
              + buildingObject.getObjectId());
    }
    if (request.getParameter("typeId") != null
        && !request.getParameter("typeId").trim().equals("")) {
      if (log.isDebugEnabled()) {
        log.debug("setting the object construction to the context");
      }
      objectConstruction = objectConstructionManager
          .getObjectConstructionForBreadCrump(request
              .getParameter("typeId"));
      request.getSession().setAttribute("constructionTypeName",objectConstruction.getConstructionType().getName());
      request.getSession().setAttribute("constructionTypeNameRef","objectConstructions.html?typeId="+ objectConstruction.getTypeId() + "&objectId="
              + objectConstruction.getObjectId());
    } else {
      // removing objectconstruction type from breadcrump
      request.getSession().setAttribute("constructionTypeName", "");
      request.getSession().setAttribute("constructionTypeNameRef", "");
    }
    // destroying examples and defect refferences
    request.getSession().setAttribute("constructionExampleName", "");
    request.getSession().setAttribute("constructionDefectName", "");
   
    ObjectConstruction newObjectConstruction = new ObjectConstruction();
    if (request.getParameter("addConstructionType") != null) {
      if (log.isDebugEnabled()) {
        log.debug("Adding new object construction of specified construction type.");
      }
       String buildObjectId = request.getParameter("buildObjectId");
      // ModelAndView mav2 = new ModelAndView(
      //    "redirect:objectConstructions.html?objectId="
      //          + buildObjectId);
     
      // ObjectConstruction newObjectConstruction = new ObjectConstruction();
      newObjectConstruction.setObjectId(new Integer(buildObjectId));
      Integer constructionTypeId = new Integer(request.getParameter("constructionTypeId"));
      if (!constructionTypeId.equals(new Integer(-1))) {
        newObjectConstruction.setConstructionType(constructionTypeManager
            .getConstructionType(constructionTypeId.toString()));
        newObjectConstruction.setMaterial(constructionTypeManager.getConstructionType(constructionTypeId.toString()).getMaterial());
      }
      objectConstructionManager.saveObjectConstruction(newObjectConstruction);
            System.out.println("Generated Id"+newObjectConstruction.getTypeId());
      //return mav2;
    }
   
    String typeId = "0";
   
    if (request.getParameter("addExamples") != null) {
     
   
      if (log.isDebugEnabled()) {
        log.debug("Adding new examples ... ");
      }
   
      ModelAndView mav2 = new ModelAndView(
          "redirect:constructionExamples.html");
      String buildObjectId = request.getParameter("buildObjectId");
     
      if(request.getParameter("addConstructionType")!=null){
         typeId = newObjectConstruction.getTypeId().toString();
      }else{
         typeId = request.getParameter("typeId");
      }
      objectConstruction = objectConstructionManager.getObjectConstructionForBreadCrump(typeId);
      // adding new examples to the construction varity
      int exampleNumber = 0;
      try {
        exampleNumber = Integer.parseInt(request.getParameter("examplesNumber"));
      } catch (NumberFormatException e) {
        e.printStackTrace();
        return new ModelAndView(
            "redirect:objectConstructions.html?objectId="
                + buildObjectId + "&typeId=" + typeId);
      }
     
      if (exampleNumber > 0) {
        ConstructionExample constructionExample = new ConstructionExample();
        // generating the unique number of construction
        constructionExample.setExampleName("конструкция 0");
        System.out.println(objectConstruction.getTypeId().intValue());
        Integer number = constructionExampleManager.getExampleNumberByConstructionObjectId(new Integer(objectConstruction.getTypeId()));
        constructionExample.setExampleRelativeNumber(number);
        DangerCategory dc = new DangerCategory();
        // 0 -default danger category means N/A
        dc.setDangerCategoryId(new Integer(0));
        constructionExample.setDangerCategory(dc);
        constructionExample.setObjectId(new Integer(buildObjectId));
        constructionExample.setBuildObjectId(new Integer(buildObjectId));
        constructionExample.setObjectConstructionId(objectConstruction.getTypeId());
        constructionExample.setConstructionType(objectConstruction.getConstructionType());
        constructionExample.setRecommendedDangerCategory(null);
        constructionExample.setParent(objectConstruction);
        // setting the ways to esciz
        // checking esciz
        if (constructionExample.getWayToDefectEsckiz() == null
        || constructionExample.getWayToDefectEsckiz().equals("")) {
          // retrieving esciz from object construction
          Blob eskiz = objectConstructionManager
              .getObjectConstructionImage(new Integer(typeId),"eskiz");
          // esciz for defects
          if (eskiz != null) {
            String wayToDefectEskiz = "eskiz"
                + (System.currentTimeMillis() & 0xffffffffL)
                + ".jpg";
            constructionExample.setDefectEsckizBlob(eskiz);
            constructionExample
                .setWayToDefectEsckiz(wayToDefectEskiz);
            constructionExample.setDefectEsckizWayImage("image"
                + wayToDefectEskiz);
            // esciz for power points
            String wayToPowerEskiz = "powereskiz"
                + (System.currentTimeMillis() & 0xffffffffL)
                + ".jpg";
            constructionExample
                .setWayToPowerEsckiz(wayToPowerEskiz);
            constructionExample.setPowerEsckizBlob(eskiz);
            constructionExample.setPowerEsckizWayImage("image"
                + wayToPowerEskiz);
          }
        }
        constructionExampleManager
            .saveConstructionExample(constructionExample);
        constructionExampleManager.copyExample(
            constructionExample.getExampleId(), exampleNumber - 1);
        Cookie cookie = new Cookie("nodeEnsureVisible", ""
            + (new java.util.Date().getTime()));
        cookie.setValue(String.valueOf(number));
        cookie.setMaxAge(30 * 24 * 60 * 60);
        response.addCookie(cookie);

        }
        if (request.getParameter("typeId") != null ) {
          if(request.getParameter("addExamples") == null){
            objectConstruction = objectConstructionManager.getObjectConstructionForBreadCrump(request.getParameter("typeId"));
//            objectConstructionManager.evict(objectConstruction);
            request.getSession().setAttribute("constructionTypeName", objectConstruction.getConstructionType().getName());
            request.getSession().setAttribute("constructionTypeNameRef", "objectConstructions.html?typeId=" + objectConstruction.getTypeId() + "&objectId=" + objectConstruction.getObjectId());

      mav2.addObject("typeId", request.getParameter("typeId"));
      mav2.addObject("treeParams", "FFFFFF");

      return mav2;

    }}
        }
        /*
    if (request.getParameter("addConstructionType") != null) {
      if (log.isDebugEnabled()) {
        log.debug("Adding new object construction of specified construction type.");
      }
       String buildObjectId = request.getParameter("buildObjectId");
       ModelAndView mav2 = new ModelAndView(
          "redirect:objectConstructions.html?objectId="
                + buildObjectId);
     
      ObjectConstruction newObjectConstruction = new ObjectConstruction();
      newObjectConstruction.setObjectId(new Integer(buildObjectId));
      Integer constructionTypeId = new Integer(request.getParameter("constructionTypeId"));
      if (!constructionTypeId.equals(new Integer(-1))) {
        newObjectConstruction.setConstructionType(constructionTypeManager
            .getConstructionType(constructionTypeId.toString()));
        newObjectConstruction.setMaterial(constructionTypeManager.getConstructionType(constructionTypeId.toString()).getMaterial());
      }
      objectConstructionManager.saveObjectConstruction(newObjectConstruction);
           
      return mav2;
    }
    */
    if (request.getParameter("delete") != null) {
      ResourceBundle bundle = ResourceBundle
          .getBundle("ApplicationResources");
      boolean hasFatalError = false;
      try {
        String objectConstructionId = request.getParameter("id");
        objectConstruction = objectConstructionManager
            .getObjectConstruction(objectConstructionId);
        BuildingObject buildingObject = buildingObjectManager
            .getBuildingObject(objectConstruction.getObjectId()
                .toString());
        // TODO find out the way of updating collection indexes without
        // extra sql query
        Integer constructionPosition = objectConstruction
            .getTypePosition();
        buildingObject.getConstructionTypes()
            .remove(objectConstruction);
        objectConstructionManager
            .removeObjectConstruction(objectConstructionId);
        buildingObjectManager.saveBuildingObject(buildingObject);
        request.getSession().setAttribute("madeChanges",
            new Boolean(true));
        request.setAttribute("message",
            bundle.getString("objectConstruction.deleted"));
        return new ModelAndView(
            "redirect:objectConstructions.html?objectId="
                + request.getParameter("objectId"));

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

    if (request.getParameter("elementCopy") != null) {

      BuildingObject buildingObject = buildingObjectManager
          .getBuildingObject(request.getParameter("objectId"));
      ObjectConstruction oldObjectConstruction = objectConstructionManager
          .getObjectConstruction(request.getParameter("id"));
      newObjectConstruction = (ObjectConstruction) elementCopyManager
          .getNewObject(oldObjectConstruction);
      buildingObject.getConstructionTypes().add(newObjectConstruction);
      objectConstructionManager
          .saveObjectConstruction(newObjectConstruction);
      buildingObjectManager.saveBuildingObject(buildingObject);
      elementCopyManager.setNumZerro();

View Full Code Here

Examples of com.vst.model.BuildingObject

        List buildingObjectTypes = new ArrayList();
        String currentRegion = "";
        BuildingObjectTypeDTO buildingObjectTypeDTO = new BuildingObjectTypeDTO();

        for (int i = 0; i < buildingObjects.size(); i++) {
            BuildingObject buildingObject = (BuildingObject) buildingObjects.get(i);

            List objectConstructionList = buildingObject.getConstructionTypes();
            for (int j = 0; j < objectConstructionList.size(); j++) {
                ObjectConstruction objectConstruction = (ObjectConstruction) objectConstructionList.get(j);
                if (objectConstruction.getDescription() != null) {
                    objectConstruction.setBriefDescription(objectConstruction.getDescription().length() > 10 ? objectConstruction.getDescription().substring(0, 9) + "..." : objectConstruction.getDescription());
                }
            }
        }


        for (int i = 0; i < buildingObjects.size(); i++) {
            BuildingObject buildingObject = (BuildingObject) buildingObjects.get(i);
            if (i == 0 || (!currentRegion.equals(buildingObject.getRegion()) && !(currentRegion == null) && !currentRegion.trim().equals(""))) {
                if (i != 0) {
                    buildingObjectTypes.add(buildingObjectTypeDTO);
                }
                buildingObjectTypeDTO = new BuildingObjectTypeDTO();
                currentRegion = buildingObject.getRegion();
                buildingObjectTypeDTO.setObjectType(currentRegion);
            }
            buildingObjectTypeDTO.getBuildingObjects().add(buildingObject);

View Full Code Here

Examples of com.vst.model.BuildingObject

    public ModelAndView handleRequest(HttpServletRequest request,
                                      HttpServletResponse response)
            throws Exception {

        String objectId = request.getParameter("objectId");
        BuildingObject buildingObject = buildingObjectManager.getBuildingObject(objectId);
        if (buildingObject.getWayToTechnicalTask() != null) {
            File file = new File(FileHelper.getCurrentPath(request) + buildingObject.getWayToTechnicalTask());
            if (file.exists()) {
                file.delete();
            }
            file.createNewFile();
            FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + buildingObject.getWayToTechnicalTask());
            Blob blob = buildingObject.getTechnicalTask();
            byte[] bufer = new byte[62000];
            InputStream inputStream = blob.getBinaryStream();
            while (inputStream.read(bufer) != -1) {
                fileOutputStream.write(bufer);
            }
            inputStream.close();
            fileOutputStream.close();
            return new ModelAndView("redirect:" + buildingObject.getWayToTechnicalTask());
        }
        return new ModelAndView("redirect:noTZ.doc");

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.