Class Main
- java.lang.Object
-
- org.linuxforhealth.fhir.schema.app.Main
-
public class Main extends java.lang.ObjectUtility 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.StringADMIN_SCHEMANAMEstatic java.lang.StringBATCH_SCHEMANAMEstatic java.lang.StringDATA_SCHEMANAMEstatic java.lang.StringOAUTH_SCHEMANAMEjava.util.List<DbType>PRIVILEGES_FEATURE_ENABLEDjava.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 voidaddProperty(java.lang.String pair)Parse the given key=value string and add to the properties being collectedprotected voidapplyDataMigrationForV0010()Perform the special data migration steps required for the V0010 version of the schemaprotected voidapplyDataMigrationForV0014()protected voidapplyDataMigrationForV0027()protected voidapplyModel(PhysicalDataModel pdm, ISchemaAdapter adapter, ITaskCollector collector, VersionHistoryService vhs, SchemaType schemaType)Start the schema object creation tasks and wait for everything to completeprotected voidbackfillResourceChangeLog()Backfill the RESOURCE_CHANGE_LOG table if it is emptyprotected voidbuildAdminSchemaModel(PhysicalDataModel pdm)Add the admin schema objects to thePhysicalDataModelprotected voidbuildCommonModel(PhysicalDataModel pdm, boolean addFhirDataSchema, boolean addOAuthSchema, boolean addJavaBatchSchema)Build a common PhysicalDataModel containing all the requested schemasprotected voidbuildFhirDataSchemaModel(PhysicalDataModel pdm)Add FHIR data schema objects to the givenPhysicalDataModelprotected voidbuildJavaBatchSchemaModel(PhysicalDataModel pdm)Add the JavaBatch schema objects to the givenPhysicalDataModelprotected voidbuildOAuthSchemaModel(PhysicalDataModel pdm)Add the OAuth schema objects to the givenPhysicalDataModelprotected booleancheckCompatibility()specific feature to check if it is compatible.protected voidconfigureConnectionPool()Create a simple connection pool associated with our data source so that we can perform the DDL deployment in parallelprotected java.sql.ConnectioncreateConnection()protected voidcreateSchemas()Create the schemasprotected voiddropSchema()Drop all the objects in the admin and data schemas.protected SchemaTypegetDataSchemaType()What type of FHIR data schema do we want to build?protected intgetExitStatus()Get the program exit status from the environmentprotected voidgrantPrivileges()Grant the minimum required set of privileges on the FHIR schema objects to the grantTo user.protected voidgrantPrivilegesForBatch()Apply grants to the JavaBatch schema objectsprotected voidgrantPrivilegesForFhirData()protected voidgrantPrivilegesForFhirData(java.lang.String privilegeGroupName, java.lang.String targetUser)Apply grants to the FHIR data schema objectsprotected voidgrantPrivilegesForOAuth()Apply grants to the OAuth schema objectsprotected voidgrantReadPrivilegesForFhirData()Grant only SELECT privileges to the given user to provide read-only direct schema accessvoidloadPropertyFile(java.lang.String filename)Read the properties from the given fileprotected voidlogStatusMessage(int status)Write a final status message - useful for QA to review when checking the outputstatic voidmain(java.lang.String[] args)Main entry pointprotected voidparseArgs(java.lang.String[] args)Parse the command-line arguments, building up the environment and establishing the run-listprotected voidpopulateResourceTypeAndParameterNameTableEntries()populates the RESOURCE_TYPE table.protected voidprocess()Process the requested operationprotected voidupdateFhirSchema()Update the FHIR data schemaprotected voidupdateJavaBatchSchema()Build and apply the JavaBatch schema changesprotected voidupdateOauthSchema()Build and apply the OAuth schema changesprotected voidupdateProcedures()Update the stored procedures used by FHIR to insert records into the FHIR resource tablesprotected booleanupdateSchema(PhysicalDataModel pdm, SchemaType schemaType)Update the schema associated with the givenPhysicalDataModelprotected voidupdateSchemas()Process the schemas configured to be updatedvoidupdateVacuumSettings()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-
-
applyDataMigrationForV0010
protected void applyDataMigrationForV0010()
Perform the special data migration steps required for the V0010 version of the schema
-
applyDataMigrationForV0014
protected void applyDataMigrationForV0014()
-
applyDataMigrationForV0027
protected void applyDataMigrationForV0027()
-
backfillResourceChangeLog
protected void backfillResourceChangeLog()
Backfill the RESOURCE_CHANGE_LOG table if it is empty
-
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-
-
-