//
//
// Setup a project...
ProjectEntity project = new ProjectEntity();
project.setId(UUID.randomUUID());
project.setName("caffinitas");
project.setLicense(License.APACHE_V2);
project.getAuthors().add("snazy");
project.getContributors().add("snazy");
project.setProjectURL(new URL("http://caffinitas.org/"));
AggregatorModuleEntity parentModule = new AggregatorModuleEntity();
parentModule.setProjectId(project.getId());
parentModule.setName("caffinitas-parent");
CodeModuleEntity moduleCore = new CodeModuleEntity();
moduleCore.setProjectId(project.getId());
moduleCore.setName("caffinitas-core");
moduleCore.setLanguage(Language.JAVA);
CodeModuleEntity moduleDemo = new CodeModuleEntity();
moduleDemo.setProjectId(project.getId());
moduleDemo.setName("caffinitas-demo");
moduleDemo.setLanguage(Language.JAVA);
CodeModuleEntity moduleTest = new CodeModuleEntity();
moduleTest.setProjectId(project.getId());
moduleTest.setName("caffinitas-test");
moduleTest.setLanguage(Language.JAVA);
parentModule.getModules().add("caffinitas-core");
parentModule.getModules().add("caffinitas-demo");
parentModule.getModules().add("caffinitas-test");
ModifyFuture<ProjectEntity> projectPersistFuture = session.insertAsync(project);
ModifyFuture<AggregatorModuleEntity> parentModulePersistFuture = session.insertAsync(parentModule);
ModifyFuture<CodeModuleEntity> moduleCorePersistFuture = session.insertAsync(moduleCore);
ModifyFuture<CodeModuleEntity> moduleDemoPersistFuture = session.insertAsync(moduleDemo);
ModifyFuture<CodeModuleEntity> moduleTestPersistFuture = session.insertAsync(moduleTest);
ListenableFuture<List<Object>> combinedFuture =
Futures.allAsList(projectPersistFuture, parentModulePersistFuture,
moduleCorePersistFuture, moduleDemoPersistFuture, moduleTestPersistFuture);
Uninterruptibles.getUninterruptibly(combinedFuture);
//
project = session.loadOne(ProjectEntity.class, project.getId());
// load all modules (since projectId is the partition key in ModuleEntity we can load it with one SELECT)
List<ModuleEntity> modules = session.loadMultiple(ModuleEntity.class, project.getId());
for (ModuleEntity module : modules)
{
System.out.println(" " + module.getName());
}