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 Stringtable or view where each row is a subject <param-name>dbTableOrView</param-name>protected Stringsearch queries will sort by this.protected Stringcol for subject description <param-name>descriptionCol</param-name>protected Stringfor searches (not by id or identifier), this is the col which holds the search terms, in lower case <param-name>lowerSearchCol</param-name>protected Stringcolumn which holds the subject name <param-name>nameCol</param-name>cols which are selected in queriesprotected Stringcolumn 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, subjectTypeStringFields 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 TypeMethodDescriptionvoidmake sure the config is ok, and log descriptive errors if notprotected SubjectcreateSubject(ResultSet resultSet, String query, Collection<String> identifiersForIdentifierToMap, Map<String, Subject> resultIdentifierToSubject) Create a subject from the current row in the resultSetprotected Stringget 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 StringretrieveString(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.voidsetDbTableOrView(String dbTableOrView1) table or view where each row is a subject <param-name>dbTableOrView</param-name>voidsetDefaultSortCol(String defaultSortCol1) search queries will sort by this.voidsetDescriptionCol(String descriptionCol1) voidsetLowerSearchCol(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>voidsetNameCol(String nameCol1) column which holds the subject name <param-name>nameCol</param-name>voidsetSubjectAttributeColToName(Map<String, String> subjectAttributeColToName1) map of col to attribute name //<param-name>subjectAttributeCol0</param-name> //<param-name>subjectAttributeName0</param-name>voidsetSubjectIdCol(String subjectIdCol1) column which holds the subject id <param-name>subjectIdCol</param-name>voidsetSubjectIdentifierCols(Set<String> subjectIdentifierCols1) cols which are used in a findByIdentifier query <param-name>subjectIdentifierCol0</param-name>protected voidsetupDataSource(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, tryToChangeQueryMethods 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:Sourcemake sure the config is ok, and log descriptive errors if not- Specified by:
checkConfigin interfaceSource- Overrides:
checkConfigin classJDBCSourceAdapter- See Also:
-
getSubject
public Subject getSubject(String id1, boolean exceptionIfNull, String realm) throws SubjectNotFoundException, SubjectNotUniqueException Description copied from interface:SourceGets a Subject by its ID.- Specified by:
getSubjectin interfaceSource- Overrides:
getSubjectin classBaseSourceAdapterexceptionIfNull- 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:
SubjectNotFoundExceptionSubjectNotUniqueException- See Also:
-
getSubjectByIdentifier
public Subject getSubjectByIdentifier(String identifier, boolean exceptionIfNull, String realm) throws SubjectNotFoundException, SubjectNotUniqueException Description copied from interface:SourceGets a Subject by other well-known identifiers, aside from the subject ID, for example, login ID.- Specified by:
getSubjectByIdentifierin interfaceSource- Overrides:
getSubjectByIdentifierin classBaseSourceAdapterrealm- 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:
SubjectNotFoundExceptionSubjectNotUniqueException- See Also:
-
getSubjectByIdOrIdentifier
public Subject getSubjectByIdOrIdentifier(String idOrIdentifier, boolean exceptionIfNull, String realm) throws SubjectNotFoundException, SubjectNotUniqueException Description copied from interface:Sourcefind by id or identifier. pass in either an id or an identifier- Specified by:
getSubjectByIdOrIdentifierin interfaceSource- Overrides:
getSubjectByIdOrIdentifierin classBaseSourceAdapterexceptionIfNull- 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:
SubjectNotFoundExceptionSubjectNotUniqueException- See Also:
-
getSubjectByIdOrIdentifier
public Subject getSubjectByIdOrIdentifier(String idOrIdentifier, boolean exceptionIfNull) throws SubjectNotFoundException, SubjectNotUniqueException Description copied from class:BaseSourceAdapterfind by id or identifier- Specified by:
getSubjectByIdOrIdentifierin interfaceSource- Overrides:
getSubjectByIdOrIdentifierin classBaseSourceAdapterexceptionIfNull- if SubjectNotFoundException or null- Returns:
- the subject
- Throws:
SubjectNotFoundExceptionSubjectNotUniqueException- See Also:
-
getSubjectsByIdentifiers
Description copied from interface:SourceGet 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:
getSubjectsByIdentifiersin interfaceSource- Overrides:
getSubjectsByIdentifiersin classBaseSourceAdapterrealm- 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:Sourceget all subject ids- Specified by:
retrieveAllSubjectIdsin interfaceSource- Overrides:
retrieveAllSubjectIdsin classJDBCSourceAdapter- Returns:
- all subjectIds
- See Also:
-
getSubjectsByIds
Description copied from interface:SourceGet 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:
getSubjectsByIdsin interfaceSource- Overrides:
getSubjectsByIdsin classBaseSourceAdapterrealm- 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:SourceGet 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:
getSubjectsByIdsOrIdentifiersin interfaceSource- Overrides:
getSubjectsByIdsOrIdentifiersin 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:SourceGet 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:
getSubjectsByIdsOrIdentifiersin interfaceSource- Overrides:
getSubjectsByIdsOrIdentifiersin 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:SourceUnstructured 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:
searchin interfaceSource- Overrides:
searchin classBaseSourceAdapterrealm- 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:SourceUnstructured 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:
searchPagein interfaceSource- Overrides:
searchPagein classBaseSourceAdapterrealm- 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:
setupDataSourcein 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:SourceGet 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:
getSubjectsByIdentifiersin interfaceSource- Overrides:
getSubjectsByIdentifiersin classJDBCSourceAdapter- Returns:
- a map of results never null indexed by the identifiers
- See Also:
-
getSubjectsByIds
Description copied from interface:SourceGet 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:
getSubjectsByIdsin interfaceSource- Overrides:
getSubjectsByIdsin 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:JDBCSourceAdapterGets a Subject by its ID.- Specified by:
getSubjectin interfaceSource- Overrides:
getSubjectin classJDBCSourceAdapterexceptionIfNull- if SubjectNotFoundException should be throws if the subject is null, or if null should be returned- Returns:
- subject
- Throws:
SubjectNotFoundExceptionSubjectNotUniqueException- See Also:
-
searchPage
Description copied from interface:SourceUnstructured 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:
searchPagein interfaceSource- Overrides:
searchPagein classJDBCSourceAdapter- Returns:
- results and if there are too many, never return null!!!
- See Also:
-
search
Description copied from class:JDBCSourceAdapterUnstructured 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:
searchin interfaceSource- Overrides:
searchin 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:BaseSourceAdapternote, you should implement this method since this implementation will become abstract at some point- Specified by:
getSubjectByIdentifierin interfaceSource- Overrides:
getSubjectByIdentifierin classJDBCSourceAdapter- Returns:
- subject
- Throws:
SubjectNotFoundExceptionSubjectNotUniqueException- 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:SourceGet the names of attributes that are subject identifiers. This only returns the first- Specified by:
getSubjectIdentifierAttributesin interfaceSource- Overrides:
getSubjectIdentifierAttributesin classJDBCSourceAdapter- Returns:
- subject identifiers
- See Also:
-
getSubjectIdentifierAttributesAll
Description copied from interface:SourceGet all the names of attributes that are subject identifiers.- Specified by:
getSubjectIdentifierAttributesAllin interfaceSource- Overrides:
getSubjectIdentifierAttributesAllin classJDBCSourceAdapter- Returns:
- subject identifiers
- See Also:
-