Class QueryBuilder
java.lang.Object
org.odpi.openmetadata.adapters.repositoryservices.postgres.repositoryconnector.database.QueryBuilder
Translates open metadata query requests into SQL fragments that can be assembled before issuing
 then to the database.
- 
Constructor SummaryConstructorsConstructorDescriptionQueryBuilder(String principleTableName, String propertyTableName, OMRSRepositoryHelper repositoryHelper, String repositoryName) Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionReturn the where clause built up from the query parameters supplied.getDistinctPropertyJoinQuery(RepositoryTable principleTable, String propertiesTableName) Join the principle table with its associated attributes table.getPrimaryKeysClause(String instanceGUID, long version, String classificationName) Return the where clause that identified the primary key of an entity, relationship or classification.getPropertyJoinQuery(String principleTableName, String propertiesTableName, String columnSelection) Join the principle table with its associated attributes table.getSequenceAndPaging(String principleTableName) The sequencing (order by) and paging (limit/offset) can only be added at the end and may only includevoidsetAsOfTime(Date asOfTime) Set up the database time to issue the query for - null means the latest versionvoidsetGUIDList(List<String> guidList) Set up a list of GUIDs as part of a search.voidsetLimitResultsByClassification(List<String> limitResultsByClassification) Set up the list of classifications that must be present on all returned entities.voidsetLimitResultsByStatus(List<InstanceStatus> limitResultsByStatus) Set up the list od current statuses that an instance must have to be returned.voidsetMatchProperties(InstanceProperties matchProperties, MatchCriteria matchCriteria) Set up the properties that should be matched during the query.voidsetPaging(int fromElement, int pageSize) Set up the required paging.voidsetRelationshipEndGUID(String relationshipEndGUID) Set up an entity GUID for searching for an entity's relationships.voidsetSearchClassifications(SearchClassifications matchClassifications) Set up optional list of entity classifications to match.voidsetSearchProperties(SearchProperties searchProperties) Set up the search properties.voidsetSearchString(String searchString) Set up the Java regular expression used to match against any of the String property values within instances of the specified type(s).voidsetSequencingOrder(SequencingOrder sequencingOrder, String sequencingProperty) Set up the sequencing order required.voidsetTypeGUID(String typeGUID, String typeGUIDParameterName) Set up the type information for the query.voidsetTypeGUID(String typeGUID, String typeGUIDParameterName, List<String> subTypeGUIDs, String subTypeGUIDsParameterName) Set up the type information for the query.toString()toString() JSON-style
- 
Constructor Details- 
QueryBuilderpublic QueryBuilder(String principleTableName, String propertyTableName, OMRSRepositoryHelper repositoryHelper, String repositoryName) Constructor.- Parameters:
- principleTableName- name of entity, relationship, classification
- propertyTableName- name of entity_attribute_value, classification_attribute_value, relationship_attribute_value
- repositoryName- name of this repository
- repositoryHelper- helper
 
 
- 
- 
Method Details- 
setRelationshipEndGUIDSet up an entity GUID for searching for an entity's relationships.- Parameters:
- relationshipEndGUID- entity GUID
 
- 
setSearchStringSet up the Java regular expression used to match against any of the String property values within instances of the specified type(s).- Parameters:
- searchString- regex
 
- 
setMatchPropertiesSet up the properties that should be matched during the query.- Parameters:
- matchProperties- Optional list of entity properties to match (where any String property's value should be defined as a Java regular expression, even if it should be an exact match).
- matchCriteria- Enum defining how the match properties should be matched to the entities in the repository.
 
- 
setSearchPropertiesSet up the search properties.- Parameters:
- searchProperties- Optional list of entity property conditions to match.
 
- 
setSearchClassificationsSet up optional list of entity classifications to match.- Parameters:
- matchClassifications- match classifications
 
- 
setLimitResultsByClassificationSet up the list of classifications that must be present on all returned entities.- Parameters:
- limitResultsByClassification- list of classification names
 
- 
setTypeGUIDSet up the type information for the query.- Parameters:
- typeGUID- unique identifier of desired type.
- typeGUIDParameterName- parameter name use to pass the type guid
 
- 
setTypeGUIDpublic void setTypeGUID(String typeGUID, String typeGUIDParameterName, List<String> subTypeGUIDs, String subTypeGUIDsParameterName) Set up the type information for the query.- Parameters:
- typeGUID- unique identifier of desired type.
- typeGUIDParameterName- parameter name use to pass the type guid
- subTypeGUIDs- list of unique identifiers for the desired type
- subTypeGUIDsParameterName- parameter name use to pass the subtype guid list
 
- 
setLimitResultsByStatusSet up the list od current statuses that an instance must have to be returned.- Parameters:
- limitResultsByStatus- list of statuses
 
- 
setAsOfTimeSet up the database time to issue the query for - null means the latest version- Parameters:
- asOfTime- date or null
 
- 
setSequencingOrderSet up the sequencing order required.- Parameters:
- sequencingOrder- order to return results
- sequencingProperty- optional property if sequencing on specific property results
 
- 
setPagingpublic void setPaging(int fromElement, int pageSize) Set up the required paging.- Parameters:
- fromElement- starting from element (0 for first)
- pageSize- maximum number of elements that can be returned
 
- 
setGUIDListSet up a list of GUIDs as part of a search.- Parameters:
- guidList- list of GUID to search for
 
- 
getPrimaryKeysClauseReturn the where clause that identified the primary key of an entity, relationship or classification.- Parameters:
- instanceGUID- unique identifier of the associated entity or relationship
- version- the version of the instance
- classificationName- optional classification name
- Returns:
- where clause
 
- 
getPropertyJoinQuerypublic String getPropertyJoinQuery(String principleTableName, String propertiesTableName, String columnSelection) Join the principle table with its associated attributes table.- Parameters:
- principleTableName- name of main table
- propertiesTableName- name of attributes table
- columnSelection- name of a specific column to select
- Returns:
- the join part of the SQL query
 
- 
getDistinctPropertyJoinQuerypublic String getDistinctPropertyJoinQuery(RepositoryTable principleTable, String propertiesTableName) Join the principle table with its associated attributes table.- Parameters:
- principleTable- main table
- propertiesTableName- name of attributes table
- Returns:
- the join part of the SQL query
 
- 
getAsOfTimeWhereClauseReturn the where clause built up from the query parameters supplied.- Returns:
- SQL command fragment
- Throws:
- RepositoryErrorException
 
- 
getSequenceAndPagingThe sequencing (order by) and paging (limit/offset) can only be added at the end and may only include- Parameters:
- principleTableName- main table that the ordering will occur on
- Returns:
- sql fragment
 
- 
toStringtoString() JSON-style
 
-