-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Introduce a RepositoryManager and its file-based implementation to…
… achieve separation of cocerns and and make it the single responsible for the repositories required by the services.
- Loading branch information
Showing
20 changed files
with
162 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tofhir-server/src/main/scala/io/tofhir/server/repository/FolderRepositoryManager.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package io.tofhir.server.repository | ||
|
||
import io.tofhir.engine.config.ToFhirEngineConfig | ||
import io.tofhir.server.repository.job.JobFolderRepository | ||
import io.tofhir.server.repository.mapping.ProjectMappingFolderRepository | ||
import io.tofhir.server.repository.mappingContext.MappingContextFolderRepository | ||
import io.tofhir.server.repository.project.ProjectFolderRepository | ||
import io.tofhir.server.repository.schema.SchemaFolderRepository | ||
import io.tofhir.server.repository.terminology.TerminologySystemFolderRepository | ||
import io.tofhir.server.repository.terminology.codesystem.CodeSystemFolderRepository | ||
import io.tofhir.server.repository.terminology.conceptmap.ConceptMapFolderRepository | ||
|
||
/** | ||
* Folder/file based implementation of the RepositoryManager where all managed repositories are folder-based. | ||
* | ||
* @param toFhirEngineConfig | ||
*/ | ||
class FolderRepositoryManager(toFhirEngineConfig: ToFhirEngineConfig) extends IRepositoryManager { | ||
|
||
override val projectRepository: ProjectFolderRepository = new ProjectFolderRepository(toFhirEngineConfig) | ||
override val mappingRepository: ProjectMappingFolderRepository = new ProjectMappingFolderRepository(toFhirEngineConfig.mappingRepositoryFolderPath, projectRepository) | ||
override val schemaRepository: SchemaFolderRepository = new SchemaFolderRepository(toFhirEngineConfig.schemaRepositoryFolderPath, projectRepository) | ||
override val mappingJobRepository: JobFolderRepository = new JobFolderRepository(toFhirEngineConfig.jobRepositoryFolderPath, projectRepository) | ||
override val mappingContextRepository: MappingContextFolderRepository = new MappingContextFolderRepository(toFhirEngineConfig.mappingContextRepositoryFolderPath, projectRepository) | ||
|
||
override val terminologySystemRepository: TerminologySystemFolderRepository = new TerminologySystemFolderRepository(toFhirEngineConfig.terminologySystemFolderPath) | ||
override val conceptMapRepository: ConceptMapFolderRepository = new ConceptMapFolderRepository(toFhirEngineConfig.terminologySystemFolderPath) | ||
override val codeSystemRepository: CodeSystemFolderRepository = new CodeSystemFolderRepository(toFhirEngineConfig.terminologySystemFolderPath) | ||
|
||
private val folderDBInitializer = new FolderDBInitializer( | ||
projectRepository, | ||
schemaRepository, | ||
mappingRepository, | ||
mappingJobRepository, | ||
mappingContextRepository | ||
) | ||
|
||
/** | ||
* Initializes the Repository Manager's internal database (the projects.json file) after initialization of | ||
* each individual repository. | ||
*/ | ||
override def init(): Unit = { | ||
folderDBInitializer.init() | ||
} | ||
|
||
/** | ||
* Deletes the internal repository database (the projects.json file) for a fresh start (usually after cache invalidate operations) | ||
*/ | ||
override def clear(): Unit = { | ||
folderDBInitializer.removeProjectsJsonFile() | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
tofhir-server/src/main/scala/io/tofhir/server/repository/IRepositoryManager.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.tofhir.server.repository | ||
|
||
import io.tofhir.server.repository.job.IJobRepository | ||
import io.tofhir.server.repository.mapping.IMappingRepository | ||
import io.tofhir.server.repository.mappingContext.IMappingContextRepository | ||
import io.tofhir.server.repository.project.IProjectRepository | ||
import io.tofhir.server.repository.schema.ISchemaRepository | ||
import io.tofhir.server.repository.terminology.ITerminologySystemRepository | ||
import io.tofhir.server.repository.terminology.codesystem.ICodeSystemRepository | ||
import io.tofhir.server.repository.terminology.conceptmap.IConceptMapRepository | ||
|
||
/** | ||
* Manage the repositories throughout toFHIR | ||
*/ | ||
trait IRepositoryManager { | ||
val projectRepository: IProjectRepository | ||
val mappingRepository: IMappingRepository | ||
val schemaRepository: ISchemaRepository | ||
val mappingJobRepository: IJobRepository | ||
val mappingContextRepository: IMappingContextRepository | ||
|
||
val terminologySystemRepository: ITerminologySystemRepository | ||
val conceptMapRepository: IConceptMapRepository | ||
val codeSystemRepository: ICodeSystemRepository | ||
|
||
/** | ||
* Initialize the repository | ||
*/ | ||
def init(): Unit | ||
|
||
/** | ||
* Clean-up the repository database | ||
*/ | ||
def clear(): Unit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.