Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit f448495

Browse files
committed
refine example templates, fix UTF output (SORMAS-Foundation#2906, SORMAS-Foundation#4057)
1 parent 8b686c9 commit f448495

File tree

8 files changed

+110
-128
lines changed

8 files changed

+110
-128
lines changed

sormas-backend/src/main/java/de/symeda/sormas/backend/docgeneration/TemplateEngine.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.InputStreamReader;
2626
import java.io.Reader;
2727
import java.io.StringWriter;
28+
import java.nio.charset.StandardCharsets;
2829
import java.util.HashSet;
2930
import java.util.Properties;
3031
import java.util.Set;
@@ -163,6 +164,7 @@ public String generateDocumentTxt(Properties properties, File templateFile) {
163164
template.merge(velocityContext, stringWriter);
164165
OutputSettings outputSettings = new OutputSettings();
165166
outputSettings.prettyPrint(false);
167+
outputSettings.charset(StandardCharsets.UTF_8);
166168
return Jsoup.clean(stringWriter.toString(), "", HTML_TEMPLATE_WHITELIST, outputSettings);
167169
}
168170

sormas-cargoserver/src/main/resources/layout/sormasfolders/custom/docgeneration/eventHandout/EventHandout.html

Lines changed: 0 additions & 68 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<h1>Event: $event.eventTitle</h1>
2+
<h2>$event.uuid</h2>
3+
4+
<p>
5+
Event status: <b>$!event_eventStatus</b><br/>
6+
Event date: <b>$!event_startDate</b>
7+
</p>
8+
9+
<p>
10+
Region: <b>$event_eventLocation_region</b><br/>
11+
District: <b>$event_eventLocation_district</b><br/>
12+
Community: <b>$!event_eventLocation_community</b>
13+
</p>
14+
15+
<p>Reported: $event_reportDateTime by $event_reportingUser_firstName $event_reportingUser_lastName</p>
16+
17+
<h2>Description</h2>
18+
19+
<p>$!event.eventDesc</p>
20+
21+
<h1>Actions</h1>
22+
23+
#foreach($action in $eventActions)
24+
<div class="actions">
25+
<h2>$action.title</h2>
26+
<p>
27+
date: $F.format($action.getDate())<br/>
28+
status: $!action.getStatus()<br/>
29+
status changed: $!F.format($action.getStatusChangeDate())<br/>
30+
created: $F.format($action.getCreationDate())<br/>
31+
modified: $!F.format($action.getChangeDate())
32+
</p>
33+
<div>#if($action.getDescription()) $action.getDescription() #else <span class="red">*</span> #end</div>
34+
<div>#if($action.reply) $action.reply #else <span class="red">*</span> #end</div>
35+
</div>
36+
#end
37+
38+
<h1>Event Participants</h1>
39+
40+
<table>
41+
<tr>
42+
<th>Name</th>
43+
<th>Address</th>
44+
<th>City</th>
45+
<th>Phone</th>
46+
<th>Email</th>
47+
</tr>
48+
#foreach($participant in $eventParticipants)
49+
<tr>
50+
<td>$!participant.getPerson().firstName $!participant.getPerson().lastName</td>
51+
<td>$!participant.getPerson().address.street $!participant.getPerson().address.houseNumber</td>
52+
<td>$!participant.getPerson().address.postalCode $!participant.getPerson().address.city</td>
53+
<td>$!participant.getPerson().phone</td>
54+
<td>$!participant.getPerson().emailAddress</td>
55+
</tr>
56+
#end
57+
</table>

sormas-ui/src/main/java/de/symeda/sormas/ui/docgeneration/EventDocumentLayout.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package de.symeda.sormas.ui.docgeneration;
1717

1818
import java.io.ByteArrayInputStream;
19+
import java.nio.charset.StandardCharsets;
1920
import java.util.List;
2021

2122
import com.vaadin.server.Page;
@@ -63,7 +64,8 @@ protected StreamResource createStreamResource(String templateFile, String filena
6364
EventDocumentFacade eventDocumentFacade = FacadeProvider.getEventDocumentFacade();
6465
try {
6566
return new ByteArrayInputStream(
66-
eventDocumentFacade.getGeneratedDocument(templateFile, eventReferenceDto, readAdditionalVariables()).getBytes());
67+
eventDocumentFacade.getGeneratedDocument(templateFile, eventReferenceDto, readAdditionalVariables())
68+
.getBytes(StandardCharsets.UTF_8));
6769
} catch (Exception e) {
6870
e.printStackTrace();
6971
new Notification(I18nProperties.getString(Strings.errorProcessingTemplate), e.getMessage(), Notification.Type.ERROR_MESSAGE)
Lines changed: 48 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,57 @@
1-
<html>
2-
<header>
3-
<style type="text/css">
4-
* {
5-
font-family: "Open Sans", sans-serif, "Source Sans Pro";
6-
font-size: 12px;
7-
}
8-
h1 {
9-
font-size: 2.4em;
10-
color: #005A9C;
11-
}
12-
h2 {
13-
font-size: 1.6em;
14-
color: #6591C4;
15-
}
16-
table, td, th {
17-
border: 1px solid black;
18-
border-collapse: collapse;
19-
}
20-
td, th {
21-
padding: 5px;
22-
}
23-
th {
24-
font-weight: bold;
25-
}
26-
.actions > div {
27-
box-shadow: inset 0 0 4px #CDD8EC;
28-
border-radius: 4px;
29-
padding: 10px;
30-
background-color: #F7F8F8;
31-
width: 900px;
32-
margin: 10px;
33-
}
34-
div.actions {
35-
margin-bottom: 35px;
36-
}
37-
</style>
38-
</header>
39-
<body>
40-
<h1>$event.eventTitle</h1>
41-
<p>Event-ID: <b>$event.uuid</b></p>
1+
<h1>Event: $event.eventTitle</h1>
2+
<h2>$event.uuid</h2>
423

43-
<p>$event.eventDesc</p>
4+
<p>
5+
Event status: <b>$!event_eventStatus</b><br/>
6+
Event date: <b>$!event_startDate</b>
7+
</p>
448

45-
<table>
46-
<tr><th>Disease</th><th>Status</th><th>Event Date</th><th>Report Date</th></tr>
47-
<tr><td>$event.disease</td><td>$event.eventStatus</td><td>$F.format($event.startDate)</td><td>$F.format($event.reportDateTime)</td></tr>
48-
</table>
9+
<p>
10+
Region: <b>$event_eventLocation_region</b><br/>
11+
District: <b>$event_eventLocation_district</b><br/>
12+
Community: <b>$!event_eventLocation_community</b>
13+
</p>
4914

50-
<h2>Event Participants</h2>
15+
<p>Reported: $event_reportDateTime by $event_reportingUser_firstName $event_reportingUser_lastName</p>
5116

52-
<table>
53-
<tr><th>First Name</th><th>Last Name</th><th>Phone</th><th>Contacted</th></tr>
54-
#foreach($participant in $eventParticipants)
55-
<tr><td>$participant.person.firstName</td><td>$participant.person.lastName</td><td>$participant.person.phone</td><td>[ ]</td></tr>
56-
#end
57-
</table>
17+
<h2>Description</h2>
18+
19+
<p>$!event.eventDesc</p>
20+
21+
<h1>Actions</h1>
5822

59-
<h2>Actions</h2>
6023
#foreach($action in $eventActions)
6124
<div class="actions">
62-
<p>$F.format($action.getDate()) - <b style="color: #6591C4; font-size: 1.2em;">$action.title</b></p>
63-
<div>#if($action.getDescription()) $action.getDescription() #else <span style="color:#f00">*</span> #end</div>
64-
<div>#if($action.reply) $action.reply #else <span style="color:#f00">*</span> #end</div>
25+
<h2>$action.title</h2>
26+
<p>
27+
date: $F.format($action.getDate())<br/>
28+
status: $!action.getStatus()<br/>
29+
status changed: $!F.format($action.getStatusChangeDate())<br/>
30+
created: $F.format($action.getCreationDate())<br/>
31+
modified: $!F.format($action.getChangeDate())
32+
</p>
33+
<div>#if($action.getDescription()) $action.getDescription() #else <span class="red">*</span> #end</div>
34+
<div>#if($action.reply) $action.reply #else <span class="red">*</span> #end</div>
6535
</div>
6636
#end
67-
</body>
68-
</html>
37+
38+
<h1>Event Participants</h1>
39+
40+
<table>
41+
<tr>
42+
<th>Name</th>
43+
<th>Address</th>
44+
<th>City</th>
45+
<th>Phone</th>
46+
<th>Email</th>
47+
</tr>
48+
#foreach($participant in $eventParticipants)
49+
<tr>
50+
<td>$!participant.getPerson().firstName $!participant.getPerson().lastName</td>
51+
<td>$!participant.getPerson().address.street $!participant.getPerson().address.houseNumber</td>
52+
<td>$!participant.getPerson().address.postalCode $!participant.getPerson().address.city</td>
53+
<td>$!participant.getPerson().phone</td>
54+
<td>$!participant.getPerson().emailAddress</td>
55+
</tr>
56+
#end
57+
</table>

0 commit comments

Comments
 (0)