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

SHC Validation + filetype detection #143

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Allow fileType to be null and derived from content in ValidationService
  • Loading branch information
dotasek committed Sep 22, 2023
commit 3962d902c9c2e6d79af33b4333bc8f8cb7c923c7
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kotlin.code.style=official
kotlin.js.generate.executable.default=false

# versions
fhirCoreVersion=6.1.2
fhirCoreVersion=6.1.8-SNAPSHOT

junitVersion=5.7.1
mockk_version=1.10.2
Expand Down
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/model/FileInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ expect class FileInfo() {
fun getFileName(): String
fun setFileContent(fileContent: String): FileInfo
fun getFileContent(): String
fun setFileType(fileType: String): FileInfo
fun getFileType(): String
fun setFileType(fileType: String?): FileInfo
fun getFileType(): String?
}
8 changes: 4 additions & 4 deletions src/jsMain/kotlin/model/FileInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ actual class FileInfo actual constructor() {

var fileName: String = ""
var fileContent: String = ""
var fileType: String = ""
var fileType: String? = ""

constructor(fileName: String, fileContent: String, fileType: String) : this() {
constructor(fileName: String, fileContent: String, fileType: String?) : this() {
this.fileName = fileName
this.fileContent = fileContent
this.fileType = fileType
Expand All @@ -33,11 +33,11 @@ actual class FileInfo actual constructor() {
return this
}

actual fun getFileType(): String {
actual fun getFileType(): String? {
return fileType
}

actual fun setFileType(fileType: String): FileInfo {
actual fun setFileType(fileType: String?): FileInfo {
this.fileType = fileType
return this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ManualEntryTab : RComponent<ManualEntryTabProps, ManualEntryTabState>() {
cliContext = props.cliContext,
fileName = generateFileName(fileContent),
fileContent = fileContent,
fileType = FhirFormat.JSON
fileType = null
).setSessionId(props.sessionId)
mainScope.launch {
try {
Expand Down
4 changes: 2 additions & 2 deletions src/jsMain/kotlin/utils/RequestUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ fun assembleRequest(
cliContext: CliContext,
fileName: String,
fileContent: String,
fileType: FhirFormat,
fileType: FhirFormat?,
): ValidationRequest {
return assembleRequest(cliContext, FileInfo(fileName, fileContent, fileType.code))
return assembleRequest(cliContext, FileInfo(fileName, fileContent, if (fileType == null) null else fileType.code))
}

fun assembleRequest(cliContext: CliContext, file: FileInfo): ValidationRequest {
Expand Down
2 changes: 1 addition & 1 deletion src/jvmMain/kotlin/model/FileInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fun FileInfo.isValidFileName(): Boolean {
}

fun FileInfo.isValidFileType(): Boolean {
return (this.fileType != null && FhirFormat.fromCode(this.fileType) != null)
return (this.fileType == null || FhirFormat.fromCode(this.fileType) != null)
}

fun FileInfo.isValidFileContent(): Boolean {
Expand Down