polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject zest-java git commit: ZEST-126 Fix forum sample assembly and gradle `runSample` task
Date Mon, 28 Sep 2015 13:19:59 GMT
Repository: zest-java
Updated Branches:
  refs/heads/support/2.1 efcf237c4 -> 23520c083


ZEST-126 Fix forum sample assembly and gradle `runSample` task

Cherry-picked from b7d4c765f1dc6c78be295edb6651ed432548d734


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

Branch: refs/heads/support/2.1
Commit: 23520c083bb3ac618aa6580ae30ed0a3ee6c7f7a
Parents: efcf237
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Mon Sep 28 14:39:56 2015 +0200
Committer: Paul Merlin <paul@nosphere.org>
Committed: Mon Sep 28 15:17:46 2015 +0200

----------------------------------------------------------------------
 samples/forum/build.gradle                      |  7 +++--
 .../samples/forum/assembler/ForumAssembler.java | 33 +++++++++++++-------
 .../qi4j/samples/forum/data/entity/Users.java   | 14 ++++++++-
 .../forum/rest/resource/RootResource.java       |  8 +----
 .../rest/resource/signup/SignupResource.java    |  1 +
 5 files changed, 41 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/23520c08/samples/forum/build.gradle
----------------------------------------------------------------------
diff --git a/samples/forum/build.gradle b/samples/forum/build.gradle
index c3e9ddd..c8eae14 100644
--- a/samples/forum/build.gradle
+++ b/samples/forum/build.gradle
@@ -26,14 +26,17 @@ dependencies {
   compile project( ":org.qi4j.core:org.qi4j.core.bootstrap" )
   compile project( ":org.qi4j.libraries:org.qi4j.library.rest-server" )
   compile project( ":org.qi4j.libraries:org.qi4j.library.fileconfig" )
-  compile project( ":org.qi4j.extensions:org.qi4j.extension.entitystore-file" )
   compile project( ":org.qi4j.extensions:org.qi4j.extension.valueserialization-orgjson" )
+  compile project( ":org.qi4j.extensions:org.qi4j.extension.entitystore-memory" )
+  compile project( ":org.qi4j.extensions:org.qi4j.extension.entitystore-file" )
+  compile project( ":org.qi4j.extensions:org.qi4j.extension.indexing-rdf" )
   compile libraries.servlet_api
 
+  runtime libraries.logback
+
   testCompile project( ":org.qi4j.core:org.qi4j.core.testsupport" )
 
   testRuntime project( ":org.qi4j.core:org.qi4j.core.runtime" )
-  testRuntime libraries.logback
 
 }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/23520c08/samples/forum/src/main/java/org/qi4j/samples/forum/assembler/ForumAssembler.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/qi4j/samples/forum/assembler/ForumAssembler.java
b/samples/forum/src/main/java/org/qi4j/samples/forum/assembler/ForumAssembler.java
index a6fe814..b06e806 100644
--- a/samples/forum/src/main/java/org/qi4j/samples/forum/assembler/ForumAssembler.java
+++ b/samples/forum/src/main/java/org/qi4j/samples/forum/assembler/ForumAssembler.java
@@ -32,24 +32,25 @@ import org.qi4j.bootstrap.ClassScanner;
 import org.qi4j.bootstrap.LayerAssembly;
 import org.qi4j.bootstrap.ModuleAssembly;
 import org.qi4j.entitystore.file.assembly.FileEntityStoreAssembler;
-import org.qi4j.entitystore.memory.MemoryEntityStoreService;
+import org.qi4j.entitystore.memory.MemoryEntityStoreAssembler;
 import org.qi4j.functional.Function;
-import org.qi4j.library.fileconfig.FileConfigurationService;
+import org.qi4j.index.rdf.assembly.RdfNativeSesameStoreAssembler;
+import org.qi4j.library.fileconfig.FileConfigurationAssembler;
+import org.qi4j.library.rdf.repository.NativeConfiguration;
 import org.qi4j.library.rest.common.ValueAssembler;
 import org.qi4j.library.rest.server.assembler.RestServerAssembler;
 import org.qi4j.library.rest.server.restlet.RequestReaderDelegator;
 import org.qi4j.library.rest.server.restlet.ResponseWriterDelegator;
 import org.qi4j.library.rest.server.spi.CommandResult;
 import org.qi4j.samples.forum.context.Context;
+import org.qi4j.samples.forum.domainevent.DomainCommandResult;
+import org.qi4j.samples.forum.rest.resource.RootResource;
 import org.qi4j.samples.forum.context.EventsService;
 import org.qi4j.samples.forum.data.entity.User;
-import org.qi4j.samples.forum.domainevent.DomainCommandResult;
 import org.qi4j.samples.forum.domainevent.DomainEventValue;
 import org.qi4j.samples.forum.domainevent.ParameterValue;
 import org.qi4j.samples.forum.rest.ForumRestlet;
-import org.qi4j.samples.forum.rest.resource.RootResource;
 import org.qi4j.samples.forum.service.BootstrapData;
-import org.qi4j.spi.uuid.UuidIdentityGeneratorService;
 import org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
 import org.restlet.service.MetadataService;
 
@@ -76,17 +77,14 @@ public class ForumAssembler
         LayerAssembly configuration = assembly.layer( "Configuration" );
         {
             configModule = configuration.module( "Configuration" );
-            configModule.services( MemoryEntityStoreService.class );
-            configModule.services( UuidIdentityGeneratorService.class );
             new OrgJsonValueSerializationAssembler().assemble( configModule );
+            new MemoryEntityStoreAssembler().assemble( configModule );
+            new FileConfigurationAssembler().visibleIn( Visibility.application ).assemble(
configModule );
         }
 
         LayerAssembly infrastructure = assembly.layer( "Infrastructure" ).uses( configuration
);
         {
-            ModuleAssembly entityStore = infrastructure.module( "EntityStore" );
-            entityStore.services( FileConfigurationService.class );
-            new FileEntityStoreAssembler().withConfig( configModule, Visibility.application
).assemble( entityStore );
-            entityStore.services( UuidIdentityGeneratorService.class ).visibleIn( Visibility.application
);
+            ModuleAssembly serialization = infrastructure.module( "Serialization" );
             new OrgJsonValueSerializationAssembler().
                 visibleIn( Visibility.application ).
                 withValuesModuleFinder( new Function<Application, Module>()
@@ -97,7 +95,18 @@ public class ForumAssembler
                     return app.findModule( "REST", "Values" );
                 }
             } ).
-                assemble( entityStore );
+                assemble( serialization );
+
+            ModuleAssembly entityStore = infrastructure.module( "EntityStore" );
+            new FileEntityStoreAssembler()
+                .visibleIn( Visibility.application )
+                .withConfig( configModule, Visibility.application )
+                .assemble( entityStore );
+
+            ModuleAssembly indexQuery = infrastructure.module( "IndexQuery" );
+            new RdfNativeSesameStoreAssembler( Visibility.application, Visibility.application
)
+                .assemble( indexQuery );
+            configModule.entities( NativeConfiguration.class ).visibleIn( Visibility.application
);
         }
 
         LayerAssembly data = assembly.layer( "Data" ).uses( infrastructure );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/23520c08/samples/forum/src/main/java/org/qi4j/samples/forum/data/entity/Users.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/qi4j/samples/forum/data/entity/Users.java b/samples/forum/src/main/java/org/qi4j/samples/forum/data/entity/Users.java
index 8b591c4..cd86129 100644
--- a/samples/forum/src/main/java/org/qi4j/samples/forum/data/entity/Users.java
+++ b/samples/forum/src/main/java/org/qi4j/samples/forum/data/entity/Users.java
@@ -27,6 +27,7 @@ import org.qi4j.api.structure.Module;
 import org.qi4j.samples.forum.context.Events;
 import org.qi4j.samples.forum.context.signup.Registration;
 
+import static org.qi4j.api.query.QueryExpressions.eq;
 import static org.qi4j.api.query.QueryExpressions.templateFor;
 
 /**
@@ -38,7 +39,9 @@ public interface Users
 {
     String USERS_ID = "users";
 
-    public Query<User> users();
+    Query<User> users();
+
+    User userNamed( String name );
 
     abstract class Mixin
         implements Users
@@ -46,6 +49,7 @@ public interface Users
         @Structure
         Module module;
 
+        @Override
         public Query<User> users()
         {
             return module.currentUnitOfWork()
@@ -54,6 +58,14 @@ public interface Users
         }
 
         @Override
+        public User userNamed( String name )
+        {
+            return module.currentUnitOfWork().newQuery(
+                module.newQueryBuilder( User.class ).where( eq( templateFor( User.class ).name(),
name ) )
+            ).find();
+        }
+
+        @Override
         public void signedup( Registration registration )
         {
             EntityBuilder<User> builder = module.currentUnitOfWork().newEntityBuilder(
User.class );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/23520c08/samples/forum/src/main/java/org/qi4j/samples/forum/rest/resource/RootResource.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/qi4j/samples/forum/rest/resource/RootResource.java
b/samples/forum/src/main/java/org/qi4j/samples/forum/rest/resource/RootResource.java
index 2d890b0..c2d93a7 100644
--- a/samples/forum/src/main/java/org/qi4j/samples/forum/rest/resource/RootResource.java
+++ b/samples/forum/src/main/java/org/qi4j/samples/forum/rest/resource/RootResource.java
@@ -19,7 +19,6 @@
 package org.qi4j.samples.forum.rest.resource;
 
 import java.util.Collections;
-import org.qi4j.api.query.QueryExpressions;
 import org.qi4j.library.rest.server.api.ContextResource;
 import org.qi4j.library.rest.server.api.SubResource;
 import org.qi4j.library.rest.server.api.constraint.Requires;
@@ -62,12 +61,7 @@ public class RootResource
             throw new ResourceException( Status.CLIENT_ERROR_UNAUTHORIZED );
         }
 
-        User user = module.currentUnitOfWork().newQuery( module.newQueryBuilder( User.class
).where( QueryExpressions
-                                                                                        
                .eq( QueryExpressions
-                                                                                        
                         .templateFor( User.class )
-                                                                                        
                         .name(), challenge
-                                                                                        
                    .getIdentifier() ) ) )
-            .find();
+        User user = select( Users.class, Users.USERS_ID ).userNamed( challenge.getIdentifier()
);
         if( user == null || !user.isCorrectPassword( new String( challenge.getSecret() )
) )
         {
             throw new ResourceException( Status.CLIENT_ERROR_UNAUTHORIZED );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/23520c08/samples/forum/src/main/java/org/qi4j/samples/forum/rest/resource/signup/SignupResource.java
----------------------------------------------------------------------
diff --git a/samples/forum/src/main/java/org/qi4j/samples/forum/rest/resource/signup/SignupResource.java
b/samples/forum/src/main/java/org/qi4j/samples/forum/rest/resource/signup/SignupResource.java
index 69a341a..329a2d7 100644
--- a/samples/forum/src/main/java/org/qi4j/samples/forum/rest/resource/signup/SignupResource.java
+++ b/samples/forum/src/main/java/org/qi4j/samples/forum/rest/resource/signup/SignupResource.java
@@ -40,6 +40,7 @@ public class SignupResource
         form.set( "name", "Rickard" );
         form.set( "realName", "Rickard Öberg" );
         form.set( "password", "rickard" );
+        form.set( "email", "rickard@zest" );
         return form;
     }
 }


Mime
View raw message