Skip to content

Commit

Permalink
closes #151
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhrobbins-hybris committed Sep 13, 2014
1 parent 26d300a commit e757d70
Show file tree
Hide file tree
Showing 46 changed files with 715 additions and 386 deletions.
31 changes: 31 additions & 0 deletions FlashCards_API/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<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/xsd/maven-4.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_API</artifactId>
<name>FlashCards_API</name>
<description>FlashCards_API description</description>
<properties>
<skip.coveralls>true</skip.coveralls>
<skip.cobertura>true</skip.cobertura>
</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_DTO</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<finalName>FlashCards_API</finalName>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@

package org.robbins.flashcards.facade;

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

import org.robbins.flashcards.dto.FlashCardDto;
import org.robbins.flashcards.dto.TagDto;
import org.robbins.flashcards.exceptions.ServiceException;
import org.robbins.flashcards.facade.base.CrudFacade;
import org.robbins.flashcards.facade.base.GenericCrudFacade;
import org.robbins.flashcards.model.FlashCard;
import org.springframework.data.domain.PageRequest;

public interface FlashcardFacade extends GenericCrudFacade<FlashCardDto>,
CrudFacade<FlashCardDto, FlashCard> {
import java.util.List;
import java.util.Set;

public interface FlashcardFacade extends GenericCrudFacade<FlashCardDto> {

List<FlashCardDto> findByTagsIn(Set<TagDto> tags) throws ServiceException;

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

package org.robbins.flashcards.facade;

import org.robbins.flashcards.dto.TagDto;
import org.robbins.flashcards.exceptions.ServiceException;
import org.robbins.flashcards.facade.base.GenericCrudFacade;

public interface TagFacade extends GenericCrudFacade<TagDto> {

TagDto findByName(String name) throws ServiceException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

package org.robbins.flashcards.facade;

import org.robbins.flashcards.dto.UserDto;
import org.robbins.flashcards.exceptions.ServiceException;
import org.robbins.flashcards.facade.base.GenericCrudFacade;

public interface UserFacade extends GenericCrudFacade<UserDto> {

UserDto findUserByOpenid(String openid) throws ServiceException;
}
31 changes: 31 additions & 0 deletions FlashCards_Client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<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/xsd/maven-4.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_Client</artifactId>
<name>FlashCards_Client</name>
<description>FlashCards_Client description</description>
<properties>
<skip.coveralls>true</skip.coveralls>
<skip.cobertura>true</skip.cobertura>
</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_Domain</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<finalName>FlashCards_Client</finalName>
</build>
</project>
45 changes: 45 additions & 0 deletions FlashCards_DTO/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<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/xsd/maven-4.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_DTO</artifactId>
<name>FlashCards_DTO</name>
<description>FlashCards_DTO description</description>
<properties>
<skip.coveralls>true</skip.coveralls>
<skip.cobertura>true</skip.cobertura>
</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>
<!-- Spring data commons for Auditable and Persistable -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons-core</artifactId>
</dependency>

<!-- Jackson dependencies -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<build>
<finalName>FlashCards_DTO</finalName>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,15 @@
import org.robbins.flashcards.dto.FlashCardDto;
import org.robbins.flashcards.dto.TagDto;
import org.robbins.flashcards.dto.UserDto;
import org.robbins.flashcards.model.FlashCard;
import org.robbins.flashcards.model.Tag;
import org.robbins.flashcards.model.User;

public final class TestEntityGenerator {
public final class TestDtoGenerator {

private TestEntityGenerator() {
};

public static Tag createTag(final String name) {
return new Tag(name);
}
private TestDtoGenerator() {};

public static TagDto createTagDto(final String name) {
return new TagDto(name);
}

public static FlashCard createFlashCard(final String question, final String answer) {
return new FlashCard(question, answer);
}

public static User createUser(final String openid, final String email) {
return new User(openid, email);
}

public static UserDto createUserDto(final String openid, final String email) {
return new UserDto(openid, email);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.robbins.flashcards.dto.TagDto;
import org.robbins.flashcards.exceptions.ServiceException;
import org.robbins.flashcards.facade.TagFacade;
import org.robbins.tests.BaseIntegrationTest;
import org.robbins.tests.IntegrationTest;
Expand All @@ -30,7 +31,7 @@ public class DefaultTagFacadeIT extends BaseIntegrationTest {
private static String TAG_NAME = "tag1";

@Test
public void findByName() {
public void findByName() throws ServiceException {
TagDto result = tagFacade.findByName(TAG_NAME);
assertThat(result, is(TagDto.class));
assertThat(result.getName(), is(TAG_NAME));
Expand Down
10 changes: 10 additions & 0 deletions FlashCards_Service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
<artifactId>FlashCards_Domain</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.robbins.flashcards</groupId>
<artifactId>FlashCards_Repository</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@

package org.robbins.flashcards.facade.base;

import java.util.List;
import java.util.Set;
package org.robbins.flashcards.conversion;

import org.robbins.flashcards.exceptions.ServiceException;
import org.robbins.flashcards.service.base.GenericJpaService;

public interface CrudFacade<D, E> {
import java.util.List;
import java.util.Set;

GenericJpaService<E, Long> getService();
public interface DtoConverter<D, E> {

D getDto(E entity) throws ServiceException;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.robbins.flashcards.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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.robbins.flashcards.conversion.impl;


import org.robbins.flashcards.conversion.DtoConverter;
import org.robbins.flashcards.dto.FlashCardDto;
import org.robbins.flashcards.exceptions.ServiceException;
import org.robbins.flashcards.model.FlashCard;
import org.robbins.flashcards.service.util.DtoUtil;
import org.springframework.stereotype.Component;

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

@Component("flashcardDtoConverter")
public class DefaultFlashcardDtoConverter extends AbstractDtoConverter implements DtoConverter<FlashCardDto, FlashCard> {
@Override
public FlashCardDto getDto(final FlashCard entity) throws ServiceException {
return getDto(entity, null);
}

@Override
public FlashCardDto getDto(final FlashCard entity, final Set<String> fields)
throws ServiceException {
FlashCardDto flashCardDto = getMapper().map(entity, FlashCardDto.class);
DtoUtil.filterFields(flashCardDto, fields);
return flashCardDto;
}

@Override
public FlashCard getEntity(final FlashCardDto dto) {
return getMapper().map(dto, FlashCard.class);
}

@Override
public List<FlashCardDto> getDtos(final List<FlashCard> entities,
final Set<String> fields)
throws ServiceException {
List<FlashCardDto> dtos = new ArrayList<>();
for (FlashCard entity : entities) {
dtos.add(getDto(entity));
}
return dtos;
}

@Override
public List<FlashCard> getEtnties(final List<FlashCardDto> dtos) {
List<FlashCard> entities = new ArrayList<>();
for (FlashCardDto dto : dtos) {
entities.add(getEntity(dto));
}
return entities;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.robbins.flashcards.conversion.impl;

import org.robbins.flashcards.conversion.DtoConverter;
import org.robbins.flashcards.dto.TagDto;
import org.robbins.flashcards.exceptions.ServiceException;
import org.robbins.flashcards.model.Tag;
import org.robbins.flashcards.service.util.DtoUtil;
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, Tag> {

@Override
public TagDto getDto(final Tag entity) throws ServiceException {
return getDto(entity, null);
}

@Override
public TagDto getDto(final Tag entity, final Set<String> fields)
throws ServiceException {
TagDto tagDto = getMapper().map(entity, TagDto.class);
DtoUtil.filterFields(tagDto, fields);
return tagDto;
}

@Override
public Tag getEntity(final TagDto dto) {
return getMapper().map(dto, Tag.class);
}

@Override
public List<TagDto> getDtos(final List<Tag> entities, final Set<String> fields)
throws ServiceException {
List<TagDto> dtos = new ArrayList<>();
for (Tag entity : entities) {
dtos.add(getDto(entity, fields));
}
return dtos;
}

@Override
public List<Tag> getEtnties(final List<TagDto> dtos) {
List<Tag> entities = new ArrayList<>();
for (TagDto dto : dtos) {
entities.add(getEntity(dto));
}
return entities;
}
}
Loading

0 comments on commit e757d70

Please sign in to comment.