if(QueryUtils.isGrounded(object)) { ValueConstant c = ((ValueConstant) ((Function) object).getTerm(0)); // it has to be a URI constant Predicate predicate = dfac.getClassPredicate(c.getValue()); atom = dfac.getFunction(predicate, subject); } else { atom = dfac.getTripleAtom(subject, pred, object); Term uriOfPred = dfac.getUriTemplate(pred); Term uriOfObject = dfac.getUriTemplate(object); atom = dfac.getTripleAtom(subject, uriOfPred, uriOfObject); atom = dfac.getTripleAtom(subject, pred, object); } else { ValueConstant pr = (ValueConstant) ((Function) pred).getTerm(0); if (object instanceof Variable) { predicate = dfac.getPredicate(pr.getValue(), 2); } else { if (object instanceof Function) { if (((Function) object).getFunctionSymbol() instanceof URITemplatePredicate) { predicate = dfac.getObjectPropertyPredicate(pr.getValue()); } else { predicate = dfac.getDataPropertyPredicate(pr.getValue()); throw new IllegalArgumentException("predicate should be a URI Function"); atom = dfac.getFunction(predicate, subject, object);
cons = str.substring(0, i); str = str.substring(str.indexOf("}", i)+1, str.length()); terms.add(fac.getConstantLiteral(cons)); }else{ str = str.substring(str.indexOf("}")+1); terms.add(fac.getVariable(joinCond + (var))); if (!str.equals("")){ cons = str; terms.add(fac.getConstantLiteral(cons)); uriTemplate = fac.getConstantLiteral(string); terms.add(0, uriTemplate); // the URI template is always on the return fac.getUriTemplate(terms); uriTemplate = fac.getConstantLiteral(string); terms.add(0, uriTemplate); // the URI template is always on the return fac.getUriTemplate(terms); uriTemplate = fac.getConstantBNode(string); terms.add(0, uriTemplate); // the URI template is always on the return fac.getBNodeTemplate(terms); return fac.getTypedTerm(uriTemplate, COL_TYPE.LITERAL); case 4://concat
public OBDAModel loadRFrom2RMLFile(String r2rmlFile, String jdbcUrl, String username, String password, String driverClass) throws Exception { OBDADataFactory f = OBDADataFactoryImpl.getInstance(); URI obdaURI = new File(r2rmlFile).toURI(); String sourceUrl = obdaURI.toString(); OBDADataSource dataSource = f.getJDBCDataSource(sourceUrl, jdbcUrl, username, password, driverClass); R2RMLReader reader = new R2RMLReader(r2rmlFile); return reader.readModel(dataSource); }
private void saveMapping(URI dataSourceUri, String mappingId, String sourceQuery, List<Function> targetQuery) { try { OBDAMappingAxiom mapping = dataFactory.getRDBMSMappingAxiom(mappingId, dataFactory.getSQLQuery(sourceQuery), targetQuery); model.addMapping(dataSourceUri, mapping, false); } catch (DuplicateMappingException e) { // NO-OP: Ignore it as duplicates won't be loaded to the model } }
@Deprecated private Term getConstantObject(String objectString) { if (objectString.startsWith("http:")) return getURIFunction(objectString); else { // literal Constant constt = fac.getConstantLiteral(objectString); return fac.getTypedTerm(constt, COL_TYPE.LITERAL); } }
Predicate p = operations.get(op); if (p != null) { compositeTerm = fac.getFunction(p, t1, t2); compositeTerm = fac.getFunctionAND(t1, t2); break; case "OR": compositeTerm = fac.getFunctionOR(t1, t2); break; case "LIKE": compositeTerm = fac.getSQLFunctionLike(t1, t2); break; case "~": compositeTerm = fac.getFunction(ExpressionOperation.REGEX, t1, t2, fac.getConstantLiteral("")); break; case "~*": compositeTerm = fac.getFunction(ExpressionOperation.REGEX, t1, t2, fac.getConstantLiteral("i")); // i flag for case insensitivity break; case "!~": compositeTerm = fac.getFunctionNOT( fac.getFunction(ExpressionOperation.REGEX, t1, t2, fac.getConstantLiteral(""))); break; case "!~*": compositeTerm = fac.getFunctionNOT( fac.getFunction(ExpressionOperation.REGEX,t1, t2, fac.getConstantLiteral("i"))); break; case "REGEXP": compositeTerm = fac.getFunction(ExpressionOperation.REGEX, t1, t2, fac.getConstantLiteral("i")); break;
body.add(fac.getFunction(classPred, subjectAtom)); Function constPred = (Function) term0; Predicate newpred = constPred.getFunctionSymbol(); Function bodyAtom = fac.getFunction(newpred, subjectAtom); body.add(bodyAtom); ValueConstant vconst = (ValueConstant) term0; String predName = vconst.getValue(); Predicate newpred = fac.getPredicate(predName, 1); Function bodyAtom = fac.getFunction(newpred, subjectAtom); body.add(bodyAtom); Function rdftype = fac.getUriTemplate(fac.getConstantLiteral(OBDAVocabulary.RDF_TYPE)); Function bodyAtom = fac.getTripleAtom(subjectAtom, rdftype, objectAtom); Function bodyAtom = fac.getFunction(bodyPred, subjectAtom, objectAtom); body.add(bodyAtom); Function bodyAtom = fac.getTripleAtom(subjectAtom, predFunction, objectAtom);
/** * The method generates the OBDAModel from an * obda or ttl (r2rml) file * @param obdaURI - the file URI * @return the generated OBDAModel * @throws IOException * @throws InvalidMappingException */ public OBDAModel getObdaModel(URI obdaURI) throws IOException, InvalidMappingException { //create empty model OBDAModel obdaModel = fac.getOBDAModel(); // System.out.println(obdaURI.toString()); if (obdaURI.toString().endsWith(".obda")) { //read obda file ModelIOManager modelIO = new ModelIOManager(obdaModel); modelIO.load(new File(obdaURI)); } else if (obdaURI.toString().endsWith(".ttl")) { //read R2RML file R2RMLReader reader = null; try { reader = new R2RMLReader(new File(obdaURI)); obdaModel = reader.readModel(obdaURI); } catch (Exception e) { e.printStackTrace(); } } return obdaModel; }
value = dfac.getUriTemplate(terms31); Predicate.COL_TYPE type = dtfac.getDatatype(functionName); if (type != null) value = dfac.getTypedTerm(terms31.get(0), type); else { functionSymbol = dfac.getPredicate(functionName, arity); value = dfac.getFunction(functionSymbol, terms31);
objectAtom = fac.getConstantLiteral(obj); Term newlit = fac.getConstantLiteral(obj); objectAtom = fac.getUriTemplate(newlit); } else { objectAtom = fac.getTypedTerm(newlit, COL_TYPE.LITERAL); // .RDFS_LITERAL; objectAtom = fac.getVariable(col); objectAtom = fac.getVariable(value); } else { Object type = om.getTermType(Object.class); objectAtom = fac.getUriTemplate(objectAtom); Term langAtom = fac.getTypedTerm(objectAtom, lan); objectAtom = langAtom; }else if ((typ.equals(R2RMLVocabulary.literal)) && (concat)){ objectAtom = fac.getTypedTerm(objectAtom, COL_TYPE.LITERAL); + datatype.toString()); } else { Term dtAtom = fac.getTypedTerm(objectAtom, type);
FormatString token = tokens.get(0); if (token instanceof FixedString) { ValueConstant uriTemplate = dfac.getConstantLiteral(token.toString()); // a single URI template toReturn = dfac.getUriTemplate(uriTemplate); Variable column = dfac.getVariable(token.toString()); toReturn = dfac.getUriTemplate(column); Variable column = dfac.getVariable(token.toString()); terms.add(column); ValueConstant uriTemplate = dfac.getConstantLiteral(sb.toString()); // complete URI template terms.add(0, uriTemplate); toReturn = dfac.getUriTemplate(terms);
Function bodyAtom = fac.getFunction(pred, terms); body.add(bodyAtom); OBDAMappingAxiom mapping = fac.getRDBMSMappingAxiom("mapping-join-"+robm.hashCode(), fac.getSQLQuery(sourceQuery), body); System.out.println("WARNING joinMapping introduced : "+mapping.toString()); joinMappings.add(mapping);
@Deprecated private Term getExplicitTypedObject(String string) { Term typedObject = null; String[] strings = string.split("<"); if (strings.length > 1) { String consts = strings[0]; consts = consts.substring(0, consts.length() - 2); consts = trim(consts); String type = strings[1]; if (type.endsWith(">")) type = type.substring(0, type.length() - 1); DatatypePredicate predicate = new DatatypePredicateImpl(type, COL_TYPE.OBJECT); Term constant = fac.getConstantLiteral(consts); typedObject = fac.getFunction(predicate, constant); } return typedObject; }
.getOBDAModel(); OBDADataSource dataSource = f.getJDBCDataSource(sourceUrl, jdbcurl, username, password, driverclass); OBDAModel model = reader.readModel(dataSource);
/** * Create an in-memory H2 database data source * @param name - the datasource name * @return the created OBDADataSource */ private static OBDADataSource getMemOBDADataSource(String name) { OBDADataSource obdaSource = OBDADataFactoryImpl.getInstance().getDataSource(URI.create(name)); String driver = "org.h2.Driver"; String url = "jdbc:h2:mem:questrepository"; String username = "sa"; String password = ""; obdaSource = fac.getDataSource(URI.create("http://www.obda.org/ABOXDUMP" + System.currentTimeMillis())); obdaSource.setParameter(RDBMSourceParameterConstants.DATABASE_DRIVER, driver); obdaSource.setParameter(RDBMSourceParameterConstants.DATABASE_PASSWORD, password); obdaSource.setParameter(RDBMSourceParameterConstants.DATABASE_URL, url); obdaSource.setParameter(RDBMSourceParameterConstants.DATABASE_USERNAME, username); obdaSource.setParameter(RDBMSourceParameterConstants.IS_IN_MEMORY, "true"); obdaSource.setParameter(RDBMSourceParameterConstants.USE_DATASOURCE_FOR_ABOXDUMP, "true"); return (obdaSource); }
if(template == null && (termType.equals(R2RMLVocabulary.iri))){ subjectAtom = fac.getUriTemplate(fac.getVariable(subj)); classPredicates.add(fac.getClassPredicate(o.toString()));
@Override public void visit(DoubleValue expression) { String termRightName = expression.toString(); result = fac.getConstantLiteral(termRightName, COL_TYPE.DOUBLE); }
Predicate p = dfac.getClassPredicate(predName); result = dfac.getFunction(p, atom.getTerm(0)); Predicate p = dfac.getObjectPropertyPredicate(predName); result = dfac.getFunction(p, atom.getTerm(0), atom.getTerm(2));
if (elements == null) elements = new Vector<Term>(); Predicate predicate = dfac.getPredicate(uri, elements.size()); terms = new Vector<Term>(); value = dfac.getFunction(predicate, terms);
value = dfac.getDatalogProgram(); CQIE rule = null; Predicate predicate = dfac.getPredicate(name, size); Function newhead = dfac.getFunction(predicate, variableList); rule.updateHead(newhead);