Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.CustomAttributeGroup


   
      JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);

    Long customAttribGroupId = Format.getLong(form.getCustomAttribGroupId());
    CustomAttributeGroup customAttributeGroup = CustomAttributeGroupDAO.load(site.getSiteId(), customAttribGroupId);
    String customAttribDetailIds[] = form.getCustomAttribDetailIds();
    if (customAttribDetailIds != null) {
      for (int i = 0; i < customAttribDetailIds.length; i++) {
        CustomAttributeDetail customAttributeDetail = (CustomAttributeDetail) em.find(CustomAttributeDetail.class, Format.getLong(customAttribDetailIds[i]));
        if (customAttributeDetail.getCustomAttribute().getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_SKU_MAKEUP) {
          String sql = "select  count(*) " +
                 "from    ItemAttributeDetail itemAttributeDetail " +
                 "where    itemAttributeDetail.customAttributeDetail = :customAttributeDetail " +
                 "and     itemAttributeDetail.item.itemTypeCd = :itemTypeCd";
          Query query = em.createQuery(sql);
          query.setParameter("customAttributeDetail", customAttributeDetail);
          query.setParameter("itemTypeCd", Constants.ITEM_TYPE_SKU);
          Long count = (Long) query.getSingleResult();
          if (count.intValue() > 0) { 
            jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
            jsonResult.put("reason", Constants.WEBSERVICE_REASON_INUSE);
            streamWebService(response, jsonResult.toHtmlString());
            return null;
          }
        }

        String sql = "delete " +
               "from   ItemAttributeDetail itemAttributeDetail " +
               "where  itemAttributeDetail.customAttributeDetail = :customAttributeDetail ";
        Query query = em.createQuery(sql);
        query.setParameter("customAttributeDetail", customAttributeDetail);
        query.executeUpdate();

        customAttributeGroup.getCustomAttributeDetails().remove(customAttributeDetail);
        em.remove(customAttributeDetail);
      }
    }
    streamWebService(response, jsonResult.toHtmlString());
    return null;
View Full Code Here


    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
   
    Long customAttribId = Format.getLong(form.getCustomAttribId());
    CustomAttribute customAttribute = (CustomAttribute) em.find(CustomAttribute.class, customAttribId);
    Long customAttribGroupId = Format.getLong(form.getCustomAttribGroupId());
    CustomAttributeGroup customAttributeGroup = (CustomAttributeGroup) em.find(CustomAttributeGroup.class, customAttribGroupId);
    int seqNum = 0;
    Iterator<?> iterator = customAttributeGroup.getCustomAttributeDetails().iterator();
    boolean found = false;
    while (iterator.hasNext()) {
      CustomAttributeDetail customAttributeDetail = (CustomAttributeDetail) iterator.next();
      if (customAttributeDetail.getCustomAttribute().getCustomAttribId().equals(customAttribute.getCustomAttribId())) {
        found = true;
      }
      if (customAttributeDetail.getSeqNum().intValue() >= seqNum) {
        seqNum = customAttributeDetail.getSeqNum() + 1;
      }
    }
   
    if (!found) {
      CustomAttributeDetail customAttributeDetail = new CustomAttributeDetail();
      customAttributeDetail.setCustomAttribute(customAttribute);
      customAttributeDetail.setSeqNum(seqNum);
      customAttributeDetail.setRecUpdateBy(adminBean.getUser().getUserId());
      customAttributeDetail.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      customAttributeDetail.setRecCreateBy(adminBean.getUser().getUserId());
      customAttributeDetail.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      customAttributeGroup.getCustomAttributeDetails().add(customAttributeDetail);
      em.persist(customAttributeDetail);
    }

    streamWebService(response, jsonResult.toHtmlString());
    return null;
View Full Code Here

          query.setParameter("customAttribGroupName", "%" + form.getSrCustomAttribGroupName() + "%");
        }
        Iterator<?> iterator = query.getResultList().iterator();
        Vector<CustomAttributeGroupDisplayForm> vector = new Vector<CustomAttributeGroupDisplayForm>();
        while (iterator.hasNext()) {
          CustomAttributeGroup customAttributeGroup = (CustomAttributeGroup) iterator.next();
        CustomAttributeGroupDisplayForm customAttributeGroupDisplay = new CustomAttributeGroupDisplayForm();
        customAttributeGroupDisplay.setCustomAttribGroupId(Format.getLong(customAttributeGroup.getCustomAttribGroupId()));
        customAttributeGroupDisplay.setCustomAttribGroupName(customAttributeGroup.getCustomAttribGroupName());
        vector.add(customAttributeGroupDisplay);
        }
        form.setCustomAttributeGroups(vector);
       
        ActionForward actionForward = actionMapping.findForward("success");
View Full Code Here

        String customAttribGroupIds[] = form.getCustomAttribGroupIds();
       
        try {
          if (customAttribGroupIds != null) {
            for (int i = 0; i < customAttribGroupIds.length; i++) {
                CustomAttributeGroup customAttributeGroup = new CustomAttributeGroup();
                customAttributeGroup = CustomAttributeGroupDAO.load(getAdminBean(request).getSite().getSiteId(), Format.getLong(customAttribGroupIds[i]));
                em.remove(customAttributeGroup);
            }
            em.getTransaction().commit();
          }
View Full Code Here

      for (ItemTierPrice p : removeTierPriceList) {
        item.getItemTierPrices().remove(p);
      }
    }

    CustomAttributeGroup customAttributeGroup = null;
    if (customAttributeGroupId != null || !Format.isNullOrEmpty(customAttributeGroupName)) {
      if (customAttributeGroupId != null) {
        customAttributeGroup = CustomAttributeGroupDAO.load(siteId, customAttributeGroupId);
      }
      else {
        customAttributeGroup = CustomAttributeGroupDAO.loadByName(siteId, customAttributeGroupName);
      }
      if (customAttributeGroup == null) {
        throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
             "customAttributeGroup",
             "customAttributeGroupId and customAttributeGroupName",
             customAttributeGroupId + " and " + customAttributeGroupName));
      }
      if (item.getCustomAttributeGroup() != null) {
        if (!item.getCustomAttributeGroup().getCustomAttribGroupId().equals(customAttributeGroup.getCustomAttribGroupId())) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E123", customAttributeGroup.getCustomAttribGroupId(), customAttributeGroup.getCustomAttribGroupName()));
        }
      }
      else {
        item.setCustomAttributeGroup(customAttributeGroup);
      }
     
      for (CustomAttributeDetail customAttributeDetail : customAttributeGroup.getCustomAttributeDetails()) {
        CustomAttribute customAttribute = customAttributeDetail.getCustomAttribute();
        ItemAttributeDetail itemAttributeDetailImport = null;
        boolean found = false;
        for (ItemAttributeDetail detail : this.getItemAttributeDetails()) {
          if (detail.getCustomAttribId() != null) {
            if (detail.getCustomAttribId().equals(customAttribute.getCustomAttribId())) {
              itemAttributeDetailImport = detail;
              found = true;
              break;
            }
          }
          else {
            if (detail.getCustomAttribName().equals(customAttribute.getCustomAttribName())) {
              itemAttributeDetailImport = detail;
              found = true;
              break;
            }
          }
        }
        if (!found) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E113",
                                   customAttribute.getCustomAttribId(),
                                   customAttribute.getCustomAttribName()));
        }
        if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_SELECT_DROPDOWN) {
          if (itemAttributeDetailImport.getItemAttributeDetailLanguages().size() > 0) {
            throw new ItemSaveException(resources.getMessage("IE.ERROR.E121", customAttribute.getCustomAttribName()));
          }
        }
        else if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT) {
          if (itemAttributeDetailImport.getCustomAttribId() != null ||
            Format.isNullOrEmpty(itemAttributeDetailImport.getCustomAttribName())) {
            throw new ItemSaveException(resources.getMessage("IE.ERROR.E117", customAttribute.getCustomAttribName()));
          }
          if (itemAttributeDetailImport.getItemAttributeDetailLanguages().size() > 0) {
            throw new ItemSaveException(resources.getMessage("IE.ERROR.E121", customAttribute.getCustomAttribName()));
          }
        }
        else if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_SELECT_DROPDOWN) {
          if (itemAttributeDetailImport.getCustomAttribOptionId() == null &&
            Format.isNullOrEmpty(itemAttributeDetailImport.getCustomAttribValue())) {
            throw new ItemSaveException(resources.getMessage("IE.ERROR.E115", customAttribute.getCustomAttribName()));
          }
          if (itemAttributeDetailImport.getItemAttributeDetailLanguages().size() > 0) {
            throw new ItemSaveException(resources.getMessage("IE.ERROR.E121", customAttribute.getCustomAttribName()));
          }
        }
        else if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_INPUT) {
          if (itemAttributeDetailImport.getCustomAttribOptionId() != null ||
            !Format.isNullOrEmpty(itemAttributeDetailImport.getCustomAttribValue())) {
            throw new ItemSaveException(resources.getMessage("IE.ERROR.E117", customAttribute.getCustomAttribName()));
          }
          if (this.isDefaultProfile()) {
            boolean valueFound = false;
            for (ItemAttributeDetailLanguage itemAttributeDetailLanguage : itemAttributeDetailImport.getItemAttributeDetailLanguages()) {
              if (itemAttributeDetailLanguage.getSiteProfileClassId().equals(siteProfileClassDefault.getSiteProfileClassId())) {
                if (Format.isNullOrEmpty(itemAttributeDetailLanguage.getItemAttribDetailValue())) {
                  throw new ItemSaveException(resources.getMessage("IE.ERROR.E122", customAttribute.getCustomAttribName()));
                }
                valueFound = true;
              }
            }
            if (!valueFound) {
              throw new ItemSaveException(resources.getMessage("IE.ERROR.E122", customAttribute.getCustomAttribName()));
            }
          }
        }
        else if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_SKU_MAKEUP) {
          if (itemAttributeDetailImport.getCustomAttribOptionId() == null &&
            Format.isNullOrEmpty(itemAttributeDetailImport.getCustomAttribValue())) {
            throw new ItemSaveException(resources.getMessage("IE.ERROR.E115", customAttribute.getCustomAttribName()));
          }
        }
      }
     
      for (ItemAttributeDetail detail : this.getItemAttributeDetails()) {
        boolean found = false;
        for (CustomAttributeDetail customAttributeDetail : customAttributeGroup.getCustomAttributeDetails()) {
          CustomAttribute customAttribute = customAttributeDetail.getCustomAttribute();
          if (detail.getCustomAttribId() != null) {
            if (detail.getCustomAttribId().equals(customAttribute.getCustomAttribId())) {
              found = true;
              break;
            }
          }
          else {
            if (detail.getCustomAttribName().equals(customAttribute.getCustomAttribName())) {
              found = true;
              break;
            }
          }
        }
        if (!found) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E119", detail.getCustomAttribId(), detail.getCustomAttribName()));
        }
      }
     
      for (ItemAttributeDetail itemAttributeDetailImport : this.getItemAttributeDetails()) {
        com.jada.jpa.entity.ItemAttributeDetail itemAttributeDetail = null;
        boolean foundDetail = false;
        for (com.jada.jpa.entity.ItemAttributeDetail detail : item.getItemAttributeDetails()) {
          CustomAttribute customAttribute = detail.getCustomAttributeDetail().getCustomAttribute();
          if (itemAttributeDetailImport.getCustomAttribId() != null) {
            if (itemAttributeDetailImport.getCustomAttribId().equals(customAttribute.getCustomAttribId())) {
              itemAttributeDetail = detail;
              foundDetail = true;
            }
          }
          else {
            if (itemAttributeDetailImport.getCustomAttribName().equals(customAttribute.getCustomAttribName())) {
              itemAttributeDetail = detail;
              foundDetail = true;
            }
          }
        }
        if (!foundDetail) {
          itemAttributeDetail = new com.jada.jpa.entity.ItemAttributeDetail();
          CustomAttributeDetail customAttributeDetail = null;
          for (CustomAttributeDetail d : customAttributeGroup.getCustomAttributeDetails()) {
            CustomAttribute customAttribute = d.getCustomAttribute();
            if (itemAttributeDetailImport.getCustomAttribOptionId() != null) {
              if (itemAttributeDetailImport.getCustomAttribId() == customAttribute.getCustomAttribId()) {
                customAttributeDetail = d;
                break;
              }
            }
            else {
              if (itemAttributeDetailImport.getCustomAttribName() == customAttribute.getCustomAttribName()) {
                customAttributeDetail = d;
                break;
              }
            }
          }
          itemAttributeDetail.setCustomAttributeDetail(customAttributeDetail);
          itemAttributeDetail.setRecCreateBy(Constants.USERNAME_IMPORT);
          itemAttributeDetail.setRecCreateDatetime(new Date());
          itemAttributeDetail.setItem(item);
        }
        if (itemAttributeDetailImport.getCustomAttribId() != null) {
          for (CustomAttributeDetail customAttributeDetail : customAttributeGroup.getCustomAttributeDetails()) {
            if (customAttributeDetail.getCustomAttribute().getCustomAttribId().equals(itemAttributeDetailImport.getCustomAttribId())) {
              itemAttributeDetail.setCustomAttributeDetail(customAttributeDetail);
              break;
            }
          }
        }
        if (!Format.isNullOrEmpty(itemAttributeDetailImport.getCustomAttribName())) {
          for (CustomAttributeDetail customAttributeDetail : customAttributeGroup.getCustomAttributeDetails()) {
            if (customAttributeDetail.getCustomAttribute().getCustomAttribName().equals(itemAttributeDetailImport.getCustomAttribName())) {
              itemAttributeDetail.setCustomAttributeDetail(customAttributeDetail);
              break;
            }
          }
View Full Code Here

public class CustomAttributeGroupDAO extends CustomAttributeGroup {
  private static final long serialVersionUID = 2018608223165684363L;

  public static CustomAttributeGroup load(String siteId, Long customAttribGroupId) throws SecurityException, Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      CustomAttributeGroup customAttributeGroup = (CustomAttributeGroup) em.find(CustomAttributeGroup.class, customAttribGroupId);
    if (!customAttributeGroup.getSite().getSiteId().equals(siteId)) {
      throw new SecurityException();
    }
    return customAttributeGroup;
  }
View Full Code Here

      Query query = em.createQuery("from CustomAttributeGroup where siteId = :siteId and customAttribGroupName = :customAttribGroupName");
      query.setParameter("siteId", siteId);
      query.setParameter("customAttribGroupName", customAttributeGroupName);
      Iterator<?> iterator = query.getResultList().iterator();
      if (iterator.hasNext()) {
        CustomAttributeGroup customAttributeGroup = (CustomAttributeGroup) iterator.next();
        return customAttributeGroup;
      }
      return null;
  }
View Full Code Here

        itemTierPriceXml.getItemTierPriceCurrencies().add(itemTierPriceCurrencyXml);
      }
      itemXml.getItemTierPrices().add(itemTierPriceXml);
    }
   
    CustomAttributeGroup customAttributeGroup = item.getCustomAttributeGroup();
    if (customAttributeGroup != null) {
      itemXml.setCustomAttributeGroupId(customAttributeGroup.getCustomAttribGroupId());
      itemXml.setCustomAttributeGroupName(customAttributeGroup.getCustomAttribGroupName());
     
      for (ItemAttributeDetail itemAttributeDetail : item.getItemAttributeDetails()) {
        com.jada.xml.ie.ItemAttributeDetail itemAttributeDetailXml = new com.jada.xml.ie.ItemAttributeDetail();
        CustomAttribute customAttribute = itemAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
        itemAttributeDetailXml.setCustomAttribId(customAttribute.getCustomAttribId());
View Full Code Here

TOP

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

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.