use of fr.lirmm.graphik.graal.api.io.ParseError in project graal by graphik-team.
the class Producer method run.
@Override
public void run() {
org.eclipse.rdf4j.rio.RDFParser rdfParser = Rio.createParser(format);
if (this.config != null) {
rdfParser.setParserConfig(config);
}
rdfParser.setRDFHandler(new RDFListener(buffer));
try {
rdfParser.parse(this.reader, "");
} catch (RDFParseException e) {
throw new ParseError("An error occured while parsing", e);
} catch (RDFHandlerException e) {
throw new ParseError("An error occured while parsing", e);
} catch (IOException e) {
throw new ParseError("An error occured while parsing", e);
}
buffer.close();
try {
this.reader.close();
} catch (IOException e) {
}
}
use of fr.lirmm.graphik.graal.api.io.ParseError in project graal by graphik-team.
the class AbstractDlgpListener method endsConjunction.
@Override
public void endsConjunction(OBJECT_TYPE objectType) {
switch(objectType) {
case QUERY:
Set<Variable> bodyVars = this.atomSet.getVariables();
for (Term t : this.answerVars) {
if (t.isVariable() && !bodyVars.contains(t)) {
throw new ParseError("The variable [" + t + "] of the answer list does not appear in the query body.");
}
}
this.createQuery(DefaultConjunctiveQueryFactory.instance().create(this.label, this.atomSet, this.answerVars));
break;
case NEG_CONSTRAINT:
this.createNegConstraint(new DefaultNegativeConstraint(this.label, this.atomSet));
break;
case RULE:
if (this.atomSet2 == null) {
this.atomSet2 = this.atomSet;
this.atomSet = new LinkedListAtomSet();
} else {
this.createRule(DefaultRuleFactory.instance().create(this.label, this.atomSet, this.atomSet2));
}
break;
case FACT:
this.createAtomSet(this.atomSet);
break;
default:
break;
}
}
use of fr.lirmm.graphik.graal.api.io.ParseError in project graal by graphik-team.
the class SparqlConjunctiveQueryParser method execute.
// /////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS
// /////////////////////////////////////////////////////////////////////////
private void execute(String queryString) {
this.prefixes = new LinkedList<Prefix>();
List<Term> ans = new LinkedList<Term>();
Query sparql = QueryFactory.create(queryString);
for (Map.Entry<String, String> e : sparql.getPrefixMapping().getNsPrefixMap().entrySet()) {
this.prefixes.add(new Prefix(e.getKey(), e.getValue()));
}
if (sparql.isSelectType()) {
for (String v : sparql.getResultVars()) {
ans.add(DefaultTermFactory.instance().createVariable(v));
}
}
ElementVisitorImpl visitor = new ElementVisitorImpl(DefaultAtomSetFactory.instance().create());
sparql.getQueryPattern().visit(visitor);
// check if answer variables appear in the query body
Set<Variable> bodyVars = visitor.getAtomSet().getVariables();
for (Term t : ans) {
if (t.isVariable() && !bodyVars.contains(t)) {
throw new ParseError("The variable [" + t + "] of the answer list does not appear in the query body.");
}
}
this.query = DefaultConjunctiveQueryFactory.instance().create(visitor.getAtomSet(), ans);
}
Aggregations