You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by an...@apache.org on 2012/03/28 17:00:10 UTC
svn commit: r1306390 [5/10] - in /incubator/stanbol/trunk/rules/manager: ./
RuleConf/ demo/ src/main/java/org/apache/stanbol/rules/manager/
src/main/java/org/apache/stanbol/rules/manager/arqextention/
src/main/java/org/apache/stanbol/rules/manager/atom...
Added: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/DivisionAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/DivisionAtom.java?rev=1306390&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/DivisionAtom.java (added)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/DivisionAtom.java Wed Mar 28 15:00:06 2012
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.rules.manager.atoms;
+
+public class DivisionAtom extends NumericFunctionAtom {
+
+ private NumericFunctionAtom numericFunctionAtom1;
+ private NumericFunctionAtom numericFunctionAtom2;
+
+ public DivisionAtom(NumericFunctionAtom numericFunctionAtom1, NumericFunctionAtom numericFunctionAtom2) {
+ this.numericFunctionAtom1 = numericFunctionAtom1;
+ this.numericFunctionAtom2 = numericFunctionAtom2;
+ }
+
+ @Override
+ public String toString() {
+ String function1 = numericFunctionAtom1.toString();
+ String function2 = numericFunctionAtom2.toString();
+ return "div(" + function1 + ", " + function2 + ")";
+ }
+
+ @Override
+ public String prettyPrint() {
+ return numericFunctionAtom1.prettyPrint() + "/" + numericFunctionAtom2.prettyPrint();
+ }
+
+ public NumericFunctionAtom getNumericFunctionAtom1() {
+ return numericFunctionAtom1;
+ }
+
+ public NumericFunctionAtom getNumericFunctionAtom2() {
+ return numericFunctionAtom2;
+ }
+}
Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/EndsWithAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/EndsWithAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/EndsWithAtom.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/EndsWithAtom.java Wed Mar 28 15:00:06 2012
@@ -1,79 +1,54 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.rules.manager.atoms;
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
-import org.apache.stanbol.rules.manager.SPARQLComparison;
-import org.semanticweb.owlapi.model.OWLDataFactory;
-import org.semanticweb.owlapi.model.SWRLAtom;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
-
+/**
+ *
+ * @author anuzzolese
+ *
+ */
public class EndsWithAtom extends ComparisonAtom {
-
- private StringFunctionAtom argument;
- private StringFunctionAtom term;
-
- public EndsWithAtom(StringFunctionAtom argument, StringFunctionAtom term) {
- this.argument = argument;
- this.term = term;
- }
-
- @Override
- public Resource toSWRL(Model model) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SPARQLObject toSPARQL() {
- String argumentSparql = argument.toSPARQL().getObject();
-
-
-
- return new SPARQLComparison("<http://www.w3.org/2005/xpath-functions#ends-with> (" + argumentSparql + ", " + term.toSPARQL().getObject() + ")");
- }
-
- @Override
- public SWRLAtom toSWRL(OWLDataFactory factory) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String toKReSSyntax() {
-
-
-
- return "endsWith(" + argument.toKReSSyntax() + ", " + term.toKReSSyntax() + ")";
- }
-
- @Override
- public JenaClauseEntry toJenaClauseEntry(JenaVariableMap jenaVariableMap) {
- // TODO Auto-generated method stub
- return null;
- }
-
-
+ private StringFunctionAtom argument;
+ private StringFunctionAtom term;
+
+ public EndsWithAtom(StringFunctionAtom argument, StringFunctionAtom term) {
+ this.argument = argument;
+ this.term = term;
+ }
+
+ @Override
+ public String toString() {
+
+ return "endsWith(" + argument.toString() + ", " + term.toString() + ")";
+ }
+
+ @Override
+ public String prettyPrint() {
+ return argument.prettyPrint() + " ends with " + term.prettyPrint();
+ }
+
+ public StringFunctionAtom getArgument() {
+ return argument;
+ }
+
+ public StringFunctionAtom getTerm() {
+ return term;
+ }
}
Added: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/ExpressionAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/ExpressionAtom.java?rev=1306390&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/ExpressionAtom.java (added)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/ExpressionAtom.java Wed Mar 28 15:00:06 2012
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.rules.manager.atoms;
+
+public abstract class ExpressionAtom extends AbstractRuleAtom {
+
+}
Added: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/GreaterEqualThanAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/GreaterEqualThanAtom.java?rev=1306390&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/GreaterEqualThanAtom.java (added)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/GreaterEqualThanAtom.java Wed Mar 28 15:00:06 2012
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.rules.manager.atoms;
+
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLLiteral;
+
+/**
+ *
+ * @author anuzzolese
+ *
+ */
+
+public class GreaterEqualThanAtom extends ComparisonAtom {
+
+ private ExpressionAtom argument1;
+ private ExpressionAtom argument2;
+
+ public GreaterEqualThanAtom(ExpressionAtom argument1, ExpressionAtom argument2) {
+ this.argument1 = argument1;
+ this.argument2 = argument2;
+ }
+
+ @Override
+ public String toString() {
+ return "geq(" + argument1.toString() + ", " + argument2.toString() + ")";
+ }
+
+ private OWLLiteral getOWLTypedLiteral(Object argument) {
+
+ OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
+
+ OWLLiteral owlLiteral;
+ if (argument instanceof String) {
+ owlLiteral = factory.getOWLTypedLiteral((String) argument);
+ } else if (argument instanceof Integer) {
+ owlLiteral = factory.getOWLTypedLiteral(((Integer) argument).intValue());
+ } else if (argument instanceof Double) {
+ owlLiteral = factory.getOWLTypedLiteral(((Double) argument).doubleValue());
+ } else if (argument instanceof Float) {
+ owlLiteral = factory.getOWLTypedLiteral(((Float) argument).floatValue());
+ } else if (argument instanceof Boolean) {
+ owlLiteral = factory.getOWLTypedLiteral(((Boolean) argument).booleanValue());
+ } else {
+ owlLiteral = factory.getOWLStringLiteral(argument.toString());
+ }
+
+ return owlLiteral;
+ }
+
+ @Override
+ public String prettyPrint() {
+ return argument1.prettyPrint() + " >= " + argument2.prettyPrint();
+ }
+
+ public ExpressionAtom getArgument1() {
+ return argument1;
+ }
+
+ public ExpressionAtom getArgument2() {
+ return argument2;
+ }
+}
Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/GreaterThanAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/GreaterThanAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/GreaterThanAtom.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/GreaterThanAtom.java Wed Mar 28 15:00:06 2012
@@ -1,275 +1,72 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.rules.manager.atoms;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
-import org.apache.stanbol.rules.base.api.URIResource;
-import org.apache.stanbol.rules.manager.JenaClauseEntryImpl;
-import org.apache.stanbol.rules.manager.SPARQLComparison;
import org.semanticweb.owlapi.apibinding.OWLManager;
-import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLLiteral;
-import org.semanticweb.owlapi.model.SWRLAtom;
-import org.semanticweb.owlapi.model.SWRLBuiltInAtom;
-import org.semanticweb.owlapi.model.SWRLDArgument;
-import org.semanticweb.owlapi.vocab.SWRLBuiltInsVocabulary;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
-import com.hp.hpl.jena.reasoner.rulesys.Functor;
-import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
-import com.hp.hpl.jena.vocabulary.XSD;
-
public class GreaterThanAtom extends ComparisonAtom {
-
- private Object argument1;
- private Object argument2;
-
- public GreaterThanAtom(Object argument1, Object argument2) {
- this.argument1 = argument1;
- this.argument2 = argument2;
- }
-
- @Override
- public Resource toSWRL(Model model) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SPARQLObject toSPARQL() {
- String arg1 = argument1.toString();
- String arg2 = argument2.toString();
-
-
- if(arg1.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg1 = "str(?"+arg1.replace("http://kres.iks-project.eu/ontology/meta/variables#", "") + ")";
-
- }
- else{
- arg1 = "str("+arg1+")";
- }
-
- if(arg2.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg2 = "str(?"+arg2.replace("http://kres.iks-project.eu/ontology/meta/variables#", "") + ")";
-
- }
- else if(!arg2.startsWith("<") && !arg2.endsWith(">")){
- OWLLiteral literal = getOWLTypedLiteral(argument2);
- arg2 = "str(" + literal.getLiteral() + ")";
- }
- else{
- arg2 = "str("+arg2+")";
- }
-
-
- return new SPARQLComparison(arg1+" > "+arg2);
-
- }
-
- @Override
- public SWRLAtom toSWRL(OWLDataFactory factory) {
-
- List<SWRLDArgument> swrldArguments = new ArrayList<SWRLDArgument>();
-
- SWRLDArgument swrldArgument1 = null;
-
- if(argument1.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
-
- swrldArgument1 = factory.getSWRLVariable(IRI.create(argument1.toString()));
- }
- else{
-
- OWLLiteral literal = null;
- if(argument1 instanceof TypedLiteralAtom){
- TypedLiteralAtom typedLiteralAtom = (TypedLiteralAtom) argument1;
-
- URIResource xsdType = typedLiteralAtom.getXsdType();
-
- if(xsdType.getURI().equals(XSD.xboolean)){
- literal = factory.getOWLLiteral(Boolean.valueOf(argument1.toString()).booleanValue());
- }
- else if(xsdType.getURI().equals(XSD.xdouble)){
- literal = factory.getOWLLiteral(Double.valueOf(argument1.toString()).doubleValue());
- }
- else if(xsdType.getURI().equals(XSD.xfloat)){
- literal = factory.getOWLLiteral(Float.valueOf(argument1.toString()).floatValue());
- }
- else if(xsdType.getURI().equals(XSD.xint)){
- literal = factory.getOWLLiteral(Integer.valueOf(argument1.toString()).intValue());
- }
-
- else{
- literal = factory.getOWLLiteral(argument1.toString());
- }
-
- }
- else{
- literal = factory.getOWLLiteral(argument1.toString());
- }
-
- swrldArgument1 = factory.getSWRLLiteralArgument(literal);
-
- }
-
- SWRLDArgument swrldArgument2 = null;
-
- if(argument2.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
-
- swrldArgument2 = factory.getSWRLVariable(IRI.create(argument2.toString()));
- }
- else{
-
- OWLLiteral literal = null;
- if(argument2 instanceof TypedLiteralAtom){
- TypedLiteralAtom typedLiteralAtom = (TypedLiteralAtom) argument2;
-
- URIResource xsdType = typedLiteralAtom.getXsdType();
-
- if(xsdType.getURI().equals(XSD.xboolean)){
- literal = factory.getOWLLiteral(Boolean.valueOf(argument2.toString()).booleanValue());
- }
- else if(xsdType.getURI().equals(XSD.xdouble)){
- literal = factory.getOWLLiteral(Double.valueOf(argument2.toString()).doubleValue());
- }
- else if(xsdType.getURI().equals(XSD.xfloat)){
- literal = factory.getOWLLiteral(Float.valueOf(argument2.toString()).floatValue());
- }
- else if(xsdType.getURI().equals(XSD.xint)){
- literal = factory.getOWLLiteral(Integer.valueOf(argument2.toString()).intValue());
- }
-
- else{
- literal = factory.getOWLLiteral(argument2.toString());
- }
-
- }
- else{
- literal = factory.getOWLLiteral(argument2.toString());
- }
-
- swrldArgument2 = factory.getSWRLLiteralArgument(literal);
-
- }
-
- swrldArguments.add(swrldArgument1);
- swrldArguments.add(swrldArgument2);
-
- SWRLBuiltInAtom swrlBuiltInAtom = factory.getSWRLBuiltInAtom(SWRLBuiltInsVocabulary.GREATER_THAN.getIRI(), swrldArguments);
- return swrlBuiltInAtom;
- }
-
- @Override
- public String toKReSSyntax() {
- String arg1 = null;
- String arg2 = null;
-
- if(argument1.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg1 = "?"+argument1.toString().replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- }
- else{
- arg1 = argument1.toString();
- }
-
-
- if(argument2.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg2 = "?"+argument2.toString().replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
-
-
- return "gt(" + arg1 + ", " + arg2 +")";
- }
- else{
-
- return "gt(" + arg1 + ", " + argument2.toString() +")";
- }
- }
-
-
- private OWLLiteral getOWLTypedLiteral(Object argument){
-
- OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
-
- OWLLiteral owlLiteral;
- if(argument instanceof String){
- owlLiteral = factory.getOWLTypedLiteral((String) argument);
- }
- else if(argument instanceof Integer){
- owlLiteral = factory.getOWLTypedLiteral(((Integer) argument).intValue());
- }
- else if(argument instanceof Double){
- owlLiteral = factory.getOWLTypedLiteral(((Double) argument).doubleValue());
- }
- else if(argument instanceof Float){
- owlLiteral = factory.getOWLTypedLiteral(((Float) argument).floatValue());
- }
- else if(argument instanceof Boolean){
- owlLiteral = factory.getOWLTypedLiteral(((Boolean) argument).booleanValue());
- }
- else{
- owlLiteral = factory.getOWLStringLiteral(argument.toString());
- }
-
-
-
- return owlLiteral;
- }
-
-
- @Override
- public JenaClauseEntry toJenaClauseEntry(JenaVariableMap jenaVariableMap) {
-
- Node arg1Node = null;
- Node arg2Node = null;
-
- String arg1 = argument1.toString();
- if(arg1.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg1 = "?" + arg1.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- arg1Node = new Node_RuleVariable(arg1, jenaVariableMap.getVariableIndex(arg1));
- }
- else{
- arg1Node = getTypedLiteral(argument1);
- }
-
- String arg2 = argument2.toString();
- if(arg2.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg2 = "?" + arg2.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- arg2Node = new Node_RuleVariable(arg2, jenaVariableMap.getVariableIndex(arg2));
- }
- else{
- arg2Node = getTypedLiteral(argument2);
- }
-
- java.util.List<Node> nodes = new ArrayList<Node>();
-
- nodes.add(arg1Node);
- nodes.add(arg2Node);
-
- return new JenaClauseEntryImpl(new Functor("greaterThan", nodes, new BuiltinRegistry()), jenaVariableMap);
-
- }
-}
+ private ExpressionAtom argument1;
+ private ExpressionAtom argument2;
+ public GreaterThanAtom(ExpressionAtom argument1, ExpressionAtom argument2) {
+ this.argument1 = argument1;
+ this.argument2 = argument2;
+ }
+
+ @Override
+ public String toString() {
+ return "gt(" + argument1.toString() + ", " + argument2.toString() + ")";
+ }
+
+ @Override
+ public String prettyPrint() {
+ return argument1.prettyPrint() + ">" + argument2.prettyPrint();
+ }
+
+ private OWLLiteral getOWLTypedLiteral(Object argument) {
+
+ OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
+
+ OWLLiteral owlLiteral;
+ if (argument instanceof String) {
+ owlLiteral = factory.getOWLTypedLiteral((String) argument);
+ } else if (argument instanceof Integer) {
+ owlLiteral = factory.getOWLTypedLiteral(((Integer) argument).intValue());
+ } else if (argument instanceof Double) {
+ owlLiteral = factory.getOWLTypedLiteral(((Double) argument).doubleValue());
+ } else if (argument instanceof Float) {
+ owlLiteral = factory.getOWLTypedLiteral(((Float) argument).floatValue());
+ } else if (argument instanceof Boolean) {
+ owlLiteral = factory.getOWLTypedLiteral(((Boolean) argument).booleanValue());
+ } else {
+ owlLiteral = factory.getOWLStringLiteral(argument.toString());
+ }
+
+ return owlLiteral;
+ }
+
+ public ExpressionAtom getArgument1() {
+ return argument1;
+ }
+
+ public ExpressionAtom getArgument2() {
+ return argument2;
+ }
+}
Added: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IObjectAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IObjectAtom.java?rev=1306390&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IObjectAtom.java (added)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IObjectAtom.java Wed Mar 28 15:00:06 2012
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.rules.manager.atoms;
+
+import org.apache.stanbol.rules.base.api.URIResource;
+
+public abstract class IObjectAtom extends ExpressionAtom implements URIResource {
+
+}
Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IndividualPropertyAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IndividualPropertyAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IndividualPropertyAtom.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IndividualPropertyAtom.java Wed Mar 28 15:00:06 2012
@@ -16,267 +16,63 @@
*/
package org.apache.stanbol.rules.manager.atoms;
-import java.util.ArrayList;
-
-import org.apache.stanbol.rules.base.SWRL;
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
-import org.apache.stanbol.rules.base.api.URIResource;
-import org.apache.stanbol.rules.manager.JenaClauseEntryImpl;
-import org.apache.stanbol.rules.manager.SPARQLNot;
-import org.apache.stanbol.rules.manager.SPARQLTriple;
-import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLDataFactory;
-import org.semanticweb.owlapi.model.OWLIndividual;
-import org.semanticweb.owlapi.model.OWLObjectProperty;
-import org.semanticweb.owlapi.model.SWRLAtom;
-import org.semanticweb.owlapi.model.SWRLIArgument;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.reasoner.TriplePattern;
-import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
-import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
-
public class IndividualPropertyAtom extends CoreAtom {
- private URIResource objectProperty;
- private URIResource argument1;
- private URIResource argument2;
+ private IObjectAtom objectProperty;
+ private IObjectAtom argument1;
+ private IObjectAtom argument2;
- public IndividualPropertyAtom(URIResource objectProperty, URIResource argument1, URIResource argument2) {
+ public IndividualPropertyAtom(IObjectAtom objectProperty, IObjectAtom argument1, IObjectAtom argument2) {
this.objectProperty = objectProperty;
this.argument1 = argument1;
this.argument2 = argument2;
}
- @Override
- public SPARQLObject toSPARQL() {
- String arg1 = argument1.toString();
- String arg2 = argument2.toString();
- String objP = objectProperty.toString();
-
- boolean negativeArg1 = false;
- boolean negativeArg2 = false;
- boolean negativeObjP = false;
-
- if (arg1.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")) {
- arg1 = "?" + arg1.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- VariableAtom variable = (VariableAtom) argument1;
- if (variable.isNegative()) {
- negativeArg1 = true;
- }
- }
-
- if (arg2.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")) {
- arg2 = "?" + arg2.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- VariableAtom variable = (VariableAtom) argument2;
- if (variable.isNegative()) {
- negativeArg2 = true;
- }
- }
-
- if (objP.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")) {
- objP = "?" + objP.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- VariableAtom variable = (VariableAtom) objectProperty;
- if (variable.isNegative()) {
- negativeObjP = true;
- }
- }
-
- if (negativeArg1 || negativeArg2 || negativeObjP) {
- String optional = arg1 + " " + objP + " " + arg2;
-
- ArrayList<String> filters = new ArrayList<String>();
- if (negativeArg1) {
- filters.add("!bound(" + arg1 + ")");
- }
- if (negativeArg2) {
- filters.add("!bound(" + arg2 + ")");
- }
- if (negativeObjP) {
- filters.add("!bound(" + objP + ")");
- }
-
- String[] filterArray = new String[filters.size()];
- filterArray = filters.toArray(filterArray);
-
- return new SPARQLNot(optional, filterArray);
- } else {
- return new SPARQLTriple(arg1 + " " + objP + " " + arg2);
- }
-
- }
-
- @Override
- public Resource toSWRL(Model model) {
- Resource individualPropertyAtom = model.createResource(SWRL.IndividualPropertyAtom);
-
- Resource objectPropertyPredicate = objectProperty.createJenaResource(model);
- Resource argument1Resource = argument1.createJenaResource(model);
- Resource argument2Resource = argument2.createJenaResource(model);
-
- individualPropertyAtom.addProperty(SWRL.propertyPredicate, objectPropertyPredicate);
- individualPropertyAtom.addProperty(SWRL.argument1, argument1Resource);
- individualPropertyAtom.addProperty(SWRL.argument2, argument2Resource);
-
- return individualPropertyAtom;
- }
-
- @Override
- public SWRLAtom toSWRL(OWLDataFactory factory) {
- OWLObjectProperty owlObjectProperty = factory.getOWLObjectProperty(IRI.create(objectProperty.getURI()
- .toString()));
-
- SWRLIArgument swrliArgument1;
- SWRLIArgument swrliArgument2;
-
- if (argument1 instanceof VariableAtom) {
- swrliArgument1 = factory.getSWRLVariable(IRI.create(argument1.getURI().toString()));
- } else {
- OWLIndividual owlIndividual = factory.getOWLNamedIndividual(IRI.create(argument1.getURI()
- .toString()));
- swrliArgument1 = factory.getSWRLIndividualArgument(owlIndividual);
- }
-
- if (argument2 instanceof VariableAtom) {
- swrliArgument2 = factory.getSWRLVariable(IRI.create(argument2.getURI().toString()));
- } else {
- OWLIndividual owlIndividual = factory.getOWLNamedIndividual(IRI.create(argument2.getURI()
- .toString()));
- swrliArgument2 = factory.getSWRLIndividualArgument(owlIndividual);
- }
-
- return factory.getSWRLObjectPropertyAtom(owlObjectProperty, swrliArgument1, swrliArgument2);
- }
-
- public URIResource getObjectProperty() {
+ public IObjectAtom getObjectProperty() {
return objectProperty;
}
- public URIResource getArgument1() {
+ public IObjectAtom getArgument1() {
return argument1;
}
- public URIResource getArgument2() {
+ public IObjectAtom getArgument2() {
return argument2;
}
@Override
- public String toString() {
+ public String prettyPrint() {
return "Individual " + argument1.toString() + " has object property " + argument1.toString()
+ " that refers to individual " + argument2.toString();
}
@Override
- public String toKReSSyntax() {
- String arg1 = null;
- String arg2 = null;
- String arg3 = null;
-
- if (argument1.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")) {
- arg1 = "?"
- + argument1.toString().replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- VariableAtom variable = (VariableAtom) argument1;
- if (variable.isNegative()) {
- arg1 = "notex(" + arg1 + ")";
- }
- } else {
- arg1 = argument1.toString();
- }
-
- if (objectProperty.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")) {
- arg3 = "?"
- + objectProperty.toString().replace("http://kres.iks-project.eu/ontology/meta/variables#",
- "");
- VariableAtom variable = (VariableAtom) objectProperty;
- if (variable.isNegative()) {
- arg3 = "notex(" + arg3 + ")";
- }
- } else {
- arg3 = objectProperty.toString();
- }
-
- if (argument2.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")) {
- arg2 = "?"
- + argument2.toString().replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- VariableAtom variable = (VariableAtom) argument2;
- if (variable.isNegative()) {
- arg2 = "notex(" + arg2 + ")";
- }
- } else {
- arg2 = argument2.toString();
- }
-
- return "has(" + arg3 + ", " + arg1 + ", " + arg2 + ")";
+ public String toString() {
- }
+ return "has(" + objectProperty.toString() + ", " + argument1.toString() + ", " + argument2.toString()
+ + ")";
- @Override
- public boolean isSPARQLConstruct() {
- return false;
- }
+ /*
+ * String arg1 = null; String arg2 = null; String arg3 = null;
+ *
+ * if (argument1.toString().startsWith(Symbols.variablesPrefix)) { arg1 = "?" +
+ * argument1.toString().replace(Symbols.variablesPrefix, ""); VariableAtom variable = (VariableAtom)
+ * argument1; if (variable.isNegative()) { arg1 = "notex(" + arg1 + ")"; } } else { arg1 =
+ * argument1.toString(); }
+ *
+ * if (objectProperty.toString().startsWith(Symbols.variablesPrefix)) { arg3 = "?" +
+ * objectProperty.toString().replace(Symbols.variablesPrefix, ""); VariableAtom variable =
+ * (VariableAtom) objectProperty; if (variable.isNegative()) { arg3 = "notex(" + arg3 + ")"; } } else
+ * { arg3 = objectProperty.toString(); }
+ *
+ * if (argument2.toString().startsWith(Symbols.variablesPrefix)) { arg2 = "?" +
+ * argument2.toString().replace(Symbols.variablesPrefix, ""); VariableAtom variable = (VariableAtom)
+ * argument2; if (variable.isNegative()) { arg2 = "notex(" + arg2 + ")"; } } else { arg2 =
+ * argument2.toString(); }
+ *
+ * return "has(" + arg3 + ", " + arg1 + ", " + arg2 + ")";
+ */
- @Override
- public boolean isSPARQLDelete() {
- return false;
}
- @Override
- public JenaClauseEntry toJenaClauseEntry(JenaVariableMap jenaVariableMap) {
-
- String subject = argument1.toString();
-
- Node subjectNode = null;
- if(subject.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- subject = "?" + subject.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
-
- //subjectNode = Node_RuleVariable.createVariable(subject);
- subjectNode = new Node_RuleVariable(subject, jenaVariableMap.getVariableIndex(subject));
- }
- else{
- if(subject.startsWith("<") && subject.endsWith(">")){
- subject = subject.substring(1, subject.length()-1);
- }
- subjectNode = Node_RuleVariable.createURI(subject);
- }
-
- String object = argument2.toString();
- Node objectNode = null;
- if(object.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- object = subject.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- if(object.startsWith("?")){
- object = object.substring(1);
- }
-
- object = "?" + object;
- objectNode = new Node_RuleVariable(object, jenaVariableMap.getVariableIndex(object));
- }
- else{
- if(object.startsWith("<") && object.endsWith(">")){
- object = object.substring(1, object.length()-1);
- }
- objectNode = Node_RuleVariable.createURI(object);
- }
-
- String predicate = objectProperty.toString();
- Node predicateNode = null;
- if(predicate.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- predicate = predicate.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- //predicateNode = Node_RuleVariable.createVariable(predicate);
- predicateNode = new Node_RuleVariable(predicate, 2);
- }
- else{
- if(predicate.startsWith("<") && predicate.endsWith(">")){
- predicate = predicate.substring(1, predicate.length()-1);
- }
- predicateNode = Node_RuleVariable.createURI(predicate);
- }
-
- ClauseEntry clauseEntry = new TriplePattern(subjectNode, predicateNode, objectNode);
- return new JenaClauseEntryImpl(clauseEntry, jenaVariableMap);
- }
-
}
Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IsBlankAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IsBlankAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IsBlankAtom.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/IsBlankAtom.java Wed Mar 28 15:00:06 2012
@@ -1,111 +1,53 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.rules.manager.atoms;
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
-import org.apache.stanbol.rules.base.api.URIResource;
-import org.apache.stanbol.rules.manager.SPARQLComparison;
-import org.semanticweb.owlapi.model.OWLDataFactory;
-import org.semanticweb.owlapi.model.SWRLAtom;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
+public class IsBlankAtom extends ComparisonAtom {
+ private IObjectAtom uriResource;
-public class IsBlankAtom extends ComparisonAtom {
+ public IsBlankAtom(IObjectAtom uriResource) {
+ this.uriResource = uriResource;
+ }
+
+ @Override
+ public String toString() {
+
+ return "isBlank(" + uriResource.toString() + ")";
+
+ /*
+ * String argument = uriResource.toString();
+ *
+ * String kReS;
+ *
+ * if(argument.startsWith(Symbols.variablesPrefix)){ kReS =
+ * "?"+argument.replace(Symbols.variablesPrefix, ""); } else{ kReS = argument; }
+ *
+ * kReS = "isBlank(" + kReS + ")"; return kReS;
+ */
+ }
+
+ @Override
+ public String prettyPrint() {
+ return uriResource.toString() + " is a blank node";
+ }
+
+ public IObjectAtom getUriResource() {
+ return uriResource;
+ }
- private URIResource uriResource;
-
- public IsBlankAtom(URIResource uriResource) {
- this.uriResource = uriResource;
- }
-
- @Override
- public Resource toSWRL(Model model) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SPARQLObject toSPARQL() {
- String argument = uriResource.toString();
-
- String sparql;
-
- if(argument.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- sparql = "?"+argument.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- }
- else{
- sparql = argument;
- }
-
- sparql = "isBlank(" + sparql + ")";
-
- return new SPARQLComparison(sparql);
- }
-
- @Override
- public SWRLAtom toSWRL(OWLDataFactory factory) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String toKReSSyntax() {
- String argument = uriResource.toString();
-
- String kReS;
-
- if(argument.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- kReS = "?"+argument.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- }
- else{
- kReS = argument;
- }
-
- kReS = "isBlank(" + kReS + ")";
- return kReS;
- }
-
- @Override
- public boolean isSPARQLConstruct() {
- return false;
- }
-
-
- @Override
- public JenaClauseEntry toJenaClauseEntry(JenaVariableMap jenaVariableMap) {
-
- /*
- * TODO
- String argument = uriResource.toString();
- if(argument.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- argument = "?" + argument.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- }
-
- java.util.List<Node> nodes = new ArrayList<Node>();
-
- nodes.add(Node.createURI(argument));
-
- return new Functor("isBNode", nodes);
- */
- return null;
- }
-
}
Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LengthAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LengthAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LengthAtom.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LengthAtom.java Wed Mar 28 15:00:06 2012
@@ -1,69 +1,47 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.rules.manager.atoms;
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
-import org.apache.stanbol.rules.manager.SPARQLFunction;
-import org.semanticweb.owlapi.model.OWLDataFactory;
-import org.semanticweb.owlapi.model.SWRLAtom;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
-
+/**
+ *
+ * @author anuzzolese
+ *
+ */
public class LengthAtom extends NumericFunctionAtom {
-
- private StringFunctionAtom stringFunctionAtom;
-
- public LengthAtom(StringFunctionAtom stringFunctionAtom) {
- this.stringFunctionAtom = stringFunctionAtom;
- }
-
- @Override
- public Resource toSWRL(Model model) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SPARQLObject toSPARQL() {
- String sparql = "<http://www.w3.org/2005/xpath-functions#string-length> (" + stringFunctionAtom.toSPARQL().getObject() + ")";
-
- return new SPARQLFunction(sparql);
- }
-
- @Override
- public SWRLAtom toSWRL(OWLDataFactory factory) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String toKReSSyntax() {
- return "length(" + stringFunctionAtom.toKReSSyntax() + ")";
- }
-
- @Override
- public JenaClauseEntry toJenaClauseEntry(JenaVariableMap jenaVariableMap) {
- // TODO Auto-generated method stub
- return null;
- }
+ private StringFunctionAtom stringFunctionAtom;
+
+ public LengthAtom(StringFunctionAtom stringFunctionAtom) {
+ this.stringFunctionAtom = stringFunctionAtom;
+ }
+
+ @Override
+ public String toString() {
+ return "length(" + stringFunctionAtom.toString() + ")";
+ }
+
+ @Override
+ public String prettyPrint() {
+ return "the length of " + stringFunctionAtom.prettyPrint();
+ }
+
+ public StringFunctionAtom getStringFunctionAtom() {
+ return stringFunctionAtom;
+ }
}
Added: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LessEqualThanAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LessEqualThanAtom.java?rev=1306390&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LessEqualThanAtom.java (added)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LessEqualThanAtom.java Wed Mar 28 15:00:06 2012
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.rules.manager.atoms;
+
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLLiteral;
+
+public class LessEqualThanAtom extends ComparisonAtom {
+
+ private ExpressionAtom argument1;
+ private ExpressionAtom argument2;
+
+ public LessEqualThanAtom(ExpressionAtom argument1, ExpressionAtom argument2) {
+ this.argument1 = argument1;
+ this.argument2 = argument2;
+ }
+
+ @Override
+ public String toString() {
+ return "leq(" + argument1.toString() + ", " + argument2.toString() + ")";
+ }
+
+ private OWLLiteral getOWLTypedLiteral(Object argument) {
+
+ OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
+
+ OWLLiteral owlLiteral;
+ if (argument instanceof String) {
+ owlLiteral = factory.getOWLTypedLiteral((String) argument);
+ } else if (argument instanceof Integer) {
+ owlLiteral = factory.getOWLTypedLiteral(((Integer) argument).intValue());
+ } else if (argument instanceof Double) {
+ owlLiteral = factory.getOWLTypedLiteral(((Double) argument).doubleValue());
+ } else if (argument instanceof Float) {
+ owlLiteral = factory.getOWLTypedLiteral(((Float) argument).floatValue());
+ } else if (argument instanceof Boolean) {
+ owlLiteral = factory.getOWLTypedLiteral(((Boolean) argument).booleanValue());
+ } else {
+ owlLiteral = factory.getOWLStringLiteral(argument.toString());
+ }
+
+ return owlLiteral;
+ }
+
+ @Override
+ public String prettyPrint() {
+ return argument1.prettyPrint() + "<=" + argument2.prettyPrint();
+ }
+
+ public ExpressionAtom getArgument1() {
+ return argument1;
+ }
+
+ public ExpressionAtom getArgument2() {
+ return argument2;
+ }
+}
Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LessThanAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LessThanAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LessThanAtom.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LessThanAtom.java Wed Mar 28 15:00:06 2012
@@ -1,272 +1,72 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.rules.manager.atoms;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
-import org.apache.stanbol.rules.base.api.URIResource;
-import org.apache.stanbol.rules.manager.JenaClauseEntryImpl;
-import org.apache.stanbol.rules.manager.JenaVariableMapImpl;
-import org.apache.stanbol.rules.manager.SPARQLComparison;
import org.semanticweb.owlapi.apibinding.OWLManager;
-import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLLiteral;
-import org.semanticweb.owlapi.model.SWRLAtom;
-import org.semanticweb.owlapi.model.SWRLBuiltInAtom;
-import org.semanticweb.owlapi.model.SWRLDArgument;
-import org.semanticweb.owlapi.vocab.SWRLBuiltInsVocabulary;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.reasoner.rulesys.BuiltinRegistry;
-import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
-import com.hp.hpl.jena.reasoner.rulesys.Functor;
-import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
-import com.hp.hpl.jena.vocabulary.XSD;
-
public class LessThanAtom extends ComparisonAtom {
-
- private Object argument1;
- private Object argument2;
-
- public LessThanAtom(Object argument1, Object argument2) {
- this.argument1 = argument1;
- this.argument2 = argument2;
- }
-
- @Override
- public Resource toSWRL(Model model) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SPARQLObject toSPARQL() {
- String arg1 = argument1.toString();
- String arg2 = argument2.toString();
-
-
- if(arg1.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg1 = "str(?"+arg1.replace("http://kres.iks-project.eu/ontology/meta/variables#", "") + ")";
-
- }
- else{
- arg1 = "str("+arg1+")";
- }
-
- if(arg2.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg2 = "str(?"+arg2.replace("http://kres.iks-project.eu/ontology/meta/variables#", "") + ")";
-
- }
- else if(!arg2.startsWith("<") && !arg2.endsWith(">")){
- OWLLiteral literal = getOWLTypedLiteral(argument2);
- arg2 = "str(" + literal.getLiteral() + ")";
- }
- else{
- arg2 = "str("+arg2+")";
- }
-
-
- return new SPARQLComparison(arg1+" < "+arg2);
-
- }
-
- @Override
- public SWRLAtom toSWRL(OWLDataFactory factory) {
- List<SWRLDArgument> swrldArguments = new ArrayList<SWRLDArgument>();
-
- SWRLDArgument swrldArgument1 = null;
-
- if(argument1.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
-
- swrldArgument1 = factory.getSWRLVariable(IRI.create(argument1.toString()));
- }
- else{
-
- OWLLiteral literal = null;
- if(argument1 instanceof TypedLiteralAtom){
- TypedLiteralAtom typedLiteralAtom = (TypedLiteralAtom) argument1;
-
- URIResource xsdType = typedLiteralAtom.getXsdType();
-
- if(xsdType.getURI().equals(XSD.xboolean)){
- literal = factory.getOWLLiteral(Boolean.valueOf(argument1.toString()).booleanValue());
- }
- else if(xsdType.getURI().equals(XSD.xdouble)){
- literal = factory.getOWLLiteral(Double.valueOf(argument1.toString()).doubleValue());
- }
- else if(xsdType.getURI().equals(XSD.xfloat)){
- literal = factory.getOWLLiteral(Float.valueOf(argument1.toString()).floatValue());
- }
- else if(xsdType.getURI().equals(XSD.xint)){
- literal = factory.getOWLLiteral(Integer.valueOf(argument1.toString()).intValue());
- }
-
- else{
- literal = factory.getOWLLiteral(argument1.toString());
- }
-
- }
- else{
- literal = factory.getOWLLiteral(argument1.toString());
- }
-
- swrldArgument1 = factory.getSWRLLiteralArgument(literal);
-
- }
-
- SWRLDArgument swrldArgument2 = null;
-
- if(argument2.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
-
- swrldArgument2 = factory.getSWRLVariable(IRI.create(argument2.toString()));
- }
- else{
-
- OWLLiteral literal = null;
- if(argument2 instanceof TypedLiteralAtom){
- TypedLiteralAtom typedLiteralAtom = (TypedLiteralAtom) argument2;
-
- URIResource xsdType = typedLiteralAtom.getXsdType();
-
- if(xsdType.getURI().equals(XSD.xboolean)){
- literal = factory.getOWLLiteral(Boolean.valueOf(argument2.toString()).booleanValue());
- }
- else if(xsdType.getURI().equals(XSD.xdouble)){
- literal = factory.getOWLLiteral(Double.valueOf(argument2.toString()).doubleValue());
- }
- else if(xsdType.getURI().equals(XSD.xfloat)){
- literal = factory.getOWLLiteral(Float.valueOf(argument2.toString()).floatValue());
- }
- else if(xsdType.getURI().equals(XSD.xint)){
- literal = factory.getOWLLiteral(Integer.valueOf(argument2.toString()).intValue());
- }
-
- else{
- literal = factory.getOWLLiteral(argument2.toString());
- }
-
- }
- else{
- literal = factory.getOWLLiteral(argument2.toString());
- }
-
- swrldArgument2 = factory.getSWRLLiteralArgument(literal);
-
- }
-
- swrldArguments.add(swrldArgument1);
- swrldArguments.add(swrldArgument2);
-
- SWRLBuiltInAtom swrlBuiltInAtom = factory.getSWRLBuiltInAtom(SWRLBuiltInsVocabulary.LESS_THAN.getIRI(), swrldArguments);
- return swrlBuiltInAtom;
- }
-
- @Override
- public String toKReSSyntax() {
- String arg1 = null;
- String arg2 = null;
-
- if(argument1.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg1 = "?"+argument1.toString().replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- }
- else{
- arg1 = argument1.toString();
- }
-
-
- if(argument2.toString().startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg2 = "?"+argument2.toString().replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
-
-
- return "lt(" + arg1 + ", " + arg2 +")";
- }
- else{
-
- return "lt(" + arg1 + ", " + argument2.toString() +")";
- }
- }
-
-
- private OWLLiteral getOWLTypedLiteral(Object argument){
-
- OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
-
- OWLLiteral owlLiteral;
- if(argument instanceof String){
- owlLiteral = factory.getOWLTypedLiteral((String) argument);
- }
- else if(argument instanceof Integer){
- owlLiteral = factory.getOWLTypedLiteral(((Integer) argument).intValue());
- }
- else if(argument instanceof Double){
- owlLiteral = factory.getOWLTypedLiteral(((Double) argument).doubleValue());
- }
- else if(argument instanceof Float){
- owlLiteral = factory.getOWLTypedLiteral(((Float) argument).floatValue());
- }
- else if(argument instanceof Boolean){
- owlLiteral = factory.getOWLTypedLiteral(((Boolean) argument).booleanValue());
- }
- else{
- owlLiteral = factory.getOWLStringLiteral(argument.toString());
- }
-
-
-
- return owlLiteral;
- }
-
- @Override
- public JenaClauseEntry toJenaClauseEntry(JenaVariableMap jenaVariableMap) {
- Node arg1Node = null;
- Node arg2Node = null;
-
- String arg1 = argument1.toString();
- if(arg1.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg1 = arg1.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- arg1Node = new Node_RuleVariable(arg1, jenaVariableMap.getVariableIndex(arg1));
- }
- else{
- arg1Node = getTypedLiteral(argument1);
- }
-
- String arg2 = argument2.toString();
- if(arg2.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- arg2 = arg2.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- arg2Node = new Node_RuleVariable(arg2, jenaVariableMap.getVariableIndex(arg2));
- }
- else{
- arg2Node = getTypedLiteral(argument2);
- }
-
- java.util.List<Node> nodes = new ArrayList<Node>();
-
- nodes.add(arg1Node);
- nodes.add(arg2Node);
-
- return new JenaClauseEntryImpl(new Functor("lessThan", nodes, new BuiltinRegistry()), jenaVariableMap);
- }
+ private ExpressionAtom argument1;
+ private ExpressionAtom argument2;
+
+ public LessThanAtom(ExpressionAtom argument1, ExpressionAtom argument2) {
+ this.argument1 = argument1;
+ this.argument2 = argument2;
+ }
+
+ @Override
+ public String toString() {
+ return "lt(" + argument1.toString() + ", " + argument2.toString() + ")";
+ }
+
+ private OWLLiteral getOWLTypedLiteral(Object argument) {
+
+ OWLDataFactory factory = OWLManager.createOWLOntologyManager().getOWLDataFactory();
+
+ OWLLiteral owlLiteral;
+ if (argument instanceof String) {
+ owlLiteral = factory.getOWLTypedLiteral((String) argument);
+ } else if (argument instanceof Integer) {
+ owlLiteral = factory.getOWLTypedLiteral(((Integer) argument).intValue());
+ } else if (argument instanceof Double) {
+ owlLiteral = factory.getOWLTypedLiteral(((Double) argument).doubleValue());
+ } else if (argument instanceof Float) {
+ owlLiteral = factory.getOWLTypedLiteral(((Float) argument).floatValue());
+ } else if (argument instanceof Boolean) {
+ owlLiteral = factory.getOWLTypedLiteral(((Boolean) argument).booleanValue());
+ } else {
+ owlLiteral = factory.getOWLStringLiteral(argument.toString());
+ }
+
+ return owlLiteral;
+ }
+
+ @Override
+ public String prettyPrint() {
+ return argument1.prettyPrint() + "<" + argument2.prettyPrint();
+ }
+
+ public ExpressionAtom getArgument1() {
+ return argument1;
+ }
+
+ public ExpressionAtom getArgument2() {
+ return argument2;
+ }
}
Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LetAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LetAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LetAtom.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LetAtom.java Wed Mar 28 15:00:06 2012
@@ -1,95 +1,58 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.rules.manager.atoms;
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
import org.apache.stanbol.rules.base.api.RuleAtom;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
+import org.apache.stanbol.rules.base.api.Symbols;
import org.apache.stanbol.rules.base.api.URIResource;
-import org.apache.stanbol.rules.manager.SPARQLFunction;
-import org.semanticweb.owlapi.model.OWLDataFactory;
-import org.semanticweb.owlapi.model.SWRLAtom;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
+/**
+ *
+ * @author anuzzolese
+ *
+ */
public class LetAtom implements RuleAtom {
-
- private Logger log = LoggerFactory.getLogger(getClass());
- private URIResource variable;
- private StringFunctionAtom parameterFunctionAtom;
-
- public LetAtom(URIResource variable, StringFunctionAtom parameterFunctionAtom) {
- this.variable = variable;
- this.parameterFunctionAtom = parameterFunctionAtom;
- }
-
- @Override
- public Resource toSWRL(Model model) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SPARQLObject toSPARQL() {
- log.debug("Parameter Function : "+parameterFunctionAtom.toSPARQL().getObject());
- String variableArgument = variable.toString().replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- String let = "LET (?" + variableArgument + " := " + parameterFunctionAtom.toSPARQL().getObject() + ")";
- SPARQLObject sparqlObject = new SPARQLFunction(let);
- return sparqlObject;
- }
-
- @Override
- public SWRLAtom toSWRL(OWLDataFactory factory) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String toKReSSyntax() {
- String arg1 = "?" + variable.toString().replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- String syntax = "let(" + arg1 + ", " + parameterFunctionAtom.toKReSSyntax() + ")";
- return syntax;
- }
-
-
- @Override
- public boolean isSPARQLConstruct() {
- return false;
- }
-
- @Override
- public boolean isSPARQLDelete() {
- return false;
- }
-
- @Override
- public boolean isSPARQLDeleteData() {
- return false;
- }
-
- @Override
- public JenaClauseEntry toJenaClauseEntry(JenaVariableMap jenaVariableMap) {
- // TODO Auto-generated method stub
- return null;
- }
+ private IObjectAtom variable;
+ private StringFunctionAtom parameterFunctionAtom;
+
+ public LetAtom(IObjectAtom variable, StringFunctionAtom parameterFunctionAtom) {
+ this.variable = variable;
+ this.parameterFunctionAtom = parameterFunctionAtom;
+ }
+
+ @Override
+ public String toString() {
+ String arg1 = variable.toString();
+ String syntax = "let(" + arg1 + ", " + parameterFunctionAtom.toString() + ")";
+ return syntax;
+ }
+
+ @Override
+ public String prettyPrint() {
+ return "bind " + variable.toString() + " to " + parameterFunctionAtom.prettyPrint();
+ }
+
+ public StringFunctionAtom getParameterFunctionAtom() {
+ return parameterFunctionAtom;
+ }
+
+ public IObjectAtom getVariable() {
+ return variable;
+ }
}
Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LocalNameAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LocalNameAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LocalNameAtom.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LocalNameAtom.java Wed Mar 28 15:00:06 2012
@@ -1,80 +1,46 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.rules.manager.atoms;
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
+import org.apache.stanbol.rules.base.api.Symbols;
import org.apache.stanbol.rules.base.api.URIResource;
-import org.apache.stanbol.rules.manager.SPARQLFunction;
-import org.semanticweb.owlapi.model.OWLDataFactory;
-import org.semanticweb.owlapi.model.SWRLAtom;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
-
public class LocalNameAtom extends StringFunctionAtom {
- private URIResource uriResource;
-
- public LocalNameAtom(URIResource uriResource) {
- this.uriResource = uriResource;
- }
-
- @Override
- public Resource toSWRL(Model model) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SPARQLObject toSPARQL() {
- String argument = uriResource.toString();
-
- if(argument.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- argument = "?"+argument.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- }
-
- String sparql = "<http://jena.hpl.hp.com/ARQ/function#localname>(" + argument + ")";
- return new SPARQLFunction(sparql);
- }
-
- @Override
- public SWRLAtom toSWRL(OWLDataFactory factory) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String toKReSSyntax() {
- String argument = uriResource.toString();
-
- if(argument.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- argument = "?"+argument.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- }
- return "localname(" + argument + ")";
- }
-
- @Override
- public JenaClauseEntry toJenaClauseEntry(JenaVariableMap jenaVariableMap) {
- // TODO Auto-generated method stub
- return null;
- }
+ private IObjectAtom uriResource;
+
+ public LocalNameAtom(IObjectAtom uriResource) {
+ this.uriResource = uriResource;
+ }
+
+ public IObjectAtom getUriResource() {
+ return uriResource;
+ }
+
+ @Override
+ public String toString() {
+ String argument = uriResource.toString();
+
+ return "localname(" + argument + ")";
+ }
+
+ @Override
+ public String prettyPrint() {
+ return "the local name of " + uriResource.toString();
+ }
}
Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LowerCaseAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LowerCaseAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LowerCaseAtom.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/LowerCaseAtom.java Wed Mar 28 15:00:06 2012
@@ -1,86 +1,41 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.rules.manager.atoms;
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
-import org.apache.stanbol.rules.manager.SPARQLFunction;
-import org.semanticweb.owlapi.model.OWLDataFactory;
-import org.semanticweb.owlapi.model.SWRLAtom;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+public class LowerCaseAtom extends StringFunctionAtom {
+ private StringFunctionAtom stringFunctionAtom;
-public class LowerCaseAtom extends StringFunctionAtom {
+ public LowerCaseAtom(StringFunctionAtom stringFunctionAtom) {
+ this.stringFunctionAtom = stringFunctionAtom;
+ }
+
+ public StringFunctionAtom getStringFunctionAtom() {
+ return stringFunctionAtom;
+ }
+
+ @Override
+ public String toString() {
+ return "lowerCase(" + stringFunctionAtom.toString() + ")";
+ }
+
+ @Override
+ public String prettyPrint() {
+ return "the lower-case representation of \"" + stringFunctionAtom.prettyPrint() + "\"";
+ }
- private StringFunctionAtom stringFunctionAtom;
-
- public LowerCaseAtom(StringFunctionAtom stringFunctionAtom) {
- this.stringFunctionAtom = stringFunctionAtom;
- }
-
- @Override
- public Resource toSWRL(Model model) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SPARQLObject toSPARQL() {
-
- String uriResourceString = stringFunctionAtom.toSPARQL().getObject();
-
- if(uriResourceString.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- uriResourceString = "?"+uriResourceString.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
-
- }
-
- String sparql = "<http://www.w3.org/2005/xpath-functions#lower-case> (" + uriResourceString + ")";
-
- return new SPARQLFunction(sparql);
- }
-
- @Override
- public SWRLAtom toSWRL(OWLDataFactory factory) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String toKReSSyntax() {
- String uriResourceString = stringFunctionAtom.toKReSSyntax();
-
- if(uriResourceString.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- uriResourceString = "?"+uriResourceString.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
-
- }
-
- return "lowerCase(" + uriResourceString + ")";
- }
-
- @Override
- public JenaClauseEntry toJenaClauseEntry(JenaVariableMap jenaVariableMap) {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-
}
\ No newline at end of file
Added: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/MultiplicationAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/MultiplicationAtom.java?rev=1306390&view=auto
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/MultiplicationAtom.java (added)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/MultiplicationAtom.java Wed Mar 28 15:00:06 2012
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.rules.manager.atoms;
+
+public class MultiplicationAtom extends NumericFunctionAtom {
+
+ private NumericFunctionAtom numericFunctionAtom1;
+ private NumericFunctionAtom numericFunctionAtom2;
+
+ public MultiplicationAtom(NumericFunctionAtom numericFunctionAtom1,
+ NumericFunctionAtom numericFunctionAtom2) {
+ this.numericFunctionAtom1 = numericFunctionAtom1;
+ this.numericFunctionAtom2 = numericFunctionAtom2;
+ }
+
+ public NumericFunctionAtom getNumericFunctionAtom1() {
+ return numericFunctionAtom1;
+ }
+
+ public NumericFunctionAtom getNumericFunctionAtom2() {
+ return numericFunctionAtom2;
+ }
+
+ @Override
+ public String toString() {
+ String kReSFunction1 = numericFunctionAtom1.toString();
+ String kReSFunction2 = numericFunctionAtom2.toString();
+ return "mult(" + kReSFunction1 + ", " + kReSFunction2 + ")";
+ }
+
+ @Override
+ public String prettyPrint() {
+ return numericFunctionAtom1.prettyPrint() + "*" + numericFunctionAtom2.prettyPrint();
+ }
+
+}
Modified: incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/NamespaceAtom.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/NamespaceAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/NamespaceAtom.java (original)
+++ incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/NamespaceAtom.java Wed Mar 28 15:00:06 2012
@@ -1,80 +1,43 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.stanbol.rules.manager.atoms;
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
-import org.apache.stanbol.rules.base.api.URIResource;
-import org.apache.stanbol.rules.manager.SPARQLFunction;
-import org.semanticweb.owlapi.model.OWLDataFactory;
-import org.semanticweb.owlapi.model.SWRLAtom;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
-
-
public class NamespaceAtom extends StringFunctionAtom {
-private URIResource uriResource;
-
- public NamespaceAtom(URIResource uriResource) {
- this.uriResource = uriResource;
- }
-
- @Override
- public Resource toSWRL(Model model) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public SPARQLObject toSPARQL() {
- String argument = uriResource.toString();
-
- if(argument.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- argument = "?"+argument.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- }
-
- String sparql = "<http://jena.hpl.hp.com/ARQ/function#namespace>(" + argument + ")";
- return new SPARQLFunction(sparql);
- }
-
- @Override
- public SWRLAtom toSWRL(OWLDataFactory factory) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public String toKReSSyntax() {
- String argument = uriResource.toString();
-
- if(argument.startsWith("http://kres.iks-project.eu/ontology/meta/variables#")){
- argument = "?"+argument.replace("http://kres.iks-project.eu/ontology/meta/variables#", "");
- }
- return "namespace(" + argument + ")";
- }
-
- @Override
- public JenaClauseEntry toJenaClauseEntry(JenaVariableMap jenaVariableMap) {
- // TODO Auto-generated method stub
- return null;
- }
+ private IObjectAtom uriResource;
+
+ public NamespaceAtom(IObjectAtom uriResource) {
+ this.uriResource = uriResource;
+ }
+
+ public IObjectAtom getUriResource() {
+ return uriResource;
+ }
+
+ @Override
+ public String toString() {
+ String argument = uriResource.toString();
+
+ return "namespace(" + argument + ")";
+ }
+
+ @Override
+ public String prettyPrint() {
+ return "the namespace of the URI <" + uriResource.toString() + ">";
+ }
}