de.fh_mannheim.mm.dms.framework
Class ContentManager

java.lang.Object
  extended byde.fh_mannheim.mm.dms.framework.ConnectionManager
      extended byde.fh_mannheim.mm.dms.framework.ContentConnectionManager
          extended byde.fh_mannheim.mm.dms.framework.ContentManager
All Implemented Interfaces:
ISearchManager

public class ContentManager
extends ContentConnectionManager
implements ISearchManager

ContentManager loads extracted text to the database and stems the keywords. To search the documentbase, the function searchQuery() is used.

Version:
$Revision: 1.54 $
Author:
Jan Löffler, mail@jlsoft.de

Field Summary
static int BOOLEAN_AND
          Public declarations for weights for boolean values
static int BOOLEAN_NOT
           
static int BOOLEAN_OR
           
static double MIN_RELEVANCY
          Minimum relevance
static int PRIORITY_META
          Factor for metainformation
 
Fields inherited from class de.fh_mannheim.mm.dms.framework.ContentConnectionManager
MAX_RESULTS
 
Constructor Summary
ContentManager(Config cfg, UploadManager uplMgr, StopwordManager stwdMgr)
          Constructor.
 
Method Summary
 boolean addContent(java.lang.String strText, int nID)
          Add new content.
 boolean addIndex(int nFileID, int nKeywordID, int nFrequency)
          Adds a document-keyword-pair to the index database.
 boolean addIndexList(int nFileID, java.util.ArrayList aKeywords)
          Adds a list with document-keyword-pairs to the index database.
 boolean addKeyword(java.lang.String strKeyword)
          Adds a keyword to the keyword database.
 boolean addKeyword(java.lang.String strKeyword, int nFrequency)
          Adds a keyword to the keyword database.
 boolean addKeywordList(java.util.ArrayList aKeywords)
          Adds a list with keywords to the keyword database.
 int addLanguage(Upload upload, StopwordList aStopwords)
          Adds a the language to the upload by comparing the stopwords.
 boolean addMetaIndexList(int nFileID, java.util.ArrayList aKeywords)
          Adds a list with document-keyword-pairs to the index database.
 boolean addPreparedQueryWord(java.lang.String strWord, int nBoolType, int nLanguage, int nUserID)
          Prepare the querystring for request.
 boolean addQueryWord(java.lang.String strWord, double dWeight, int nUserID)
          Adds a query keyword to the query database.
 boolean addQueryWord(java.lang.String strWord, int nUserID)
          Adds a query keyword to the query database.
 boolean addUpload(Upload upload)
          Extract the plaintext from a given document.
 void adjustWeights()
          Adjust the weights.
 boolean clearQuery(int nUserID)
          Clear the querystring for request.
static java.lang.StringBuffer convertText(java.lang.String strPlaintext)
          Remove umlaute and convert to lowercase.
 void cutOffWords(java.util.ArrayList aWords)
          Remove all words with frequency 1.
 boolean deleteContent(int nID)
          Deletes content of a file.
 boolean deleteIndex()
          Delete all keywords.
 boolean deleteIndex(int nFileID)
          Delete all keywords from a file.
 int getIndexNum()
          Counts all index pairs.
 int getKeyword(java.lang.String strKeyword)
          Get keyword.
 int getKeywordNum()
          Counts all keywords.
 java.util.ArrayList getKeywords(int nUploadID, int nLimit)
          Get all keywords of a given document.
 double getLastCompressionRate()
          Returns the compressionrate of the last file.
 int indexMetaInformation(Upload upload)
          Index metainformation of upload.
 int indexText(java.lang.StringBuffer strText, Upload upload)
          Remove stopwords of a string and index keywords.
 int indexTextFile(Upload upload)
          Extract the plaintext from a text document.
 void optimize()
          Optimize tables.
 SearchResultList searchQuery(Query query)
          Prepare the querystring for request.
 void showMessage(java.lang.String strMessage)
          Show a message.
 void showMessage(java.lang.String strMessage, boolean bShowTime)
          Show a message.
 void showMessage(java.lang.String strMessage, boolean bShowTime, boolean bNewLine)
          Show a message.
static java.util.ArrayList sort(java.lang.String[] strList)
          Sort list.
 java.util.ArrayList stemWordList(java.util.ArrayList aWords, int nLanguage)
          Creates a new list with all words stemmed.
 
Methods inherited from class de.fh_mannheim.mm.dms.framework.ContentConnectionManager
insertIndex, insertKeyword, insertQuery, searchQuery, searchQuery, searchQueryByLanguage, searchQueryByLanguage, updateFileWeight, updateIndexFrequency, updateIndexWeight, updateKeywordFrequency, updateKeywordWeight, updateQuery
 
Methods inherited from class de.fh_mannheim.mm.dms.framework.ConnectionManager
checkConnection, closeConnection, closePreparedStatement, closeResultSet, closeResultSet, commit, executeQuery, executeQueryGetBool, executeQueryGetDate, executeQueryGetDouble, executeQueryGetInt, executeQueryGetString, executeUpdate, formatBool, formatDate, formatDate, formatDouble, formatInteger, formatString, getPreparedStatement, openConnection, optimizeTable, rollback, startTransaction
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOOLEAN_AND

public static final int BOOLEAN_AND
Public declarations for weights for boolean values

See Also:
Constant Field Values

BOOLEAN_NOT

public static final int BOOLEAN_NOT
See Also:
Constant Field Values

BOOLEAN_OR

public static final int BOOLEAN_OR
See Also:
Constant Field Values

MIN_RELEVANCY

public static final double MIN_RELEVANCY
Minimum relevance

See Also:
Constant Field Values

PRIORITY_META

public static final int PRIORITY_META
Factor for metainformation

See Also:
Constant Field Values
Constructor Detail

ContentManager

public ContentManager(Config cfg,
                      UploadManager uplMgr,
                      StopwordManager stwdMgr)
Constructor.

Parameters:
cfg - Config
uplMgr - UploadManager
Method Detail

addContent

public boolean addContent(java.lang.String strText,
                          int nID)
Add new content.

Parameters:
strText -
nID - ID of file
Returns:
true, if successful

addIndex

public boolean addIndex(int nFileID,
                        int nKeywordID,
                        int nFrequency)
Adds a document-keyword-pair to the index database.

Parameters:
nFileID - Corresponding upload
nKeywordID - Corresponding keyword
nFrequency - Number of found equal keywords
Returns:
true, if successful

addIndexList

public boolean addIndexList(int nFileID,
                            java.util.ArrayList aKeywords)
Adds a list with document-keyword-pairs to the index database.

Parameters:
nFileID - Corresponding upload
aKeywords - Corresponding keywords
Returns:
true, if successful

addKeyword

public boolean addKeyword(java.lang.String strKeyword)
Adds a keyword to the keyword database.

Parameters:
strKeyword - New keyword
Returns:
true, if successful

addKeyword

public boolean addKeyword(java.lang.String strKeyword,
                          int nFrequency)
Adds a keyword to the keyword database.

Parameters:
strKeyword - New keyword
nFrequency - Frequency of keyword
Returns:
true, if successful

addKeywordList

public boolean addKeywordList(java.util.ArrayList aKeywords)
Adds a list with keywords to the keyword database.

Parameters:
aKeywords - New keyword list
Returns:
true, if successful

addLanguage

public int addLanguage(Upload upload,
                       StopwordList aStopwords)
Adds a the language to the upload by comparing the stopwords.

Parameters:
upload - Upload order
aStopwords - Stopwords within this document
Returns:
true, if successful

addMetaIndexList

public boolean addMetaIndexList(int nFileID,
                                java.util.ArrayList aKeywords)
Adds a list with document-keyword-pairs to the index database.

Parameters:
nFileID - Corresponding upload
aKeywords - Corresponding keywords
Returns:
true, if successful

addQueryWord

public boolean addQueryWord(java.lang.String strWord,
                            int nUserID)
Adds a query keyword to the query database.

Parameters:
strWord - New query-keyword
nUserID - ID of user who calls search
Returns:
true, if successful

addQueryWord

public boolean addQueryWord(java.lang.String strWord,
                            double dWeight,
                            int nUserID)
Adds a query keyword to the query database.

Parameters:
strWord - New query-keyword
dWeight - Weight
nUserID - ID of user who calls search
Returns:
true, if successful

addUpload

public boolean addUpload(Upload upload)
                  throws ParsingFailedException
Extract the plaintext from a given document.

Parameters:
upload - Document, which should be parsed
Returns:
true, if successful
Throws:
ParsingFailedException - When document could not be parsed

adjustWeights

public void adjustWeights()
Adjust the weights.


convertText

public static java.lang.StringBuffer convertText(java.lang.String strPlaintext)
Remove umlaute and convert to lowercase.

Parameters:
strPlaintext - Text which should be parsed
Returns:
text with converted umlauten

deleteContent

public boolean deleteContent(int nID)
Deletes content of a file.

Parameters:
nID - ID of file
Returns:
true, if successful

deleteIndex

public boolean deleteIndex()
Delete all keywords.

Returns:
true, if successful

deleteIndex

public boolean deleteIndex(int nFileID)
Delete all keywords from a file.

Parameters:
nFileID - ID of file
Returns:
true, if successful

getIndexNum

public int getIndexNum()
Counts all index pairs.

Returns:
size of index with all pairs

getKeyword

public int getKeyword(java.lang.String strKeyword)
Get keyword.

Parameters:
strKeyword - Keyword
Returns:
id of keyword

getKeywordNum

public int getKeywordNum()
Counts all keywords.

Returns:
size of index with all keywords

getKeywords

public java.util.ArrayList getKeywords(int nUploadID,
                                       int nLimit)
Get all keywords of a given document.

Parameters:
nUploadID - ID of upload
nLimit - Limit of keywords
Returns:
list with all found records

getLastCompressionRate

public double getLastCompressionRate()
Returns the compressionrate of the last file.

Returns:
compressionrate

indexMetaInformation

public int indexMetaInformation(Upload upload)
Index metainformation of upload.

Parameters:
upload - Upload with metainformation
Returns:
number of indexed keywords

indexText

public int indexText(java.lang.StringBuffer strText,
                     Upload upload)
Remove stopwords of a string and index keywords.

Parameters:
strText - Text
upload - Upload
Returns:
number of indexed keywords

indexTextFile

public int indexTextFile(Upload upload)
Extract the plaintext from a text document.

Parameters:
upload - Upload
Returns:
number of indexed keywords

clearQuery

public boolean clearQuery(int nUserID)
Clear the querystring for request.

Parameters:
nUserID - ID of user who calls search
Returns:
true, if successful

addPreparedQueryWord

public boolean addPreparedQueryWord(java.lang.String strWord,
                                    int nBoolType,
                                    int nLanguage,
                                    int nUserID)
Prepare the querystring for request.

Parameters:
strWord - Word
nBoolType - Weight
nLanguage - Language of search
nUserID - ID of user who calls search
Returns:
true, if successfull

searchQuery

public SearchResultList searchQuery(Query query)
Prepare the querystring for request.

Specified by:
searchQuery in interface ISearchManager
Parameters:
query - Searchtext
Returns:
SearchResultList

optimize

public void optimize()
Optimize tables.


cutOffWords

public void cutOffWords(java.util.ArrayList aWords)
Remove all words with frequency 1.

Parameters:
aWords - ArrayList with words to be checked

showMessage

public void showMessage(java.lang.String strMessage)
Show a message.

Parameters:
strMessage - Message that should be displayed

showMessage

public void showMessage(java.lang.String strMessage,
                        boolean bShowTime)
Show a message.

Parameters:
strMessage - Message that should be displayed
bShowTime - Should time be displayed behind message

showMessage

public void showMessage(java.lang.String strMessage,
                        boolean bShowTime,
                        boolean bNewLine)
Show a message.

Parameters:
strMessage - Message that should be displayed
bShowTime - Should time be displayed behind message
bNewLine - Should a line break follow the text

sort

public static java.util.ArrayList sort(java.lang.String[] strList)
Sort list.

Parameters:
strList - StringList to be sorted

stemWordList

public java.util.ArrayList stemWordList(java.util.ArrayList aWords,
                                        int nLanguage)
Creates a new list with all words stemmed.

Parameters:
aWords - ArrayList with words to be stemmed
nLanguage - Language of keywords
Returns:
ArrayList with stemmed words