use of org.apache.jena.cmd.CmdException in project jena by apache.
the class shex_validate method exec.
@Override
protected void exec() {
ShexSchema shapes;
try {
shapes = Shex.readSchema(shapesfile);
} catch (ShexException ex) {
System.err.println("Failed to read shapes: " + ex.getMessage());
throw new CmdException();
}
Graph dataGraph;
try {
dataGraph = load(datafile, "data file");
} catch (RiotException ex) {
throw new CmdException("Failed to data: " + ex.getMessage());
}
if (mapfile != null) {
ShexMap map;
try {
map = Shex.readShapeMap(mapfile);
} catch (ShexException ex) {
throw new CmdException("Failed to read shapes map: " + ex.getMessage());
}
ShexReport report = ShexValidator.get().validate(dataGraph, shapes, map);
ShexLib.printReport(output, report);
return;
}
// Or --shapeURI
ShexShape startShape = shapes.getStart();
if (startShape == null)
throw new CmdException("Start node required for URI-validation");
String targetURIstr = dataGraph.getPrefixMapping().expandPrefix(targetNode);
Node focus = NodeFactory.createURI(targetURIstr);
// if ( isVerbose() )
// ValidationContext.VERBOSE = true;
// ValidationReport report = ( node != null )
// ? ShaclValidator.get().validate(shapesGraph, dataGraph, node)
// : ShaclValidator.get().validate(shapesGraph, dataGraph);
ShexReport report = ShexValidator.get().validate(dataGraph, shapes, startShape, focus);
ShexLib.printReport(output, report);
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class shex_validate method processModulesAndArgs.
@Override
protected void processModulesAndArgs() {
super.processModulesAndArgs();
datafile = super.getValue(argData);
shapesfile = super.getValue(argShapes);
// No -- arguments, use act on single file of shapes and data.
if (datafile == null && shapesfile == null) {
if (positionals.size() == 1) {
datafile = positionals.get(0);
shapesfile = positionals.get(0);
}
}
if (datafile == null)
throw new CmdException("Usage: " + getSummary());
if (shapesfile == null)
shapesfile = datafile;
textOutput = super.hasArg(argOutputText);
if (contains(argTargetNode))
targetNode = getValue(argTargetNode);
if (contains(argShapeMap))
mapfile = getValue(argShapeMap);
if (targetNode != null && mapfile != null)
throw new CmdException("Only one of target node and map file");
if (targetNode == null && mapfile == null)
throw new CmdException("One of target node and map file required");
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class CmdSub method exec.
protected void exec() {
Exec exec = dispatch.get(subCmd);
if (exec == null)
throw new CmdException("No subcommand: " + subCmd);
exec.exec(args);
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class ModTDBAssembler method processArgs.
@Override
public void processArgs(CmdArgModule cmdLine) {
int count = 0;
modLocation.processArgs(cmdLine);
super.processArgs(cmdLine);
if (super.getAssemblerFile() != null)
count++;
if (modLocation.getLocation() != null)
count++;
if (count == 0) {
useDefaultAssemblerFile = true;
// throw new CmdException("No assembler file and no location") ;
}
if (count > 1)
throw new CmdException("Only one of an assembler file and a location");
}
use of org.apache.jena.cmd.CmdException in project jena by apache.
the class tdbloader method processModulesAndArgs.
@Override
protected void processModulesAndArgs() {
super.processModulesAndArgs();
if (contains(argLoader)) {
String loadername = getValue(argLoader).toLowerCase();
if (loadername.matches("basic.*"))
loader = LoaderEnum.Basic;
else if (loadername.matches("phas.*"))
loader = LoaderEnum.Phased;
else if (loadername.matches("seq.*"))
loader = LoaderEnum.Sequential;
else if (loadername.matches("para.*"))
loader = LoaderEnum.Parallel;
else if (loadername.matches("light"))
loader = LoaderEnum.Light;
else
throw new CmdException("Unrecognized value for --loader: " + loadername);
}
if (super.contains(argStats)) {
if (!hasValueOfTrue(argStats) && !hasValueOfFalse(argStats))
throw new CmdException("Not a boolean value: " + getValue(argStats));
generateStats = super.hasValueOfTrue(argStats);
}
if (super.graphName != null)
lang = Lang.NTRIPLES;
if (super.contains(argSyntax)) {
String syntax = super.getValue(argSyntax);
Lang lang$ = RDFLanguages.nameToLang(syntax);
if (lang$ == null)
throw new CmdException("Can not detemine the syntax from '" + syntax + "'");
this.lang = lang$;
}
}
Aggregations