Skip to content

Commit

Permalink
issue #277
Browse files Browse the repository at this point in the history
  • Loading branch information
wowasa committed Feb 2, 2025
1 parent 0bdd90a commit f25a769
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 7.2.0
- adding collection history report (issue https://github.com/clarin-eric/curation-dashboard/issues/277)

# 7.1.2
- setting maximum CMDI file size to 100MB (issue https://github.com/clarin-eric/curation-dashboard/issues/275)
- upgrading to Spring Boot 3.4.1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package eu.clarin.cmdi.curation.api.report.collection;

import eu.clarin.cmdi.curation.api.report.LocalDateTimeAdapter;
import eu.clarin.cmdi.curation.api.report.NamedReport;
import jakarta.xml.bind.annotation.*;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.TreeMap;
import java.util.TreeSet;

@XmlRootElement
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class CollectionHistoryReport implements NamedReport {
@XmlAttribute
@XmlJavaTypeAdapter(LocalDateTimeAdapter.class)
public final LocalDateTime creationTime = LocalDateTime.now();
private final TreeMap<String, ProviderGroup> providerGroups = new TreeMap<>((pg1, pg2) -> pg1.compareTo(pg2));
@XmlElement(name = "collection")
public Collection<ProviderGroup> getCollections(){

return this.providerGroups.values();
}

public void addReport(String providerGroup, String isoDate, String fileName){

this.providerGroups.computeIfAbsent(providerGroup, k -> new ProviderGroup(k)).addReport(isoDate, fileName);
}

@Override
public String getName() {
return this.getClass().getSimpleName();
}

@Override
public LocalDateTime getCreationTime() {

return this.creationTime;
}

@Override
public void setPreviousCreationTime(LocalDateTime previousCreationTime) {

}

@Override
public LocalDateTime getPreviousCreationTime() {
return null;
}

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@RequiredArgsConstructor
@NoArgsConstructor(force = true)
private static class ProviderGroup{
@XmlAttribute
public final String name;
@XmlElement(name = "report")
public TreeSet<Report> reports = new TreeSet<>((report1, report2) -> report2.isoDate.compareTo(report1.isoDate));

public void addReport(String isoDate, String fileName){
this.reports.add(new Report(isoDate, fileName));
}
}
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@RequiredArgsConstructor
@NoArgsConstructor(force = true)
public static class Report {
@XmlAttribute
public final String isoDate;
@XmlAttribute
public final String fileName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import eu.clarin.cmdi.curation.api.CurationModule;
import eu.clarin.cmdi.curation.api.entity.CurationEntityType;
import eu.clarin.cmdi.curation.api.report.collection.AllCollectionReport;
import eu.clarin.cmdi.curation.api.report.collection.CollectionHistoryReport;
import eu.clarin.cmdi.curation.api.report.collection.CollectionReport;
import eu.clarin.cmdi.curation.api.report.linkchecker.AllLinkcheckerReport;
import eu.clarin.cmdi.curation.api.report.profile.AllProfileReport;
Expand Down Expand Up @@ -33,6 +34,8 @@
import java.nio.file.Path;
import java.time.LocalDateTime;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

/**
Expand All @@ -46,6 +49,8 @@
@EnableConfigurationProperties
@Slf4j
public class CurationApp {

private static final Pattern pattern = Pattern.compile("(\\S+)_(\\d{4}-\\d{2}-\\d{2}).html");

@Autowired
private AppConfig conf;
Expand Down Expand Up @@ -92,8 +97,9 @@ public CommandLineRunner commandLineRunner(ApplicationContext ctx) {


final AllCollectionReport allCollectionReport = new AllCollectionReport();
final AllLinkcheckerReport allLinkcheckerReport = new AllLinkcheckerReport();

final AllLinkcheckerReport allLinkcheckerReport = new AllLinkcheckerReport();
final CollectionHistoryReport collectionHistoryReport = new CollectionHistoryReport();

conf.getDirectory().getIn().forEach(inPath -> {
try {
processCollection(inPath, allCollectionReport,allLinkcheckerReport );
Expand All @@ -103,8 +109,20 @@ public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
}
});

// we create a meta report of all collection reports
Files.walk(conf.getDirectory().getOut().resolve("html").resolve("collection")).forEach(path -> {

Matcher matcher;

if(!path.getFileName().toString().startsWith("AllCollectionReport") && (matcher = pattern.matcher(path.getFileName().toString())).matches()) {

collectionHistoryReport.addReport(matcher.group(1).replaceAll("_", " ").trim(), matcher.group(2), path.getFileName().toString());
}
});

storage.saveReport(allCollectionReport, CurationEntityType.COLLECTION, true);
storage.saveReport(allLinkcheckerReport, CurationEntityType.LINKCHECKER, true);
storage.saveReport(collectionHistoryReport, CurationEntityType.COLLECTION, false);

}
// it's important to process profiles after collections, to fill the collection usage section of the profiles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
</xsl:for-each>
</tbody>
</table>
<div class="floatRight">
<a href="/collection/CollectionHistoryReport.html">report history</a>
</div>
</body>
</html>
</xsl:template>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/collectionHistoryReport">
<xsl:for-each select="collection">
<h1><xsl:value-of select="@name" /> </h1>

<xsl:for-each select="report">
<a>
<xsl:attribute name="href">
<xsl:text>/collection/</xsl:text><xsl:value-of select="@fileName" />
</xsl:attribute>
<xsl:value-of select="@isoDate" />
</a>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<linkchecker-persistence.version>2.0.0</linkchecker-persistence.version>
<revision>7.1.3-SNAPSHOT</revision>
<revision>7.2.0-SNAPSHOT</revision>
<vlo.version>4.12.1</vlo.version>
<vtd.version>2.11</vtd.version>
<saxon.version>12.3</saxon.version>
Expand Down

0 comments on commit f25a769

Please sign in to comment.