You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2012/03/30 11:19:35 UTC

svn commit: r1307328 - in /incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi: index/ store/

Author: rwesten
Date: Fri Mar 30 09:19:34 2012
New Revision: 1307328

URL: http://svn.apache.org/viewvc?rev=1307328&view=rev
Log:
Adaption to the Store interface; Added Javadoc; Uris for the Enums

Added:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/ChangeSet.java
      - copied, changed from r1307297, incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Changes.java
Removed:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Changes.java
Modified:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/EndpointType.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/IndexState.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndex.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/EndpointType.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/EndpointType.java?rev=1307328&r1=1307327&r2=1307328&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/EndpointType.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/EndpointType.java Fri Mar 30 09:19:34 2012
@@ -2,4 +2,17 @@ package org.apache.stanbol.contenthub.se
 
 public enum EndpointType {
     SOLR
+    ;
+    
+    private static final String prefix = "http://stanbol.apache.org/ontology/contenthub#endpointType_";
+    
+    public String getUri() {
+    	return prefix+name().toLowerCase();
+	}
+
+    @Override
+    public String toString() {
+    	return getUri();
+    }
+
 }

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/IndexState.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/IndexState.java?rev=1307328&r1=1307327&r2=1307328&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/IndexState.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/IndexState.java Fri Mar 30 09:19:34 2012
@@ -4,5 +4,15 @@ public enum IndexState {
     UNINIT,
     INDEXING,
     ACTIVE,
-    REINDEXING
+    REINDEXING;
+    
+    private static final String prefix = "http://stanbol.apache.org/ontology/contenthub#indexState_";
+    
+    public String getUri() {
+    	return prefix+name().toLowerCase();
+	}
+    @Override
+    public String toString() {
+    	return getUri();
+    }
 }

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndex.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndex.java?rev=1307328&r1=1307327&r2=1307328&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndex.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/index/SemanticIndex.java Fri Mar 30 09:19:34 2012
@@ -26,6 +26,5 @@ public interface SemanticIndex {
     
     Map<String, String> getRESTSearchEndpoints();
 
-    @SuppressWarnings("rawtypes")
-    Map<Class, ServiceReference> getSearchEndPoints();
+    Map<Class<?>, ServiceReference> getSearchEndPoints();
 }

Copied: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/ChangeSet.java (from r1307297, incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Changes.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/ChangeSet.java?p2=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/ChangeSet.java&p1=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Changes.java&r1=1307297&r2=1307328&rev=1307328&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Changes.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/ChangeSet.java Fri Mar 30 09:19:34 2012
@@ -4,11 +4,49 @@ import java.util.Set;
 
 import org.apache.clerezza.rdf.core.UriRef;
 
-public interface Changes {
-    long from();
-    
-    long to();
+/**
+ * This represents a set of {@link #size()} changes starting
+ * {@link #fromRevision()} {@link #toRevision()} affecting
+ * ContentItems with the {@link UriRef}s returned by
+ * {@link #changed()};
+ * <p>
+ * The intended usage of this class is
+ * <code><pre>
+ *     Store store; //the store
+ *     long revision = Long.MIN_VALUE; //start for scatch
+ *     int batchSize = 1000;
+ *     ChangeSet cs;
+ *     do {
+ *         cs = store.changes(revision);
+ *         for(UriRef changed : cs.changed()){
+ *             ContentItem ci = store.get(changed);
+ *             //precess
+ *         } 
+ *     while(!cs.changed().isEmpty()){
+ * </pre></code>
+ */
+public interface ChangeSet {
+	/**
+	 * The lowest revision number included in this ChangeSet
+	 * @return the lowest revision number of this set
+	 */
+    long fromRevision();
+    /**
+     * The highest revision number included in this ChangeSet
+     * @return the highest revision number of this set
+     */
+    long toRevision();
     
+    /**
+     * The read only {@link Set} of changes ContentItems included
+     * in this ChangeSet.
+     * @return the {@link UriRef}s of the changed contentItems
+     * included in this ChangeSet
+     */
     Set<UriRef>changed();
-    
+    /**
+     * The reference to the {@link Store} of this {@link ChangeSet}.
+     * This can be used to get the next ChangeSet by calling
+     * @return
+     */
 }

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java?rev=1307328&r1=1307327&r2=1307328&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java Fri Mar 30 09:19:34 2012
@@ -18,6 +18,7 @@ package org.apache.stanbol.contenthub.se
 
 import java.io.InputStream;
 
+import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
 
@@ -28,29 +29,29 @@ import org.apache.stanbol.enhancer.servi
  */
 public interface Store {
 
-    /**
-     * Creates a {@link ContentItem} item based on supplied data, using an implementation that suits this
-     * store.
-     * <p>
-     * Calling this method creates an empty data transfer object in memory suitable for later saving using the
-     * {@link Store#put(ContentItem)} method. The Store state is unchanged by the call to the
-     * {@link #create(String, byte[], String)} method.
-     * 
-     * @param id
-     *            The value to use {@link ContentItem#getId}. If <code>null</code> is parsed as id, an id need
-     *            to be computed based on the parsed content ( e.g. calculating the stream digest (see also
-     *            {@link ContentItemHelper#streamDigest(java.io.InputStream, java.io.OutputStream, String)})
-     * @param content
-     *            the binary content
-     * @param contentType
-     *            The Mime-Type of the binary data
-     * @return the {@link ContentItem} that was created
-     */
-    ContentItem create(String id, byte[] content, String contentType) throws StoreException;
-
-    ContentItem create(String id, InputStream is, String contentType) throws StoreException;
+//    /**
+//     * Creates a {@link ContentItem} item based on supplied data, using an implementation that suits this
+//     * store.
+//     * <p>
+//     * Calling this method creates an empty data transfer object in memory suitable for later saving using the
+//     * {@link Store#put(ContentItem)} method. The Store state is unchanged by the call to the
+//     * {@link #create(String, byte[], String)} method.
+//     * 
+//     * @param id
+//     *            The value to use {@link ContentItem#getId}. If <code>null</code> is parsed as id, an id need
+//     *            to be computed based on the parsed content ( e.g. calculating the stream digest (see also
+//     *            {@link ContentItemHelper#streamDigest(java.io.InputStream, java.io.OutputStream, String)})
+//     * @param content
+//     *            the binary content
+//     * @param contentType
+//     *            The Mime-Type of the binary data
+//     * @return the {@link ContentItem} that was created
+//     */
+//    ContentItem create(String id, byte[] content, String contentType) throws StoreException;
+//
+//    ContentItem create(String id, InputStream is, String contentType) throws StoreException;
 
-    ContentItem remove(String id) throws StoreException;
+    ContentItem remove(UriRef id) throws StoreException;
 
     /**
      * Store supplied {@link ContentItem} and return its id, which is assigned by the store if not defined
@@ -58,10 +59,17 @@ public interface Store {
      * 
      * If the {@link ContentItem} already exists, it is overwritten.
      */
-    String put(ContentItem ci) throws StoreException;
+    UriRef put(ContentItem ci) throws StoreException;
 
     /** Get a {@link ContentItem} by id, null if non-existing */
-    ContentItem get(String id) throws StoreException;
-
-    Changes changes(long revision) throws StoreException;
+    ContentItem get(UriRef id) throws StoreException;
+    /**
+     * Requests the next <code>batchSize</code> changes starting from
+     * <code>revision</code>. If there are no more revisions that an
+     * {@link ChangeSet} with an empty {@link ChangeSet#changed()} set.
+     * @param revision the starting revision number for the returned {@link ChangeSet}
+     * @return the {@link ChangeSet} with a maximum of <code>batchSize</code> changes
+     * @throws StoreException on any error while accessing the store.
+     */
+    ChangeSet changes(long revision, int batchSize) throws StoreException;
 }