-
Notifications
You must be signed in to change notification settings - Fork 2
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 #98 from InseeFr/devLunaticReader
Refactor of lunatic specification reader
- Loading branch information
Showing
17 changed files
with
77,099 additions
and
83 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
41 changes: 41 additions & 0 deletions
41
kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/metadata/ComponentLunatic.java
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,41 @@ | ||
package fr.insee.kraftwerk.core.metadata; | ||
|
||
import lombok.Getter; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
import java.util.Arrays; | ||
|
||
@Log4j2 | ||
@Getter | ||
public enum ComponentLunatic { | ||
|
||
DATE_PICKER("Datepicker", VariableType.DATE), | ||
CHECKBOX_BOOLEAN("CheckboxBoolean", VariableType.BOOLEAN), | ||
INPUT_NUMBER("InputNumber", null), | ||
INPUT("Input", VariableType.STRING), | ||
TEXT_AREA("Textarea", VariableType.STRING), | ||
RADIO("Radio", VariableType.STRING), | ||
CHECKBOX_ONE("CheckboxOne", VariableType.STRING), | ||
DROPDOWN("Dropdown", VariableType.STRING), | ||
CHECKBOX_GROUP("CheckboxGroup", VariableType.BOOLEAN), | ||
SUGGESTER("Suggester", VariableType.STRING), | ||
PAIRWISE_LINKS("PairwiseLinks", null), | ||
TABLE("Table", null); | ||
|
||
private String jsonName; | ||
// Represents the type of the variable expected with this component type | ||
// If null, the type is not unique | ||
private VariableType type; | ||
|
||
ComponentLunatic(String jsonName, VariableType type) { | ||
this.jsonName=jsonName; | ||
this.type = type; | ||
} | ||
|
||
public static ComponentLunatic fromJsonName(String jsonName) { | ||
return Arrays.stream(ComponentLunatic.values()) | ||
.filter(component -> component.getJsonName().equals(jsonName)) | ||
.findFirst() | ||
.orElse(null); | ||
} | ||
} |
365 changes: 314 additions & 51 deletions
365
kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/metadata/LunaticReader.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
6 changes: 6 additions & 0 deletions
6
kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/metadata/SpecType.java
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,6 @@ | ||
package fr.insee.kraftwerk.core.metadata; | ||
|
||
public enum SpecType { | ||
|
||
DDI,LUNATIC; | ||
} |
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
31 changes: 31 additions & 0 deletions
31
kraftwerk-functional-tests/src/test/resources/features/do_we_get_metadata_correctly.feature
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,31 @@ | ||
Feature: Do we retrieve correctly all metadata from specifications ? | ||
|
||
Scenario Outline: Does the metadata model is correct with Lunatic? | ||
Given Step 0 : We have some survey in directory "<Directory>" | ||
When Step 1 : We initialize metadata model with lunatic specification only | ||
Then We should have a metadata model with <NumberOfVariables> variables | ||
And We should have <NumberOfStringVariables> of type STRING | ||
|
||
Examples: | ||
# Parameters : | ||
# - Directory : Directory of test campaigns | ||
# - NumberOfVariables : Expected number of variables identified in Lunatic Json File | ||
# - NumberOfStringVariables : Expected number of variables of String Type | ||
|
||
|Directory |NumberOfVariables | NumberOfStringVariables | | ||
|SAMPLETEST-METADATA |370 | 174 | | ||
|
||
Scenario Outline: Does the metadata model is correct with DDI? | ||
Given Step 0 : We have some survey in directory "<Directory>" | ||
When Step 1 : We initialize metadata model with DDI specification only | ||
Then We should have a metadata model with <NumberOfVariables> variables | ||
And We should have <NumberOfStringVariables> of type STRING | ||
|
||
Examples: | ||
# Parameters : | ||
# - Directory : Directory of test campaigns | ||
# - NumberOfVariables : Expected number of variables identified in Lunatic Json File | ||
# - NumberOfStringVariables : Expected number of variables of String Type | ||
|
||
|Directory |NumberOfVariables | NumberOfStringVariables | | ||
|SAMPLETEST-METADATA |370 | 163 | |
Oops, something went wrong.