Skip to content

Commit

Permalink
Fix #341
Browse files Browse the repository at this point in the history
  • Loading branch information
enridaga committed Feb 6, 2023
1 parent 081a9c1 commit c78c0ad
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.github.basilapi.basil.sparql.SpecificationFactory;
import io.github.basilapi.basil.sparql.VariablesBinder;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.jena.graph.Node;
Expand Down Expand Up @@ -63,6 +64,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -468,7 +470,8 @@ public static void main(String[] args) throws Exception {
// If directory, load all files
List<File> list = new ArrayList<File>();
//Path base = Paths.get(".");
File[] files = loadSource.listFiles();
//File[] files = loadSource.listFiles();
Collection<File> files = FileUtils.listFiles(loadSource, null, true);
for (File f : files) {
logger.info("Adding file to be loaded: {}", f);
// list.add(base.relativize(f.toPath()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2023 SPARQL Anything Contributors @ http://github.com/sparql-anything
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.github.sparqlanything.cli;

import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoadSubdirsTest {
public static final Logger L = LoggerFactory.getLogger(LoadSubdirsTest.class);

@Test
public void test() throws Exception {
String q = getClass().getClassLoader().getResource("count-triples.sparql").toString();
String d = getClass().getClassLoader().getResource("./load-subdirs").toURI().toString();
SPARQLAnything sa = new SPARQLAnything();
String out = sa.callMain(new String[]{
"-q", q, "-l", d
});
Assert.assertTrue(out.contains("51"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT (COUNT(*) AS ?count) WHERE { graph ?f {?a ?b ?c} }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_:bn1234 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
_:bn1234 <http://schema.org/familyName> "Trump" .
_:bn1234 <http://schema.org/givenName> "Lucy" .
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"@context": "https://schema.org",
"@type": "Person",
"address": {
"@type": "PostalAddress",
"addressLocality": "Monterotondo",
"addressRegion": "Lazio",
"postalCode": "00010",
"streetAddress": "via Veneto"
},
"email": "[email protected]",
"jobTitle": "Web Developer",
"name": "Paolo Muti",
"birthPlace": "Philadelphia, PA",
"birthDate": "1979-11-12",
"height": "74 inches",
"gender": "male",
"memberOf": "SS Lazio",
"nationality": "Romanian",
"telephone": "(0039) 339-1024288",
"url": "http://www.example.com",
"sameAs" : [ "https://www.facebook.com/",
"https://www.linkedin.com/",
"http://twitter.com/"]
}
12 changes: 12 additions & 0 deletions sparql-anything-cli/src/test/resources/load-subdirs/dir1/file1.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix odrl: <http://www.w3.org/ns/odrl/2/>.
@prefix fx: <http://sparql.xyz/facade-x/ns/>.
@prefix xyz: <http://sparql.xyz/facade-x/data/>.
@prefix dct: <http://purl.org/dc/terms/>.
@prefix skos: <http://www.w3.org/2004/02/skos/core#>.
@prefix schema: <http://schema.org/>.

[ a schema:Person; schema:familyName "Smith"; schema:givenName "John" ] .
[ a schema:Person; schema:familyName "Goldberg"; schema:givenName "Corinna" ] .

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"@context": "https://schema.org",
"@type": "Person",
"address": {
"@type": "PostalAddress",
"addressLocality": "Monterotondo",
"addressRegion": "Lazio",
"postalCode": "00010",
"streetAddress": "via Veneto"
},
"email": "[email protected]",
"jobTitle": "Web Master",
"name": "Lucia Malatesta",
"birthPlace": "London, UK",
"birthDate": "1985-01-22",
"height": "70 inches",
"gender": "female",
"memberOf": "SS Roma",
"nationality": "Ungarian",
"telephone": "(0039) 338-1224248",
"url": "http://www.example.com/lucia00123",
"sameAs" : [ "https://www.facebook.com/lucia00123",
"https://www.linkedin.com/lucia00123",
"http://twitter.com/lucia00123"]
}

0 comments on commit c78c0ad

Please sign in to comment.