/** * This method finds the term for the predicate template */ private static Function findTemplatePredicateTerm(Function atom, int arity) { Function uriTermForPredicate; if(arity == 1) { uriTermForPredicate = (Function) atom.getTerm(2); } else if (arity == 2) { uriTermForPredicate = (Function) atom.getTerm(1); } else { throw new IllegalArgumentException("The parameter arity should be 1 or 2"); } return uriTermForPredicate; } }
Function uri = ((Function) term); if (uri.getFunctionSymbol() instanceof URITemplatePredicate) { String uriName = ((ValueConstant) uri.getTerm(0)).getValue(); if (uriName.startsWith(oldPrefix)) { uriName = uriName.replaceFirst(oldPrefix, newPrefix);
private static boolean isRDFType(Term pred) { // if (pred instanceof Constant && ((Constant) pred).getValue().equals(OBDAVocabulary.RDF_TYPE)) { // return true; // } if (pred instanceof Function && ((Function) pred).getTerm(0) instanceof Constant ) { String c= ((Constant) ((Function) pred).getTerm(0)).getValue(); return c.equals(OBDAVocabulary.RDF_TYPE); } return false; }
Function uriTemplate = (Function) tquery.get(0).getTerm(0); //URI("..{}..", , ) String subjectTemplate = URITemplates.getUriTemplateString(uriTemplate, prefixmng); Function predf = (Function)func.getTerm(1); if (predf.getFunctionSymbol() instanceof URITemplatePredicate) { if (predf.getTerms().size() == 1) //fixed string pred = OBDADataFactoryImpl.getInstance().getPredicate(((ValueConstant)(predf.getTerm(0))).getValue(), 1); predUri = vf.createURI(pred.getName()); Term object = func.getTerm(1); Term objectTerm = ((Function) object).getTerm(0);
ValueConstant term = (ValueConstant) uriFunction.getTerm(0); final String template = term.getValue(); List<Variable> varList = new ArrayList<>();
Function uriTemplate = (Function) tquery.get(0).getTerm(0); //URI("..{}..", , ) String subjectTemplate = URITemplates.getUriTemplateString(uriTemplate, prefixmng); Template templs = mfact.createTemplate(subjectTemplate); Function predf = (Function)func.getTerm(1); if (predf.getFunctionSymbol() instanceof URITemplatePredicate) { if (predf.getTerms().size() == 1) { //fixed string pred = OBDADataFactoryImpl.getInstance().getPredicate(((ValueConstant)(predf.getTerm(0))).getValue(), 1); predUri = vf.createURI(pred.getName()); object = func.getTerm(1); object = func.getTerm(2); if (objectPred instanceof URITemplatePredicate) { Term objectTerm = ((Function) object).getTerm(0); Term objectTerm = ((Function) object).getTerm(0); Term langTerm = ((Function) object).getTerm(1); Term langTerm = ((Function) object).getTerm(1); if(langTerm instanceof Constant) { obm.setLanguageTag(((Constant) langTerm).getValue());
/** * check if the term is {@code URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")} * @param term * @return */ private static boolean isURIRDFType(Term term) { boolean result = true; if(term instanceof Function){ Function func = (Function) term; if (func.getArity() != 1){ result = false; } else { result = result && (func.getFunctionSymbol() instanceof URITemplatePredicate); result = result && (func.getTerm(0) instanceof ValueConstant) && ((ValueConstant) func.getTerm(0)).getValue(). equals(OBDAVocabulary.RDF_TYPE); } } else { result = false; } return result; }
String originalString = atom.getFunctionSymbol().toString(); if (isUnary(atom)) { Term subjectTerm = atom.getTerm(0); subject = getDisplayName(subjectTerm, prefixManager); predicate = "a"; Term subjectTerm = atom.getTerm(0); subject = getDisplayName(subjectTerm, prefixManager); Term predicateTerm = atom.getTerm(1); predicate = getDisplayName(predicateTerm, prefixManager); Term objectTerm = atom.getTerm(2); object = getDisplayName(objectTerm, prefixManager); Term subjectTerm = atom.getTerm(0); subject = getDisplayName(subjectTerm, prefixManager); predicate = getAbbreviatedName(originalString, prefixManager, false); predicate = "<" + predicate + ">"; Term objectTerm = atom.getTerm(1); object = getDisplayName(objectTerm, prefixManager);
if (isURIRDFType(bodyAtom.getTerm(1))) {
if (vars.isEmpty()) { Function funcObjectAtom = (Function) objectAtom; Term term0 = funcObjectAtom.getTerm(0); if (term0 instanceof Function) { Function constPred = (Function) term0;
if (object instanceof Function) { 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); ValueConstant pr = (ValueConstant) ((Function) pred).getTerm(0); if (object instanceof Variable) { predicate = dfac.getPredicate(pr.getValue(), 2);
functionName = ((ValueConstant) ((Function)resource25).getTerm(0)).getValue(); } else { throw new IllegalArgumentException("resource25 should be an URI");
String functionName = ( (ValueConstant) ((Function)resource38).getTerm(0) ).getValue();