Package net.fp.rp.search.mid.category

Source Code of net.fp.rp.search.mid.category.BasicCategory

/*
* Copyright (C) 2004 Paul Browne, http://www.firstpartners.net,
* built with the help of Fast-Soft (fastsoftdev@yahoo.com)
*
* released under terms of the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*
* This product includes software developed by the
* Apache Software Foundation (http://www.apache.org)."
*
* This product includes software developed by the
* Spring Framework Project (http://www.springframework.org)."
*
*/
package net.fp.rp.search.mid.category;

import net.fp.rp.common.exception.RpException;
import net.fp.rp.search.common.AddInfo;
import net.fp.rp.search.plugins.ICategory;
import net.fp.rp.search.plugins.ICategoryManager;
import net.fp.rp.search.plugins.IDataExtractor;

import org.apache.log4j.Logger;

import java.util.Date;


/**
* A Category is a set of Data. Many Categories make up a knowledgebase. This
* is a basic implementation of a Category
*
* @author brownpa
* Copyright @link www.firstpartners.net/red
*/
public class BasicCategory implements ICategory {
    /** Logger for this class and subclasses */
    protected final Logger logger = Logger.getLogger(getClass());

    /** Original category location */
    private String m_original;

    /** Category name */
    private String m_name;

    /** Uri location of the category */
    private String m_uri;

    /** Extractor handler of the category */
    private IDataExtractor m_extractor;

    /** Direct score of the category */
    private double m_categoryScore;

    /** Time stamp for last category update */
    private String m_lastUpdate;

    /**
     * Creates a new BasicCategory object.
     *
     * @param original Original location
     * @param name Category name
     * @param uri URI of the information to be added
     * @param extractor The extractor which will handle the information
     */
    public BasicCategory(String original, String name, String uri,
        IDataExtractor extractor) {
        this.m_original = original;
        this.m_name = name;
        this.m_uri = uri;
        this.m_extractor = extractor;

        //category
        this.m_categoryScore = 1.00;
        this.m_lastUpdate = new Date().toString();
    }

    /**
     * Construct the category    1. generate the tuple from the information
     * using the extractor  2. store the information as RDF  using the
     * category store    3. add the information to the index
     *
     * @param manager Manager responsable for
     *
     * @throws RpException Error occur in process the information
     */
    public void generateCategoryData(ICategoryManager manager)
        throws RpException {
        logger.debug("Start to generate the category data");

        try {
            //add info object for the original location, categor name and specified uri
            AddInfo addinfo = new AddInfo(m_original, m_name, m_uri);

            m_extractor.convert(addinfo);
        } catch (RpException e) {
            logger.warn("Error in generate the data for the category " +
                e.getMessage(), e);
            e.printStackTrace(System.out);
            throw e;
        }
    }

    /**
     * Get original location of the category
     *
     * @return Original location of the category
     */
    public String getOriginalLocation() {
        return m_original;
    }

    /**
     * Get the name of this Category
     *
     * @return Name of this category
     */
    public String getCategoryName() {
        return m_name;
    }

    /**
     * Get a Handle to the Datasource used when creating this Category <BR/> ie
     * where we got the original data from
     *
     * @return IDataExtractor
     */
    public IDataExtractor getDataSource() {
        return m_extractor;
    }

    /**
     * Get the category uri location
     *
     * @return Original location
     */
    public String getLocation() {
        return m_uri;
    }

    /**
     * Get the last update of the document
     *
     * @return Last update for the document!
     */
    public String getLastUpdate() {
        return m_lastUpdate;
    }

    /**
     * Get the category scroe
     *
     * @return The category score
     */
    public double getCategoryScore() {
        return m_categoryScore;
    }

    /**
     * Get the calculated score of the category
     *
     * @return The calculated score
     */
    public double getCalculatedScore() {
        return m_categoryScore * 1;
    }
}
TOP

Related Classes of net.fp.rp.search.mid.category.BasicCategory

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.