Examples of CategoryAttribute


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

    Iterator<CategoryAttribute> iterator = categoryContainer.iterator();

    int nCategories;
    int nAssociations = 0;
    for (nCategories = 0; iterator.hasNext(); nCategories++) {
      CategoryAttribute ca = iterator.next();
      AssociationProperty aa = (AssociationProperty) ca
          .getProperty(AssociationIntProperty.class);
      if (aa != null) {
        assertEquals("Wrong association value", 17, aa.getAssociation());
        nAssociations++;
      }
View Full Code Here

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

public class CategoryAttributeImplTest extends LuceneTestCase {

  @Test
  public void testCategoryPath() {
    CategoryAttribute ca = new CategoryAttributeImpl();

    assertNull("Category Path should be null", ca.getCategoryPath());

    CategoryPath cp = new CategoryPath("a", "b");
    ca.setCategoryPath(cp);

    assertEquals("Wrong Category Path", cp, ca.getCategoryPath());

    ca.setCategoryPath(null);
    assertNull("Category Path should be null", ca.getCategoryPath());

    ca = new CategoryAttributeImpl(cp);
    assertEquals("Wrong Category Path", cp, ca.getCategoryPath());
  }
View Full Code Here

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

    assertEquals("Wrong Category Path", cp, ca.getCategoryPath());
  }

  @Test
  public void testProperties() throws FacetException {
    CategoryAttribute ca = new CategoryAttributeImpl();

    assertNull("Attribute should be null", ca
        .getProperty(DummyProperty.class));
    assertNull("Attribute classes should be null", ca.getPropertyClasses());

    ca.addProperty(new DummyProperty());
    assertEquals("DummyProperty should be in properties",
        new DummyProperty(), ca.getProperty(DummyProperty.class));
    assertEquals("Attribute classes should contain 1 element", 1, ca
        .getPropertyClasses().size());

    boolean failed = false;
    try {
      ca.addProperty(new DummyProperty());
    } catch (UnsupportedOperationException e) {
      failed = true;
    }

    if (!failed) {
      fail("Two DummyAttributes added to the same CategoryAttribute");
    }

    ca.clearProperties();
    assertNull("Attribute classes should be null", ca.getPropertyClasses());

    ca.addProperty(new DummyProperty());
    assertEquals("DummyProperty should be in properties",
        new DummyProperty(), ca.getProperty(DummyProperty.class));
    ca.remove(DummyProperty.class);
    assertEquals("DummyProperty should not be in properties", null, ca
        .getProperty(DummyProperty.class));
    assertNull("Attribute classes should be null", ca.getPropertyClasses());

    ca.addProperty(new DummyProperty());
    List<Class<? extends CategoryProperty>> propertyClasses = new ArrayList<Class<? extends CategoryProperty>>();
    assertEquals("No property expected when no classes given", null, ca
        .getProperty(propertyClasses));
    propertyClasses.add(DummyProperty.class);
    assertEquals("DummyProperty should be in properties",
        new DummyProperty(), ca.getProperty(propertyClasses));
    propertyClasses.add(OrdinalProperty.class);
    assertEquals("DummyProperty should be in properties",
        new DummyProperty(), ca.getProperty(propertyClasses));
    propertyClasses.clear();
    propertyClasses.add(OrdinalProperty.class);
    assertEquals("No ordinal property expected", null, ca
        .getProperty(propertyClasses));
  }
View Full Code Here

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

    CategoryPath cp = new CategoryPath("a", "b");
    ca1.setCategoryPath(cp);
    ca1.addProperty(new DummyProperty());

    CategoryAttribute ca2 = ca1.clone();
    assertEquals("Error in cloning", ca1, ca2);

    CategoryAttributeImpl ca3 = new CategoryAttributeImpl();
    assertNotSame("Should not be the same", ca1, ca3);
    ca1.copyTo(ca3);
    assertEquals("Error in cloning", ca1, ca3);

    ca2.setCategoryPath(null);
    assertNotSame("Should not be the same", ca1, ca2);
    ca2.set(ca3);
    assertEquals("Error in cloning", ca1, ca2);
  }
View Full Code Here

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

    for (int i = 0; i < initialCatgeories.length; i++) {
      pathsSet.add(initialCatgeories[i]);
    }
    stream.reset();
    while (stream.incrementToken()) {
      CategoryAttribute fromStream = stream
          .getAttribute(CategoryAttribute.class);
      if (!pathsSet.remove(fromStream.getCategoryPath())) {
        fail("Unexpected category path: "
            + fromStream.getCategoryPath().toString(':'));
      }
    }
    assertTrue("all category paths should have been found", pathsSet
        .isEmpty());
  }
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

   *            The properties to associate to the category.
   * @return The {@link CategoryAttribute} of the category.
   */
  public CategoryAttribute addCategory(CategoryPath categoryPath,
      CategoryProperty... properties) {
    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

   *            The {@link CategoryAttribute} to add.
   * @return The {@link CategoryAttribute} of the category (could be different
   *         from the one provided).
   */
  public CategoryAttribute addCategory(CategoryAttribute categoryAttribute) {
    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.infoglue.cms.entities.management.CategoryAttribute

    List localCategoryKeys = getDefinedCategoryKeys(localSchemaValue);

    Iterator categoriesIterator = remoteCategoryKeys.iterator();
    while(categoriesIterator.hasNext())
    {
      CategoryAttribute categoryAttribute = (CategoryAttribute)categoriesIterator.next();
      //logger.info("categoryAttribute:" + categoryAttribute.getCategoryName());
     
      Iterator localCategoriesIterator = localCategoryKeys.iterator();
      boolean categoryExisted = false;
      while(localCategoriesIterator.hasNext())
      {
        CategoryAttribute localCategoryAttribute = (CategoryAttribute)localCategoriesIterator.next();
        if(localCategoryAttribute.getCategoryName().equals(categoryAttribute.getCategoryName()))
          categoryExisted = true;
      }
      //logger.info("categoryExisted:" + categoryExisted);
     
      if(!categoryExisted)
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.