Modified: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentation.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentation.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentation.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentation.java Tue May 17 22:20:49 2016 @@ -22,11 +22,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; -import org.apache.clerezza.rdf.core.Literal; +import org.apache.clerezza.commons.rdf.Literal; import org.apache.clerezza.rdf.core.NoConvertorException; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.clerezza.rdf.utils.GraphNode; import org.apache.stanbol.entityhub.servicesapi.util.AdaptingIterator; import org.apache.stanbol.entityhub.servicesapi.util.FilteringIterator; @@ -35,8 +35,8 @@ import org.apache.stanbol.entityhub.mode import org.apache.stanbol.entityhub.model.clerezza.impl.LiteralAdapter; import org.apache.stanbol.entityhub.model.clerezza.impl.NaturalTextFilter; import org.apache.stanbol.entityhub.model.clerezza.impl.Resource2ValueAdapter; -import org.apache.stanbol.entityhub.model.clerezza.impl.UriRef2ReferenceAdapter; -import org.apache.stanbol.entityhub.model.clerezza.impl.UriRefAdapter; +import org.apache.stanbol.entityhub.model.clerezza.impl.IRI2ReferenceAdapter; +import org.apache.stanbol.entityhub.model.clerezza.impl.IRIAdapter; import org.apache.stanbol.entityhub.model.clerezza.utils.Resource2StringAdapter; import org.apache.stanbol.entityhub.servicesapi.model.Reference; import org.apache.stanbol.entityhub.servicesapi.model.Representation; @@ -59,7 +59,7 @@ public class RdfRepresentation implement return graphNode; } - protected RdfRepresentation(UriRef resource, TripleCollection graph) { + protected RdfRepresentation(IRI resource, Graph graph) { this.graphNode = new GraphNode(resource, graph); } @@ -68,12 +68,12 @@ public class RdfRepresentation implement * * @return The RDF graph of this Representation */ - public TripleCollection getRdfGraph(){ + public Graph getRdfGraph(){ return graphNode.getGraph(); } -// protected UriRef getRepresentationType(){ -// Iterator<UriRef> it = this.graphNode.getUriRefObjects(REPRESENTATION_TYPE_PROPERTY); +// protected IRI getRepresentationType(){ +// Iterator<IRI> it = this.graphNode.getIRIObjects(REPRESENTATION_TYPE_PROPERTY); // return it.hasNext()?it.next():null; // } @Override @@ -86,32 +86,32 @@ public class RdfRepresentation implement if(value == null){ throw new IllegalArgumentException("NULL values are not supported by Representations"); } - UriRef fieldUriRef = new UriRef(field); + IRI fieldIRI = new IRI(field); Collection<Object> values = new ArrayList<Object>(); //process the parsed value with the Utility Method -> // this converts Objects as defined in the specification ModelUtils.checkValues(valueFactory, value, values); //We still need to implement support for specific types supported by this implementation for (Object current : values){ - if (current instanceof Resource){ //native support for Clerezza types! - graphNode.addProperty(fieldUriRef, (Resource)current); + if (current instanceof RDFTerm){ //native support for Clerezza types! + graphNode.addProperty(fieldIRI, (RDFTerm)current); } else if (current instanceof RdfReference){ //treat RDF Implementations special to avoid creating new instances - graphNode.addProperty(fieldUriRef, ((RdfReference) current).getUriRef()); + graphNode.addProperty(fieldIRI, ((RdfReference) current).getIRI()); } else if (current instanceof Reference){ - graphNode.addProperty(fieldUriRef, new UriRef(((Reference) current).getReference())); + graphNode.addProperty(fieldIRI, new IRI(((Reference) current).getReference())); } else if (current instanceof RdfText){ //treat RDF Implementations special to avoid creating new instances - graphNode.addProperty(fieldUriRef,((RdfText) current).getLiteral()); + graphNode.addProperty(fieldIRI,((RdfText) current).getLiteral()); } else if (current instanceof Text){ - addNaturalText(fieldUriRef, ((Text)current).getText(), ((Text)current).getLanguage()); + addNaturalText(fieldIRI, ((Text)current).getText(), ((Text)current).getLanguage()); } else { //else add an typed Literal! - addTypedLiteral(fieldUriRef, current); + addTypedLiteral(fieldIRI, current); } } } - private void addTypedLiteral(UriRef field, Object literalValue){ + private void addTypedLiteral(IRI field, Object literalValue){ Literal literal; try { literal = RdfResourceUtils.createLiteral(literalValue); @@ -134,7 +134,7 @@ public class RdfRepresentation implement } else if (reference.isEmpty()) { throw new IllegalArgumentException("References MUST NOT be empty!"); } - graphNode.addProperty(new UriRef(field), new UriRef(reference)); + graphNode.addProperty(new IRI(field), new IRI(reference)); } @Override public void addNaturalText(String field, String text, String...languages) { @@ -146,9 +146,9 @@ public class RdfRepresentation implement if(text == null){ throw new IllegalArgumentException("NULL values are not supported by Representations"); } - this.addNaturalText(new UriRef(field), text, languages); + this.addNaturalText(new IRI(field), text, languages); } - private void addNaturalText(UriRef field, String text, String...languages) { + private void addNaturalText(IRI field, String text, String...languages) { if(languages == null || languages.length == 0){ languages = new String []{null}; } @@ -165,36 +165,36 @@ public class RdfRepresentation implement } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } - UriRef fieldUriRef = new UriRef(field); - if(Resource.class.isAssignableFrom(type)){ //native support for Clerezza types - return new TypeSafeIterator<T>(graphNode.getObjects(fieldUriRef), type); + IRI fieldIRI = new IRI(field); + if(RDFTerm.class.isAssignableFrom(type)){ //native support for Clerezza types + return new TypeSafeIterator<T>(graphNode.getObjects(fieldIRI), type); // NOTE: (Rupert Westenthaler 12.01.2011) // Converting everything to String is not an intended functionality. When // someone parsed String.class he rather assumes that he gets only string // values and not also string representations for Dates, Integer ... // // } else if(type.equals(String.class)){ //support to convert anything to String -// return (Iterator<T>) new AdaptingIterator<Resource,String>( -// graphNode.getObjects(fieldUriRef), -// new Resource2StringAdapter<Resource>(), +// return (Iterator<T>) new AdaptingIterator<RDFTerm,String>( +// graphNode.getObjects(fieldIRI), +// new Resource2StringAdapter<RDFTerm>(), // String.class); } else if(type.equals(URI.class) || type.equals(URL.class)){ //support for References - return new AdaptingIterator<UriRef, T>( - graphNode.getUriRefObjects(fieldUriRef), - new UriRefAdapter<T>(), + return new AdaptingIterator<IRI, T>( + graphNode.getIRIObjects(fieldIRI), + new IRIAdapter<T>(), type); } else if(Reference.class.isAssignableFrom(type)){ - return (Iterator<T>) new AdaptingIterator<UriRef,Reference>( - graphNode.getUriRefObjects(fieldUriRef), - new UriRef2ReferenceAdapter(),Reference.class); + return (Iterator<T>) new AdaptingIterator<IRI,Reference>( + graphNode.getIRIObjects(fieldIRI), + new IRI2ReferenceAdapter(),Reference.class); } else if(Text.class.isAssignableFrom(type)){ return (Iterator<T>)new AdaptingIterator<Literal, Text>( - graphNode.getLiterals(fieldUriRef), + graphNode.getLiterals(fieldIRI), new Literal2TextAdapter<Literal>(), Text.class); } else { //support for Literals -> Type conversions return new AdaptingIterator<Literal, T>( - graphNode.getLiterals(fieldUriRef), + graphNode.getLiterals(fieldIRI), new LiteralAdapter<Literal, T>(), type); } @@ -207,9 +207,9 @@ public class RdfRepresentation implement } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } - return new AdaptingIterator<UriRef,Reference>( - graphNode.getUriRefObjects(new UriRef(field)), - new UriRef2ReferenceAdapter(),Reference.class); + return new AdaptingIterator<IRI,Reference>( + graphNode.getIRIObjects(new IRI(field)), + new IRI2ReferenceAdapter(),Reference.class); } @Override @@ -220,7 +220,7 @@ public class RdfRepresentation implement throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } return new AdaptingIterator<Literal, Text>( - graphNode.getLiterals(new UriRef(field)), + graphNode.getLiterals(new IRI(field)), new Literal2TextAdapter<Literal>(), Text.class); } @@ -232,8 +232,8 @@ public class RdfRepresentation implement } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } - return new AdaptingIterator<Resource, Object>(graphNode.getObjects(new UriRef(field)), - new Resource2ValueAdapter<Resource>(),Object.class); + return new AdaptingIterator<RDFTerm, Object>(graphNode.getObjects(new IRI(field)), + new Resource2ValueAdapter<RDFTerm>(),Object.class); } @Override @@ -244,15 +244,15 @@ public class RdfRepresentation implement throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } return new AdaptingIterator<Literal, Text>( - graphNode.getLiterals(new UriRef(field)), + graphNode.getLiterals(new IRI(field)), new Literal2TextAdapter<Literal>(languages), Text.class); } @Override public Iterator<String> getFieldNames() { - return new AdaptingIterator<UriRef, String>(graphNode.getProperties(), - new Resource2StringAdapter<UriRef>(), String.class); + return new AdaptingIterator<IRI, String>(graphNode.getProperties(), + new Resource2StringAdapter<IRI>(), String.class); } @Override @@ -318,11 +318,11 @@ public class RdfRepresentation implement return getNode().getUnicodeString(); } /** - * Getter for the UriRef representing the ID of this Representation. - * @return The UriRef representing the ID of this Representation. + * Getter for the IRI representing the ID of this Representation. + * @return The IRI representing the ID of this Representation. */ - public UriRef getNode(){ - return (UriRef)graphNode.getNode(); + public IRI getNode(){ + return (IRI)graphNode.getNode(); } @Override @@ -337,26 +337,26 @@ public class RdfRepresentation implement +" and field "+field+" -> call ignored"); return; } - UriRef fieldUriRef = new UriRef(field); + IRI fieldIRI = new IRI(field); Collection<Object> removeValues = new ArrayList<Object>(); ModelUtils.checkValues(valueFactory, parsedValue, removeValues); //We still need to implement support for specific types supported by this implementation for (Object current : removeValues){ - if (current instanceof Resource){ //native support for Clerezza types! - graphNode.deleteProperty(fieldUriRef, (Resource)current); + if (current instanceof RDFTerm){ //native support for Clerezza types! + graphNode.deleteProperty(fieldIRI, (RDFTerm)current); } else if (current instanceof RdfReference){ //treat RDF Implementations special to avoid creating new instances - graphNode.deleteProperty(fieldUriRef, ((RdfReference) current).getUriRef()); + graphNode.deleteProperty(fieldIRI, ((RdfReference) current).getIRI()); } else if (current instanceof Reference){ - graphNode.deleteProperty(fieldUriRef, new UriRef(((Reference) current).getReference())); + graphNode.deleteProperty(fieldIRI, new IRI(((Reference) current).getReference())); } else if (current instanceof RdfText){ //treat RDF Implementations special to avoid creating new instances - graphNode.deleteProperty(fieldUriRef,((RdfText) current).getLiteral()); + graphNode.deleteProperty(fieldIRI,((RdfText) current).getLiteral()); } else if (current instanceof Text){ removeNaturalText(field,((Text)current).getText(),((Text)current).getLanguage()); } else { //else add an typed Literal! - removeTypedLiteral(fieldUriRef, current); + removeTypedLiteral(fieldIRI, current); } } } @@ -371,9 +371,9 @@ public class RdfRepresentation implement if(reference == null){ log.warn("NULL parsed as value in remove method for symbol "+getId()+" and field "+field+" -> call ignored"); } - graphNode.deleteProperty(new UriRef(field), new UriRef(reference)); + graphNode.deleteProperty(new IRI(field), new IRI(reference)); } - protected void removeTypedLiteral(UriRef field, Object object){ + protected void removeTypedLiteral(IRI field, Object object){ Literal literal; try{ literal = RdfResourceUtils.createLiteral(object); @@ -398,13 +398,13 @@ public class RdfRepresentation implement //need to be interpreted as default language languages = new String []{null}; } - UriRef fieldUriRef = new UriRef(field); + IRI fieldIRI = new IRI(field); for(String language : languages){ - graphNode.deleteProperty(fieldUriRef,RdfResourceUtils.createLiteral(value, language)); + graphNode.deleteProperty(fieldIRI,RdfResourceUtils.createLiteral(value, language)); if(language == null){ //if the language is null //we need also try to remove a typed Literal with the data type //xsd:string and the parsed value! - graphNode.deleteProperty(fieldUriRef,RdfResourceUtils.createLiteral(value)); + graphNode.deleteProperty(fieldIRI,RdfResourceUtils.createLiteral(value)); } } } @@ -415,7 +415,7 @@ public class RdfRepresentation implement } else if(field.isEmpty()){ throw new IllegalArgumentException("The parsed field MUST NOT be Empty"); } - graphNode.deleteProperties(new UriRef(field)); + graphNode.deleteProperties(new IRI(field)); } @Override public void removeAllNaturalText(String field, String... languages) { @@ -427,17 +427,17 @@ public class RdfRepresentation implement // if(languages == null || languages.length == 0){ // languages = new String []{null}; // } - UriRef fieldUriRef = new UriRef(field); + IRI fieldIRI = new IRI(field); //get all the affected Literals Collection<Literal> toRemove = new ArrayList<Literal>(); Iterator<Literal> it = new FilteringIterator<Literal>( - graphNode.getLiterals(fieldUriRef), + graphNode.getLiterals(fieldIRI), new NaturalTextFilter(languages),Literal.class); while(it.hasNext()){ toRemove.add(it.next()); } for(Literal l : toRemove){ - graphNode.deleteProperty(fieldUriRef, l); + graphNode.deleteProperty(fieldIRI, l); } }
Modified: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfResourceUtils.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfResourceUtils.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfResourceUtils.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfResourceUtils.java Tue May 17 22:20:49 2016 @@ -27,19 +27,17 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.clerezza.rdf.core.Language; -import org.apache.clerezza.rdf.core.Literal; +import org.apache.clerezza.commons.rdf.Language; +import org.apache.clerezza.commons.rdf.Literal; + +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.TypedLiteral; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.SimpleLiteralFactory; import org.apache.stanbol.entityhub.servicesapi.defaults.DataTypeEnum; /** - * Utilities to create {@link Resource} instances for Java Objects. + * Utilities to create {@link RDFTerm} instances for Java Objects. * @author Rupert Westenthaler * */ @@ -106,21 +104,21 @@ public final class RdfResourceUtils { * by the {@link XsdDataTypeEnum}. */ - public static final Map<UriRef, XsdDataTypeEnum> XSD_DATATYPE_VALUE_MAPPING; + public static final Map<IRI, XsdDataTypeEnum> XSD_DATATYPE_VALUE_MAPPING; /** * Unmodifiable containing all xsd data types that can be converted to * {@link Text} (without language). */ - public static final Set<UriRef> STRING_DATATYPES; + public static final Set<IRI> STRING_DATATYPES; public static final Map<Class<?>, XsdDataTypeEnum> JAVA_OBJECT_XSD_DATATYPE_MAPPING; static { - Map<UriRef,XsdDataTypeEnum> dataTypeMappings = new HashMap<UriRef, XsdDataTypeEnum>(); + Map<IRI,XsdDataTypeEnum> dataTypeMappings = new HashMap<IRI, XsdDataTypeEnum>(); Map<Class<?>,XsdDataTypeEnum> objectMappings = new HashMap<Class<?>, XsdDataTypeEnum>(); - Set<UriRef> stringDataTypes = new HashSet<UriRef>(); + Set<IRI> stringDataTypes = new HashSet<IRI>(); stringDataTypes.add(null);//map missing dataTypes to String for(XsdDataTypeEnum mapping : XsdDataTypeEnum.values()){ - UriRef uri = new UriRef(mapping.getUri()); + IRI uri = new IRI(mapping.getUri()); dataTypeMappings.put(uri,mapping); if(mapping.getMappedClass() != null && String.class.isAssignableFrom(mapping.getMappedClass())){ stringDataTypes.add(uri); @@ -195,10 +193,9 @@ public final class RdfResourceUtils { List<String> results = new ArrayList<String>(); while (literals.hasNext()) { Literal act = literals.next(); - if (act instanceof PlainLiteral) { - PlainLiteral pl = (PlainLiteral) act; - if (languageSet.contains(pl.getLanguage())) { - results.add(0, pl.getLexicalForm()); //add to front + if (act.getLanguage() != null) { + if (languageSet.contains(act.getLanguage())) { + results.add(0, act.getLexicalForm()); //add to front } } else if (containsNull) { //add also all types Literals, because the do not define an language! results.add(act.getLexicalForm()); //append to the end @@ -213,7 +210,7 @@ public final class RdfResourceUtils { * @param uriRefObjects iterator over URIs * @return the unicode representation */ - public static Collection<String> getUriRefValues(Iterator<UriRef> uriRefObjects) { + public static Collection<String> getIRIValues(Iterator<IRI> uriRefObjects) { Collection<String> results = new ArrayList<String>(); while (uriRefObjects.hasNext()) { results.add(uriRefObjects.next().getUnicodeString()); @@ -232,12 +229,12 @@ public final class RdfResourceUtils { * @param lang the language of the literal * @return the Literal */ - public static PlainLiteral createLiteral(String literalValue, String lang) { + public static Literal createLiteral(String literalValue, String lang) { Language language = (lang != null && lang.length() > 0) ? new Language(lang) : null; return new PlainLiteralImpl(literalValue, language); } - public static TypedLiteral createLiteral(Object object) { + public static Literal createLiteral(Object object) { return literalFactory.createTypedLiteral(object); } Modified: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfText.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfText.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfText.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfText.java Tue May 17 22:20:49 2016 @@ -16,10 +16,9 @@ */ package org.apache.stanbol.entityhub.model.clerezza; -import org.apache.clerezza.rdf.core.Language; -import org.apache.clerezza.rdf.core.Literal; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; +import org.apache.clerezza.commons.rdf.Language; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; import org.apache.stanbol.entityhub.servicesapi.model.Text; public class RdfText implements Text, Cloneable { @@ -41,14 +40,14 @@ public class RdfText implements Text, Cl protected RdfText(Literal literal) { this.literal = literal; - this.isPlain = literal instanceof PlainLiteral; + this.isPlain = literal instanceof Literal; } @Override public String getLanguage() { return isPlain && - ((PlainLiteral) literal).getLanguage() != null ? - ((PlainLiteral) literal).getLanguage().toString() : null; + (literal).getLanguage() != null ? + (literal).getLanguage().toString() : null; } @Override @@ -62,7 +61,7 @@ public class RdfText implements Text, Cl @Override public RdfText clone() { - Language language = isPlain ? ((PlainLiteral) literal).getLanguage() : null; + Language language = isPlain ? (literal).getLanguage() : null; return new RdfText(new PlainLiteralImpl(literal.getLexicalForm(), language)); } Modified: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactory.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactory.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactory.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactory.java Tue May 17 22:20:49 2016 @@ -18,13 +18,13 @@ package org.apache.stanbol.entityhub.mod import java.util.Iterator; -import org.apache.clerezza.rdf.core.Graph; -import org.apache.clerezza.rdf.core.Literal; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.clerezza.commons.rdf.ImmutableGraph; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.apache.stanbol.entityhub.servicesapi.model.Representation; import org.apache.stanbol.entityhub.servicesapi.model.ValueFactory; /** @@ -53,7 +53,7 @@ public final class RdfValueFactory imple * If not <code>null</code> all {@link RdfRepresentation} created by this * instance will use this graph. */ - private MGraph graph; + private Graph graph; private RdfValueFactory(){ this(null); } @@ -64,7 +64,7 @@ public final class RdfValueFactory imple * graph. * @param graph */ - public RdfValueFactory(MGraph graph){ + public RdfValueFactory(Graph graph){ super(); this.graph = graph; } @@ -73,8 +73,8 @@ public final class RdfValueFactory imple public RdfReference createReference(Object value) { if (value == null) { throw new IllegalArgumentException("The parsed value MUST NOT be NULL"); - } else if (value instanceof UriRef) { - return new RdfReference((UriRef) value); + } else if (value instanceof IRI) { + return new RdfReference((IRI) value); } else { return new RdfReference(value.toString()); } @@ -103,14 +103,14 @@ public final class RdfValueFactory imple } else if(id.isEmpty()){ throw new IllegalArgumentException("The parsed id MUST NOT be empty!"); } else { - return createRdfRepresentation(new UriRef(id), - graph == null ? new IndexedMGraph() : graph); + return createRdfRepresentation(new IRI(id), + graph == null ? new IndexedGraph() : graph); } } /** * {@link RdfRepresentation} specific create Method based on an existing - * RDF Graph. + * RDF ImmutableGraph. * * @param node The node of the node used for the representation. If this * node is not part of the parsed graph, the resulting representation @@ -118,7 +118,7 @@ public final class RdfValueFactory imple * @param graph the graph. * @return The representation based on the state of the parsed graph */ - public RdfRepresentation createRdfRepresentation(UriRef node, TripleCollection graph) { + public RdfRepresentation createRdfRepresentation(IRI node, Graph graph) { if (node == null) { throw new IllegalArgumentException("The parsed id MUST NOT be NULL!"); } @@ -129,11 +129,11 @@ public final class RdfValueFactory imple } /** - * Extracts the Graph for {@link RdfRepresentation} or creates a {@link Graph} + * Extracts the ImmutableGraph for {@link RdfRepresentation} or creates a {@link ImmutableGraph} * for all other implementations of {@link Representation}. * * @param representation the representation - * @return the read only RDF Graph. + * @return the read only RDF ImmutableGraph. */ public RdfRepresentation toRdfRepresentation(Representation representation) { if (representation instanceof RdfRepresentation) { Copied: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/IRI2ReferenceAdapter.java (from r1744311, stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRef2ReferenceAdapter.java) URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/IRI2ReferenceAdapter.java?p2=stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/IRI2ReferenceAdapter.java&p1=stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRef2ReferenceAdapter.java&r1=1744311&r2=1744328&rev=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRef2ReferenceAdapter.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/IRI2ReferenceAdapter.java Tue May 17 22:20:49 2016 @@ -16,24 +16,24 @@ */ package org.apache.stanbol.entityhub.model.clerezza.impl; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.stanbol.entityhub.servicesapi.util.AdaptingIterator.Adapter; import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory; import org.apache.stanbol.entityhub.servicesapi.model.Reference; /** - * Adapter that converts Clerezza {@link UriRef} instances to {@link Reference}s. + * Adapter that converts Clerezza {@link IRI} instances to {@link Reference}s. * The {@link RdfValueFactory} is used to create {@link Reference} instances. * @author Rupert Westenthaler * */ -public class UriRef2ReferenceAdapter implements Adapter<UriRef,Reference> { +public class IRI2ReferenceAdapter implements Adapter<IRI,Reference> { private final RdfValueFactory valueFactory = RdfValueFactory.getInstance(); @Override - public final Reference adapt(UriRef value, Class<Reference> type) { + public final Reference adapt(IRI value, Class<Reference> type) { return valueFactory.createReference(value); } Copied: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/IRIAdapter.java (from r1744311, stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRefAdapter.java) URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/IRIAdapter.java?p2=stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/IRIAdapter.java&p1=stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRefAdapter.java&r1=1744311&r2=1744328&rev=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/UriRefAdapter.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/IRIAdapter.java Tue May 17 22:20:49 2016 @@ -21,38 +21,38 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.stanbol.entityhub.servicesapi.util.AdaptingIterator.Adapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class UriRefAdapter<A> implements Adapter<UriRef, A> { +public class IRIAdapter<A> implements Adapter<IRI, A> { - private static Logger log = LoggerFactory.getLogger(UriRefAdapter.class); + private static Logger log = LoggerFactory.getLogger(IRIAdapter.class); @SuppressWarnings("unchecked") @Override - public final A adapt(UriRef value, Class<A> type) { + public final A adapt(IRI value, Class<A> type) { if(type.equals(URI.class)){ try { return (A) new URI(value.getUnicodeString()); } catch (URISyntaxException e) { - log.warn("Unable to parse an URI for UriRef "+value,e); + log.warn("Unable to parse an URI for IRI "+value,e); return null; } } else if(type.equals(URL.class)){ try { return (A) new URL(value.getUnicodeString()); } catch (MalformedURLException e) { - log.warn("Unable to parse an URL for UriRef "+value,e); + log.warn("Unable to parse an URL for IRI "+value,e); } } else if(type.equals(String.class)){ return (A) value.getUnicodeString(); - } else if(type.equals(UriRef.class)){ //Who converts UriRef -> UriRef ^ + } else if(type.equals(IRI.class)){ //Who converts IRI -> IRI ^ return (A) value; } else { - log.warn(type+" is not a supported target type for "+UriRef.class); + log.warn(type+" is not a supported target type for "+IRI.class); } return null; } Modified: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Literal2TextAdapter.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Literal2TextAdapter.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Literal2TextAdapter.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Literal2TextAdapter.java Tue May 17 22:20:49 2016 @@ -21,10 +21,9 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.apache.clerezza.rdf.core.Literal; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.TypedLiteral; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.Language; import org.apache.stanbol.entityhub.servicesapi.util.AdaptingIterator.Adapter; import org.apache.stanbol.entityhub.model.clerezza.RdfResourceUtils; import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory; @@ -56,11 +55,11 @@ public class Literal2TextAdapter<T exten * The xsd:string data type constant used for TypedLiterals to check if the * represent an string value! */ - private static UriRef xsdString = new UriRef(DataTypeEnum.String.getUri()); + private static IRI xsdString = new IRI(DataTypeEnum.String.getUri()); /** * Unmodifiable set of the active languages */ - private final Set<String> languages; + private final Set<Language> languages; private final boolean containsNull; private final RdfValueFactory valueFactory = RdfValueFactory.getInstance(); @@ -74,7 +73,15 @@ public class Literal2TextAdapter<T exten */ public Literal2TextAdapter(String...lang){ if(lang != null && lang.length>0){ - this.languages = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(lang))); + Set<Language> languagesConverted = new HashSet<Language>(); + for (String lang1 : lang) { + if (lang1 == null) { + languagesConverted.add(null); + } else { + languagesConverted.add(new Language(lang1)); + } + } + this.languages = Collections.unmodifiableSet(languagesConverted); this.containsNull = languages.contains(null); } else{ this.languages = null; @@ -85,14 +92,13 @@ public class Literal2TextAdapter<T exten @Override public final Text adapt(T value, Class<Text> type) { - if(value instanceof PlainLiteral){ - String literalLang = ((PlainLiteral) value).getLanguage() == null ? - null : ((PlainLiteral) value).getLanguage().toString(); + if(value.getLanguage() != null) { + Language literalLang = value.getLanguage(); if(languages == null || languages.contains(literalLang)){ return valueFactory.createText(value); } //else wrong language -> filter - } else if(value instanceof TypedLiteral) { - if(containsNull && ((TypedLiteral)value).getDataType().equals(xsdString)){ + } else { + if(containsNull && value.getDataType().equals(xsdString)){ /* * if the null language is active, than we can also return * "normal" literals (with no known language). @@ -100,10 +106,7 @@ public class Literal2TextAdapter<T exten */ return valueFactory.createText(value); } // else no xsd:string dataType and therefore not a text with default lang! - } else {// unknown Literal type -> filter + warning - log.warn(String.format("Unknown LiteralType %s (lexicalForm=\"%s\") -> ignored! Pleas adapt this implementation to support this type!", - value.getClass(),value.getLexicalForm())); - } + } return null; } Modified: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/LiteralAdapter.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/LiteralAdapter.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/LiteralAdapter.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/LiteralAdapter.java Tue May 17 22:20:49 2016 @@ -17,12 +17,9 @@ package org.apache.stanbol.entityhub.model.clerezza.impl; import org.apache.clerezza.rdf.core.InvalidLiteralTypeException; -import org.apache.clerezza.rdf.core.Literal; +import org.apache.clerezza.commons.rdf.Literal; import org.apache.clerezza.rdf.core.LiteralFactory; import org.apache.clerezza.rdf.core.NoConvertorException; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.TypedLiteral; -import org.apache.clerezza.rdf.core.impl.SimpleLiteralFactory; import org.apache.stanbol.entityhub.servicesapi.util.AdaptingIterator.Adapter; import org.apache.stanbol.entityhub.model.clerezza.RdfResourceUtils; import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory; @@ -37,7 +34,7 @@ import org.slf4j.LoggerFactory; * <li> String: Converts all Literal to there lexical form * <li> Text: Converts {@link PlainLiteral}s and {@link TypedLiteral}s with a * data type constrained in {@link RdfResourceUtils#STRING_DATATYPES} to Text instances - * <li> Int, Long, UriRef ... : Converts {@link TypedLiteral}s to the according + * <li> Int, Long, IRI ... : Converts {@link TypedLiteral}s to the according * Java Object by using the Clerezza {@link LiteralFactory} (see {@link SimpleLiteralFactory}) * </ul> * @@ -66,21 +63,15 @@ public class LiteralAdapter<T extends Li // return (A) value.getLexicalForm(); // } else if(Text.class.isAssignableFrom(type)){ - if(value instanceof PlainLiteral || - (value instanceof TypedLiteral && - RdfResourceUtils.STRING_DATATYPES.contains(((TypedLiteral)value).getDataType()))){ + if(RdfResourceUtils.STRING_DATATYPES.contains(value.getDataType())){ return (A)valueFactory.createText(value); } else { //this Literal can not be converted to Text! - if(value instanceof TypedLiteral){ //TODO: maybe remove this debugging for performance reasons - log.debug("TypedLiterals of type "+((TypedLiteral)value).getDataType()+" can not be converted to Text"); - } else { - log.warn("Literal of type"+value.getClass()+" are not supported by this Adapter"); - } + log.warn("Literal of type"+value.getClass()+" are not supported by this Adapter"); return null; } - } else if(TypedLiteral.class.isAssignableFrom(value.getClass())){ + } else if(Literal.class.isAssignableFrom(value.getClass())){ try { - return lf.createObject(type, (TypedLiteral)value); + return lf.createObject(type, value); } catch (NoConvertorException e) { //This usually indicates a missing converter ... so log in warning log.warn("unable to convert "+value+" to "+type,e); Modified: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/NaturalTextFilter.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/NaturalTextFilter.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/NaturalTextFilter.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/NaturalTextFilter.java Tue May 17 22:20:49 2016 @@ -21,10 +21,9 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.apache.clerezza.rdf.core.Literal; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.TypedLiteral; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.Language; import org.apache.stanbol.entityhub.servicesapi.util.FilteringIterator; import org.apache.stanbol.entityhub.servicesapi.util.FilteringIterator.Filter; import org.apache.stanbol.entityhub.servicesapi.defaults.DataTypeEnum; @@ -55,8 +54,8 @@ public class NaturalTextFilter implement * The xsd:string data type constant used for TypedLiterals to check if the * represent an string value! */ - private static UriRef xsdString = new UriRef(DataTypeEnum.String.getUri()); - private final Set<String> languages; + private static IRI xsdString = new IRI(DataTypeEnum.String.getUri()); + private final Set<Language> languages; private final boolean containsNull; public NaturalTextFilter(String...languages){ @@ -64,35 +63,36 @@ public class NaturalTextFilter implement this.languages = null; this.containsNull = true; // if no language is parse accept any (also the default) } else { - Set<String> languageSet = new HashSet<String>(Arrays.asList(languages)); - if(languageSet.remove("")){ - /* - * Parsing "" as language needs to be interpreted as parsing - * null - */ - languageSet.add(null); + Set<Language> languagesConverted = new HashSet<Language>(); + for (String lang1 : languages) { + + if (lang1 == null || lang1.equals("")) { + languagesConverted.add(null); + } else { + languagesConverted.add(new Language(lang1)); + } } - this.languages = Collections.unmodifiableSet(languageSet); + this.languages = Collections.unmodifiableSet(languagesConverted); + this.containsNull = this.languages.contains(null); } } @Override public final boolean isValid(Literal value) { - if (value instanceof PlainLiteral){ + if (value.getLanguage() != null){ if(languages == null) { //no language restrictions return true; //return any Plain Literal } else { - String literalLang = ((PlainLiteral) value).getLanguage() == null ? - null : ((PlainLiteral) value).getLanguage().toString(); + Language literalLang = value.getLanguage(); return languages.contains(literalLang); } - } else if(value instanceof TypedLiteral){ + } else if(value.getDataType().equals(xsdString)) { /* * if the null language is active, than we can also return * "normal" literals (with no known language). This includes * Types literals with the data type xsd:string */ - return containsNull && ((TypedLiteral)value).getDataType().equals(xsdString); + return containsNull; } else {// unknown Literal type -> filter + warning log.warn(String.format("Unknown LiteralType %s (lexicalForm=\"%s\") -> ignored! Pleas adapt this implementation to support this type!", value.getClass(),value.getLexicalForm())); Modified: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2ValueAdapter.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2ValueAdapter.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2ValueAdapter.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/impl/Resource2ValueAdapter.java Tue May 17 22:20:49 2016 @@ -16,12 +16,10 @@ */ package org.apache.stanbol.entityhub.model.clerezza.impl; -import org.apache.clerezza.rdf.core.Literal; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.TypedLiteral; -import org.apache.clerezza.rdf.core.UriRef; import org.apache.stanbol.entityhub.servicesapi.util.AdaptingIterator.Adapter; import org.apache.stanbol.entityhub.model.clerezza.RdfResourceUtils; import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory; @@ -37,9 +35,9 @@ import org.slf4j.LoggerFactory; * @author Rupert Westenthaler * * @param <T> - * the type of the Resource that can be converted to values + * the type of the RDFTerm that can be converted to values */ -public class Resource2ValueAdapter<T extends Resource> implements Adapter<T,Object> { +public class Resource2ValueAdapter<T extends RDFTerm> implements Adapter<T,Object> { private static Logger log = LoggerFactory.getLogger(Resource2ValueAdapter.class); @@ -49,12 +47,10 @@ public class Resource2ValueAdapter<T ext @Override public final Object adapt(T value, Class<Object> type) { - if (value instanceof UriRef) { + if (value instanceof IRI) { return valueFactory.createReference(value); - } else if (value instanceof PlainLiteral) { - return valueFactory.createText(value); - } else if (value instanceof TypedLiteral) { - TypedLiteral literal = (TypedLiteral) value; + } else if (value instanceof Literal) { + Literal literal = (Literal) value; if (literal.getDataType() == null) { // if no dataType is defined // return a Text without a language return valueFactory.createText(literal); @@ -96,7 +92,7 @@ public class Resource2ValueAdapter<T ext } } } else { - log.warn("Unsupported Resource Type {} -> return String by using the toString method", + log.warn("Unsupported RDFTerm Type {} -> return String by using the toString method", value.getClass()); return value.toString(); } Modified: stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/utils/Resource2StringAdapter.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/utils/Resource2StringAdapter.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/utils/Resource2StringAdapter.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/main/java/org/apache/stanbol/entityhub/model/clerezza/utils/Resource2StringAdapter.java Tue May 17 22:20:49 2016 @@ -16,27 +16,27 @@ */ package org.apache.stanbol.entityhub.model.clerezza.utils; -import org.apache.clerezza.rdf.core.Literal; -import org.apache.clerezza.rdf.core.Resource; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.stanbol.entityhub.servicesapi.util.AdaptingIterator.Adapter; /** - * Needed because UriRefs and Literals use the RDF representation for the + * Needed because IRIs and Literals use the RDF representation for the * toString Method * * @author Rupert Westenthaler * * @param <T> */ -public class Resource2StringAdapter<T extends Resource> implements Adapter<T, String> { +public class Resource2StringAdapter<T extends RDFTerm> implements Adapter<T, String> { @Override public final String adapt(T value, Class<String> type) { if (value == null) { return null; - } else if (value instanceof UriRef) { - return ((UriRef) value).getUnicodeString(); + } else if (value instanceof IRI) { + return ((IRI) value).getUnicodeString(); } else if (value instanceof Literal) { return ((Literal) value).getLexicalForm(); } else { Modified: stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentationTest.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentationTest.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentationTest.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfRepresentationTest.java Tue May 17 22:20:49 2016 @@ -28,11 +28,10 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.apache.clerezza.rdf.core.Language; +import org.apache.clerezza.commons.rdf.Language; +import org.apache.clerezza.commons.rdf.Literal; +import org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.PlainLiteral; -import org.apache.clerezza.rdf.core.TypedLiteral; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; import org.apache.stanbol.entityhub.servicesapi.model.Representation; import org.apache.stanbol.entityhub.servicesapi.model.Text; import org.apache.stanbol.entityhub.servicesapi.model.ValueFactory; @@ -65,7 +64,7 @@ public class RdfRepresentationTest exten * Additional Tests for special Features of the Clerezza based implementation * * This includes mainly support for additional types like PlainLiteral, - * TypedLiteral, UriRefs. The conversion to such types as well as getter for + * TypedLiteral, IRIs. The conversion to such types as well as getter for * such types. *-------------------------------------------------------------------------- */ @@ -79,11 +78,11 @@ public class RdfRepresentationTest exten @Test public void testPlainLiteralToTextConversion(){ String field = "urn:test.RdfRepresentation:test.field"; - PlainLiteral noLangLiteral = new PlainLiteralImpl("A plain literal without Language"); - PlainLiteral enLiteral = new PlainLiteralImpl("An english literal",new Language("en")); - PlainLiteral deLiteral = new PlainLiteralImpl("Ein Deutsches Literal",new Language("de")); - PlainLiteral deATLiteral = new PlainLiteralImpl("Ein Topfen Verband hilft bei Zerrungen",new Language("de-AT")); - Collection<PlainLiteral> plainLiterals = Arrays.asList(noLangLiteral,enLiteral,deLiteral,deATLiteral); + Literal noLangLiteral = new PlainLiteralImpl("A plain literal without Language"); + Literal enLiteral = new PlainLiteralImpl("An english literal",new Language("en")); + Literal deLiteral = new PlainLiteralImpl("Ein Deutsches Literal",new Language("de")); + Literal deATLiteral = new PlainLiteralImpl("Ein Topfen Verband hilft bei Zerrungen",new Language("de-AT")); + Collection<Literal> plainLiterals = Arrays.asList(noLangLiteral,enLiteral,deLiteral,deATLiteral); Representation rep = createRepresentation(null); rep.add(field, plainLiterals); //now test, that the Plain Literals are available as natural language @@ -104,7 +103,7 @@ public class RdfRepresentationTest exten assertFalse(enLangaugeTexts.hasNext());//only a single result //3) test to get all natural language values Set<String> stringValues = new HashSet<String>(); - for(PlainLiteral plainLiteral : plainLiterals){ + for(Literal plainLiteral : plainLiterals){ stringValues.add(plainLiteral.getLexicalForm()); } Iterator<Text> texts = rep.getText(field); @@ -123,9 +122,9 @@ public class RdfRepresentationTest exten @Test public void testTypedLiteralToTextConversion(){ String field = "urn:test.RdfRepresentation:test.field"; - TypedLiteral stringLiteral = literalFactory.createTypedLiteral("This is a stirng value"); + Literal stringLiteral = literalFactory.createTypedLiteral("This is a stirng value"); //also add an integer to test that other typed literals are not used as texts - TypedLiteral integerLiteral = literalFactory.createTypedLiteral(new Integer(5)); + Literal integerLiteral = literalFactory.createTypedLiteral(new Integer(5)); Representation rep = createRepresentation(null); rep.add(field, Arrays.asList(stringLiteral,integerLiteral)); //test if the literal is returned when asking for natural language text without language @@ -151,20 +150,20 @@ public class RdfRepresentationTest exten public void testTypedLiteralToValueConversion(){ String field = "urn:test.RdfRepresentation:test.field"; Integer integerValue = 5; - TypedLiteral integerLiteral = literalFactory.createTypedLiteral(integerValue); + Literal integerLiteral = literalFactory.createTypedLiteral(integerValue); Date dateValue = new Date(); - TypedLiteral dateLiteeral = literalFactory.createTypedLiteral(dateValue); + Literal dateLiteeral = literalFactory.createTypedLiteral(dateValue); Double doubleValue = Math.PI; - TypedLiteral doubleLiteral = literalFactory.createTypedLiteral(doubleValue); + Literal doubleLiteral = literalFactory.createTypedLiteral(doubleValue); String stringValue = "This is a string literal value"; - TypedLiteral stringLiteral = literalFactory.createTypedLiteral(stringValue); + Literal stringLiteral = literalFactory.createTypedLiteral(stringValue); Representation rep = createRepresentation(null); - Collection<TypedLiteral> typedLiterals = + Collection<Literal> typedLiterals = Arrays.asList(integerLiteral,doubleLiteral,stringLiteral,dateLiteeral); rep.add(field, typedLiterals); //now check that such values are available via TypedLiteral - Iterator<TypedLiteral> typedLiteralValues = rep.get(field, TypedLiteral.class); + Iterator<Literal> typedLiteralValues = rep.get(field, Literal.class); int size = 0; while(typedLiteralValues.hasNext()){ assertTrue(typedLiterals.contains(typedLiteralValues.next())); Modified: stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactoryTest.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactoryTest.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactoryTest.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/RdfValueFactoryTest.java Tue May 17 22:20:49 2016 @@ -16,10 +16,10 @@ */ package org.apache.stanbol.entityhub.model.clerezza; -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.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.apache.stanbol.entityhub.servicesapi.model.ValueFactory; import org.apache.stanbol.entityhub.test.model.ValueFactoryTest; import org.junit.Before; @@ -51,12 +51,12 @@ public class RdfValueFactoryTest extends } @Test(expected=IllegalArgumentException.class) public void testNullNodeRepresentation() { - MGraph graph = new IndexedMGraph(); + Graph graph = new IndexedGraph(); valueFactory.createRdfRepresentation(null, graph); } @Test(expected=IllegalArgumentException.class) public void testNullGraphRepresentation() { - UriRef rootNode = new UriRef("urn:test.rootNode"); + IRI rootNode = new IRI("urn:test.rootNode"); valueFactory.createRdfRepresentation(rootNode, null); } Modified: stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/impl/ResourceAdapterTest.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/impl/ResourceAdapterTest.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/impl/ResourceAdapterTest.java (original) +++ stanbol/trunk/entityhub/model/clerezza/src/test/java/org/apache/stanbol/entityhub/model/clerezza/impl/ResourceAdapterTest.java Tue May 17 22:20:49 2016 @@ -22,11 +22,11 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.UriRef; -import org.apache.clerezza.rdf.core.impl.TripleImpl; -import org.apache.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory; import org.apache.stanbol.entityhub.servicesapi.model.Representation; import org.junit.Assert; @@ -39,9 +39,9 @@ public class ResourceAdapterTest { */ @Test public void testDouble(){ - MGraph graph = new IndexedMGraph(); - UriRef id = new UriRef("http://www.example.org/test"); - UriRef doubleTestField = new UriRef("http://www.example.org/field/double"); + Graph graph = new IndexedGraph(); + IRI id = new IRI("http://www.example.org/test"); + IRI doubleTestField = new IRI("http://www.example.org/field/double"); LiteralFactory lf = LiteralFactory.getInstance(); graph.add(new TripleImpl(id, doubleTestField, lf.createTypedLiteral(Double.NaN))); graph.add(new TripleImpl(id, doubleTestField, lf.createTypedLiteral(Double.POSITIVE_INFINITY))); @@ -62,9 +62,9 @@ public class ResourceAdapterTest { @Test public void testFloat(){ - MGraph graph = new IndexedMGraph(); - UriRef id = new UriRef("http://www.example.org/test"); - UriRef doubleTestField = new UriRef("http://www.example.org/field/double"); + Graph graph = new IndexedGraph(); + IRI id = new IRI("http://www.example.org/test"); + IRI doubleTestField = new IRI("http://www.example.org/field/double"); LiteralFactory lf = LiteralFactory.getInstance(); graph.add(new TripleImpl(id, doubleTestField, lf.createTypedLiteral(Float.NaN))); graph.add(new TripleImpl(id, doubleTestField, lf.createTypedLiteral(Float.POSITIVE_INFINITY))); @@ -85,9 +85,9 @@ public class ResourceAdapterTest { // TODO: how to create NAN, POSITIVE_INFINITY, NEGATIVE_INVINITY instances for BigDecimal // @Test // public void testBigDecimal(){ -// MGraph graph = new IndexedMGraph(); -// UriRef id = new UriRef("http://www.example.org/test"); -// UriRef doubleTestField = new UriRef("http://www.example.org/field/double"); +// Graph graph = new IndexedGraph(); +// IRI id = new IRI("http://www.example.org/test"); +// IRI doubleTestField = new IRI("http://www.example.org/field/double"); // LiteralFactory lf = LiteralFactory.getInstance(); // graph.add(new TripleImpl(id, doubleTestField, lf.createTypedLiteral(BigDecimal.valueOf(Double.NaN)))); // graph.add(new TripleImpl(id, doubleTestField, lf.createTypedLiteral(BigDecimal.valueOf(Double.POSITIVE_INFINITY)))); Modified: stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/ClerezzaQueryUtils.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/ClerezzaQueryUtils.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/ClerezzaQueryUtils.java (original) +++ stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/ClerezzaQueryUtils.java Tue May 17 22:20:49 2016 @@ -18,10 +18,10 @@ package org.apache.stanbol.entityhub.que import java.util.Iterator; -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.commons.rdf.RDFTerm; +import org.apache.clerezza.commons.rdf.Triple; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.stanbol.entityhub.model.clerezza.RdfRepresentation; import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory; import org.apache.stanbol.entityhub.query.sparql.SparqlQueryUtils; @@ -47,24 +47,24 @@ public final class ClerezzaQueryUtils { private static final RdfValueFactory valueFavtory = RdfValueFactory.getInstance(); /** - * {@link UriRef} constant for {@link RdfResourceEnum#queryResult} + * {@link IRI} constant for {@link RdfResourceEnum#queryResult} * * @see RdfResourceEnum.fieldQueryResult */ - public static final UriRef FIELD_QUERY_RESULT = new UriRef(RdfResourceEnum.queryResult.getUri()); + public static final IRI FIELD_QUERY_RESULT = new IRI(RdfResourceEnum.queryResult.getUri()); /** - * {@link UriRef} constant for {@link RdfResourceEnum#QueryResultSet} + * {@link IRI} constant for {@link RdfResourceEnum#QueryResultSet} * * @see RdfResourceEnum.FieldQueryResultSet */ - public static final UriRef FIELD_QUERY_RESULT_SET = new UriRef(RdfResourceEnum.QueryResultSet.getUri()); + public static final IRI FIELD_QUERY_RESULT_SET = new IRI(RdfResourceEnum.QueryResultSet.getUri()); /** * @param query * @param resultGraph * @return */ - public static Iterator<RdfRepresentation> parseQueryResultsFromMGraph(final TripleCollection resultGraph) { + public static Iterator<RdfRepresentation> parseQueryResultsFromGraph(final Graph resultGraph) { Iterator<Triple> resultTripleIterator = resultGraph.filter(FIELD_QUERY_RESULT_SET, FIELD_QUERY_RESULT, null); Iterator<RdfRepresentation> resultIterator = new AdaptingIterator<Triple,RdfRepresentation>( @@ -75,14 +75,14 @@ public final class ClerezzaQueryUtils { */ @Override public RdfRepresentation adapt(Triple value, Class<RdfRepresentation> type) { - Resource object = value.getObject(); + RDFTerm object = value.getObject(); if (object == null) { return null; - } else if (object instanceof UriRef) { - return valueFavtory.createRdfRepresentation((UriRef) object, resultGraph); + } else if (object instanceof IRI) { + return valueFavtory.createRdfRepresentation((IRI) object, resultGraph); } else { log.warn("Unable to create representation for FieldQueryResult " + object - + " because this Resource is not of Type UriRef (type: " + + " because this RDFTerm is not of Type IRI (type: " + object.getClass() + ") -> result gets ignored"); return null; } Modified: stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/RdfQueryResultList.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/RdfQueryResultList.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/RdfQueryResultList.java (original) +++ stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/RdfQueryResultList.java Tue May 17 22:20:49 2016 @@ -25,7 +25,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import org.apache.clerezza.rdf.core.MGraph; +import org.apache.clerezza.commons.rdf.Graph; import org.apache.stanbol.entityhub.model.clerezza.RdfRepresentation; import org.apache.stanbol.entityhub.servicesapi.model.Representation; import org.apache.stanbol.entityhub.servicesapi.query.FieldQuery; @@ -37,19 +37,19 @@ public class RdfQueryResultList implemen private final FieldQuery query; private final List<RdfRepresentation> results; - private final MGraph resultGraph; + private final Graph resultGraph; - public RdfQueryResultList(FieldQuery query,MGraph resultGraph) { + public RdfQueryResultList(FieldQuery query,Graph resultGraph) { if(query == null){ throw new IllegalArgumentException("Parameter Query MUST NOT be NULL!"); } if(resultGraph == null){ - throw new IllegalArgumentException("Parameter \"MGraph resultGraph\" MUST NOT be NULL"); + throw new IllegalArgumentException("Parameter \"Graph resultGraph\" MUST NOT be NULL"); } this.query = query; this.resultGraph = resultGraph; List<RdfRepresentation> results = (List<RdfRepresentation>)ModelUtils.addToCollection( - ClerezzaQueryUtils.parseQueryResultsFromMGraph(resultGraph), + ClerezzaQueryUtils.parseQueryResultsFromGraph(resultGraph), new ArrayList<RdfRepresentation>()); //sort the list based on the score Collections.sort(results,RESULT_SCORE_COMPARATOR); @@ -92,10 +92,10 @@ public class RdfQueryResultList implemen return results.size(); } /** - * Getter for the RDF Graph holding the Results of the Query - * @return the RDF Graph with the Results + * Getter for the RDF ImmutableGraph holding the Results of the Query + * @return the RDF ImmutableGraph with the Results */ - public final MGraph getResultGraph() { + public final Graph getResultGraph() { return resultGraph; } @Override Modified: stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java (original) +++ stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java Tue May 17 22:20:49 2016 @@ -18,8 +18,8 @@ package org.apache.stanbol.entityhub.que import java.util.Iterator; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.stanbol.entityhub.model.clerezza.RdfRepresentation; import org.apache.stanbol.entityhub.query.sparql.SparqlEndpointTypeEnum; import org.apache.stanbol.entityhub.servicesapi.model.rdf.RdfResourceEnum; @@ -39,19 +39,19 @@ public final class SparqlQueryUtils { private SparqlQueryUtils() {} /** - * {@link UriRef} constant for {@link RdfResourceEnum#queryResult} + * {@link IRI} constant for {@link RdfResourceEnum#queryResult} * * @see ClerezzaQueryUtils#FIELD_QUERY_RESULT */ @Deprecated - public static final UriRef FIELD_QUERY_RESULT = ClerezzaQueryUtils.FIELD_QUERY_RESULT; + public static final IRI FIELD_QUERY_RESULT = ClerezzaQueryUtils.FIELD_QUERY_RESULT; /** - * {@link UriRef} constant for {@link RdfResourceEnum#QueryResultSet} + * {@link IRI} constant for {@link RdfResourceEnum#QueryResultSet} * * @see ClerezzaQueryUtils#FIELD_QUERY_RESULT_SET */ @Deprecated - public static final UriRef FIELD_QUERY_RESULT_SET = new UriRef(RdfResourceEnum.QueryResultSet.getUri()); + public static final IRI FIELD_QUERY_RESULT_SET = new IRI(RdfResourceEnum.QueryResultSet.getUri()); /** * Use {@link org.apache.stanbol.entityhub.query.sparql.SparqlQueryUtils} @@ -246,11 +246,11 @@ public final class SparqlQueryUtils { * @param query * @param resultGraph * @return - * @see ClerezzaQueryUtils#parseQueryResultsFromMGraph(TripleCollection) + * @see ClerezzaQueryUtils#parseQueryResultsFromGraph(Graph) */ @Deprecated - public static Iterator<RdfRepresentation> parseQueryResultsFromMGraph(final TripleCollection resultGraph) { - return ClerezzaQueryUtils.parseQueryResultsFromMGraph(resultGraph); + public static Iterator<RdfRepresentation> parseQueryResultsFromGraph(final Graph resultGraph) { + return ClerezzaQueryUtils.parseQueryResultsFromGraph(resultGraph); } } Modified: stanbol/trunk/entityhub/query/clerezza/src/test/java/org/apache/stanbol/entityhub/query/clerezza/RdfResultListTest.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/query/clerezza/src/test/java/org/apache/stanbol/entityhub/query/clerezza/RdfResultListTest.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/query/clerezza/src/test/java/org/apache/stanbol/entityhub/query/clerezza/RdfResultListTest.java (original) +++ stanbol/trunk/entityhub/query/clerezza/src/test/java/org/apache/stanbol/entityhub/query/clerezza/RdfResultListTest.java Tue May 17 22:20:49 2016 @@ -20,11 +20,11 @@ import java.util.Iterator; import java.util.SortedMap; import java.util.TreeMap; -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.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; +import org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph; +import org.apache.clerezza.commons.rdf.impl.utils.TripleImpl; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.apache.stanbol.entityhub.core.query.FieldQueryImpl; import org.apache.stanbol.entityhub.model.clerezza.RdfRepresentation; import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory; @@ -44,10 +44,10 @@ public class RdfResultListTest { @Test public void testRdfResultSorting(){ SortedMap<Double,RdfRepresentation> sorted = new TreeMap<Double,RdfRepresentation>(); - MGraph resultGraph = new IndexedMGraph(); + Graph resultGraph = new IndexedGraph(); RdfValueFactory vf = new RdfValueFactory(resultGraph); - UriRef resultListNode = new UriRef(RdfResourceEnum.QueryResultSet.getUri()); - UriRef resultProperty = new UriRef(RdfResourceEnum.queryResult.getUri()); + IRI resultListNode = new IRI(RdfResourceEnum.QueryResultSet.getUri()); + IRI resultProperty = new IRI(RdfResourceEnum.queryResult.getUri()); for(int i=0;i<100;i++){ Double rank; do { //avoid duplicate keys Modified: stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/CoolUriDereferencer.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/CoolUriDereferencer.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/CoolUriDereferencer.java (original) +++ stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/CoolUriDereferencer.java Tue May 17 22:20:49 2016 @@ -21,13 +21,13 @@ import java.io.InputStream; import java.net.URL; import java.net.URLConnection; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.clerezza.rdf.core.serializedform.Parser; import org.apache.clerezza.rdf.core.serializedform.SupportedFormat; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Reference; -import org.apache.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.apache.stanbol.entityhub.core.site.AbstractEntityDereferencer; import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory; import org.apache.stanbol.entityhub.servicesapi.model.Representation; @@ -72,10 +72,10 @@ public class CoolUriDereferencer extends long queryEnd = System.currentTimeMillis(); log.debug(" > DereferenceTime: "+(queryEnd-start)); if(in != null){ - MGraph rdfData = new IndexedMGraph(parser.parse(in, format,new UriRef(getBaseUri()))); + Graph rdfData = new IndexedGraph(parser.parse(in, format,new IRI(getBaseUri()))); long parseEnd = System.currentTimeMillis(); log.debug(" > ParseTime: "+(parseEnd-queryEnd)); - return valueFactory.createRdfRepresentation(new UriRef(uri), rdfData); + return valueFactory.createRdfRepresentation(new IRI(uri), rdfData); } else { return null; } Modified: stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/LarqSearcher.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/LarqSearcher.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/LarqSearcher.java (original) +++ stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/LarqSearcher.java Tue May 17 22:20:49 2016 @@ -23,13 +23,13 @@ import java.io.IOException; import java.io.InputStream; import java.util.List; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.clerezza.rdf.core.serializedform.Parser; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Reference; -import org.apache.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.apache.stanbol.entityhub.core.query.QueryResultListImpl; import org.apache.stanbol.entityhub.core.site.AbstractEntitySearcher; import org.apache.stanbol.entityhub.query.clerezza.RdfQueryResultList; @@ -69,13 +69,13 @@ public class LarqSearcher extends Abstra long queryEnd = System.currentTimeMillis(); log.debug(" > QueryTime: "+(queryEnd-initEnd)); if(in != null){ - MGraph graph; - TripleCollection rdfData = parser.parse(in, SparqlSearcher.DEFAULT_RDF_CONTENT_TYPE, - new UriRef(getBaseUri())); - if(rdfData instanceof MGraph){ - graph = (MGraph) rdfData; + Graph graph; + Graph rdfData = parser.parse(in, SparqlSearcher.DEFAULT_RDF_CONTENT_TYPE, + new IRI(getBaseUri())); + if(rdfData instanceof Graph){ + graph = (Graph) rdfData; } else { - graph = new IndexedMGraph(rdfData); + graph = new IndexedGraph(rdfData); } long parseEnd = System.currentTimeMillis(); log.debug(" > ParseTime: "+(parseEnd-queryEnd)); Modified: stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlDereferencer.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlDereferencer.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlDereferencer.java (original) +++ stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlDereferencer.java Tue May 17 22:20:49 2016 @@ -19,14 +19,14 @@ package org.apache.stanbol.entityhub.sit import java.io.IOException; import java.io.InputStream; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.clerezza.rdf.core.serializedform.Parser; import org.apache.clerezza.rdf.core.serializedform.SupportedFormat; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.Service; -import org.apache.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.apache.stanbol.entityhub.core.site.AbstractEntityDereferencer; import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory; import org.apache.stanbol.entityhub.servicesapi.model.Representation; @@ -67,7 +67,7 @@ public class SparqlDereferencer extends if(uri==null){ return null; } - UriRef reference = new UriRef(uri); + IRI reference = new IRI(uri); StringBuilder query = new StringBuilder(); query.append("CONSTRUCT { "); query.append(reference); @@ -86,10 +86,10 @@ public class SparqlDereferencer extends long queryEnd = System.currentTimeMillis(); log.debug(" > DereferenceTime: {}",(queryEnd-start)); if(in != null){ - MGraph rdfData = new IndexedMGraph(parser.parse(in, format,new UriRef(getBaseUri()))); + Graph rdfData = new IndexedGraph(parser.parse(in, format,new IRI(getBaseUri()))); long parseEnd = System.currentTimeMillis(); log.debug(" > ParseTime: {}",(parseEnd-queryEnd)); - return valueFactory.createRdfRepresentation(new UriRef(uri), rdfData); + return valueFactory.createRdfRepresentation(new IRI(uri), rdfData); } else { return null; } Modified: stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlSearcher.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlSearcher.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlSearcher.java (original) +++ stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlSearcher.java Tue May 17 22:20:49 2016 @@ -22,15 +22,15 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.clerezza.rdf.core.serializedform.Parser; import org.apache.clerezza.rdf.core.serializedform.SupportedFormat; import org.apache.commons.io.IOUtils; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Reference; -import org.apache.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.apache.stanbol.entityhub.core.query.QueryResultListImpl; import org.apache.stanbol.entityhub.core.site.AbstractEntitySearcher; import org.apache.stanbol.entityhub.query.clerezza.RdfQueryResultList; @@ -126,13 +126,13 @@ public class SparqlSearcher extends Abst long queryEnd = System.currentTimeMillis(); log.debug(" > QueryTime: "+(queryEnd-initEnd)); if(in != null){ - MGraph graph; - TripleCollection rdfData = parser.parse(in, DEFAULT_RDF_CONTENT_TYPE, - new UriRef(getBaseUri())); - if(rdfData instanceof MGraph){ - graph = (MGraph) rdfData; + Graph graph; + Graph rdfData = parser.parse(in, DEFAULT_RDF_CONTENT_TYPE, + new IRI(getBaseUri())); + if(rdfData instanceof Graph){ + graph = (Graph) rdfData; } else { - graph = new IndexedMGraph(rdfData); + graph = new IndexedGraph(rdfData); } long parseEnd = System.currentTimeMillis(); log.debug(" > ParseTime: "+(parseEnd-queryEnd)); Modified: stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/VirtuosoSearcher.java URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/VirtuosoSearcher.java?rev=1744328&r1=1744327&r2=1744328&view=diff ============================================================================== --- stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/VirtuosoSearcher.java (original) +++ stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/VirtuosoSearcher.java Tue May 17 22:20:49 2016 @@ -23,13 +23,13 @@ import java.io.IOException; import java.io.InputStream; import java.util.List; -import org.apache.clerezza.rdf.core.MGraph; -import org.apache.clerezza.rdf.core.TripleCollection; -import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.Graph; +import org.apache.clerezza.commons.rdf.IRI; import org.apache.clerezza.rdf.core.serializedform.Parser; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Reference; -import org.apache.stanbol.commons.indexedgraph.IndexedMGraph; +import org.apache.stanbol.commons.indexedgraph.IndexedGraph; import org.apache.stanbol.entityhub.core.query.QueryResultListImpl; import org.apache.stanbol.entityhub.core.site.AbstractEntitySearcher; import org.apache.stanbol.entityhub.query.clerezza.RdfQueryResultList; @@ -67,13 +67,13 @@ public class VirtuosoSearcher extends Ab long queryEnd = System.currentTimeMillis(); log.info(" > QueryTime: " + (queryEnd - initEnd)); if (in != null) { - MGraph graph; - TripleCollection rdfData = parser.parse(in, SparqlSearcher.DEFAULT_RDF_CONTENT_TYPE, new UriRef( + Graph graph; + Graph rdfData = parser.parse(in, SparqlSearcher.DEFAULT_RDF_CONTENT_TYPE, new IRI( getBaseUri())); - if (rdfData instanceof MGraph) { - graph = (MGraph) rdfData; + if (rdfData instanceof Graph) { + graph = (Graph) rdfData; } else { - graph = new IndexedMGraph(rdfData); + graph = new IndexedGraph(rdfData); } long parseEnd = System.currentTimeMillis(); log.info(" > ParseTime: " + (parseEnd - queryEnd));
