Skip to content

Commit c0db0a4

Browse files
committed
upgrade to release versions
1 parent 0add4c6 commit c0db0a4

File tree

17 files changed

+388
-47
lines changed

17 files changed

+388
-47
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ results.tsv
3434
.vscode
3535
dependency-reduced-pom.xml
3636

37+
38+
.travis.yml
39+

docs/lsq-maven-plugin.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
layout: default
3+
title: Overview
4+
nav_order: 10
5+
---
6+
7+
# LSQ Maven Plugin
8+
9+
The [Linked SPARQL Queries](https://lsq.aksw.org/) (LSQ) Maven Plugin features the goals:
10+
11+
* `rdfize`: Extracts SPARQL queries from Web server logs (e.g. Apache, Virtuoso) and emits quad-based RDF data. Each graph corresponds to one query.
12+
* `benchmark`: Takes a SPARQL query log as input and runs the queries against a configured endpoint.
13+
The query log may be supplied in various formats, including that of the output of `rdfize`.
14+
15+

lsq-maven-plugin/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<inceptionYear>2024</inceptionYear>
1818

1919
<properties>
20-
<lsq.version>2.0.0-RC3-SNAPSHOT</lsq.version>
20+
<lsq.version>2.0.0-RC3</lsq.version>
2121

2222
<jenax.version>5.0.0-1</jenax.version>
2323
</properties>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.aksw.maven.plugin.lsq;
2+
3+
import org.aksw.jenax.arq.dataset.api.DatasetOneNg;
4+
import org.aksw.jenax.arq.dataset.impl.DatasetGraphOneNgImpl;
5+
import org.aksw.jenax.arq.dataset.impl.DatasetOneNgImpl;
6+
import org.apache.jena.rdf.model.RDFNode;
7+
8+
public class DatasetOneNgImplBackport {
9+
public static DatasetOneNg naturalDataset(RDFNode resource) {
10+
return new DatasetOneNgImpl(DatasetGraphOneNgImpl.create(resource.asNode(), resource.getModel().getGraph()));
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package org.aksw.maven.plugin.lsq;
2+
3+
import java.io.IOException;
4+
import java.io.OutputStream;
5+
import java.nio.file.AtomicMoveNotSupportedException;
6+
import java.nio.file.FileAlreadyExistsException;
7+
import java.nio.file.Files;
8+
import java.nio.file.Path;
9+
import java.nio.file.StandardCopyOption;
10+
import java.nio.file.StandardOpenOption;
11+
import java.util.Objects;
12+
import java.util.function.Consumer;
13+
import java.util.function.Function;
14+
15+
import org.aksw.commons.lambda.throwing.ThrowingConsumer;
16+
17+
/** FIXME Delete this class as it has been moved to aksw-commons */
18+
public class FileUtilsBackport {
19+
public static void moveAtomicIfSupported(Consumer<String> warnCallback, Path source, Path target) throws IOException {
20+
try {
21+
Files.move(source, target, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
22+
} catch (AtomicMoveNotSupportedException e) {
23+
if (warnCallback != null) {
24+
warnCallback.accept(String.format("Atomic move from %s to %s failed, falling back to copy", source, target));
25+
}
26+
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
27+
}
28+
}
29+
30+
/** Actions if the target already exists */
31+
public static enum OverwriteMode {
32+
/** Raise an error */
33+
ERROR,
34+
35+
/** Overwrite the target */
36+
OVERWRITE,
37+
38+
/** Skip the write */
39+
SKIP
40+
}
41+
42+
public static void safeCreate(Path target, OverwriteMode overwriteAction, ThrowingConsumer<OutputStream> writer) throws Exception {
43+
safeCreate(target, null, overwriteAction, writer);
44+
}
45+
46+
public static void safeCreate(Path target, Function<OutputStream, OutputStream> encoder, OverwriteMode overwriteAction, ThrowingConsumer<OutputStream> writer) throws Exception {
47+
Objects.requireNonNull(overwriteAction);
48+
49+
String fileName = target.getFileName().toString();
50+
String tmpFileName = "." + fileName + ".tmp"; // + new Random().nextInt();
51+
Path tmpFile = target.resolveSibling(tmpFileName);
52+
53+
Boolean fileExists = OverwriteMode.SKIP.equals(overwriteAction) || OverwriteMode.ERROR.equals(overwriteAction)
54+
? Files.exists(target)
55+
: null;
56+
57+
// Check whether the target already exists before we start writing the tmpFile
58+
if (Boolean.TRUE.equals(fileExists) && OverwriteMode.ERROR.equals(overwriteAction)) {
59+
throw new FileAlreadyExistsException(target.toAbsolutePath().toString());
60+
}
61+
62+
if (!(Boolean.TRUE.equals(fileExists) && OverwriteMode.SKIP.equals(overwriteAction))) {
63+
Path parent = target.getParent();
64+
if (parent != null) {
65+
Files.createDirectories(parent);
66+
}
67+
68+
boolean allowOverwrite = OverwriteMode.OVERWRITE.equals(overwriteAction);
69+
// What to do if the tmp file already exists?
70+
try (OutputStream raw = Files.newOutputStream(tmpFile, allowOverwrite ? StandardOpenOption.CREATE : StandardOpenOption.CREATE_NEW);
71+
OutputStream out = encoder != null ? encoder.apply(raw) : raw) {
72+
writer.accept(out);
73+
out.flush();
74+
}
75+
moveAtomicIfSupported(null, tmpFile, target);
76+
}
77+
}
78+
79+
/** Delete a path if it is an empty directory */
80+
public void deleteDirectoryIfEmpty(Path path) throws IOException {
81+
boolean isDirectory = Files.isDirectory(path);
82+
if (isDirectory) {
83+
boolean isEmpty = Files.list(path).count() == 0;
84+
if (isEmpty) {
85+
Files.delete(path);
86+
}
87+
}
88+
}
89+
90+
}

0 commit comments

Comments
 (0)