From 63f9a149daa86500f148ff1f845806ab2c440068 Mon Sep 17 00:00:00 2001 From: Zhenia Trochun Date: Wed, 9 May 2018 22:08:11 +0300 Subject: [PATCH] twitter users integrated with db --- .../GoogleBookResponseToBookConverter.java | 10 ++++++++-- src/main/resources/application.properties | 20 +++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/yevhenii/kpi/readmore/api/google/converter/GoogleBookResponseToBookConverter.java b/src/main/java/com/yevhenii/kpi/readmore/api/google/converter/GoogleBookResponseToBookConverter.java index 216f2ed..8bb23d6 100644 --- a/src/main/java/com/yevhenii/kpi/readmore/api/google/converter/GoogleBookResponseToBookConverter.java +++ b/src/main/java/com/yevhenii/kpi/readmore/api/google/converter/GoogleBookResponseToBookConverter.java @@ -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 { @@ -32,7 +33,7 @@ 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)) @@ -40,6 +41,11 @@ public Book apply(GoogleBookResponse googleBookResponse) { .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()) || diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f5b0a27..ca12156 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -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 @@ -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/