-
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.
- Loading branch information
Showing
102 changed files
with
14,323 additions
and
106 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Maven specific files | ||
target/ | ||
pom.xml.tag | ||
pom.xml.releaseBackup | ||
pom.xml.branch | ||
release.properties | ||
maven-metadata-*.xml | ||
maven-archiver/ | ||
MANIFEST.MF | ||
|
||
|
||
# IntelliJ IDEA files | ||
.idea/ | ||
*.iml | ||
|
||
# Eclipse files | ||
.classpath | ||
.project | ||
.settings/ | ||
|
||
# NetBeans files | ||
nb-configuration.xml | ||
build/ | ||
nbactions.xml |
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 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "interactive" | ||
} |
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,11 @@ | ||
FROM maven:3.9.6-eclipse-temurin-17-alpine AS build | ||
WORKDIR /app | ||
COPY pom.xml . | ||
COPY src ./src | ||
RUN mvn clean package -DskipTests | ||
|
||
FROM maven:3.9.6-eclipse-temurin-17-alpine | ||
WORKDIR /app | ||
COPY --from=build /app/target/backend.jar backend.jar | ||
EXPOSE 8080 | ||
ENTRYPOINT ["java", "-jar", "backend.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Lab3 Project | ||
|
||
This project is a small web application built using Java Servlets and JSP with Spring Boot framework. Maven is used for dependency management and project build. | ||
As Spring boot framework already contains TomCat Server, no more further download needed. | ||
|
||
## Prerequisites | ||
|
||
Before you begin, ensure you have the following installed on your machine: | ||
- Docker | ||
|
||
## Getting Started | ||
|
||
To get started with this project, follow these steps: | ||
|
||
1. Clone or download this repository to your local machine. | ||
|
||
2. Navigate to the project directory. | ||
|
||
3. Build the project using Docker | ||
|
||
``` | ||
docker-compose up -d | ||
``` |
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,7 @@ | ||
services: | ||
server: | ||
build: | ||
dockerfile: Dockerfile | ||
container_name: backend | ||
ports: | ||
- "8080: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,107 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.2.5</version> | ||
<relativePath /> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>library</groupId> | ||
<artifactId>app</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<properties> | ||
<maven.compiler.source>19</maven.compiler.source> | ||
<maven.compiler.target>19</maven.compiler.target> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-rest</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-devtools</artifactId> | ||
<scope>runtime</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-webflux</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springdoc</groupId> | ||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> | ||
<version>2.3.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>jakarta.xml.bind</groupId> | ||
<artifactId>jakarta.xml.bind-api</artifactId> | ||
<version>4.0.2</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.10.1</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>3.1.5</version> | ||
<executions> | ||
<execution> | ||
<id>pre-integration-test</id> | ||
<goals> | ||
<goal>start</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>post-integration-test</id> | ||
<goals> | ||
<goal>stop</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.springdoc</groupId> | ||
<artifactId>springdoc-openapi-maven-plugin</artifactId> | ||
<version>1.4</version> | ||
<executions> | ||
<execution> | ||
<phase>integration-test</phase> | ||
<goals> | ||
<goal>generate</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
<finalName>backend</finalName> | ||
</build> | ||
</project> |
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 @@ | ||
package lab10; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
|
||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) | ||
public class App { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(App.class, args); | ||
} | ||
|
||
} |
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,21 @@ | ||
package lab10.entities; | ||
|
||
import jakarta.persistence.Entity; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
public class Book { | ||
private String title; | ||
private String author; | ||
private int year; | ||
private String publisher; | ||
private String language; | ||
private int pages; | ||
private long isbn10; | ||
private long isbn13; | ||
private String description; | ||
private String category; | ||
} |
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,19 @@ | ||
package lab10.entities; | ||
import java.util.List; | ||
import jakarta.xml.bind.annotation.XmlElement; | ||
import jakarta.xml.bind.annotation.XmlRootElement; | ||
|
||
@XmlRootElement(name = "library") | ||
public class Library { | ||
|
||
private List<Book> books; | ||
|
||
@XmlElement(name = "book") | ||
public List<Book> getBooks() { | ||
return books; | ||
} | ||
|
||
public void setBooks(List<Book> books) { | ||
this.books = books; | ||
} | ||
} |
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,36 @@ | ||
package lab10.services; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.stereotype.Service; | ||
import jakarta.xml.bind.JAXBContext; | ||
import jakarta.xml.bind.JAXBException; | ||
import jakarta.xml.bind.Unmarshaller; | ||
import org.springframework.core.io.Resource; | ||
import lab10.entities.Book; | ||
import lab10.entities.Library; | ||
|
||
@Service | ||
public class BookService { | ||
|
||
public List<Book> getAllBooks() { | ||
try { | ||
Resource resource = new ClassPathResource("book.xml"); | ||
InputStream inputStream = resource.getInputStream(); | ||
|
||
JAXBContext jaxbContext = JAXBContext.newInstance(Library.class); | ||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); | ||
Library library = (Library) jaxbUnmarshaller.unmarshal(inputStream); | ||
|
||
return library.getBooks(); | ||
} catch (JAXBException | IOException e) { | ||
e.printStackTrace(); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
} |
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,21 @@ | ||
package lab10.servlets; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import lab10.entities.Book; | ||
import lab10.services.BookService; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
public class BookServlet { | ||
|
||
@Autowired | ||
private BookService bookService; | ||
|
||
@GetMapping("/books") | ||
public List<Book> getAllBooks() { | ||
return bookService.getAllBooks(); | ||
} | ||
} |
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 lab10.servlets; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@RestController | ||
public class Data { | ||
@GetMapping("/data") | ||
public String getData() { | ||
RestTemplate restTemplate = new RestTemplate(); | ||
return restTemplate.getForObject("http://localhost:8080/books", String.class); | ||
} | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<library> | ||
<book> | ||
<title>An Introduction to Support Vector Machines and Other Kernel-based Learning Methods</title> | ||
<author>Nello Cristianini, John Shawe-Taylor</author> | ||
<year>2013</year> | ||
<publisher>Cambridge University Press</publisher> | ||
<language>English</language> | ||
<pages>204</pages> | ||
<isbn10>0511801386</isbn10> | ||
<isbn13>9780511801389</isbn13> | ||
<description> | ||
This is the first comprehensive introduction to Support Vector Machines (SVMs), a new generation learning system based on recent advances in statistical learning theory. | ||
Students will find the book both stimulating and accessible, while practitioners will be guided smoothly through the material required for a good grasp of the theory and its applications. | ||
The concepts are introduced gradually in accessible and self-contained stages, while the presentation is rigorous and thorough. | ||
Pointers to relevant literature and web sites containing software make it an ideal starting point for further study. | ||
</description> | ||
<categories> | ||
<category>Computers - Artificial Intelligence (AI)</category> | ||
</categories> | ||
</book> | ||
</library> |
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,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Books</title> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> | ||
<script src="javascript.js"></script> | ||
</head> | ||
<body> | ||
<h1>Books</h1> | ||
<table id="booksTable" border="1"> | ||
<thead> | ||
<tr> | ||
<th>Title</th> | ||
<th>Author</th> | ||
<th>Year</th> | ||
<th>Language</th> | ||
<th>Description</th> | ||
<th>Publisher</th> | ||
<th>ISBN-10</th> | ||
<th>ISBN-13</th> | ||
</tr> | ||
</thead> | ||
<tbody></tbody> | ||
</table> | ||
</body> | ||
</html> |
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 @@ | ||
$(document).ready(() => { | ||
$.ajax({ | ||
type: "GET", | ||
url: "/data", | ||
success: (response) => { | ||
const books = JSON.parse(response); | ||
const tableBody = $('#booksTable tbody'); | ||
books.forEach((book) => { | ||
const { title, author, year, language, description, publisher, isbn10, isbn13 } = book; | ||
const row = `<tr> | ||
<td>${title}</td> | ||
<td>${author}</td> | ||
<td>${year}</td> | ||
<td>${language}</td> | ||
<td>${description}</td> | ||
<td>${publisher}</td> | ||
<td>${isbn10}</td> | ||
<td>${isbn13}</td> | ||
</tr>`; | ||
tableBody.append(row); | ||
}); | ||
}, | ||
error: () => { | ||
alert('Error fetching data'); | ||
} | ||
}); | ||
}); |
Empty file.
Oops, something went wrong.