net.firstpartners.rp.back.datastore
Class BasicCategoryStore

java.lang.Object
  extended by net.firstpartners.rp.back.datastore.BasicCategoryStore
All Implemented Interfaces:
ICategoryStore

public class BasicCategoryStore
extends java.lang.Object
implements ICategoryStore

Simple Meta Data Store as an XML file.

Author:
brownpa

Field Summary
protected  org.apache.log4j.Logger logger
          Logger for this class and subclasses
(package private) static java.lang.String MODEL_EXTENSION
          Model extension
(package private) static java.lang.String MODEL_NAME
          Model name
private static java.lang.String SEPARATOR
          Separator for the links list (categoryname/nodeid)
 
Constructor Summary
BasicCategoryStore()
           
 
Method Summary
private  com.hp.hpl.jena.rdf.model.Resource generateResource(NodeStruct root, com.hp.hpl.jena.rdf.model.Model model)
          Generate the RDF-Resource for the content node
 double getDirectScore(java.lang.String categName, java.lang.String documID)
          Get the direct score for the specified document id in the category
 double getImpliedScore(java.lang.String categName, java.lang.String documID)
          Get the implied score for the specified document id in the category
private  java.lang.String getModelPath(java.lang.String categoryname, java.lang.String documentid)
          Get the model path for the specified document in the category
 java.lang.String getOriginalLocation(java.lang.String path)
          Get the original location of the category from the model.
 void store(DocumStruct doc)
          Store the document data as rdf-xml.
 void updateCategoryScore(java.lang.String categoryname, int userScore)
          Update the category score using the categoryname and user feedback score
 void updateDocumentDirectScore(java.lang.String categoryname, java.lang.String documentid, int userScore)
          Update the direct score of the document using the categoryname, document id and user feedback score
 void updateDocumentLinksAndScore(java.util.LinkedList listLinks, int userScore)
          Update the document with the specified links list and user feedback (+/-)
private  void updateModelCategoryScore(java.lang.String modelpath, int userScore)
          Update the category score of the document using the model path and user feedback score
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODEL_NAME

static final java.lang.String MODEL_NAME
Model name

See Also:
Constant Field Values

MODEL_EXTENSION

static final java.lang.String MODEL_EXTENSION
Model extension

See Also:
Constant Field Values

SEPARATOR

private static final java.lang.String SEPARATOR
Separator for the links list (categoryname/nodeid)

See Also:
Constant Field Values

logger

protected final org.apache.log4j.Logger logger
Logger for this class and subclasses

Constructor Detail

BasicCategoryStore

public BasicCategoryStore()
Method Detail

getOriginalLocation

public java.lang.String getOriginalLocation(java.lang.String path)
                                     throws RpException
Get the original location of the category from the model. Return the original location (category location of the first model from the category folder)

Specified by:
getOriginalLocation in interface ICategoryStore
Parameters:
path - Category folder path
Returns:
Original location of the category
Throws:
RpException - If an error occur in reading the document location

getDirectScore

public double getDirectScore(java.lang.String categName,
                             java.lang.String documID)
                      throws RpException
Get the direct score for the specified document id in the category

Specified by:
getDirectScore in interface ICategoryStore
Parameters:
categName - The category name
documID - The document id
Returns:
Direct score of the document
Throws:
RpException - If an error occur in reading the direct score of the document

getImpliedScore

public double getImpliedScore(java.lang.String categName,
                              java.lang.String documID)
                       throws RpException
Get the implied score for the specified document id in the category

Specified by:
getImpliedScore in interface ICategoryStore
Parameters:
categName - The category name
documID - The document id
Returns:
Implied score of the document
Throws:
RpException - If an error occur in calculate the implied score of the document

getModelPath

private java.lang.String getModelPath(java.lang.String categoryname,
                                      java.lang.String documentid)
Get the model path for the specified document in the category

Parameters:
categoryname - The category name
documentid - The document id
Returns:
The model path for document in the category

updateDocumentLinksAndScore

public void updateDocumentLinksAndScore(java.util.LinkedList listLinks,
                                        int userScore)
Update the document with the specified links list and user feedback (+/-)

Specified by:
updateDocumentLinksAndScore in interface ICategoryStore
Parameters:
listLinks - Links list to update the document
userScore - User feedback score (+/-)

updateDocumentDirectScore

public void updateDocumentDirectScore(java.lang.String categoryname,
                                      java.lang.String documentid,
                                      int userScore)
Update the direct score of the document using the categoryname, document id and user feedback score

Specified by:
updateDocumentDirectScore in interface ICategoryStore
Parameters:
categoryname - The category name
documentid - The document id
userScore - The user feedback score (+1/-1)

updateModelCategoryScore

private void updateModelCategoryScore(java.lang.String modelpath,
                                      int userScore)
Update the category score of the document using the model path and user feedback score

Parameters:
modelpath - The model path
userScore - The user feedback score (+1/-1)

updateCategoryScore

public void updateCategoryScore(java.lang.String categoryname,
                                int userScore)
Update the category score using the categoryname and user feedback score

Specified by:
updateCategoryScore in interface ICategoryStore
Parameters:
categoryname - The category name
userScore - The user feedback score (+1/-1)

store

public void store(DocumStruct doc)
           throws RpException
Store the document data as rdf-xml. If the model exists , then rewrite the new model.

Specified by:
store in interface ICategoryStore
Parameters:
doc - Document to be stored
Throws:
RpException - If an error occur in storing the data

generateResource

private com.hp.hpl.jena.rdf.model.Resource generateResource(NodeStruct root,
                                                            com.hp.hpl.jena.rdf.model.Model model)
Generate the RDF-Resource for the content node

Parameters:
root - Node struct content
model - RDF-Model used for generation of the resources
Returns:
RDF-Resources for the specified node