Merge branch 'master' of github.com:spring-projects/spring-data-cassandra
This commit is contained in:
27
README.md
27
README.md
@@ -1,5 +1,32 @@
|
||||
# Spring Data Cassandra Project Info
|
||||
|
||||
## Quick Start
|
||||
|
||||
To begin working with ``spring-cassandra`` and ``spring-data-cassandra`` add the Spring Maven Repository to your ``pom.xml``.
|
||||
|
||||
<repository>
|
||||
<id>spring-libs-snapshot</id>
|
||||
<url>http://repo.spring.io/libs-snapshot</url>
|
||||
</repository>
|
||||
|
||||
Then include the latest and greatest JAR into your project dependencies.
|
||||
|
||||
**CQL Only**
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-cassandra</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
**CQL and Object Mapping**
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-cassandra</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
## Release Preview
|
||||
|
||||
The goal of this release preview is to publish the pieces of spring-data-cassandra as they become available
|
||||
|
||||
@@ -48,10 +48,10 @@ public class AlterKeyspaceCqlGenerator extends KeyspaceOptionsCqlGenerator<Alter
|
||||
return noNull(cql).append("ALTER KEYSPACE ").append(spec().getNameAsIdentifier()).append(" ");
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@SuppressWarnings("unchecked")
|
||||
protected StringBuilder optionsCql(StringBuilder cql) {
|
||||
cql = noNull(cql);
|
||||
|
||||
|
||||
// begin options clause
|
||||
Map<String, Object> options = spec().getOptions();
|
||||
|
||||
@@ -61,7 +61,7 @@ public class AlterKeyspaceCqlGenerator extends KeyspaceOptionsCqlGenerator<Alter
|
||||
boolean first = true;
|
||||
cql.append(" WITH ");
|
||||
// end option preamble
|
||||
|
||||
|
||||
if (!options.isEmpty()) {
|
||||
for (String name : options.keySet()) {
|
||||
// append AND if we're not on first option
|
||||
@@ -92,7 +92,7 @@ public class AlterKeyspaceCqlGenerator extends KeyspaceOptionsCqlGenerator<Alter
|
||||
}
|
||||
}
|
||||
// end options
|
||||
|
||||
|
||||
return cql;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,12 +51,12 @@ public class CreateKeyspaceCqlGenerator extends KeyspaceCqlGenerator<CreateKeysp
|
||||
.append(spec().getNameAsIdentifier());
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@SuppressWarnings("unchecked")
|
||||
protected StringBuilder optionsCql(StringBuilder cql) {
|
||||
cql = noNull(cql);
|
||||
|
||||
cql.append( " " );
|
||||
|
||||
|
||||
cql.append(" ");
|
||||
|
||||
// begin options clause
|
||||
Map<String, Object> options = spec().getOptions();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class CreateKeyspaceCqlGenerator extends KeyspaceCqlGenerator<CreateKeysp
|
||||
boolean first = true;
|
||||
cql.append("WITH ");
|
||||
// end option preamble
|
||||
|
||||
|
||||
if (!options.isEmpty()) {
|
||||
for (String name : options.keySet()) {
|
||||
// append AND if we're not on first option
|
||||
@@ -97,7 +97,7 @@ public class CreateKeyspaceCqlGenerator extends KeyspaceCqlGenerator<CreateKeysp
|
||||
}
|
||||
}
|
||||
// end options
|
||||
|
||||
|
||||
return cql;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.cassandra.core.keyspace.Option;
|
||||
* @param T The subtype of this class for which this is a CQL generator.
|
||||
*/
|
||||
public abstract class KeyspaceOptionsCqlGenerator<T extends KeyspaceOptionsSpecification<T>> extends
|
||||
KeyspaceNameCqlGenerator<KeyspaceOptionsSpecification<T>> {
|
||||
KeyspaceNameCqlGenerator<KeyspaceOptionsSpecification<T>> {
|
||||
|
||||
public KeyspaceOptionsCqlGenerator(KeyspaceOptionsSpecification<T> specification) {
|
||||
super(specification);
|
||||
|
||||
@@ -13,8 +13,8 @@ import org.springframework.cassandra.core.cql.CqlStringUtils;
|
||||
* Abstract builder class to support the construction of table specifications that have table options, that is, those
|
||||
* options normally specified by <code>WITH ... AND ...</code>.
|
||||
* <p/>
|
||||
* It is important to note that although this class depends on {@link KeyspaceOption} for convenient and typesafe use, it
|
||||
* ultimately stores its options in a <code>Map<String,Object></code> for flexibility. This means that
|
||||
* It is important to note that although this class depends on {@link KeyspaceOption} for convenient and typesafe use,
|
||||
* it ultimately stores its options in a <code>Map<String,Object></code> for flexibility. This means that
|
||||
* {@link #with(KeyspaceOption)} and {@link #with(KeyspaceOption, Object)} delegate to
|
||||
* {@link #with(String, Object, boolean, boolean)}. This design allows the API to support new Cassandra options as they
|
||||
* are introduced without having to update the code immediately.
|
||||
@@ -27,7 +27,7 @@ public abstract class KeyspaceOptionsSpecification<T extends KeyspaceOptionsSpec
|
||||
|
||||
protected Map<String, Object> options = new LinkedHashMap<String, Object>();
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@SuppressWarnings("unchecked")
|
||||
public T name(String name) {
|
||||
return (T) super.name(name);
|
||||
}
|
||||
@@ -43,8 +43,8 @@ public abstract class KeyspaceOptionsSpecification<T extends KeyspaceOptionsSpec
|
||||
|
||||
/**
|
||||
* Sets the given table option. This is a convenience method that calls
|
||||
* {@link #with(String, Object, boolean, boolean)} appropriately from the given {@link KeyspaceOption} and value for that
|
||||
* option.
|
||||
* {@link #with(String, Object, boolean, boolean)} appropriately from the given {@link KeyspaceOption} and value for
|
||||
* that option.
|
||||
*
|
||||
* @param option The option to set.
|
||||
* @param value The value of the option. Must be type-compatible with the {@link KeyspaceOption}.
|
||||
|
||||
@@ -15,13 +15,12 @@
|
||||
*/
|
||||
package org.springframework.cassandra.core.keyspace;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Builder class to support the construction of keyspace specifications that have columns. This class can also be used as a
|
||||
* standalone {@link KeyspaceDescriptor}, independent of {@link CreateKeyspaceSpecification}.
|
||||
* Builder class to support the construction of keyspace specifications that have columns. This class can also be used
|
||||
* as a standalone {@link KeyspaceDescriptor}, independent of {@link CreateKeyspaceSpecification}.
|
||||
*
|
||||
* @author John McPeek
|
||||
*/
|
||||
public class KeyspaceSpecification<T> extends KeyspaceOptionsSpecification<KeyspaceSpecification<T>> implements KeyspaceDescriptor {
|
||||
public class KeyspaceSpecification<T> extends KeyspaceOptionsSpecification<KeyspaceSpecification<T>> implements
|
||||
KeyspaceDescriptor {
|
||||
}
|
||||
|
||||
@@ -15,12 +15,13 @@
|
||||
*/
|
||||
package org.springframework.cassandra.test.integration.core.cql.generator;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cassandra.core.keyspace.Option;
|
||||
import org.springframework.cassandra.core.keyspace.KeyspaceDescriptor;
|
||||
import org.springframework.cassandra.core.keyspace.Option;
|
||||
|
||||
import com.datastax.driver.core.KeyspaceMetadata;
|
||||
import com.datastax.driver.core.Session;
|
||||
@@ -29,18 +30,18 @@ public class CqlKeyspaceSpecificationAssertions {
|
||||
|
||||
public static double DELTA = 1e-6; // delta for comparisons of doubles
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void assertKeyspace(KeyspaceDescriptor expected, String keyspace, Session session) {
|
||||
KeyspaceMetadata kmd = session.getCluster().getMetadata().getKeyspace(keyspace.toLowerCase());
|
||||
|
||||
assertEquals( expected.getName(), kmd.getName() );
|
||||
|
||||
Map<String,String> options = kmd.getReplication();
|
||||
Map<String,Object> expectedOptions = expected.getOptions();
|
||||
Map<Option,Object> replicationMap = (Map<Option, Object>) expectedOptions.get( "replication" );
|
||||
assertEquals(expected.getName(), kmd.getName());
|
||||
|
||||
Map<String, String> options = kmd.getReplication();
|
||||
Map<String, Object> expectedOptions = expected.getOptions();
|
||||
Map<Option, Object> replicationMap = (Map<Option, Object>) expectedOptions.get("replication");
|
||||
assertEquals(replicationMap.size(), options.size());
|
||||
|
||||
for ( Map.Entry<Option, Object> optionEntry : replicationMap.entrySet()) {
|
||||
for (Map.Entry<Option, Object> optionEntry : replicationMap.entrySet()) {
|
||||
String optionValue = options.get(optionEntry.getKey().getName());
|
||||
String repMapValue = "" + optionEntry.getValue();
|
||||
assertTrue(optionValue.endsWith(repMapValue));
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.springframework.cassandra.test.unit.core.keyspace;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user