Skip to content

Commit

Permalink
Allowing the service startup to index all non-Gen Java classes includ…
Browse files Browse the repository at this point in the history
…ing pages 3 times
  • Loading branch information
computate committed Sep 12, 2023
1 parent a98058b commit 82e4854
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,6 @@ public void pageCodeClasseJava(String langueNom, YAMLConfiguration langueConfig)
if(hackathonPageGenLabels != null)
auteurPageClasse.l(String.format(" * Map.hackathonLabelsGen: %s", hackathonPageGenLabels));

auteurPageClasse.l(" * ", langueConfig.getString(ConfigCles.var_Traduire), ": false");
auteurPageClasse.l(" * ", langueConfig.getString(ConfigCles.var_Promesse), ": true");
for(String langueNom2 : autresLangues) {
YAMLConfiguration langueConfig2 = configurations.fileBased(YAMLConfiguration.class, String.format("%s/src/main/resources/org/computate/i18n/i18n_%s.yml", appComputate, classePageLangueNom));
Expand Down
61 changes: 34 additions & 27 deletions src/main/java/org/computate/frFR/java/RegarderRepertoire.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,33 +249,9 @@ public static void main(String[] args) throws Exception {
regarderRepertoire.ajouterCheminsARegarder(classeLangueConfig);

try {
String classeLangueNom = StringUtils.defaultString(System.getenv("SITE_LANG"), "frFR");
File dir = new File(String.format("%s/src/main/java", SITE_CHEMIN));
try (Stream<Path> stream = Files.walk(Paths.get(dir.getAbsolutePath()))) {
stream.filter(Files::isRegularFile)
.filter(chemin -> chemin.toString().endsWith(".java"))
.filter(chemin -> {
try {
return !FileUtils.readFileToString(chemin.toFile(), "UTF-8").contains("* Translate: false");
} catch(Exception ex) {
return false;
}
})
.forEach(chemin -> {
String cheminStr = chemin.toString();
// System.out.println(String.format("%s %s", chemin.toString().endsWith(".java"), chemin.toString()));
RegarderClasse regarderClasse = new RegarderClasse();
try {
regarderClasse.setArgs(new String[] {SITE_CHEMIN, cheminStr});
regarderClasse.initRegarderClasseBase(classeLangueNom, classeLangueConfig);
SolrInputDocument classeDoc = new SolrInputDocument();
regarderClasse.indexerClasse(cheminStr, classeDoc, classeLangueNom);
System.out.println(String.format("%s %s", classeLangueConfig.getString(ConfigCles.var_Indexe), cheminStr));
} catch(Exception ex) {
System.err.println(String.format("An exception occured while indexing files: %s", ExceptionUtils.getStackTrace(ex)));
}
});
}
indexerClasses(SITE_CHEMIN, classeLangueConfig);
indexerClasses(SITE_CHEMIN, classeLangueConfig);
indexerClasses(SITE_CHEMIN, classeLangueConfig);
} catch(Exception ex) {
System.out.println(String.format("Error indexing files on startup: %s", ex.getMessage()));
}
Expand All @@ -287,6 +263,37 @@ public static void main(String[] args) throws Exception {
System.err.println(ExceptionUtils.getStackTrace(e));
}
}

public static void indexerClasses(String SITE_CHEMIN, YAMLConfiguration classeLangueConfig) throws Exception {

String classeLangueNom = StringUtils.defaultString(System.getenv("SITE_LANG"), "frFR");
File dir = new File(String.format("%s/src/main/java", SITE_CHEMIN));
try (Stream<Path> stream = Files.walk(Paths.get(dir.getAbsolutePath()))) {
stream.filter(Files::isRegularFile)
.filter(chemin -> chemin.toString().endsWith(".java"))
.filter(chemin -> {
try {
return !FileUtils.readFileToString(chemin.toFile(), "UTF-8").contains("* Translate: false");
} catch(Exception ex) {
return false;
}
})
.forEach(chemin -> {
String cheminStr = chemin.toString();
// System.out.println(String.format("%s %s", chemin.toString().endsWith(".java"), chemin.toString()));
RegarderClasse regarderClasse = new RegarderClasse();
try {
regarderClasse.setArgs(new String[] {SITE_CHEMIN, cheminStr});
regarderClasse.initRegarderClasseBase(classeLangueNom, classeLangueConfig);
SolrInputDocument classeDoc = new SolrInputDocument();
regarderClasse.indexerClasse(cheminStr, classeDoc, classeLangueNom);
System.out.println(String.format("%s %s", classeLangueConfig.getString(ConfigCles.var_Indexe), cheminStr));
} catch(Exception ex) {
System.err.println(String.format("An exception occured while indexing files: %s", ExceptionUtils.getStackTrace(ex)));
}
});
}
}
/*
* r: cles
* r: observateur
Expand Down

0 comments on commit 82e4854

Please sign in to comment.