Class Main
- java.lang.Object
-
- org.linuxforhealth.fhir.schema.app.Main
-
public class Main extends java.lang.Object
Utility app to connect to a database and create/update the IBM FHIR Server schema. The DDL processing is idempotent, with only the necessary changes applied.
This utility also includes an option to exercise the tenant partitioning code.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ADMIN_SCHEMANAME
static java.lang.String
BATCH_SCHEMANAME
static java.lang.String
DATA_SCHEMANAME
static java.lang.String
OAUTH_SCHEMANAME
java.util.List<DbType>
PRIVILEGES_FEATURE_ENABLED
java.util.List<DbType>
STORED_PROCEDURE_ENABLED
-
Constructor Summary
Constructors Constructor Description Main()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addProperty(java.lang.String pair)
Parse the given key=value string and add to the properties being collectedprotected void
applyDataMigrationForV0027()
protected void
applyModel(PhysicalDataModel pdm, ISchemaAdapter adapter, ITaskCollector collector, VersionHistoryService vhs, SchemaType schemaType)
Start the schema object creation tasks and wait for everything to completeprotected void
buildAdminSchemaModel(PhysicalDataModel pdm)
Add the admin schema objects to thePhysicalDataModel
protected void
buildCommonModel(PhysicalDataModel pdm, boolean addFhirDataSchema, boolean addOAuthSchema, boolean addJavaBatchSchema)
Build a common PhysicalDataModel containing all the requested schemasprotected void
buildFhirDataSchemaModel(PhysicalDataModel pdm)
Add FHIR data schema objects to the givenPhysicalDataModel
protected void
buildJavaBatchSchemaModel(PhysicalDataModel pdm)
Add the JavaBatch schema objects to the givenPhysicalDataModel
protected void
buildOAuthSchemaModel(PhysicalDataModel pdm)
Add the OAuth schema objects to the givenPhysicalDataModel
protected boolean
checkCompatibility()
specific feature to check if it is compatible.protected void
configureConnectionPool()
Create a simple connection pool associated with our data source so that we can perform the DDL deployment in parallelprotected java.sql.Connection
createConnection()
protected void
createSchemas()
Create the schemasprotected void
dropSchema()
Drop all the objects in the admin and data schemas.protected SchemaType
getDataSchemaType()
What type of FHIR data schema do we want to build?protected int
getExitStatus()
Get the program exit status from the environmentprotected void
grantPrivileges()
Grant the minimum required set of privileges on the FHIR schema objects to the grantTo user.protected void
grantPrivilegesForBatch()
Apply grants to the JavaBatch schema objectsprotected void
grantPrivilegesForFhirData()
protected void
grantPrivilegesForFhirData(java.lang.String privilegeGroupName, java.lang.String targetUser)
Apply grants to the FHIR data schema objectsprotected void
grantPrivilegesForOAuth()
Apply grants to the OAuth schema objectsprotected void
grantReadPrivilegesForFhirData()
Grant only SELECT privileges to the given user to provide read-only direct schema accessvoid
loadPropertyFile(java.lang.String filename)
Read the properties from the given fileprotected void
logStatusMessage(int status)
Write a final status message - useful for QA to review when checking the outputstatic void
main(java.lang.String[] args)
Main entry pointprotected void
parseArgs(java.lang.String[] args)
Parse the command-line arguments, building up the environment and establishing the run-listprotected void
populateResourceTypeAndParameterNameTableEntries()
populates the RESOURCE_TYPE table.protected void
process()
Process the requested operationprotected void
updateFhirSchema()
Update the FHIR data schemaprotected void
updateJavaBatchSchema()
Build and apply the JavaBatch schema changesprotected void
updateOauthSchema()
Build and apply the OAuth schema changesprotected void
updateProcedures()
Update the stored procedures used by FHIR to insert records into the FHIR resource tablesprotected boolean
updateSchema(PhysicalDataModel pdm, SchemaType schemaType)
Update the schema associated with the givenPhysicalDataModel
protected void
updateSchemas()
Process the schemas configured to be updatedvoid
updateVacuumSettings()
updates the vacuum settings for postgres/citus.
-
-
-
Field Detail
-
STORED_PROCEDURE_ENABLED
public java.util.List<DbType> STORED_PROCEDURE_ENABLED
-
PRIVILEGES_FEATURE_ENABLED
public java.util.List<DbType> PRIVILEGES_FEATURE_ENABLED
-
ADMIN_SCHEMANAME
public static final java.lang.String ADMIN_SCHEMANAME
- See Also:
- Constant Field Values
-
OAUTH_SCHEMANAME
public static final java.lang.String OAUTH_SCHEMANAME
- See Also:
- Constant Field Values
-
BATCH_SCHEMANAME
public static final java.lang.String BATCH_SCHEMANAME
- See Also:
- Constant Field Values
-
DATA_SCHEMANAME
public static final java.lang.String DATA_SCHEMANAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
createConnection
protected java.sql.Connection createConnection()
- Returns:
- a created connection to the selected database
-
configureConnectionPool
protected void configureConnectionPool()
Create a simple connection pool associated with our data source so that we can perform the DDL deployment in parallel
-
buildAdminSchemaModel
protected void buildAdminSchemaModel(PhysicalDataModel pdm)
Add the admin schema objects to thePhysicalDataModel
- Parameters:
pdm
- the data model to build
-
buildOAuthSchemaModel
protected void buildOAuthSchemaModel(PhysicalDataModel pdm)
Add the OAuth schema objects to the givenPhysicalDataModel
- Parameters:
pdm
- the model to build
-
buildJavaBatchSchemaModel
protected void buildJavaBatchSchemaModel(PhysicalDataModel pdm)
Add the JavaBatch schema objects to the givenPhysicalDataModel
- Parameters:
pdm
-
-
applyModel
protected void applyModel(PhysicalDataModel pdm, ISchemaAdapter adapter, ITaskCollector collector, VersionHistoryService vhs, SchemaType schemaType)
Start the schema object creation tasks and wait for everything to complete- Parameters:
pdm
-adapter
-collector
-vhs
-
-
checkCompatibility
protected boolean checkCompatibility()
specific feature to check if it is compatible.- Returns:
-
createSchemas
protected void createSchemas()
Create the schemas
-
updateSchemas
protected void updateSchemas()
Process the schemas configured to be updated
-
buildFhirDataSchemaModel
protected void buildFhirDataSchemaModel(PhysicalDataModel pdm)
Add FHIR data schema objects to the givenPhysicalDataModel
- Parameters:
pdm
- the data model being built
-
updateFhirSchema
protected void updateFhirSchema()
Update the FHIR data schema
-
updateOauthSchema
protected void updateOauthSchema()
Build and apply the OAuth schema changes
-
updateJavaBatchSchema
protected void updateJavaBatchSchema()
Build and apply the JavaBatch schema changes
-
updateSchema
protected boolean updateSchema(PhysicalDataModel pdm, SchemaType schemaType)
Update the schema associated with the givenPhysicalDataModel
- Returns:
- true if the database is new
-
populateResourceTypeAndParameterNameTableEntries
protected void populateResourceTypeAndParameterNameTableEntries()
populates the RESOURCE_TYPE table.
-
dropSchema
protected void dropSchema()
Drop all the objects in the admin and data schemas. Typically used during development.
-
updateProcedures
protected void updateProcedures()
Update the stored procedures used by FHIR to insert records into the FHIR resource tables
-
buildCommonModel
protected void buildCommonModel(PhysicalDataModel pdm, boolean addFhirDataSchema, boolean addOAuthSchema, boolean addJavaBatchSchema)
Build a common PhysicalDataModel containing all the requested schemas- Parameters:
pdm
- the model to constructaddFhirDataSchema
- include objects for the FHIR data schemaaddOAuthSchema
- include objects for the Liberty OAuth schemaaddJavaBatchSchema
- include objects for the Liberty JavaBatch schema
-
grantPrivilegesForFhirData
protected void grantPrivilegesForFhirData()
-
grantReadPrivilegesForFhirData
protected void grantReadPrivilegesForFhirData()
Grant only SELECT privileges to the given user to provide read-only direct schema access
-
grantPrivilegesForFhirData
protected void grantPrivilegesForFhirData(java.lang.String privilegeGroupName, java.lang.String targetUser)
Apply grants to the FHIR data schema objects- Parameters:
privilegeGroupName
- identifies the group of privileges to apply
-
grantPrivilegesForOAuth
protected void grantPrivilegesForOAuth()
Apply grants to the OAuth schema objects
-
grantPrivilegesForBatch
protected void grantPrivilegesForBatch()
Apply grants to the JavaBatch schema objects
-
grantPrivileges
protected void grantPrivileges()
Grant the minimum required set of privileges on the FHIR schema objects to the grantTo user. All tenant data access is via this user, and is the only user the FHIR server itself is configured with.
-
getDataSchemaType
protected SchemaType getDataSchemaType()
What type of FHIR data schema do we want to build?- Returns:
-
parseArgs
protected void parseArgs(java.lang.String[] args)
Parse the command-line arguments, building up the environment and establishing the run-list- Parameters:
args
-
-
loadPropertyFile
public void loadPropertyFile(java.lang.String filename)
Read the properties from the given file- Parameters:
filename
-
-
addProperty
public void addProperty(java.lang.String pair)
Parse the given key=value string and add to the properties being collected- Parameters:
pair
-
-
applyDataMigrationForV0027
protected void applyDataMigrationForV0027()
-
updateVacuumSettings
public void updateVacuumSettings()
updates the vacuum settings for postgres/citus.
-
process
protected void process()
Process the requested operation
-
getExitStatus
protected int getExitStatus()
Get the program exit status from the environment- Returns:
-
logStatusMessage
protected void logStatusMessage(int status)
Write a final status message - useful for QA to review when checking the output
-
main
public static void main(java.lang.String[] args)
Main entry point- Parameters:
args
-
-
-