Skip to content

Commit 3afc62e

Browse files
committed
issue #278
1 parent 9d49da7 commit 3afc62e

File tree

9 files changed

+420
-175
lines changed

9 files changed

+420
-175
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 7.4.0
2+
- adding timelines for link checking (issue https://github.com/clarin-eric/curation-dashboard/issues/278)
3+
14
# 7.3.1
25
- fix for maven lookup (issue https://github.com/clarin-eric/curation-dashboard/issues/281)
36

curation-app/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
<version>${project.version}</version>
2626
<scope>compile</scope>
2727
</dependency>
28+
<dependency>
29+
<groupId>eu.clarin.cmdi</groupId>
30+
<artifactId>curation-chart</artifactId>
31+
<version>${project.version}</version>
32+
<scope>compile</scope>
33+
</dependency>
2834
<dependency>
2935
<groupId>com.h2database</groupId>
3036
<artifactId>h2</artifactId>

curation-app/src/main/java/eu/clarin/cmdi/curation/app/CurationApp.java

Lines changed: 256 additions & 173 deletions
Large diffs are not rendered by default.

curation-app/src/main/resources/xslt/AllLinkcheckerReport2HTML.xsl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
</td>
5454
</tr>
5555
</xsl:for-each>
56-
5756
</tbody>
5857
<tfoot>
5958
<tr>
@@ -70,6 +69,8 @@
7069
</tr>
7170
</tfoot>
7271
</table>
72+
<br />
73+
<img src="/img/linkchecker/Overall.png" alt="timeline of link checking results" width="800" higth="200" />
7374
<br/>
7475
<h3>Metadata Providers:</h3>
7576

@@ -129,6 +130,13 @@
129130
</tfoot>
130131
</table>
131132
<br/>
133+
<img alt="timeline of link checking results" width="800" higth="200">
134+
<xsl:attribute name="src">
135+
<xsl:text>/img/linkchecker/</xsl:text>
136+
<xsl:value-of select="$name" />
137+
<xsl:text>.png</xsl:text>
138+
</xsl:attribute>
139+
</img>
132140
</xsl:for-each>
133141
</xsl:template>
134142
</xsl:stylesheet>

curation-app/src/main/resources/xslt/CollectionReport2HTML.xsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,14 @@
697697
</xsl:for-each>
698698
</tbody>
699699
</table>
700+
<br/>
701+
<img alt="timeline of link checking results" width="800" higth="200">
702+
<xsl:attribute name="src">
703+
<xsl:text>/img/linkchecker/</xsl:text>
704+
<xsl:value-of select="//fileReport/provider" />
705+
<xsl:text>.png</xsl:text>
706+
</xsl:attribute>
707+
</img>
700708
</xsl:if>
701709
</xsl:template>
702710
</xsl:stylesheet>

curation-chart/pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<parent>
4+
<groupId>eu.clarin.cmdi</groupId>
5+
<artifactId>curation-dashboard</artifactId>
6+
<version>${revision}</version>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
<artifactId>curation-chart</artifactId>
10+
<name>curation-chart</name>
11+
<dependencies>
12+
<dependency>
13+
<groupId>org.jfree</groupId>
14+
<artifactId>jfreechart</artifactId>
15+
<version>1.5.4</version>
16+
</dependency>
17+
</dependencies>
18+
</project>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package eu.clarin.cmdi.curation.chart;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.jfree.chart.ChartFactory;
5+
import org.jfree.chart.ChartUtils;
6+
import org.jfree.chart.JFreeChart;
7+
import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2;
8+
import org.jfree.data.time.Day;
9+
import org.jfree.data.time.TimeTableXYDataset;
10+
11+
import java.io.File;
12+
import java.io.IOException;
13+
import java.nio.file.Files;
14+
import java.nio.file.Path;
15+
import java.util.Date;
16+
import java.util.HashMap;
17+
import java.util.Map;
18+
19+
@Slf4j
20+
public class StackedAreaChartFactory {
21+
22+
final HashMap<String, TimeTableXYDataset> datasets;
23+
24+
private String chartTitle;
25+
private String xAxisLabel;
26+
private String yAxisLabel;
27+
28+
private int width;
29+
private int height;
30+
31+
private StackedAreaChartFactory() {
32+
33+
this.datasets = new HashMap<>();
34+
}
35+
36+
public static StackedAreaChartFactory newInstance() {
37+
38+
return new StackedAreaChartFactory();
39+
}
40+
41+
public void setLabels(String chartTitle, String xAxisLabel, String yAxisLabel) {
42+
this.chartTitle = chartTitle;
43+
this.xAxisLabel = xAxisLabel;
44+
this.yAxisLabel = yAxisLabel;
45+
}
46+
47+
public void setDimensions(int width, int height) {
48+
49+
this.width = width;
50+
this.height = height;
51+
}
52+
53+
public void addXY(String datasetName, String seriesName, Date date, Double value){
54+
55+
this.datasets.computeIfAbsent(datasetName, k -> new TimeTableXYDataset()).add(new Day(date), value, seriesName);
56+
}
57+
58+
public void save(Path outputDir, String datasetName) throws IOException {
59+
60+
if(datasets.containsKey(datasetName)){
61+
62+
JFreeChart chart = ChartFactory.createTimeSeriesChart(this.chartTitle, this.xAxisLabel, this.yAxisLabel, datasets.get(datasetName));
63+
chart.getXYPlot().setRenderer(new StackedXYAreaRenderer2());
64+
65+
ChartUtils.saveChartAsPNG(new File(outputDir.toFile(), datasetName + ".png"), chart, this.width, this.height);
66+
}
67+
else{
68+
69+
log.error("Dataset '{}' does not exist", datasetName);
70+
}
71+
}
72+
73+
public void saveAll(Path outputDir) throws IOException {
74+
75+
for (Map.Entry<String, TimeTableXYDataset> entry : this.datasets.entrySet()) {
76+
77+
JFreeChart chart = ChartFactory.createTimeSeriesChart(this.chartTitle, this.xAxisLabel, this.yAxisLabel, entry.getValue());
78+
chart.getXYPlot().setRenderer(new StackedXYAreaRenderer2());
79+
80+
ChartUtils.saveChartAsPNG(new File(outputDir.toFile(), entry.getKey() + ".png"), chart, this.width, this.height);
81+
}
82+
}
83+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package eu.clarin.cmdi.curation.web.controller;
2+
3+
import eu.clarin.cmdi.curation.web.conf.WebConfig;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.http.MediaType;
6+
import org.springframework.http.ResponseEntity;
7+
import org.springframework.stereotype.Controller;
8+
import org.springframework.web.bind.annotation.GetMapping;
9+
import org.springframework.web.bind.annotation.PathVariable;
10+
import org.springframework.web.bind.annotation.RequestMapping;
11+
12+
import java.io.IOException;
13+
import java.nio.file.Files;
14+
import java.nio.file.Path;
15+
16+
@Controller
17+
@RequestMapping("/img")
18+
public class ImageCtl {
19+
20+
@Autowired
21+
WebConfig conf;
22+
23+
@GetMapping("/{curationEntityType}/{fileName}")
24+
public ResponseEntity<byte[]> getImage(@PathVariable("curationEntityType") String curationEntityType,@PathVariable("fileName") String fileName) throws IOException {
25+
26+
Path imageFilePath = conf.getDirectory().getOut().resolve("img").resolve(curationEntityType).resolve(fileName).normalize();
27+
28+
if (imageFilePath.startsWith(this.conf.getDirectory().getOut()) && Files.exists(imageFilePath)) {
29+
30+
return ResponseEntity.ok().contentType(MediaType.IMAGE_PNG).body(Files.readAllBytes(imageFilePath));
31+
}
32+
33+
return ResponseEntity.notFound().build();
34+
}
35+
}

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<maven.compiler.target>21</maven.compiler.target>
2323
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2424
<linkchecker-persistence.version>2.0.0</linkchecker-persistence.version>
25-
<revision>7.3.2-SNAPSHOT</revision>
25+
<revision>7.4.0-SNAPSHOT</revision>
2626
<vlo.version>4.12.1</vlo.version>
2727
<vtd.version>2.11</vtd.version>
2828
<saxon.version>12.3</saxon.version>
@@ -145,6 +145,7 @@
145145
<module>curation-api</module>
146146
<module>curation-app</module>
147147
<module>curation-web</module>
148+
<module>curation-chart</module>
148149
</modules>
149150
<dependencyManagement>
150151
<dependencies>

0 commit comments

Comments
 (0)