Class JDBCSourceAdapter2
java.lang.Object
edu.internet2.middleware.subject.provider.BaseSourceAdapter
edu.internet2.middleware.subject.provider.JDBCSourceAdapter
edu.internet2.middleware.subject.provider.JDBCSourceAdapter2
- All Implemented Interfaces:
Source
- Direct Known Subclasses:
GrouperJdbcSourceAdapter2_5
,HelperGrouperJdbcSourceAdapter2
jdbc source adapter based on one table with more complex searches
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
table or view where each row is a subject <param-name>dbTableOrView</param-name>protected String
search queries will sort by this.protected String
col for subject description <param-name>descriptionCol</param-name>protected String
for searches (not by id or identifier), this is the col which holds the search terms, in lower case <param-name>lowerSearchCol</param-name>protected String
column which holds the subject name <param-name>nameCol</param-name>cols which are selected in queriesprotected String
column which holds the subject id <param-name>subjectIdCol</param-name>cols which are used in a findByIdentifier query <param-name>subjectIdentifierCol0</param-name>Fields inherited from class edu.internet2.middleware.subject.provider.JDBCSourceAdapter
errorOnMaxResults, failOnSearchForTesting, jdbcConnectionProvider, maxResults, queryCountforTesting, subjectIDAttributeName, subjectTypeString
Fields inherited from class edu.internet2.middleware.subject.provider.BaseSourceAdapter
attributes, descriptionAttributeName, id, internalAttributes, name, nameAttributeName, params, searchAttributes, searches, sortAttributes, subjectIdentifierAttributes, subjectIdentifierAttributesAll, type, types
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
make sure the config is ok, and log descriptive errors if notprotected Subject
createSubject
(ResultSet resultSet, String query, Collection<String> identifiersForIdentifierToMap, Map<String, Subject> resultIdentifierToSubject) Create a subject from the current row in the resultSetprotected String
get the db table or view, considering realmtable or view where each row is a subject <param-name>dbTableOrView</param-name>search queries will sort by this.for searches (not by id or identifier), this is the col which holds the search terms, in lower case <param-name>lowerSearchCol</param-name>column which holds the subject name <param-name>nameCol</param-name>getSubject
(String id1, boolean exceptionIfNull) Gets a Subject by its ID.getSubject
(String id1, boolean exceptionIfNull, String realm) Gets a Subject by its ID.map of col to attribute name //<param-name>subjectAttributeCol0</param-name> //<param-name>subjectAttributeName0</param-name>getSubjectByIdentifier
(String identifier, boolean exceptionIfNull) note, you should implement this method since this implementation will become abstract at some pointgetSubjectByIdentifier
(String identifier, boolean exceptionIfNull, String realm) Gets a Subject by other well-known identifiers, aside from the subject ID, for example, login ID.getSubjectByIdOrIdentifier
(String idOrIdentifier, boolean exceptionIfNull) find by id or identifiergetSubjectByIdOrIdentifier
(String idOrIdentifier, boolean exceptionIfNull, String realm) find by id or identifier.column which holds the subject id <param-name>subjectIdCol</param-name>Get the names of attributes that are subject identifiers.Get all the names of attributes that are subject identifiers.cols which are used in a findByIdentifier query <param-name>subjectIdentifierCol0</param-name>getSubjectsByIdentifiers
(Collection<String> identifiers) Get subjects by identifiers.getSubjectsByIdentifiers
(Collection<String> identifiers, String realm) Get subjects by identifiers.getSubjectsByIds
(Collection<String> ids) Get subjects by ids.getSubjectsByIds
(Collection<String> ids, String realm) Get subjects by ids.getSubjectsByIdsOrIdentifiers
(Collection<String> idsOrIdentifiers) Get subjects by ids or identifiers.getSubjectsByIdsOrIdentifiers
(Collection<String> idsOrIdentifiers, String realm) Get subjects by ids or identifiers.loadAttributes
(ResultSet resultSet, String query, ResultSetMetaData resultSetMetaData) Loads attributes for the argument subject.get all subject idsprotected String
retrieveString
(ResultSet resultSet, String name, String varName, String query, ResultSetMetaData resultSetMetaData) retrieve a param from resultsetUnstructured search for Subjects.Unstructured search for Subjects.searchPage
(String searchValue) Unstructured search for Subjects.searchPage
(String searchValue, String realm) Unstructured search for Subjects.void
setDbTableOrView
(String dbTableOrView1) table or view where each row is a subject <param-name>dbTableOrView</param-name>void
setDefaultSortCol
(String defaultSortCol1) search queries will sort by this.void
setDescriptionCol
(String descriptionCol1) void
setLowerSearchCol
(String lowerSearchCol1) for searches (not by id or identifier), this is the col which holds the search terms, in lower case <param-name>lowerSearchCol</param-name>void
setNameCol
(String nameCol1) column which holds the subject name <param-name>nameCol</param-name>void
setSubjectAttributeColToName
(Map<String, String> subjectAttributeColToName1) map of col to attribute name //<param-name>subjectAttributeCol0</param-name> //<param-name>subjectAttributeName0</param-name>void
setSubjectIdCol
(String subjectIdCol1) column which holds the subject id <param-name>subjectIdCol</param-name>void
setSubjectIdentifierCols
(Set<String> subjectIdentifierCols1) cols which are used in a findByIdentifier query <param-name>subjectIdentifierCol0</param-name>protected void
setupDataSource
(Properties props) DataSource connection pool setup.Methods inherited from class edu.internet2.middleware.subject.provider.JDBCSourceAdapter
closeStatement, getDatabaseType, getDescriptionAttributeName, getMaxPage, getNameAttributeName, getSqlResults, getSqlResults, getSubject, getSubjectByIdentifier, getSubjectIDAttributeName, getSubjectTypeString, init, isChangeSearchQueryForMaxResults, isUseInClauseForIdAndIdentifier, loadAttributes, loadDriver, loggingStart, loggingStop, prepareStatement, printConfig, tryToChangeQuery
Methods inherited from class edu.internet2.middleware.subject.provider.BaseSourceAdapter
addAttribute, addInitParam, addInternalAttribute, addSubjectType, attributeNameToViewerGroupName, convertSourceAttributeToSubjectAttribute, convertSubjectAttributeToSourceAttribute, createSubject, equals, exportLabelToAttributeName, getAttributes, getConfigId, getId, getInitParam, getInternalAttributes, getName, getSearch, getSearchAttributes, getSearches, getSortAttributes, getSourceAttributesToLowerCase, getSubjectStatusConfig, getSubjectType, getSubjectTypes, hashCode, initParams, isEditable, isEnabled, loadSearch, removeInitParam, resultSetLimit, setConfigId, setId, setName, setSearchAttributes, setSearches, setSortAttributes, setSubjectIdentifierAttributes, setSubjectIdentifierAttributesAll, virtualAttributesForSource, virtualAttributesForSourceLegacy, virtualAttributeVariablesForSourceLegacy
-
Field Details
-
dbTableOrView
table or view where each row is a subject <param-name>dbTableOrView</param-name> -
subjectIdCol
column which holds the subject id <param-name>subjectIdCol</param-name> -
nameCol
column which holds the subject name <param-name>nameCol</param-name> -
descriptionCol
col for subject description <param-name>descriptionCol</param-name> -
lowerSearchCol
for searches (not by id or identifier), this is the col which holds the search terms, in lower case <param-name>lowerSearchCol</param-name> -
defaultSortCol
search queries will sort by this. Note it might be overridden by caller, e.g. UI <param-name>defaultSortCol</param-name> -
subjectIdentifierCols
cols which are used in a findByIdentifier query <param-name>subjectIdentifierCol0</param-name> -
selectCols
cols which are selected in queries
-
-
Constructor Details
-
JDBCSourceAdapter2
public JDBCSourceAdapter2() -
JDBCSourceAdapter2
- Parameters:
id
-name
-
-
-
Method Details
-
checkConfig
public void checkConfig()Description copied from interface:Source
make sure the config is ok, and log descriptive errors if not- Specified by:
checkConfig
in interfaceSource
- Overrides:
checkConfig
in classJDBCSourceAdapter
- See Also:
-
getSubject
public Subject getSubject(String id1, boolean exceptionIfNull, String realm) throws SubjectNotFoundException, SubjectNotUniqueException Description copied from interface:Source
Gets a Subject by its ID.- Specified by:
getSubject
in interfaceSource
- Overrides:
getSubject
in classBaseSourceAdapter
exceptionIfNull
- if SubjectNotFoundException should be throws if the subject is null, or if null should be returnedrealm
- string value that sets the realm for the search. The source can implement various realms to account for permissions of the calling user- Returns:
- subject
- Throws:
SubjectNotFoundException
SubjectNotUniqueException
- See Also:
-
getSubjectByIdentifier
public Subject getSubjectByIdentifier(String identifier, boolean exceptionIfNull, String realm) throws SubjectNotFoundException, SubjectNotUniqueException Description copied from interface:Source
Gets a Subject by other well-known identifiers, aside from the subject ID, for example, login ID.- Specified by:
getSubjectByIdentifier
in interfaceSource
- Overrides:
getSubjectByIdentifier
in classBaseSourceAdapter
realm
- string value that sets the realm for the search. The source can implement various realms to account for permissions of the calling user- Returns:
- subject
- Throws:
SubjectNotFoundException
SubjectNotUniqueException
- See Also:
-
getSubjectByIdOrIdentifier
public Subject getSubjectByIdOrIdentifier(String idOrIdentifier, boolean exceptionIfNull, String realm) throws SubjectNotFoundException, SubjectNotUniqueException Description copied from interface:Source
find by id or identifier. pass in either an id or an identifier- Specified by:
getSubjectByIdOrIdentifier
in interfaceSource
- Overrides:
getSubjectByIdOrIdentifier
in classBaseSourceAdapter
exceptionIfNull
- if SubjectNotFoundException or nullrealm
- string value that sets the realm for the search. The source can implement various realms to account for permissions of the calling user- Returns:
- the subject
- Throws:
SubjectNotFoundException
SubjectNotUniqueException
- See Also:
-
getSubjectByIdOrIdentifier
public Subject getSubjectByIdOrIdentifier(String idOrIdentifier, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException Description copied from class:BaseSourceAdapter
find by id or identifier- Specified by:
getSubjectByIdOrIdentifier
in interfaceSource
- Overrides:
getSubjectByIdOrIdentifier
in classBaseSourceAdapter
exceptionIfNull
- if SubjectNotFoundException or null- Returns:
- the subject
- Throws:
SubjectNotFoundException
SubjectNotUniqueException
- See Also:
-
getSubjectsByIdentifiers
Description copied from interface:Source
Get subjects by identifiers. Note, if the subjects arent found or arent unique, they wont be returned. Identifiers are unique ways to refer to a subject that isnt its id (e.g. netid). Duplicates are ok on the input, but will return one output.- Specified by:
getSubjectsByIdentifiers
in interfaceSource
- Overrides:
getSubjectsByIdentifiers
in classBaseSourceAdapter
realm
- string value that sets the realm for the search. The source can implement various realms to account for permissions of the calling user- Returns:
- a map of results never null indexed by the identifiers
- See Also:
-
retrieveAllSubjectIds
Description copied from interface:Source
get all subject ids- Specified by:
retrieveAllSubjectIds
in interfaceSource
- Overrides:
retrieveAllSubjectIds
in classJDBCSourceAdapter
- Returns:
- all subjectIds
- See Also:
-
getSubjectsByIds
Description copied from interface:Source
Get subjects by ids. Note, if the subjects arent found or arent unique, they wont be returned. Duplicates are ok on the input, but will return one output.- Specified by:
getSubjectsByIds
in interfaceSource
- Overrides:
getSubjectsByIds
in classBaseSourceAdapter
realm
- string value that sets the realm for the search. The source can implement various realms to account for permissions of the calling user- Returns:
- a map of results never null indexed by the id
- See Also:
-
getSubjectsByIdsOrIdentifiers
public Map<String,Subject> getSubjectsByIdsOrIdentifiers(Collection<String> idsOrIdentifiers, String realm) Description copied from interface:Source
Get subjects by ids or identifiers. Note, if the subjects arent found or arent unique, they wont be returned. Identifiers are unique ways to refer to a subject that isnt its id (e.g. netid). Duplicates are ok on the input, but will return one output.- Specified by:
getSubjectsByIdsOrIdentifiers
in interfaceSource
- Overrides:
getSubjectsByIdsOrIdentifiers
in classBaseSourceAdapter
- Parameters:
idsOrIdentifiers
- each string could be a subject id or identifierrealm
- string value that sets the realm for the search. The source can implement various realms to account for permissions of the calling user- Returns:
- a map of results never null indexed by the id or identifier that was passed in. Note, the same subject could be returned twice if looked up by id and identifier (two inputs)
- See Also:
-
getSubjectsByIdsOrIdentifiers
Description copied from interface:Source
Get subjects by ids or identifiers. Note, if the subjects arent found or arent unique, they wont be returned. Identifiers are unique ways to refer to a subject that isnt its id (e.g. netid). Duplicates are ok on the input, but will return one output.- Specified by:
getSubjectsByIdsOrIdentifiers
in interfaceSource
- Overrides:
getSubjectsByIdsOrIdentifiers
in classBaseSourceAdapter
- Parameters:
idsOrIdentifiers
- each string could be a subject id or identifier- Returns:
- a map of results never null indexed by the id or identifier that was passed in. Note, the same subject could be returned twice if looked up by id and identifier (two inputs)
- See Also:
-
search
Description copied from interface:Source
Unstructured search for Subjects. Each implementation utilizes its own search algorithm tailored to the Subject repository and schema. Note if config param: throwErrorOnFindAllFailure is false, then swallow and log exceptions- Specified by:
search
in interfaceSource
- Overrides:
search
in classBaseSourceAdapter
realm
- string value that sets the realm for the search. The source can implement various realms to account for permissions of the calling user- Returns:
- set
- See Also:
-
searchPage
Description copied from interface:Source
Unstructured search for Subjects. Each implementation utilizes its own search algorithm tailored to the Subject repository and schema. Note if config param: throwErrorOnFindAllFailure is false, then swallow and log exceptions if maxPageSize is set in subject.properties, then only return max that many, and if there are more, set the tooManyResults flag- Specified by:
searchPage
in interfaceSource
- Overrides:
searchPage
in classBaseSourceAdapter
realm
- string value that sets the realm for the search. The source can implement various realms to account for permissions of the calling user- Returns:
- results and if there are too many, never return null!!!
- See Also:
-
setupDataSource
DataSource connection pool setup.- Overrides:
setupDataSource
in classJDBCSourceAdapter
- Parameters:
props
-- Throws:
SourceUnavailableException
-
getDbTableOrView
table or view where each row is a subject <param-name>dbTableOrView</param-name>- Returns:
- table or view
-
getSubjectsByIdentifiers
Description copied from interface:Source
Get subjects by identifiers. Note, if the subjects arent found or arent unique, they wont be returned. Identifiers are unique ways to refer to a subject that isnt its id (e.g. netid). Duplicates are ok on the input, but will return one output.- Specified by:
getSubjectsByIdentifiers
in interfaceSource
- Overrides:
getSubjectsByIdentifiers
in classJDBCSourceAdapter
- Returns:
- a map of results never null indexed by the identifiers
- See Also:
-
getSubjectsByIds
Description copied from interface:Source
Get subjects by ids. Note, if the subjects arent found or arent unique, they wont be returned. Duplicates are ok on the input, but will return one output.- Specified by:
getSubjectsByIds
in interfaceSource
- Overrides:
getSubjectsByIds
in classJDBCSourceAdapter
- Returns:
- a map of results never null indexed by the id
- See Also:
-
getSubject
public Subject getSubject(String id1, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException Description copied from class:JDBCSourceAdapter
Gets a Subject by its ID.- Specified by:
getSubject
in interfaceSource
- Overrides:
getSubject
in classJDBCSourceAdapter
exceptionIfNull
- if SubjectNotFoundException should be throws if the subject is null, or if null should be returned- Returns:
- subject
- Throws:
SubjectNotFoundException
SubjectNotUniqueException
- See Also:
-
searchPage
Description copied from interface:Source
Unstructured search for Subjects. Each implementation utilizes its own search algorithm tailored to the Subject repository and schema. Note if config param: throwErrorOnFindAllFailure is false, then swallow and log exceptions if maxPageSize is set in subject.properties, then only return max that many, and if there are more, set the tooManyResults flag- Specified by:
searchPage
in interfaceSource
- Overrides:
searchPage
in classJDBCSourceAdapter
- Returns:
- results and if there are too many, never return null!!!
- See Also:
-
search
Description copied from class:JDBCSourceAdapter
Unstructured search for Subjects. Each implementation utilizes its own search algorithm tailored to the Subject repository and schema. Note if config param: throwErrorOnFindAllFailure is false, then swallow and log exceptions- Specified by:
search
in interfaceSource
- Overrides:
search
in classJDBCSourceAdapter
- Returns:
- set
- See Also:
-
dbTableOrView
get the db table or view, considering realm- Returns:
- the db table or view
-
getSubjectByIdentifier
public Subject getSubjectByIdentifier(String identifier, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException Description copied from class:BaseSourceAdapter
note, you should implement this method since this implementation will become abstract at some point- Specified by:
getSubjectByIdentifier
in interfaceSource
- Overrides:
getSubjectByIdentifier
in classJDBCSourceAdapter
- Returns:
- subject
- Throws:
SubjectNotFoundException
SubjectNotUniqueException
- See Also:
-
createSubject
protected Subject createSubject(ResultSet resultSet, String query, Collection<String> identifiersForIdentifierToMap, Map<String, Subject> resultIdentifierToSubject) throws SQLExceptionCreate a subject from the current row in the resultSet- Parameters:
resultSet
-query
-identifiersForIdentifierToMap
-resultIdentifierToSubject
-- Returns:
- subject
- Throws:
SQLException
-
loadAttributes
protected Map<String,Set<String>> loadAttributes(ResultSet resultSet, String query, ResultSetMetaData resultSetMetaData) throws SQLException Loads attributes for the argument subject.- Parameters:
resultSet
-query
- for loggingresultSetMetaData
-- Returns:
- attributes
- Throws:
SQLException
-
retrieveString
protected String retrieveString(ResultSet resultSet, String name, String varName, String query, ResultSetMetaData resultSetMetaData) throws SQLException retrieve a param from resultset- Parameters:
resultSet
-name
-varName
-query
-resultSetMetaData
-- Returns:
- the value
- Throws:
SQLException
-
setDbTableOrView
table or view where each row is a subject <param-name>dbTableOrView</param-name>- Parameters:
dbTableOrView1
-
-
getSubjectIdCol
column which holds the subject id <param-name>subjectIdCol</param-name>- Returns:
- the subject id col
-
setSubjectIdCol
column which holds the subject id <param-name>subjectIdCol</param-name>- Parameters:
subjectIdCol1
-
-
getNameCol
column which holds the subject name <param-name>nameCol</param-name>- Returns:
- the col for name
-
setNameCol
column which holds the subject name <param-name>nameCol</param-name>- Parameters:
nameCol1
-
-
getDescriptionCol
- Returns:
- description col
-
setDescriptionCol
- Parameters:
descriptionCol1
-
-
getLowerSearchCol
for searches (not by id or identifier), this is the col which holds the search terms, in lower case <param-name>lowerSearchCol</param-name>- Returns:
- lower search col
-
setLowerSearchCol
for searches (not by id or identifier), this is the col which holds the search terms, in lower case <param-name>lowerSearchCol</param-name>- Parameters:
lowerSearchCol1
-
-
getDefaultSortCol
search queries will sort by this. Note it might be overridden by caller, e.g. UI <param-name>defaultSortCol</param-name>- Returns:
- sort col
-
setDefaultSortCol
search queries will sort by this. Note it might be overridden by caller, e.g. UI <param-name>defaultSortCol</param-name>- Parameters:
defaultSortCol1
-
-
getSubjectIdentifierCols
cols which are used in a findByIdentifier query <param-name>subjectIdentifierCol0</param-name>- Returns:
- subject id cols
-
setSubjectIdentifierCols
cols which are used in a findByIdentifier query <param-name>subjectIdentifierCol0</param-name>- Parameters:
subjectIdentifierCols1
-
-
getSubjectAttributeColToName
map of col to attribute name //<param-name>subjectAttributeCol0</param-name> //<param-name>subjectAttributeName0</param-name>- Returns:
- subject attribute col
-
setSubjectAttributeColToName
map of col to attribute name //<param-name>subjectAttributeCol0</param-name> //<param-name>subjectAttributeName0</param-name>- Parameters:
subjectAttributeColToName1
-
-
getSubjectIdentifierAttributes
Description copied from interface:Source
Get the names of attributes that are subject identifiers. This only returns the first- Specified by:
getSubjectIdentifierAttributes
in interfaceSource
- Overrides:
getSubjectIdentifierAttributes
in classJDBCSourceAdapter
- Returns:
- subject identifiers
- See Also:
-
getSubjectIdentifierAttributesAll
Description copied from interface:Source
Get all the names of attributes that are subject identifiers.- Specified by:
getSubjectIdentifierAttributesAll
in interfaceSource
- Overrides:
getSubjectIdentifierAttributesAll
in classJDBCSourceAdapter
- Returns:
- subject identifiers
- See Also:
-