polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From soelvs...@apache.org
Subject [2/2] zest-java git commit: removed ModuleEntityStoreUnitOfWork, added EntityStoreSPI#versionOf
Date Wed, 26 Aug 2015 20:04:37 GMT
removed ModuleEntityStoreUnitOfWork, added EntityStoreSPI#versionOf


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/587c43d7
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/587c43d7
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/587c43d7

Branch: refs/heads/module_entitystore_uow
Commit: 587c43d7d4b8cadb4f87a1ac49a2fc0f6f7105ed
Parents: 698f392
Author: Kent Sølvsten <soelvsten@apache.org>
Authored: Wed Aug 26 22:01:56 2015 +0200
Committer: Kent Sølvsten <soelvsten@apache.org>
Committed: Wed Aug 26 22:01:56 2015 +0200

----------------------------------------------------------------------
 .../runtime/structure/ModuleUnitOfWork.java     |  4 +--
 .../runtime/unitofwork/UnitOfWorkInstance.java  |  6 ++--
 .../ConcurrentModificationCheckConcern.java     | 18 ++++++----
 .../DefaultEntityStoreUnitOfWork.java           |  7 ++++
 .../spi/entitystore/EntityStateVersions.java    |  9 ++---
 .../zest/spi/entitystore/EntityStore.java       |  2 +-
 .../zest/spi/entitystore/EntityStoreSPI.java    |  2 ++
 .../spi/entitystore/EntityStoreUnitOfWork.java  |  2 ++
 .../helpers/JSONMapEntityStoreMixin.java        | 38 ++++++++++++++------
 .../helpers/MapEntityStoreMixin.java            | 29 +++++++++++----
 .../prefs/PreferencesEntityStoreMixin.java      | 32 ++++++++++++-----
 .../entitystore/sql/SQLEntityStoreMixin.java    | 32 ++++++++++++-----
 .../elasticsearch/ElasticSearchIndexer.java     |  1 -
 .../rdf/entity/EntitySerializerTest.java        |  2 +-
 .../zest/library/rest/admin/EntityResource.java |  5 ++-
 15 files changed, 133 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
old mode 100644
new mode 100755
index f052de2..91e8e68
--- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/ModuleUnitOfWork.java
@@ -205,7 +205,7 @@ public class ModuleUnitOfWork
 
         builder = new EntityBuilderInstance<>( model,
                                                this,
-                                               uow.getEntityStoreUnitOfWork( entityStore,
module ),
+                                               uow.getEntityStoreUnitOfWork( entityStore
),
                                                identity );
         return builder;
     }
@@ -278,7 +278,7 @@ public class ModuleUnitOfWork
 
         return new EntityBuilderInstance<>( model,
                                             this,
-                                            uow.getEntityStoreUnitOfWork( entityStore, module
),
+                                            uow.getEntityStoreUnitOfWork( entityStore ),
                                             identity,
                                             stateResolver );
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
old mode 100644
new mode 100755
index 2136528..ff6a312
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
@@ -109,12 +109,12 @@ public final class UnitOfWorkInstance
         return currentTime;
     }
 
-    public EntityStoreUnitOfWork getEntityStoreUnitOfWork( EntityStore store, ModuleSpi module
)
+    public EntityStoreUnitOfWork getEntityStoreUnitOfWork( EntityStore store )
     {
         EntityStoreUnitOfWork uow = storeUnitOfWork.get( store );
         if( uow == null )
         {
-            uow = store.newUnitOfWork( usecase, module, currentTime );
+            uow = store.newUnitOfWork( usecase, currentTime );
             storeUnitOfWork.put( store, uow );
         }
         return uow;
@@ -141,7 +141,7 @@ public final class UnitOfWorkInstance
             for( ModelModule<EntityModel> potentialModel : potentialModels )
             {
                 EntityStore store = potentialModel.module().entityStore();
-                EntityStoreUnitOfWork storeUow = getEntityStoreUnitOfWork( store, potentialModel.module()
);
+                EntityStoreUnitOfWork storeUow = getEntityStoreUnitOfWork( store );
                 try
                 {
                     entityState = storeUow.entityStateOf( potentialModel.module(), identity
);

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
old mode 100644
new mode 100755
index a00145d..225a4bf
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
@@ -48,10 +48,10 @@ public abstract class ConcurrentModificationCheckConcern
     private ZestAPI api;
 
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, ModuleSpi module, long currentTime
)
+    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
     {
-        final EntityStoreUnitOfWork uow = next.newUnitOfWork( usecase, module, currentTime
);
-        return new ConcurrentCheckingEntityStoreUnitOfWork( uow, api.dereference( versions
), module, currentTime );
+        final EntityStoreUnitOfWork uow = next.newUnitOfWork( usecase, currentTime );
+        return new ConcurrentCheckingEntityStoreUnitOfWork( uow, api.dereference( versions
), currentTime );
     }
 
     private static class ConcurrentCheckingEntityStoreUnitOfWork
@@ -59,7 +59,6 @@ public abstract class ConcurrentModificationCheckConcern
     {
         private final EntityStoreUnitOfWork uow;
         private EntityStateVersions versions;
-        private ModuleSpi module;
         private long currentTime;
 
         private List<EntityState> loaded = new ArrayList<>();
@@ -68,13 +67,11 @@ public abstract class ConcurrentModificationCheckConcern
 
         public ConcurrentCheckingEntityStoreUnitOfWork( EntityStoreUnitOfWork uow,
                                                         EntityStateVersions versions,
-                                                        ModuleSpi module,
                                                         long currentTime
         )
         {
             this.uow = uow;
             this.versions = versions;
-            this.module = module;
             this.currentTime = currentTime;
         }
 
@@ -108,7 +105,7 @@ public abstract class ConcurrentModificationCheckConcern
 
             try
             {
-                versions.checkForConcurrentModification( loaded, module, currentTime );
+                versions.checkForConcurrentModification( loaded, currentTime );
 
                 final StateCommitter committer = uow.applyChanges();
 
@@ -187,5 +184,12 @@ public abstract class ConcurrentModificationCheckConcern
                 lock.readLock().unlock();
             }
         }
+
+        @Override
+        public String versionOf( EntityReference anIdentity )
+            throws EntityStoreException
+        {
+            return uow.versionOf( anIdentity );
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
b/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
old mode 100644
new mode 100755
index f0f9a2a..8aeb8ba
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
@@ -94,6 +94,13 @@ public final class DefaultEntityStoreUnitOfWork
     }
 
     @Override
+    public String versionOf( EntityReference anIdentity )
+        throws EntityStoreException
+    {
+        return entityStoreSPI.versionOf( this, anIdentity );
+    }
+
+    @Override
     public StateCommitter applyChanges()
         throws EntityStoreException
     {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
old mode 100644
new mode 100755
index 7f4b93c..57a7119
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
@@ -24,7 +24,6 @@ import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.usecase.Usecase;
 import org.apache.zest.spi.entity.EntityState;
 import org.apache.zest.spi.entity.EntityStatus;
-import org.apache.zest.spi.module.ModuleSpi;
 
 /**
  * Entity versions state.
@@ -36,7 +35,7 @@ public interface EntityStateVersions
 
     void rememberVersion( EntityReference identity, String version );
 
-    void checkForConcurrentModification( Iterable<EntityState> loaded, ModuleSpi module,
long currentTime )
+    void checkForConcurrentModification( Iterable<EntityState> loaded, long currentTime
)
         throws ConcurrentEntityStateModificationException;
 
     /**
@@ -67,7 +66,6 @@ public interface EntityStateVersions
 
         @Override
         public synchronized void checkForConcurrentModification( Iterable<EntityState>
loaded,
-                                                                 ModuleSpi module,
                                                                  long currentTime
         )
             throws ConcurrentEntityStateModificationException
@@ -83,9 +81,8 @@ public interface EntityStateVersions
                 String storeVersion = versions.get( entityState.identity() );
                 if( storeVersion == null )
                 {
-                    EntityStoreUnitOfWork unitOfWork = store.newUnitOfWork( Usecase.DEFAULT,
module, currentTime );
-                    EntityState state = unitOfWork.entityStateOf( module, entityState.identity()
);
-                    storeVersion = state.version();
+                    EntityStoreUnitOfWork unitOfWork = store.newUnitOfWork( Usecase.DEFAULT,
currentTime );
+                    storeVersion = unitOfWork.versionOf( entityState.identity() );
                     unitOfWork.discard();
                 }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
old mode 100644
new mode 100755
index 1d94c79..0a3d3e3
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
@@ -26,7 +26,7 @@ import org.apache.zest.spi.module.ModuleSpi;
  */
 public interface EntityStore
 {
-    EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, ModuleSpi module, long currentTime
);
+    EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, long currentTime );
 
     Input<EntityState, EntityStoreException> entityStates( ModuleSpi module );
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java
old mode 100644
new mode 100755
index aa7bfa1..f584f7a
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java
@@ -31,6 +31,8 @@ public interface EntityStoreSPI
 
     EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleSpi module, EntityReference
identity );
 
+    String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference identity );
+
     StateCommitter applyChanges( EntityStoreUnitOfWork unitOfWork, Iterable<EntityState>
state
     );
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
old mode 100644
new mode 100755
index a106906..ea1e01c
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
@@ -59,6 +59,8 @@ public interface EntityStoreUnitOfWork
     EntityState entityStateOf( ModuleSpi module, EntityReference anIdentity )
         throws EntityStoreException, EntityNotFoundException;
 
+    String versionOf( EntityReference anIdentity) throws EntityStoreException;
+
     StateCommitter applyChanges()
         throws EntityStoreException;
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
old mode 100644
new mode 100755
index 8c9bf68..73d32d5
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
@@ -28,9 +28,6 @@ import java.io.Writer;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
 import org.apache.zest.api.cache.CacheOptions;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.entity.EntityDescriptor;
@@ -60,13 +57,14 @@ import org.apache.zest.spi.entitystore.EntityStore;
 import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.EntityStoreSPI;
 import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
-import org.apache.zest.spi.entitystore.ModuleEntityStoreUnitOfWork;
 import org.apache.zest.spi.entitystore.StateCommitter;
 import org.apache.zest.spi.module.ModelModule;
 import org.apache.zest.spi.module.ModuleSpi;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
 
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.map;
+import static org.apache.zest.functional.Iterables.*;
 
 /**
  * Implementation of EntityStore that works with an implementation of MapEntityStore.
@@ -143,11 +141,9 @@ public class JSONMapEntityStoreMixin
     // EntityStore
 
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecaseMetaInfo, ModuleSpi module,
long currentTime )
+    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecaseMetaInfo, long currentTime
)
     {
-        EntityStoreUnitOfWork storeUnitOfWork = new DefaultEntityStoreUnitOfWork( entityStoreSpi,
newUnitOfWorkId(), usecaseMetaInfo, currentTime );
-        storeUnitOfWork = new ModuleEntityStoreUnitOfWork( module, storeUnitOfWork );
-        return storeUnitOfWork;
+        return new DefaultEntityStoreUnitOfWork( entityStoreSpi, newUnitOfWorkId(), usecaseMetaInfo,
currentTime );
     }
 
     // EntityStoreSPI
@@ -202,6 +198,13 @@ public class JSONMapEntityStoreMixin
     }
 
     @Override
+    public String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference identity )
+    {
+        Reader in = mapEntityStore.get( identity );
+        return readVersion( in );
+    }
+
+    @Override
     public StateCommitter applyChanges( final EntityStoreUnitOfWork unitOfWork,
                                         final Iterable<EntityState> state
     )
@@ -455,6 +458,21 @@ public class JSONMapEntityStoreMixin
         }
     }
 
+    protected String readVersion( Reader entityState )
+        throws EntityStoreException
+    {
+        try
+        {
+            JSONObject jsonObject = new JSONObject( new JSONTokener( entityState ) );
+            return jsonObject.getString( JSONKeys.VERSION );
+
+        }
+        catch( JSONException e )
+        {
+            throw new EntityStoreException( e );
+        }
+    }
+
     @Override
     public JSONObject jsonStateOf( String id )
         throws IOException

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
old mode 100644
new mode 100755
index b1ba7b2..77c2375
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
@@ -62,7 +62,6 @@ import org.apache.zest.spi.entitystore.EntityStore;
 import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.EntityStoreSPI;
 import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
-import org.apache.zest.spi.entitystore.ModuleEntityStoreUnitOfWork;
 import org.apache.zest.spi.entitystore.StateCommitter;
 import org.apache.zest.spi.module.ModelModule;
 import org.apache.zest.spi.module.ModuleSpi;
@@ -116,12 +115,9 @@ public class MapEntityStoreMixin
 
     // EntityStore
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecaseMetaInfo, ModuleSpi module,
long currentTime )
+    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecaseMetaInfo, long currentTime
)
     {
-        EntityStoreUnitOfWork storeUnitOfWork =
-            new DefaultEntityStoreUnitOfWork( entityStoreSpi, newUnitOfWorkId(), usecaseMetaInfo,
currentTime );
-        storeUnitOfWork = new ModuleEntityStoreUnitOfWork( module, storeUnitOfWork );
-        return storeUnitOfWork;
+        return new DefaultEntityStoreUnitOfWork( entityStoreSpi, newUnitOfWorkId(), usecaseMetaInfo,
currentTime );
     }
 
     // EntityStoreSPI
@@ -146,6 +142,13 @@ public class MapEntityStoreMixin
     }
 
     @Override
+    public String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference identity )
+    {
+        Reader in = mapEntityStore.get( identity );
+        return readVersion( in );
+    }
+
+    @Override
     public StateCommitter applyChanges( final EntityStoreUnitOfWork unitofwork, final Iterable<EntityState>
state
     )
         throws EntityStoreException
@@ -546,6 +549,20 @@ public class MapEntityStoreMixin
         }
     }
 
+    protected String readVersion( Reader entityState )
+        throws EntityStoreException
+    {
+        try
+        {
+            JSONObject jsonObject = new JSONObject( new JSONTokener( entityState ) );
+            return jsonObject.getString( JSONKeys.VERSION );
+        }
+        catch( JSONException e )
+        {
+            throw new EntityStoreException( e );
+        }
+    }
+
     @Override
     public JSONObject jsonStateOf( String id )
         throws IOException

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
old mode 100644
new mode 100755
index 7bc4ddb..52623ca
--- a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
@@ -66,7 +66,6 @@ import org.apache.zest.spi.entitystore.EntityStore;
 import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.EntityStoreSPI;
 import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
-import org.apache.zest.spi.entitystore.ModuleEntityStoreUnitOfWork;
 import org.apache.zest.spi.entitystore.StateCommitter;
 import org.apache.zest.spi.entitystore.helpers.DefaultEntityState;
 import org.apache.zest.spi.module.ModelModule;
@@ -74,8 +73,7 @@ import org.apache.zest.spi.module.ModuleSpi;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.zest.functional.Iterables.first;
-import static org.apache.zest.functional.Iterables.map;
+import static org.apache.zest.functional.Iterables.*;
 
 /**
  * Implementation of EntityStore that is backed by the Preferences API.
@@ -174,11 +172,9 @@ public class PreferencesEntityStoreMixin
     }
 
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, ModuleSpi module, long currentTime
)
+    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
     {
-        EntityStoreUnitOfWork storeUnitOfWork = new DefaultEntityStoreUnitOfWork( entityStoreSpi,
newUnitOfWorkId(), usecase, currentTime );
-        storeUnitOfWork = new ModuleEntityStoreUnitOfWork( module, storeUnitOfWork );
-        return storeUnitOfWork;
+        return new DefaultEntityStoreUnitOfWork( entityStoreSpi, newUnitOfWorkId(), usecase,
currentTime );
     }
 
     @Override
@@ -199,7 +195,7 @@ public class PreferencesEntityStoreMixin
                         UsecaseBuilder builder = UsecaseBuilder.buildUsecase( "zest.entitystore.preferences.visit"
);
                         Usecase visitUsecase = builder.withMetaInfo( CacheOptions.NEVER ).newUsecase();
                         final EntityStoreUnitOfWork uow =
-                            newUnitOfWork( visitUsecase, module, System.currentTimeMillis()
);
+                            newUnitOfWork( visitUsecase, System.currentTimeMillis() );
 
                         try
                         {
@@ -458,6 +454,26 @@ public class PreferencesEntityStoreMixin
     }
 
     @Override
+    public String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference identity )
+    {
+        try
+        {
+            if( !root.nodeExists( identity.identity() ) )
+            {
+                throw new NoSuchEntityException( identity, UnknownType.class, unitOfWork.usecase()
);
+            }
+
+            Preferences entityPrefs = root.node( identity.identity() );
+            return entityPrefs.get( "version", "" );
+
+        }
+        catch( BackingStoreException e )
+        {
+            throw new EntityStoreException( e );
+        }
+    }
+
+    @Override
     public StateCommitter applyChanges( final EntityStoreUnitOfWork unitofwork, final Iterable<EntityState>
state )
     {
         return new StateCommitter()

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
old mode 100644
new mode 100755
index f79e5b6..38be104
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
@@ -72,7 +72,6 @@ import org.apache.zest.spi.entitystore.EntityStore;
 import org.apache.zest.spi.entitystore.EntityStoreException;
 import org.apache.zest.spi.entitystore.EntityStoreSPI;
 import org.apache.zest.spi.entitystore.EntityStoreUnitOfWork;
-import org.apache.zest.spi.entitystore.ModuleEntityStoreUnitOfWork;
 import org.apache.zest.spi.entitystore.StateCommitter;
 import org.apache.zest.spi.entitystore.helpers.DefaultEntityState;
 import org.apache.zest.spi.entitystore.helpers.JSONKeys;
@@ -245,6 +244,13 @@ public class SQLEntityStoreMixin
     }
 
     @Override
+    public String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference entityRef
)
+    {
+        EntityValueResult valueResult = getValue( entityRef );
+        return readVersion( valueResult.getReader() );
+    }
+
+    @Override
     public EntityState newEntityState( EntityStoreUnitOfWork unitOfWork,
                                        ModuleSpi module,
                                        EntityReference entityRef,
@@ -255,12 +261,9 @@ public class SQLEntityStoreMixin
     }
 
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, ModuleSpi module, long currentTime
)
+    public EntityStoreUnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
     {
-        EntityStoreUnitOfWork storeUnitOfWork =
-            new DefaultEntityStoreUnitOfWork( entityStoreSPI, newUnitOfWorkId(), usecase,
currentTime );
-        storeUnitOfWork = new ModuleEntityStoreUnitOfWork( module, storeUnitOfWork );
-        return storeUnitOfWork;
+        return new DefaultEntityStoreUnitOfWork( entityStoreSPI, newUnitOfWorkId(), usecase,
currentTime );
     }
 
     @Override
@@ -308,8 +311,6 @@ public class SQLEntityStoreMixin
         ResultSet rs = null;
         UsecaseBuilder builder = UsecaseBuilder.buildUsecase( "zest.entitystore.sql.visit"
);
         Usecase usecase = builder.withMetaInfo( CacheOptions.NEVER ).newUsecase();
-        final ModuleEntityStoreUnitOfWork uow =
-            (ModuleEntityStoreUnitOfWork) newUnitOfWork( usecase, module, System.currentTimeMillis()
);
         try
         {
             connection = database.getConnection();
@@ -502,6 +503,21 @@ public class SQLEntityStoreMixin
         }
     }
 
+    protected String readVersion( Reader entityState )
+        throws EntityStoreException
+    {
+        try
+        {
+            JSONObject jsonObject = new JSONObject( new JSONTokener( entityState ) );
+            String version = jsonObject.getString( JSONKeys.VERSION );
+            return version;
+        }
+        catch( JSONException e )
+        {
+            throw new EntityStoreException( e );
+        }
+    }
+
     @Override
     public JSONObject jsonStateOf( String id )
         throws IOException

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
old mode 100644
new mode 100755
index 94941c8..844f37a
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
@@ -101,7 +101,6 @@ public interface ElasticSearchIndexer
 
             EntityStoreUnitOfWork uow = entityStore.newUnitOfWork(
                 UsecaseBuilder.newUsecase( "Load associations for indexing" ),
-                module,
                 System.currentTimeMillis()
             );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
old mode 100644
new mode 100755
index 8082065..49edb94
--- a/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
+++ b/libraries/rdf/src/test/java/org/apache/zest/library/rdf/entity/EntitySerializerTest.java
@@ -81,7 +81,7 @@ public class EntitySerializerTest
         EntityReference entityReference = new EntityReference( "test2" );
         Usecase usecase = UsecaseBuilder.newUsecase( "Test" );
         long currentTime = System.currentTimeMillis();
-        EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( usecase, module, currentTime
);
+        EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( usecase, currentTime
);
         EntityState entityState = unitOfWork.entityStateOf( module, entityReference );
 
         Iterable<Statement> graph = serializer.serialize( entityState );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/587c43d7/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
old mode 100644
new mode 100755
index e8e3a71..46ea9f7
--- a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
+++ b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
@@ -110,7 +110,7 @@ public class EntityResource
         throws ResourceException
     {
         Usecase usecase = UsecaseBuilder.newUsecase( "Remove entity" );
-        EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( usecase, module, System.currentTimeMillis()
);
+        EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( usecase, System.currentTimeMillis()
);
         try
         {
             EntityReference identityRef = EntityReference.parseEntityReference( identity
);
@@ -132,7 +132,6 @@ public class EntityResource
         throws ResourceException
     {
         EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( UsecaseBuilder.newUsecase(
"Get entity" ),
-                                                               module,
                                                                System.currentTimeMillis()
);
 
         try
@@ -356,7 +355,7 @@ public class EntityResource
         throws ResourceException
     {
         Usecase usecase = UsecaseBuilder.newUsecase( "Update entity" );
-        EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( usecase, module, System.currentTimeMillis()
);
+        EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( usecase, System.currentTimeMillis()
);
         EntityState entity = getEntityState( unitOfWork );
 
         Form form = new Form( entityRepresentation );


Mime
View raw message