Class DatabaseStore
java.lang.Object
org.odpi.openmetadata.adapters.repositoryservices.postgres.repositoryconnector.database.DatabaseStore
Manages the connection between the repository connector and the database.
Note, a single JDBC Connection can only be used from a single thread.
-
Constructor Summary
ConstructorsConstructorDescriptionDatabaseStore(org.odpi.openmetadata.adapters.connectors.resource.jdbc.JDBCResourceConnector jdbcResourceConnector, String repositoryName, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper repositoryHelper) Create access to the entity store. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntityProxyToStore(EntityMapper entityMapper) Add an entity proxy to the database only if the entity is not known.voidaddEntityToStore(EntityMapper entityMapper) Add an entity to the database.voidaddRelationshipToStore(RelationshipMapper relationshipMapper) Add a relationship to the database.voidFree up the connection since the request is over.getClassificationForUpdate(String entityGUID, String classificationName) Retrieve details about an entity from the store.getCompleteEntityFromStore(String guid, Map<String, org.odpi.openmetadata.adapters.connectors.resource.jdbc.properties.JDBCDataValue> entityRow, Date asOfTime) Retrieve the related information for an entity.getCompleteRelationshipFromStore(String guid, Map<String, org.odpi.openmetadata.adapters.connectors.resource.jdbc.properties.JDBCDataValue> relationshipRow, Date asOfTime) Retrieve the related information for a relationship.Extract the repository control table from the database schema.getEntityForUpdate(String guid) Retrieve details about an entity from the store.getEntityFromStore(String guid, Date asOfTime) Retrieve the version of an entity from the database that was active at the requested time.getEntityHistoryFromStore(String guid, Date fromTime, Date toTime, boolean oldestFirst) Return the list of versions for an entity.getHomeClassifications(String guid, String localMetadataCollectionId, Date asOfTime) Return the list of home classifications for an entity.Retrieve a relationship from the database.getRelationshipFromStore(String guid, Date asOfTime) Retrieve the version of a relationship from the database that was active at the requested time.getRelationshipHistoryFromStore(String guid, Date fromTime, Date toTime, boolean oldestFirst) Return the list of versions for a relationship.getVersionEndDate(Date updateTime) Determine the end time for the previous version of an entity, relationship or classification.voidpurgeClassification(String entityGUID, String classificationName) Purge a classification from the databasevoidpurgeEntity(String guid) Remove (purge) an entity from the repository.voidpurgeRelationship(String guid) Remove (purge) a relationship from the repository.retrieveEntitiesByProperties(QueryBuilder entityQueryBuilder, QueryBuilder classificationQueryBuilder, Date asOfTime) This query is issued against the entity table and the entity attribute table.retrieveRelationships(QueryBuilder queryBuilder, Date asOfTime) This query is issued against the relationship table.retrieveRelationshipsByProperties(QueryBuilder queryBuilder, Date asOfTime) This query is issued against the relationship table and the relationship attribute table.voidsaveClassification(ClassificationMapper classificationMapper) Maintain a classification within the entity.voidsaveControlTable(ControlMapper controlMapper) Save the control table row to the database.voidupdatePreviousClassificationVersionEndTime(ClassificationMapper classificationMapper, Date versionEndTime) Update the version end date in an entity's classification to the database.voidupdatePreviousEntityVersionEndTime(EntityMapper entityMapper, Date versionEndTime) Update the version end date in an entity to the database.voidupdatePreviousRelationshipVersionEndTime(RelationshipMapper relationshipMapper, Date versionEndTime) Update the version end date in a relationship to the database.
-
Constructor Details
-
DatabaseStore
public DatabaseStore(org.odpi.openmetadata.adapters.connectors.resource.jdbc.JDBCResourceConnector jdbcResourceConnector, String repositoryName, org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper repositoryHelper) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Create access to the entity store.- Parameters:
jdbcResourceConnector- connector to the databaserepositoryName- name of this repositoryrepositoryHelper- helper- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException
-
-
Method Details
-
getControlTable
public ControlMapper getControlTable() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorExceptionExtract the repository control table from the database schema. This is used to validate that the server is using the correct repository.- Returns:
- contents of the control table (only 1 row expected)
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem connecting to the database
-
saveControlTable
public void saveControlTable(ControlMapper controlMapper) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Save the control table row to the database.- Parameters:
controlMapper- control mapper filled with the desired values.- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem connecting to the database
-
getEntityForUpdate
public EntityMapper getEntityForUpdate(String guid) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Retrieve details about an entity from the store. The entity mapper is returned to allow the caller to choose what style of entity to return.- Parameters:
guid- unique identifier of the entity- Returns:
- entity mapper containing all that is known about the latest version of the entity
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- either a problem accessing the database or a mapping problem with the contents retrieved
-
getRelationshipForUpdate
public RelationshipMapper getRelationshipForUpdate(String guid) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Retrieve a relationship from the database.- Parameters:
guid- unique identifier of the relationship- Returns:
- Relationship mapper
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
getClassificationForUpdate
public ClassificationMapper getClassificationForUpdate(String entityGUID, String classificationName) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Retrieve details about an entity from the store. The entity mapper is returned to allow the caller to choose what style of entity to return.- Parameters:
entityGUID- unique identifier of the entityclassificationName- name of classification- Returns:
- classification mapper containing all that is known about the latest version of the classification
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- either a problem accessing the database or a mapping problem with the contents retrieved
-
getHomeClassifications
public List<ClassificationMapper> getHomeClassifications(String guid, String localMetadataCollectionId, Date asOfTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Return the list of home classifications for an entity.- Parameters:
guid- unique identifier of the entitylocalMetadataCollectionId- unique identifier of the local metadata collectionasOfTime- database time- Returns:
- list of classifications or null
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database
-
getEntityFromStore
public EntityMapper getEntityFromStore(String guid, Date asOfTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Retrieve the version of an entity from the database that was active at the requested time. Null is returned if there were no active instance.- Parameters:
guid- unique identifier of the entityasOfTime- requested time for the version- Returns:
- entity mapper
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
getRelationshipFromStore
public RelationshipMapper getRelationshipFromStore(String guid, Date asOfTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Retrieve the version of a relationship from the database that was active at the requested time. Null is returned if there were no active instance.- Parameters:
guid- unique identifier of the relationshipasOfTime- requested time for the version- Returns:
- relationship mapper
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
retrieveEntitiesByProperties
public List<EntityMapper> retrieveEntitiesByProperties(QueryBuilder entityQueryBuilder, QueryBuilder classificationQueryBuilder, Date asOfTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException This query is issued against the entity table and the entity attribute table.- Parameters:
classificationQueryBuilder- filled with conditions for the where clause for the SQL queryentityQueryBuilder- filled with conditions for the where clause for the SQL queryasOfTime- database time- Returns:
- list of matching entity mappers or null if nothing matches
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
retrieveRelationships
public List<RelationshipMapper> retrieveRelationships(QueryBuilder queryBuilder, Date asOfTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException This query is issued against the relationship table.- Parameters:
queryBuilder- where clause for the SQL queryasOfTime- database time- Returns:
- list of matching relationship mappers or null if nothing matches
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
retrieveRelationshipsByProperties
public List<RelationshipMapper> retrieveRelationshipsByProperties(QueryBuilder queryBuilder, Date asOfTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException This query is issued against the relationship table and the relationship attribute table.- Parameters:
queryBuilder- populated with details of the where clause for the SQL queryasOfTime- database time- Returns:
- list of matching relationship mappers or null if nothing matches
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
getCompleteEntityFromStore
public EntityMapper getCompleteEntityFromStore(String guid, Map<String, org.odpi.openmetadata.adapters.connectors.resource.jdbc.properties.JDBCDataValue> entityRow, Date asOfTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorExceptionRetrieve the related information for an entity. Null is returned if there were no active instance.- Parameters:
guid- unique identifier of the entityentityRow- appropriate row from tableasOfTime- database time- Returns:
- entity mapper
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
getCompleteRelationshipFromStore
public RelationshipMapper getCompleteRelationshipFromStore(String guid, Map<String, org.odpi.openmetadata.adapters.connectors.resource.jdbc.properties.JDBCDataValue> relationshipRow, Date asOfTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorExceptionRetrieve the related information for a relationship. Null is returned if there was no active instance.- Parameters:
guid- unique identifier of the relationshiprelationshipRow- appropriate row from tableasOfTime- time for the database query- Returns:
- relationship mapper
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
getEntityHistoryFromStore
public List<EntityMapper> getEntityHistoryFromStore(String guid, Date fromTime, Date toTime, boolean oldestFirst) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Return the list of versions for an entity.- Parameters:
guid- unique identifier of the instancefromTime- starting timetoTime- ending timeoldestFirst- ordering- Returns:
- list of instance versions
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database
-
getRelationshipHistoryFromStore
public List<RelationshipMapper> getRelationshipHistoryFromStore(String guid, Date fromTime, Date toTime, boolean oldestFirst) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Return the list of versions for a relationship.- Parameters:
guid- unique identifier of the relationshipfromTime- starting timetoTime- ending timeoldestFirst- ordering- Returns:
- list of instance versions
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
addEntityToStore
public void addEntityToStore(EntityMapper entityMapper) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Add an entity to the database. Its header information (and effectivity dates) goes into the entity table. The properties go into the entity attribute values table.- Parameters:
entityMapper- details about the entity- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
getVersionEndDate
public Date getVersionEndDate(Date updateTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Determine the end time for the previous version of an entity, relationship or classification.- Parameters:
updateTime- update time from next version- Returns:
- date - 1 millisecond earlier than that the update time
- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- no update time in next version
-
addEntityProxyToStore
public void addEntityProxyToStore(EntityMapper entityMapper) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Add an entity proxy to the database only if the entity is not known. Its header information (and effectivity dates) goes into the entity table. The properties go into the entity attribute values table.- Parameters:
entityMapper- details about the entity- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
saveClassification
public void saveClassification(ClassificationMapper classificationMapper) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Maintain a classification within the entity.- Parameters:
classificationMapper- classification to update- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database
-
addRelationshipToStore
public void addRelationshipToStore(RelationshipMapper relationshipMapper) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Add a relationship to the database. Its header information (and effectivity dates) goes into the relationship table. The properties go into the relationship attribute values table.- Parameters:
relationshipMapper- details about the relationship- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
updatePreviousEntityVersionEndTime
public void updatePreviousEntityVersionEndTime(EntityMapper entityMapper, Date versionEndTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Update the version end date in an entity to the database.- Parameters:
entityMapper- details about the entityversionEndTime- time that the previous version ended- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
updatePreviousClassificationVersionEndTime
public void updatePreviousClassificationVersionEndTime(ClassificationMapper classificationMapper, Date versionEndTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Update the version end date in an entity's classification to the database.- Parameters:
classificationMapper- details about the classificationversionEndTime- time that the previous version ended- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
updatePreviousRelationshipVersionEndTime
public void updatePreviousRelationshipVersionEndTime(RelationshipMapper relationshipMapper, Date versionEndTime) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Update the version end date in a relationship to the database.- Parameters:
relationshipMapper- details about the relationshipversionEndTime- time that the previous version ended- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database, or mapping the values returned
-
purgeClassification
public void purgeClassification(String entityGUID, String classificationName) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Purge a classification from the database- Parameters:
entityGUID- unique identifierclassificationName- name of classification to remove- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database
-
purgeEntity
public void purgeEntity(String guid) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Remove (purge) an entity from the repository. This method relies on the foreign key relationships to remove all versions of the entity, and its linked relationships and classifications. This request could ripple updates into all tables except the repository control table.- Parameters:
guid- unique identifier of the entity- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database
-
purgeRelationship
public void purgeRelationship(String guid) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException Remove (purge) a relationship from the repository. This method relies on the foreign key relationships to properly remove all of the versions and properties associated with the relationship. It should have no effect on the entities and classification tables.- Parameters:
guid- unique identifier of the entity- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem communicating with the database
-
disconnect
public void disconnect() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorExceptionFree up the connection since the request is over.- Throws:
org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException- problem closing connection
-