java.lang.Object
org.odpi.openmetadata.adapters.repositoryservices.postgres.repositoryconnector.database.QueryBuilder

public class QueryBuilder extends Object
Translates open metadata query requests into SQL fragments that can be assembled before issuing then to the database.
  • Constructor Summary

    Constructors
    Constructor
    Description
    QueryBuilder(String principleTableName, String propertyTableName, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper repositoryHelper, String repositoryName)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return 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 include
    void
    setAsOfTime(Date asOfTime)
    Set up the database time to issue the query for - null means the latest version
    void
    setGUIDList(List<String> guidList)
    Set up a list of GUIDs as part of a search.
    void
    setLimitResultsByClassification(List<String> limitResultsByClassification)
    Set up the list of classifications that must be present on all returned entities.
    void
    setLimitResultsByStatus(List<org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus> limitResultsByStatus)
    Set up the list od current statuses that an instance must have to be returned.
    void
    setMatchProperties(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties matchProperties, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria matchCriteria)
    Set up the properties that should be matched during the query.
    void
    setPaging(int fromElement, int pageSize)
    Set up the required paging.
    void
    setRelationshipEndGUID(String relationshipEndGUID)
    Set up an entity GUID for searching for an entity's relationships.
    void
    setSearchClassifications(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.search.SearchClassifications matchClassifications)
    Set up optional list of entity classifications to match.
    void
    setSearchProperties(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.search.SearchProperties searchProperties)
    Set up the search properties.
    void
    setSearchString(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).
    void
    setSequencingOrder(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder sequencingOrder, String sequencingProperty)
    Set up the sequencing order required.
    void
    setTypeGUID(String typeGUID, String typeGUIDParameterName)
    Set up the type information for the query.
    void
    setTypeGUID(String typeGUID, String typeGUIDParameterName, List<String> subTypeGUIDs, String subTypeGUIDsParameterName)
    Set up the type information for the query.
    toString() JSON-style

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • QueryBuilder

      public QueryBuilder(String principleTableName, String propertyTableName, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.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

    • setRelationshipEndGUID

      public void setRelationshipEndGUID(String relationshipEndGUID)
      Set up an entity GUID for searching for an entity's relationships.
      Parameters:
      relationshipEndGUID - entity GUID
    • setSearchString

      public void setSearchString(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).
      Parameters:
      searchString - regex
    • setMatchProperties

      public void setMatchProperties(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties matchProperties, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria matchCriteria)
      Set 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.
    • setSearchProperties

      public void setSearchProperties(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.search.SearchProperties searchProperties)
      Set up the search properties.
      Parameters:
      searchProperties - Optional list of entity property conditions to match.
    • setSearchClassifications

      public void setSearchClassifications(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.search.SearchClassifications matchClassifications)
      Set up optional list of entity classifications to match.
      Parameters:
      matchClassifications - match classifications
    • setLimitResultsByClassification

      public void setLimitResultsByClassification(List<String> limitResultsByClassification)
      Set up the list of classifications that must be present on all returned entities.
      Parameters:
      limitResultsByClassification - list of classification names
    • setTypeGUID

      public void setTypeGUID(String typeGUID, String typeGUIDParameterName)
      Set up the type information for the query.
      Parameters:
      typeGUID - unique identifier of desired type.
      typeGUIDParameterName - parameter name use to pass the type guid
    • setTypeGUID

      public 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
    • setLimitResultsByStatus

      public void setLimitResultsByStatus(List<org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus> limitResultsByStatus)
      Set up the list od current statuses that an instance must have to be returned.
      Parameters:
      limitResultsByStatus - list of statuses
    • setAsOfTime

      public void setAsOfTime(Date asOfTime)
      Set up the database time to issue the query for - null means the latest version
      Parameters:
      asOfTime - date or null
    • setSequencingOrder

      public void setSequencingOrder(org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder sequencingOrder, String sequencingProperty)
      Set up the sequencing order required.
      Parameters:
      sequencingOrder - order to return results
      sequencingProperty - optional property if sequencing on specific property results
    • setPaging

      public 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
    • setGUIDList

      public void setGUIDList(List<String> guidList)
      Set up a list of GUIDs as part of a search.
      Parameters:
      guidList - list of GUID to search for
    • getPrimaryKeysClause

      public String getPrimaryKeysClause(String instanceGUID, long version, String classificationName)
      Return 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
    • getPropertyJoinQuery

      public 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
    • getDistinctPropertyJoinQuery

      public 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
    • getAsOfTimeWhereClause

      public String getAsOfTimeWhereClause() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException
      Return the where clause built up from the query parameters supplied.
      Returns:
      SQL command fragment
      Throws:
      org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException
    • getSequenceAndPaging

      public String getSequenceAndPaging(String principleTableName)
      The 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
    • toString

      public String toString()
      toString() JSON-style
      Overrides:
      toString in class Object
      Returns:
      string description