Skip to content

Commit

Permalink
Fix #482
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-asprino committed May 30, 2024
1 parent 1989dc1 commit 53ed591
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -927,13 +927,22 @@ public void testIssue330() throws URISyntaxException, IOException {

}


@Ignore
@Test
public void testIssue478() throws URISyntaxException, IOException {
executeTest("issues/issue478.sparql", "issues/issue 478.xls", false, false, false);
executeTest("issues/issue478-2.sparql", "issues/issue 478.xls", false, false, false);
}

@Test
public void testIssue482() throws URISyntaxException, IOException {
QueryExecution qExec = executeTest("issues/issue482.sparql", "issues/issue482.xlsx", false, false, false);
ResultSet rs = qExec.execSelect();
assertTrue(rs.hasNext());
assertEquals("2024-05-29T00:00:00+02:00",rs.next().get("o").asLiteral().getString());
assertFalse(rs.hasNext());
}

private QueryExecution executeTest(String queryPath, String resourcePath, boolean printQueryString, boolean printFormattedQuery, boolean printResults) throws IOException, URISyntaxException {
Dataset ds = DatasetFactory.createGeneral();
QC.setFactory(ARQ.getContext(), FacadeX.ExecutorFactory);
Expand Down
10 changes: 10 additions & 0 deletions sparql-anything-it/src/test/resources/issues/issue482.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?o WHERE {
SERVICE <x-sparql-anything:> {
fx:properties fx:location "%%%LOCATION%%%" .
?s rdf:_6/rdf:_1 ?o
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@
import io.github.sparqlanything.model.*;
import io.github.sparqlanything.model.annotations.Example;
import io.github.sparqlanything.model.annotations.Option;
import org.apache.jena.datatypes.RDFDatatype;
import org.apache.jena.datatypes.xsd.XSDDatatype;
import org.apache.jena.ext.com.google.common.collect.Sets;
import org.apache.jena.graph.NodeFactory;
import org.apache.jena.rdf.model.Literal;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.vocabulary.XSD;
import org.apache.poi.ss.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.*;

@io.github.sparqlanything.model.annotations.Triplifier
Expand Down Expand Up @@ -175,6 +183,12 @@ private Object extractCellValue(Cell cell, boolean evaluateFormulas) {
case STRING:
return cell.getStringCellValue();
case NUMERIC:
if(DateUtil.isCellDateFormatted(cell)){
Date date = cell.getDateCellValue();
Calendar c = Calendar.getInstance();
c.setTime(date);
return NodeFactory.createLiteral(DatatypeConverter.printDateTime(c), XSDDatatype.XSDdateTime);
}
return cell.getNumericCellValue();
case FORMULA:
if (evaluateFormulas) {
Expand Down

0 comments on commit 53ed591

Please sign in to comment.