Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nck-mlcnv committed Nov 28, 2023
1 parent 000dee5 commit 2a5e5c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.aksw.iguana.commons.rdf.IONT;
import org.aksw.iguana.commons.rdf.IPROP;
import org.aksw.iguana.commons.rdf.IRES;
import org.aksw.iguana.commons.time.TimeUtils;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
Expand All @@ -18,9 +19,6 @@
import java.util.Map;
import java.util.Optional;

import static org.aksw.iguana.commons.time.TimeUtils.createTypedDurationLiteral;
import static org.aksw.iguana.commons.time.TimeUtils.toXSDDurationInSeconds;

public class AggregatedExecutionStatistics extends Metric implements ModelWritingMetric {

public AggregatedExecutionStatistics() {
Expand Down Expand Up @@ -81,8 +79,8 @@ private static Model createAggregatedModel(List<HttpWorker.ExecutionStats> data,
m.add(queryRes, IPROP.timeOuts, ResourceFactory.createTypedLiteral(timeOuts));
m.add(queryRes, IPROP.wrongCodes, ResourceFactory.createTypedLiteral(wrongCodes));
m.add(queryRes, IPROP.unknownException, ResourceFactory.createTypedLiteral(unknownExceptions));
// m.add(queryRes, IPROP.totalTime, ResourceFactory.createTypedLiteral(toXSDDurationInSeconds(totalTime)));
m.add(queryRes, IPROP.totalTime, createTypedDurationLiteral(totalTime));
m.add(queryRes, IPROP.totalTime, TimeUtils.createTypedDurationLiteralInSeconds(totalTime));
// m.add(queryRes, IPROP.totalTime, TimeUtils.createTypedDurationLiteral(totalTime));
m.add(queryRes, RDF.type, IONT.executedQuery);

return m;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import java.time.Duration;

/**
* Class related to the conversion of Java time objects to RDF literals. This class is used to convert a Java Duration
* object to a typed RDF literal. The literal is typed as xsd:duration. This class temporarily fixes an issue with Jena.
* This class is used to convert a Java Duration object to a typed RDF literal. The literal is typed as xsd:duration.
* This class temporarily fixes an issue with Jena.
*/
public class DurationLiteral implements RDFDatatype {

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/aksw/iguana/commons/time/TimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public static XSDDuration toXSDDurationInSeconds(Duration duration) {
return (XSDDuration) new XSDDurationType().parse("PT" + new BigDecimal(BigInteger.valueOf(duration.toNanos()), 9).toPlainString() + "S");
}

public static Literal createTypedDurationLiteralInSeconds(Duration duration) {
final var seconds = "PT" + new BigDecimal(BigInteger.valueOf(duration.toNanos()), 9).toPlainString() + "S";
return ResourceFactory.createTypedLiteral(seconds, new DurationLiteral(duration));
}

public static Literal createTypedDurationLiteral(Duration duration) {
return ResourceFactory.createTypedLiteral(duration.toString(), new DurationLiteral(duration));
}
Expand Down

0 comments on commit 2a5e5c7

Please sign in to comment.