-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Application Event listeners for debugging. Add H2 DB for Sprint 0 Add first Kdoc Entity Add sample schema and data for testing
- Loading branch information
Showing
14 changed files
with
357 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,4 @@ build/ | |
/.mvn/ | ||
/mvnw | ||
/mvnw.cmd | ||
/secrets/ |
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,14 @@ | ||
FROM maven:3.8.4-openjdk-11-slim as BUILDER | ||
ARG VERSION=0.0.1-SNAPSHOT | ||
WORKDIR /build/ | ||
COPY pom.xml /build/ | ||
COPY src /build/src/ | ||
|
||
RUN mvn clean package | ||
COPY target/Klutter-${VERSION}.jar target/application.jar | ||
|
||
FROM openjdk:11.0.8-jre-slim | ||
WORKDIR /app/ | ||
|
||
COPY --from=BUILDER /build/target/application.jar /app/ | ||
CMD java -jar /app/application.jar |
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
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
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
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 |
---|---|---|
@@ -1,16 +1,33 @@ | ||
package io.klutter; | ||
|
||
import io.klutter.dao.KdocRepository; | ||
import io.klutter.entity.Kdoc; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.context.event.ApplicationReadyEvent; | ||
import org.springframework.context.event.EventListener; | ||
|
||
//Add the scanBasePackages parameter to the annotation as I added my services in | ||
//separate packages so, they need to be configured on application start. | ||
@SpringBootApplication(scanBasePackages = {"io.klutter.declutterservice", "io.klutter.pdfservice"} ) | ||
@SpringBootApplication(scanBasePackages = {"io.klutter.declutterservice", "io.klutter.pdfservice", "io.klutter.dao"} ) | ||
public class KlutterApplication { | ||
|
||
private final KdocRepository kdocRepository; | ||
|
||
public KlutterApplication(KdocRepository kdocRepository) { | ||
this.kdocRepository = kdocRepository; | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(KlutterApplication.class, args); | ||
System.out.println("Application Running: http://localhost:8080"); | ||
} | ||
|
||
// So I can visualize data access working. | ||
// So I can wait for Spring to set up the DB before I start playing around with DB. | ||
@EventListener(ApplicationReadyEvent.class) | ||
public void EventListenerExecute() { | ||
Iterable<Kdoc> kdocs = this.kdocRepository.findAll(); | ||
kdocs.forEach(System.out::println); | ||
} | ||
|
||
} |
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,22 @@ | ||
package io.klutter; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import springfox.documentation.builders.PathSelectors; | ||
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
|
||
@Configuration | ||
public class SpringFoxConfig { | ||
|
||
@Bean | ||
public Docket api() { | ||
return new Docket(DocumentationType.SWAGGER_2) | ||
.select() | ||
.apis(RequestHandlerSelectors.any()) | ||
.paths(PathSelectors.any()) | ||
.build(); | ||
} | ||
|
||
} |
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,12 @@ | ||
package io.klutter.dao; | ||
|
||
import io.klutter.entity.Kdoc; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface KdocRepository extends CrudRepository<Kdoc, Long> { | ||
|
||
// Additional non-CRUD related methods. | ||
|
||
} |
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,134 @@ | ||
package io.klutter.entity; | ||
|
||
import javax.persistence.*; | ||
import java.io.Serializable; | ||
|
||
@Entity | ||
@Table(name = "Kdoc") | ||
public class Kdoc implements Serializable { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "id") | ||
private Long id; | ||
|
||
@Column(name = "title") | ||
private String title; | ||
|
||
@Column(name = "url") | ||
private String url; | ||
|
||
@Column(name = "excerpt") | ||
private String excerpt; | ||
|
||
@Column(name = "byline") | ||
private String byline; | ||
|
||
@Column(name = "content") | ||
private String content; | ||
|
||
@Column(name = "ease") | ||
private Float ease; | ||
|
||
@Column(name = "grade") | ||
private Float grade; | ||
|
||
@Column(name = "pdf") | ||
@Lob | ||
private String pdf; | ||
|
||
|
||
public Kdoc() { | ||
} | ||
|
||
public Kdoc(String url, String title, String excerpt, String byline, String content, Float ease, Float grade, String pdf) { | ||
this.title = title; | ||
this.url = url; | ||
this.excerpt = excerpt; | ||
this.byline = byline; | ||
this.content = content; | ||
this.ease = ease; | ||
this.grade = grade; | ||
this.pdf = pdf; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public String getUrl() { return url;} | ||
|
||
public void setUrl(String url) { this.url = url; } | ||
|
||
public String getExcerpt() { | ||
return excerpt; | ||
} | ||
|
||
public void setExcerpt(String excerpt) { | ||
this.excerpt = excerpt; | ||
} | ||
|
||
public String getByline() { | ||
return byline; | ||
} | ||
|
||
public void setByline(String byline) { | ||
this.byline = byline; | ||
} | ||
|
||
public String getContent() { | ||
return content; | ||
} | ||
|
||
public void setContent(String content) { | ||
this.content = content; | ||
} | ||
|
||
public Float getEase() { | ||
return ease; | ||
} | ||
|
||
public void setEase(Float ease) { | ||
this.ease = ease; | ||
} | ||
|
||
public Float getGrade() { | ||
return grade; | ||
} | ||
|
||
public void setGrade(Float grade) { | ||
this.grade = grade; | ||
} | ||
|
||
public String getPdf() { | ||
return pdf; | ||
} | ||
|
||
public void setPdf(String pdf) { | ||
this.pdf = pdf; | ||
} | ||
|
||
|
||
@Override | ||
public String toString() { | ||
return "Kdoc{" + | ||
"id=" + id + | ||
", title='" + title + '\'' + | ||
", url='" + url + '\'' + | ||
", excerpt='" + excerpt + '\'' + | ||
", byline='" + byline + '\'' + | ||
", content='" + content + '\'' + | ||
", ease=" + ease + | ||
", grade=" + grade + | ||
", pdf='" + pdf + '\'' + | ||
'}'; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/io/klutter/textanalytics/TextAnalyticsService.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,8 @@ | ||
package io.klutter.textanalytics; | ||
|
||
|
||
// Encapsulation of 3rd party API from Azure. This API tends to change over time (typical MS) | ||
// this way, I can isolate the impacteded code if something changes. | ||
|
||
public class TextAnalyticsService { | ||
} |
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 |
---|---|---|
@@ -1 +1,14 @@ | ||
logging.level.org.hibernate.tool.hbm2ddl=DEBUG | ||
logging.level.org.hibernate.SQL=DEBUG | ||
|
||
# So Swagger doesn't give out. | ||
spring.mvc.pathmatch.matching-strategy=ant_path_matcher | ||
|
||
|
||
# ToDo: Remove for production | ||
# For logging H2 during dev. | ||
logging.level.org.springframework.jdbc.datasource.init.ScriptUtils=debug | ||
|
||
# Tell JPA that I'll handle the schema, just connect to the DB. | ||
spring.jpa.hibernate.ddl-auto=none | ||
|
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,2 @@ | ||
server: | ||
port: 8080 |
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,3 @@ | ||
spring: | ||
application: | ||
name: Klutter |
Oops, something went wrong.