Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.ContentImage


  }
 
  static byte[] getContentImage(HttpServletRequest request, String id, int maxsize) throws Exception {
    byte data[] = null;
    String contentType = null;
    ContentImage image = ContentImageDAO.load(Long.valueOf(id));
    if (image != null) {
      data = image.getImageValue();
      contentType = image.getContentType();
    }
    else {
        data = transparent;
        contentType = "jpeg";
    }
View Full Code Here


          contentInfo.setContentDefaultImageUrl(imageUrl);
        }
        Vector<String> contentImages = new Vector<String>();
        Iterator<?> iterator = contentLanguageDefault.getImages().iterator();
        while (iterator.hasNext()) {
          ContentImage image = (ContentImage) iterator.next();
          String imageUrl = imageUrlPrefix +
                    "?type=C" +
                    "&imageId=" + image.getImageId();
          contentImages.add(imageUrl);
        }
        contentInfo.setContentImageUrls(contentImages);
        if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
        ContentLanguage contentLanguage = null;
        for (ContentLanguage language : content.getContentLanguages()) {
          if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfile.getSiteProfileClass().getSiteProfileClassId())) {
            contentLanguage = language;
            break;
          }
        }
        if (contentLanguage != null) {
         if (contentLanguage.getContentTitle() != null) {
          contentInfo.setContentTitle(contentLanguage.getContentTitle());
        }
        if (contentLanguage.getContentShortDesc() != null) {
          contentInfo.setContentShortDesc(contentLanguage.getContentShortDesc());
        }
        if (contentLanguage.getContentDesc() != null) {
          contentInfo.setContentDesc(contentLanguage.getContentDesc());
        }
        if (Format.isNullOrEmpty(contentLanguageDefault.getPageTitle())) {
          if (contentLanguage.getContentTitle() != null) {
            contentInfo.setPageTitle(contentLanguage.getContentTitle());
          }
        }
        else {
          if (contentLanguage.getPageTitle() != null) {
            contentInfo.setPageTitle(contentLanguage.getPageTitle());
          }
        }
        if (Format.isNullOrEmpty(contentLanguageDefault.getMetaKeywords())) {
          if (contentLanguage.getContentTitle() != null) {
            contentInfo.setMetaKeywords(contentLanguage.getContentTitle());
          }
        }
        else {
          if (contentLanguage.getMetaKeywords() != null) {
            contentInfo.setMetaKeywords(contentLanguage.getMetaKeywords());
          }
        }
        if (Format.isNullOrEmpty(contentLanguageDefault.getMetaDescription())) {
          if (contentLanguage.getContentTitle() != null) {
            contentInfo.setMetaDescription(contentLanguage.getContentTitle());
          }
        }
        else {
          if (contentLanguage.getMetaKeywords() != null) {
            contentInfo.setMetaDescription(contentLanguage.getMetaDescription());
          }
        }
        if (contentLanguage.getContentImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
            if (contentLanguage.getContentImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
              String url = null;
                  contentInfo.setContentDefaultImageUrl(null);
                  if (contentLanguage.getImage() != null) {
                    url = "?type=C&" +
                        "&imageId=" + contentLanguage.getImage().getImageId();
                    contentInfo.setContentDefaultImageUrl(imageUrlPrefix + url);
                  }
                  contentImages = new Vector<String>();
                  Iterator<?> images = contentLanguage.getImages().iterator();
                  while (images.hasNext()) {
                    ContentImage image = (ContentImage) images.next();
                    url = "?type=C" +
                        "&imageId=" + image.getImageId();
                    contentImages.add(imageUrlPrefix + url);
                  }
                  contentInfo.setContentImageUrls(contentImages);
            }
        }
View Full Code Here

        break;
      }
    }
   
    if (form.isSiteProfileClassDefault()) {
      ContentImage contentImage = new ContentImage();
      contentImage.setImageName(file.getFileName());
      contentImage.setContentType("image/jpeg");
      contentImage.setImageValue(scaler.getBytes());
      contentImage.setImageHeight(scaler.getHeight());
      contentImage.setImageWidth(scaler.getWidth());
      contentImage.setRecUpdateBy(adminBean.getUser().getUserId());
      contentImage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      contentImage.setRecCreateBy(adminBean.getUser().getUserId());
      contentImage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      em.persist(contentImage);
      if (contentLanguage.getImage() == null) {
        contentLanguage.setImage(contentImage);
      }
      else {
        contentImage.setContentLanguage(contentLanguage);
        contentLanguage.getImages().add(contentImage);
      }
      contentLanguage.setRecUpdateBy(adminBean.getUser().getUserId());
      contentLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      em.persist(contentLanguage);
    }
    else {
      if (contentLanguage == null) {
        contentLanguage = new ContentLanguage();
        contentLanguage.setContent(content);
        contentLanguage.setRecCreateBy(adminBean.getUser().getUserId());
        contentLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        SiteProfileClass siteProfileClass = SiteProfileClassDAO.load(form.getSiteProfileClassId());
        contentLanguage.setSiteProfileClass(siteProfileClass);
        em.persist(contentLanguage);
      }
      ContentImage contentImage = new ContentImage();
      contentImage.setImageName(file.getFileName());
      contentImage.setContentType("image/jpeg");
      contentImage.setImageValue(scaler.getBytes());
      contentImage.setImageHeight(scaler.getHeight());
      contentImage.setImageWidth(scaler.getWidth());
      contentImage.setRecUpdateBy(adminBean.getUser().getUserId());
      contentImage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      contentImage.setRecCreateBy(adminBean.getUser().getUserId());
      contentImage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      em.persist(contentImage);
      if (contentLanguage.getImage() == null) {
        contentLanguage.setImage(contentImage);
      }
      else {
        contentImage.setContentLanguage(contentLanguage);
        contentLanguage.getImages().add(contentImage);
      }
      contentLanguage.setRecUpdateBy(adminBean.getUser().getUserId());
      contentLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      em.persist(contentImage);
View Full Code Here

      if (contentLanguage.getContentImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
        effectiveLanguage = contentLanguage;
      }
    }
   
    ContentImage defaultImage = effectiveLanguage.getImage();
    if (defaultImage != null) {
      JSONEscapeObject jsonDefaultImage = new JSONEscapeObject();
      jsonDefaultImage.put("imageId", defaultImage.getImageId());
      jsonDefaultImage.put("imageName", defaultImage.getImageName());
      jsonDefaultImage.put("isLanguageDefault", true);
      jsonResult.put("defaultImage", jsonDefaultImage);
    }
   
    Iterator<?> iterator = effectiveLanguage.getImages().iterator();
    while (iterator.hasNext()) {
      ContentImage image = (ContentImage) iterator.next();
      JSONEscapeObject jsonImage = new JSONEscapeObject();
      jsonImage.put("imageId", image.getImageId());
      jsonImage.put("imageName", image.getImageName());
      jsonImage.put("isLanguageDefault", true);
      vector.add(jsonImage);
    }
    jsonResult.put("images", vector);
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
View Full Code Here

    }
    if (form.getImagesOverride().equalsIgnoreCase("true")) {
      contentLanguage.setContentImageOverride(String.valueOf(Constants.VALUE_YES));
    }
    else {
      ContentImage contentImage = null;
      if (contentLanguage.getImage() != null) {
        contentImage = contentLanguage.getImage();
        em.remove(contentImage);
        contentLanguage.setImage(null);
      }
View Full Code Here

        contentLanguage = language;
        break;
      }
    }
    if (contentLanguage != null) {
      ContentImage defaultImage = contentLanguage.getImage();
      if (imageIds != null) {
        for (int i = 0; i < imageIds.length; i++) {
          if (defaultImage != null && defaultImage.getImageId().equals(Format.getLong(imageIds[i]))) {
            contentLanguage.setImage(null);
            em.persist(contentLanguage);
            em.remove(defaultImage);
            defaultImage = null;
          }
          else {
            ContentImage contentImage = ContentImageDAO.load(site.getSiteId(), Format.getLong(imageIds[i]));
            contentLanguage.getImages().remove(contentImage);
            em.remove(contentImage);
          }
        }
      }
      contentLanguage.setRecUpdateBy(adminBean.getUser().getUserId());
      contentLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
     
      if (contentLanguage.getImage() == null) {
        Set<?> images = contentLanguage.getImages();
        if (!images.isEmpty()) {
          ContentImage contentImage = (ContentImage) images.iterator().next();
          contentLanguage.setImage(contentImage);
          contentImage.setContentLanguage(null);
          images.remove(contentImage);
        }
      }
    }
   
View Full Code Here

        contentLanguage = language;
        break;
      }
    }
    String defaultImageId = form.getCreateDefaultImageId();
    ContentImage contentImage = ContentImageDAO.load(site.getSiteId(), Format.getLong(defaultImageId));
   
    ContentImage currentImage = contentLanguage.getImage();
    currentImage.setContentLanguage(contentLanguage);
    contentLanguage.getImages().add(currentImage);
   
    contentImage.setContentLanguage(contentLanguage);
    contentImage.setContentLanguage(null);
    contentLanguage.setImage(contentImage);
View Full Code Here

    form.setContentExpireOn(Format.getDate(content.getContentExpireOn()));
    form.setRemoveImages(null);
    form.setRemoveMenus(null);
    form.setMenuWindowMode("");
   
    ContentImage contentImage = defaultContentLanguage.getImage();
    if (contentImage != null) {
      LabelValueBean bean = new LabelValueBean();
      bean.setLabel(contentImage.getImageName());
      bean.setValue(Format.getLong(contentImage.getImageId()));
      form.setDefaultImageId(bean);
    }
    else {
      form.setDefaultImageId(null);
    }
View Full Code Here

public class ContentImageDAO extends ContentImage {
  private static final long serialVersionUID = -695380566631098351L;
  public static ContentImage load(String siteId, Long imageId) throws SecurityException, Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    ContentImage contentimage = (ContentImage) em.find(ContentImage.class, imageId);
    if (!contentimage.getContentLanguage().getSiteProfileClass().getSite().getSiteId().equals(siteId)) {
      throw new SecurityException();
    }
    return contentimage;
  }
View Full Code Here

    }
    return contentimage;
  }
  public static ContentImage load(Long imageId) throws SecurityException, Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    ContentImage contentimage = (ContentImage) em.find(ContentImage.class, imageId);
    return contentimage;
  }
View Full Code Here

TOP

Related Classes of com.jada.jpa.entity.ContentImage

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.