Package org.languagetool.server
Class DatabaseAccess
java.lang.Object
org.languagetool.server.DatabaseAccess
- Direct Known Subclasses:
DatabaseAccessOpenSource
Encapsulate database access. Will do nothing if database access is not configured.
- Since:
- 4.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static DatabaseAccessprotected org.apache.ibatis.session.SqlSessionFactory -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDatabaseAccess(HTTPServerConfig config) Implementations required to provide a constructor with the same signature -
Method Summary
Modifier and TypeMethodDescription(package private) abstract boolean(package private) abstract voidaddWordBatch(List<String> words, Long userId, String groupName) add words in sql batch mode, no auto commit for better performance with large lists also suppresses uniqueness checksvoidFor unit tests only!voidcreateAndFillTestTables(boolean mysql) For unit tests only!abstract voidcreateAndFillTestTables(boolean mysql, List<String> skipStatements) For unit tests only!(package private) abstract voidFor unit tests only!(package private) abstract booleandeleteWord(String word, Long userId, String groupName) (package private) abstract booleandeleteWordBatch(List<String> words, Long userId, String groupName) remove words in sql batch mode, no auto commit for better performance with large lists also suppresses uniqueness checks(package private) voidexecute(org.apache.ibatis.jdbc.SQL sql) For unit tests only!(package private) ResultSetexecuteStatement(org.apache.ibatis.jdbc.SQL sql) For unit tests only!(package private) abstract List<DictGroupEntry> getDictGroups(Long userId) get all dictionary groups belonging to a user(package private) abstract ExtendedUserInfogetExtendedUserInfo(long userId) Get more general information on a user.(package private) abstract ExtendedUserInfogetExtendedUserInfo(String user) Get more general information on a user Expects access to already be authorized(package private) static DatabaseAccess(package private) abstract LonggetOrCreateClientId(String client) (package private) abstract LonggetOrCreateDictGroup(Long userId, String groupName) get or create a group with this name if it doesn't exist(package private) abstract LonggetRules(UserLimits limits, Language lang, List<String> groups) (package private) abstract UserInfoEntrygetUserInfoWithAddonToken(String username, String apiKey) (package private) abstract UserInfoEntrygetUserInfoWithApiKey(String username, String apiKey) (package private) abstract UserInfoEntrygetUserInfoWithPassword(String username, String password) (package private) abstract LonggetUserRequestCount(Long userId) getWords(UserLimits limits, List<String> groups, int offset, int limit) (package private) static voidinit(HTTPServerConfig config) (package private) abstract voidFor tests, to avoid waiting for the invalidation period.(package private) abstract void(package private) static booleanisReady()(package private) static voidreset()voidFor unit tests only!
-
Field Details
-
instance
-
sqlSessionFactory
protected org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory
-
-
Constructor Details
-
DatabaseAccess
Implementations required to provide a constructor with the same signature
-
-
Method Details
-
init
-
reset
static void reset() -
getInstance
-
isReady
static boolean isReady()- Since:
- 5.7 Test if instance is configured and can be used
-
invalidateCaches
abstract void invalidateCaches()For tests, to avoid waiting for the invalidation period. -
addWord
-
deleteWord
-
deleteWordBatch
remove words in sql batch mode, no auto commit for better performance with large lists also suppresses uniqueness checks -
addWordBatch
add words in sql batch mode, no auto commit for better performance with large lists also suppresses uniqueness checks -
getUserInfoWithPassword
-
getExtendedUserInfo
Get more general information on a user Expects access to already be authorized- Parameters:
user- email address of user- Returns:
- POJO with user information
-
getExtendedUserInfo
Get more general information on a user. Expects access to already be authorized.- Parameters:
userId- user id- Returns:
- POJO with more user information
-
getUserInfoWithApiKey
-
getUserInfoWithAddonToken
-
invalidateUserInfoCache
-
getUserRequestCount
-
getOrCreateServerId
-
getOrCreateClientId
-
getDictGroups
get all dictionary groups belonging to a user -
getOrCreateDictGroup
get or create a group with this name if it doesn't exist- Returns:
- id of the created/existing group
-
createAndFillTestTables
public void createAndFillTestTables()For unit tests only! -
createAndFillTestTables
public void createAndFillTestTables(boolean mysql) For unit tests only! -
createAndFillTestTables
For unit tests only! -
shutdownCompact
public void shutdownCompact()For unit tests only! -
deleteTestTables
abstract void deleteTestTables()For unit tests only! -
executeStatement
For unit tests only!- Throws:
SQLException
-
execute
For unit tests only!- Throws:
SQLException
-
getWords
public abstract List<String> getWords(UserLimits limits, List<String> groups, int offset, int limit) - Parameters:
limits- user account and settings for e.g. cachinggroups- names of dictionaries to be fetched, or null for default dictionaryoffset- use offset with limit for an ordered list of words in the dictionary, or RowBounds.NO_ROW_OFFSETlimit- use limit with offset for an ordered list of words in the dictionary, or use RowBounds.NO_ROW_LIMIT- Returns:
- a list of words from the user's dictionary (complete, or from the given range)
-
getRules
public abstract List<Rule> getRules(UserLimits limits, Language lang, @Nullable List<String> groups) - Parameters:
limits- user account and settings for e.g. cachinglang- language of rules to fetch; fetches global rules and language-specific rules for that languagegroups- names of groups of rules to be fetched, or null for default set of rules- Returns:
- a list of user rules (complete, or from the given range)
-