switch (constant.getType()) { case BNODE: case OBJECT: case STRING: return sqladapter.getSQLLexicalFormString(constant.getValue()); case BOOLEAN: boolean v = XsdDatatypeConverter.parseXsdBoolean(constant.getValue()); return sqladapter.getSQLLexicalFormBoolean(v); case DATETIME: return sqladapter.getSQLLexicalFormDatetime(constant.getValue()); case DATETIME_STAMP: return sqladapter.getSQLLexicalFormDatetimeStamp(constant.getValue()); case DECIMAL: case DOUBLE: case POSITIVE_INTEGER: case NON_NEGATIVE_INTEGER: return constant.getValue(); case NULL: return "NULL"; default: return "'" + constant.getValue() + "'";
public static Literal getLiteral(ValueConstant literal) { Objects.requireNonNull(literal); switch (literal.getType()) { case OBJECT: case LITERAL: case STRING: // creates xsd:string return fact.createLiteral(literal.getValue()); case LANG_STRING: // creates xsd:langString return fact.createLiteral(literal.getValue(), literal.getLanguage()); default: IRI datatype = TYPE_FACTORY.getDatatypeURI(literal.getType()); if (datatype == null) throw new RuntimeException( "Found unknown TYPE for constant: " + literal + " with COL_TYPE=" + literal.getType()); return fact.createLiteral(literal.getValue(), datatype); } }
private static String displayValueConstant(Term term) { return "\"" + ((ValueConstant) term).getValue() + "\""; }
private Predicate getDatatypePredicate(Term term) { if (term instanceof Function) { Function function = (Function) term; return function.getFunctionSymbol(); } else if (term instanceof ValueConstant) { ValueConstant constant = (ValueConstant) term; RDFDatatype type = constant.getType(); Predicate pred = termFactory.getRequiredTypePredicate(type); if (pred == null) pred = termFactory.getRequiredTypePredicate(XSD.STRING); // .XSD_STRING; return pred; } else { throw new RuntimeException("Unexpected term type: " + term); } }
private static String getPredicateName(Term templateTerm, List<String> values) { if (templateTerm instanceof Variable) { return values.get(0); } else { String uriTemplate = ((ValueConstant) templateTerm).getValue(); return URITemplates.format(uriTemplate, values); } } }
private static Function get_REGEXP_REPLACE(ImmutableList<Term> terms, net.sf.jsqlparser.expression.Function expression) { Term flags; switch (terms.size()) { case 3: // either Oracle or PostgreSQL, without flags flags = TERM_FACTORY.getConstantLiteral(""); // the 4th argument is flags break; case 4: if (((ValueConstant)terms.get(3)).getType() == Predicate.COL_TYPE.STRING) { // PostgreSQL flags = terms.get(3); // check that flags is either ig or g } else throw new UnsupportedSelectQueryRuntimeException("Unsupported SQL function", expression); break; case 6: // Oracle if (!terms.get(3).equals(TERM_FACTORY.getConstantLiteral("1", Predicate.COL_TYPE.LONG)) || !terms.get(4).equals(TERM_FACTORY.getConstantLiteral("0", Predicate.COL_TYPE.LONG))) throw new UnsupportedSelectQueryRuntimeException("Unsupported SQL function", expression); // check that the flags is a combination of imx flags = terms.get(5); break; default: throw new UnsupportedSelectQueryRuntimeException("Unsupported SQL function", expression); } return TERM_FACTORY.getFunction( ExpressionOperation.REPLACE, terms.get(0), terms.get(1), terms.get(2), flags); }
switch (constant.getType()) { case BNODE: case LITERAL: case OBJECT: case STRING: return sqladapter.getSQLLexicalFormString(constant.getValue()); case BOOLEAN: boolean v = XsdDatatypeConverter.parseXsdBoolean(constant.getValue()); return sqladapter.getSQLLexicalFormBoolean(v); case DATETIME: return sqladapter.getSQLLexicalFormDatetime(constant.getValue()); case DATETIME_STAMP: return sqladapter.getSQLLexicalFormDatetimeStamp(constant.getValue()); case DECIMAL: case DOUBLE: case POSITIVE_INTEGER: case NON_NEGATIVE_INTEGER: return constant.getValue(); case NULL: return "NULL"; default: return "'" + constant.getValue() + "'";
private static String getPredicateName(ImmutableTerm templateTerm, List<String> values) { if (templateTerm instanceof Variable) { return values.get(0); } else { String uriTemplate = ((ValueConstant) templateTerm).getValue(); return URITemplates.format(uriTemplate, values); } } }
if (o.getLanguage() != null) { head = TERM_FACTORY.getFunction(p, TERM_FACTORY.getUriTemplate( TERM_FACTORY.getConstantLiteral(s.getURI())), TERM_FACTORY.getTypedTerm(TERM_FACTORY.getConstantLiteral(o.getValue()), o.getLanguage())); } else { TERM_FACTORY.getConstantLiteral(s.getURI())), TERM_FACTORY.getTypedTerm(o, o.getType())); if (o.getLanguage() != null) { head = TERM_FACTORY.getFunction(p, TERM_FACTORY.getUriTemplate( TERM_FACTORY.getConstantLiteral(s.getURI())), TERM_FACTORY.getTypedTerm(TERM_FACTORY.getConstantLiteral(o.getValue()), o.getLanguage())); } else { TERM_FACTORY.getConstantLiteral(s.getURI())), TERM_FACTORY.getTypedTerm(o, o.getType()));
private Function get_REGEXP_REPLACE(ImmutableList<Term> terms, net.sf.jsqlparser.expression.Function expression) { Term flags; switch (terms.size()) { case 3: // either Oracle or PostgreSQL, without flags flags = termFactory.getConstantLiteral(""); // the 4th argument is flags break; case 4: if (((ValueConstant)terms.get(3)).getType().equals(typeFactory.getDatatype(XSD.STRING))) { // PostgreSQL flags = terms.get(3); // check that flags is either ig or g } else throw new UnsupportedSelectQueryRuntimeException("Unsupported SQL function", expression); break; case 6: // Oracle if (!terms.get(3).equals(termFactory.getConstantLiteral("1", typeFactory.getDatatype(XSD.LONG))) || !terms.get(4).equals(termFactory.getConstantLiteral("0", typeFactory.getDatatype(XSD.LONG)))) throw new UnsupportedSelectQueryRuntimeException("Unsupported SQL function", expression); // check that the flags is a combination of imx flags = terms.get(5); break; default: throw new UnsupportedSelectQueryRuntimeException("Unsupported SQL function", expression); } return termFactory.getFunction( ExpressionOperation.REPLACE, terms.get(0), terms.get(1), terms.get(2), flags); }
/** * TODO: could we have a RDF sub-class of ValueConstant? */ public static Literal getLiteral(ValueConstant literal) { Objects.requireNonNull(literal); TermType type = literal.getType(); if (!(type instanceof RDFDatatype)) // TODO: throw a proper exception throw new IllegalStateException("A ValueConstant given to OWLAPI must have a RDF datatype"); RDFDatatype datatype = (RDFDatatype) type; return datatype.getLanguageTag() .map(lang -> fact.createLiteral(literal.getValue(), lang.getFullString())) .orElseGet(() -> fact.createLiteral(literal.getValue(), fact.createIRI(datatype.getIRI().getIRIString()))); }
private boolean isNumeric(ValueConstant constant) { String constantValue = constant.getValue(); Optional<COL_TYPE> type = TYPE_FACTORY.getDatatype(constantValue); if (type.isPresent()) { Predicate p = TYPE_FACTORY.getTypePredicate(type.get()); return isNumeric(p); } return false; }
return Optional.of(TYPE_FACTORY.getTermType(((ValueConstant) term).getType()));
switch (COL_TYPE.getColType(constant.getType().getIRI())) { case BNODE: case OBJECT: case STRING: return sqladapter.getSQLLexicalFormString(constant.getValue()); case BOOLEAN: boolean v = XsdDatatypeConverter.parseXsdBoolean(constant.getValue()); return sqladapter.getSQLLexicalFormBoolean(v); case DATETIME: return sqladapter.getSQLLexicalFormDatetime(constant.getValue()); case DATETIME_STAMP: return sqladapter.getSQLLexicalFormDatetimeStamp(constant.getValue()); case DECIMAL: case DOUBLE: case POSITIVE_INTEGER: case NON_NEGATIVE_INTEGER: return constant.getValue(); case NULL: return "NULL"; default: return "'" + constant.getValue() + "'";
final String template = term.getValue(); List<Variable> varList = new ArrayList<>(); TermUtils.addReferencedVariablesTo(varList, uriFunction);
atom.setTerm(position, newTerm); } else if (term instanceof ValueConstant) { Term newTerm = termFactory.getTypedTerm(term, ((ValueConstant) term).getType()); atom.setTerm(position, newTerm); } else {
public OWLLiteral translate(ValueConstant v) { if (v == null) return null; String value = v.getValue(); if (value == null) { return null; } TermType type = v.getType(); if (!(type instanceof RDFDatatype)) // TODO: throw a proper exception throw new IllegalStateException("A ValueConstant given to OWLAPI must have a RDF datatype"); RDFDatatype datatype = (RDFDatatype) type; if (datatype.getLanguageTag().isPresent()) { return dataFactory.getOWLLiteral(value, datatype.getLanguageTag().get().getFullString()); } else { OWLDatatype owlDatatype = new OWLDatatypeImpl(IRI.create(datatype.getIRI().getIRIString())); if (owlDatatype != null) return dataFactory.getOWLLiteral(value, owlDatatype); else throw new IllegalArgumentException(datatype.toString()); } }
final String template = term.getValue(); ImmutableList<? extends ImmutableTerm> otherSubTerms = uriFunction.getTerms() .subList(1, uriFunction.getTerms().size());
atom.setTerm(position, newTerm); } else if (term instanceof ValueConstant) { Term newTerm = TERM_FACTORY.getTypedTerm(term, ((ValueConstant) term).getType()); atom.setTerm(position, newTerm); } else {
SemanticIndexView view = views.getView(subject.getType(), object.getType()); PreparedStatement stm = stmMap.get(view.getId()); if (stm == null) { String value = object.getValue(); switch (COL_TYPE.getColType(object.getType().getIRI())) { case LANG_STRING: // -3 stm.setString(2, value); stm.setString(4, object.getType().getLanguageTag().get().getFullString()); break; case STRING: // 1