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/07/25 17:42:43 UTC

svn commit: r1365637 - in /incubator/stanbol/branches/contenthub-two-layered-structure: commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/ contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/st...

Author: rwesten
Date: Wed Jul 25 15:42:42 2012
New Revision: 1365637

URL: http://svn.apache.org/viewvc?rev=1365637&view=rev
Log:
STANBOL-498: Added bulk operations for put(..) and remove(..) as well as a removeAll() method to the Store interface. Added also basic implementations to the FileStore that internally call put/remove for all parsed itmes.

TODO: removeAll() is NOT implemented! 

Modified:
    incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/Store.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/Store.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/Store.java?rev=1365637&r1=1365636&r2=1365637&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/Store.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/commons/semanticindex/servicesapi/src/main/java/org/apache/stanbol/commons/semanticindex/store/Store.java Wed Jul 25 15:42:42 2012
@@ -19,7 +19,7 @@ package org.apache.stanbol.commons.seman
 /**
  * Interface to store and retrieve Items instances persistently.
  * This extends the {@link IndexingSource} interface to support
- * full CRUD operations
+ * full CRUD operations.
  */
 public interface Store<Item> extends IndexingSource<Item>{
 
@@ -34,13 +34,37 @@ public interface Store<Item> extends Ind
 
     /**
      * Stores supplied item and return its uri, which is assigned by the store if not defined
-     * yet.
+     * yet.<p>
      * 
-     * If the {@link ContentItem} already exists, it is overwritten.
+     * If an Item already exists it is replaced with the parsed version.
      * @param item the item to store
      * @param the URI of the stored item
      * @throws StoreException on any error while storing the item
      */
     String put(Item item) throws StoreException;
 
+    /**
+     * Stores all supplied items and returns it uris, which is assigned by the store if not defined
+     * yet.<p>
+     * If an Item already exists it is replaced with the parsed version.
+     * @param item
+     * @return the ids of the stored Items
+     * @throws StoreException on any error while storing the item
+     */
+    Iterable<String> put(Iterable<Item> items) throws StoreException ;
+    /**
+     * Removes all items with the parsed uris. <p>
+     * <i>NOTE:</i> This method does NOT return the removed Items to
+     * avoid loading a lot of data when deleting a big about of
+     * Items. Users that do need the data for removed Items should use
+     * {@link #remove(String)} instead.
+     * @param uris the uris of the items to delete
+     * @throws StoreException on any error while removing the items
+     */
+    void remove(Iterable<String> uris) throws StoreException ;
+    /**
+     * Clears the store by removing all items
+     * @throws StoreException on any error while removing all items
+     */
+    void removeAll() throws StoreException ;
 }

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java?rev=1365637&r1=1365636&r2=1365637&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java Wed Jul 25 15:42:42 2012
@@ -191,6 +191,18 @@ public class FileStore implements Store<
     }
 
     @Override
+    public void remove(Iterable<String> uris)
+    		throws StoreException {
+    	List<ContentItem> removed = new ArrayList<ContentItem>();
+    	for(String uri : uris){
+    		ContentItem ci = remove(uri);
+    		if(ci != null){
+    			removed.add(ci);
+    		}
+    	}
+    }
+    
+    @Override
     public ContentItem remove(String id) throws StoreException {
         checkStoreFolder();
         String urlEncodedId = encodeId(id);
@@ -206,6 +218,12 @@ public class FileStore implements Store<
         return ci;
     }
 
+    @Override
+    public void removeAll() throws StoreException {
+    	//TODO: implement
+    	throw new UnsupportedOperationException("TODO: implement!!");
+    }
+    
     private void updateTablesForDelete(String id) throws StoreException {
         // update revision
         revisionManager.updateRevision(id);
@@ -236,6 +254,15 @@ public class FileStore implements Store<
     }
 
     @Override
+    public Iterable<String> put(Iterable<ContentItem> cis) throws StoreException {
+    	List<String> uris = new ArrayList<String>();
+    	for(ContentItem ci : cis){
+    		uris.add(put(ci));
+    	}
+    	return null;
+    }
+    
+    @Override
     public String put(ContentItem ci) throws StoreException {
         try {
             jobManager.enhanceContent(ci);