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

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


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

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

        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


                                         UnavailableRuleObjectException,
                                         UnsupportedTypeForExportException {
        org.apache.stanbol.rules.manager.atoms.NamespaceAtom tmp = (org.apache.stanbol.rules.manager.atoms.NamespaceAtom) ruleAtom;
        IObjectAtom argument = tmp.getUriResource();

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

        String sparql = "<http://jena.hpl.hp.com/ARQ/function#namespace>(" + sparqlObject.getObject() + ")";
        return (T) new SPARQLFunction(sparql);
    }
View Full Code Here

        StringFunctionAtom namespaceArg = tmp.getNamespaceArg();
        StringFunctionAtom labelArg = tmp.getLabelArg();

        try {

            SPARQLObject namespaceSparqlAtom = adapter.adaptTo(namespaceArg, SPARQLObject.class);
            SPARQLObject labelSparqlAtom = adapter.adaptTo(labelArg, SPARQLObject.class);

            String ns = namespaceSparqlAtom.getObject();
            String label = labelSparqlAtom.getObject();

            String sparql = "<http://www.stlab.istc.cnr.it/semion/function#propString>(" + ns + ", " + label
                            + ")";
            return (T) new SPARQLFunction(sparql);
View Full Code Here

        org.apache.stanbol.rules.manager.atoms.CreateLabelAtom tmp = (org.apache.stanbol.rules.manager.atoms.CreateLabelAtom) ruleAtom;
        StringFunctionAtom stringFunctionAtom = tmp.getStringFunctionAtom();

        System.out.println("Argument instance of " + stringFunctionAtom.getClass().getCanonicalName());

        SPARQLObject sparqlArgument1 = adapter.adaptTo(stringFunctionAtom, SPARQLObject.class);
        String argument = sparqlArgument1.getObject();

        if (argument.startsWith(Symbols.variablesPrefix)) {
            argument = "?" + argument.replace(Symbols.variablesPrefix, "");
        }
View Full Code Here

        org.apache.stanbol.rules.manager.atoms.LessThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.LessThanAtom) 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

        ExpressionAtom argument1 = tmp.getStringFunctionAtom1();
        ExpressionAtom argument2 = tmp.getStringFunctionAtom2();

        try {
            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

    @SuppressWarnings("unchecked")
    @Override
    public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {

        org.apache.stanbol.rules.manager.atoms.NotAtom tmp = (org.apache.stanbol.rules.manager.atoms.NotAtom) ruleAtom;
        SPARQLObject sparqlObject;
        try {
            sparqlObject = adapter.adaptTo(tmp.getComparisonAtom(), SPARQLObject.class);
            String sparqlAtom = "!" + sparqlObject.getObject();
            return (T) new SPARQLComparison(sparqlAtom);
        } catch (UnsupportedTypeForExportException e) {
            throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
        } catch (UnavailableRuleObjectException e) {
            throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
View Full Code Here

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

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

        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

        boolean negativeArg = false;
        boolean negativeClass = false;

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

        SPARQLObject sparqlArgument1 = adapter.adaptTo(tmp.getArgument1(), SPARQLObject.class);
        SPARQLObject sparqlArgument2 = adapter.adaptTo(tmp.getClassResource(), SPARQLObject.class);

        if (negativeArg || negativeClass) {
            String optional = sparqlArgument1.getObject()
                              + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> "
                              + sparqlArgument2.getObject();

            ArrayList<String> filters = new ArrayList<String>();
            if (negativeArg) {
                filters.add("!bound(" + argument1SPARQL + ")");
            }
            if (negativeClass) {
                filters.add("!bound(" + argument2SPARQL + ")");
            }

            String[] filterArray = new String[filters.size()];
            filterArray = filters.toArray(filterArray);

            return (T) new SPARQLNot(optional, filterArray);
        } else {
            return (T) new SPARQLTriple(sparqlArgument1.getObject()
                                        + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> "
                                        + sparqlArgument2.getObject());
        }

    }
View Full Code Here

                scope1 += " . ";
            }

            try {

                SPARQLObject inGroupSparqlAtom = adapter.adaptTo(inGroupRuleAtom, SPARQLObject.class);

                scope1 += inGroupSparqlAtom.getObject();

            } catch (UnsupportedTypeForExportException e) {
                throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
            } catch (UnavailableRuleObjectException e) {
                throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
            }

        }

        String scope2 = "";

        for (RuleAtom inGroupRuleAtom : atomList2) {
            if (!scope2.isEmpty()) {
                scope2 += " . ";
            }

            try {

                SPARQLObject inGroupSparqlAtom = adapter.adaptTo(inGroupRuleAtom, SPARQLObject.class);

                scope2 += inGroupSparqlAtom.getObject();

            } catch (UnsupportedTypeForExportException e) {
                throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
            } catch (UnavailableRuleObjectException e) {
                throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
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.