Examples of CategoryAttribute


Examples of com.google.code.magja.model.category.CategoryAttribute

    if (attributes == null)
      return results;

    for (Map<String, Object> att : attributes) {

      CategoryAttribute attribute = new CategoryAttribute();

      for (Map.Entry<String, Object> attr : att.entrySet())
        attribute.set(attr.getKey(), attr.getValue());

      // verify options
      if (att.get("type") != null) {
        String type = (String) att.get("type");
        if (type.equals("select") || type.equals("multiselect")) {

          List<Object> optParamList = new LinkedList<Object>();
          optParamList.add(att.get("attribute_id"));
          optParamList.add(storeView);

          List<Map<String, Object>> optList = null;
          try {
            optList = (List<Map<String, Object>>) soapClient.call(
                ResourcePath.CategoryAttributeOptions,
                optParamList);
          } catch (AxisFault e) {
            if(debug) e.printStackTrace();
            throw new ServiceException(e.getMessage());
          }

          if (optList != null) {
            for (Map<String, Object> optAtt : optList) {

              CategoryAttributeOption option = new CategoryAttributeOption();
              option.setLabel((String) optAtt.get("label"));
              option.setValue(optAtt.get("value"));

              attribute.getOptions().add(option);
            }
          }
        }
      }
View Full Code Here

Examples of org.apache.lucene.facet.index.attributes.CategoryAttribute

     * This method is a special case of addCategory with multiple
     * properties, but it is kept here for two reasons: 1) Using the array
     * version has some performance cost, and 2) it is expected that most
     * calls will be for this version (single property).
     */
    CategoryAttribute ca = mapCategoryAttribute(categoryPath);
    ca.addProperty(property);
    return ca;
  }
View Full Code Here

Examples of org.apache.lucene.facet.index.attributes.CategoryAttribute

   *             one of the new properties, and merging for this property type
   *             is prohibited.
   */
  public CategoryAttribute addCategory(CategoryPath categoryPath,
      CategoryProperty... properties) throws FacetException {
    CategoryAttribute ca = mapCategoryAttribute(categoryPath);
    for (CategoryProperty attribute : properties) {
      ca.addProperty(attribute);
    }
    return ca;
  }
View Full Code Here

Examples of org.apache.lucene.facet.index.attributes.CategoryAttribute

   *         from the one provided).
   * @throws FacetException
   */
  public CategoryAttribute addCategory(CategoryAttribute categoryAttribute)
  throws FacetException {
    CategoryAttribute ca = mapCategoryAttribute(categoryAttribute
        .getCategoryPath());
    Set<Class<? extends CategoryProperty>> propertyClasses = categoryAttribute
    .getPropertyClasses();
    if (propertyClasses != null) {
      for (Class<? extends CategoryProperty> propertyClass : propertyClasses) {
        ca.addProperty(categoryAttribute.getProperty(propertyClass));
      }
    }
    return ca;
  }
View Full Code Here

Examples of org.apache.lucene.facet.index.attributes.CategoryAttribute

   * Get the {@link CategoryAttribute} object for a specific
   * {@link CategoryPath}, from the map.
   */
  private final CategoryAttribute mapCategoryAttribute(
      CategoryPath categoryPath) {
    CategoryAttribute ca = map.get(categoryPath);
    if (ca == null) {
      ca = new CategoryAttributeImpl(categoryPath);
      map.put(categoryPath, ca);
    }
    return ca;
View Full Code Here

Examples of org.apache.lucene.facet.index.attributes.CategoryAttribute

    // count the number of tokens, and check there is one DummyAttribute
    int nCategories;
    int nProperties = 0;
    for (nCategories = 0; iterator.hasNext(); nCategories++) {
      CategoryAttribute attribute = iterator.next();
      if (attribute.getProperty(DummyProperty.class) != null) {
        nProperties++;
      }
    }
    assertEquals("Wrong number of tokens", 3, nCategories);
    assertEquals("Wrong number of tokens with properties", 1, nProperties);
View Full Code Here

Examples of org.apache.lucene.facet.index.attributes.CategoryAttribute

    // count the number of tokens, and check there is one DummyAttribute
    int nCategories;
    int nDummyAttributes = 0;
    int nAssocAttributes = 0;
    for (nCategories = 0; iterator.hasNext(); nCategories++) {
      CategoryAttribute attribute = iterator.next();
      if (attribute.getProperty(DummyProperty.class) != null) {
        nDummyAttributes++;
      }
      if (attribute.getProperty(AssociationIntProperty.class) != null) {
        nAssocAttributes++;
      }
    }
    assertEquals("Wrong number of tokens", 5, nCategories);
    assertEquals("Wrong number of tokens with dummy properties", 3,
View Full Code Here

Examples of org.apache.lucene.facet.index.attributes.CategoryAttribute

    // count the number of tokens, and check there is one DummyAttribute
    int nCategories;
    int nProperties = 0;
    for (nCategories = 0; iterator.hasNext(); nCategories++) {
      CategoryAttribute attribute = iterator.next();
      if (attribute.getProperty(DummyProperty.class) != null) {
        nProperties++;
      }
    }
    assertEquals("Wrong number of tokens", 4, nCategories);
    assertEquals("Wrong number of tokens with properties", 1, nProperties);
View Full Code Here

Examples of org.apache.lucene.facet.index.attributes.CategoryAttribute

   * @throws FacetException
   */
  @Test
  public void testAddCategoryAttributeWithoutProperties()
      throws FacetException {
    CategoryAttribute newCA = new CategoryAttributeImpl(new CategoryPath(
        "seven", "eight"));
    categoryContainer.addCategory(newCA);
  }
View Full Code Here

Examples of org.apache.lucene.facet.index.attributes.CategoryAttribute

   *
   * @throws FacetException
   */
  @Test
  public void testAddCategoryAttributeWithProperty() throws FacetException {
    CategoryAttribute newCA = new CategoryAttributeImpl(new CategoryPath(
        "seven", "eight"));
    newCA.addProperty(new DummyProperty());
    categoryContainer.addCategory(newCA);
    Iterator<CategoryAttribute> iterator = categoryContainer.iterator();

    // count the number of tokens, and check there is one DummyAttribute
    int nCategories;
    int nProperties = 0;
    for (nCategories = 0; iterator.hasNext(); nCategories++) {
      CategoryAttribute attribute = iterator.next();
      if (attribute.getProperty(DummyProperty.class) != null) {
        nProperties++;
      }
    }
    assertEquals("Wrong number of tokens", 4, nCategories);
    assertEquals("Wrong number of tokens with properties", 1, nProperties);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.