Skip to content

Commit

Permalink
Merge pull request #255 from srdc/reload-bug-fix
Browse files Browse the repository at this point in the history
🐛 fix schema reloading issue
  • Loading branch information
YemreGurses authored Nov 22, 2024
2 parents 341fe2a + a967b74 commit 3cf4aa6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SchemaFolderRepository(schemaRepositoryFolderPath: String, projectFolderRe
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 val baseFhirConfig: BaseFhirConfig = initBaseFhirConfig(fhirConfigReader)
private var baseFhirConfig: BaseFhirConfig = initBaseFhirConfig(fhirConfigReader)
private val 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 @@ -528,6 +528,7 @@ class SchemaFolderRepository(schemaRepositoryFolderPath: String, projectFolderRe
*/
def reloadSchemaDefinitions(): Unit = {
this.schemaDefinitions.clear()
this.baseFhirConfig = initBaseFhirConfig(fhirConfigReader)
initMap(schemaRepositoryFolderPath)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package io.tofhir.server.endpoint

import akka.actor.ActorSystem
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.testkit.RouteTestTimeout
import akka.testkit.TestDuration
import io.tofhir.engine.util.FileUtils
import io.tofhir.server.BaseEndpointTest
import io.tofhir.server.model.Project
Expand All @@ -11,9 +14,13 @@ import org.json4s.{JArray, JObject, JString}
import org.json4s.jackson.{JsonMethods, Serialization}

import java.io.FileWriter
import scala.concurrent.duration.DurationInt

class ReloadingEndpointTest extends BaseEndpointTest {

// default timeout is 1 seconds, which is not enough for this test
implicit def default(implicit system: ActorSystem): RouteTestTimeout = RouteTestTimeout(new DurationInt(10).second.dilated(system))

"The service" should {

"should reload projects successfully after updating project file" in {
Expand Down

0 comments on commit 3cf4aa6

Please sign in to comment.