From 51ef0ab0ac81681320b89b1e4cd4cb94eaf98d8f Mon Sep 17 00:00:00 2001 From: QDIBYS Date: Thu, 28 Nov 2024 15:55:51 +0100 Subject: [PATCH 1/2] Genesis stops looking for DDI if lunatic only --- .../api/process/MainProcessingGenesis.java | 3 ++- .../core/inputs/UserInputsGenesis.java | 18 +++++++++------- .../core/inputs/UserInputsGenesisTest.java | 21 ++++++++++++++++++- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/process/MainProcessingGenesis.java b/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/process/MainProcessingGenesis.java index 2aca12be..54974e6e 100644 --- a/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/process/MainProcessingGenesis.java +++ b/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/process/MainProcessingGenesis.java @@ -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); diff --git a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesis.java b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesis.java index 1e232805..6e3d0ee3 100644 --- a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesis.java +++ b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesis.java @@ -22,21 +22,21 @@ public class UserInputsGenesis extends UserInputs{ private final List modes; - public UserInputsGenesis(boolean hasConfigFile, Path inputDirectory, List modes, FileUtilsInterface fileUtilsInterface) throws KraftwerkException { + public UserInputsGenesis(boolean hasConfigFile, Path inputDirectory, List 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); } } @@ -47,10 +47,14 @@ 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()); + } else { + 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"); diff --git a/kraftwerk-core/src/test/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesisTest.java b/kraftwerk-core/src/test/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesisTest.java index 09017ded..a4d0a9a4 100644 --- a/kraftwerk-core/src/test/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesisTest.java +++ b/kraftwerk-core/src/test/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesisTest.java @@ -24,7 +24,7 @@ void testReadValidUserInput_singleMode() throws KraftwerkException { List 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()); @@ -36,4 +36,23 @@ void testReadValidUserInput_singleMode() throws KraftwerkException { assertNull(userInputsGenesis.getVtlTransformationsFile()); assertNull(userInputsGenesis.getVtlInformationLevelsFile()); } + + @Test + void testReadValidUserInput_singleMode_lunatic_only() throws KraftwerkException { + List 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()); + } } From e8dffe779d3df26350a80dbc536bf3093f97bced Mon Sep 17 00:00:00 2001 From: QDIBYS Date: Thu, 12 Dec 2024 17:17:30 +0100 Subject: [PATCH 2/2] Look for lunatic even if withDDI true --- .../java/fr/insee/kraftwerk/core/inputs/UserInputsGenesis.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesis.java b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesis.java index 6e3d0ee3..d98ce99a 100644 --- a/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesis.java +++ b/kraftwerk-core/src/main/java/fr/insee/kraftwerk/core/inputs/UserInputsGenesis.java @@ -51,9 +51,8 @@ private ModeInputs getModeInputs(Mode mode, boolean withDDI) throws KraftwerkExc ModeInputs modeInputs = new ModeInputs(); if (withDDI) { modeInputs.setDdiUrl(findDDIFile(inputDirectory.resolve(mode.name())).toString()); - } else { - modeInputs.setLunaticFile(findLunaticFile(inputDirectory.resolve(mode.name()))); } + modeInputs.setLunaticFile(findLunaticFile(inputDirectory.resolve(mode.name()))); modeInputs.setDataMode(mode.name()); if (mode == Mode.WEB || mode == Mode.TEL || mode == Mode.F2F) {