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, setSortAttributes
protected 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 Source
getSubject
in class BaseSourceAdapter
exceptionIfNull
- if SubjectNotFoundException should be
throws if the subject is null, or if null should be returnedSubjectNotFoundException
SubjectNotUniqueException
Source.getSubject(java.lang.String, boolean)
public Subject getSubjectByIdentifier(String id1, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException
BaseSourceAdapter
getSubjectByIdentifier
in interface Source
getSubjectByIdentifier
in class BaseSourceAdapter
SubjectNotFoundException
SubjectNotUniqueException
BaseSourceAdapter.getSubjectByIdentifier(java.lang.String, boolean)
public Set<Subject> search(String searchValue)
search
in interface Source
search
in class BaseSourceAdapter
public SearchPageResult searchPage(String searchValue)
Source
searchPage
in interface Source
searchPage
in class BaseSourceAdapter
BaseSourceAdapter.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
- InvalidQueryException
SQLException
protected ResultSet getSqlResults(String searchValue, PreparedStatement stmt, Search search) throws SQLException
searchValue
- stmt
- search
- SQLException
protected ResultSet getSqlResults(List<String> batchIdsOrIdentifiers, PreparedStatement stmt, int numParameters, String sql) throws SQLException
searchValue
- stmt
- search
- SQLException
public Map<String,Subject> getSubjectsByIdentifiers(Collection<String> identifiers)
Source
getSubjectsByIdentifiers
in interface Source
getSubjectsByIdentifiers
in class BaseSourceAdapter
Source.getSubjectsByIdentifiers(Collection)
public Map<String,Subject> getSubjectsByIds(Collection<String> ids)
Source
getSubjectsByIds
in interface Source
getSubjectsByIds
in class BaseSourceAdapter
Source.getSubjectsByIds(Collection)
protected Map<String,Set<String>> loadAttributes(ResultSet rs)
rs
- public void init() throws SourceUnavailableException
init
in interface Source
init
in class BaseSourceAdapter
SourceUnavailableException
public static void loadDriver(String sourceId, String driver) throws SourceUnavailableException
sourceId
- driver
- SourceUnavailableException
protected void setupDataSource(Properties props) throws SourceUnavailableException
props
- SourceUnavailableException
public 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()
Source
Source.checkConfig()
public String printConfig()
Source
Source.printConfig()
@Deprecated public Subject getSubject(String id1) throws SubjectNotFoundException, SubjectNotUniqueException
Source
getSubject
in interface Source
getSubject
in class BaseSourceAdapter
SubjectNotFoundException
SubjectNotUniqueException
BaseSourceAdapter.getSubject(java.lang.String)
@Deprecated public Subject getSubjectByIdentifier(String id1) throws SubjectNotFoundException, SubjectNotUniqueException
Source
getSubjectByIdentifier
in interface Source
getSubjectByIdentifier
in class BaseSourceAdapter
SubjectNotFoundException
SubjectNotUniqueException
BaseSourceAdapter.getSubjectByIdentifier(java.lang.String)
Copyright © 2016 Internet2. All rights reserved.