Skip to content

Commit 7ca4447

Browse files
committed
fix checkstyle
1 parent a521897 commit 7ca4447

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

src/main/java/de/uksh/medic/etl/MedicEtlToolkit.java

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,26 @@ private static void sendToErrorTopic(KafkaProducer<String, String> producer, Str
349349
}
350350
}
351351

352+
private static void precompileGroovyScript(Mapping m) {
353+
if (Settings.getDev()) {
354+
return;
355+
}
356+
File groovyFile = new File("scripts", m.getTemplateId() + ".groovy");
357+
if (!groovyFile.exists()) {
358+
return;
359+
}
360+
if (groovyClassLoader == null) {
361+
groovyClassLoader = new GroovyClassLoader();
362+
}
363+
try {
364+
Class<? extends Script> scriptClass = groovyClassLoader.parseClass(groovyFile);
365+
GROOVY_SCRIPTS.put(m.getTemplateId(), scriptClass);
366+
Logger.info("Pre-compiled Groovy script for template: {}", m.getTemplateId());
367+
} catch (IOException e) {
368+
Logger.error("Failed to pre-compile Groovy script for template {}: {}", m.getTemplateId(), e);
369+
}
370+
}
371+
352372
private static void initializeAttribute(Mapping m, ObjectMapper mapper) {
353373
if (m.getTemplateId() != null) {
354374
OPERATIONALTEMPLATE template = null;
@@ -370,23 +390,7 @@ private static void initializeAttribute(Mapping m, ObjectMapper mapper) {
370390
opts.setSaveSyntheticDocumentElement(new QName("http://schemas.openehr.org/v1", "template"));
371391
PARSERS.put(m.getTemplateId(), new EHRParser(template.xmlText(opts)));
372392

373-
// Pre-compile Groovy script for this template
374-
if (!Settings.getDev()) {
375-
File groovyFile = new File("scripts", m.getTemplateId() + ".groovy");
376-
if (!groovyFile.exists()) {
377-
return;
378-
}
379-
if (groovyClassLoader == null) {
380-
groovyClassLoader = new GroovyClassLoader();
381-
}
382-
try {
383-
Class<? extends Script> scriptClass = groovyClassLoader.parseClass(groovyFile);
384-
GROOVY_SCRIPTS.put(m.getTemplateId(), scriptClass);
385-
Logger.info("Pre-compiled Groovy script for template: {}", m.getTemplateId());
386-
} catch (IOException e) {
387-
Logger.error("Failed to pre-compile Groovy script for template {}: {}", m.getTemplateId(), e);
388-
}
389-
}
393+
precompileGroovyScript(m);
390394
}
391395

392396
if (m.getSource() == null) {

0 commit comments

Comments
 (0)