-
Notifications
You must be signed in to change notification settings - Fork 1
Fix missing filter variables #96
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
Conversation
| metadataModel.getVariables().putVariable(new Variable(varName, group, varType)); | ||
| } | ||
|
|
||
| public static void addMissingAndFilterVariables(MetadataModel metadataModel, String lunaticFilePath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remplace lunaticFilePath par un InputSteam lunaticInputStream ici
| public static void addMissingAndFilterVariables(MetadataModel metadataModel, String lunaticFilePath) { | ||
| VariablesMap variablesMap = metadataModel.getVariables(); | ||
|
|
||
| try (InputStream lunaticStream = new FileInputStream(lunaticFilePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remplace l'ouverture de 2 FileInputStreams par JsonNode rootNode = JsonReader.read(lunaticInputStream);
| try (InputStream lunaticStream = new FileInputStream(lunaticFilePath); | ||
| InputStream lunaticStream2 = new FileInputStream(lunaticFilePath)) { | ||
|
|
||
| List<String> missingVars = LunaticReader.getMissingVariablesFromLunatic(lunaticStream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getMissing/getFilter vont prendre en entrée le JsonNode rootNode
| MetadataModel metadataModel = | ||
| getMetadataFromDDI(ddiUrlString, ddiInputStream); | ||
|
|
||
| if (metadataModel != null && lunaticFilePath != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if lunaticInputStream != null
| public static MetadataModel getMetadataFromDDIAndLunatic( | ||
| String ddiUrlString, | ||
| InputStream ddiInputStream, | ||
| String lunaticFilePath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lunaticInputStream en entrée
| * @param lunaticFile Path to a lunatic questionnaire file. | ||
| * @return A List of String. | ||
| */ | ||
| public static List<String> getMissingVariablesFromLunatic(InputStream lunaticFile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remplace InputStream lunaticFile par un JsonNode rootNode
| * @param lunaticFile Path to a lunatic questionnaire file. | ||
| * @return A List of String. | ||
| */ | ||
| public static List<String> getFilterResultFromLunatic(InputStream lunaticFile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pareil, JsonNode en paramètre
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merci pour les commentaires, je viens de push toutes les modifications
| group = metadataModel.getVariables().getQuestionGridGroup(correspondingVariableName); | ||
| } else { | ||
| group = metadataModel.getGroup(metadataModel.getGroupNames().getFirst()); | ||
| log.warn(String.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for logging avoid format, use log.warn( {}, var) instead.
And concat the two logs
| variablesNode.forEach(variableNode -> variables.add(variableNode.get("name").asText())); | ||
| return variables.stream() | ||
| .filter(varToRead -> varToRead.endsWith(MISSING_SUFFIX) || varsEno.contains(varToRead)).toList(); | ||
| JsonNode variablesNode = rootNode.get("variables"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the VARIABLES constant
| } | ||
| } | ||
| return variables.stream() | ||
| .filter(var -> var.startsWith(Constants.FILTER_RESULT_PREFIX)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename "var" to avoird restricted identifiers
| List<String> missingVars = LunaticReader.getMissingVariablesFromLunatic(rootNode); | ||
| List<String> filterVars = LunaticReader.getFilterResultFromLunatic(rootNode); | ||
|
|
||
| for (String var : missingVars) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid "var", maybe missingVar here
| } | ||
| } | ||
|
|
||
| for (String var : filterVars) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid "var"
| metadataModel.getVariables().putVariable(new Variable(varName, group, varType)); | ||
| } | ||
|
|
||
| public static void addMissingAndFilterVariables(MetadataModel metadataModel, InputStream lunaticInputStream) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you only use lunatic here. Maybe this method should be in the lunatic reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or make it private
| ) throws MetadataParserException { | ||
|
|
||
| MetadataModel metadataModel = | ||
| getMetadataFromDDI(ddiUrlString, ddiInputStream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DDIReader.getMetadataFromDDI
I prefer to show where is the method, what do you think about this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes i agree
|
Thank you for all your comments, i have applied all the modifications |
This PR adds missing and filter variables in metadata by merging Lunatic data into the existing DDI metadata. Tests were added to ensure these variables are correctly included in the resulting metadata model.