Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge development changes to doc_development #201

Merged
merged 54 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8545824
refactor: Update JUnitTestFileGenerator to use relative path for TEST…
remiceres Jul 1, 2024
56ff189
Working SPARQL result format test for XML
MaillPierre Jul 4, 2024
c0cf633
SPARQL query format tests
MaillPierre Jul 4, 2024
9726dd9
SPARQL protocol query tests
MaillPierre Jul 5, 2024
bc7f683
fix ambiguous named graph test
MaillPierre Jul 5, 2024
d9c015b
fix: Corrected web server display issue
remiceres Jul 5, 2024
fb480e8
refactor: Update canonicalize.java to use default RDFC10SHA256 algorithm
remiceres Jul 5, 2024
e741e2f
fix queryGETHTML
remiceres Jul 5, 2024
496c6f5
Merge remote-tracking branch 'origin/development' into serverUnitTest
MaillPierre Jul 8, 2024
affc830
factoring test utilities
MaillPierre Jul 9, 2024
aa6026c
all result format tested
MaillPierre Jul 9, 2024
e175101
update tests first draft
MaillPierre Jul 9, 2024
defc82b
refactor: Add support for retrieving triples in Markdown format
remiceres Jul 9, 2024
6425335
basic graph store protocol tests and minor refactoring
MaillPierre Jul 9, 2024
a79ece9
Improve Corese-Command unit test
remiceres Jul 10, 2024
d451dae
graph store protocol tested
MaillPierre Jul 10, 2024
4d8b8b3
Minor fix
MaillPierre Jul 11, 2024
931cd8a
minor fix
MaillPierre Jul 11, 2024
eb15ca8
More exhaustive SPARQL HTTP query support tests
MaillPierre Jul 12, 2024
c28458b
Merge branch 'serverUnitTest' into development
MaillPierre Jul 12, 2024
d056895
Merge branch 'doc_development' into development
remiceres Jul 17, 2024
998aec0
chore: Update branch name in Sphinx workflow
remiceres Jul 17, 2024
a7f9ecf
Fix typos in cli doc
remiceres Jul 19, 2024
9b72fd8
Update JUnit dependencies in corese-command/pom.xml
remiceres Jul 22, 2024
3d2352f
Add remote=sparql test and dependencies for mock HTTPS server
remiceres Jul 22, 2024
b0c3c6a
Update Corese library Python examples with correct graph URIs
remiceres Jul 23, 2024
cb0c3ec
chore: Update remote-sparql command version to App.version
remiceres Jul 23, 2024
10c3b7b
Update prefix in SPARQL queries to use example.com domain
remiceres Jul 23, 2024
4726d8a
Rename inputFile into inputPath in ConvertTest
remiceres Jul 23, 2024
45e0fd7
Add test for Canonicalize command
remiceres Jul 23, 2024
50220fa
Bump rexml in /corese-unit-test/src/test/resources/data/rdf-star-main
dependabot[bot] Aug 2, 2024
58db614
chore: Update picocli dependency to version 4.7.6
remiceres Aug 2, 2024
0c26901
Update inputPath variable in CanonicalizeTest
remiceres Aug 2, 2024
cd65a90
refactor: Update SparqlTest to use canonical RDF comparison
remiceres Aug 2, 2024
5537bed
refactor Corese-Command and remove dupluicate code
remiceres Aug 2, 2024
b2afe1f
doc: Update request method option to use lowercase in remote-sparql c…
remiceres Aug 2, 2024
835f611
refactor: Update colors in Corese-Command
remiceres Aug 13, 2024
1247385
chore: Add generate-completion command in Corese-Command
remiceres Aug 14, 2024
c00b228
refactor: Update verbose mode flag in AbstractCommand to use negatable
remiceres Aug 14, 2024
f068150
refactor: Fix output enumeration colors for Convert command
remiceres Aug 14, 2024
1c27562
Merge branch 'development' into dependabot/bundler/corese-unit-test/s…
remiceres Aug 20, 2024
f0f4c17
Merge pull request #195 from Wimmics/dependabot/bundler/corese-unit-t…
remiceres Aug 20, 2024
480c0da
chore: Update flatpak metadata to include ipc sharing
remiceres Aug 20, 2024
2807a43
Bump rexml in /corese-unit-test/src/test/resources/data/rdf-star-main
dependabot[bot] Aug 22, 2024
f2bf7bf
Merge branch 'development' of github.com:Wimmics/corese into development
remiceres Aug 23, 2024
62e4e4f
Merge branch 'development' into dependabot/bundler/corese-unit-test/s…
remiceres Aug 23, 2024
0a26499
Merge pull request #196 from Wimmics/dependabot/bundler/corese-unit-t…
remiceres Aug 23, 2024
2d84a53
refactoring SPARQL REST API
MaillPierre Aug 27, 2024
0bb37b6
refactoring of utilities
MaillPierre Aug 27, 2024
f04dca1
Bug fix
MaillPierre Aug 28, 2024
5871d41
completing unit tests
MaillPierre Aug 28, 2024
5779810
Merge branch '#191' into development
MaillPierre Aug 28, 2024
cffc7c2
cleaning
MaillPierre Aug 28, 2024
bca607c
Merge branch 'GraphProtocol' into development
MaillPierre Aug 28, 2024
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
6 changes: 3 additions & 3 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
contents: write
steps:

- name: Checkout doc_development branch
- name: Checkout development branch
uses: actions/checkout@v4
with:
ref: doc_development
ref: development

- name: Build Sphinx Docs
uses: ammaraskar/sphinx-action@master
Expand All @@ -29,7 +29,7 @@ jobs:

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/doc_development'
if: github.ref == 'refs/heads/development'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/html
Expand Down
37 changes: 27 additions & 10 deletions corese-command/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,46 @@

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<!-- CLI Interface -->
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>4.7.4</version>
<version>4.7.6</version>
</dependency>

<!-- Corese -->
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>corese-core</artifactId>
</dependency>

<!-- Unit Test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.0-M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.11.0-M1</version>
<scope>test</scope>
</dependency>

<!-- Mock HTTPS Server for Test -->
<dependency>
<groupId>org.wiremock</groupId>
<artifactId>wiremock</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.26.3</version>
<scope>test</scope>
</dependency>

</dependencies>

Expand Down
27 changes: 24 additions & 3 deletions corese-command/src/main/java/fr/inria/corese/command/App.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
package fr.inria.corese.command;

import fr.inria.corese.command.programs.canonicalize;
import fr.inria.corese.command.programs.Canonicalize;
import fr.inria.corese.command.programs.Convert;
import fr.inria.corese.command.programs.RemoteSparql;
import fr.inria.corese.command.programs.Shacl;
import fr.inria.corese.command.programs.Sparql;
import picocli.AutoComplete.GenerateCompletion;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Help.Ansi.Style;
import picocli.CommandLine.Help.ColorScheme;

@Command(name = "Corese-command", version = App.version, mixinStandardHelpOptions = true, subcommands = {
Convert.class, Sparql.class, Shacl.class, RemoteSparql.class, canonicalize.class
Convert.class, Sparql.class, Shacl.class, RemoteSparql.class, Canonicalize.class, GenerateCompletion.class
})

public final class App implements Runnable {

public final static String version = "4.5.1";

public static void main(String[] args) {
int exitCode = new CommandLine(new App()).execute(args);
// Define the color scheme
ColorScheme colorScheme = new ColorScheme.Builder()
.commands(Style.bold) // Commands in blue
.options(Style.fg_yellow) // Options in yellow
.parameters(Style.fg_cyan, Style.bold) // Parameters in cyan and bold
.optionParams(Style.italic, Style.fg_cyan) // Option parameters in italic
.errors(Style.fg_red, Style.bold) // Errors in red and bold
.stackTraces(Style.italic) // Stack traces in italic
.applySystemProperties() // Apply system properties for colors
.build();

CommandLine commandLine = new CommandLine(new App()).setColorScheme(colorScheme);

// Hide the generate-completion command
CommandLine gen = commandLine.getSubcommands().get("generate-completion");
gen.getCommandSpec().usageMessage().hidden(true);

// Execute the command
int exitCode = commandLine.execute(args);
System.exit(exitCode);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package fr.inria.corese.command.programs;

import java.nio.file.Path;
import java.util.Optional;
import java.util.concurrent.Callable;

import fr.inria.corese.command.App;
import fr.inria.corese.command.utils.ConfigManager;
import fr.inria.corese.command.utils.exporter.rdf.RdfDataExporter;
import fr.inria.corese.core.util.Property;
import fr.inria.corese.core.util.Property.Value;
import picocli.CommandLine.Command;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Option;
import picocli.CommandLine.Spec;

/**
* Abstract class for all commands.
*
* This class provides common options and methods for all commands.
*/
@Command(version = App.version)
public abstract class AbstractCommand implements Callable<Integer> {

///////////////
// Constants //
///////////////

// Exit codes
protected final int ERROR_EXIT_CODE_SUCCESS = 0;
protected final int ERROR_EXIT_CODE_ERROR = 1;

/////////////
// Options //
/////////////

@Option(names = { "-o",
"--output-data" }, description = "Specifies the output file path. If not provided, the result will be written to standard output.", arity = "0..1", fallbackValue = RdfDataExporter.DEFAULT_OUTPUT)
protected Path output;

@Option(names = { "-c", "--config",
"--init" }, description = "Specifies the path to a configuration file. If not provided, the default configuration file will be used.", required = false)
private Path configFilePath;

@Option(names = { "-v",
"--verbose" }, description = "Enables verbose mode, printing more information about the execution of the command.", negatable = true)
protected boolean verbose = false;

@Option(names = { "-w",
"--owl-import" }, description = "Disables the automatic importation of ontologies specified in 'owl:imports' statements. When this flag is set, the application will not fetch and include referenced ontologies. Default is '${DEFAULT-VALUE}'.", required = false, defaultValue = "false", negatable = true)
private boolean noOwlImport;

////////////////
// Properties //
////////////////

// Command specification
@Spec
protected CommandSpec spec;

// Output
protected Boolean outputToFileIsDefault = false;

/////////////
// Methods //
/////////////

@Override
public Integer call() {

// Load configuration file
Optional<Path> configFilePath = Optional.ofNullable(this.configFilePath);
if (configFilePath.isPresent()) {
ConfigManager.loadFromFile(configFilePath.get(), this.spec, this.verbose);
} else {
ConfigManager.loadDefaultConfig(this.spec, this.verbose);
}

// Set owl import
Property.set(Value.DISABLE_OWL_AUTO_IMPORT, this.noOwlImport);

return 0;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package fr.inria.corese.command.programs;

import java.nio.file.Path;

import picocli.CommandLine.Option;

public abstract class AbstractInputCommand extends AbstractCommand {

@Option(names = { "-i",
"--input-data" }, description = "Specifies the path or URL of the input RDF data. Multiple values are allowed.", arity = "1...")
protected String[] inputsRdfData;

@Option(names = { "-R",
"--recursive" }, description = "If set to true and an input is a directory, all files in the directory will be loaded recursively. Default value: ${DEFAULT-VALUE}.", defaultValue = "false")
protected boolean recursive = false;

@Override
public Integer call() {
super.call();

// Check input values
this.checkInputValues();

return 0;
}

/**
* Check if the input values are correct.
*
* @throws IllegalArgumentException if input path is same as output path.
*/
private void checkInputValues() throws IllegalArgumentException {
if (this.inputsRdfData != null && this.output != null) {
for (String input : this.inputsRdfData) {
if (Path.of(input).compareTo(this.output) == 0) {
throw new IllegalArgumentException("Input path cannot be same as output path: " + input);
}
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package fr.inria.corese.command.programs;

import fr.inria.corese.command.utils.exporter.rdf.EnumCanonicAlgo;
import fr.inria.corese.command.utils.exporter.rdf.RdfDataCanonicalizer;
import fr.inria.corese.command.utils.loader.rdf.EnumRdfInputFormat;
import fr.inria.corese.command.utils.loader.rdf.RdfDataLoader;
import fr.inria.corese.core.Graph;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

@Command(name = "canonicalize", description = "Canonicalize an RDF file to a specific format.", mixinStandardHelpOptions = true)
public class Canonicalize extends AbstractInputCommand {

@Option(names = { "-f", "-if",
"--input-format" }, description = "Specifies the RDF serialization format of the input file. Available options are: :@|fg(225) ${COMPLETION-CANDIDATES}|@.")
private EnumRdfInputFormat inputFormat;

@Option(names = { "-a", "-ca", "-r", "-of",
"--canonical-algo" }, required = true, description = "Specifies the canonicalization algorithm to be applied to the input file. Available options are: :@|fg(225) ${COMPLETION-CANDIDATES}|@. The default algorithm is ${DEFAULT-VALUE}.", defaultValue = "rdfc-1.0")
private EnumCanonicAlgo canonicalAlgo;

public Canonicalize() {
}

@Override
public Integer call() {

super.call();

try {
// Load the input file(s)
RdfDataLoader loader = new RdfDataLoader(this.spec, this.verbose);
Graph graph = loader.load(this.inputsRdfData, this.inputFormat, this.recursive);

// Canonicalize and export the graph
RdfDataCanonicalizer rdfCanonicalizer = new RdfDataCanonicalizer(this.spec, this.verbose, this.output);
rdfCanonicalizer.export(graph, this.canonicalAlgo);

return this.ERROR_EXIT_CODE_SUCCESS;
} catch (IllegalArgumentException e) {
this.spec.commandLine().getErr().println("Error: " + e.getMessage());
return this.ERROR_EXIT_CODE_ERROR;
}
}

}
Loading
Loading