-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit of cassandra repository
- Loading branch information
1 parent
4566d7d
commit 64884db
Showing
35 changed files
with
1,206 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
FlashCards_Repository/FlashCards_Repository_Cassandra/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<parent> | ||
<groupId>org.robbins.flashcards</groupId> | ||
<artifactId>FlashCards_Repository</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>FlashCards_Repository_Cassandra</artifactId> | ||
<packaging>jar</packaging> | ||
<name>FlashCards_Repository_Cassandra</name> | ||
<description>FlashCards_Repository_Cassandra description</description> | ||
<properties> | ||
<skip.coveralls>false</skip.coveralls> | ||
</properties> | ||
<scm> | ||
<connection>scm:git:git@github.com:justinhrobbins/FlashCards_App.git</connection> | ||
<url>scm:git:git@github.com:justinhrobbins/FlashCards_App.git</url> | ||
<developerConnection>scm:git:git@github.com:justinhrobbins/FlashCards_App.git</developerConnection> | ||
</scm> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.robbins.flashcards</groupId> | ||
<artifactId>FlashCards_Repository_Commons</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.robbins.flashcards</groupId> | ||
<artifactId>FlashCards_DTO</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.robbins.flashcards</groupId> | ||
<artifactId>FlashCards_API</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-cassandra</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.data</groupId> | ||
<artifactId>spring-data-commons-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
</dependency> | ||
|
||
<!-- Dozer for mapping to DTOs --> | ||
<dependency> | ||
<groupId>net.sf.dozer</groupId> | ||
<artifactId>dozer</artifactId> | ||
</dependency> | ||
|
||
<!-- JSR 330: Dependency Injection for Java --> | ||
<dependency> | ||
<groupId>javax.inject</groupId> | ||
<artifactId>javax.inject</artifactId> | ||
</dependency> | ||
|
||
<!-- test dependencies --> | ||
<dependency> | ||
<groupId>org.robbins.flashcards</groupId> | ||
<artifactId>FlashCards_Test</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-all</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.cassandraunit</groupId> | ||
<artifactId>cassandra-unit-spring</artifactId> | ||
</dependency> | ||
|
||
<!-- logging --> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>FlashCards_Repository_Cassandra</finalName> | ||
</build> | ||
</project> |
13 changes: 13 additions & 0 deletions
13
...s_Repository_Cassandra/src/main/java/org/robbins/flashcards/repository/TagRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.robbins.flashcards.repository; | ||
|
||
import org.robbins.flashcards.repository.domain.TagCassandra; | ||
import org.springframework.data.cassandra.repository.CassandraRepository; | ||
import org.springframework.data.cassandra.repository.TypedIdCassandraRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.UUID; | ||
|
||
@Repository("tagRepository") | ||
public interface TagRepository extends TypedIdCassandraRepository<TagCassandra, UUID> { | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...src/main/java/org/robbins/flashcards/repository/conversion/impl/AbstractDtoConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.robbins.flashcards.repository.conversion.impl; | ||
|
||
import org.dozer.Mapper; | ||
|
||
import javax.inject.Inject; | ||
|
||
public class AbstractDtoConverter { | ||
@Inject | ||
private Mapper mapper; | ||
|
||
public Mapper getMapper() { | ||
return mapper; | ||
} | ||
|
||
public void setMapper(final Mapper mapper) { | ||
this.mapper = mapper; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...c/main/java/org/robbins/flashcards/repository/conversion/impl/DefaultTagDtoConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.robbins.flashcards.repository.conversion.impl; | ||
|
||
import org.apache.commons.lang3.NotImplementedException; | ||
import org.robbins.flashcards.conversion.DtoConverter; | ||
import org.robbins.flashcards.dto.TagDto; | ||
import org.robbins.flashcards.exceptions.RepositoryException; | ||
import org.robbins.flashcards.repository.domain.TagCassandra; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@Component("tagDtoConverter") | ||
public class DefaultTagDtoConverter extends AbstractDtoConverter implements DtoConverter<TagDto, TagCassandra> { | ||
|
||
@Override | ||
public TagDto getDto(final TagCassandra entity) throws RepositoryException { | ||
return getMapper().map(entity, TagDto.class); | ||
} | ||
|
||
@Override | ||
public TagDto getDto(final TagCassandra entity, final Set<String> fields) | ||
throws RepositoryException | ||
{ | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public TagCassandra getEntity(final TagDto dto) { | ||
return getMapper().map(dto, TagCassandra.class); | ||
} | ||
|
||
@Override | ||
public List<TagDto> getDtos(List<TagCassandra> entities) throws RepositoryException { | ||
List<TagDto> dtos = new ArrayList<>(); | ||
for (TagCassandra entity : entities) { | ||
dtos.add(getDto(entity)); | ||
} | ||
return dtos; | ||
} | ||
|
||
@Override | ||
public List<TagDto> getDtos(final List<TagCassandra> entities, final Set<String> fields) | ||
throws RepositoryException {throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public List<TagCassandra> getEtnties(final List<TagDto> dtos) { | ||
List<TagCassandra> entities = new ArrayList<>(); | ||
for (TagDto dto : dtos) { | ||
entities.add(getEntity(dto)); | ||
} | ||
return entities; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...sitory_Cassandra/src/main/java/org/robbins/flashcards/repository/domain/TagCassandra.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.robbins.flashcards.repository.domain; | ||
|
||
import org.springframework.data.cassandra.mapping.PrimaryKey; | ||
import org.springframework.data.cassandra.mapping.Table; | ||
|
||
import java.util.UUID; | ||
|
||
@Table(value = "tag") | ||
public class TagCassandra { | ||
|
||
@PrimaryKey | ||
private UUID id; | ||
|
||
private String name; | ||
|
||
public UUID getId() { | ||
return id; | ||
} | ||
|
||
public void setId(UUID id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
...ra/src/main/java/org/robbins/flashcards/repository/facade/DefaultTagRepositoryFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
|
||
package org.robbins.flashcards.repository.facade; | ||
|
||
import com.google.common.collect.Lists; | ||
import org.apache.commons.lang3.NotImplementedException; | ||
import org.robbins.flashcards.conversion.DtoConverter; | ||
import org.robbins.flashcards.dto.TagDto; | ||
import org.robbins.flashcards.exceptions.FlashcardsException; | ||
import org.robbins.flashcards.exceptions.RepositoryException; | ||
import org.robbins.flashcards.facade.TagFacade; | ||
import org.robbins.flashcards.repository.TagRepository; | ||
import org.robbins.flashcards.repository.domain.TagCassandra; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import javax.inject.Inject; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@Transactional | ||
@Component("tagRepositoryFacade") | ||
public class DefaultTagRepositoryFacade implements | ||
TagFacade { | ||
|
||
@Inject | ||
private TagRepository repository; | ||
|
||
@Inject | ||
@Qualifier("tagDtoConverter") | ||
private DtoConverter<TagDto, TagCassandra> converter; | ||
|
||
public DtoConverter<TagDto, TagCassandra> getConverter() | ||
{ | ||
return converter; | ||
} | ||
|
||
public TagRepository getRepository() { | ||
return repository; | ||
} | ||
|
||
@Override | ||
public TagDto findByName(final String name) throws RepositoryException { | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public List<TagDto> findTagsForFlashcard(final Long flashcardId, final Set<String> fields) throws RepositoryException { | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public List<TagDto> list() throws FlashcardsException { | ||
List<TagCassandra> tags = Lists.newArrayList(getRepository().findAll()); | ||
return getConverter().getDtos(tags); | ||
} | ||
|
||
@Override | ||
public List<TagDto> list(Integer page, Integer size, String sort, String direction) throws FlashcardsException { | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public List<TagDto> list(Integer page, Integer size, String sort, String direction, Set<String> fields) throws FlashcardsException { | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public Long count() { | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public TagDto findOne(Long id) throws FlashcardsException { | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public TagDto findOne(Long id, Set<String> fields) throws FlashcardsException { | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public TagDto save(TagDto entity) throws FlashcardsException { | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public void delete(Long id) { | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
|
||
@Override | ||
public List<TagDto> findByCreatedBy(Long userId, Set<String> fields) throws FlashcardsException { | ||
throw new NotImplementedException("method not yet implemented in Cassandra repository"); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...Cards_Repository_Cassandra/src/main/resources/applicationContext-repository-cassandra.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xmlns:cassandra="http://www.springframework.org/schema/data/cassandra" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd | ||
http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra-1.0.xsd"> | ||
|
||
<bean id="mapper" class="org.dozer.DozerBeanMapper"> | ||
<property name="mappingFiles"> | ||
<list> | ||
<value>dozer-mappings.xml</value> | ||
</list> | ||
</property> | ||
</bean> | ||
|
||
|
||
<context:component-scan base-package=" | ||
org.robbins.flashcards.repository.facade, | ||
org.robbins.flashcards.repository.conversion" /> | ||
|
||
<!-- REQUIRED: The Cassandra Cluster --> | ||
<cassandra:cluster contact-points="localhost" /> | ||
|
||
<!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching | ||
to a keyspace --> | ||
<cassandra:session keyspace-name="flashcardsapp" /> | ||
|
||
<!-- REQUIRED: The Default Cassandra Mapping Context used by CassandraConverter --> | ||
<cassandra:mapping /> | ||
|
||
<!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate --> | ||
<cassandra:converter /> | ||
|
||
<!-- REQUIRED: The Cassandra Template is the building block of all Spring | ||
Data Cassandra --> | ||
<cassandra:template id="cassandraTemplate" /> | ||
|
||
<cassandra:repositories base-package="org.robbins.flashcards.repository" /> | ||
</beans> |
Oops, something went wrong.