You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2015/03/19 22:34:39 UTC

[5/6] clerezza git commit: CLEREZZA-964: using rdf-commons from clerezza-rdf-core repository

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriMutatingGraph.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriMutatingGraph.java b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriMutatingGraph.java
new file mode 100644
index 0000000..4b0a4dc
--- /dev/null
+++ b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriMutatingGraph.java
@@ -0,0 +1,223 @@
+/*
+ * 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.clerezza.rdf.utils;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.locks.ReadWriteLock;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.AbstractGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleImmutableGraph;
+
+/**
+ * This wrapps a Triplecollection changing a prefix for the Iris contained
+ * in subject or object position.
+ *
+ * Currently it only supports read opearations.
+ *
+ * @author reto
+ */
+public class UriMutatingGraph implements Graph {
+
+    private final Graph base;
+    private final String sourcePrefix;
+    private final String targetPrefix;
+    private final int sourcePrefixLength;
+    private final int targetPrefixLength;
+
+    public UriMutatingGraph(Graph base, String sourcePrefix,
+            String targetPrefix) {
+        this.base = base;
+        this.sourcePrefix = sourcePrefix;
+        sourcePrefixLength= sourcePrefix.length();
+        this.targetPrefix = targetPrefix;
+        targetPrefixLength= targetPrefix.length();
+    }
+
+    private <R extends RdfTerm> R toTargetRdfTerm(final R sourceRdfTerm) {
+        if (sourceRdfTerm instanceof Iri) {
+            final Iri sourceIri = (Iri) sourceRdfTerm;
+            if (sourceIri.getUnicodeString().startsWith(sourcePrefix)) {
+                final String uriRest = sourceIri.getUnicodeString()
+                        .substring(sourcePrefixLength);
+                return (R) new Iri(targetPrefix+uriRest);
+            }
+        }
+        return sourceRdfTerm;            
+    }
+
+    private Triple toTargetTriple(Triple triple) {
+        if (triple == null) {
+            return null;
+        }
+        return new TripleImpl(toTargetRdfTerm(triple.getSubject()),
+                triple.getPredicate(), toTargetRdfTerm(triple.getObject()));
+    }
+
+    private <R extends RdfTerm> R toSourceRdfTerm(final R targetRdfTerm) {
+        if (targetRdfTerm instanceof Iri) {
+            final Iri sourceIri = (Iri) targetRdfTerm;
+            if (sourceIri.getUnicodeString().startsWith(targetPrefix)) {
+                final String uriRest = sourceIri.getUnicodeString()
+                        .substring(targetPrefixLength);
+                return (R) new Iri(sourcePrefix+uriRest);
+            }
+        }
+        return targetRdfTerm;
+    }
+
+    private Triple toSourceTriple(Triple triple) {
+        if (triple == null) {
+            return null;
+        }
+        return new TripleImpl(toSourceRdfTerm(triple.getSubject()),
+                triple.getPredicate(), toSourceRdfTerm(triple.getObject()));
+    }
+
+    @Override
+    public Iterator<Triple> filter(BlankNodeOrIri subject, Iri predicate, RdfTerm object) {
+        final Iterator<Triple> baseIter = base.filter(toSourceRdfTerm(subject),
+                predicate, toSourceRdfTerm(object));
+        return new WrappedIteraror(baseIter);
+
+
+    }
+
+
+    @Override
+    public int size() {
+        return base.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return base.isEmpty();
+    }
+
+    @Override
+    public boolean contains(Object o) {
+        return base.contains(toSourceTriple((Triple)o));
+    }
+
+    @Override
+    public Iterator<Triple> iterator() {
+        return filter(null, null, null);
+    }
+
+    @Override
+    public Object[] toArray() {
+        Object[] result = base.toArray();
+        for (int i = 0; i < result.length; i++) {
+            Triple triple = (Triple) result[i];
+            result[i] = toTargetTriple(triple);
+        }
+        return result;
+    }
+
+    @Override
+    public <T> T[] toArray(T[] a) {
+        T[] result = base.toArray(a);
+        for (int i = 0; i < result.length; i++) {
+            Triple triple = (Triple) result[i];
+            result[i] = (T) toTargetTriple(triple);
+        }
+        return result;
+    }
+
+    @Override
+    public boolean add(Triple e) {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public boolean remove(Object o) {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public boolean containsAll(Collection<?> c) {
+        for (Object object : c) {
+            if (!contains(object)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public boolean addAll(Collection<? extends Triple> c) {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public boolean removeAll(Collection<?> c) {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public boolean retainAll(Collection<?> c) {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public void clear() {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
+    @Override
+    public ImmutableGraph getImmutableGraph() {
+        return new SimpleImmutableGraph(this);
+    }
+
+    @Override
+    public ReadWriteLock getLock() {
+        return base.getLock();
+    }
+
+    class WrappedIteraror implements Iterator<Triple>{
+        private final Iterator<Triple> baseIter;
+
+        private WrappedIteraror(Iterator<Triple> baseIter) {
+            this.baseIter = baseIter;
+        }
+
+        @Override
+        public boolean hasNext() {
+            return baseIter.hasNext();
+        }
+
+        @Override
+        public Triple next() {
+            return toTargetTriple(baseIter.next());
+        }
+
+        @Override
+        public void remove() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriMutatingTripleCollection.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriMutatingTripleCollection.java b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriMutatingTripleCollection.java
deleted file mode 100644
index fa4f732..0000000
--- a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriMutatingTripleCollection.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * 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.clerezza.rdf.utils;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.apache.clerezza.rdf.core.NonLiteral;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.event.FilterTriple;
-import org.apache.clerezza.rdf.core.event.GraphListener;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-
-/**
- * This wrapps a Triplecollection changing a prefix for the UriRefs contained
- * in subject or object position.
- *
- * Currently it only supports read opearations.
- *
- * @author reto
- */
-public class UriMutatingTripleCollection implements TripleCollection {
-
-    private final TripleCollection base;
-    private final String sourcePrefix;
-    private final String targetPrefix;
-    private final int sourcePrefixLength;
-    private final int targetPrefixLength;
-
-    public UriMutatingTripleCollection(TripleCollection base, String sourcePrefix,
-            String targetPrefix) {
-        this.base = base;
-        this.sourcePrefix = sourcePrefix;
-        sourcePrefixLength= sourcePrefix.length();
-        this.targetPrefix = targetPrefix;
-        targetPrefixLength= targetPrefix.length();
-    }
-
-    private <R extends Resource> R toTargetResource(final R sourceResource) {
-        if (sourceResource instanceof UriRef) {
-            final UriRef sourceUriRef = (UriRef) sourceResource;
-            if (sourceUriRef.getUnicodeString().startsWith(sourcePrefix)) {
-                final String uriRest = sourceUriRef.getUnicodeString()
-                        .substring(sourcePrefixLength);
-                return (R) new UriRef(targetPrefix+uriRest);
-            }
-        }
-        return sourceResource;            
-    }
-
-    private Triple toTargetTriple(Triple triple) {
-        if (triple == null) {
-            return null;
-        }
-        return new TripleImpl(toTargetResource(triple.getSubject()),
-                triple.getPredicate(), toTargetResource(triple.getObject()));
-    }
-
-    private <R extends Resource> R toSourceResource(final R targetResource) {
-        if (targetResource instanceof UriRef) {
-            final UriRef sourceUriRef = (UriRef) targetResource;
-            if (sourceUriRef.getUnicodeString().startsWith(targetPrefix)) {
-                final String uriRest = sourceUriRef.getUnicodeString()
-                        .substring(targetPrefixLength);
-                return (R) new UriRef(sourcePrefix+uriRest);
-            }
-        }
-        return targetResource;
-    }
-
-    private Triple toSourceTriple(Triple triple) {
-        if (triple == null) {
-            return null;
-        }
-        return new TripleImpl(toSourceResource(triple.getSubject()),
-                triple.getPredicate(), toSourceResource(triple.getObject()));
-    }
-
-    @Override
-    public Iterator<Triple> filter(NonLiteral subject, UriRef predicate, Resource object) {
-        final Iterator<Triple> baseIter = base.filter(toSourceResource(subject),
-                predicate, toSourceResource(object));
-        return new WrappedIteraror(baseIter);
-
-
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter, long delay) {
-    }
-
-    @Override
-    public void addGraphListener(GraphListener listener, FilterTriple filter) {
-    }
-
-    @Override
-    public void removeGraphListener(GraphListener listener) {
-    }
-
-    @Override
-    public int size() {
-        return base.size();
-    }
-
-    @Override
-    public boolean isEmpty() {
-        return base.isEmpty();
-    }
-
-    @Override
-    public boolean contains(Object o) {
-        return base.contains(toSourceTriple((Triple)o));
-    }
-
-    @Override
-    public Iterator<Triple> iterator() {
-        return filter(null, null, null);
-    }
-
-    @Override
-    public Object[] toArray() {
-        Object[] result = base.toArray();
-        for (int i = 0; i < result.length; i++) {
-            Triple triple = (Triple) result[i];
-            result[i] = toTargetTriple(triple);
-        }
-        return result;
-    }
-
-    @Override
-    public <T> T[] toArray(T[] a) {
-        T[] result = base.toArray(a);
-        for (int i = 0; i < result.length; i++) {
-            Triple triple = (Triple) result[i];
-            result[i] = (T) toTargetTriple(triple);
-        }
-        return result;
-    }
-
-    @Override
-    public boolean add(Triple e) {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-    @Override
-    public boolean remove(Object o) {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-    @Override
-    public boolean containsAll(Collection<?> c) {
-        for (Object object : c) {
-            if (!contains(object)) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    @Override
-    public boolean addAll(Collection<? extends Triple> c) {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-    @Override
-    public boolean removeAll(Collection<?> c) {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-    @Override
-    public boolean retainAll(Collection<?> c) {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-    @Override
-    public void clear() {
-        throw new UnsupportedOperationException("Not supported.");
-    }
-
-    class WrappedIteraror implements Iterator<Triple>{
-        private final Iterator<Triple> baseIter;
-
-        private WrappedIteraror(Iterator<Triple> baseIter) {
-            this.baseIter = baseIter;
-        }
-
-        @Override
-        public boolean hasNext() {
-            return baseIter.hasNext();
-        }
-
-        @Override
-        public Triple next() {
-            return toTargetTriple(baseIter.next());
-        }
-
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriRefUtil.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriRefUtil.java b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriRefUtil.java
deleted file mode 100644
index 4aed365..0000000
--- a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/UriRefUtil.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.clerezza.rdf.utils;
-
-
-/**
- * A utility class for UriRef and String manipulations.
- *
- * @author tio
- */
-public class UriRefUtil {
-
-    /**
-     * Strips #x00 - #x1F and #x7F-#x9F from a Unicode string
-     * @see <a href="http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference">
-     * http://www.w3.org/TR/rdf-concepts/#dfn-URI-reference</a> and
-     * replaces all US-ASCII space character with a "+".
-     *
-     * @param inputChars
-     * @return the stripped string
-     * 
-     */
-    public static String stripNonUriRefChars(CharSequence inputChars) {
-
-        if (inputChars == null) {
-            return "";
-        }
-
-        StringBuffer buffer = new StringBuffer();
-
-        for (int i = 0; i < inputChars.length(); i++) {
-            char c = inputChars.charAt(i);
-
-            if (!isIllegal(c)) {
-                buffer.append(c);
-            }
-        }
-        return buffer.toString().replaceAll("\\s+", "+");
-    }
-
-    private static boolean isIllegal(char ch) {
-        if ((ch >= 0x7F) && (ch <= 0x9F)) {
-            return true;
-        }
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/graphnodeprovider/GraphNodeProvider.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/graphnodeprovider/GraphNodeProvider.java b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/graphnodeprovider/GraphNodeProvider.java
index 3f839e9..03c73a5 100644
--- a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/graphnodeprovider/GraphNodeProvider.java
+++ b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/graphnodeprovider/GraphNodeProvider.java
@@ -18,7 +18,7 @@ package org.apache.clerezza.rdf.utils.graphnodeprovider;
  * specific language governing permissions and limitations
  * under the License.
  */
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.commons.rdf.Iri;
 import org.apache.clerezza.rdf.utils.GraphNode;
 
 /**
@@ -34,18 +34,18 @@ public interface GraphNodeProvider {
      * Get a GraphNode for the specified resource, see class comments for
      * details.
      */
-    GraphNode get(UriRef uriRef);
+    GraphNode get(Iri uriRef);
 
     /**
      * Get a GraphNode for the specified resource, The resource is assumed to be
-     * local, i.e. the method behaves like get(UriRef) for a Uri with an
+     * local, i.e. the method behaves like get(Iri) for a Uri with an
      * authority section contained in the Set retuned by
      * <code>org.apache.clerezza.platform.config.PlatformConfig#getBaseUris()</code>
      */
-    GraphNode getLocal(UriRef uriRef);
+    GraphNode getLocal(Iri uriRef);
 
     /**
      * return true iff getLocal(uriRef).getNodeContext.size > 0
      */
-    boolean existsLocal(UriRef uriRef);
+    boolean existsLocal(Iri uriRef);
 }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/BaseSmusher.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/BaseSmusher.java b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/BaseSmusher.java
index ad03681..1841cd1 100644
--- a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/BaseSmusher.java
+++ b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/BaseSmusher.java
@@ -21,15 +21,14 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.locks.Lock;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.NonLiteral;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.LockableMGraph;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
 import org.apache.clerezza.rdf.ontologies.OWL;
 
 /**
@@ -50,12 +49,12 @@ public class BaseSmusher {
      * @param equivalenceSets sets of equivalent resources
      * @param addOwlSameAs whether owl:sameAs statements should be added
      */
-    public void smush(LockableMGraph mGraph, Set<Set<NonLiteral>> equivalenceSets, boolean addOwlSameAs) {
-        Map<NonLiteral, NonLiteral> current2ReplacementMap = new HashMap<NonLiteral, NonLiteral>();
-        final MGraph owlSameAsGraph = new SimpleMGraph();
-        for (Set<NonLiteral> equivalenceSet : equivalenceSets) {
-            final NonLiteral replacement = getReplacementFor(equivalenceSet, owlSameAsGraph);
-            for (NonLiteral current : equivalenceSet) {
+    public void smush(Graph mGraph, Set<Set<BlankNodeOrIri>> equivalenceSets, boolean addOwlSameAs) {
+        Map<BlankNodeOrIri, BlankNodeOrIri> current2ReplacementMap = new HashMap<BlankNodeOrIri, BlankNodeOrIri>();
+        final Graph owlSameAsGraph = new SimpleGraph();
+        for (Set<BlankNodeOrIri> equivalenceSet : equivalenceSets) {
+            final BlankNodeOrIri replacement = getReplacementFor(equivalenceSet, owlSameAsGraph);
+            for (BlankNodeOrIri current : equivalenceSet) {
                 if (!current.equals(replacement)) {
                     current2ReplacementMap.put(current, replacement);
                 }
@@ -67,11 +66,11 @@ public class BaseSmusher {
         try {
             for (Iterator<Triple> it = mGraph.iterator(); it.hasNext();) {
                 final Triple triple = it.next();
-                final NonLiteral subject = triple.getSubject();
-                NonLiteral subjectReplacement = current2ReplacementMap.get(subject);
-                final Resource object = triple.getObject();
+                final BlankNodeOrIri subject = triple.getSubject();
+                BlankNodeOrIri subjectReplacement = current2ReplacementMap.get(subject);
+                final RdfTerm object = triple.getObject();
                 @SuppressWarnings(value = "element-type-mismatch")
-                Resource objectReplacement = current2ReplacementMap.get(object);
+                RdfTerm objectReplacement = current2ReplacementMap.get(object);
                 if ((subjectReplacement != null) || (objectReplacement != null)) {
                     it.remove();
                     if (subjectReplacement == null) {
@@ -92,24 +91,24 @@ public class BaseSmusher {
         }
     }
     
-    private NonLiteral getReplacementFor(Set<NonLiteral> equivalenceSet, 
-            MGraph owlSameAsGraph) {
-        final Set<UriRef> uriRefs = new HashSet<UriRef>();
-        for (NonLiteral nonLiteral : equivalenceSet) {
-            if (nonLiteral instanceof UriRef) {
-                uriRefs.add((UriRef) nonLiteral);
+    private BlankNodeOrIri getReplacementFor(Set<BlankNodeOrIri> equivalenceSet, 
+            Graph owlSameAsGraph) {
+        final Set<Iri> uriRefs = new HashSet<Iri>();
+        for (BlankNodeOrIri nonLiteral : equivalenceSet) {
+            if (nonLiteral instanceof Iri) {
+                uriRefs.add((Iri) nonLiteral);
             }
         }
         switch (uriRefs.size()) {
             case 1:
                 return uriRefs.iterator().next();
             case 0:
-                return new BNode();
+                return new BlankNode();
         }
-        final UriRef preferedIri = getPreferedIri(uriRefs);
-        final Iterator<UriRef> uriRefIter = uriRefs.iterator();
+        final Iri preferedIri = getPreferedIri(uriRefs);
+        final Iterator<Iri> uriRefIter = uriRefs.iterator();
         while (uriRefIter.hasNext()) {
-            UriRef uriRef = uriRefIter.next();
+            Iri uriRef = uriRefIter.next();
             if (!uriRef.equals(preferedIri)) {
                 owlSameAsGraph.add(new TripleImpl(uriRef, OWL.sameAs, preferedIri));
             }
@@ -126,8 +125,8 @@ public class BaseSmusher {
      * @param uriRefs
      * @return 
      */
-    protected UriRef getPreferedIri(Set<UriRef> uriRefs) {
-        final Iterator<UriRef> uriRefIter = uriRefs.iterator();
+    protected Iri getPreferedIri(Set<Iri> uriRefs) {
+        final Iterator<Iri> uriRefIter = uriRefs.iterator();
         //instead of an arbitrary one we might either decide lexicographically
         //or look at their frequency in mGraph
         return uriRefIter.next();

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/IfpSmusher.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/IfpSmusher.java b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/IfpSmusher.java
index 0e1d380..fad1d6b 100644
--- a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/IfpSmusher.java
+++ b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/IfpSmusher.java
@@ -18,7 +18,6 @@
  */
 package org.apache.clerezza.rdf.utils.smushing;
 
-import org.apache.clerezza.rdf.utils.*;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -26,16 +25,11 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.NonLiteral;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.LockableMGraph;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Iri;
 import org.apache.clerezza.rdf.ontologies.OWL;
 import org.apache.clerezza.rdf.ontologies.RDF;
 import org.slf4j.Logger;
@@ -61,35 +55,35 @@ public class IfpSmusher extends BaseSmusher {
      * @param mGraph
      * @param tBox
      */
-    public void smush(LockableMGraph mGraph, TripleCollection tBox) {
-        final Set<UriRef> ifps = getIfps(tBox);
-        final Map<PredicateObject, Set<NonLiteral>> ifp2nodesMap = new HashMap<PredicateObject, Set<NonLiteral>>();
+    public void smush(Graph mGraph, Graph tBox) {
+        final Set<Iri> ifps = getIfps(tBox);
+        final Map<PredicateObject, Set<BlankNodeOrIri>> ifp2nodesMap = new HashMap<PredicateObject, Set<BlankNodeOrIri>>();
         for (Iterator<Triple> it = mGraph.iterator(); it.hasNext();) {
             final Triple triple = it.next();
-            final UriRef predicate = triple.getPredicate();
+            final Iri predicate = triple.getPredicate();
             if (!ifps.contains(predicate)) {
                 continue;
             }
             final PredicateObject po = new PredicateObject(predicate, triple.getObject());
-            Set<NonLiteral> equivalentNodes = ifp2nodesMap.get(po);
+            Set<BlankNodeOrIri> equivalentNodes = ifp2nodesMap.get(po);
             if (equivalentNodes == null) {
-                equivalentNodes = new HashSet<NonLiteral>();
+                equivalentNodes = new HashSet<BlankNodeOrIri>();
                 ifp2nodesMap.put(po, equivalentNodes);
             }
             equivalentNodes.add(triple.getSubject());
         }
-        Set<Set<NonLiteral>> unitedEquivalenceSets = uniteSetsWithCommonElement(ifp2nodesMap.values());
+        Set<Set<BlankNodeOrIri>> unitedEquivalenceSets = uniteSetsWithCommonElement(ifp2nodesMap.values());
         smush(mGraph, unitedEquivalenceSets, true);
     }
     
 
-    private Set<UriRef> getIfps(TripleCollection tBox) {
+    private Set<Iri> getIfps(Graph tBox) {
         final Iterator<Triple> ifpDefinitions = tBox.filter(null, RDF.type,
                 OWL.InverseFunctionalProperty);
-        final Set<UriRef> ifps = new HashSet<UriRef>();
+        final Set<Iri> ifps = new HashSet<Iri>();
         while (ifpDefinitions.hasNext()) {
             final Triple triple = ifpDefinitions.next();
-            ifps.add((UriRef) triple.getSubject());
+            ifps.add((Iri) triple.getSubject());
         }
         return ifps;
     }
@@ -136,10 +130,10 @@ public class IfpSmusher extends BaseSmusher {
 
     class PredicateObject {
 
-        final UriRef predicate;
-        final Resource object;
+        final Iri predicate;
+        final RdfTerm object;
 
-        public PredicateObject(UriRef predicate, Resource object) {
+        public PredicateObject(Iri predicate, RdfTerm object) {
             this.predicate = predicate;
             this.object = object;
         }

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmusher.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmusher.java b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmusher.java
index e9ccbe0..e656a42 100644
--- a/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmusher.java
+++ b/rdf.utils/src/main/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmusher.java
@@ -24,11 +24,10 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.clerezza.rdf.core.NonLiteral;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.LockableMGraph;
+import org.apache.commons.rdf.BlankNodeOrIri;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
 import org.apache.clerezza.rdf.ontologies.OWL;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,43 +49,43 @@ public class SameAsSmusher extends BaseSmusher {
      * @param owlSameStatements 
      * @param addCanonicalSameAsStatements if true owl:sameAsStatements with the preferedIri as object will be added
      */
-    public void smush(LockableMGraph mGraph, 
-            TripleCollection owlSameStatements,
+    public void smush(Graph mGraph, 
+            Graph owlSameStatements,
             boolean addCanonicalSameAsStatements) {
     	
     	log.info("Starting smushing");
         
     	// This hashmap contains a uri (key) and the set of equivalent uris (value)
-    	final Map<NonLiteral, Set<NonLiteral>> node2EquivalenceSet = new HashMap<NonLiteral, Set<NonLiteral>>();
+    	final Map<BlankNodeOrIri, Set<BlankNodeOrIri>> node2EquivalenceSet = new HashMap<BlankNodeOrIri, Set<BlankNodeOrIri>>();
     	
     	log.info("Creating the sets of equivalent uris of each subject or object in the owl:sameAs statements");
     	// Determines for each subject and object in all the owl:sameAs statements the set of ewquivalent uris 
     	for (Iterator<Triple> it = owlSameStatements.iterator(); it.hasNext();) {            
     		final Triple triple = it.next();
-            final UriRef predicate = triple.getPredicate();
+            final Iri predicate = triple.getPredicate();
             if (!predicate.equals(OWL.sameAs)) {
                 throw new RuntimeException("Statements must use only <http://www.w3.org/2002/07/owl#sameAs> predicate.");
             }
-            final NonLiteral subject = triple.getSubject();
+            final BlankNodeOrIri subject = triple.getSubject();
             //literals not yet supported
-            final NonLiteral object = (NonLiteral)triple.getObject();
+            final BlankNodeOrIri object = (BlankNodeOrIri)triple.getObject();
             
-            Set<NonLiteral> equivalentNodes = node2EquivalenceSet.get(subject);
+            Set<BlankNodeOrIri> equivalentNodes = node2EquivalenceSet.get(subject);
             
             // if there is not a set of equivalent uris then create a new set
             if (equivalentNodes == null) {
             	equivalentNodes = node2EquivalenceSet.get(object);
             	if (equivalentNodes == null) {
-                    equivalentNodes = new HashSet<NonLiteral>();
+                    equivalentNodes = new HashSet<BlankNodeOrIri>();
                 }
             } else {
-                Set<NonLiteral> objectSet = node2EquivalenceSet.get(object);
+                Set<BlankNodeOrIri> objectSet = node2EquivalenceSet.get(object);
                 if ((objectSet != null) && (objectSet != equivalentNodes)) {
                     //merge two sets
-                    for (NonLiteral res : objectSet) {
+                    for (BlankNodeOrIri res : objectSet) {
                         node2EquivalenceSet.remove(res);
                     }
-                    for (NonLiteral res : objectSet) {
+                    for (BlankNodeOrIri res : objectSet) {
                         node2EquivalenceSet.put(res,equivalentNodes);
                     }
                     equivalentNodes.addAll(objectSet);
@@ -106,7 +105,7 @@ public class SameAsSmusher extends BaseSmusher {
     	}
     	
     	// This set contains the sets of equivalent uris
-    	Set<Set<NonLiteral>> unitedEquivalenceSets = new HashSet<Set<NonLiteral>>(node2EquivalenceSet.values());
+    	Set<Set<BlankNodeOrIri>> unitedEquivalenceSets = new HashSet<Set<BlankNodeOrIri>>(node2EquivalenceSet.values());
         smush(mGraph, unitedEquivalenceSets, addCanonicalSameAsStatements);
     }
 

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/GraphUtilsTest.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/GraphUtilsTest.java b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/GraphUtilsTest.java
new file mode 100644
index 0000000..fa14977
--- /dev/null
+++ b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/GraphUtilsTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.clerezza.rdf.utils;
+
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.rdf.utils.GraphUtils.NoSuchSubGraphException;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author reto
+ */
+public class GraphUtilsTest {
+
+    final Iri u1 = new Iri("http://ex.org/1");
+    final Iri u2 = new Iri("http://ex.org/2");
+    final Iri u3 = new Iri("http://ex.org/3");
+
+    @Test
+    public void removeSubGraph() throws NoSuchSubGraphException {
+        Graph baseGraph = createBaseGraph();
+
+        Graph subGraph = new SimpleGraph();
+        {
+            BlankNode bNode1 = new BlankNode();
+            BlankNode bNode2 = new BlankNode();
+            subGraph.add(new TripleImpl(u1, u2, bNode2));
+            subGraph.add(new TripleImpl(bNode2, u2, bNode2));
+            subGraph.add(new TripleImpl(bNode2, u2, bNode1));
+        }
+        GraphUtils.removeSubGraph(baseGraph, subGraph);
+        Assert.assertEquals(1, baseGraph.size());
+    }
+
+    private Graph createBaseGraph() {
+        Graph baseGraph = new SimpleGraph();
+        {
+            BlankNode bNode1 = new BlankNode();
+            BlankNode bNode2 = new BlankNode();
+            baseGraph.add(new TripleImpl(u1, u2, bNode2));
+            baseGraph.add(new TripleImpl(bNode2, u2, bNode2));
+            baseGraph.add(new TripleImpl(bNode2, u2, bNode1));
+            baseGraph.add(new TripleImpl(u3, u2, u1));
+        }
+        return baseGraph;
+    }
+    
+    /** It is required that the subgraph comprises the whole context of the Bnodes it ioncludes
+     * 
+     * @throws org.apache.clerezza.rdf.utils.GraphUtils.NoSuchSubGraphException
+     */
+    @Test(expected=NoSuchSubGraphException.class)
+    public void removeIncompleteSubGraph() throws NoSuchSubGraphException {
+        Graph baseGraph = createBaseGraph();
+
+        Graph subGraph = new SimpleGraph();
+        {
+            BlankNode bNode1 = new BlankNode();
+            BlankNode bNode2 = new BlankNode();
+            subGraph.add(new TripleImpl(u1, u2, bNode2));
+            subGraph.add(new TripleImpl(bNode2, u2, bNode2));
+        }
+        GraphUtils.removeSubGraph(baseGraph, subGraph);
+    }
+
+    @Test(expected=NoSuchSubGraphException.class)
+    public void removeInvalidSubGraph() throws NoSuchSubGraphException {
+        Graph baseGraph = createBaseGraph();
+
+        Graph subGraph = new SimpleGraph();
+        {
+            BlankNode bNode1 = new BlankNode();
+            BlankNode bNode2 = new BlankNode();
+            subGraph.add(new TripleImpl(u1, u2, bNode2));
+            subGraph.add(new TripleImpl(bNode2, u2, bNode2));
+            baseGraph.add(new TripleImpl(bNode2, u2, bNode1));
+            baseGraph.add(new TripleImpl(bNode2, u2, new BlankNode()));
+        }
+        GraphUtils.removeSubGraph(baseGraph, subGraph);
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/IfpSmushTest.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/IfpSmushTest.java b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/IfpSmushTest.java
index 1094b51..d7a2b81 100644
--- a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/IfpSmushTest.java
+++ b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/IfpSmushTest.java
@@ -18,12 +18,12 @@
  */
 package org.apache.clerezza.rdf.utils;
 
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
 import org.apache.clerezza.rdf.ontologies.FOAF;
 import org.apache.clerezza.rdf.ontologies.OWL;
 import org.apache.clerezza.rdf.ontologies.RDF;
@@ -37,20 +37,20 @@ import org.junit.Test;
  */
 public class IfpSmushTest {
 
-    private MGraph ontology = new SimpleMGraph();
+    private Graph ontology = new SimpleGraph();
     {
         ontology.add(new TripleImpl(FOAF.mbox, RDF.type, OWL.InverseFunctionalProperty));
     }
 
     @Test
-    public void simpleBNode()  {
-        MGraph mGraph = new SimpleMGraph();
-        UriRef mbox1 = new UriRef("mailto:foo@example.org");
-        final BNode bNode1 = new BNode();
+    public void simpleBlankNode()  {
+        Graph mGraph = new SimpleGraph();
+        Iri mbox1 = new Iri("mailto:foo@example.org");
+        final BlankNode bNode1 = new BlankNode();
         mGraph.add(new TripleImpl(bNode1, FOAF.mbox, mbox1));
         mGraph.add(new TripleImpl(bNode1, RDFS.comment, 
                 new PlainLiteralImpl("a comment")));
-        final BNode bNode2 = new BNode();
+        final BlankNode bNode2 = new BlankNode();
         mGraph.add(new TripleImpl(bNode2, FOAF.mbox, mbox1));
         mGraph.add(new TripleImpl(bNode2, RDFS.comment, 
                 new PlainLiteralImpl("another comment")));
@@ -60,19 +60,19 @@ public class IfpSmushTest {
 
     @Test
     public void overlappingEquivalenceClasses()  {
-        MGraph mGraph = new SimpleMGraph();
-        UriRef mbox1 = new UriRef("mailto:foo@example.org");
-        final BNode bNode1 = new BNode();
+        Graph mGraph = new SimpleGraph();
+        Iri mbox1 = new Iri("mailto:foo@example.org");
+        final BlankNode bNode1 = new BlankNode();
         mGraph.add(new TripleImpl(bNode1, FOAF.mbox, mbox1));
         mGraph.add(new TripleImpl(bNode1, RDFS.comment,
                 new PlainLiteralImpl("a comment")));
-        final BNode bNode2 = new BNode();
-        UriRef mbox2 = new UriRef("mailto:bar@example.org");
+        final BlankNode bNode2 = new BlankNode();
+        Iri mbox2 = new Iri("mailto:bar@example.org");
         mGraph.add(new TripleImpl(bNode2, FOAF.mbox, mbox1));
         mGraph.add(new TripleImpl(bNode2, FOAF.mbox, mbox2));
         mGraph.add(new TripleImpl(bNode2, RDFS.comment,
                 new PlainLiteralImpl("another comment")));
-        final BNode bNode3 = new BNode();
+        final BlankNode bNode3 = new BlankNode();
         mGraph.add(new TripleImpl(bNode3, FOAF.mbox, mbox2));
         mGraph.add(new TripleImpl(bNode3, RDFS.comment,
                 new PlainLiteralImpl("yet another comment")));
@@ -81,14 +81,14 @@ public class IfpSmushTest {
     }
 
     @Test
-    public void oneUriRef()  {
-        MGraph mGraph = new SimpleMGraph();
-        UriRef mbox1 = new UriRef("mailto:foo@example.org");
-        final UriRef resource = new UriRef("http://example.org/");
+    public void oneIri()  {
+        Graph mGraph = new SimpleGraph();
+        Iri mbox1 = new Iri("mailto:foo@example.org");
+        final Iri resource = new Iri("http://example.org/");
         mGraph.add(new TripleImpl(resource, FOAF.mbox, mbox1));
         mGraph.add(new TripleImpl(resource, RDFS.comment,
                 new PlainLiteralImpl("a comment")));
-        final BNode bNode2 = new BNode();
+        final BlankNode bNode2 = new BlankNode();
         mGraph.add(new TripleImpl(bNode2, FOAF.mbox, mbox1));
         mGraph.add(new TripleImpl(bNode2, RDFS.comment,
                 new PlainLiteralImpl("another comment")));
@@ -97,14 +97,14 @@ public class IfpSmushTest {
     }
 
     @Test
-    public void twoUriRefs()  {
-        MGraph mGraph = new SimpleMGraph();
-        UriRef mbox1 = new UriRef("mailto:foo@example.org");
-        final UriRef resource1 = new UriRef("http://example.org/");
+    public void twoIris()  {
+        Graph mGraph = new SimpleGraph();
+        Iri mbox1 = new Iri("mailto:foo@example.org");
+        final Iri resource1 = new Iri("http://example.org/");
         mGraph.add(new TripleImpl(resource1, FOAF.mbox, mbox1));
         mGraph.add(new TripleImpl(resource1, RDFS.comment,
                 new PlainLiteralImpl("a comment")));
-        final UriRef resource2 = new UriRef("http://2.example.org/");
+        final Iri resource2 = new Iri("http://2.example.org/");
         mGraph.add(new TripleImpl(resource2, FOAF.mbox, mbox1));
         mGraph.add(new TripleImpl(resource2, RDFS.comment,
                 new PlainLiteralImpl("another comment")));

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/MGraphUtilsTest.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/MGraphUtilsTest.java b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/MGraphUtilsTest.java
deleted file mode 100644
index 19a85f9..0000000
--- a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/MGraphUtilsTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.clerezza.rdf.utils;
-
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-import org.apache.clerezza.rdf.utils.MGraphUtils.NoSuchSubGraphException;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- *
- * @author reto
- */
-public class MGraphUtilsTest {
-
-    final UriRef u1 = new UriRef("http://ex.org/1");
-    final UriRef u2 = new UriRef("http://ex.org/2");
-    final UriRef u3 = new UriRef("http://ex.org/3");
-
-    @Test
-    public void removeSubGraph() throws NoSuchSubGraphException {
-        MGraph baseGraph = createBaseGraph();
-
-        MGraph subGraph = new SimpleMGraph();
-        {
-            BNode bNode1 = new BNode();
-            BNode bNode2 = new BNode();
-            subGraph.add(new TripleImpl(u1, u2, bNode2));
-            subGraph.add(new TripleImpl(bNode2, u2, bNode2));
-            subGraph.add(new TripleImpl(bNode2, u2, bNode1));
-        }
-        MGraphUtils.removeSubGraph(baseGraph, subGraph);
-        Assert.assertEquals(1, baseGraph.size());
-    }
-
-    private MGraph createBaseGraph() {
-        MGraph baseGraph = new SimpleMGraph();
-        {
-            BNode bNode1 = new BNode();
-            BNode bNode2 = new BNode();
-            baseGraph.add(new TripleImpl(u1, u2, bNode2));
-            baseGraph.add(new TripleImpl(bNode2, u2, bNode2));
-            baseGraph.add(new TripleImpl(bNode2, u2, bNode1));
-            baseGraph.add(new TripleImpl(u3, u2, u1));
-        }
-        return baseGraph;
-    }
-    
-    /** It is required that the subgraph comprises the whole context of the Bnodes it ioncludes
-     * 
-     * @throws org.apache.clerezza.rdf.utils.MGraphUtils.NoSuchSubGraphException
-     */
-    @Test(expected=NoSuchSubGraphException.class)
-    public void removeIncompleteSubGraph() throws NoSuchSubGraphException {
-        MGraph baseGraph = createBaseGraph();
-
-        MGraph subGraph = new SimpleMGraph();
-        {
-            BNode bNode1 = new BNode();
-            BNode bNode2 = new BNode();
-            subGraph.add(new TripleImpl(u1, u2, bNode2));
-            subGraph.add(new TripleImpl(bNode2, u2, bNode2));
-        }
-        MGraphUtils.removeSubGraph(baseGraph, subGraph);
-    }
-
-    @Test(expected=NoSuchSubGraphException.class)
-    public void removeInvalidSubGraph() throws NoSuchSubGraphException {
-        MGraph baseGraph = createBaseGraph();
-
-        MGraph subGraph = new SimpleMGraph();
-        {
-            BNode bNode1 = new BNode();
-            BNode bNode2 = new BNode();
-            subGraph.add(new TripleImpl(u1, u2, bNode2));
-            subGraph.add(new TripleImpl(bNode2, u2, bNode2));
-            baseGraph.add(new TripleImpl(bNode2, u2, bNode1));
-            baseGraph.add(new TripleImpl(bNode2, u2, new BNode()));
-        }
-        MGraphUtils.removeSubGraph(baseGraph, subGraph);
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/RdfListTest.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/RdfListTest.java b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/RdfListTest.java
index 2097975..cd4045d 100644
--- a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/RdfListTest.java
+++ b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/RdfListTest.java
@@ -24,13 +24,13 @@ import java.util.Set;
 import junit.framework.Assert;
 
 import org.junit.Test;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
 import static org.junit.Assert.*;
 
 /**
@@ -41,8 +41,8 @@ public class RdfListTest {
 
     @Test
     public void listCreationAndAccess() {
-        TripleCollection tc = new SimpleMGraph();
-        List<Resource> list = new RdfList(new UriRef("http://example.org/mytest"), tc);
+        Graph tc = new SimpleGraph();
+        List<RdfTerm> list = new RdfList(new Iri("http://example.org/mytest"), tc);
         assertEquals(0, list.size());
         list.add(new PlainLiteralImpl("hello"));
         list.add(new PlainLiteralImpl("world"));
@@ -61,7 +61,7 @@ public class RdfListTest {
         assertEquals(5, list.size());
         assertEquals(new PlainLiteralImpl("hello"), list.get(1));
         assertEquals(new PlainLiteralImpl("interesting"), list.get(2));
-        List<Resource> list2 = new RdfList(new UriRef("http://example.org/mytest"), tc);
+        List<RdfTerm> list2 = new RdfList(new Iri("http://example.org/mytest"), tc);
         assertEquals(5, list2.size());
         assertEquals(new PlainLiteralImpl("hello"), list2.get(1));
         assertEquals(new PlainLiteralImpl("interesting"), list2.get(2));
@@ -86,13 +86,13 @@ public class RdfListTest {
 
     @Test
     public void listCreationAndAccess2() {
-        TripleCollection tc = new SimpleMGraph();
-        List<Resource> list = new RdfList(new UriRef("http://example.org/mytest"), tc);
+        Graph tc = new SimpleGraph();
+        List<RdfTerm> list = new RdfList(new Iri("http://example.org/mytest"), tc);
         assertEquals(0, list.size());
         list.add(0,new PlainLiteralImpl("world"));
-        list = new RdfList(new UriRef("http://example.org/mytest"), tc);
+        list = new RdfList(new Iri("http://example.org/mytest"), tc);
         list.add(0,new PlainLiteralImpl("beautifuly"));
-        list = new RdfList(new UriRef("http://example.org/mytest"), tc);
+        list = new RdfList(new Iri("http://example.org/mytest"), tc);
         list.add(0,new PlainLiteralImpl("hello"));
         assertEquals(new PlainLiteralImpl("hello"), list.get(0));
         assertEquals(new PlainLiteralImpl("beautifuly"), list.get(1));
@@ -101,12 +101,12 @@ public class RdfListTest {
 
     @Test
     public void listCreationAndAccess3() {
-        TripleCollection tc = new SimpleMGraph();
-        List<Resource> list = new RdfList(new UriRef("http://example.org/mytest"), tc);
+        Graph tc = new SimpleGraph();
+        List<RdfTerm> list = new RdfList(new Iri("http://example.org/mytest"), tc);
         assertEquals(0, list.size());
-        BNode node0 = new BNode() {};
-        BNode node1 = new BNode() {};
-        BNode node2 = new BNode() {};
+        BlankNode node0 = new BlankNode() {};
+        BlankNode node1 = new BlankNode() {};
+        BlankNode node2 = new BlankNode() {};
         list.add(0,node2);
         list.add(0,node1);
         list.add(0,node0);
@@ -117,8 +117,8 @@ public class RdfListTest {
 
     @Test
     public void secondButLastElementAccessTest() {
-        TripleCollection tc = new SimpleMGraph();
-        List<Resource> list = new RdfList(new UriRef("http://example.org/mytest2"), tc);
+        Graph tc = new SimpleGraph();
+        List<RdfTerm> list = new RdfList(new Iri("http://example.org/mytest2"), tc);
         list.add(new PlainLiteralImpl("hello"));
         list.add(new PlainLiteralImpl("world"));
         list.remove(1);
@@ -127,8 +127,8 @@ public class RdfListTest {
 
     @Test
     public void cleanGraphAfterRemoval() {
-        TripleCollection tc = new SimpleMGraph();
-        List<Resource> list = new RdfList(new UriRef("http://example.org/mytest"), tc);
+        Graph tc = new SimpleGraph();
+        List<RdfTerm> list = new RdfList(new Iri("http://example.org/mytest"), tc);
         list.add(new PlainLiteralImpl("hello"));
         list.add(new PlainLiteralImpl("world"));
         list.remove(1);
@@ -138,14 +138,14 @@ public class RdfListTest {
 
     @Test
     public void findContainingListNodesAndfindContainingListsTest() {
-        TripleCollection tc = new SimpleMGraph();
-        GraphNode listA = new GraphNode(new UriRef("http:///listA"), tc);
-        GraphNode listB = new GraphNode(new UriRef("http:///listB"), tc);
-        BNode element1 = new BNode();
-        BNode element2 = new BNode();
-        BNode element3 = new BNode();
-        BNode element4 = new BNode();
-        BNode element5 = new BNode();
+        Graph tc = new SimpleGraph();
+        GraphNode listA = new GraphNode(new Iri("http:///listA"), tc);
+        GraphNode listB = new GraphNode(new Iri("http:///listB"), tc);
+        BlankNode element1 = new BlankNode();
+        BlankNode element2 = new BlankNode();
+        BlankNode element3 = new BlankNode();
+        BlankNode element4 = new BlankNode();
+        BlankNode element5 = new BlankNode();
 
         RdfList rdfListA = new RdfList(listA);
         rdfListA.add(element1);

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/SameAsSmushTest.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/SameAsSmushTest.java b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/SameAsSmushTest.java
index d32034c..66c4005 100644
--- a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/SameAsSmushTest.java
+++ b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/SameAsSmushTest.java
@@ -19,16 +19,14 @@
 package org.apache.clerezza.rdf.utils;
 
 import java.util.Iterator;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Literal;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.PlainLiteral;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.LockableMGraph;
-import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Literal;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
 import org.apache.clerezza.rdf.ontologies.FOAF;
 import org.apache.clerezza.rdf.ontologies.OWL;
 import org.apache.clerezza.rdf.ontologies.RDF;
@@ -42,16 +40,16 @@ import org.junit.Test;
  */
 public class SameAsSmushTest {
     
-    private final UriRef uriA = new UriRef("http://example.org/A");
-    private final UriRef uriB = new UriRef("http://example.org/B");
+    private final Iri uriA = new Iri("http://example.org/A");
+    private final Iri uriB = new Iri("http://example.org/B");
     private final Literal lit = new PlainLiteralImpl("That's me (and you)");
 
-    private MGraph sameAsStatements = new SimpleMGraph();
+    private Graph sameAsStatements = new SimpleGraph();
     {
         sameAsStatements.add(new TripleImpl(uriA, OWL.sameAs, uriB));
     }
     
-    private MGraph  dataGraph = new SimpleMGraph();
+    private Graph  dataGraph = new SimpleGraph();
     {
         dataGraph.add(new TripleImpl(uriA, FOAF.knows, uriB));
         dataGraph.add(new TripleImpl(uriB, RDFS.label, lit));

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/TestGraphNode.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/TestGraphNode.java b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/TestGraphNode.java
index c8f8cf9..af8434a 100644
--- a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/TestGraphNode.java
+++ b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/TestGraphNode.java
@@ -25,16 +25,16 @@ import java.util.Set;
 
 import junit.framework.Assert;
 import org.junit.Test;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Literal;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-import org.apache.clerezza.rdf.core.test.RandomMGraph;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Literal;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.RdfTerm;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.rdf.core.test.RandomGraph;
 
 /**
  *
@@ -44,11 +44,11 @@ public class TestGraphNode {
 
     @Test
     public void nodeContext() {
-        MGraph g = new SimpleMGraph();
-        BNode bNode1 = new BNode() {};
-        BNode bNode2 = new BNode() {};
-        UriRef property1 = new UriRef("http://example.org/property1");
-        UriRef property2 = new UriRef("http://example.org/property2");
+        Graph g = new SimpleGraph();
+        BlankNode bNode1 = new BlankNode() {};
+        BlankNode bNode2 = new BlankNode() {};
+        Iri property1 = new Iri("http://example.org/property1");
+        Iri property2 = new Iri("http://example.org/property2");
         g.add(new TripleImpl(bNode1, property1, new PlainLiteralImpl("literal")));
         g.add(new TripleImpl(bNode1, property2, property1));
         g.add(new TripleImpl(bNode2, property2, bNode1));
@@ -63,10 +63,10 @@ public class TestGraphNode {
 
     @Test
     public void addNode() {
-        MGraph g = new SimpleMGraph();
-        BNode bNode1 = new BNode() {};
-        BNode bNode2 = new BNode() {};
-        UriRef property1 = new UriRef("http://example.org/property1");
+        Graph g = new SimpleGraph();
+        BlankNode bNode1 = new BlankNode() {};
+        BlankNode bNode2 = new BlankNode() {};
+        Iri property1 = new Iri("http://example.org/property1");
         GraphNode n = new GraphNode(bNode1, g);
         n.addProperty(property1, bNode2);
         Assert.assertEquals(1, g.size());
@@ -74,14 +74,14 @@ public class TestGraphNode {
 
     @Test
     public void testGetSubjectAndObjectNodes() {
-        RandomMGraph graph = new RandomMGraph(500, 20, new SimpleMGraph());
+        RandomGraph graph = new RandomGraph(500, 20, new SimpleGraph());
         for (int j = 0; j < 200; j++) {
             Triple randomTriple = graph.getRandomTriple();
             GraphNode node = new GraphNode(randomTriple.getSubject(), graph);
-            Iterator<UriRef> properties = node.getProperties();
+            Iterator<Iri> properties = node.getProperties();
             while (properties.hasNext()) {
-                UriRef property = properties.next();
-                Set<Resource> objects = createSet(node.getObjects(property));
+                Iri property = properties.next();
+                Set<RdfTerm> objects = createSet(node.getObjects(property));
                 Iterator<GraphNode> objectNodes = node.getObjectNodes(property);
                 while (objectNodes.hasNext()) {
                     GraphNode graphNode = objectNodes.next();
@@ -93,10 +93,10 @@ public class TestGraphNode {
         for (int j = 0; j < 200; j++) {
             Triple randomTriple = graph.getRandomTriple();
             GraphNode node = new GraphNode(randomTriple.getObject(), graph);
-            Iterator<UriRef> properties = node.getProperties();
+            Iterator<Iri> properties = node.getProperties();
             while (properties.hasNext()) {
-                UriRef property = properties.next();
-                Set<Resource> subjects = createSet(node.getSubjects(property));
+                Iri property = properties.next();
+                Set<RdfTerm> subjects = createSet(node.getSubjects(property));
                 Iterator<GraphNode> subjectNodes = node.getSubjectNodes(property);
                 while (subjectNodes.hasNext()) {
                     GraphNode graphNode = subjectNodes.next();
@@ -108,14 +108,14 @@ public class TestGraphNode {
 
     @Test
     public void getAvailableProperties(){
-        MGraph g = new SimpleMGraph();
-        BNode bNode1 = new BNode() {};
-        BNode bNode2 = new BNode() {};
-        UriRef property1 = new UriRef("http://example.org/property1");
-        UriRef property2 = new UriRef("http://example.org/property2");
-        UriRef property3 = new UriRef("http://example.org/property3");
-        UriRef property4 = new UriRef("http://example.org/property4");
-        ArrayList<UriRef> props = new ArrayList<UriRef>();
+        Graph g = new SimpleGraph();
+        BlankNode bNode1 = new BlankNode() {};
+        BlankNode bNode2 = new BlankNode() {};
+        Iri property1 = new Iri("http://example.org/property1");
+        Iri property2 = new Iri("http://example.org/property2");
+        Iri property3 = new Iri("http://example.org/property3");
+        Iri property4 = new Iri("http://example.org/property4");
+        ArrayList<Iri> props = new ArrayList<Iri>();
         props.add(property1);
         props.add(property2);
         props.add(property3);
@@ -125,11 +125,11 @@ public class TestGraphNode {
         n.addProperty(property2, bNode2);
         n.addProperty(property3, bNode2);
         n.addProperty(property4, bNode2);
-        Iterator<UriRef> properties = n.getProperties();
+        Iterator<Iri> properties = n.getProperties();
         int i = 0;
         while(properties.hasNext()){
             i++;
-            UriRef prop = properties.next();
+            Iri prop = properties.next();
             Assert.assertTrue(props.contains(prop));
             props.remove(prop);
         }
@@ -140,11 +140,11 @@ public class TestGraphNode {
 
     @Test
     public void deleteAll() {
-        MGraph g = new SimpleMGraph();
-        BNode bNode1 = new BNode() {};
-        BNode bNode2 = new BNode() {};
-        UriRef property1 = new UriRef("http://example.org/property1");
-        UriRef property2 = new UriRef("http://example.org/property2");
+        Graph g = new SimpleGraph();
+        BlankNode bNode1 = new BlankNode() {};
+        BlankNode bNode2 = new BlankNode() {};
+        Iri property1 = new Iri("http://example.org/property1");
+        Iri property2 = new Iri("http://example.org/property2");
         //the two properties two be deleted
         g.add(new TripleImpl(bNode1, property1, new PlainLiteralImpl("literal")));
         g.add(new TripleImpl(bNode1, property1, new PlainLiteralImpl("bla bla")));
@@ -159,11 +159,11 @@ public class TestGraphNode {
 
     @Test
     public void deleteSingleProperty() {
-        MGraph g = new SimpleMGraph();
-        BNode bNode1 = new BNode() {};
-        BNode bNode2 = new BNode() {};
-        UriRef property1 = new UriRef("http://example.org/property1");
-        UriRef property2 = new UriRef("http://example.org/property2");
+        Graph g = new SimpleGraph();
+        BlankNode bNode1 = new BlankNode() {};
+        BlankNode bNode2 = new BlankNode() {};
+        Iri property1 = new Iri("http://example.org/property1");
+        Iri property2 = new Iri("http://example.org/property2");
         //the properties two be deleted
         g.add(new TripleImpl(bNode1, property1, new PlainLiteralImpl("literal")));
         //this 4 properties should stay
@@ -178,13 +178,13 @@ public class TestGraphNode {
 
     @Test
     public void replaceWith() {
-        MGraph initialGraph = new SimpleMGraph();
-        BNode bNode1 = new BNode();
-        BNode bNode2 = new BNode();
-        BNode newBnode = new BNode();
-        UriRef property1 = new UriRef("http://example.org/property1");
-        UriRef property2 = new UriRef("http://example.org/property2");
-        UriRef newUriRef = new UriRef("http://example.org/newName");
+        Graph initialGraph = new SimpleGraph();
+        BlankNode bNode1 = new BlankNode();
+        BlankNode bNode2 = new BlankNode();
+        BlankNode newBnode = new BlankNode();
+        Iri property1 = new Iri("http://example.org/property1");
+        Iri property2 = new Iri("http://example.org/property2");
+        Iri newIri = new Iri("http://example.org/newName");
         Literal literal1 = new PlainLiteralImpl("literal");
         Literal literal2 = new PlainLiteralImpl("bla bla");
 
@@ -199,14 +199,14 @@ public class TestGraphNode {
         initialGraph.add(triple4);
         initialGraph.add(triple5);
         GraphNode node = new GraphNode(property1,
-                new SimpleMGraph(initialGraph.iterator()));
+                new SimpleGraph(initialGraph.iterator()));
 
-        node.replaceWith(newUriRef, true);
+        node.replaceWith(newIri, true);
         Assert.assertEquals(5, node.getGraph().size());
-        Triple expectedTriple1 = new TripleImpl(bNode1, newUriRef, literal1);
-        Triple expectedTriple2 = new TripleImpl(bNode1, property2, newUriRef);
-        Triple expectedTriple3 = new TripleImpl(newUriRef, newUriRef, bNode2);
-        Triple expectedTriple4 = new TripleImpl(newUriRef, newUriRef, literal2);
+        Triple expectedTriple1 = new TripleImpl(bNode1, newIri, literal1);
+        Triple expectedTriple2 = new TripleImpl(bNode1, property2, newIri);
+        Triple expectedTriple3 = new TripleImpl(newIri, newIri, bNode2);
+        Triple expectedTriple4 = new TripleImpl(newIri, newIri, literal2);
 
         Assert.assertTrue(node.getGraph().contains(expectedTriple1));
         Assert.assertTrue(node.getGraph().contains(expectedTriple2));
@@ -218,7 +218,7 @@ public class TestGraphNode {
         Assert.assertFalse(node.getGraph().contains(triple4));
         Assert.assertFalse(node.getGraph().contains(triple5));
 
-        node = new GraphNode(property1, new SimpleMGraph(initialGraph.iterator()));
+        node = new GraphNode(property1, new SimpleGraph(initialGraph.iterator()));
         node.replaceWith(newBnode);
         Triple expectedTriple5 = new TripleImpl(bNode1, property2, newBnode);
         Triple expectedTriple6 = new TripleImpl(newBnode, property1, bNode2);
@@ -229,16 +229,16 @@ public class TestGraphNode {
         Assert.assertTrue(node.getGraph().contains(expectedTriple6));
         Assert.assertTrue(node.getGraph().contains(expectedTriple7));
 
-        node = new GraphNode(literal1, new SimpleMGraph(initialGraph.iterator()));
+        node = new GraphNode(literal1, new SimpleGraph(initialGraph.iterator()));
         node.replaceWith(newBnode);
         Triple expectedTriple8 = new TripleImpl(bNode1, property1, newBnode);
         Assert.assertTrue(node.getGraph().contains(expectedTriple8));
 
-        node = new GraphNode(property1, new SimpleMGraph(initialGraph.iterator()));
-        node.replaceWith(newUriRef);
-        Triple expectedTriple9 = new TripleImpl(bNode1, property2, newUriRef);
-        Triple expectedTriple10 = new TripleImpl(newUriRef, property1, bNode2);
-        Triple expectedTriple11 = new TripleImpl(newUriRef, property1, literal2);
+        node = new GraphNode(property1, new SimpleGraph(initialGraph.iterator()));
+        node.replaceWith(newIri);
+        Triple expectedTriple9 = new TripleImpl(bNode1, property2, newIri);
+        Triple expectedTriple10 = new TripleImpl(newIri, property1, bNode2);
+        Triple expectedTriple11 = new TripleImpl(newIri, property1, literal2);
         Assert.assertTrue(node.getGraph().contains(triple1));
         Assert.assertTrue(node.getGraph().contains(expectedTriple9));
         Assert.assertTrue(node.getGraph().contains(expectedTriple10));
@@ -247,10 +247,10 @@ public class TestGraphNode {
 
     @Test
     public void equality() {
-        MGraph g = new SimpleMGraph();
-        BNode bNode1 = new BNode() {};
-        BNode bNode2 = new BNode() {};
-        UriRef property1 = new UriRef("http://example.org/property1");
+        Graph g = new SimpleGraph();
+        BlankNode bNode1 = new BlankNode() {};
+        BlankNode bNode2 = new BlankNode() {};
+        Iri property1 = new Iri("http://example.org/property1");
         GraphNode n = new GraphNode(bNode1, g);
         n.addProperty(property1, bNode2);
         Assert.assertTrue(n.equals(new GraphNode(bNode1, g)));
@@ -259,10 +259,10 @@ public class TestGraphNode {
         Assert.assertFalse(n.equals(n2));
     }
 
-    private Set<Resource> createSet(Iterator<? extends Resource> resources) {
-        Set<Resource> set = new HashSet<Resource>();
+    private Set<RdfTerm> createSet(Iterator<? extends RdfTerm> resources) {
+        Set<RdfTerm> set = new HashSet<RdfTerm>();
         while (resources.hasNext()) {
-            Resource resource = resources.next();
+            RdfTerm resource = resources.next();
             set.add(resource);
         }
         return set;

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/UnionGraphTest.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/UnionGraphTest.java b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/UnionGraphTest.java
new file mode 100644
index 0000000..2881eb4
--- /dev/null
+++ b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/UnionGraphTest.java
@@ -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.clerezza.rdf.utils;
+
+import java.util.Iterator;
+import org.junit.Test;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.junit.Assert;
+
+/**
+ *
+ * @author hasan
+ */
+public class UnionGraphTest {
+
+    private final Iri uriRef1 =
+            new Iri("http://example.org/ontology#res1");
+    private final Iri uriRef2 =
+            new Iri("http://example.org/ontology#res2");
+    private final Iri uriRef3 =
+            new Iri("http://example.org/ontology#res3");
+    private final Iri uriRef4 =
+            new Iri("http://example.org/ontology#res4");
+
+    @Test
+    public void readAccess() {
+        Graph graph = new SimpleGraph();
+        Graph graph2 = new SimpleGraph();
+        BlankNode bnode = new BlankNode() {
+        };
+        graph.add(new TripleImpl(uriRef1, uriRef2, uriRef1));
+        graph2.add(new TripleImpl(bnode, uriRef1, uriRef3));
+        Graph unionGraph = new UnionGraph(graph, graph2);
+        Iterator<Triple> unionTriples = unionGraph.iterator();
+        Assert.assertTrue(unionTriples.hasNext());
+        unionTriples.next();
+        Assert.assertTrue(unionTriples.hasNext());
+        unionTriples.next();
+        Assert.assertFalse(unionTriples.hasNext());
+        Assert.assertEquals(2, unionGraph.size());
+    }
+    
+    @Test
+    public void writeAccess() {
+        Graph graph = new SimpleGraph();
+        Graph graph2 = new SimpleGraph();
+        BlankNode bnode = new BlankNode() {
+        };
+        graph2.add(new TripleImpl(bnode, uriRef1, uriRef3));
+        Graph unionGraph = new UnionGraph(graph, graph2);
+        Assert.assertEquals(1, unionGraph.size());
+        unionGraph.add(new TripleImpl(uriRef4, uriRef1, uriRef3));
+        Assert.assertEquals(1, graph.size());
+        Assert.assertEquals(2, unionGraph.size());
+        Assert.assertEquals(1, graph2.size());
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/UnionMGraphTest.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/UnionMGraphTest.java b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/UnionMGraphTest.java
deleted file mode 100644
index 1c72497..0000000
--- a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/UnionMGraphTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.clerezza.rdf.utils;
-
-import java.util.Iterator;
-import junit.framework.Assert;
-import org.junit.Test;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
-
-/**
- *
- * @author hasan
- */
-public class UnionMGraphTest {
-
-    private final UriRef uriRef1 =
-            new UriRef("http://example.org/ontology#res1");
-    private final UriRef uriRef2 =
-            new UriRef("http://example.org/ontology#res2");
-    private final UriRef uriRef3 =
-            new UriRef("http://example.org/ontology#res3");
-    private final UriRef uriRef4 =
-            new UriRef("http://example.org/ontology#res4");
-
-    @Test
-    public void readAccess() {
-        MGraph graph = new SimpleMGraph();
-        MGraph graph2 = new SimpleMGraph();
-        BNode bnode = new BNode() {
-        };
-        graph.add(new TripleImpl(uriRef1, uriRef2, uriRef1));
-        graph2.add(new TripleImpl(bnode, uriRef1, uriRef3));
-        MGraph unionGraph = new UnionMGraph(graph, graph2);
-        Iterator<Triple> unionTriples = unionGraph.iterator();
-        Assert.assertTrue(unionTriples.hasNext());
-        unionTriples.next();
-        Assert.assertTrue(unionTriples.hasNext());
-        unionTriples.next();
-        Assert.assertFalse(unionTriples.hasNext());
-        Assert.assertEquals(2, unionGraph.size());
-    }
-    
-    @Test
-    public void writeAccess() {
-        MGraph graph = new SimpleMGraph();
-        MGraph graph2 = new SimpleMGraph();
-        BNode bnode = new BNode() {
-        };
-        graph2.add(new TripleImpl(bnode, uriRef1, uriRef3));
-        MGraph unionGraph = new UnionMGraph(graph, graph2);
-        Assert.assertEquals(1, unionGraph.size());
-        unionGraph.add(new TripleImpl(uriRef4, uriRef1, uriRef3));
-        Assert.assertEquals(1, graph.size());
-        Assert.assertEquals(2, unionGraph.size());
-        Assert.assertEquals(1, graph2.size());
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/de5881d4/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmushTest.java
----------------------------------------------------------------------
diff --git a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmushTest.java b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmushTest.java
index 6bb1688..bab58e9 100644
--- a/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmushTest.java
+++ b/rdf.utils/src/test/java/org/apache/clerezza/rdf/utils/smushing/SameAsSmushTest.java
@@ -20,17 +20,14 @@ package org.apache.clerezza.rdf.utils.smushing;
 
 import java.util.Iterator;
 import java.util.Set;
-import org.apache.clerezza.rdf.core.BNode;
-import org.apache.clerezza.rdf.core.Literal;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.PlainLiteral;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.LockableMGraph;
-import org.apache.clerezza.rdf.core.access.LockableMGraphWrapper;
-import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
-import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Literal;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Triple;
+import org.apache.commons.rdf.Iri;
+import org.apache.commons.rdf.impl.utils.PlainLiteralImpl;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
 import org.apache.clerezza.rdf.ontologies.FOAF;
 import org.apache.clerezza.rdf.ontologies.OWL;
 import org.apache.clerezza.rdf.ontologies.RDF;
@@ -44,18 +41,18 @@ import org.junit.Test;
  */
 public class SameAsSmushTest {
     
-    private final UriRef uriA = new UriRef("http://example.org/A");
-    private final UriRef uriB = new UriRef("http://example.org/B");
-    private final UriRef uriC = new UriRef("http://example.org/C");
+    private final Iri uriA = new Iri("http://example.org/A");
+    private final Iri uriB = new Iri("http://example.org/B");
+    private final Iri uriC = new Iri("http://example.org/C");
     
     private final Literal lit = new PlainLiteralImpl("That's me (and you)");
 
-    private MGraph sameAsStatements = new SimpleMGraph();
+    private Graph sameAsStatements = new SimpleGraph();
     {
         sameAsStatements.add(new TripleImpl(uriA, OWL.sameAs, uriB));
     }
     
-    private LockableMGraph  dataGraph = new LockableMGraphWrapper(new SimpleMGraph());
+    private Graph  dataGraph = new SimpleGraph();
     {
         dataGraph.add(new TripleImpl(uriA, FOAF.knows, uriB));
         dataGraph.add(new TripleImpl(uriB, RDFS.label, lit));
@@ -67,7 +64,7 @@ public class SameAsSmushTest {
         SameAsSmusher smusher = new SameAsSmusher() {
 
             @Override
-            protected UriRef getPreferedIri(Set<UriRef> uriRefs) {
+            protected Iri getPreferedIri(Set<Iri> uriRefs) {
                 if (!uriRefs.contains(uriA)) throw new RuntimeException("not the set we excpect");
                 if (!uriRefs.contains(uriB)) throw new RuntimeException("not the set we excpect");
                 return uriC;