Package org.apache.stanbol.rules.base.api

Examples of org.apache.stanbol.rules.base.api.SPARQLObject


        StringFunctionAtom stringFunctionAtom = tmp.getStringFunctionAtom();
        NumericFunctionAtom startAtom = tmp.getStart();
        NumericFunctionAtom lengthAtom = tmp.getLength();

        try {
            SPARQLObject stringSparqlAtom = adapter.adaptTo(stringFunctionAtom, SPARQLObject.class);
            SPARQLObject startSparqlAtom = adapter.adaptTo(startAtom, SPARQLObject.class);
            SPARQLObject lengthSparqlAtom = adapter.adaptTo(lengthAtom, SPARQLObject.class);

            String uriResourceString = stringSparqlAtom.getObject();
            String start = startSparqlAtom.getObject();
            String length = lengthSparqlAtom.getObject();

            String sparql = "<http://www.w3.org/2005/xpath-functions#substring> (" + uriResourceString + ", "
                            + start + ", " + length + ")";

            return (T) new SPARQLFunction(sparql);
View Full Code Here


        StringFunctionAtom argument = tmp.getArgument();
        StringFunctionAtom term = tmp.getTerm();

        try {
            SPARQLObject sparqlArgument = adapter.adaptTo(argument, SPARQLObject.class);
            SPARQLObject sparqlTerm = adapter.adaptTo(term, SPARQLObject.class);

            String argumentSparql = sparqlArgument.getObject();
            String termSparql = sparqlTerm.getObject();

            return (T) new SPARQLComparison("<http://www.w3.org/2005/xpath-functions#starts-with> ("
                                            + argumentSparql + ", " + termSparql + ")");

        } catch (UnsupportedTypeForExportException e) {
View Full Code Here

        org.apache.stanbol.rules.manager.atoms.StrAtom tmp = (org.apache.stanbol.rules.manager.atoms.StrAtom) ruleAtom;

        IObjectAtom argumentAtom = tmp.getUriResource();

        SPARQLObject sparqlObject = adapter.adaptTo(argumentAtom, SPARQLObject.class);

        String sparql = "str(" + sparqlObject.getObject() + ")";
        return (T) new SPARQLFunction(sparql);
    }
View Full Code Here

                                         UnavailableRuleObjectException,
                                         UnsupportedTypeForExportException {

        org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom tmp = (org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom) ruleAtom;

        SPARQLObject sparqlArgument1 = adapter.adaptTo(tmp.getArgument1(), SPARQLObject.class);
        SPARQLObject sparqlDT = adapter.adaptTo(tmp.getObjectProperty(), SPARQLObject.class);
        SPARQLObject sparqlArgument2 = adapter.adaptTo(tmp.getArgument2(), SPARQLObject.class);

        return (T) new SPARQLTriple(sparqlArgument1.getObject() + " " + sparqlDT.getObject() + " "
                                    + sparqlArgument2.getObject());
    }
View Full Code Here

                                         UnavailableRuleObjectException,
                                         UnsupportedTypeForExportException {

        org.apache.stanbol.rules.manager.atoms.NewIRIAtom tmp = (org.apache.stanbol.rules.manager.atoms.NewIRIAtom) ruleAtom;

        SPARQLObject binding = adapter.adaptTo(tmp.getBinding(), SPARQLObject.class);
        SPARQLObject variable = adapter.adaptTo(tmp.getNewNodeVariable(), SPARQLObject.class);

        SPARQLObject sparqlObject = new SPARQLFunction("BIND(" + "IRI(" + binding.getObject() + ") AS "
                                                       + variable.getObject() + ")");
        return (T) sparqlObject;

    }
View Full Code Here

        NumericFunctionAtom argument1 = tmp.getNumericFunctionAtom1();
        NumericFunctionAtom argument2 = tmp.getNumericFunctionAtom2();

        try {

            SPARQLObject sparqlArgument1 = adapter.adaptTo(argument1, SPARQLObject.class);
            SPARQLObject sparqlArgument2 = adapter.adaptTo(argument2, SPARQLObject.class);

            String sparqlFunction1 = sparqlArgument1.getObject();
            String sparqlFunction2 = sparqlArgument2.getObject();

            StringBuilder sb = new StringBuilder();
            sb.append("(");
            sb.append(sparqlFunction1);
            sb.append(" - ");
View Full Code Here

    public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption,
                                         UnavailableRuleObjectException,
                                         UnsupportedTypeForExportException {
        org.apache.stanbol.rules.manager.atoms.DatavaluedPropertyAtom tmp = (org.apache.stanbol.rules.manager.atoms.DatavaluedPropertyAtom) ruleAtom;

        SPARQLObject sparqlArgument1 = adapter.adaptTo(tmp.getArgument1(), SPARQLObject.class);
        SPARQLObject sparqlDT = adapter.adaptTo(tmp.getDatatypeProperty(), SPARQLObject.class);
        SPARQLObject sparqlArgument2 = adapter.adaptTo(tmp.getArgument2(), SPARQLObject.class);

        return (T) new SPARQLTriple(sparqlArgument1.getObject() + " " + sparqlDT.getObject() + " "
                                    + sparqlArgument2.getObject());

    }
View Full Code Here

        org.apache.stanbol.rules.manager.atoms.TypedLiteralAtom tmp = (org.apache.stanbol.rules.manager.atoms.TypedLiteralAtom) ruleAtom;

        ExpressionAtom valueExpression = tmp.getValue();
        URIResource xsdTypeResource = tmp.getXsdType();

        SPARQLObject sparqlObject = null;

        sparqlObject = adapter.adaptTo(valueExpression, SPARQLObject.class);

        String value = sparqlObject.getObject();

        if (!value.startsWith("\"")) {
            value = "\"" + value;
        }
View Full Code Here

        org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom) ruleAtom;

        ExpressionAtom argument1 = tmp.getArgument1();
        ExpressionAtom argument2 = tmp.getArgument2();

        SPARQLObject sparqlArgument1 = adapter.adaptTo(argument1, SPARQLObject.class);
        SPARQLObject sparqlArgument2 = adapter.adaptTo(argument2, SPARQLObject.class);

        String arg1 = sparqlArgument1.getObject();
        String arg2 = sparqlArgument2.getObject();

        StringBuilder sb = new StringBuilder();
        sb.append("(");
        sb.append(arg1);
        sb.append(" >= ");
View Full Code Here

        firstIte = true;
        ArrayList<SPARQLObject> sparqlObjects = new ArrayList<SPARQLObject>();
        for (RuleAtom ruleAtom : rule.getBody()) {

            SPARQLObject tmp = ((SPARQLObject) adaptRuleAtomTo(ruleAtom, type));
            if (tmp instanceof SPARQLNot) {
                sparqlObjects.add((SPARQLNot) tmp);
            } else if (tmp instanceof SPARQLComparison) {
                sparqlObjects.add((SPARQLComparison) tmp);
            } else {
                if (!firstIte) {
                    sparql += " . ";
                } else {
                    firstIte = false;
                }
                sparql += tmp.getObject();
            }
        }

        firstIte = true;
View Full Code Here

TOP

Related Classes of org.apache.stanbol.rules.base.api.SPARQLObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.