diff --git a/pom.xml b/pom.xml index b83ae5174c8869d8bf2b2fd1785e69b60806ed35..ddec5368930dd767259c061f6d32d5da09fd94e5 100644 --- a/pom.xml +++ b/pom.xml @@ -161,14 +161,45 @@ <artifactId>commons-io</artifactId> <version>2.11.0</version> </dependency> +<<<<<<< HEAD </dependencies> +======= + + <dependency> + <groupId>org.mapstruct</groupId> + <artifactId>mapstruct</artifactId> + <version>1.6.3</version> + </dependency> + + </dependencies> + + +>>>>>>> 9e1c76c (Categories of PDF initialized) <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> +<<<<<<< HEAD +======= + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.11.0</version> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>org.mapstruct</groupId> + <artifactId>mapstruct-processor</artifactId> + <version>1.6.3</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> +>>>>>>> 9e1c76c (Categories of PDF initialized) </plugins> </build> diff --git a/script/grobid.sh b/script/grobid.sh new file mode 100644 index 0000000000000000000000000000000000000000..1e54491d57e5e628bf6ace6f7e73147d3a63cfa1 --- /dev/null +++ b/script/grobid.sh @@ -0,0 +1 @@ +docker run --rm --gpus all --init --ulimit core=0 -p 8070:8070 grobid/grobid:0.8.1 \ No newline at end of file diff --git a/src/main/java/com/dre0059/articleprocessor/config/DataInitializer.java b/src/main/java/com/dre0059/articleprocessor/config/DataInitializer.java new file mode 100644 index 0000000000000000000000000000000000000000..5cbbded85869d00b4b55838cd8ec81247269bbc2 --- /dev/null +++ b/src/main/java/com/dre0059/articleprocessor/config/DataInitializer.java @@ -0,0 +1,59 @@ +package com.dre0059.articleprocessor.config; + +import com.dre0059.articleprocessor.model.Category; +import com.dre0059.articleprocessor.repository.CategoryRepository; +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +@Configuration +public class DataInitializer { + + // automaticky sa to vykoná, nie je potrebnĂ© to znovu volaĹĄ + @Bean + public CommandLineRunner init(CategoryRepository categoryRepository) { + return args -> { + if(categoryRepository.count() == 0) { + List<Category> categories = List.of( + new Category("1.4", "Chemical sciences"), + new Category("1.5", "Earth and related environmental sciences"), + new Category("1.6", "Biological sciences"), + new Category("1.7", "Other natural sciences"), + new Category("2.1", "Civil engineering"), + new Category("2.2", "Electrical engineering, electronic engineering, information engineering"), + new Category("2.3", "Mechanical engineering"), + new Category("2.4", "Chemical engineering"), + new Category("2.5", "Materials engineering"), + new Category("2.6", "Medical engineering"), + new Category("2.7", "Environmental engineering"), + new Category("2.8", "Environmental biotechnology"), + new Category("2.9", "Industrial biotechnology"), + new Category("2.10", "Nano-technology"), + new Category("2.11", "Other engineering and technologies"), + new Category("3.2", "Clinical medicine"), + new Category("3.3", "Health sciences"), + new Category("4.1", "Agriculture, forestry, and fisheries"), + new Category("4.2", "Animal and dairy science"), + new Category("4.3", "Veterinary science"), + new Category("4.5", "Other agricultural sciences"), + new Category("5.1", "Psychology and cognitive sciences"), + new Category("5.2", "Economics and business"), + new Category("5.3", "Education"), + new Category("5.4", "Sociology"), + new Category("5.5", "Law"), + new Category("5.6", "Political science"), + new Category("5.7", "Social and economic geography"), + new Category("5.8", "Media and communication"), + new Category("5.9", "Other social sciences"), + new Category("6.1", "History and archaeology"), + new Category("6.2", "Languages and literature"), + new Category("6.4", "Arts"), + new Category("6.5", "Other Humanities and the Arts") + ); + categoryRepository.saveAll(categories); + } + }; + } +} diff --git a/src/main/java/com/dre0059/articleprocessor/controller/DocumentController.java b/src/main/java/com/dre0059/articleprocessor/controller/DocumentController.java new file mode 100644 index 0000000000000000000000000000000000000000..5529c3aa90eb357b528987733cc09945761cd61c --- /dev/null +++ b/src/main/java/com/dre0059/articleprocessor/controller/DocumentController.java @@ -0,0 +1,52 @@ +package com.dre0059.articleprocessor.controller; + +import com.dre0059.articleprocessor.dto.DocumentDto; +import com.dre0059.articleprocessor.dto.SimpleDocumentDto; +import com.dre0059.articleprocessor.service.DocumentService; +import java.util.List; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller() +@RequestMapping("/api/document") +public class DocumentController { + + private final DocumentService documentService; + + + public DocumentController(DocumentService documentService) { + this.documentService = documentService; + } + + @GetMapping("/{id}") + public ResponseEntity<DocumentDto> getDocumentById(@PathVariable Long id) { + return ResponseEntity.ok(documentService.getDocumentById(id)); + } + + @GetMapping("/references/{id}") + public ResponseEntity<List<SimpleDocumentDto>> getReferencesFromDocument(@PathVariable Long id) { + return ResponseEntity.ok(documentService.getDocumentReferences(id)); + } + + @GetMapping("/view/{id}") + public String viewPdf(Model model, @PathVariable("id") Long id) { + var references = documentService.getDocumentReferences(id); + + model.addAttribute("references", references); + + return "view-pdf"; + } + + @GetMapping("/view") + public String viewPdf(Model model) { + var references = documentService.getAllReferences(); + + model.addAttribute("references", references); + + return "view-all"; + } +} diff --git a/src/main/java/com/dre0059/articleprocessor/controller/FileUploadController.java b/src/main/java/com/dre0059/articleprocessor/controller/FileUploadController.java index 2b3dad959cd065826aad64bae262839f7a86ae1e..d727d088420f8bd13a86d10e728db9da32581dd4 100644 --- a/src/main/java/com/dre0059/articleprocessor/controller/FileUploadController.java +++ b/src/main/java/com/dre0059/articleprocessor/controller/FileUploadController.java @@ -1,6 +1,11 @@ package com.dre0059.articleprocessor.controller; import com.dre0059.articleprocessor.GrobidClient; +<<<<<<< HEAD +======= +import com.dre0059.articleprocessor.model.Category; +import com.dre0059.articleprocessor.repository.CategoryRepository; +>>>>>>> 9e1c76c (Categories of PDF initialized) import com.dre0059.articleprocessor.service.HeaderService; import com.dre0059.articleprocessor.service.ReferenceService; @@ -13,6 +18,11 @@ import org.springframework.web.multipart.MultipartFile; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +<<<<<<< HEAD +======= +import java.util.List; +import java.util.Optional; +>>>>>>> 9e1c76c (Categories of PDF initialized) @Controller @RequestMapping("/api/grobid") @@ -20,26 +30,49 @@ public class FileUploadController { private final GrobidClient grobidClient; private final HeaderService headerService; private final ReferenceService referenceService; +<<<<<<< HEAD public FileUploadController(GrobidClient grobidClient, HeaderService headerService, ReferenceService referenceService) { this.grobidClient = grobidClient; this.headerService = headerService; this.referenceService = referenceService; +======= + private final CategoryRepository categoryRepository; + + public FileUploadController(GrobidClient grobidClient, HeaderService headerService, ReferenceService referenceService, CategoryRepository categoryRepository) { + this.grobidClient = grobidClient; + this.headerService = headerService; + this.referenceService = referenceService; + this.categoryRepository = categoryRepository; +>>>>>>> 9e1c76c (Categories of PDF initialized) } @GetMapping("/upload") public String showUploadForm(Model model) { +<<<<<<< HEAD +======= + List<Category> categories = categoryRepository.findAll(); + model.addAttribute("categories", categories); +>>>>>>> 9e1c76c (Categories of PDF initialized) return "upload"; // vracia upload.html } @PostMapping("/upload") @ResponseBody +<<<<<<< HEAD public ResponseEntity<String> handleFileUpload(@RequestParam("file") MultipartFile file) { +======= + public ResponseEntity<String> handleFileUpload(@RequestParam("file") MultipartFile file, @RequestParam("category") String category) { +>>>>>>> 9e1c76c (Categories of PDF initialized) if (file.isEmpty()) { return ResponseEntity.badRequest().body("No file uploaded!"); } System.out.println("Received file: " + file.getOriginalFilename()); +<<<<<<< HEAD +======= + System.out.println("Received category: " + category); +>>>>>>> 9e1c76c (Categories of PDF initialized) try { // Vytvorenie doÄŤasnĂ©ho sĂşboru @@ -55,11 +88,30 @@ public class FileUploadController { String header = grobidClient.processHeader(tmpFile); String references = grobidClient.processReferences(tmpFile); +<<<<<<< HEAD headerService.processHeader(header); referenceService.extractReferences(references); //System.out.println(header); System.out.println(references); +======= + String categoryId = category.substring(0, 3); + Optional<Category> categoryOptional = categoryRepository.findById(categoryId); + + System.out.println("ID category is : " + categoryId); + System.out.println("Optional category is : " + categoryOptional); + if (category.isEmpty()) { + return ResponseEntity.badRequest().body("Invalid category ID!"); + } + + headerService.processHeader(header, categoryOptional); + referenceService.extractReferences(references); + + //System.out.println(header); + //System.out.println(references); + + +>>>>>>> 9e1c76c (Categories of PDF initialized) tmpFile.delete(); diff --git a/src/main/java/com/dre0059/articleprocessor/dto/DocumentDto.java b/src/main/java/com/dre0059/articleprocessor/dto/DocumentDto.java new file mode 100644 index 0000000000000000000000000000000000000000..8f97cc0a80cb3e3ff89184df8b13b46fff9ee5d2 --- /dev/null +++ b/src/main/java/com/dre0059/articleprocessor/dto/DocumentDto.java @@ -0,0 +1,76 @@ +package com.dre0059.articleprocessor.dto; + +public class DocumentDto { + private Long id; + private String title; + private Integer publicationYear; + private String doi; + private String abstractText; + private String status; + private String publisher; + private String target; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getPublicationYear() { + return publicationYear; + } + + public void setPublicationYear(Integer publicationYear) { + this.publicationYear = publicationYear; + } + + public String getDoi() { + return doi; + } + + public void setDoi(String doi) { + this.doi = doi; + } + + public String getAbstractText() { + return abstractText; + } + + public void setAbstractText(String abstractText) { + this.abstractText = abstractText; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getPublisher() { + return publisher; + } + + public void setPublisher(String publisher) { + this.publisher = publisher; + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } +} diff --git a/src/main/java/com/dre0059/articleprocessor/dto/SimpleDocumentDto.java b/src/main/java/com/dre0059/articleprocessor/dto/SimpleDocumentDto.java new file mode 100644 index 0000000000000000000000000000000000000000..9ed6b674f30bd38a295e87fe873303f1fc7dccbc --- /dev/null +++ b/src/main/java/com/dre0059/articleprocessor/dto/SimpleDocumentDto.java @@ -0,0 +1,26 @@ +package com.dre0059.articleprocessor.dto; + +public class SimpleDocumentDto { + private Long id; + private String title; + + public String getLink() { + return "/api/document/"+getId(); + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} diff --git a/src/main/java/com/dre0059/articleprocessor/mapper/DocumentMapper.java b/src/main/java/com/dre0059/articleprocessor/mapper/DocumentMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..2a5516c35ff4603e90d1164743deff8f90224afe --- /dev/null +++ b/src/main/java/com/dre0059/articleprocessor/mapper/DocumentMapper.java @@ -0,0 +1,16 @@ +package com.dre0059.articleprocessor.mapper; + +import com.dre0059.articleprocessor.dto.DocumentDto; +import com.dre0059.articleprocessor.dto.SimpleDocumentDto; +import com.dre0059.articleprocessor.model.Dokument; +import java.util.List; +import org.mapstruct.Mapper; + +@Mapper(componentModel = "spring") +public interface DocumentMapper { + + DocumentDto toDocumentDto(Dokument entity); + SimpleDocumentDto toSimpleDocument(Dokument entity); + + List<SimpleDocumentDto> toSimpleDocumentList(List<Dokument> entities); +} diff --git a/src/main/java/com/dre0059/articleprocessor/model/Category.java b/src/main/java/com/dre0059/articleprocessor/model/Category.java new file mode 100644 index 0000000000000000000000000000000000000000..22deb9fdef4d6689f63f45607fd0be6873771755 --- /dev/null +++ b/src/main/java/com/dre0059/articleprocessor/model/Category.java @@ -0,0 +1,40 @@ +package com.dre0059.articleprocessor.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +@Entity +@Table(name = "categories") + +public class Category { + @Id + private String id; + + @Column(nullable = false, unique = true) + private String name; + + public Category(String id, String name) { + this.id = id; + this.name = name; + } + + public Category() {} + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public void setId(String id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/dre0059/articleprocessor/model/Dokument.java b/src/main/java/com/dre0059/articleprocessor/model/Dokument.java index 1032698a0ad0dc9d8e7300f90c8c6ca446afe6ed..27897d9c83d20eac631041c39dea5d289f314b3b 100644 --- a/src/main/java/com/dre0059/articleprocessor/model/Dokument.java +++ b/src/main/java/com/dre0059/articleprocessor/model/Dokument.java @@ -6,8 +6,11 @@ import org.hibernate.annotations.Cascade; import java.util.ArrayList; import java.util.List; +<<<<<<< HEAD // TODO : int / boolean - ÄŤi je PDF nahratĂ© alebo je to dokument len z referencie // 1. references - +======= +>>>>>>> 9e1c76c (Categories of PDF initialized) @Entity @Table(name = "documents") @@ -24,6 +27,13 @@ public class Dokument { private Integer publicationYear; private String doi; +<<<<<<< HEAD +======= + @ManyToOne + @JoinColumn(name = "category_id") + private Category category; + +>>>>>>> 9e1c76c (Categories of PDF initialized) // @Lob for huge text //@Column(name = "abstractText", columnDefinition = "TEXT") //private String abstractText; @@ -69,6 +79,7 @@ public class Dokument { public void setAuthors(List<Author> authors) { this.authors = authors; } public void setTitle(String title) { this.title = title; } public void setTarget(String target) { this.target = target; } +<<<<<<< HEAD public void setPublicationYear(Integer publicationYear) { this.publicationYear = publicationYear; @@ -89,4 +100,22 @@ public class Dokument { public void setReferences(List<Reference> references) { this.references = references; } +======= + public void setPublicationYear(Integer publicationYear) { + this.publicationYear = publicationYear; + } + public void setDoi(String doi) { + this.doi = doi; + } + public void setStatus(String status) { + this.status = status; + } + public void setPublisher(String publisher) { + this.publisher = publisher; + } + public void setReferences(List<Reference> references) { + this.references = references; + } + public void setCategory(Category category) { this.category = category;} +>>>>>>> 9e1c76c (Categories of PDF initialized) } diff --git a/src/main/java/com/dre0059/articleprocessor/repository/CategoryRepository.java b/src/main/java/com/dre0059/articleprocessor/repository/CategoryRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..823a39dae8a0bc6a415a8ce643a2066fa9d204e2 --- /dev/null +++ b/src/main/java/com/dre0059/articleprocessor/repository/CategoryRepository.java @@ -0,0 +1,10 @@ +package com.dre0059.articleprocessor.repository; + +import com.dre0059.articleprocessor.model.Category; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CategoryRepository extends JpaRepository<Category, String> { + +} diff --git a/src/main/java/com/dre0059/articleprocessor/repository/DocumentRepository.java b/src/main/java/com/dre0059/articleprocessor/repository/DocumentRepository.java index 6a102738f6775f1244cb6eda2b067ac7f03063a8..849fe54ba8e2beed437dc77e11336eaf6300ec77 100644 --- a/src/main/java/com/dre0059/articleprocessor/repository/DocumentRepository.java +++ b/src/main/java/com/dre0059/articleprocessor/repository/DocumentRepository.java @@ -32,6 +32,19 @@ public interface DocumentRepository extends JpaRepository<Dokument, Long> { ) Optional<Dokument> findByTitleAndAuthorsIn(@Param("title") String title, @Param("lastNames") List<String> lastNames); +<<<<<<< HEAD +======= + + @Query( + """ + SELECT r.toDocument FROM Dokument d + JOIN d.references r + WHERE d.id = :id + """ + ) + List<Dokument> getReferencedDocumentsById(@Param("id") Long id); + +>>>>>>> 9e1c76c (Categories of PDF initialized) } /* diff --git a/src/main/java/com/dre0059/articleprocessor/service/DocumentService.java b/src/main/java/com/dre0059/articleprocessor/service/DocumentService.java index 48f8a1f6c895252a2c23a5d3c0e3968af8553825..24292a5ef5c7a349be40125daa0107501ce2d985 100644 --- a/src/main/java/com/dre0059/articleprocessor/service/DocumentService.java +++ b/src/main/java/com/dre0059/articleprocessor/service/DocumentService.java @@ -1,9 +1,16 @@ package com.dre0059.articleprocessor.service; +<<<<<<< HEAD +======= +import com.dre0059.articleprocessor.dto.DocumentDto; +import com.dre0059.articleprocessor.dto.SimpleDocumentDto; +import com.dre0059.articleprocessor.mapper.DocumentMapper; +>>>>>>> 9e1c76c (Categories of PDF initialized) import com.dre0059.articleprocessor.repository.*; import com.dre0059.articleprocessor.model.*; import jakarta.transaction.Transactional; +<<<<<<< HEAD import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -23,4 +30,44 @@ public class DocumentService { Dokument dok = new Dokument(); return dok; } +======= +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class DocumentService { + + private final DocumentMapper documentMapper; + private final DocumentRepository documentRepository; + private final AuthorRepository authorRepository; + + public DocumentService(DocumentMapper documentMapper, DocumentRepository documentRepository, + AuthorRepository authorRepository) { + this.documentMapper = documentMapper; + this.documentRepository = documentRepository; + this.authorRepository = authorRepository; + } + + @Transactional + public DocumentDto getDocumentById(Long id) { + return documentMapper.toDocumentDto(documentRepository.findById(id).orElse(null)); + } + + @Transactional + public List<SimpleDocumentDto> getDocumentReferences(Long id) { + return documentMapper.toSimpleDocumentList(documentRepository.getReferencedDocumentsById(id)); + } + + @Transactional + public List<SimpleDocumentDto> getAllReferences() { + return documentMapper.toSimpleDocumentList(documentRepository.findAll()); + } + + @Transactional + public Dokument saveDocument(Dokument document) { + Dokument dok = new Dokument(); + return dok; + } +>>>>>>> 9e1c76c (Categories of PDF initialized) } diff --git a/src/main/java/com/dre0059/articleprocessor/service/HeaderService.java b/src/main/java/com/dre0059/articleprocessor/service/HeaderService.java index c4f8e5eaeec5654421ae19895e37b10f71b02d3e..b4b865f18f046db2d59552b4a225d0eedfbdc25f 100644 --- a/src/main/java/com/dre0059/articleprocessor/service/HeaderService.java +++ b/src/main/java/com/dre0059/articleprocessor/service/HeaderService.java @@ -1,8 +1,15 @@ package com.dre0059.articleprocessor.service; import com.dre0059.articleprocessor.model.Author; +<<<<<<< HEAD import com.dre0059.articleprocessor.model.Dokument; import com.dre0059.articleprocessor.repository.AuthorRepository; +======= +import com.dre0059.articleprocessor.model.Category; +import com.dre0059.articleprocessor.model.Dokument; +import com.dre0059.articleprocessor.repository.AuthorRepository; +import com.dre0059.articleprocessor.repository.CategoryRepository; +>>>>>>> 9e1c76c (Categories of PDF initialized) import com.dre0059.articleprocessor.repository.DocumentRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -24,6 +31,10 @@ public class HeaderService { private final DocumentRepository documentRepository; private final AuthorRepository authorRepository; private final ReferenceService referenceService; +<<<<<<< HEAD +======= + private final CategoryRepository categoryRepository; +>>>>>>> 9e1c76c (Categories of PDF initialized) //public Dokument(String title, Integer year, String doi, String abstractText, Integer pages, String publisher) { @@ -36,6 +47,7 @@ public class HeaderService { private List<Author> authorList = new ArrayList<>(); private String author; +<<<<<<< HEAD @Autowired public HeaderService(DocumentRepository documentRepository, AuthorRepository authorRepository, ReferenceService referenceService) { @@ -45,6 +57,19 @@ public class HeaderService { } public void processHeader(String header){ +======= + private Category category; + + @Autowired + public HeaderService(DocumentRepository documentRepository, AuthorRepository authorRepository, ReferenceService referenceService, CategoryRepository categoryRepository) { + this.documentRepository = documentRepository; + this.authorRepository = authorRepository; + this.referenceService = referenceService; + this.categoryRepository = categoryRepository; + } + + public void processHeader(String header, Optional<Category> category) { +>>>>>>> 9e1c76c (Categories of PDF initialized) this.title = this.parseHeaderFields(header, "title"); if(!this.parseHeaderFields(header, "doi").equals("Not found")){ @@ -74,7 +99,10 @@ public class HeaderService { System.out.println("Author list before checking duplicity: " + authorList); System.out.println("Author last names before checking duplicity: " + authorLastNames); +<<<<<<< HEAD // tu dostávam error : +======= +>>>>>>> 9e1c76c (Categories of PDF initialized) boolean headerDuplicity = documentRepository.existsByTitleAndAuthorsIn(title, authorLastNames); // check duplicity of the document @@ -86,8 +114,18 @@ public class HeaderService { List<Author> savedAuthors = authorRepository.saveAll(authorList); Dokument dokument = new Dokument(title, year, doi, publisher, "PDF"); +<<<<<<< HEAD dokument.setAuthors(savedAuthors); this.documentRepository.save(dokument); +======= + //dokument.setCategory(category.get()); + dokument.setAuthors(savedAuthors); + + System.out.println("Category: " + category); + category.ifPresent(dokument::setCategory); + + this.documentRepository.save(dokument); // output : Optional.empty +>>>>>>> 9e1c76c (Categories of PDF initialized) // set the document, which has the list of references referenceService.setFromDocument(dokument); diff --git a/src/main/java/com/dre0059/articleprocessor/service/ReferenceService.java b/src/main/java/com/dre0059/articleprocessor/service/ReferenceService.java index 74cfea52ded85ecee72f5603e20ca6e33079b2d6..861dab3c32cab58f7b4372a74503d0bf1f63e1cc 100644 --- a/src/main/java/com/dre0059/articleprocessor/service/ReferenceService.java +++ b/src/main/java/com/dre0059/articleprocessor/service/ReferenceService.java @@ -23,6 +23,7 @@ import java.io.InputStream; import java.io.StringReader; import java.util.*; +<<<<<<< HEAD // TODO : // 1. uloĹľiĹĄ prepojenie toDocument a fromDocument do tabuÄľky referencie // 2. vytiahnuĹĄ orderNumber z referencie (toto riešiĹĄ cez GROBID) @@ -31,6 +32,8 @@ import java.util.*; // 5. ak uĹľ bolo PDF raz uloĹľenĂ©, uložà sa mi "null" ÄŤlánok, prepojenĂ˝ s autormi - VYRIESIT +======= +>>>>>>> 9e1c76c (Categories of PDF initialized) @Service public class ReferenceService { diff --git a/src/main/resources/templates/upload.html b/src/main/resources/templates/upload.html index dd6b70aa386dae9a5967f26cbcd63f1990497e24..3391d1b41b3a9723753ced49598283ce7fb76403 100644 --- a/src/main/resources/templates/upload.html +++ b/src/main/resources/templates/upload.html @@ -19,10 +19,24 @@ <h1>Upload your PDF</h1> <!-- formular na nahravanie PDF --> +<<<<<<< HEAD <form action="/api/grobid/upload" method="post" id = "uploadForm" enctype = "multipart/form-data"> <label for="fileInput">Choose PDF file:</label> <input type = "file" id = "fileInput" name = "file" accept="application/pdf"> +======= + <form action="/api/grobid/upload" method="post" id = "uploadForm" enctype = "multipart/form-data"> + <label for="fileInput">Choose PDF file:</label> + <input type = "file" id = "fileInput" name = "file" accept="application/pdf"> + + <label for="category">Select Category:</label> + <select id="category" name="category"> + <option value="1.4 Chemical sciences">1.4 Chemical sciences</option> + <option value="1.5 Earth and related environmental sciences">1.5 Earth and related environmental sciences</option> + <option value="1.6 Biological sciences">1.6 Biological sciences</option> + </select> + +>>>>>>> 9e1c76c (Categories of PDF initialized) <button type = "submit">Upload & Process the PDF</button> </form> @@ -37,6 +51,11 @@ <pre id = "json-output"></pre> </div> +<<<<<<< HEAD +======= + <!--<a href="/api/document/22">click here</a> --> + +>>>>>>> 9e1c76c (Categories of PDF initialized) <!-- .js na zobrazenie PDF --> <script> document.getElementById('fileInput').addEventListener('change', function(event){ @@ -54,6 +73,10 @@ $('#uploadForm').submit(function(event) { event.preventDefault(); const fileInput = $('#fileInput')[0].files[0]; +<<<<<<< HEAD +======= + const category = $('#category').val(); // ZĂskanie vybranej kategĂłrie +>>>>>>> 9e1c76c (Categories of PDF initialized) if(!fileInput){ alert("Please select a PDF file first."); @@ -62,6 +85,10 @@ const formData = new FormData(); formData.append("file", fileInput); +<<<<<<< HEAD +======= + formData.append("category", category); // Posielame aj kategĂłriu +>>>>>>> 9e1c76c (Categories of PDF initialized) $.ajax({ url: "/api/grobid/upload", diff --git a/src/main/resources/templates/view-all.html b/src/main/resources/templates/view-all.html new file mode 100644 index 0000000000000000000000000000000000000000..8715ea9fbcbd92d5e5368ec5f8a55e28e952785a --- /dev/null +++ b/src/main/resources/templates/view-all.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<html xmlns:th="http://www.thymeleaf.org"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Upload PDF</title> + <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> + <style> + #pdf-preview { + width: 500px; + height: 600px; + border: 1px solid #ddd; + margin-top: 10px; + } + </style> +</head> + +<body> +<h1>PDF files</h1> + +<!-- zobrazenie PDF --> +<div id="pdf-container"> + <iframe id="pdf-preview" src="" style="display: none;"></iframe> +</div> + +<table> + <thead> + <tr> + <th>ID</th> + <th>Title</th> + <th>Link</th> + </tr> + </thead> + <tbody> + <tr th:each="ref: ${references}"> + <td th:text="${ref.id}"></td> + <td th:text="${ref.title}"></td> + <td><a th:href="@{'/api/document/' + ${ref.id}}" th:text="${ref.title}"></a></td> + </tr> + </tbody> +</table> + +</body> +</html> diff --git a/src/main/resources/templates/view-pdf.html b/src/main/resources/templates/view-pdf.html new file mode 100644 index 0000000000000000000000000000000000000000..8715ea9fbcbd92d5e5368ec5f8a55e28e952785a --- /dev/null +++ b/src/main/resources/templates/view-pdf.html @@ -0,0 +1,44 @@ +<!DOCTYPE html> +<html xmlns:th="http://www.thymeleaf.org"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Upload PDF</title> + <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> + <style> + #pdf-preview { + width: 500px; + height: 600px; + border: 1px solid #ddd; + margin-top: 10px; + } + </style> +</head> + +<body> +<h1>PDF files</h1> + +<!-- zobrazenie PDF --> +<div id="pdf-container"> + <iframe id="pdf-preview" src="" style="display: none;"></iframe> +</div> + +<table> + <thead> + <tr> + <th>ID</th> + <th>Title</th> + <th>Link</th> + </tr> + </thead> + <tbody> + <tr th:each="ref: ${references}"> + <td th:text="${ref.id}"></td> + <td th:text="${ref.title}"></td> + <td><a th:href="@{'/api/document/' + ${ref.id}}" th:text="${ref.title}"></a></td> + </tr> + </tbody> +</table> + +</body> +</html>