|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.utils.db.hibernate.HibernatePersistenceManager edu.northwestern.at.wordhoard.model.PersistenceManager
public class PersistenceManager
WordHoard persistence manager.
The "getxxx" and "findxxx" methods fetch objects and collections of objects by various criteria. They are implemented using Hibernate queries, which in turn become SQL select statements.
Field Summary |
---|
Fields inherited from class edu.northwestern.at.utils.db.hibernate.HibernatePersistenceManager |
---|
JDBC_BATCH_SIZE, session, sessionFactory, stackTracesEnabled, t, threadPM |
Constructor Summary | |
---|---|
PersistenceManager()
Creates a new persistence manager. |
Method Summary | |
---|---|
java.lang.Object |
clone(PersistentObject obj)
Clones an object. |
static void |
closePM()
Close persistence manager for the current thread. |
java.util.Collection |
findAuthorsByNamePrefix(java.lang.String prefix)
Finds authors by name prefix. |
java.util.Collection |
findLemmasByTagPrefix(java.lang.String prefix,
Corpus corpus)
Finds lemmas by tag prefix. |
java.util.Collection |
findSpeakerNamesbyPrefix(java.lang.String prefix,
Corpus corpus)
Finds speaker names by prefix. |
Word |
findWord(WorkPart workPart,
int lineIndex,
int startOffset,
int endOffset)
Finds a word in a work part. |
static java.lang.StringBuffer |
generateInPhrase(java.lang.String objectName,
java.util.Collection objects)
Generates "item in (:items)" query phrase. |
static java.lang.StringBuffer |
generateInPhrase(java.lang.String objectName,
PersistentObject[] objects)
Generates "item in (:items)" query phrase. |
static java.lang.StringBuffer |
generateInPhrase2(java.lang.String objectName,
java.util.Collection objects)
Generates "item in (:items)" query phrase. |
java.util.Collection |
getAllAuthors()
Gets all the authors. |
java.util.Collection |
getAllAuthors(Corpus corpus)
Gets all the authors. |
java.util.Collection |
getAllCorpora()
Gets all the corpora. |
java.util.Collection |
getAllLemmas()
Gets all the lemmas. |
java.util.Collection |
getAllLemPos()
Gets all the LemPos objects. |
java.util.Collection |
getAllMajorWordClasses()
Gets all the major word classes. |
java.util.Collection |
getAllMetricalShapes()
Gets all the metrical shapes. |
java.util.Collection |
getAllPos()
Gets all the parts of speech. |
java.util.Collection |
getAllWordClasses()
Gets all the word classes. |
java.util.Collection |
getAllWorkParts()
Gets all the work parts. |
java.util.Collection |
getAllWorks()
Gets all the works. |
AnnotationCategory |
getAnnotationCategoryByName(java.lang.String name)
Gets an annotation category by name. |
java.util.Collection |
getAnnotationsForWorkPart(WorkPart workPart)
Gets the annotations for a work part. |
Author |
getAuthorByName(java.lang.String name)
Gets an author by name. |
java.util.Collection |
getColocates(java.util.Collection words,
int distance)
Gets colocates for a collection of words. |
Corpus |
getCorpusByTag(java.lang.String tag)
Gets a corpus by tag. |
Lemma |
getLemmaByTag(java.lang.String tag)
Gets a lemma by tag. |
LemmaCorpusCounts |
getLemmaCorpusCounts(Lemma lemma,
Corpus corpus)
Gets lemma/corpus counts. |
java.util.Collection |
getLemmaPosSpellingCounts(Lemma lemma,
Corpus corpus)
Gets lemma/pos/spelling counts. |
LemmaWorkCounts |
getLemmaWorkCounts(Lemma lemma,
Work work)
Gets lemma/work counts. |
java.util.Collection |
getLexicon(Corpus corpus)
Gets the lexicon for a corpus. |
Line |
getLineByTag(java.lang.String tag)
Gets a line by tag. |
java.util.Collection |
getLinesInWork(Work work)
Gets the lines in a work. |
java.util.Collection |
getLinesInWorkPart(WorkPart workPart)
Gets the lines in a work part. |
static PersistenceManager |
getPM()
Gets a persistence manager for the current thread. |
Word |
getWordByTag(java.lang.String tag)
Gets a word by tag. |
java.util.Collection |
getWordsInWork(Work work)
Gets the words in a work. |
java.util.Collection |
getWordsInWorkPart(WorkPart workPart)
Gets the words in a work part. |
java.util.Collection |
getWordsInWorkPartWithPreloading(WorkPart workPart)
Gets the words in a work part with preloading. |
WorkPart |
getWorkPartByTag(java.lang.String tag)
Gets a work part by tag. |
java.util.Collection |
getWorkParts(Work work)
Gets all the work parts for a work. |
WorkPart[] |
getWorkPartsByTag(java.util.Collection tags)
Gets work parts by their tags. |
static void |
init(boolean cache2)
Initializes Hibernate for WordHoard using default properties file. |
static void |
init(java.lang.String url,
java.lang.String username,
java.lang.String password,
boolean cache2)
Initializes Hibernate for WordHoard using specified parameters. |
void |
preloadAdjacentInfo(java.util.Collection words,
boolean preceding)
Preloads adjacent words information. |
void |
preloadConcordanceInfo(java.util.Collection words)
Preloads concordance information. |
java.util.List |
searchLemmata(SearchCriteriaLemmaSearch sq)
Searches for lemmmata. |
java.util.List |
searchWords(SearchCriteria sq)
Searches for words. |
java.util.List |
searchWorks(SearchWorkCriteria sq)
Searches for works. |
Methods inherited from class edu.northwestern.at.utils.db.hibernate.HibernatePersistenceManager |
---|
begin, clear, close, closePM, commit, contains, countQuery, delete, delete, deleteViaQuery, deleteViaQuery, deleteViaSQL, doClear, doContains, doCountQuery, doDelete, doDelete, doEvict, doEvict, doGet, doInsertViaSQL, doLoad, doQuery, doQuery, doQuery, doQuery, doQuery, doQuery, doRefresh, doSave, doSave, doScrollableQuery, doScrollableQuery, doScrollableQuery, doScrollableQuery, doScrollableQuery, doUpdate, doUpdate, enableStackTraces, evict, evict, flush, get, getBatchSize, getConnection, getConnectionProvider, getHPM, getSession, init, init, init, init, insertViaSQL, load, performBatchInserts, query, query, query, query, query, refresh, rollback, save, save, scrollableQuery, scrollableQuery, scrollableQuery, scrollableQuery, scrollableQuery, setQueryParams, update, update |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PersistenceManager() throws PersistenceException
PersistenceException
Method Detail |
---|
public static void init(boolean cache2) throws PersistenceException
cache2
- True to enable second-level cache.
PersistenceException
public static void init(java.lang.String url, java.lang.String username, java.lang.String password, boolean cache2) throws PersistenceException
url
- URL for MySQL database, or null to use the
"hibernate.properties" file for setting
the Hibernate parameters.username
- Username for MySQL database access. Ignored
if url = null.password
- Password for MySQL database access. Ignored
if url = null.cache2
- True to enable second-level cache.
PersistenceException
public static PersistenceManager getPM() throws PersistenceException
PersistenceException
public static void closePM()
public java.lang.Object clone(PersistentObject obj) throws PersistenceException
Loads a new copy of a persistent object in this persistence manager.
obj
- Persistent object.
PersistenceException
public java.util.Collection getAllCorpora() throws PersistenceException
In addition to loading and returning all the corpora, all the works, table of contents views, authors, and work child parts are preloaded.
PersistenceException
public java.util.Collection getAllWorkParts() throws PersistenceException
PersistenceException
public java.util.Collection getWorkParts(Work work) throws PersistenceException
work
- Work.
PersistenceException
public java.util.Collection getAllWorks() throws PersistenceException
PersistenceException
public java.util.Collection getAllAuthors() throws PersistenceException
PersistenceException
public java.util.Collection getAllAuthors(Corpus corpus) throws PersistenceException
corpus
- Corpus, or null.
PersistenceException
public java.util.Collection getAllPos() throws PersistenceException
PersistenceException
public java.util.Collection getAllWordClasses() throws PersistenceException
PersistenceException
public java.util.Collection getAllLemmas() throws PersistenceException
PersistenceException
public java.util.Collection getAllLemPos() throws PersistenceException
PersistenceException
public java.util.Collection getAllMajorWordClasses() throws PersistenceException
PersistenceException
public java.util.Collection getAllMetricalShapes() throws PersistenceException
PersistenceException
public Corpus getCorpusByTag(java.lang.String tag) throws PersistenceException
tag
- Corpus tag.
PersistenceException
public Word getWordByTag(java.lang.String tag) throws PersistenceException
tag
- tag.
PersistenceException
public WorkPart getWorkPartByTag(java.lang.String tag) throws PersistenceException
tag
- tag.
PersistenceException
public WorkPart[] getWorkPartsByTag(java.util.Collection tags) throws PersistenceException
tags
- Collection of work part tags.
PersistenceException
public Lemma getLemmaByTag(java.lang.String tag) throws PersistenceException
tag
- tag.
PersistenceException
public Line getLineByTag(java.lang.String tag) throws PersistenceException
tag
- tag.
PersistenceException
public Author getAuthorByName(java.lang.String name) throws PersistenceException
name
- English name.
PersistenceException
public AnnotationCategory getAnnotationCategoryByName(java.lang.String name) throws PersistenceException
name
- Catgegory name.
PersistenceException
public java.util.Collection getWordsInWorkPart(WorkPart workPart) throws PersistenceException
workPart
- Work part.
words
for this work part.
PersistenceException
public java.util.Collection getWordsInWorkPartWithPreloading(WorkPart workPart) throws PersistenceException
All related morphology and speech objects are preloaded.
workPart
- Work part.
words
for this work part.
PersistenceException
public java.util.Collection getLinesInWorkPart(WorkPart workPart) throws PersistenceException
workPart
- Work part.
lines
in the work part.
PersistenceException
public java.util.Collection getLinesInWork(Work work) throws PersistenceException
work
- Work.
lines
in the work.
PersistenceException
public java.util.Collection getWordsInWork(Work work) throws PersistenceException
work
- Work.
words
in the work.
PersistenceException
public java.util.Collection getAnnotationsForWorkPart(WorkPart workPart) throws PersistenceException
workPart
- Work part.
text annotations
for the work part.
PersistenceException
public LemmaWorkCounts getLemmaWorkCounts(Lemma lemma, Work work) throws PersistenceException
lemma
- Lemma.work
- Work.
PersistenceException
public LemmaCorpusCounts getLemmaCorpusCounts(Lemma lemma, Corpus corpus) throws PersistenceException
lemma
- Lemma.corpus
- Corpus.
PersistenceException
public java.util.Collection getLexicon(Corpus corpus) throws PersistenceException
corpus
- Corpus.
PersistenceException
public java.util.Collection getLemmaPosSpellingCounts(Lemma lemma, Corpus corpus) throws PersistenceException
lemma
- Lemma.corpus
- Corpus.
PersistenceException
public Word findWord(WorkPart workPart, int lineIndex, int startOffset, int endOffset) throws PersistenceException
workPart
- Work part.lineIndex
- Index of line containing word.startOffset
- Starting offset of word in line.endOffset
- Ending offset of word in line.
PersistenceException
public java.util.Collection findLemmasByTagPrefix(java.lang.String prefix, Corpus corpus) throws PersistenceException
prefix
- Tag prefix.corpus
- Corpus, or null.
lemmas
which have tags that start with the prefix string,
in case-insenstive increasing alphabetical order by tag.
If the corpus argument is not null, the collection is
limited to lemmas in the specified corpus.
PersistenceException
public java.util.Collection findSpeakerNamesbyPrefix(java.lang.String prefix, Corpus corpus) throws PersistenceException
prefix
- Speaker name prefix.corpus
- Corpus, or null.
PersistenceException
public java.util.Collection findAuthorsByNamePrefix(java.lang.String prefix) throws PersistenceException
prefix
- name prefix.
authors
which have name that start with the prefix string,
ordered by name.
PersistenceException
public java.util.Collection getColocates(java.util.Collection words, int distance) throws PersistenceException
words
- Collection of words.distance
- Max distance.
words
which are within "distance" words
of one of the specified words.
PersistenceException
public void preloadConcordanceInfo(java.util.Collection words) throws PersistenceException
This method is a performance optimization for concordance displays. Given a collection of words, we preload all the related objects for the words that might be needed in a concordance display.
words
- Collection of words.
PersistenceException
public void preloadAdjacentInfo(java.util.Collection words, boolean preceding) throws PersistenceException
This method is a performance optimization for the concordance grouping options for preceding word forms and following word forms. Given a collection of words, we preload all the adjacent word objects and their word part, lempos, lemma, and pos objects.
words
- Collection of words.preceding
- True to preload objects for adjacent words,
false for following words.
PersistenceException
public java.util.List searchLemmata(SearchCriteriaLemmaSearch sq) throws PersistenceException
sq
- Search criteria.
search results
which match the search criteria,
PersistenceException
public java.util.List searchWords(SearchCriteria sq) throws PersistenceException
sq
- Search criteria.
search results
which match the search criteria,
ordered by location (by work tag, then by ordinal
within work).
PersistenceException
public java.util.List searchWorks(SearchWorkCriteria sq) throws PersistenceException
sq
- Work search criteria.
works
which match the search criteria,
ordered by full title.
PersistenceException
public static java.lang.StringBuffer generateInPhrase(java.lang.String objectName, PersistentObject[] objects)
objectName
- The name of the object.objects
- Array of PersistentObject objects.
Hibernate exhibits extremely poor performance when asked to create a where clause phrase of the form:
object in (:objects)
For example, when "items" is an array of the 29,350 Word objects for the words in Hamlet, and all the Word objects are already loaded, creating the simple query "from Word where word in (:words)" takes nearly eight minutes on a 2.5 Ghz Pentium system. Note: this is not the execution time for the query, just the time to construct the query.
This method takes a parameter name, e.g., "word", and an array of PersistentObject objects, e.g., "words", and generates the correponding HQL "where" clause phrase for "word in (:words)" by expanding this to "word.id in (id1, id2, id3 ... )". This process only a fraction of a second for the Hamlet example.
public static java.lang.StringBuffer generateInPhrase(java.lang.String objectName, java.util.Collection objects)
objectName
- The name of the object.objects
- Collection of PersistentObject objects.
Hibernate exhibits extremely poor performance when asked to create a where clause phrase of the form:
object in (:objects)
For example, when "items" is a collection of the 29,350 Word objects for the words in Hamlet, and all the Word objects are already loaded, creating the simple query "from Word where word in (:words)" takes nearly eight minutes on a 2.5 Ghz Pentium system. Note: this is not the execution time for the query, just the time to construct the query.
This method takes a parameter name, e.g., "word", and a collection of PersistentObject objects, e.g., "words", and generates the correponding HQL "where" clause phrase for "word in (:words)" by expanding this to "word.id in (id1, id2, id3 ... )". This process only a fraction of a second for the Hamlet example.
public static java.lang.StringBuffer generateInPhrase2(java.lang.String objectName, java.util.Collection objects)
objectName
- The name of the object.objects
- Collection of String objects.
This method takes a parameter name, e.g., "word.tag", and a collection of objects with toString() methods, e.g., "wordTags", and generates the correponding HQL "where" clause phrase for "word.tag in (:wordTags)",
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |