Skip to content

Commit

Permalink
twitter users integrated with db
Browse files Browse the repository at this point in the history
  • Loading branch information
ZheniaTrochun committed May 9, 2018
1 parent 54538f5 commit 63f9a14
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
import com.yevhenii.kpi.readmore.api.google.model.VolumeInfo;
import com.yevhenii.kpi.readmore.model.Book;
import com.yevhenii.kpi.readmore.utils.properties.AppPropertyHolder;
//import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Objects;
import java.util.function.Function;

//import org.apache.logging.log4j.util.Strings;

@Component
public class GoogleBookResponseToBookConverter implements Function<GoogleBookResponse, Book> {

Expand All @@ -32,14 +33,19 @@ public Book apply(GoogleBookResponse googleBookResponse) {
return Book
.builder()
.name(volumeInfo.getTitle())
.author(String.join(", ", volumeInfo.getAuthors()))
.author(constructAuthor(volumeInfo))
.genre(volumeInfo.getMainCategory())
.imageUrl(constructImage(volumeInfo))
.year(constructYear(volumeInfo))
.description(volumeInfo.getDescription())
.build();
}

private String constructAuthor(VolumeInfo volumeInfo) {
return Objects.isNull(volumeInfo.getAuthors()) ?
"" : String.join(", ", volumeInfo.getAuthors());
}

private Integer constructYear(VolumeInfo volumeInfo) {
if (Objects.isNull(volumeInfo) ||
Objects.isNull(volumeInfo.getPublishedDate()) ||
Expand Down
20 changes: 10 additions & 10 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

# H2 settings
spring.datasource.url=jdbc:h2:file:./db/testReadMore
spring.datasource.username="sa"
spring.datasource.password=""
spring.datasource.driver-class-name=org.h2.Driver
#spring.datasource.url=jdbc:h2:file:./db/testReadMore
#spring.datasource.username="sa"
#spring.datasource.password=""
#spring.datasource.driver-class-name=org.h2.Driver

#spring.datasource.url=jdbc:postgresql://localhost/readmore
#spring.datasource.username=postgres
Expand All @@ -14,12 +14,12 @@ spring.datasource.driver-class-name=org.h2.Driver


# Postgres settings
#spring.datasource.username=ujwbldnbutexuo
#spring.datasource.password=ef395725cd42e661c696fdbf41b3ed81a1e5a84b0a2967402a5dcad0dd9f466f
#spring.datasource.url=jdbc:postgresql://ec2-54-75-239-237.eu-west-1.compute.amazonaws.com:5432/d6fsprddobqk7a?sslmode=require
#spring.datasource.driver-class-name=org.postgresql.Driver
#spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
#spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.username=ujwbldnbutexuo
spring.datasource.password=ef395725cd42e661c696fdbf41b3ed81a1e5a84b0a2967402a5dcad0dd9f466f
spring.datasource.url=jdbc:postgresql://ec2-54-75-239-237.eu-west-1.compute.amazonaws.com:5432/d6fsprddobqk7a?sslmode=require
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect


# https://read-more.herokuapp.com/
Expand Down

0 comments on commit 63f9a14

Please sign in to comment.