-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #542 from smeup/feature/data_definition_from_dspf
Feature/data definition from dspf
- Loading branch information
Showing
23 changed files
with
250 additions
and
43 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
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
33 changes: 33 additions & 0 deletions
33
rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/execution/SimpleDspfConfig.kt
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,33 @@ | ||
package com.smeup.rpgparser.execution | ||
|
||
import com.smeup.dspfparser.domain.DisplayFileParser | ||
import com.smeup.rpgparser.interpreter.FileMetadata | ||
import com.smeup.rpgparser.interpreter.getDbFields | ||
import kotlinx.serialization.Serializable | ||
import java.io.File | ||
|
||
/** | ||
* Helper class used to load dspf configuration from a display file | ||
* @param displayFilePath path where display file is located | ||
* */ | ||
@Serializable | ||
internal data class SimpleDspfConfig(var displayFilePath: String? = null) { | ||
|
||
internal fun getMetadata(displayFile: String): FileMetadata { | ||
val videoFile = File(displayFilePath, "$displayFile.dspf") | ||
require(videoFile.exists()) { "$videoFile doesn't exist" } | ||
|
||
return videoFile.bufferedReader().use { reader -> | ||
val dspf = DisplayFileParser.parse(reader) | ||
val fields = dspf.getDbFields() | ||
|
||
FileMetadata( | ||
name = displayFile, | ||
tableName = "", | ||
recordFormat = "", | ||
fields = fields, | ||
accessFields = emptyList() | ||
) | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/interpreter/video.kt
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,33 @@ | ||
package com.smeup.rpgparser.interpreter | ||
|
||
import com.smeup.dspfparser.domain.DSPF | ||
import com.smeup.rpgparser.parsing.parsetreetoast.RpgType | ||
|
||
internal fun DSPF.getDbFields(): List<DbField> { | ||
val fields = mutableListOf<DbField>() | ||
|
||
records.forEach { record -> | ||
record.fields.forEach { field -> | ||
val type: Type | ||
val rpgType: RpgType | ||
// currently parser can't handle REFFLD, so I created random fallback values | ||
val fallbackLength = 10 | ||
val fallbackPrecision = 10 | ||
|
||
if (field.isNumeric) { | ||
if (field.precision!! > 0) rpgType = RpgType.ZONED | ||
else rpgType = RpgType.INTEGER | ||
|
||
type = NumberType( | ||
field.length ?: fallbackLength, | ||
field.precision ?: fallbackPrecision, rpgType | ||
) | ||
} else { | ||
type = StringType.createInstance(field.length ?: fallbackLength) | ||
} | ||
fields.add(DbField(fieldName = field.name, type = type)) | ||
} | ||
} | ||
|
||
return fields | ||
} |
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
30 changes: 30 additions & 0 deletions
30
rpgJavaInterpreter-core/src/test/resources/smeup/metadata/MLNGT60AV.dspf
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,30 @@ | ||
A*%%TS SD 20240119 112614 GUAGIA REL-V7R4M0 5770-WDS | ||
A*%%EC | ||
A DSPSIZ(24 80 *DS3) | ||
A REF(*LIBL/DIZ_BR) | ||
A CHGINPDFT(HI CS) | ||
A PRINT | ||
A CA22 | ||
A CF02 | ||
A R FMT1 | ||
A*%%TS SD 20240119 112614 GUAGIA REL-V7R4M0 5770-WDS | ||
A TEXT('Videata Guida') | ||
A CF03 | ||
A CF14 | ||
A £RASDI 15A O 1 2DSPATR(HI) | ||
A 1 26'** GESTIONE ARTICOLI (Menu) **' | ||
A DSPATR(RI) | ||
A 1 60SYSNAME | ||
A £PDSNP 10A O 1 71 | ||
A 2 2DATE | ||
A EDTCDE(Y) | ||
A 2 34'Formato guida' | ||
A DSPATR(HI) | ||
A £PDSJN 10A O 2 60 | ||
A £PDSNU 10A O 2 71 | ||
A 22 2'F14=Entra nella schermata' | ||
A 23 2'F03=Fine Lavoro' | ||
A 60 W$MESV 76A O 24 2DSPATR(RI) | ||
A W$RISC 8A B 3 72 | ||
A 62 DSPATR(RI) | ||
A 62 DSPATR(PC) |
Oops, something went wrong.