Error handling for non existing speeches
This commit is contained in:
parent
e65abe88bc
commit
a21c19ab75
3 changed files with 53 additions and 36 deletions
|
@ -623,6 +623,7 @@ public class MongoPprUtils {
|
|||
System.out.println("SpeechDoc "+ speechDoc); // TODO: remove when no longer needed
|
||||
if (speechDoc == null) {
|
||||
Logger.error("Rede " + key + " nicht gefunden");
|
||||
return null;
|
||||
}
|
||||
|
||||
return new HtmlSpeech(speechDoc);
|
||||
|
|
|
@ -72,6 +72,11 @@ public class SpeechController {
|
|||
Map<String, Object> attributes = new HashMap<>();
|
||||
|
||||
HtmlSpeech speech = MongoPprUtils.getSpeechByKey(redeId);
|
||||
if (speech == null) {
|
||||
attributes.put("error", "Rede " + redeId + " nicht vorhanden");
|
||||
ctx.render("speech.ftl", attributes);
|
||||
return;
|
||||
}
|
||||
attributes.put("s", speech);
|
||||
|
||||
// Foto des Abgeordnetes
|
||||
|
|
|
@ -4,7 +4,13 @@
|
|||
<link rel="stylesheet" href="/index.css">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Rede von ${s.speakerName} <#if s.fraction??> (${s.fraction}) </#if></title>
|
||||
<title>
|
||||
<#if s??>
|
||||
Rede von ${s.speakerName} <#if s.fraction??> (${s.fraction}) </#if>
|
||||
<#else>
|
||||
Fehler
|
||||
</#if>
|
||||
</title>
|
||||
<style type="text/css">
|
||||
th, td {
|
||||
padding: 12px;
|
||||
|
@ -15,47 +21,52 @@
|
|||
</head>
|
||||
<#include "header.ftl">
|
||||
<body>
|
||||
<script src="https://d3js.org/d3.v7.min.js"></script>
|
||||
<h1>
|
||||
Rede von ${s.speakerName}
|
||||
<#if s.fraction??> (${s.fraction}) </#if>
|
||||
<#if s.dateTimeString??> vom ${s.dateTimeString} </#if>
|
||||
</h1>
|
||||
<#if s??>
|
||||
<script src="https://d3js.org/d3.v7.min.js"></script>
|
||||
<h1>
|
||||
Rede von ${s.speakerName}
|
||||
<#if s.fraction??> (${s.fraction}) </#if>
|
||||
<#if s.dateTimeString??> vom ${s.dateTimeString} </#if>
|
||||
</h1>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<h2>
|
||||
Rede ${s.speechKey}
|
||||
<#if s.agendaTitle??> / Agendapunkt: ${s.agendaTitle} </#if>
|
||||
</h2>
|
||||
<h2>
|
||||
Rede ${s.speechKey}
|
||||
<#if s.agendaTitle??> / Agendapunkt: ${s.agendaTitle} </#if>
|
||||
</h2>
|
||||
|
||||
<br>
|
||||
<main>
|
||||
<#if picture??>
|
||||
<div class="centered-content">
|
||||
<img style="max-width: 400px; height: auto; margin-bottom: 20px" src="data:image/jpeg;base64,${picture}" alt="Foto von ${s.speakerName}" />
|
||||
</div>
|
||||
<br>
|
||||
<main>
|
||||
<#if picture??>
|
||||
<div class="centered-content">
|
||||
<img style="max-width: 400px; height: auto; margin-bottom: 20px" src="data:image/jpeg;base64,${picture}" alt="Foto von ${s.speakerName}" />
|
||||
</div>
|
||||
<#else>
|
||||
<h2>(kein Foto verfügbar)</h2>
|
||||
</#if>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<#list s.content as c>
|
||||
<#include "speechContent.ftl">
|
||||
</#list>
|
||||
|
||||
<br><br>
|
||||
<#if s.nlp??>
|
||||
<h2>NLP Information</h2>
|
||||
<#assign nlp = "${s.nlp}">
|
||||
<#include "nlp.ftl">
|
||||
<#else>
|
||||
<h2>Keine NLP Information verfügbar für diese Rede</h2>
|
||||
</#if>
|
||||
<br> <br>
|
||||
|
||||
</main>
|
||||
<#else>
|
||||
<h2>(kein Foto verfügbar)</h2>
|
||||
<h2> ${error} </h2>
|
||||
</#if>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<#list s.content as c>
|
||||
<#include "speechContent.ftl">
|
||||
</#list>
|
||||
|
||||
<br><br>
|
||||
<#if s.nlp??>
|
||||
<h2>NLP Information</h2>
|
||||
<#assign nlp = "${s.nlp}">
|
||||
<#include "nlp.ftl">
|
||||
<#else>
|
||||
<h2>Keine NLP Information verfügbar für diese Rede</h2>
|
||||
</#if>
|
||||
<br> <br>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
<#include "footer.ftl">
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue