Package com.mincko.minckotest.shared

Examples of com.mincko.minckotest.shared.Image


     
        String strJson = req.getParameter("jsonData");
       
        if(strJson != null){ //update image if the json is not empty.
        String strJsonDel = req.getParameter("jsonDelete");
          Image data;
          //do the delete first
          if(strJsonDel!=null && strJsonDel!=""){
            data = new Gson().fromJson(strJsonDel, Image.class);
            if (ofy == null) ofy = PMF.getObjectify();
            //need to delete blobstoreServic
             BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
             for (Iterator<Image> iter = data.getImgList().iterator(); iter.hasNext();) {
               Image img =  ofy.get(Image.class, ((Image) iter.next()).id);
               BlobKey blobKey = new BlobKey(img.blobKey);
               //if(blobKey !=null)
                 //blobstoreService.delete(blobKey);
             }
            ofy.delete(data.getImgList());
          }
         
            data = new Gson().fromJson(strJson, Image.class);
            for (Iterator<Image> iter = data.getImgList().iterator(); iter.hasNext();) {
          Image img = (Image) iter.next();
          saveImageData(img.id, null,null, img.description, img.order );
        }
        }
        else if (req.getParameter("websiteComponentIdentifier") !=null) { //otherwise, add new image
          saveImageData(0,req.getParameter("websiteComponentIdentifier"), req.getParameter("blobkey"), req.getParameter("description"), 0);
View Full Code Here


     * Desc - to save the data, add/update
    */
    public void saveImageData(long id, String websiteComponentIdentifier, String strBlobKey, String strDescription, Integer intOrder) {
     
      if (ofy == null) ofy = PMF.getObjectify();
        Image image;
      //add new image
      if(id == 0) {
            // Save in database
        intOrder = ofy.query(Image.class).filter( "webComponentIdentifier",websiteComponentIdentifier).count()+1;
            image= new Image();
            image.setBlobKey( strBlobKey );
            image.setDescription( strDescription);
            image.setOrder( intOrder);
            image.setWebComponentIdentifier(websiteComponentIdentifier);
           
           
      }else{ //updating the image
        image=  ofy.get(Image.class, id);
            if(strBlobKey !=null) image.setBlobKey( strBlobKey );
            if(strDescription !=null) image.setDescription( strDescription);
            image.setOrder( intOrder);
            if(websiteComponentIdentifier !=null) image.setWebComponentIdentifier(websiteComponentIdentifier);
      }
      //save the image
      ofy.put(image);
    }
View Full Code Here

TOP

Related Classes of com.mincko.minckotest.shared.Image

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.