Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix schemas not reloading #280

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,8 @@ import scala.language.postfixOps
class SchemaFolderRepository(schemaRepositoryFolderPath: String, projectRepository: IProjectRepository) extends AbstractSchemaRepository {

private val logger: Logger = Logger(this.getClass)

private val fhirConfigReader: IFhirConfigReader = new FSConfigReader(
fhirVersion = FhirVersionUtil.getMajorFhirVersion(ToFhirConfig.engineConfig.schemaRepositoryFhirVersion),
profilesPath = Some(FileUtils.getPath(schemaRepositoryFolderPath).toString))
// BaseFhirConfig will act as a validator for the schema definitions by holding the ProfileDefinitions in memory
private var baseFhirConfig: BaseFhirConfig = initBaseFhirConfig(fhirConfigReader)
private val simpleStructureDefinitionService = new SimpleStructureDefinitionService(baseFhirConfig)
private var baseFhirConfig: BaseFhirConfig = initBaseFhirConfig()
private var simpleStructureDefinitionService = new SimpleStructureDefinitionService(baseFhirConfig)

// Schema definition cache: project id -> schema id -> schema definition
private val schemaDefinitions: mutable.Map[String, mutable.Map[String, SchemaDefinition]] = mutable.Map.empty[String, mutable.Map[String, SchemaDefinition]]
Expand Down Expand Up @@ -312,10 +307,14 @@ class SchemaFolderRepository(schemaRepositoryFolderPath: String, projectReposito
/**
* Try to initialize the BaseFhirConfig. Otherwise print the error message and halt.
*
* @param fhirConfigReader config reader for BaseFhirConfig
* @return
*/
private def initBaseFhirConfig(fhirConfigReader: IFhirConfigReader): BaseFhirConfig = {
private def initBaseFhirConfig(): BaseFhirConfig = {
// BaseFhirConfig will act as a validator for the schema definitions by holding the ProfileDefinitions in memory
val fhirConfigReader: IFhirConfigReader = new FSConfigReader(
fhirVersion = FhirVersionUtil.getMajorFhirVersion(ToFhirConfig.engineConfig.schemaRepositoryFhirVersion),
profilesPath = Some(FileUtils.getPath(schemaRepositoryFolderPath).toString))

val folder = FileUtils.getPath(schemaRepositoryFolderPath).toFile
if (!folder.exists()) {
folder.mkdirs()
Expand Down Expand Up @@ -530,7 +529,8 @@ class SchemaFolderRepository(schemaRepositoryFolderPath: String, projectReposito
*/
override def invalidate(): Unit = {
this.schemaDefinitions.clear()
this.baseFhirConfig = initBaseFhirConfig(fhirConfigReader)
this.baseFhirConfig = initBaseFhirConfig()
this.simpleStructureDefinitionService = new SimpleStructureDefinitionService(this.baseFhirConfig)
initMap(schemaRepositoryFolderPath)
}

Expand Down
Loading