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

Genesis stops looking for DDI if lunatic only #200

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public void init(String idCampaign) throws KraftwerkException {
inDirectory = controlInputSequenceGenesis.getInDirectory(idCampaign);
//First we check the modes present in database for the given questionnaire
//We build userInputs for the given questionnaire
userInputs = new UserInputsGenesis(controlInputSequenceGenesis.isHasConfigFile(), inDirectory, client.getModes(idCampaign), fileUtilsInterface);
userInputs = new UserInputsGenesis(controlInputSequenceGenesis.isHasConfigFile(), inDirectory,
client.getModes(idCampaign), fileUtilsInterface, withDDI);
if (!userInputs.getModes().isEmpty()) {
try {
metadataModels = withDDI ? MetadataUtilsGenesis.getMetadata(userInputs.getModeInputsMap(), fileUtilsInterface): MetadataUtilsGenesis.getMetadataFromLunatic(userInputs.getModeInputsMap(), fileUtilsInterface);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ public class UserInputsGenesis extends UserInputs{

private final List<Mode> modes;

public UserInputsGenesis(boolean hasConfigFile, Path inputDirectory, List<Mode> modes, FileUtilsInterface fileUtilsInterface) throws KraftwerkException {
public UserInputsGenesis(boolean hasConfigFile, Path inputDirectory, List<Mode> modes, FileUtilsInterface fileUtilsInterface, boolean withDDI) throws KraftwerkException {
super(inputDirectory, fileUtilsInterface);
this.hasConfigFile = hasConfigFile;
this.modes=modes;
computeInputs();
computeInputs(withDDI);
}

private void computeInputs() throws KraftwerkException {
private void computeInputs(boolean withDDI) throws KraftwerkException {
UserInputsFile userInputsFile;
if(hasConfigFile){
userInputsFile = new UserInputsFile(inputDirectory.resolve(Constants.USER_INPUT_FILE), inputDirectory, fileUtilsInterface);
modeInputsMap = userInputsFile.getModeInputsMap();
}else{
for (Mode mode : modes) {
ModeInputs modeInputs = getModeInputs(mode);
ModeInputs modeInputs = getModeInputs(mode, withDDI);
modeInputsMap.put(mode.name(), modeInputs);
}
}
Expand All @@ -47,10 +47,13 @@ private void computeInputs() throws KraftwerkException {
* @param mode mode to get inputs from
* @return a ModeInputs object
*/
private ModeInputs getModeInputs(Mode mode) throws KraftwerkException {
private ModeInputs getModeInputs(Mode mode, boolean withDDI) throws KraftwerkException {
ModeInputs modeInputs = new ModeInputs();
modeInputs.setDdiUrl(findDDIFile(inputDirectory.resolve(mode.name())).toString());
modeInputs.setLunaticFile(findLunaticFile(inputDirectory.resolve(mode.name())));
if (withDDI) {
modeInputs.setDdiUrl(findDDIFile(inputDirectory.resolve(mode.name())).toString());
}
modeInputs.setLunaticFile(findLunaticFile(inputDirectory.resolve(mode.name())));

modeInputs.setDataMode(mode.name());
if (mode == Mode.WEB || mode == Mode.TEL || mode == Mode.F2F) {
modeInputs.setDataFormat("LUNATIC_XML");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void testReadValidUserInput_singleMode() throws KraftwerkException {
List<Mode> modes = new ArrayList<>();
modes.add(Mode.F2F);

UserInputsGenesis userInputsGenesis = new UserInputsGenesis(false, inputSamplesDirectory.resolve("Valid"), modes, new FileSystemImpl(TestConstants.TEST_RESOURCES_DIRECTORY));
UserInputsGenesis userInputsGenesis = new UserInputsGenesis(false, inputSamplesDirectory.resolve("Valid"), modes, new FileSystemImpl(TestConstants.TEST_RESOURCES_DIRECTORY), true);
//
ModeInputs modeInputs = userInputsGenesis.getModeInputs("F2F");
assertNotNull(modeInputs.getDdiUrl());
Expand All @@ -36,4 +36,23 @@ void testReadValidUserInput_singleMode() throws KraftwerkException {
assertNull(userInputsGenesis.getVtlTransformationsFile());
assertNull(userInputsGenesis.getVtlInformationLevelsFile());
}

@Test
void testReadValidUserInput_singleMode_lunatic_only() throws KraftwerkException {
List<Mode> modes = new ArrayList<>();
modes.add(Mode.F2F);

UserInputsGenesis userInputsGenesis = new UserInputsGenesis(false, inputSamplesDirectory.resolve("Valid"), modes, new FileSystemImpl(TestConstants.TEST_RESOURCES_DIRECTORY), false);
//
ModeInputs modeInputs = userInputsGenesis.getModeInputs("F2F");
assertNull(modeInputs.getDdiUrl());
assertNotNull(modeInputs.getLunaticFile());
assertEquals(DataFormat.LUNATIC_XML, modeInputs.getDataFormat());
assertNull(modeInputs.getParadataFolder());
assertNull(modeInputs.getModeVtlFile());
//
assertNull(userInputsGenesis.getVtlReconciliationFile());
assertNull(userInputsGenesis.getVtlTransformationsFile());
assertNull(userInputsGenesis.getVtlInformationLevelsFile());
}
}
Loading