Index: topia-service/src/java/org/codelutin/topia/migration/kernel/ConfigurationHelper.java diff -u topia-service/src/java/org/codelutin/topia/migration/kernel/ConfigurationHelper.java:1.1 topia-service/src/java/org/codelutin/topia/migration/kernel/ConfigurationHelper.java:1.2 --- topia-service/src/java/org/codelutin/topia/migration/kernel/ConfigurationHelper.java:1.1 Mon Apr 2 14:24:37 2007 +++ topia-service/src/java/org/codelutin/topia/migration/kernel/ConfigurationHelper.java Thu Apr 19 10:02:38 2007 @@ -22,6 +22,7 @@ import java.io.File; import java.io.IOException; import java.io.StringReader; +import java.util.ArrayList; import java.util.List; import javax.xml.parsers.DocumentBuilder; @@ -49,9 +50,9 @@ * @author Chevallereau Benjamin * @author Eon Sébastien * @author Trève Vincent - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * - * Last update : $Date: 2007/04/02 14:24:37 $ + * Last update : $Date: 2007/04/19 10:02:38 $ */ public class ConfigurationHelper { @@ -71,6 +72,9 @@ * Retourne une configuration correspondant au chargement * de tous les mappings du dossier specifie. * + * Ici, on pourrait utiliser configuration.addDirectory + * mais on modifie les mappings version "entity-map" + * * @param pathDirectory Le dossier ou se trouvent les mappings * @return La configuration associee */ @@ -90,9 +94,10 @@ } logger.debug("Loading mappings in " + mappingDir.getAbsolutePath()); - File[] filesInIt = mappingDir.listFiles(); + // TODO chagement 20070419 fonction a tester + List filesInIt = recursiveListFiles(mappingDir); - if (filesInIt != null && filesInIt.length > 0) { + if (filesInIt != null && filesInIt.size() > 0) { // s'il y a des fichier a charger configuration = new Configuration(); @@ -118,6 +123,30 @@ } /** + * Liste recursivement les fichiers d'un repertoire un les filtrant + * via leur nom + * + * @param mappingDir le dossier a lister + * @param regexFilename le filtre + * @return une liste de fichier + */ + private List recursiveListFiles(File currentDir) { + + List localFiles = new ArrayList(); + for(File f : currentDir.listFiles()) { + // dossier + if(f.isDirectory()) { + localFiles.addAll(recursiveListFiles(f)); + } + else { + // ou fichier + localFiles.add(f); + } + } + return localFiles; + } + + /** * Charge un fichier et retourne un mapping valide pour etre manipule via les map * * @param fichier le nom du fichier