You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by re...@apache.org on 2016/05/17 22:20:55 UTC
svn commit: r1744328 [13/24] - in /stanbol/trunk: ./
commons/indexedgraph/src/main/java/org/apache/stanbol/commons/indexedgraph/
commons/indexedgraph/src/test/java/org/apache/stanbol/commons/indexedgraph/
commons/installer/bundleprovider/src/main/java/...
Modified: stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/ContentItem.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/ContentItem.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/ContentItem.java (original)
+++ stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/ContentItem.java Tue May 17 22:20:49 2016
@@ -20,20 +20,20 @@ import java.io.InputStream;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
-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;
/**
* A unit of content that Stanbol Enhancer can enhance.
* <p>
* Gives access to the binary content that
- * was registered, and the Graph that represents its metadata
+ * was registered, and the ImmutableGraph that represents its metadata
* (provided by client and/or generated).
*/
public interface ContentItem {
/** The Uri of this ContentItem (either supplied by client or generated by Stanbol Enhancer) */
- UriRef getUri();
+ IRI getUri();
/**
* The binary content stream. Shortcut for
@@ -53,20 +53,20 @@ public interface ContentItem {
* Read/write lock used to synchronise access to the {@link #getMetadata()
* metadata} and the content parts of this content item.<p>
* The lock needs to be used for reading and writing information from/to
- * the ContentItem. In case the {@link MGraph} retured by {@link #getMetadata()}
- * is an instanceof used by the {@link org.apache.clerezza.rdf.core.access.LockableMGraph}
+ * the ContentItem. In case the {@link Graph} retured by {@link #getMetadata()}
+ * is an instanceof used by the {@link org.apache.clerezza.rdf.core.access.LockableGraph}
* the {@link Lock} returned by this mehtod is the same as used by the
* metadata.This is to avoid deadlocks when using a lock while iterating over
* the {@link #getMetadata() metadata} and simultaneously accessing the content
* parts.
*
- * @return the lock used for the content parts and the {@link LockableMGraph}
+ * @return the lock used for the content parts and the {@link LockableGraph}
* containing the metadata of this content item.
*/
ReadWriteLock getLock();
/** Optional metadata */
- MGraph getMetadata();
+ Graph getMetadata();
/**
* The main content of this content item
@@ -96,13 +96,13 @@ public interface ContentItem {
* @throws IllegalArgumentException if <code>null</code> is parsed as
* uri or clazz.
*/
- <T> T getPart(UriRef uri, Class<T> clazz) throws NoSuchPartException;
+ <T> T getPart(IRI uri, Class<T> clazz) throws NoSuchPartException;
/**
* Get the uri of the part at the specified index
* @throws NoSuchPartException if no part with the parsed index exists
*/
- UriRef getPartUri(int index) throws NoSuchPartException;
+ IRI getPartUri(int index) throws NoSuchPartException;
/**
* Add a new part to this ContentItem
@@ -114,7 +114,7 @@ public interface ContentItem {
* @throws IllegalArgumentException if <code>null</code> is parsed as
* uriRef or object.
*/
- Object addPart(UriRef uriRef, Object object);
+ Object addPart(IRI uriRef, Object object);
/**
* Removes a part - other than the main content part - from this ContentItem
@@ -138,6 +138,6 @@ public interface ContentItem {
* <code>{@link #getPartUri(int) getPartUri(0)}</code>. This uri refers to
* the main content part. This part can NOT be removed by this method
*/
- void removePart(UriRef uriRef);
+ void removePart(IRI uriRef);
}
Modified: stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/ContentItemFactory.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/ContentItemFactory.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/ContentItemFactory.java (original)
+++ stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/ContentItemFactory.java Tue May 17 22:20:49 2016
@@ -20,9 +20,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-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.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.IRI;
/**
* OSGI service to be used to create {@link ContentItem}s and Blobs.
@@ -101,7 +101,7 @@ public interface ContentItemFactory {
* @throws IOException on any error while reading the content from the
* content source.
*/
- ContentItem createContentItem(UriRef id, ContentSource source) throws IOException;
+ ContentItem createContentItem(IRI id, ContentSource source) throws IOException;
/**
* Creates a new ContentItem for the passed id and content source.
* @param prefix the URI prefix used generate the URI of the content item.
@@ -118,7 +118,7 @@ public interface ContentItemFactory {
* Callers can safely close any resource related to the parsed {@link ContentSource}
* method after this method returns.
* @param source The content source
- * @param metadata an {@link MGraph} with the metadata or <code>null</code>
+ * @param metadata an {@link Graph} with the metadata or <code>null</code>
* if none. Implementation are free to use the passed instance or to generate
* a new one. However they MUST ensure that all {@link Triple}s contained by
* the passed graph are also added to the {@link ContentItem#getMetadata()
@@ -131,7 +131,7 @@ public interface ContentItemFactory {
* @throws IOException on any error while reading the content from the
* content source.
*/
- ContentItem createContentItem(String prefix, ContentSource source, MGraph metadata) throws IOException;
+ ContentItem createContentItem(String prefix, ContentSource source, Graph metadata) throws IOException;
/**
* Creates a new ContentItem for the passed id and content source.
* @param id the id for the ContentItem or <code>null</code> to generate an id.
@@ -146,7 +146,7 @@ public interface ContentItemFactory {
* Callers can safely close any resource related to the parsed {@link ContentSource}
* method after this method returns.
* @param source The content source
- * @param metadata an {@link MGraph} with the metadata or <code>null</code>
+ * @param metadata an {@link Graph} with the metadata or <code>null</code>
* if none. Implementation are free to use the passed instance or to generate
* a new one. However they MUST ensure that all {@link Triple}s contained by
* the passed graph are also added to the {@link ContentItem#getMetadata()
@@ -159,7 +159,7 @@ public interface ContentItemFactory {
* @throws IOException on any error while reading the content from the
* content source.
*/
- ContentItem createContentItem(UriRef id, ContentSource source, MGraph metadata) throws IOException;
+ ContentItem createContentItem(IRI id, ContentSource source, Graph metadata) throws IOException;
/**
* Creates a new ContentItem for the passed {@link ContentReference}. The
* {@link ContentReference#getReference()} is used as ID for the content
@@ -183,7 +183,7 @@ public interface ContentItemFactory {
* dereference}
* the reference at creation if needed.
* @param reference the reference to the content
- * @param metadata an {@link MGraph} with the metadata or <code>null</code>
+ * @param metadata an {@link Graph} with the metadata or <code>null</code>
* if none. Implementation are free to use the passed instance or to generate
* a new one. However they MUST ensure that all {@link Triple}s contained by
* the passed graph are also added to the {@link ContentItem#getMetadata()
@@ -196,7 +196,7 @@ public interface ContentItemFactory {
* @throws IllegalArgumentException if the passed {@link ContentReference}
* is <code>null</code>.
*/
- ContentItem createContentItem(ContentReference reference, MGraph metadata) throws IOException;
+ ContentItem createContentItem(ContentReference reference, Graph metadata) throws IOException;
/**
* Creates a new Blob based on the passed {@link ContentSource}<p>
* The content provided by the {@link ContentSource} is consumed by the
Modified: stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/NoSuchPartException.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/NoSuchPartException.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/NoSuchPartException.java (original)
+++ stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/NoSuchPartException.java Tue May 17 22:20:49 2016
@@ -16,7 +16,7 @@
*/
package org.apache.stanbol.enhancer.servicesapi;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.commons.rdf.IRI;
/**
* Indicates that a COntent Item doesn't has the requested part
@@ -29,7 +29,7 @@ public class NoSuchPartException extends
public NoSuchPartException(int index) {
super("The Content Item has no part with index "+index);
}
- public NoSuchPartException(UriRef partUri) {
+ public NoSuchPartException(IRI partUri) {
super("The Content Item has no part with index "+partUri);
}
public NoSuchPartException(String message) {
Modified: stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/ContentItemHelper.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/ContentItemHelper.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/ContentItemHelper.java (original)
+++ stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/ContentItemHelper.java Tue May 17 22:20:49 2016
@@ -33,7 +33,7 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
-import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.commons.rdf.IRI;
import org.apache.commons.io.IOUtils;
import org.apache.stanbol.enhancer.servicesapi.Blob;
import org.apache.stanbol.enhancer.servicesapi.ContentItem;
@@ -72,12 +72,12 @@ public final class ContentItemHelper {
* Check that ContentItem#getId returns a valid URI or make an urn out of
* it.
*/
- public static UriRef ensureUri(ContentItem ci) {
+ public static IRI ensureUri(ContentItem ci) {
String uri = ci.getUri().getUnicodeString();
if (!uri.startsWith("http://") && !uri.startsWith("urn:")) {
uri = "urn:" + urlEncode(uri);
}
- return new UriRef(uri);
+ return new IRI(uri);
}
public static String urlEncode(String uriPart) {
@@ -145,22 +145,22 @@ public final class ContentItemHelper {
return buf.toString();
}
- public static UriRef makeDefaultUrn(Blob blob) {
+ public static IRI makeDefaultUrn(Blob blob) {
return makeDefaultUri(DEFAULT_CONTENT_ITEM_PREFIX, blob.getStream());
}
- public static UriRef makeDefaultUrn(InputStream in) {
+ public static IRI makeDefaultUrn(InputStream in) {
return makeDefaultUri(DEFAULT_CONTENT_ITEM_PREFIX, in);
}
- public static UriRef makeDefaultUrn(byte[] data){
+ public static IRI makeDefaultUrn(byte[] data){
return makeDefaultUri(DEFAULT_CONTENT_ITEM_PREFIX, new ByteArrayInputStream(data));
}
- public static UriRef makeDefaultUri(String baseUri, Blob blob) {
+ public static IRI makeDefaultUri(String baseUri, Blob blob) {
return makeDefaultUri(baseUri, blob.getStream());
}
- public static UriRef makeDefaultUri(String baseUri, byte[] data) {
+ public static IRI makeDefaultUri(String baseUri, byte[] data) {
return makeDefaultUri(baseUri, new ByteArrayInputStream(data));
}
- public static UriRef makeDefaultUri(String baseUri, InputStream in) {
+ public static IRI makeDefaultUri(String baseUri, InputStream in) {
// calculate an ID based on the digest of the content
if (!baseUri.startsWith("urn:") && !baseUri.endsWith("/")) {
baseUri += "/";
@@ -174,7 +174,7 @@ public final class ContentItemHelper {
"of an ContentItem!",e);
}
IOUtils.closeQuietly(in);
- return new UriRef(baseUri + SHA1.toLowerCase() + "-" + hexDigest);
+ return new IRI(baseUri + SHA1.toLowerCase() + "-" + hexDigest);
}
/**
* This parses and validates the mime-type and parameters from the
@@ -230,7 +230,7 @@ public final class ContentItemHelper {
return parsed;
}
/**
- * Searches an {@link ContentItem#getPart(UriRef, Class) content part}
+ * Searches an {@link ContentItem#getPart(IRI, Class) content part}
* of the type {@link Blob} with one of the the parsed mimeTypes. <p>
* NOTE:<ul>
* <li> MimeTypes are converted to lower case before compared with
@@ -243,20 +243,20 @@ public final class ContentItemHelper {
* this method does NOT throw {@link NoSuchPartException}.
* @param ci the contentITem
* @param mimeTypes List of possible mimeTypes
- * @return the {@link UriRef URI} and the {@link Blob content} of the content
+ * @return the {@link IRI URI} and the {@link Blob content} of the content
* part or <code>null</code> if not found
* @throws IllegalArgumentException If the parsed {@link ContentItem} is
* <code>null</code> or the parsed Set with the mimeTypes is <code>null</code>
* or {@link Set#isEmpty() empty}.
*/
- public static Entry<UriRef, Blob> getBlob(ContentItem ci, Set<String> mimeTypes){
+ public static Entry<IRI, Blob> getBlob(ContentItem ci, Set<String> mimeTypes){
if(ci == null){
throw new IllegalArgumentException("The parsed ContentItem MUST NOT be NULL!");
}
if(mimeTypes == null || mimeTypes.isEmpty()){
throw new IllegalArgumentException("The parsed Set with mime type MUST NOT be NULL nor empty!");
}
- UriRef cpUri = null;
+ IRI cpUri = null;
int index = 0;
ci.getLock().readLock().lock();
try {
@@ -293,14 +293,14 @@ public final class ContentItemHelper {
* this method does NOT throw {@link NoSuchPartException}.
* @param ci the content item
* @param clazz the class of the content part
- * @return the Map with the {@link UriRef id}s and the content as entries.
+ * @return the Map with the {@link IRI id}s and the content as entries.
*/
- public static <T> Map<UriRef,T> getContentParts(ContentItem ci, Class<T> clazz){
+ public static <T> Map<IRI,T> getContentParts(ContentItem ci, Class<T> clazz){
if(ci == null){
throw new IllegalArgumentException("The parsed ContentItem MUST NOT be NULL!");
}
- LinkedHashMap<UriRef,T> blobs = new LinkedHashMap<UriRef,T>();
- UriRef cpUri = null;
+ LinkedHashMap<IRI,T> blobs = new LinkedHashMap<IRI,T>();
+ IRI cpUri = null;
int index = 0;
ci.getLock().readLock().lock();
try {
@@ -365,7 +365,7 @@ public final class ContentItemHelper {
* EnhancementEngine properties <p>
* @since 0.12.1
*/
- public static final UriRef REQUEST_PROPERTIES_URI = new UriRef(
+ public static final IRI REQUEST_PROPERTIES_URI = new IRI(
"urn:apache.org:stanbol.enhancer:request.properties");
/**
@@ -373,7 +373,7 @@ public final class ContentItemHelper {
* <code>0.12.0</code>
*/
@Deprecated
- private static final UriRef WEB_ENHANCEMENT_PROPERTIES_URI = new UriRef(
+ private static final IRI WEB_ENHANCEMENT_PROPERTIES_URI = new IRI(
"urn:apache.org:stanbol.web:enhancement.properties");
/**
Modified: stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/EnhancementEngineHelper.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/EnhancementEngineHelper.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/EnhancementEngineHelper.java (original)
+++ stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/EnhancementEngineHelper.java Tue May 17 22:20:49 2016
@@ -39,21 +39,19 @@ import java.util.Map.Entry;
import java.util.Random;
import java.util.UUID;
-import org.apache.clerezza.rdf.core.BNode;
+import org.apache.clerezza.commons.rdf.BlankNode;
import org.apache.clerezza.rdf.core.InvalidLiteralTypeException;
-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.Graph;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
+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.clerezza.commons.rdf.impl.utils.PlainLiteralImpl;
+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.NonLiteral;
-import org.apache.clerezza.rdf.core.PlainLiteral;
-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.TypedLiteral;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
-import org.apache.clerezza.rdf.core.impl.TripleImpl;
import org.apache.stanbol.enhancer.servicesapi.Chain;
import org.apache.stanbol.enhancer.servicesapi.ContentItem;
import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
@@ -117,22 +115,22 @@ public final class EnhancementEngineHelp
* Create a new instance with the types enhancer:Enhancement and
* enhancer:TextAnnotation in the metadata-graph of the content
* item along with default properties (dc:creator and dc:created) and return
- * the UriRef of the extraction so that engines can further add.
+ * the IRI of the extraction so that engines can further add.
*
* @param ci the ContentItem being under analysis
* @param engine the Engine performing the analysis
*
* @return the URI of the new enhancement instance
*/
- public static UriRef createTextEnhancement(ContentItem ci,
+ public static IRI createTextEnhancement(ContentItem ci,
EnhancementEngine engine){
- return createTextEnhancement(ci.getMetadata(), engine, new UriRef(ci.getUri().getUnicodeString()));
+ return createTextEnhancement(ci.getMetadata(), engine, new IRI(ci.getUri().getUnicodeString()));
}
/**
* Create a new instance with the types enhancer:Enhancement and
* enhancer:TextAnnotation in the parsed graph along with default properties
* (dc:creator, dc:created and enhancer:extracted-form) and return
- * the UriRef of the extraction so that engines can further add.
+ * the IRI of the extraction so that engines can further add.
*
* @param metadata the graph
* @param engine the engine
@@ -140,9 +138,9 @@ public final class EnhancementEngineHelp
*
* @return the URI of the new enhancement instance
*/
- public static UriRef createTextEnhancement(MGraph metadata,
- EnhancementEngine engine, UriRef contentItemId){
- UriRef enhancement = createEnhancement(metadata, engine,contentItemId);
+ public static IRI createTextEnhancement(Graph metadata,
+ EnhancementEngine engine, IRI contentItemId){
+ IRI enhancement = createEnhancement(metadata, engine,contentItemId);
//add the Text Annotation Type
metadata.add(new TripleImpl(enhancement, RDF_TYPE,
ENHANCER_TEXTANNOTATION));
@@ -153,7 +151,7 @@ public final class EnhancementEngineHelp
* fise:selected-text and fise:selection-suffix properties for the
* parsed fise:TextAnnotation instance according to the parsed parameters.<p>
* While it is intended to be used for TextAnnotations this method can also
- * be used to add the mentioned properties to {@link UriRef}s with different
+ * be used to add the mentioned properties to {@link IRI}s with different
* type.<p>
* <b>NOTE</b> the <code>allowSelectionHeadTail</code>: This parameter allows
* to deactivate the usage of fise:selection-head and fise:selection-tail.
@@ -161,7 +159,7 @@ public final class EnhancementEngineHelp
* and <code>true</code> in case sections of the text (e.g. phrases, sentences,
* chapters ...) are selected.
* @param metadata The RDF graph to add the information
- * @param textAnnotation the UriRef of the fise:TextAnnotation
+ * @param textAnnotation the IRI of the fise:TextAnnotation
* @param content the plain text content as String
* @param start the start index of the occurrence
* @param end the end index of the occurrence
@@ -175,7 +173,7 @@ public final class EnhancementEngineHelp
* size of the selected area.
* @since 0.11.0
*/
- public static void setOccurrence(MGraph metadata, UriRef textAnnotation,
+ public static void setOccurrence(Graph metadata, IRI textAnnotation,
String content, Integer start, Integer end, Language lang, int prefixSuffixSize,
boolean allowSelectionHeadTail){
//set start, end
@@ -275,21 +273,21 @@ public final class EnhancementEngineHelp
* Create a new instance with the types enhancer:Enhancement and
* enhancer:EntityAnnotation in the metadata-graph of the content
* item along with default properties (dc:creator and dc:created) and return
- * the UriRef of the extraction so that engines can further add
+ * the IRI of the extraction so that engines can further add
*
* @param ci the ContentItem being under analysis
* @param engine the Engine performing the analysis
* @return the URI of the new enhancement instance
*/
- public static UriRef createEntityEnhancement(ContentItem ci,
+ public static IRI createEntityEnhancement(ContentItem ci,
EnhancementEngine engine){
- return createEntityEnhancement(ci.getMetadata(), engine, new UriRef(ci.getUri().getUnicodeString()));
+ return createEntityEnhancement(ci.getMetadata(), engine, new IRI(ci.getUri().getUnicodeString()));
}
/**
* Create a new instance with the types enhancer:Enhancement and
* enhancer:EntityAnnotation in the parsed graph along with default properties
* (dc:creator, dc:created and enhancer:extracted-form) and return
- * the UriRef of the extraction so that engines can further add.
+ * the IRI of the extraction so that engines can further add.
*
* @param metadata the graph
* @param engine the engine
@@ -297,9 +295,9 @@ public final class EnhancementEngineHelp
*
* @return the URI of the new enhancement instance
*/
- public static UriRef createEntityEnhancement(MGraph metadata,
- EnhancementEngine engine, UriRef contentItemId){
- UriRef enhancement = createEnhancement(metadata, engine, contentItemId);
+ public static IRI createEntityEnhancement(Graph metadata,
+ EnhancementEngine engine, IRI contentItemId){
+ IRI enhancement = createEnhancement(metadata, engine, contentItemId);
metadata.add(new TripleImpl(enhancement, RDF_TYPE, ENHANCER_ENTITYANNOTATION));
return enhancement;
}
@@ -307,7 +305,7 @@ public final class EnhancementEngineHelp
* Create a new instance with the types enhancer:Enhancement and
* enhancer:TopicAnnotation in the parsed graph along with default properties
* (dc:creator, dc:created and enhancer:extracted-form) and return
- * the UriRef of the extraction so that engines can further add.
+ * the IRI of the extraction so that engines can further add.
*
* @param metadata the graph
* @param engine the engine
@@ -315,9 +313,9 @@ public final class EnhancementEngineHelp
*
* @return the URI of the new enhancement instance
*/
- public static UriRef createTopicEnhancement(MGraph metadata,
- EnhancementEngine engine, UriRef contentItemId){
- UriRef enhancement = createEnhancement(metadata, engine, contentItemId);
+ public static IRI createTopicEnhancement(Graph metadata,
+ EnhancementEngine engine, IRI contentItemId){
+ IRI enhancement = createEnhancement(metadata, engine, contentItemId);
metadata.add(new TripleImpl(enhancement, RDF_TYPE, ENHANCER_TOPICANNOTATION));
return enhancement;
}
@@ -325,20 +323,20 @@ public final class EnhancementEngineHelp
* Create a new instance with the types enhancer:Enhancement and
* enhancer:TopicAnnotation in the metadata-graph of the content
* item along with default properties (dc:creator and dc:created) and return
- * the UriRef of the extraction so that engines can further add
+ * the IRI of the extraction so that engines can further add
*
* @param ci the ContentItem being under analysis
* @param engine the Engine performing the analysis
* @return the URI of the new enhancement instance
*/
- public static UriRef createTopicEnhancement(ContentItem ci,
+ public static IRI createTopicEnhancement(ContentItem ci,
EnhancementEngine engine){
- return createTopicEnhancement(ci.getMetadata(), engine, new UriRef(ci.getUri().getUnicodeString()));
+ return createTopicEnhancement(ci.getMetadata(), engine, new IRI(ci.getUri().getUnicodeString()));
}
/**
* Create a new enhancement instance in the metadata-graph of the content
* item along with default properties (dc:creator and dc:created) and return
- * the UriRef of the extraction so that engines can further add. <p>
+ * the IRI of the extraction so that engines can further add. <p>
* <i>NOTE:</i> This method was protected prior to <code>0.12.1</code> (see
* <a href="https://issues.apache.org/jira/browse/STANBOL-1321">STANBOL-1321</a>)
*
@@ -348,11 +346,11 @@ public final class EnhancementEngineHelp
* @return the URI of the new enhancement instance
* @since 0.12.1
*/
- public static UriRef createEnhancement(MGraph metadata,
- EnhancementEngine engine, UriRef contentItemId){
+ public static IRI createEnhancement(Graph metadata,
+ EnhancementEngine engine, IRI contentItemId){
LiteralFactory literalFactory = LiteralFactory.getInstance();
- UriRef enhancement = new UriRef("urn:enhancement-"
+ IRI enhancement = new IRI("urn:enhancement-"
+ EnhancementEngineHelper.randomUUID());
//add the Enhancement Type
metadata.add(new TripleImpl(enhancement, RDF_TYPE,
@@ -386,7 +384,7 @@ public final class EnhancementEngineHelp
* @param enhancement the enhancement
* @param engine the engine
*/
- public static void addContributingEngine(MGraph metadata, UriRef enhancement,
+ public static void addContributingEngine(Graph metadata, IRI enhancement,
EnhancementEngine engine){
LiteralFactory literalFactory = LiteralFactory.getInstance();
// TODO: use a public dereferencing URI instead?
@@ -399,7 +397,7 @@ public final class EnhancementEngineHelp
/**
* Create a new extraction instance in the metadata-graph of the content
* item along with default properties (dc:creator and dc:created) and return
- * the UriRef of the extraction so that engines can further add
+ * the IRI of the extraction so that engines can further add
*
* @param ci the ContentItem being under analysis
* @param engine the Engine performing the analysis
@@ -409,12 +407,12 @@ public final class EnhancementEngineHelp
* @see EnhancementEngineHelper#createTextEnhancement(ContentItem, EnhancementEngine)
*/
@Deprecated
- public static UriRef createNewExtraction(ContentItem ci,
+ public static IRI createNewExtraction(ContentItem ci,
EnhancementEngine engine) {
LiteralFactory literalFactory = LiteralFactory.getInstance();
- MGraph metadata = ci.getMetadata();
- UriRef extraction = new UriRef("urn:extraction-"
+ Graph metadata = ci.getMetadata();
+ IRI extraction = new IRI("urn:extraction-"
+ EnhancementEngineHelper.randomUUID());
metadata.add(new TripleImpl(extraction, RDF_TYPE,
@@ -422,7 +420,7 @@ public final class EnhancementEngineHelp
// relate the extraction to the content item
metadata.add(new TripleImpl(extraction,
- ENHANCER_RELATED_CONTENT_ITEM, new UriRef(ci.getUri().getUnicodeString())));
+ ENHANCER_RELATED_CONTENT_ITEM, new IRI(ci.getUri().getUnicodeString())));
// creation date
metadata.add(new TripleImpl(extraction, DC_CREATED,
@@ -459,16 +457,16 @@ public final class EnhancementEngineHelp
* @param literalFactory the literalFactory
* @return the value
*/
- public static <T> T get(TripleCollection graph, NonLiteral resource, UriRef property, Class<T> type,
+ public static <T> T get(Graph graph, BlankNodeOrIRI resource, IRI property, Class<T> type,
LiteralFactory literalFactory){
Iterator<Triple> results = graph.filter(resource, property, null);
if(results.hasNext()){
while(results.hasNext()){
Triple result = results.next();
- if(result.getObject() instanceof TypedLiteral){
- return literalFactory.createObject(type, (TypedLiteral)result.getObject());
+ if(result.getObject() instanceof Literal){
+ return literalFactory.createObject(type, (Literal)result.getObject());
} else {
- log.debug("Triple {} does not have a TypedLiteral as object! -> ignore",result);
+ log.debug("Triple {} does not have a Literal as object! -> ignore",result);
}
}
log.info("No value for {} and property {} had the requested Type {} -> return null",
@@ -487,7 +485,7 @@ public final class EnhancementEngineHelp
* @param property the property
* @param value the value
*/
- public static void set(MGraph graph, NonLiteral resource, UriRef property, Resource value){
+ public static void set(Graph graph, BlankNodeOrIRI resource, IRI property, RDFTerm value){
set(graph,resource,property,value == null ? null : singleton(value),null);
}
/**
@@ -498,7 +496,7 @@ public final class EnhancementEngineHelp
* @param property the property
* @param value the value
*/
- public static void set(MGraph graph, NonLiteral resource, UriRef property, Collection<Resource> values){
+ public static void set(Graph graph, BlankNodeOrIRI resource, IRI property, Collection<RDFTerm> values){
set(graph,resource,property,values,null);
}
@@ -508,13 +506,13 @@ public final class EnhancementEngineHelp
* @param graph the graph
* @param resource the resource
* @param property the property
- * @param value the value. In case it is an instance of {@link Resource} it
+ * @param value the value. In case it is an instance of {@link RDFTerm} it
* is directly added to the graph. Otherwise the parsed {@link LiteralFactory}
* is used to create a {@link TypedLiteral} for the parsed value.
* @param literalFactory the {@link LiteralFactory} used in case the parsed
- * value is not an {@link Resource}
+ * value is not an {@link RDFTerm}
*/
- public static void set(MGraph graph, NonLiteral resource, UriRef property,
+ public static void set(Graph graph, BlankNodeOrIRI resource, IRI property,
Object value, LiteralFactory literalFactory){
set(graph,resource,property,value == null ? null : singleton(value),literalFactory);
}
@@ -524,13 +522,13 @@ public final class EnhancementEngineHelp
* @param graph the graph
* @param resource the resource
* @param property the property
- * @param value the value. In case it is an instance of {@link Resource} it
+ * @param value the value. In case it is an instance of {@link RDFTerm} it
* is directly added to the graph. Otherwise the parsed {@link LiteralFactory}
* is used to create a {@link TypedLiteral} for the parsed value.
* @param literalFactory the {@link LiteralFactory} used in case the parsed
- * value is not an {@link Resource}
+ * value is not an {@link RDFTerm}
*/
- public static void set(MGraph graph, NonLiteral resource, UriRef property,
+ public static void set(Graph graph, BlankNodeOrIRI resource, IRI property,
Collection<?> values, LiteralFactory literalFactory){
Iterator<Triple> currentValues = graph.filter(resource, property, null);
while(currentValues.hasNext()){
@@ -539,8 +537,8 @@ public final class EnhancementEngineHelp
}
if(values != null){
for(Object value : values){
- if(value instanceof Resource){
- graph.add(new TripleImpl(resource, property, (Resource) value));
+ if(value instanceof RDFTerm){
+ graph.add(new TripleImpl(resource, property, (RDFTerm) value));
} else if (value != null){
graph.add(new TripleImpl(resource, property,
literalFactory.createTypedLiteral(value)));
@@ -560,16 +558,16 @@ public final class EnhancementEngineHelp
* @param literalFactory the literalFactory
* @return the value
*/
- public static <T> Iterator<T> getValues(TripleCollection graph, NonLiteral resource,
- UriRef property, final Class<T> type, final LiteralFactory literalFactory){
+ public static <T> Iterator<T> getValues(Graph graph, BlankNodeOrIRI resource,
+ IRI property, final Class<T> type, final LiteralFactory literalFactory){
final Iterator<Triple> results = graph.filter(resource, property, null);
return new Iterator<T>() {
- //TODO: dose not check if the object of the triple is of type UriRef
+ //TODO: dose not check if the object of the triple is of type IRI
@Override
public boolean hasNext() { return results.hasNext(); }
@Override
public T next() {
- return literalFactory.createObject(type, (TypedLiteral)results.next().getObject());
+ return literalFactory.createObject(type, (Literal)results.next().getObject());
}
@Override
public void remove() { results.remove(); }
@@ -582,7 +580,7 @@ public final class EnhancementEngineHelp
* @param property the property
* @return the value
*/
- public static String getString(TripleCollection graph, NonLiteral resource, UriRef property){
+ public static String getString(Graph graph, BlankNodeOrIRI resource, IRI property){
Iterator<Triple> results = graph.filter(resource, property, null);
if(results.hasNext()){
while (results.hasNext()){
@@ -608,10 +606,10 @@ public final class EnhancementEngineHelp
* @param property the property
* @return the value
*/
- public static Iterator<String> getStrings(TripleCollection graph, NonLiteral resource, UriRef property){
+ public static Iterator<String> getStrings(Graph graph, BlankNodeOrIRI resource, IRI property){
final Iterator<Triple> results = graph.filter(resource, property, null);
return new Iterator<String>() {
- //TODO: dose not check if the object of the triple is of type UriRef
+ //TODO: dose not check if the object of the triple is of type IRI
@Override
public boolean hasNext() { return results.hasNext(); }
@Override
@@ -629,18 +627,18 @@ public final class EnhancementEngineHelp
* @param property the property
* @return the value
*/
- public static UriRef getReference(TripleCollection graph, NonLiteral resource, UriRef property){
+ public static IRI getReference(Graph graph, BlankNodeOrIRI resource, IRI property){
Iterator<Triple> results = graph.filter(resource, property, null);
if(results.hasNext()){
while(results.hasNext()){
Triple result = results.next();
- if(result.getObject() instanceof UriRef){
- return (UriRef)result.getObject();
+ if(result.getObject() instanceof IRI){
+ return (IRI)result.getObject();
} else {
- log.debug("Triple "+result+" does not have a UriRef as object! -> ignore");
+ log.debug("Triple "+result+" does not have a IRI as object! -> ignore");
}
}
- log.info("No UriRef value for {} and property {} -> return null",resource,property);
+ log.info("No IRI value for {} and property {} -> return null",resource,property);
return null;
} else {
log.debug("No Triple found for {} and property {}! -> return null",resource,property);
@@ -655,14 +653,14 @@ public final class EnhancementEngineHelp
* @param property the property
* @return The iterator over all the values (
*/
- public static Iterator<UriRef> getReferences(TripleCollection graph, NonLiteral resource, UriRef property){
+ public static Iterator<IRI> getReferences(Graph graph, BlankNodeOrIRI resource, IRI property){
final Iterator<Triple> results = graph.filter(resource, property, null);
- return new Iterator<UriRef>() {
- //TODO: dose not check if the object of the triple is of type UriRef
+ return new Iterator<IRI>() {
+ //TODO: dose not check if the object of the triple is of type IRI
@Override
public boolean hasNext() { return results.hasNext(); }
@Override
- public UriRef next() { return (UriRef)results.next().getObject(); }
+ public IRI next() { return (IRI)results.next().getObject(); }
@Override
public void remove() { results.remove(); }
};
@@ -717,16 +715,16 @@ public final class EnhancementEngineHelp
* @return the sorted list of language annotations or an empty list if none.
* @throws IllegalArgumentException if <code>null</code> is parsed as graph
*/
- public static List<NonLiteral> getLanguageAnnotations(TripleCollection graph){
+ public static List<BlankNodeOrIRI> getLanguageAnnotations(Graph graph){
if(graph == null){
throw new IllegalArgumentException("The parsed graph MUST NOT be NULL!");
}
// I do not use SPARQL, because I do not want to instantiate a QueryEngine
- final Map<NonLiteral,Double> confidences = new HashMap<NonLiteral,Double>();
- List<NonLiteral> langAnnotations = new ArrayList<NonLiteral>();
+ final Map<BlankNodeOrIRI,Double> confidences = new HashMap<BlankNodeOrIRI,Double>();
+ List<BlankNodeOrIRI> langAnnotations = new ArrayList<BlankNodeOrIRI>();
Iterator<Triple> textAnnoataions = graph.filter(null, RDF_TYPE, ENHANCER_TEXTANNOTATION);
while(textAnnoataions.hasNext()){
- NonLiteral textAnnotation = textAnnoataions.next().getSubject();
+ BlankNodeOrIRI textAnnotation = textAnnoataions.next().getSubject();
String language = getString(graph, textAnnotation, DC_LANGUAGE);
if(language != null){
Double confidence = null;
@@ -748,9 +746,9 @@ public final class EnhancementEngineHelp
}
}
if(langAnnotations.size() > 1){
- Collections.sort(langAnnotations,new Comparator<NonLiteral>() {
+ Collections.sort(langAnnotations,new Comparator<BlankNodeOrIRI>() {
@Override
- public int compare(NonLiteral o1, NonLiteral o2) {
+ public int compare(BlankNodeOrIRI o1, BlankNodeOrIRI o2) {
Double c1 = confidences.get(o1);
Double c2 = confidences.get(o2);
//decrising order (values without confidence last)
@@ -772,13 +770,13 @@ public final class EnhancementEngineHelp
* 'fise:confidence' value - or if no annotations are present - the
* 'dc-terms:language' value of the {@link ContentItem#getUri()}.<p>
* Users that want to obtain all language annotations should use
- * {@link #getLanguageAnnotations(TripleCollection)} instead.<p>
+ * {@link #getLanguageAnnotations(Graph)} instead.<p>
* This method ensures a write lock on the {@link ContentItem}.
* @param ci the contentItem
* @return the identified language of the parsed {@link ContentItem}.
* <code>null</code> if not available.
* @throws IllegalArgumentException if <code>null</code> is parsed as content item
- * @see #getLanguageAnnotations(TripleCollection)
+ * @see #getLanguageAnnotations(Graph)
*/
public static String getLanguage(ContentItem ci){
if(ci == null){
@@ -786,7 +784,7 @@ public final class EnhancementEngineHelp
}
ci.getLock().readLock().lock();
try {
- List<NonLiteral> langAnnotations = getLanguageAnnotations(ci.getMetadata());
+ List<BlankNodeOrIRI> langAnnotations = getLanguageAnnotations(ci.getMetadata());
if(langAnnotations.isEmpty()){ //fallback
return getString(ci.getMetadata(), ci.getUri(), DC_LANGUAGE);
} else {
@@ -921,10 +919,10 @@ public final class EnhancementEngineHelp
Map<String,Object> engineExProps = new HashMap<String,Object>();
ci.getLock().readLock().lock();
try{
- MGraph em = ExecutionMetadataHelper.getExecutionMetadata(ci);
+ Graph em = ExecutionMetadataHelper.getExecutionMetadata(ci);
//(1.a) retrieve EnhancementProperties from the ep:ExecutionPlan
log.debug("> extract EnhancementProperties form the ExecutionPlan");
- NonLiteral executionPlanNode = ExecutionMetadataHelper.getExecutionPlanNode(em,
+ BlankNodeOrIRI executionPlanNode = ExecutionMetadataHelper.getExecutionPlanNode(em,
ExecutionMetadataHelper.getChainExecution(em, ci.getUri()));
extractEnhancementProperties(chainExProps, em, executionPlanNode, "Chain Execution");
//(1.b) retrieve Enhancement Properties from the ep:ExectutionNode
@@ -935,7 +933,7 @@ public final class EnhancementEngineHelp
//NOTE: we expect only a single execution node for an engine, but if
// there are multiple we will merge the properties of those
while(engineExecutions.hasNext()){
- NonLiteral engineExecution = engineExecutions.next().getSubject();
+ BlankNodeOrIRI engineExecution = engineExecutions.next().getSubject();
if(em.contains(new TripleImpl(executionPlanNode, ExecutionPlan.HAS_EXECUTION_NODE, engineExecution))){
extractEnhancementProperties(engineExProps,em, engineExecution, "Engine Execution");
} //else engine execution of a different execution plan
@@ -959,8 +957,8 @@ public final class EnhancementEngineHelp
* @param node the node to extract the properties from
* @param level the name of the level (only used for logging)
*/
- private static void extractEnhancementProperties(Map<String,Object> properties, TripleCollection graph,
- NonLiteral node, String level) {
+ private static void extractEnhancementProperties(Map<String,Object> properties, Graph graph,
+ BlankNodeOrIRI node, String level) {
log.debug(" - extract {} properties from {}", level, node);
Iterator<Triple> props = graph.filter(node, null, null);
while(props.hasNext()){
@@ -968,7 +966,7 @@ public final class EnhancementEngineHelp
String propUri = t.getPredicate().getUnicodeString();
if(propUri.startsWith(EHPROP_NS)){
String prop = propUri.substring(EHPROP_NS_LENGTH);
- Resource resource = t.getObject();
+ RDFTerm resource = t.getObject();
Object value = extractEnhancementPropertyValue(resource);
if(value != null && !prop.isEmpty()){
Object current = properties.get(prop);
@@ -997,17 +995,17 @@ public final class EnhancementEngineHelp
}
/**
- * Extracts the EnhancementProperty value from the parsed Resource.<p>
- * Currently this will return {@link UriRef#getUnicodeString()} or
- * {@link Literal#getLexicalForm()}. For {@link BNode}s <code>null</code>
+ * Extracts the EnhancementProperty value from the parsed RDFTerm.<p>
+ * Currently this will return {@link IRI#getUnicodeString()} or
+ * {@link Literal#getLexicalForm()}. For {@link BlankNode}s <code>null</code>
* is returned.
* @param r the resource to parse the value form
* @return the parsed value
*/
- private static Object extractEnhancementPropertyValue(Resource r) {
+ private static Object extractEnhancementPropertyValue(RDFTerm r) {
Object value;
- if(r instanceof UriRef){
- value = ((UriRef)r).getUnicodeString();
+ if(r instanceof IRI){
+ value = ((IRI)r).getUnicodeString();
} else if(r instanceof Literal){
value = ((Literal) r).getLexicalForm();
} else {
Modified: stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/ExecutionMetadataHelper.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/ExecutionMetadataHelper.java?rev=1744328&r1=1744327&r2=1744328&view=diff
==============================================================================
--- stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/ExecutionMetadataHelper.java (original)
+++ stanbol/trunk/enhancer/generic/servicesapi/src/main/java/org/apache/stanbol/enhancer/servicesapi/helper/ExecutionMetadataHelper.java Tue May 17 22:20:49 2016
@@ -48,18 +48,17 @@ 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.Literal;
+import org.apache.clerezza.commons.rdf.BlankNode;
+import org.apache.clerezza.commons.rdf.Literal;
+import org.apache.clerezza.commons.rdf.BlankNodeOrIRI;
+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.clerezza.commons.rdf.impl.utils.PlainLiteralImpl;
+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.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.impl.PlainLiteralImpl;
-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.enhancer.servicesapi.Chain;
import org.apache.stanbol.enhancer.servicesapi.ContentItem;
import org.apache.stanbol.enhancer.servicesapi.EnhancementJobManager;
@@ -82,9 +81,9 @@ public final class ExecutionMetadataHelp
private static final LiteralFactory lf = LiteralFactory.getInstance();
- public static NonLiteral createChainExecutionNode(MGraph graph, NonLiteral executionPlan,
- UriRef ciUri, boolean defaultChain){
- NonLiteral node = new BNode();
+ public static BlankNodeOrIRI createChainExecutionNode(Graph graph, BlankNodeOrIRI executionPlan,
+ IRI ciUri, boolean defaultChain){
+ BlankNodeOrIRI node = new BlankNode();
graph.add(new TripleImpl(node, RDF_TYPE, EXECUTION));
graph.add(new TripleImpl(node, RDF_TYPE, CHAIN_EXECUTION));
graph.add(new TripleImpl(node, ENHANCES, ciUri));
@@ -96,10 +95,10 @@ public final class ExecutionMetadataHelp
return node;
}
- public static NonLiteral createEngineExecution(MGraph graph, NonLiteral chainExecution,
- NonLiteral executionNode){
+ public static BlankNodeOrIRI createEngineExecution(Graph graph, BlankNodeOrIRI chainExecution,
+ BlankNodeOrIRI executionNode){
- NonLiteral node = new BNode();
+ BlankNodeOrIRI node = new BlankNode();
graph.add(new TripleImpl(node, RDF_TYPE, EXECUTION));
graph.add(new TripleImpl(node, RDF_TYPE, ENGINE_EXECUTION));
graph.add(new TripleImpl(node, EXECUTION_PART, chainExecution));
@@ -113,7 +112,7 @@ public final class ExecutionMetadataHelp
* @param execution
* @param message An optional message
*/
- public static void setExecutionCompleted(MGraph graph,NonLiteral execution,String message){
+ public static void setExecutionCompleted(Graph graph,BlankNodeOrIRI execution,String message){
Literal dateTime = lf.createTypedLiteral(new Date());
setStatus(graph, execution,STATUS_COMPLETED);
graph.add(new TripleImpl(execution, COMPLETED, dateTime));
@@ -127,7 +126,7 @@ public final class ExecutionMetadataHelp
* @param graph the graph holding the execution metadata
* @param execution the execution node
*/
- public static void setExecutionScheduled(MGraph graph,NonLiteral execution){
+ public static void setExecutionScheduled(Graph graph,BlankNodeOrIRI execution){
setStatus(graph, execution,STATUS_SCHEDULED);
Iterator<Triple> it = graph.filter(execution, STARTED, null);
while(it.hasNext()){
@@ -146,7 +145,7 @@ public final class ExecutionMetadataHelp
* @param execution
* @param message An message describing why the execution failed
*/
- public static void setExecutionFaild(MGraph graph,NonLiteral execution,String message){
+ public static void setExecutionFaild(Graph graph,BlankNodeOrIRI execution,String message){
Literal dateTime = lf.createTypedLiteral(new Date());
setStatus(graph, execution,STATUS_FAILED);
graph.add(new TripleImpl(execution, COMPLETED, dateTime));
@@ -163,7 +162,7 @@ public final class ExecutionMetadataHelp
* @param execution
* @param message An optional message why this execution was skipped
*/
- public static void setExecutionSkipped(MGraph graph,NonLiteral execution,String message){
+ public static void setExecutionSkipped(Graph graph,BlankNodeOrIRI execution,String message){
Literal dateTime = lf.createTypedLiteral(new Date());
setStatus(graph, execution,STATUS_SKIPPED);
graph.add(new TripleImpl(execution, STARTED, dateTime));
@@ -178,7 +177,7 @@ public final class ExecutionMetadataHelp
* @param graph
* @param execution
*/
- public static void setExecutionInProgress(MGraph graph,NonLiteral execution){
+ public static void setExecutionInProgress(Graph graph,BlankNodeOrIRI execution){
Literal dateTime = lf.createTypedLiteral(new Date());
setStatus(graph, execution,STATUS_IN_PROGRESS);
graph.add(new TripleImpl(execution, STARTED, dateTime));
@@ -190,7 +189,7 @@ public final class ExecutionMetadataHelp
* @param graph
* @param execution
*/
- private static void setStatus(MGraph graph, NonLiteral execution, UriRef status) {
+ private static void setStatus(Graph graph, BlankNodeOrIRI execution, IRI status) {
Iterator<Triple> it = graph.filter(execution, STATUS, null);
while(it.hasNext()){
it.next();
@@ -212,8 +211,8 @@ public final class ExecutionMetadataHelp
* @param chainName the name of the executed chain
* @return the node or <code>null</code> if not found.
*/
- public static final NonLiteral getChainExecutionForChainName(TripleCollection em, TripleCollection ep, String chainName){
- final NonLiteral executionPlanNode = ExecutionPlanHelper.getExecutionPlan(ep, chainName);
+ public static final BlankNodeOrIRI getChainExecutionForChainName(Graph em, Graph ep, String chainName){
+ final BlankNodeOrIRI executionPlanNode = ExecutionPlanHelper.getExecutionPlan(ep, chainName);
if(executionPlanNode == null){
return null;
} else {
@@ -229,7 +228,7 @@ public final class ExecutionMetadataHelp
* @param executionPlanNode the {@link ExecutionPlan#EXECUTION_PLAN} node
* @return the {@link ExecutionMetadata#CHAIN_EXECUTION} node
*/
- public static NonLiteral getChainExecutionForExecutionPlan(TripleCollection graph, final NonLiteral executionPlanNode) {
+ public static BlankNodeOrIRI getChainExecutionForExecutionPlan(Graph graph, final BlankNodeOrIRI executionPlanNode) {
if(graph == null){
throw new IllegalArgumentException("The parsed graph with the execution metadata MUST NOT be NULL!");
}
@@ -251,13 +250,13 @@ public final class ExecutionMetadataHelp
* content part
* @since 0.12.1
*/
- public static MGraph getExecutionMetadata(ContentItem contentItem) {
+ public static Graph getExecutionMetadata(ContentItem contentItem) {
if(contentItem == null) {
throw new IllegalArgumentException("The parsed ContentItme MUST NOT be NULL!");
}
contentItem.getLock().readLock().lock();
try{
- return contentItem.getPart(CHAIN_EXECUTION, MGraph.class);
+ return contentItem.getPart(CHAIN_EXECUTION, Graph.class);
}finally{
contentItem.getLock().readLock().unlock();
}
@@ -271,32 +270,32 @@ public final class ExecutionMetadataHelp
* content item otherwise it returns the existing part registered under that
* URI.<p>
* Typically users will also want to use
- * {@link #initExecutionMetadata(MGraph, TripleCollection, UriRef, String, boolean)}
+ * {@link #initExecutionMetadata(Graph, Graph, IRI, String, boolean)}
* to initialise the state based on the grpah returned by this method.
* NOTES:<ul>
* <li> If a content part is registered under the URI
* {@link ExecutionMetadata#CHAIN_EXECUTION} that is not of type
- * {@link MGraph} this method will replace it with an empty {@link MGraph}.
+ * {@link Graph} this method will replace it with an empty {@link Graph}.
* <li> This method acquires a write lock on the content item while checking
* for the content part.
* </ul>
* @param contentItem the contentItem
- * @return the {@link MGraph} with the execution metadata as registered as
+ * @return the {@link Graph} with the execution metadata as registered as
* content part with the URI {@link ExecutionMetadata#CHAIN_EXECUTION} to
* the {@link ContentItem}
* @throws IllegalArgumentException if the parsed content itme is <code>null</code>.
*/
- public static MGraph initExecutionMetadataContentPart(ContentItem contentItem) {
+ public static Graph initExecutionMetadataContentPart(ContentItem contentItem) {
if(contentItem == null){
throw new IllegalArgumentException("The parsed ContentItme MUST NOT be NULL!");
}
- MGraph executionMetadata;
+ Graph executionMetadata;
contentItem.getLock().writeLock().lock();
try {
try {
- executionMetadata = contentItem.getPart(CHAIN_EXECUTION, MGraph.class);
+ executionMetadata = contentItem.getPart(CHAIN_EXECUTION, Graph.class);
} catch (NoSuchPartException e) {
- executionMetadata = new IndexedMGraph();
+ executionMetadata = new IndexedGraph();
contentItem.addPart(CHAIN_EXECUTION, executionMetadata);
}
} finally {
@@ -334,7 +333,7 @@ public final class ExecutionMetadataHelp
* @throws IllegalArgumentException if any of the requirements stated in the
* documentation for the parameters is not fulfilled.
*/
- public static final Map<NonLiteral,NonLiteral> initExecutionMetadata(MGraph em, TripleCollection ep, UriRef ciUri, String chainName, Boolean isDefaultChain){
+ public static final Map<BlankNodeOrIRI,BlankNodeOrIRI> initExecutionMetadata(Graph em, Graph ep, IRI ciUri, String chainName, Boolean isDefaultChain){
if(em == null){
throw new IllegalArgumentException("The parsed ExecutionMetadata graph MUST NOT be NULL!");
}
@@ -342,8 +341,8 @@ public final class ExecutionMetadataHelp
throw new IllegalArgumentException("The parsed URI of the contentItem MUST NOT be NULL!");
}
//1. check for the ChainExecution node for the parsed content item
- final NonLiteral executionPlanNode;
- NonLiteral chainExecutionNode = getChainExecutionForExecutionPlan(em, ciUri);
+ final BlankNodeOrIRI executionPlanNode;
+ BlankNodeOrIRI chainExecutionNode = getChainExecutionForExecutionPlan(em, ciUri);
if(chainExecutionNode != null){ //init from existing executin metadata
// -> chainName and isDefaultChain may be null
//init from existing
@@ -386,12 +385,12 @@ public final class ExecutionMetadataHelp
chainExecutionNode = createChainExecutionNode(em, executionPlanNode, ciUri, isDefaultChain);
}
//2. check/init the EngineExecution nodes for for the ExecutionNodes of the ExecutionPlan
- Map<NonLiteral,NonLiteral> executionsMap = new HashMap<NonLiteral,NonLiteral>();
- Set<NonLiteral> executionNodes = getExecutionNodes(ep, executionPlanNode);
- Set<NonLiteral> executions = getExecutions(em, chainExecutionNode);
- for(NonLiteral en : executionNodes) {
+ Map<BlankNodeOrIRI,BlankNodeOrIRI> executionsMap = new HashMap<BlankNodeOrIRI,BlankNodeOrIRI>();
+ Set<BlankNodeOrIRI> executionNodes = getExecutionNodes(ep, executionPlanNode);
+ Set<BlankNodeOrIRI> executions = getExecutions(em, chainExecutionNode);
+ for(BlankNodeOrIRI en : executionNodes) {
Iterator<Triple> it = em.filter(null, EXECUTION_NODE, en);
- NonLiteral execution;
+ BlankNodeOrIRI execution;
if(it.hasNext()){
execution = it.next().getSubject();
if(!executions.contains(execution)){
@@ -408,9 +407,9 @@ public final class ExecutionMetadataHelp
}
//3. check that there are no executions that are not part of the
// parsed ExecutionPlan
- for(NonLiteral e : executions){
+ for(BlankNodeOrIRI e : executions){
if(!executionsMap.containsKey(e)){
- NonLiteral en = getExecutionNode(em, e);
+ BlankNodeOrIRI en = getExecutionNode(em, e);
throw new IllegalStateException("ChainExecution '"
+ chainExecutionNode +"' (chain: '"+chainName+") contains"
+ "Execution '"+e+"' for ExecutionNode '" + en
@@ -427,16 +426,16 @@ public final class ExecutionMetadataHelp
* @param execution the em:Execution node
* @return the ep:ExecutionNode node
*/
- public static NonLiteral getExecutionNode(TripleCollection graph, NonLiteral execution){
+ public static BlankNodeOrIRI getExecutionNode(Graph graph, BlankNodeOrIRI execution){
Iterator<Triple> it = graph.filter(execution, EXECUTION_NODE, null);
if(it.hasNext()){
Triple t = it.next();
- Resource o = t.getObject();
- if(o instanceof NonLiteral){
- return (NonLiteral)o;
+ RDFTerm o = t.getObject();
+ if(o instanceof BlankNodeOrIRI){
+ return (BlankNodeOrIRI)o;
} else {
throw new IllegalStateException("Value of property "+ EXECUTION_NODE
- + "MUST BE of type NonLiteral (triple: '"+t+"')!");
+ + "MUST BE of type BlankNodeOrIRI (triple: '"+t+"')!");
}
} else {
//maybe an em:ChainExecution
@@ -452,14 +451,14 @@ public final class ExecutionMetadataHelp
* @param chainExecutionNode the chain execution node
* @return the Set with all execution part of the chain execution
*/
- public static Set<NonLiteral> getExecutions(TripleCollection em, NonLiteral chainExecutionNode) {
+ public static Set<BlankNodeOrIRI> getExecutions(Graph em, BlankNodeOrIRI chainExecutionNode) {
if(em == null){
throw new IllegalArgumentException("The parsed graph with the Execution metadata MUST NOT be NULL!");
}
if(chainExecutionNode == null){
throw new IllegalArgumentException("The parsed chain execution plan node MUST NOT be NULL!");
}
- Set<NonLiteral> executionNodes = new HashSet<NonLiteral>();
+ Set<BlankNodeOrIRI> executionNodes = new HashSet<BlankNodeOrIRI>();
Iterator<Triple> it = em.filter(null, ExecutionMetadata.EXECUTION_PART, chainExecutionNode);
while(it.hasNext()){
executionNodes.add(it.next().getSubject());
@@ -473,16 +472,16 @@ public final class ExecutionMetadataHelp
* @param chainExecutionNode the chain execution node
* @return the execution plan node
*/
- public static NonLiteral getExecutionPlanNode(TripleCollection em, NonLiteral chainExecutionNode){
+ public static BlankNodeOrIRI getExecutionPlanNode(Graph em, BlankNodeOrIRI chainExecutionNode){
Iterator<Triple> it = em.filter(chainExecutionNode, EXECUTION_PLAN, null);
if(it.hasNext()){
Triple t = it.next();
- Resource r = t.getObject();
- if(r instanceof NonLiteral){
- return (NonLiteral)r;
+ RDFTerm r = t.getObject();
+ if(r instanceof BlankNodeOrIRI){
+ return (BlankNodeOrIRI)r;
} else {
throw new IllegalStateException("Value of the property "+EXECUTION_PLAN
- + " MUST BE a NonLiteral (triple: '"+t+"')!");
+ + " MUST BE a BlankNodeOrIRI (triple: '"+t+"')!");
}
} else {
return null;
@@ -495,7 +494,7 @@ public final class ExecutionMetadataHelp
* @param ciUri the ID of the content item
* @return the node that {@link ExecutionMetadata#ENHANCES} the {@link ContentItem}
*/
- public static NonLiteral getChainExecution(TripleCollection em, UriRef ciUri){
+ public static BlankNodeOrIRI getChainExecution(Graph em, IRI ciUri){
Iterator<Triple> it = em.filter(null, ENHANCES, ciUri);
if(it.hasNext()){
return it.next().getSubject();
@@ -511,7 +510,7 @@ public final class ExecutionMetadataHelp
* @param execution the execution node
* @return <code>true</code> if the status is faild. Otherwise <code>false</code>.
*/
- public static boolean isExecutionFailed(TripleCollection graph, NonLiteral execution){
+ public static boolean isExecutionFailed(Graph graph, BlankNodeOrIRI execution){
return STATUS_FAILED.equals(getReference(graph,execution,STATUS));
}
/**
@@ -523,8 +522,8 @@ public final class ExecutionMetadataHelp
* @param execution the execution node
* @return <code>true</code> if the execution has already finished
*/
- public static boolean isExecutionFinished(TripleCollection graph, NonLiteral execution){
- UriRef status = getReference(graph,execution,STATUS);
+ public static boolean isExecutionFinished(Graph graph, BlankNodeOrIRI execution){
+ IRI status = getReference(graph,execution,STATUS);
return STATUS_FAILED.equals(status) || STATUS_COMPLETED.equals(status);
}
/**
@@ -533,7 +532,7 @@ public final class ExecutionMetadataHelp
* @param execution the execution instance
* @return the time or <code>null</code> if not present
*/
- public static Date getStarted(TripleCollection graph, NonLiteral execution){
+ public static Date getStarted(Graph graph, BlankNodeOrIRI execution){
return get(graph, execution, ExecutionMetadata.STARTED, Date.class, lf);
}
/**
@@ -542,7 +541,7 @@ public final class ExecutionMetadataHelp
* @param execution the execution instance
* @return the time or <code>null</code> if not present
*/
- public static Date getCompleted(TripleCollection graph, NonLiteral execution){
+ public static Date getCompleted(Graph graph, BlankNodeOrIRI execution){
return get(graph, execution, ExecutionMetadata.COMPLETED, Date.class, lf);
}
}