public class JDBCSourceAdapter extends BaseSourceAdapter
| Modifier and Type | Field and Description |
|---|---|
protected String |
descriptionAttributeName
decsription attribute name
|
static boolean |
failOnSearchForTesting
for testing if we should fail on testing
|
protected JdbcConnectionProvider |
jdbcConnectionProvider
keep a reference to the object which gets our connections for us
|
protected Integer |
maxResults
if there is a limit to the number of results
|
protected String |
nameAttributeName
name attribute name
|
static int |
queryCountforTesting
increment a query count for testing
|
protected String |
subjectIDAttributeName
subject id attribute name
|
protected String |
subjectTypeString
subject type string
|
attributes, id, internalAttributes, name, params, searchAttributes, searches, sortAttributes, type, types| Constructor and Description |
|---|
JDBCSourceAdapter()
Allocates new JDBCSourceAdapter;
|
JDBCSourceAdapter(String id1,
String name1)
Allocates new JDBCSourceAdapter;
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkConfig()
make sure the config is ok, and log descriptive errors if not
|
protected void |
closeStatement(PreparedStatement stmt) |
String |
getDatabaseType() |
String |
getDescriptionAttributeName() |
Integer |
getMaxPage()
max Page size
|
String |
getNameAttributeName() |
protected ResultSet |
getSqlResults(List<String> batchIdsOrIdentifiers,
PreparedStatement stmt,
int numParameters,
String sql)
Set the parameters in the prepared statement and execute the query.
|
protected ResultSet |
getSqlResults(String searchValue,
PreparedStatement stmt,
Search search)
Set the parameters in the prepared statement and execute the query.
|
Subject |
getSubject(String id1)
Deprecated.
|
Subject |
getSubject(String id1,
boolean exceptionIfNull)
Gets a Subject by its ID.
|
Subject |
getSubjectByIdentifier(String id1)
Deprecated.
|
Subject |
getSubjectByIdentifier(String id1,
boolean exceptionIfNull)
note, you should implement this method since this implementation will become abstract at some point
|
String |
getSubjectIDAttributeName() |
Map<String,Subject> |
getSubjectsByIdentifiers(Collection<String> identifiers)
Get subjects by identifiers.
|
Map<String,Subject> |
getSubjectsByIds(Collection<String> ids)
Get subjects by ids.
|
String |
getSubjectTypeString() |
void |
init()
Called by SourceManager when it loads this source.
|
boolean |
isChangeSearchQueryForMaxResults()
if we should change the query based on max resuuls or page
|
boolean |
isUseInClauseForIdAndIdentifier()
if we should use an in clause for id or identifier searches
|
protected Map<String,Set<String>> |
loadAttributes(ResultSet rs)
Loads attributes for the argument subject.
|
static void |
loadDriver(String sourceId,
String driver)
Loads the the JDBC driver.
|
protected PreparedStatement |
prepareStatement(Search search,
Connection conn,
boolean searchAll,
boolean firstPageOnly)
Prepare a statement handle from the search object.
|
String |
printConfig()
in the startup on this i2mi app, print helpful and brief info about this source
|
Set<Subject> |
search(String searchValue)
Unstructured search for Subjects.
|
SearchPageResult |
searchPage(String searchValue)
Unstructured search for Subjects.
|
protected void |
setupDataSource(Properties props)
DataSource connection pool setup.
|
String |
tryToChangeQuery(String query,
Connection conn,
int resultSetLimit)
try to change a paging query, note it will add one to the resultSetLimit so that
the caller can see if there are too many records
|
addAttribute, addInitParam, addInternalAttribute, addSubjectType, equals, getAttributes, getId, getInitParam, getInternalAttributes, getName, getSearch, getSearchAttributes, getSearches, getSortAttributes, getSubject, getSubjectByIdentifier, getSubjectByIdOrIdentifier, getSubjectByIdOrIdentifier, getSubjectsByIdentifiers, getSubjectsByIds, getSubjectsByIdsOrIdentifiers, getSubjectsByIdsOrIdentifiers, getSubjectStatusConfig, getSubjectType, getSubjectTypes, hashCode, initParams, loadSearch, removeInitParam, resultSetLimit, search, searchPage, setId, setName, setSearchAttributes, setSearches, setSortAttributesprotected String nameAttributeName
protected String subjectIDAttributeName
protected String descriptionAttributeName
protected String subjectTypeString
protected Integer maxResults
protected JdbcConnectionProvider jdbcConnectionProvider
public static boolean failOnSearchForTesting
public static int queryCountforTesting
public String tryToChangeQuery(String query, Connection conn, int resultSetLimit)
query - conn - resultSetLimit - public String getDatabaseType()
public boolean isChangeSearchQueryForMaxResults()
public Subject getSubject(String id1, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
getSubject in interface SourcegetSubject in class BaseSourceAdapterexceptionIfNull - if SubjectNotFoundException should be
throws if the subject is null, or if null should be returnedSubjectNotFoundExceptionSubjectNotUniqueExceptionSource.getSubject(java.lang.String, boolean)public Subject getSubjectByIdentifier(String id1, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
BaseSourceAdaptergetSubjectByIdentifier in interface SourcegetSubjectByIdentifier in class BaseSourceAdapterSubjectNotFoundExceptionSubjectNotUniqueExceptionBaseSourceAdapter.getSubjectByIdentifier(java.lang.String, boolean)public Set<Subject> search(String searchValue)
search in interface Sourcesearch in class BaseSourceAdapterpublic SearchPageResult searchPage(String searchValue)
SourcesearchPage in interface SourcesearchPage in class BaseSourceAdapterBaseSourceAdapter.searchPage(java.lang.String)protected PreparedStatement prepareStatement(Search search, Connection conn, boolean searchAll, boolean firstPageOnly) throws InvalidQueryException, SQLException
search - conn - searchAll - true if a searchAll methodfirstPageOnly - InvalidQueryExceptionSQLExceptionprotected ResultSet getSqlResults(String searchValue, PreparedStatement stmt, Search search) throws SQLException
searchValue - stmt - search - SQLExceptionprotected ResultSet getSqlResults(List<String> batchIdsOrIdentifiers, PreparedStatement stmt, int numParameters, String sql) throws SQLException
searchValue - stmt - search - SQLExceptionpublic Map<String,Subject> getSubjectsByIdentifiers(Collection<String> identifiers)
SourcegetSubjectsByIdentifiers in interface SourcegetSubjectsByIdentifiers in class BaseSourceAdapterSource.getSubjectsByIdentifiers(Collection)public Map<String,Subject> getSubjectsByIds(Collection<String> ids)
SourcegetSubjectsByIds in interface SourcegetSubjectsByIds in class BaseSourceAdapterSource.getSubjectsByIds(Collection)protected Map<String,Set<String>> loadAttributes(ResultSet rs)
rs - public void init()
throws SourceUnavailableException
init in interface Sourceinit in class BaseSourceAdapterSourceUnavailableExceptionpublic static void loadDriver(String sourceId, String driver) throws SourceUnavailableException
sourceId - driver - SourceUnavailableExceptionprotected void setupDataSource(Properties props) throws SourceUnavailableException
props - SourceUnavailableExceptionpublic Integer getMaxPage()
public boolean isUseInClauseForIdAndIdentifier()
protected void closeStatement(PreparedStatement stmt)
stmt - public String getDescriptionAttributeName()
public String getNameAttributeName()
public String getSubjectIDAttributeName()
public String getSubjectTypeString()
public void checkConfig()
SourceSource.checkConfig()public String printConfig()
SourceSource.printConfig()@Deprecated public Subject getSubject(String id1) throws SubjectNotFoundException, SubjectNotUniqueException
SourcegetSubject in interface SourcegetSubject in class BaseSourceAdapterSubjectNotFoundExceptionSubjectNotUniqueExceptionBaseSourceAdapter.getSubject(java.lang.String)@Deprecated public Subject getSubjectByIdentifier(String id1) throws SubjectNotFoundException, SubjectNotUniqueException
SourcegetSubjectByIdentifier in interface SourcegetSubjectByIdentifier in class BaseSourceAdapterSubjectNotFoundExceptionSubjectNotUniqueExceptionBaseSourceAdapter.getSubjectByIdentifier(java.lang.String)Copyright © 2016 Internet2. All rights reserved.