-
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 H2 DB for testing Remove future services for clarity Enable H2 console Swap Kdoc crudrepository implementation for a JpaRepository implementation
- Loading branch information
Showing
14 changed files
with
175 additions
and
122 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 |
---|---|---|
|
@@ -33,7 +33,6 @@ build/ | |
.vscode/ | ||
/bak/ | ||
/.mvn/ | ||
/.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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.klutter.controllers; | ||
|
||
|
||
import io.klutter.models.Kdoc; | ||
import io.klutter.services.KdocService; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/kdocs") | ||
public class KdocController { | ||
|
||
private final KdocService kdocService; | ||
|
||
|
||
public KdocController(KdocService kdocService) { | ||
this.kdocService = kdocService; | ||
} | ||
|
||
@GetMapping | ||
public List<Kdoc> getAllKdocs(){ | ||
return kdocService.getAllKdocs(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/io/klutter/controllers/KdocRestController.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,27 @@ | ||
package io.klutter.controllers; | ||
|
||
|
||
import io.klutter.models.Kdoc; | ||
import io.klutter.services.KdocService; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/kdocs") | ||
public class KdocRestController { | ||
|
||
private final KdocService kdocService; | ||
|
||
|
||
public KdocRestController(KdocService kdocService) { | ||
this.kdocService = kdocService; | ||
} | ||
|
||
@GetMapping | ||
public List<Kdoc> getAllKdocs(){ | ||
return kdocService.getAllKdocs(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
package io.klutter.data; | ||
|
||
import io.klutter.models.Kdoc; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface KdocRepository extends JpaRepository<Kdoc, Long> { | ||
|
||
// Additional non-CRUD related methods. | ||
|
||
} |
5 changes: 3 additions & 2 deletions
5
src/main/java/io/klutter/entity/Kdoc.java → src/main/java/io/klutter/models/Kdoc.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
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,94 @@ | ||
package io.klutter.services; | ||
|
||
import io.github.bonigarcia.wdm.WebDriverManager; | ||
import io.klutter.data.KdocRepository; | ||
import io.klutter.models.Kdoc; | ||
import io.whelk.flesch.kincaid.ReadabilityCalculator; | ||
import net.dankito.readability4j.Readability4J; | ||
import org.jsoup.Jsoup; | ||
import org.jsoup.nodes.Document; | ||
import org.jsoup.safety.Safelist; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import org.openqa.selenium.chrome.ChromeOptions; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1") | ||
public class KdocService { | ||
|
||
private final KdocRepository kdocRepository; | ||
|
||
public KdocService(KdocRepository kdocRepository) { | ||
this.kdocRepository = kdocRepository; | ||
} | ||
|
||
public List<Kdoc> getAllKdocs(){ | ||
return kdocRepository.findAll(); | ||
} | ||
|
||
// @RequestMapping("/documents") | ||
// public String index() { | ||
// | ||
// String url = "https://realpython.com/python-sockets/"; | ||
// | ||
// // Selenium. Using Selenium because jsoup doesn't handle JS and lazy loading. | ||
// // System.setProperty("webdriver.chrome.driver", "/home/dave/chromedriver"); | ||
// ChromeOptions options = new ChromeOptions();options.addArguments("--headless"); | ||
// //WebDriver driver = new ChromeDriver(options); | ||
// | ||
// // Using Webdriver | ||
// WebDriverManager.chromedriver().setup(); | ||
// WebDriver driver = new ChromeDriver(options); | ||
// | ||
// // ToDo: Receive URL from frontend. | ||
// driver.get(url); | ||
// | ||
// // Get the raw HTML source. | ||
// String html = driver.getPageSource(); | ||
// | ||
// // Parse with Jsoup, so we can work with it.; | ||
// Document doc = Jsoup.parse(html); | ||
// | ||
// // ToDo: Do a bit of sanitization on the HTML before passing to the PDF service. | ||
// String safe = Jsoup.clean(doc.html(), Safelist.basic()); | ||
// | ||
// // Process with the readability4j mozilla readability.js wrapper. | ||
// Readability4J readability4J = new Readability4J(url, doc); | ||
// net.dankito.readability4j.Article article = readability4J.parse(); | ||
// | ||
// // returns extracted content in a <div> element | ||
// String extractedContentHtml = article.getContent(); | ||
// // to get content wrapped in <html> tags and encoding set to UTF-8, see chapter 'Output encoding' | ||
// String extractedContentHtmlWithUtf8Encoding = article.getContentWithUtf8Encoding(); | ||
// String extractedContentPlainText = article.getTextContent(); | ||
// String title = article.getTitle(); | ||
// String byline = article.getByline(); | ||
// String excerpt = article.getExcerpt(); | ||
// | ||
// | ||
// // Get the reading ease score. | ||
// double ease = ReadabilityCalculator.calculateReadingEase(extractedContentPlainText); | ||
// | ||
// // Get the grade level score. | ||
// double grade = ReadabilityCalculator.calculateGradeLevel(extractedContentPlainText); | ||
// | ||
// // Check it's working | ||
// System.out.println(ease + " " + grade); | ||
// | ||
// // Testing the sizing of the document for Azure | ||
//// System.out.println(">>>>>>>>>>>>>>>>>>>>>> " + extractedContentPlainText.length()); | ||
//// System.out.println(">>>>>>>>>>>>>>>>>>>>>> " + WordUtils.wrap(extractedContentPlainText, 40)); | ||
// | ||
// // ToDo: Add user, title, excerpt, byline, content, ease, grade and tag array to model. | ||
// | ||
// // Return the clean HTML | ||
// return extractedContentHtml; | ||
// } | ||
|
||
|
||
} | ||
|
11 changes: 1 addition & 10 deletions
11
...ava/io/klutter/pdfservice/PdfService.java → .../java/io/klutter/services/PdfService.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
8 changes: 0 additions & 8 deletions
8
src/main/java/io/klutter/textanalytics/TextAnalyticsService.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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