package fr.insee.eno.generation;

import java.io.File;

import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import fr.insee.eno.Constants;

public class IdentityGenerator implements Generator {

	private static final Logger logger = LoggerFactory.getLogger(IdentityGenerator.class);

	@Override
	public File generate(File finalInput, byte[] parameters, String surveyName) throws Exception {
		logger.info("Identity generation : START");
		logger.info("Identity generation : simply copying input file in another file");
		String outputForm = Constants.TEMP_FOLDER_PATH + "/" + surveyName + "/ddi33/out.xml";
		FileUtils.copyFile(finalInput, new File(outputForm));
		logger.info("Identity generation : END");
		return new File(outputForm);
	}

	public String in2out() {
		return "identity";
	}	
}

@@ -89,16 +89,60 @@
 eUtils;%0A
+import org.apache.commons.io.FilenameUtils;%0A
 import o
@@ -221,16 +221,65 @@
 nstants;
+%0Aimport fr.insee.eno.transform.xsl.XslParameters;
 %0A%0Apublic
@@ -657,223 +657,961 @@
 ;%0A%09%09
-String outputForm = Constants.TEMP_FOLDER_PATH + %22/%22 + surveyName + %22/ddi33/out.xml%22;%0A%09%09FileUtils.copyFile(finalInput, new File(outputForm));%0A%09%09logger.info(%22Identity generation : END%22);%0A%09%09return new File(outputForm)
+logger.debug(%22Arguments : finalInput : %22 + finalInput + %22 surveyName %22 + surveyName);%0A%09%09String formNameFolder = null;%0A%09%09String outputBasicFormPath = null;%0A%0A%09%09formNameFolder = getFormNameFolder(finalInput);%0A%0A%09%09logger.debug(%22formNameFolder : %22 + formNameFolder);%0A%09%09outputBasicFormPath = Constants.TEMP_FOLDER_PATH + %22/%22 + surveyName + %22/%22 + formNameFolder + %22/form%22;%0A%09%09logger.debug(%22Output folder for basic-form : %22 + outputBasicFormPath);%0A%09%09String outputForm = outputBasicFormPath + %22/form.xml%22;%0A%09%09FileUtils.copyFile(finalInput, new File(outputForm));%0A%09%09logger.info(%22Identity generation : END%22);%0A%09%09return new File(outputForm);%0A%09%7D%0A%09%0A%09private String getFormNameFolder(File finalInput) %7B%0A%09%09String formNameFolder;%0A%09%09formNameFolder = FilenameUtils.getBaseName(finalInput.getAbsolutePath());%0A%09%09formNameFolder = FilenameUtils.removeExtension(formNameFolder);%0A%09%09formNameFolder = formNameFolder.replace(XslParameters.TITLED_EXTENSION, %22%22);%0A%09%09return formNameFolder
 ;%0A%09%7D

Update IdentityGenerator.java