org.apache.oodt.cas.filemgr.catalog
Class DataSourceCatalog

java.lang.Object
  extended by org.apache.oodt.cas.filemgr.catalog.DataSourceCatalog
All Implemented Interfaces:
Catalog, Pagination
Direct Known Subclasses:
MappedDataSourceCatalog

public class DataSourceCatalog
extends Object
implements Catalog

Version:
$Revision: 9683 $

Implementation of a Catalog that is backed by a DataSource front-end to a SQL DBMS.

Author:
mattmann, bfoster

Field Summary
protected  DataSource dataSource
           
protected  boolean fieldIdStringFlag
           
protected  int pageSize
           
 
Fields inherited from interface org.apache.oodt.cas.filemgr.catalog.Catalog
X_POINT_ID
 
Constructor Summary
DataSourceCatalog(DataSource ds, ValidationLayer valLayer, boolean fieldId, int pageSize, long cacheUpdateMin)
           Default Constructor
 
Method Summary
 void addMetadata(org.apache.oodt.cas.metadata.Metadata m, Product product)
           Ingests Metadata into the metadata store, and associates it with the given productId.
 void addProduct(Product product)
           Adds a Product to the Catalog.
 void addProductReferences(Product product)
           Adds the specified List of References to the Catalog, and associates them with this Product specified by its productId.
 ProductPage getFirstPage(ProductType type)
           
 ProductPage getLastProductPage(ProductType type)
           
 org.apache.oodt.cas.metadata.Metadata getMetadata(Product product)
           Gets the Metadata for a given Product.
 ProductPage getNextPage(ProductType type, ProductPage currentPage)
           
 int getNumProducts(ProductType type)
           
 ProductPage getPrevPage(ProductType type, ProductPage currentPage)
           
 Product getProductById(String productId)
           Gets a Product, with the specified productId.
 Product getProductByName(String productName)
           Gets a Product with the specified productName.
 List<Reference> getProductReferences(Product product)
           Gets the References associated with this Product.
 List<Product> getProducts()
           Gets all the Products in the Catalog.
 List<Product> getProductsByProductType(ProductType type)
           Gets the Products associated with the specified ProductType in the Catalog.
 org.apache.oodt.cas.metadata.Metadata getReducedMetadata(Product product, List<String> elems)
           Gets a reduced set of metadata for a give Product.
 List<Product> getTopNProducts(int n)
           Gets the top N most recent products that have been cataloged.
 List<Product> getTopNProducts(int n, ProductType type)
           Gets the top N most recent products that have been cataloged for the given ProductType.
 ValidationLayer getValidationLayer()
           
 void modifyProduct(Product product)
           Modifies an existing Product within the Catalog.
 ProductPage pagedQuery(Query query, ProductType type, int pageNum)
           Performs a query against the underlying Catalog, and then properly formulates a page of results to send back to the user.
 List<String> query(Query query, ProductType type)
           Queries the Catalog with the specified Query
 void removeMetadata(org.apache.oodt.cas.metadata.Metadata m, Product product)
           Removes Metadata from the metadata store, and disassociates it from the given productId.
 void removeProduct(Product product)
           Removes a Product from the Catalog.
 void setProductTransferStatus(Product product)
           Persists the transferStatus attribute of the given Product to the Catalog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataSource

protected DataSource dataSource

fieldIdStringFlag

protected boolean fieldIdStringFlag

pageSize

protected int pageSize
Constructor Detail

DataSourceCatalog

public DataSourceCatalog(DataSource ds,
                         ValidationLayer valLayer,
                         boolean fieldId,
                         int pageSize,
                         long cacheUpdateMin)

Default Constructor

.

Throws:
Method Detail

addMetadata

public void addMetadata(org.apache.oodt.cas.metadata.Metadata m,
                        Product product)
                 throws CatalogException
Description copied from interface: Catalog

Ingests Metadata into the metadata store, and associates it with the given productId.

Specified by:
addMetadata in interface Catalog
Parameters:
m - The Metadata to ingest.
product - The product to add the metadata for.
Throws:
CatalogException - If any general error occurs.

removeMetadata

public void removeMetadata(org.apache.oodt.cas.metadata.Metadata m,
                           Product product)
                    throws CatalogException
Description copied from interface: Catalog

Removes Metadata from the metadata store, and disassociates it from the given productId.

Specified by:
removeMetadata in interface Catalog
Parameters:
m - The Metadata to remove.
product - The product for which the metadata is to be removed.
Throws:
CatalogException - If any general error occurs.

addProduct

public void addProduct(Product product)
                throws CatalogException
Description copied from interface: Catalog

Adds a Product to the Catalog.

Specified by:
addProduct in interface Catalog
Parameters:
product - The Product to add.
Throws:
CatalogException - If any error occurs during the add.

modifyProduct

public void modifyProduct(Product product)
                   throws CatalogException
Description copied from interface: Catalog

Modifies an existing Product within the Catalog.

Specified by:
modifyProduct in interface Catalog
Parameters:
product - The new Product information to modify the existing Product with.
Throws:
CatalogException - If any error occurs.

removeProduct

public void removeProduct(Product product)
                   throws CatalogException
Description copied from interface: Catalog

Removes a Product from the Catalog.

Specified by:
removeProduct in interface Catalog
Parameters:
product - The product to remove.
Throws:
CatalogException - If any error occurs.

setProductTransferStatus

public void setProductTransferStatus(Product product)
                              throws CatalogException
Description copied from interface: Catalog

Persists the transferStatus attribute of the given Product to the Catalog.

Specified by:
setProductTransferStatus in interface Catalog
Parameters:
product - The Product whose transfer status will be persisted. The caller should make sure that the product ID field is set.
Throws:
CatalogException

addProductReferences

public void addProductReferences(Product product)
                          throws CatalogException
Description copied from interface: Catalog

Adds the specified List of References to the Catalog, and associates them with this Product specified by its productId.

Specified by:
addProductReferences in interface Catalog
Parameters:
product - The product to add references for. The references are read from the Products list of References.
Throws:
CatalogException - If anything goes wrong.

getProductById

public Product getProductById(String productId)
                       throws CatalogException
Description copied from interface: Catalog

Gets a Product, with the specified productId.

Specified by:
getProductById in interface Catalog
Parameters:
productId - The unique ID of the Product to retrieve.
Returns:
A Product, with the given ID. The implementer of this method should ensure that the product References are populated as well.
Throws:
CatalogException - If any error occurs.

getProductByName

public Product getProductByName(String productName)
                         throws CatalogException
Description copied from interface: Catalog

Gets a Product with the specified productName.

Specified by:
getProductByName in interface Catalog
Parameters:
productName - The name of the Product to retrieve.
Returns:
A Product with the given name. The implementer of this method should ensure that the product References are populated as well.
Throws:
CatalogException

getProductReferences

public List<Reference> getProductReferences(Product product)
                                     throws CatalogException
Description copied from interface: Catalog

Gets the References associated with this Product.

Specified by:
getProductReferences in interface Catalog
Parameters:
product - The Product to obtain the References for.
Returns:
A List of References, associated with the specified Product.
Throws:
CatalogException

getProducts

public List<Product> getProducts()
                          throws CatalogException
Description copied from interface: Catalog

Gets all the Products in the Catalog.

Specified by:
getProducts in interface Catalog
Returns:
A List of Products in the Catalog.
Throws:
CatalogException - If any error occurs.

getProductsByProductType

public List<Product> getProductsByProductType(ProductType type)
                                       throws CatalogException
Description copied from interface: Catalog

Gets the Products associated with the specified ProductType in the Catalog.

Specified by:
getProductsByProductType in interface Catalog
Parameters:
type - The ProductType to obtain the Products for.
Returns:
A List of Products that are associated with the specified productType in the Catalog.
Throws:
CatalogException - If any error occurs.

getMetadata

public org.apache.oodt.cas.metadata.Metadata getMetadata(Product product)
                                                  throws CatalogException
Description copied from interface: Catalog

Gets the Metadata for a given Product.

Specified by:
getMetadata in interface Catalog
Parameters:
product - The Product to obtain the Metadata for.
Returns:
The Metadata for the given productId.

Throws:
CatalogException - If any error occurs.

getReducedMetadata

public org.apache.oodt.cas.metadata.Metadata getReducedMetadata(Product product,
                                                                List<String> elems)
                                                         throws CatalogException
Description copied from interface: Catalog

Gets a reduced set of metadata for a give Product.

Specified by:
getReducedMetadata in interface Catalog
Parameters:
product - The Product to obtain the Metadata for.
elems - The set of metadata elements of interest.
Returns:
The reduced Metadata for the given productId.
Throws:
CatalogException - If any error occurs.

query

public List<String> query(Query query,
                          ProductType type)
                   throws CatalogException
Description copied from interface: Catalog

Queries the Catalog with the specified Query

.

Specified by:
query in interface Catalog
Parameters:
query - The set of criteria by which to query the Catalog.
type - The ProductType that should be queried.
Returns:
A List of String product IDs that can be used to retrieve products that match the query.
Throws:
CatalogException - If any error occurs.

getTopNProducts

public List<Product> getTopNProducts(int n)
                              throws CatalogException
Description copied from interface: Catalog

Gets the top N most recent products that have been cataloged.

Specified by:
getTopNProducts in interface Catalog
Parameters:
n - The amount of recent products to return.
Returns:
A List of Products that have been cataloged recently.
Throws:
CatalogException - If any error occurs.

getTopNProducts

public List<Product> getTopNProducts(int n,
                                     ProductType type)
                              throws CatalogException
Description copied from interface: Catalog

Gets the top N most recent products that have been cataloged for the given ProductType.

Specified by:
getTopNProducts in interface Catalog
Parameters:
n - The amount of recent products to return.
type - The ProductType to limit the query to.
Returns:
A List of Products that have been cataloged recently.
Throws:
CatalogException - If any error occurs.

getValidationLayer

public ValidationLayer getValidationLayer()
                                   throws CatalogException
Specified by:
getValidationLayer in interface Catalog
Returns:
The ValidationLayer that is used by this Catalog.
Throws:
CatalogException - If any error occurs (e.g., the layer isn't initialized).

getNumProducts

public int getNumProducts(ProductType type)
                   throws CatalogException
Specified by:
getNumProducts in interface Catalog
Parameters:
type - The ProductType to count the number of products for.
Returns:
An integer count of the number of Products for the specified ProductType.
Throws:
CatalogException - If any error occurs.

getFirstPage

public ProductPage getFirstPage(ProductType type)
Specified by:
getFirstPage in interface Pagination
Parameters:
type - The ProductType to obtain the first ProductPage for.
Returns:
The first page of products for a particular ProductType.

getLastProductPage

public ProductPage getLastProductPage(ProductType type)
Specified by:
getLastProductPage in interface Pagination
Parameters:
type - The ProductType to obtain the last ProductPage for.
Returns:
The last page of products for a particular ProductType.

getNextPage

public ProductPage getNextPage(ProductType type,
                               ProductPage currentPage)
Specified by:
getNextPage in interface Pagination
Parameters:
type - The ProductType to obtain the next page for, given the currentPage.
currentPage - The current page that tells the function what the next page to obtain is.
Returns:
The next page in the ProductType product list, given the currentPage.

getPrevPage

public ProductPage getPrevPage(ProductType type,
                               ProductPage currentPage)
Specified by:
getPrevPage in interface Pagination
Parameters:
type - The ProductType to obtain the previous page for, given the currentPage.
currentPage - The currentPage that tells the function what the previous page to obtain is.
Returns:
The previous page in the ProductType product list, given the currentPage.

pagedQuery

public ProductPage pagedQuery(Query query,
                              ProductType type,
                              int pageNum)
                       throws CatalogException
Description copied from interface: Catalog

Performs a query against the underlying Catalog, and then properly formulates a page of results to send back to the user. This method is useful when you would like to conserve memory and not send back the entire list of results, nor load them into memory. Of course, this method assumes that queries are deterministic, i.e., the same query issued 2x within a paginating session will produce the same set of results to paginate.

Specified by:
pagedQuery in interface Catalog
Parameters:
query - The query to perform against the underlying Catalog.
type - The ProductType that you are querying for.
pageNum - The number of the ProductPage to return back to the user.
Returns:
The requested ProductPage of results.
Throws:
CatalogException - If any error occurs.


Copyright © 1999-2011 Apache OODT. All Rights Reserved.