Package com.vst.model

Examples of com.vst.model.ObjectConstruction


               mainMenu += "<li class='add3'><a target='mainFrame'"+
                      "href='/vst/objectConstructions.html?form=new&objectId="+b.getObjectId()+"'> </a></li>";       
            List bol = b.getConstructionTypes();
            if (bol.size() > 0) {
              for (Object o2 : bol) {
                ObjectConstruction ct = (ObjectConstruction) o2;
                name = ct.getConstructionType().getName();
                k = name.length() / 15;
                l = 0;
                if (k <= 1) {
                  l = name.length();
                } else {
                  l = 14;
                }
                if (name.trim().equals(""))
                  name = "N/A";
                else
                  name = name.substring(0, l);
                outputHtml += "<li onclick=\"ajaxSampleSvc.expandTreeItem('constructionType',";
                outputHtml += ct.getTypeId().intValue();
                outputHtml += ", processItemChange);\" >";
                outputHtml += "<a target='mainFrame' href='objectConstructions.html?objectId=";
                outputHtml += ct.getObjectId() + "&typeId="  + ct.getTypeId();
                outputHtml += "'>";
                outputHtml += name;
                outputHtml += "<span>"+ct.getNumberInObject()+"</span>";
                outputHtml += "</a>";
                // reverse expandable value
                // b.setExpandable(!b.isExpandable());
                // break;
                outputHtml += "</li>";
              }
            } else {
              outputHtml += "<li><a>No items present</a></li><br>";
            }
          }else if(itemType.equals("list")){
            String name = b.getName().trim().toUpperCase();
            int k = name.length() / 15;
            int l = 0;
            if (k <= 1) {
              l = name.length();
            } else {
              l = 14;
            }
            if (name.trim().equals(""))
              outputHtml += "N/A";
            else           
            outputHtml += "<li onclick=\"ajaxSampleSvc.expandTreeItem('buildingObject',"+b.getObjectId()+", processItemChange);\">";
            outputHtml += "<a target='mainFrame' href='buildingObjects.html?type=one&objectId="+b.getObjectId()+"' >"+name.substring(0, l);
                outputHtml     +=  "</a></li>";
          } /*
           * else { String name = b.getName().trim(); int k =
           * name.length() / 15; int l = 0; if (k <= 1) { l =
           * name.length(); } else { l = 14; } outputHtml +=
           * "<span onclick=\"ajaxSampleSvc.expandTreeItem('buildingObject',"
           * ; outputHtml += b.getObjectId().intValue(); outputHtml +=
           * ", processItemChange);\" >"; outputHtml +=
           * b.getName().trim().substring(0, l); outputHtml +=
           * "</span>"; outputHtml +=
           * "<br><span class='next-step'></span>";
           *
           * }
           */
        }
      }
      // Set changed item.
      WebContextFactory.get().getHttpServletRequest().getSession()
          .setAttribute("buildingObject", buildingObjectTypes);
    } else if (itemType.equals("constructionType")) {
      for (Object o : buildingObjectTypes) {
        bo = (BuildingObjectTypeDTO) o;
        bolist = bo.getBuildingObjects();
        for (BuildingObject b : bolist) {
          List ctl = b.getConstructionTypes();
          if (ctl.size() > 0) {
            for (Object o2 : ctl) {
              ObjectConstruction ct = (ObjectConstruction) o2;
              if (isConstructionTypeSelected(ct, itemId)) {
                String name = b.getName().trim().toUpperCase();
                int k = name.length() / 15;
                int l = 0;
                if (k <= 1) {
                  l = name.length();
                } else {
                  l = 14;
                }             
                outputHtml += "<a target='mainFrame' href='buildingObjects.html?type=one&objectId="+b.getObjectId().intValue()+"' >"+name.substring(0, l)
                       "</a><br/><span class='next-step' onclick=\"location.href='index.html'\" ></span>";                               
                //outputHtml  += "<a href='index.html'>"+name.substring(0, l);
                //outputHtml  += "</a><br/><span class='next-step'></span>";                               
                outputHtml  += "<a href=\"objectConstructions.html?objectId=";
                outputHtml  += ct.getObjectId().intValue()+ "&typeId=";
                outputHtml  += ct.getTypeId().intValue();
                outputHtml  += "\" target='mainFrame' > ";
                outputHtml  += ct.getConstructionType().getName() +"</a><br/>";                               
                //outputHtml  += "<a href='buildingObjects.html?type=one&objectId=";
                //outputHtml  += ct.getObjectId();
                //outputHtml  += "' target='mainFrame' >";
                //outputHtml  += ct.getConstructionType().getName();               
                outputHtml  += "<span onclick=\"ajaxSampleSvc.expandTreeItem('buildingObject',";
                outputHtml  += ct.getObjectId().intValue();
                outputHtml  += ", processItemChange);\"  class='next-step'></span></div><ul class='number-list'>";
                mainMenu    += "<li class='add3'><a target='mainFrame'"+
                               "href='/vst/objectConstructions.html?form=new&objectId="+b.getObjectId()+"'> </a></li>";
                List eol = ct.getConstructionExamples();
                if(eol.size() > 0){
                for (Object ob : eol) {
                  ConstructionExample ce = (ConstructionExample) ob;
                  name = ce.getExampleName();
                  k = name.length() / 15;
                  l = 0;
                  if (k <= 1) {
                    l = name.length();
                  } else {
                    l = 14;
                  }
                  if (name.trim().equals(""))
                    name = "N/A";
                  else
                    name = name.substring(0, l);
                  outputHtml += "<li onclick=\"ajaxSampleSvc.expandTreeItem('constructionExample',";
                  outputHtml += ce.getExampleId().intValue() ;
                  outputHtml += ", processItemChange);\" >"  ;
                  outputHtml += "<a target='mainFrame' href='constructionExamples.html?exampleId=";
                  outputHtml += ce.getExampleId();
                  outputHtml += "&typeId=";
                  outputHtml += ce.getObjectConstructionId();
                  outputHtml += "&objectId="+ct.getObjectId()+"'";
                  outputHtml += ce.getObjectId();
                  outputHtml += "'>";
                  outputHtml += name;
                  outputHtml += "</a>";
                }

              }//else{
              //  outputHtml += "<li><a>No items present</a></li><br>";
              //}
              }
            }
          }
        }
      }
    } else if (itemType.equals("constructionExample")
        || (itemType.equals("exampleEdit"))) {
      for (Object o : buildingObjectTypes) {
        bo = (BuildingObjectTypeDTO) o;
        bolist = bo.getBuildingObjects();
        for (BuildingObject b : bolist) {
          List ctl = b.getConstructionTypes();
          if (ctl.size() > 0) {
            for (Object o2 : ctl) {
              ObjectConstruction ct = (ObjectConstruction) o2;
              // if (isConstructionTypeSelected(ct, itemId)) {
              List eol = ct.getConstructionExamples();
              for (Object ob : eol) {
                ConstructionExample ce = (ConstructionExample) ob;
                // System.out.print("EID:"+ce.getExampleId());
                if (isConstructionExampleSelected(ce, itemId)) {
                  // Bread Crump
                  String name = b.getName().trim()
                      .toUpperCase();
                  int k = name.length() / 15;
                  int l = 0;
                  if (k <= 1) {
                    l = name.length();
                  } else {
                    l = 14;
                  }         
                  //           + "<br><span class='next-step'></span>";                 
                  /*outputHtml   + = "<a target='mainFrame' href='objectConstructions.html?objectId=";
                    outputHtml   + = ct.getObjectId() + "&typeId="
                                +   ct.getTypeId();
                    outputHtml   += "'>";*/               
                  outputHtml  += "<a target='mainFrame' href='buildingObjects.html?type=one&objectId="+b.getObjectId().intValue()+"' >"+name.substring(0, l)
                           "</a><br/><span class='next-step' onclick=\"location.href='buildingObjects.html'\" ></span>";
                 
                  outputHtml  += "<a href=\"objectConstructions.html?objectId=";
                  outputHtml  += ct.getObjectId().intValue()+ "&typeId=";
                  outputHtml  += ct.getTypeId().intValue();
                  outputHtml  += "\" target='mainFrame' > ";
                  outputHtml  += ct.getConstructionType().getName() +"</a><br/><span onclick=\"ajaxSampleSvc.expandTreeItem('constructionType',";
                  outputHtml  += ct.getTypeId().intValue();
                  outputHtml  += ", processItemChange);\"  class='next-step'></span></div><ul class='number-list'>";
                  mainMenu    += "<li class='add3'><a target='mainFrame'"+
                                 "href='/vst/objectConstructions.html?form=new&objectId="+b.getObjectId()+"'> </a></li>";
               
                  mainMenu    += "<li class='add4'><a target='mainFrame'"+
                               "href='" +
                               "/vst/constructionDefectZoneForm.html?objectConstructionId=" +ct.getTypeId()+"&objectId="+b.getObjectId()+"&exampleId=" + ce.getExampleId() + "&docLocation=constructionDefects.html?exampleId=" + ce.getExampleId() + "'></a></li>";
               
                        name = ce.getExampleName();
                  k = name.length() / 15;
                  l = 0;
                  if (k <= 1) {
View Full Code Here


    private void processParamElementCopy(HttpServletRequest request,
      HttpServletResponse response) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
      if (request.getParameter("elementCopy") != null) {


            ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(request.getParameter("typeId"));
            ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(request.getParameter("id"));
            ConstructionExample newConstructionExample = (ConstructionExample) elementCopyManager.getNewObject(constructionExample);
            objectConstruction.getConstructionExamples().add(newConstructionExample);
            constructionExampleManager.saveConstructionExample(newConstructionExample);
            objectConstructionManager.saveObjectConstruction(objectConstruction);
            elementCopyManager.setNumZerro();

        }
View Full Code Here

    }

    private void processParamTypeId(HttpServletRequest request,
      HttpServletResponse response) {
      if (extractParamTypeId(request) != null) {
            ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstructionForBreadCrump(extractParamTypeId(request));
            //objectConstructionManager.evict(objectConstruction);
           
            if(objectConstruction.getConstructionType()!=null)
               request.getSession().setAttribute("constructionTypeName", objectConstruction.getConstructionType().getName());
            if(objectConstruction.getTypeId()!=null)
               request.getSession().setAttribute("constructionTypeNameRef", "objectConstructions.html?typeId=" + objectConstruction.getTypeId() + "&objectId=" + objectConstruction.getObjectId());
            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());
View Full Code Here

      String constructionExampleId = request.getParameter("id");
        ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources");
        boolean hasFatalError = false;
        try {
            ConstructionExample constructionExample = constructionExampleManager.getConstructionExample(constructionExampleId);
            ObjectConstruction objectConstruction = objectConstructionManager.getObjectConstruction(constructionExample.getObjectConstructionId().toString());
            objectConstruction.getConstructionExamples().remove(constructionExample);
            constructionExampleManager.removeConstructionExample(constructionExampleId);
            objectConstructionManager.saveObjectConstruction(objectConstruction);
            request.getSession().setAttribute("madeChanges", new Boolean(true));
            request.setAttribute("message", bundle.getString("constructionExample.deleted"));
        } catch (Exception e) {
View Full Code Here

                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);
                                                                                }
                                                                        }
                                                                 }
                                                             }
                                                         } catch (ClassNotFoundException e) {

                                                         }
                                                         in.close();


                                                         ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(FileHelper.getCurrentPath(request)+objectConstruction.getWayToDefectMap()));
                                                          out.writeObject(objectPicture);
                                                          out.close();


                                                     } catch (IOException e) {
View Full Code Here

        request.setAttribute("materialList", materialManager.getMaterials(null));
        request.setAttribute("constructionTypeList", constructionTypeManager.getConstructionTypes(null));

        if (!isFormSubmission(request)) {
            String typeId = request.getParameter("typeId");
            ObjectConstruction objectConstruction = null;

            if (!StringUtils.isEmpty(typeId)) {
                objectConstruction = objectConstructionManager.getObjectConstruction(typeId);
                objectConstructionManager.evict(objectConstruction);
            } else {
                objectConstruction = new ObjectConstruction();
            }

            String objectId = request.getParameter("objectId");
            if (objectId != null) {
                objectConstruction.setObjectId(new Integer(objectId));
            }

            if (request.getParameter("edited") != null) {
                request.setAttribute("addition", "?edited=1");
                objectConstruction.setEdited(true);
            }
            if (objectConstruction.getObjectId() == null) {
                objectConstruction.setObjectId(new Integer(objectId));
            }
            //checking if the esciz already exists

            System.out.println(" WAYYYYYYY ");

            if (objectConstruction.getWayToEsckiz() == null || objectConstruction.getWayToEsckiz().equals("")) {
                String saveWay = ImageUtil.getUniqueJPEGFile(request);


                String loadPath = FileHelper.getCurrentPath(request) + "blank.jpg";
                InputStream imageStream = new FileInputStream(loadPath);
                Image image = ImageIO.read(imageStream);
                imageStream.close();
                int w = image.getWidth(null);
                int h = image.getHeight(null);
                BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
                Graphics2D g2 = bi.createGraphics();
                g2.drawImage(image, 0, 0, null);
                try {
                    ImageIO.write(bi, "jpg", new FileOutputStream(FileHelper.getCurrentPath(request)+saveWay));
                } catch (IOException e) {
                }


                System.out.println("saveWay = "+saveWay);
               
                request.setAttribute("saveWay", saveWay);
                objectConstruction.setWayToEsckiz(saveWay);
                String saveWayImage="image"+saveWay;
                objectConstruction.setWayToEsckizImage(saveWayImage);
                request.setAttribute("saveWayImage", saveWayImage);

                saveWay = "DefectMap"+saveWay;
                saveWayImage="image"+saveWay;
                objectConstruction.setWayToDefectMap(saveWay);
                objectConstruction.setWayToDefectMapImage(saveWayImage);


            } else {

                request.setAttribute("saveWay", objectConstruction.getWayToEsckiz());
                request.setAttribute("saveWayImage", objectConstruction.getWayToEsckizImage());
                request.setAttribute("loadWay", objectConstruction.getWayToEsckiz());
               
            }
            objectConstruction.setDocLocation(request.getParameter("docLocation"));

            return objectConstruction;
        }
        return super.formBackingObject(request);
    }
View Full Code Here

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

        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());
View Full Code Here

    public ModelAndView processFormSubmission(HttpServletRequest request,
                                              HttpServletResponse response,
                                              Object command,
                                              BindException errors)
            throws Exception {
        ObjectConstruction objectConstruction = (ObjectConstruction) command;
        if (request.getParameter("cancel") != null) {
            String addition = "";
            if (objectConstruction.getTypeId() != null) {
                addition = "&typeId=" + objectConstruction.getTypeId();
            }
            return new ModelAndView("redirect: objectConstructions.html?objectId=" + objectConstruction.getObjectId() + addition);
        }

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

    String pageNumber = request.getParameter("d-2834692-p");
    if (pageNumber != null) {
      request.setAttribute("pageNumber", "d-2834692-p=" + pageNumber);
    }
    // generating constructionType to the session
    ObjectConstruction objectConstruction = new ObjectConstruction();

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

      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();

    }
    String objectId = request.getParameter("objectId");
    if(request.getParameter("buildObjectId")!=null)
         objectId = request.getParameter("buildObjectId");
   
    List objectConstructions = new ArrayList();
    if (objectId != null) {
      objectConstructions = objectConstructionManager
          .getListForObjectConstructionPage(new Integer(objectId));
    }
    // retrieving eskiz from each construction
    for (int i = 0; i < objectConstructions.size(); i++) {
      ObjectConstruction construction = (ObjectConstruction) objectConstructions
          .get(i);
      if (construction.getEsckizBlob() != null) {
        File file = new File(FileHelper.getCurrentPath(request)
            + construction.getWayToEsckiz());
        if (file.exists()) {
          file.delete();
        }
        file.createNewFile();
        FileOutputStream fileOutputStream = new FileOutputStream(
            FileHelper.getCurrentPath(request)
                + construction.getWayToEsckiz());
        Blob blob = construction.getEsckizBlob();
        byte[] bufer = new byte[62000];
        InputStream inputStream = blob.getBinaryStream();
        while (inputStream.read(bufer) != -1) {
          fileOutputStream.write(bufer);
        }
View Full Code Here

        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());
                }
            }
        }

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.