Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
154f0cb
RDF formats
MaillPierre Jun 4, 2025
9dcbfd1
Barebone RDFParser Factory
MaillPierre Jun 5, 2025
c8015fe
Merge branch 'feature/87_89_144_152_155_parsers' into feature/89_json…
MaillPierre Jun 5, 2025
81ceb4b
barebone parser interface
MaillPierre Jun 5, 2025
1463e4a
barebone parser interface
MaillPierre Jun 5, 2025
165a871
Merge branch 'feature/87_89_144_152_155_parsers' into feature/89_json…
MaillPierre Jun 5, 2025
9401042
First draft with consumer implementation
MaillPierre Jun 11, 2025
1dc4961
Merge branch 'feature/corese-next' into feature/89_json_parser
MaillPierre Jun 12, 2025
c0cb9c0
Json parser redone ffrom scratch using Jsonld-java
MaillPierre Jun 12, 2025
72bf0b7
Unit tests
MaillPierre Jun 13, 2025
a33d70b
fix literal typing during parsing
MaillPierre Jun 16, 2025
4012ee7
TurtleParser and turtle g4
prbblrypier Jun 20, 2025
fb2b2ec
Merge remote-tracking branch 'origin/feature/corese-next' into featur…
MaillPierre Jun 20, 2025
f286b90
basic JSONLD implementation with titanium
MaillPierre Jun 23, 2025
9c06cfc
better package organization
MaillPierre Jun 24, 2025
ad06072
Basic jsonld serializer
MaillPierre Jun 25, 2025
6a97a73
better config
MaillPierre Jun 25, 2025
00eb748
TurtleParser and turtle g4
prbblrypier Jun 25, 2025
c9b2f73
- changes in the package structure
prbblrypier Jun 27, 2025
df57629
Merge remote-tracking branch 'origin/feature/87_parsers' into feature…
MaillPierre Jun 30, 2025
737fe5c
Unifying PR and A implementations
MaillPierre Jun 30, 2025
af11856
UT test with graph probem to solve before push
MaillPierre Jun 30, 2025
21ad8ff
Fixing Object handling in json parsing
MaillPierre Jul 3, 2025
5614afa
Merge remote-tracking branch 'origin/feature/corese-next' into featur…
MaillPierre Jul 3, 2025
de37817
Merge remote-tracking branch 'origin/feature/corese-next' into featur…
MaillPierre Jul 4, 2025
57d2dcb
Spring prunning of the package tree and UTs
MaillPierre Jul 4, 2025
0915c25
remove old shex file
MaillPierre Jul 7, 2025
924243a
Paser with UT
MaillPierre Jul 7, 2025
170eca8
jsonld UT init
MaillPierre Jul 7, 2025
11b6e4d
fix my personal page
MaillPierre Jul 9, 2025
e4b1fb9
refining json serializer
MaillPierre Jul 9, 2025
99e5e34
Fixed Typed Literal bug
MaillPierre Jul 9, 2025
fc1ba51
Merge branch 'feature/corese-next' into feature/89_json_parser
MaillPierre Jul 10, 2025
9a35945
fixing Exception heritage
MaillPierre Jul 10, 2025
0f9221d
Reorganizing and standardizing classes and packages
MaillPierre Jul 10, 2025
baed5bc
Fixing test names and packages following review
MaillPierre Jul 10, 2025
cf4f824
removing unwanted file
MaillPierre Jul 16, 2025
cd1ac3b
Comments, comments everywhere
MaillPierre Jul 17, 2025
9cd6442
Refactor build.gradle.kts to enhance JavaCC and Antlr source generati…
remiceres Jul 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ target/
/dist/
/nbdist/
/.nb-gradle/
.continue/

# Logs and coverage reports
*.log
Expand All @@ -82,7 +83,9 @@ gradle/gradle-daemon-jvm.properties

# Other build directories and generated files
/bin/
/out/

# Fichiers de logs
logs/
*.log
.sonarlint/
67 changes: 50 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,33 @@ sonar {
}
}

// === Generated sources directories ===
val javaccGeneratedDir = layout.buildDirectory.dir("generated-src/javacc").get().asFile
val antlrGeneratedDir = layout.buildDirectory.dir("generated-src/antlr").get().asFile
val antlrPackageDir = layout.buildDirectory.dir("generated-src/antlr/fr/inria/corese/core/next/impl/parser/antlr").get().asFile

// JavaCC configuration
javacc {
configs {
register("sparqlCorese") {
inputFile = file("src/main/java/fr/inria/corese/core/sparql/triple/javacc1/sparql_corese.jj")
packageName = "fr.inria.corese.core.sparql.triple.javacc1"
outputDir = javaccGeneratedDir
}
}
}

// Ajoute les fichiers générés par JavaCC comme source Java
// Configure source sets to include generated sources
sourceSets {
main {
java {
srcDir(layout.buildDirectory.dir("generated-src/javacc"))
srcDir(javaccGeneratedDir)
srcDir(antlrGeneratedDir)
}
}
}

// Ensure JavaCC generation happens before compilation
tasks.named("compileJava") {
dependsOn("javaccSparqlCorese")
}
Expand Down Expand Up @@ -118,6 +126,13 @@ dependencies {
antlr("org.antlr:antlr4:4.13.2") // Antlr for parsing (ANTLR 4)
implementation("org.antlr:antlr4-runtime:4.13.2") // Antlr runtime for parsing


// === JSONLD
implementation("com.apicatalog:titanium-json-ld:1.6.0")
implementation("com.apicatalog:titanium-rdf-api:1.0.0")
implementation("org.eclipse.parsson:parsson:1.1.7")
implementation("jakarta.json:jakarta.json-api:2.1.3")

// === HTTP and XML ===
implementation("org.glassfish.jersey.core:jersey-client:3.1.10") // HTTP client (Jersey)
implementation("org.glassfish.jersey.inject:jersey-hk2:3.1.10") // Dependency injection for Jersey
Expand All @@ -128,6 +143,8 @@ dependencies {
implementation("org.json:json:20250517") // JSON processing
implementation("com.typesafe:config:1.4.3") // Configuration library (Typesafe Config)



// === Test dependencies ===
testImplementation(platform("org.junit:junit-bom:5.13.2")) // JUnit BOM for consistent test versions
testImplementation("org.junit.jupiter:junit-jupiter:5.13.2") // JUnit Jupiter API and engine
Expand Down Expand Up @@ -200,7 +217,7 @@ publishing {
id.set("pierremaillot")
name.set("Pierre Maillot")
email.set("pierre.maillot@inria.fr")
url.set("https://maillpierre.github.io/personal-page/")
url.set("https://w3id.org/people/pierremaillot")
organization.set("Inria")
organizationUrl.set("http://www.inria.fr/")
}
Expand Down Expand Up @@ -329,34 +346,50 @@ tasks.withType<PublishToMavenRepository>().configureEach {

// === Antlr generated sources configuration ===

// Path where Antlr will generate sources
val generatedSourcesPath = "src/main/generated"

// Add the generated sources directory to the main source set
sourceSets["main"].java.srcDir(file(generatedSourcesPath))

// Configure the Antlr task to generate parser code with specific arguments
tasks.named<AntlrTask>("generateGrammarSource") {
arguments.addAll(listOf("-visitor", "-long-messages", "-package", "fr.inria.corese.core.next.impl.parser.antlr"))
outputDirectory = file("$buildDir/generated-src/antlr/main")
outputs.dirs(outputDirectory)
outputDirectory = antlrPackageDir
inputs.files(fileTree("src/main/antlr"))
outputs.dir(antlrPackageDir)
}

// Ensure Java compilation depends on Antlr code generation
// Ensure Java compilation depends on both JavaCC and Antlr code generation
tasks.named("compileJava") {
dependsOn("generateGrammarSource" /*, "copyAntlrGenerated" */)
dependsOn("generateGrammarSource", "javaccSparqlCorese")
}

// Ensure sources JAR includes generated sources and depends on Antlr code generation
// Ensure sources JAR includes generated sources and depends on code generation
tasks.named<Jar>("sourcesJar") {
dependsOn("generateGrammarSource" /*, "copyAntlrGenerated" */)
from(generatedSourcesPath)
dependsOn("generateGrammarSource", "javaccSparqlCorese")
from(javaccGeneratedDir)
from(antlrGeneratedDir)
includeEmptyDirs = false
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

// Clean up generated sources on clean
tasks.clean {
doLast {
file(generatedSourcesPath).deleteRecursively()
delete(javaccGeneratedDir)
delete(antlrGeneratedDir)
}
}

// Ensure generated directories exist before generation
tasks.register("createGeneratedDirs") {
doLast {
javaccGeneratedDir.mkdirs()
antlrGeneratedDir.mkdirs()
antlrPackageDir.mkdirs()
}
}

// Make generation tasks depend on directory creation
tasks.named("generateGrammarSource") {
dependsOn("createGeneratedDirs")
}

tasks.named("javaccSparqlCorese") {
dependsOn("createGeneratedDirs")
}
19 changes: 0 additions & 19 deletions src/main/java/fr/inria/corese/core/next/api/SerializerFactory.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package fr.inria.corese.core.next.api.base.io;

import fr.inria.corese.core.next.api.io.IOOptions;

/**
* Abstract class for parser/serializers that sets up the necessity of implementing a builder pattern.
*/
public abstract class AbstractIOOptions implements IOOptions {

public abstract static class Builder< T extends IOOptions> {
protected Builder() {

}

public abstract T build();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.inria.corese.core.next.impl.common.serialization;
package fr.inria.corese.core.next.api.base.io;

import java.util.List;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.inria.corese.core.next.impl.common.serialization;
package fr.inria.corese.core.next.api.base.io;

import java.util.List;
import java.util.Locale;
Expand All @@ -11,48 +11,48 @@
* This class also acts as a central registry for all known RDF formats,
* providing static constants for common formats and utility methods for lookup.
*/
public class RdfFormat extends FileFormat {
public class RDFFormat extends FileFormat {

private final boolean supportsNamespaces;
private final boolean supportsNamedGraphs;

public static final RdfFormat TURTLE = new RdfFormat(
public static final RDFFormat TURTLE = new RDFFormat(
"Turtle",
List.of("ttl"),
List.of("text/turtle"),
true,
false);


public static final RdfFormat NTRIPLES = new RdfFormat(
public static final RDFFormat NTRIPLES = new RDFFormat(
"N-Triples",
List.of("nt"),
List.of("application/n-triples", "text/plain"),
false,
false);

public static final RdfFormat NQUADS = new RdfFormat(
public static final RDFFormat NQUADS = new RDFFormat(
"N-Quads",
List.of("nq"),
List.of("application/n-quads"),
false,
true);

public static final RdfFormat JSONLD = new RdfFormat(
public static final RDFFormat JSONLD = new RDFFormat(
"JSON-LD",
List.of("jsonld"),
List.of("application/ld+json", "application/json"),
true,
true);

public static final RdfFormat RDFXML = new RdfFormat(
public static final RDFFormat RDFXML = new RDFFormat(
"RDF/XML",
List.of("rdf", "xml"),
List.of("application/rdf+xml"),
true,
false);

public static final RdfFormat TRIG = new RdfFormat(
public static final RDFFormat TRIG = new RDFFormat(
"TriG",
List.of("trig"),
List.of("application/trig"),
Expand All @@ -70,7 +70,7 @@ public class RdfFormat extends FileFormat {
* @param supportsNamedGraphs Whether the format supports named graphs.
* serialization.
*/
public RdfFormat(
public RDFFormat(
String name,
List<String> extensions,
List<String> mimeTypes,
Expand Down Expand Up @@ -104,7 +104,7 @@ public boolean supportsNamedGraphs() {
* @param name The name of the format (e.g., "Turtle").
* @return An Optional containing the matching RdfFormat if found.
*/
public static Optional<RdfFormat> byName(String name) {
public static Optional<RDFFormat> byName(String name) {
String n = name.toLowerCase(Locale.ROOT);
return all().stream()
.filter(format -> format.getName().equalsIgnoreCase(n))
Expand All @@ -117,7 +117,7 @@ public static Optional<RdfFormat> byName(String name) {
* @param extension The file extension (e.g., "ttl").
* @return An Optional containing the matching RdfFormat if found.
*/
public static Optional<RdfFormat> byExtension(String extension) {
public static Optional<RDFFormat> byExtension(String extension) {
String ext = extension.toLowerCase(Locale.ROOT);
return all().stream()
.filter(format -> format.getExtensions().stream()
Expand All @@ -131,7 +131,7 @@ public static Optional<RdfFormat> byExtension(String extension) {
* @param mimeType The MIME type (e.g., "text/turtle").
* @return An Optional containing the matching RdfFormat if found.
*/
public static Optional<RdfFormat> byMimeType(String mimeType) {
public static Optional<RDFFormat> byMimeType(String mimeType) {
String mime = mimeType.toLowerCase(Locale.ROOT);
return all().stream()
.filter(format -> format.getMimeTypes().stream()
Expand All @@ -144,7 +144,7 @@ public static Optional<RdfFormat> byMimeType(String mimeType) {
*
* @return An unmodifiable List of all RdfFormat constants.
*/
public static List<RdfFormat> all() {
public static List<RDFFormat> all() {
return List.of(TURTLE, NTRIPLES, NQUADS, JSONLD, RDFXML, TRIG);
}

Expand All @@ -162,7 +162,7 @@ public String toString() {
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!(obj instanceof RdfFormat other))
if (!(obj instanceof RDFFormat other))
return false;
return getName().equalsIgnoreCase(other.getName())
&& getExtensions().equals(other.getExtensions())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package fr.inria.corese.core.next.api.base.io.parser;

import fr.inria.corese.core.next.api.Model;
import fr.inria.corese.core.next.api.ValueFactory;
import fr.inria.corese.core.next.api.io.IOOptions;
import fr.inria.corese.core.next.api.io.parser.RDFParser;
import fr.inria.corese.core.next.api.io.parser.RDFParserOptions;
import fr.inria.corese.core.next.impl.exception.ParsingErrorException;

import java.io.InputStream;
import java.io.Reader;
import java.util.Objects;

/**
* Abstract class for RDFParser that set up the inner Model and ValueFactory
*/
public abstract class AbstractRDFParser implements RDFParser {

private final Model model;
private final ValueFactory valueFactory;
private IOOptions config;

public IOOptions getConfig() {
return config;
}

public void setConfig(IOOptions config) {
this.config = config;
}

protected AbstractRDFParser(Model model, ValueFactory factory) {
this(model, factory, null);
}

protected AbstractRDFParser(Model model, ValueFactory factory, IOOptions config) {
Objects.requireNonNull(model);
Objects.requireNonNull(factory);
this.model = model;
this.valueFactory = factory;
this.config = config;
}

@Override
public void parse(InputStream in) {
parse(in, null);
}

@Override
public void parse(Reader reader) {
parse(reader, null);
}

/**
* @return the model populated by the parser
*/
protected Model getModel() {
return model;
}

/**
* @return the value factory used by the parser
*/
protected ValueFactory getValueFactory() {
return valueFactory;
}
}
Loading