Skip to content

Commit

Permalink
closes #139
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhrobbins committed Sep 6, 2014
1 parent aea24da commit a6b65e3
Show file tree
Hide file tree
Showing 81 changed files with 528 additions and 1,024 deletions.
33 changes: 33 additions & 0 deletions FlashCards_Repository/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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_App</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>FlashCards_Repository</artifactId>
<packaging>jar</packaging>
<name>FlashCards_Repository</name>
<description>FlashCards_Repository 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>
<!-- FlashCards project module dependencies -->
<dependency>
<groupId>org.robbins.flashcards</groupId>
<artifactId>FlashCards_Domain</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<finalName>FlashCards_Repository</finalName>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

package org.robbins.flashcards.repository.springdata;
package org.robbins.flashcards.repository;

import java.util.List;
import java.util.Set;

import org.robbins.flashcards.model.FlashCard;
import org.robbins.flashcards.model.Tag;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaRepository;

public interface FlashCardRepository extends JpaRepository<FlashCard, Long> {
public interface FlashCardRepository extends FlashCardsAppRepository<FlashCard, Long> {

List<FlashCard> findByTagsIn(Set<Tag> tags);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@

package org.robbins.flashcards.repository.jpa.base;
package org.robbins.flashcards.repository;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

public interface CrudRepository<T> {
public interface FlashCardsAppRepository<T, ID extends Serializable> {

Long count();
long count();

T save(T entity);

T findOne(Long id);
T findOne(ID id);

void delete(Long id);
void delete(ID id);

void delete(T entity);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

package org.robbins.flashcards.repository;

import org.robbins.flashcards.model.Tag;

public interface TagRepository extends FlashCardsAppRepository<Tag, Long> {

Tag findByName(String name);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

package org.robbins.flashcards.repository;

import org.robbins.flashcards.model.User;

public interface UserRepository extends FlashCardsAppRepository<User, Long> {

User findUserByOpenid(String openid);
}
File renamed without changes.
127 changes: 72 additions & 55 deletions FlashCards_Service_Jpa/pom.xml → FlashCards_Repository_Jpa/pom.xml
Original file line number Diff line number Diff line change
@@ -1,55 +1,72 @@
<?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_App</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>FlashCards_Service_Jpa</artifactId>
<packaging>jar</packaging>
<name>FlashCards_Service_Jpa</name>
<description>FlashCards_Service_Jpa 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>
<!-- FlashCards project module dependencies -->
<dependency>
<groupId>org.robbins.flashcards</groupId>
<artifactId>FlashCards_Service</artifactId>
<version>${project.version}</version>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>org.robbins.flashcards</groupId>
<artifactId>FlashCards_Test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
</dependency>
<dependency>
<groupId>com.github.springtestdbunit</groupId>
<artifactId>spring-test-dbunit</artifactId>
</dependency>
</dependencies>
</project>
<?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_App</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>FlashCards_Repository_Jpa</artifactId>
<packaging>jar</packaging>
<name>FlashCards_Repository_Jpa</name>
<description>FlashCards_Repository_Jpa 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>
<!-- FlashCards project module dependencies -->
<dependency>
<groupId>org.robbins.flashcards</groupId>
<artifactId>FlashCards_Service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.robbins.flashcards</groupId>
<artifactId>FlashCards_Repository_Jpa_Commons</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>

<!-- ORM dependencies -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<scope>runtime</scope>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>org.robbins.flashcards</groupId>
<artifactId>FlashCards_Test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
</dependency>
<dependency>
<groupId>com.github.springtestdbunit</groupId>
<artifactId>spring-test-dbunit</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.robbins.flashcards.repository.jpa.base;
package org.robbins.flashcards.repository;

import javax.inject.Inject;
import javax.persistence.EntityManager;
Expand All @@ -11,7 +11,7 @@
import org.robbins.flashcards.model.common.AbstractAuditable;

public abstract class AbstractCrudRepositoryImpl<T extends AbstractAuditable<User, Long>>
implements CrudRepository<T> {
implements FlashCardsAppRepository<T, Long> {

@PersistenceContext
private EntityManager em;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

package org.robbins.flashcards.repository.jpa;
package org.robbins.flashcards.repository;

import java.util.List;
import java.util.Set;

import org.robbins.flashcards.model.FlashCard;
import org.robbins.flashcards.model.Tag;
import org.robbins.flashcards.repository.jpa.base.CrudRepository;
import org.robbins.flashcards.repository.FlashCardsAppRepository;
import org.springframework.data.domain.Pageable;

public interface FlashCardRepository extends CrudRepository<FlashCard> {
public interface FlashCardRepository extends FlashCardsAppRepository<FlashCard, Long> {

List<FlashCard> findByTagsIn(Set<Tag> tags);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package org.robbins.flashcards.repository.jpa;
package org.robbins.flashcards.repository;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -9,7 +9,6 @@

import org.robbins.flashcards.model.FlashCard;
import org.robbins.flashcards.model.Tag;
import org.robbins.flashcards.repository.jpa.base.AbstractCrudRepositoryImpl;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -116,7 +115,7 @@ public FlashCard findByQuestion(final String question) {
}

@Override
public Long count() {
public long count() {
Query query = getEm().createQuery("SELECT COUNT(*) FROM FlashCard");
return (Long) query.getSingleResult();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

package org.robbins.flashcards.repository;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

public interface FlashCardsAppRepository<T, ID extends Serializable> {

long count();

T save(T entity);

T findOne(ID id);

void delete(ID id);

void delete(T entity);

List<T> findAll();

List<T> findAll(Sort sort);

Page<T> findAll(Pageable page);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

package org.robbins.flashcards.repository;

import org.robbins.flashcards.model.Tag;
import org.robbins.flashcards.repository.FlashCardsAppRepository;

public interface TagRepository extends FlashCardsAppRepository<Tag, Long> {

Tag findByName(String name);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

package org.robbins.flashcards.repository.jpa;
package org.robbins.flashcards.repository;

import java.util.List;

import javax.persistence.Query;

import org.robbins.flashcards.model.Tag;
import org.robbins.flashcards.repository.jpa.base.AbstractCrudRepositoryImpl;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -66,7 +65,7 @@ public Tag findByName(final String name) {
}

@Override
public Long count() {
public long count() {
Query query = getEm().createQuery("SELECT COUNT(*) FROM Tag");
return (Long) query.getSingleResult();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

package org.robbins.flashcards.repository;

import org.robbins.flashcards.model.User;
import org.robbins.flashcards.repository.FlashCardsAppRepository;

public interface UserRepository extends FlashCardsAppRepository<User, Long> {

User findUserByOpenid(String openid);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

package org.robbins.flashcards.repository.jpa;
package org.robbins.flashcards.repository;

import java.util.List;

import javax.persistence.Query;

import org.robbins.flashcards.model.User;
import org.robbins.flashcards.repository.jpa.base.AbstractCrudRepositoryImpl;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
Expand Down Expand Up @@ -60,7 +59,7 @@ public User findUserByOpenid(final String openid) {
}

@Override
public Long count() {
public long count() {
Query query = getEm().createQuery("SELECT COUNT(*) FROM User");
return (Long) query.getSingleResult();
}
Expand Down
Loading

0 comments on commit a6b65e3

Please sign in to comment.