SPT Core API

com.sptci.jdo
Class CategoryFactory

java.lang.Object
  extended by com.sptci.jdo.Factory<Category>
      extended by com.sptci.jdo.CategoryFactory

public class CategoryFactory
extends Factory<Category>

Repository class for the Category model object. Manages all interactions with the data store.

© Copyright 2009 Sans Pareil Technologies, Inc.

Version:
$Id: CategoryFactory.java 4618 2009-02-10 00:49:30Z rakesh $
Author:
Rakesh Vidyadharan 2009-1-12

Field Summary
static CategoryFactory categoryFactory
          A singleton instance of the repository class.
 
Fields inherited from class com.sptci.jdo.Factory
logger
 
Constructor Summary
CategoryFactory()
           
 
Method Summary
 List<Category> children(Category parent, javax.jdo.PersistenceManager pm)
          Return all the children of the specified category.
 Collection<Category> fetchAll(javax.jdo.PersistenceManager pm)
          Return all the categories stored in the data store.
 Collection<Category> fetchByName(String name, javax.jdo.PersistenceManager pm)
          Return all the categories with the specified name.
 Category fetchByNameAndParent(String name, Category parent, javax.jdo.PersistenceManager pm)
          Return the category uniquely identified by the specified name and parent category.
static CategoryFactory getInstance()
          Return the singleton instance of this repository class.
 Collection<Category> parents(javax.jdo.PersistenceManager pm)
          Return all the root level categories in the data store.
 
Methods inherited from class com.sptci.jdo.Factory
addAlphabeticalIndex, begin, close, close, commit, count, delete, fetch, fetch, fetch, fetchAll, getPersistenceManager, removeStartLetter, rollback, save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

categoryFactory

public static final CategoryFactory categoryFactory
A singleton instance of the repository class.

Constructor Detail

CategoryFactory

public CategoryFactory()
Method Detail

getInstance

public static CategoryFactory getInstance()
Return the singleton instance of this repository class.

Returns:
The categoryFactory instance.

fetchAll

public Collection<Category> fetchAll(javax.jdo.PersistenceManager pm)
Return all the categories stored in the data store.

Parameters:
pm - The persistence manager to use.
Returns:
The collection of all the categories.

parents

public Collection<Category> parents(javax.jdo.PersistenceManager pm)
Return all the root level categories in the data store. Root level categories are those that have null parent fields.

Parameters:
pm - The persistence manager to use.
Returns:
The collection of root catetories. Returns an empty collection if no categories exist.

children

public List<Category> children(Category parent,
                               javax.jdo.PersistenceManager pm)
Return all the children of the specified category.

Parameters:
parent - The category whose child categories are to be retrieved.
pm - The persistence manager to use.
Returns:
The collection of children. Returns an empty collection if no children exist.

fetchByName

public Collection<Category> fetchByName(String name,
                                        javax.jdo.PersistenceManager pm)
Return all the categories with the specified name.

Parameters:
name - The name of the category.
pm - The persistence manager to use.
Returns:
The collection of categories. Returns an empty collection if no category exists.

fetchByNameAndParent

public Category fetchByNameAndParent(String name,
                                     Category parent,
                                     javax.jdo.PersistenceManager pm)
Return the category uniquely identified by the specified name and parent category.

Parameters:
name - The name of the category
parent - The parent category.
Returns:
The category instance of null if no such category exists.

SPT Core API