Package com.ebay.sdk.attributes.model

Examples of com.ebay.sdk.attributes.model.AttributeSet


  public void setCategoryCSProvider(ICategoryCSProvider categoryCSProvider) {
    this.categoryCSProvider = categoryCSProvider;
  }

  private AttributeSet extractOneCat(String catCsName, Map request) {
    AttributeSet attrSet = null;

    Object obj = request.get(catCsName);
    if (obj != null) {
      String cat_cs = ((String[])obj)[0];

      String[] delim = cat_cs.split("_");
      int catId = Integer.parseInt(delim[0]);
      int csId = Integer.parseInt(delim[1]);
      //int csId = this.mCategoryCSProvider.GetVCSId(catId);

      String prodId = null;
      if( delim.length > 2 )
        prodId= delim[2];

      if (csId != 0) {
        attrSet = AttrParamParser.parse(csId, request);
        attrSet.setCategoryID(catId);
        attrSet.setAttributeSetID(csId);

        if( prodId != null ) {
          attrSet.setProductID(prodId);
        }
      }
    }

    return attrSet;
View Full Code Here


   * @param nameValues java.util.Map The parameters map got from query string or post.
   * @return AttributeSet[]
   */
  public AttributeSet[] nameValuesToAttributeSets(Map nameValues) throws SdkException, Exception {
    ArrayList attrSets = new ArrayList();
    AttributeSet attrSet;

    for (int ordinal = 0; ; ordinal++) {
      String ordStr = String.valueOf(ordinal);
      attrSet = extractOneCat(CAT_CS_ID + ordStr, nameValues);
      if (attrSet != null) {
        attrSet.setCategoryOrdinal(attrSets.size());
        attrSets.add(attrSet);
      } else {
        break;
      }
    }
View Full Code Here

   */
  public AttributeSet[] getItemSpecificAttributeSetsForCategories(int[] catIds) throws SdkException, Exception {
    AttributeSet[] sets = new AttributeSet[catIds.length];
    for (int i = 0; i < catIds.length; i++) {
      int catId = catIds[i];
      AttributeSet ast = new AttributeSet();
      int csId = categoryCSProvider.getVCSId(catId);
      if (csId == 0) {
      return null;
        //throw new SdkException("Unable to get CSID by category Id");
      }
      ast.setAttributeSetID(csId);
      ast.setCategoryID(catId);
      ast.setCategoryOrdinal(i);

      sets[i] = ast;
    }

    return sets;
View Full Code Here

   */
  private AttributeSet[] excludeReturnPolicyFromSiteWideAttributes(AttributeSet[] siteWideAttributeSet) throws Exception {
    if(siteWideAttributeSet == null) {
      return null;
    }
    AttributeSet retPolicyAttrSet = getReturnPolicyAttributeSet(siteWideAttributeSet);
    if(retPolicyAttrSet == null) {
      return siteWideAttributeSet;
    }
    int retPolicyAttrId = retPolicyAttrSet.getAttributeSetID();
    List attrList = new ArrayList();
    for(int i = 0; i < siteWideAttributeSet.length; i++) {
      if(siteWideAttributeSet[i].getAttributeSetID() == retPolicyAttrId) {
        continue;
      } else {
View Full Code Here

    for (int i = 0; i < catIds.length; i++) {
      SiteWideCharacteristicsType[] swAttrSets = categoryCSProvider.getSiteWideCharacteristics(String.valueOf(catIds[i]));
      if(swAttrSets != null) {
        for(int j = 0; j < swAttrSets.length; j++) {
          SiteWideCharacteristicsType swAttrSet = swAttrSets[j];
          AttributeSet swAst = new AttributeSet();
          swAst.setAttributeSetID(swAttrSet.getCharacteristicsSet().getAttributeSetID().intValue());
          swAst.setCategoryID(catIds[i]);
          swAst.setCategoryOrdinal(i);
          swAst.setName(swAttrSet.getCharacteristicsSet().getName());
          attrSetsList.add(swAst);
        }
      }
    }
    AttributeSet[] retVal = new AttributeSet[attrSetsList.size()];
View Full Code Here

   * @param siteWideAttrSets AttributeSet[] array of site wide AttributeSet objects.
   * @return AttributeSet for Return Policy
   * @see getSiteWideAttributeSetsForCategories()
   */
  public AttributeSet getReturnPolicyAttributeSet(AttributeSet[] siteWideAttrSets) throws SdkException, Exception {
    AttributeSet retVal = null;
      for(int i = 0; i < siteWideAttrSets.length; i++ ) {
          AttributeSet attrSet = siteWideAttrSets[i];
        if(attrSet.getName().equals(RETURN_POLICY)) {
          retVal = attrSet;
            break;
        }
      } 
     
View Full Code Here

    if(attrSets == null || attrSets.length == 0) {
      return "";
    }
    // Add identification information for parsing.
    for(int i = 0; i < attrSets.length; i++ ) {
      AttributeSet attrSet = attrSets[i];
      if(attrSet == null) {
        return "";
      }
      String productID = attrSet.getProductID();
      if( productID == null ) {
        productID = "";
      }
      logger.info(attrSet);
      addHiddenInputTag(sb,
                CAT_CS_ID + String.valueOf(i),
                String.valueOf(attrSet.getCategoryID()) +
                "_" + String.valueOf(attrSet.getAttributeSetID()) +
                "_" + productID);
    }
   
    Document xmlDoc = attrXmlProvider.getMultipleCSXml(attrSets);
    if(xmlDoc == null) {
      return sb.toString();
    }

    // Add SelectedAttributes node.
    Node eBayNode = XPathUtil.selectSingleNode("//eBay", xmlDoc);
    Element selectedAttributes = xmlDoc.createElement(SELECTED_ATTRIBUTES);
    eBayNode.appendChild(selectedAttributes);
    for(int i = 0; i < attrSets.length; i++ ) {
      AttributeSet attrSet = attrSets[i];
      String attrSetName = attrSet.getName();
      if(attrSetName != null && attrSetName.equals(RETURN_POLICY)) {
        XmlUtil.appendAttributeNode(selectedAttributes, PAGE_ID, RETURN_POLICY_PAGE_ID);
      }
      Node node = getSelectedAttributesXml(xmlDoc, attrSet);
      selectedAttributes.appendChild(node);
View Full Code Here

  public ErrorSet[] validate(AttributeSet[] attrSets) throws SdkException, Exception {
    int i;
    ArrayList<ErrorSet> errList = new ArrayList<ErrorSet>();

    for(i = 0; i < attrSets.length; i++ ) {
      AttributeSet attrSet = attrSets[i];
      ErrorSet errSet = validateOneSet(attrSet);
      if (errSet != null) {
        errList.add(errSet);
      }
    }
View Full Code Here

    Document doc = null;
    // Separate attributes with product ids:
    ArrayList<AttributeSet> asListWithProdIds = new ArrayList<AttributeSet>();
    ArrayList<AttributeSet> asListNoProdIds = new ArrayList<AttributeSet>();
    for(int i = 0; i < asList.length; i++) {
      AttributeSet ast = asList[i];
      if( ast.getProductID() != null ) {
        asListWithProdIds.add(ast);
      } else {
        asListNoProdIds.add(ast);
      }
    }
View Full Code Here

    }
  }

  private static AttributeSet compile(Hashtable ht, int vcsid)
  {
    AttributeSet attrSet = new AttributeSet();
    attrSet.setAttributeSetID(vcsid);

    int cnt = ht.size();
    Enumeration iter = ht.keys();

    String key;
    Object val;
    AttrInfo info;
    ArrayList al;
    Attribute attr = null;

    while(iter.hasMoreElements())
    {
      key = iter.nextElement().toString();
      val = ht.get(key);
      if (val instanceof ArrayList)
      {
        al = (ArrayList)val;
        cnt = al.size();
        // Option Other
        if (cnt == 2)
        {
          AttrInfo info0 = (AttrInfo)al.get(0);
          AttrInfo info1 = (AttrInfo)al.get(1);
          if (info0.typeId == AttributeTypes.ATTR_ID)
          {
            attr = ExtractAttr2(info0, info1);
            attrSet.add(attr);
          }
          else if (info1.typeId == AttributeTypes.ATTR_ID)
          {
            attr = ExtractAttr2(info1, info0);
            attrSet.add(attr);
          }
          else
          {
            //Unknow type.
          }
        }
        // DateTime
        else if (cnt == 3)
        {
          YMD ymd = new YMD(null, null, null);
          for (int i = 0; i < cnt; i ++)
          {
            info = (AttrInfo)al.get(i);
            switch(info.typeId)
            {
              case AttributeTypes.ATTR_DATE_D:
                ymd.day = info.val[0];
                break;
              case AttributeTypes.ATTR_DATE_M:
                ymd.month = info.val[0];
                break;
              case AttributeTypes.ATTR_DATE_Y:
                ymd.year = info.val[0];
                break;
            }
          }

          YMD.FixYMD(ymd);

          if (ymd.day != null && ymd.month!= null && ymd.year != null)
          {
            info = (AttrInfo)al.get(0);
            ArrayList_removeRange(al, 0, cnt);

            info.typeId = AttributeTypes.ATTR_TEXT_DATE;
            info.val = new String[] { ymd.year + ymd.month + ymd.day };
            al.add(info);

            attr = ExtractAttr(info);
            ((Value)attr.getValue()[0]).setValueID(new Integer(ValueIds.COMPLETE_TEXT_DATE));
            //attr.ValueList[0].ValueId = (int)ValueIds.COMPLETE_TEXT_DATE;

            attrSet.add(attr);
          }
        }
      }
      else
      {
        info = (AttrInfo) val;

        // Only year field.
        if( info.typeId == AttributeTypes.ATTR_DATE_Y )
        {
          info.typeId = AttributeTypes.ATTR_DATE_Y;
          info.val = info.val;

          attr = ExtractAttr(info);
          //((Value)attr.getValue()[0]).setValueID(new Integer(ValueIds.COMPLETE_TEXT_DATE));
          ((Value)attr.getValue()[0]).setValueID(new Integer(ValueIds.TEXT));

          attrSet.add(attr);
        }
        else
        {
          attr = ExtractAttr(info);
          if( attr.getType() == AttributeTypes.ATTR_TEXT )
          {
            ((Value)attr.getValue()[0]).setValueID(new Integer(ValueIds.TEXT));
            //attr.ValueList[0].ValueId = (int) ValueIds.TEXT;
          }

          attrSet.add(attr);
        }
      }
    }

    return attrSet;
View Full Code Here

TOP

Related Classes of com.ebay.sdk.attributes.model.AttributeSet

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.