Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
16bba2b
Base of the program
Mar 16, 2024
b2068f6
Creation of packages model and repository and modification of applica…
Mar 16, 2024
c13fe19
add validator interface
estefaniaemburse Mar 16, 2024
d4cfa25
create Issue model
DJH23 Mar 16, 2024
e4e613a
refactor name
estefaniaemburse Mar 16, 2024
9a9be90
Merge pull request #1 from jtiradohernandez/interface_validator
Mar 16, 2024
3f27f17
Merge remote-tracking branch 'origin/main' into issue_class
DJH23 Mar 16, 2024
66887f2
add InputValidator implementation to Issue model
DJH23 Mar 16, 2024
30c48a1
Book class creation and test
estefaniaemburse Mar 16, 2024
3f19c58
Book DDL
estefaniaemburse Mar 16, 2024
75a3a58
add Issue testing
DJH23 Mar 16, 2024
46b6294
Merge pull request #2 from jtiradohernandez/issue_class
Mar 16, 2024
51fdafe
Solution of author model, repository and DDL tasks
Mar 16, 2024
3b382b6
Merge branch 'main' into AuthorModelRepo
Mar 16, 2024
ac3cb10
Merge pull request #3 from jtiradohernandez/book_model
Mar 16, 2024
82eec48
Add pom on gitignore and adapt author model to validator abstract class
Mar 16, 2024
c5ebad2
Mergen main to branch
Mar 16, 2024
80b579f
change isbn to primary key
estefaniaemburse Mar 16, 2024
ea9c0f7
Add book dependency
Mar 16, 2024
c6f3fcf
student model and repostory, tests
Katenokk Mar 16, 2024
87c7065
modify Issue and its testing
DJH23 Mar 16, 2024
5c427ae
modify Issue and its testing
DJH23 Mar 16, 2024
8199294
subit tests y student repository
Katenokk Mar 16, 2024
8e0c785
Merge pull request #7 from jtiradohernandez/issue_class
ainafetse22 Mar 16, 2024
a674aa7
Create automationtest.yml
Mar 16, 2024
17d395f
actualizar test studentrepository
Katenokk Mar 16, 2024
043389b
Update automationtest.yml
Mar 16, 2024
c61130d
Merge pull request #5 from jtiradohernandez/book_primary_key
Katenokk Mar 16, 2024
21b141f
Merge pull request #8 from jtiradohernandez/student-feature
ainafetse22 Mar 16, 2024
49aad56
Update automationtest.yml
Mar 16, 2024
6f146cb
Update automationtest.yml
Mar 16, 2024
ee3b020
Update automationtest.yml
Mar 16, 2024
6b4c1fc
Update automationtest.yml
Mar 16, 2024
c2ba9b6
Update automationtest.yml
Mar 16, 2024
52d25c4
Merge remote-tracking branch 'origin/main' into issue_class
DJH23 Mar 16, 2024
1e6a168
Update automationtest.yml
Mar 16, 2024
4b5f60e
add Issue DDL in SQL
DJH23 Mar 16, 2024
3aa0331
Merge pull request #12 from jtiradohernandez/issue_class
Katenokk Mar 16, 2024
a34de27
add hascode and equals to Student.java ; add student table to SQL ; u…
Katenokk Mar 16, 2024
943f164
Merge pull request #13 from jtiradohernandez/student-feature
DJH23 Mar 16, 2024
3585ac3
recuperar pom
Katenokk Mar 16, 2024
238b26d
Merge pull request #14 from jtiradohernandez/student-feature
Katenokk Mar 16, 2024
c8b3d72
Merge of main branch
Mar 17, 2024
f9213d5
Final solution for Author model, repository, DDL and tests
Mar 17, 2024
a61c448
Re-structured
Mar 18, 2024
3b51b60
Merge pull request #16 from jtiradohernandez/bug_structure
sergi-svg Mar 19, 2024
c6e44d6
Untrack .idea directory
Mar 19, 2024
77434ae
Merge pull request #17 from jtiradohernandez/bug_gitignore
sergi-svg Mar 19, 2024
1a1e4ab
Update automationtest.yml
sergi-svg Mar 19, 2024
9023a7a
updated schema.sql
Mar 19, 2024
ac4a4c6
Merge pull request #18 from jtiradohernandez/feat_schema
sergi-svg Mar 19, 2024
d1049a6
Merge pull request #11 from jtiradohernandez/jtiradohernandez-gitaction
sergi-svg Mar 19, 2024
da860f9
Update automationtest.yml
Mar 19, 2024
9007a4c
Update automationtest.yml
Mar 19, 2024
c8d4e93
Update automationtest.yml
Mar 19, 2024
9668d85
Merge pull request #19 from jtiradohernandez/jtiradohernandez-patch-1
Mar 19, 2024
f2cb5b2
bugfix missing package
estefaniaemburse Mar 19, 2024
92ef9ee
Merge pull request #21 from jtiradohernandez/bugfix_project_structure
sergi-svg Mar 19, 2024
55e7ed6
bugfix repositories
estefaniaemburse Mar 19, 2024
ae6600d
Merge pull request #22 from jtiradohernandez/bugfix_repositories
sergi-svg Mar 19, 2024
c4c5583
Author with tests
Mar 19, 2024
e5430e0
Add of gitignored previously deleted
Mar 19, 2024
bd97430
Comment test of repository
Mar 19, 2024
9f593d4
Merge pull request #23 from jtiradohernandez/AuthorModelRepo
sergi-svg Mar 21, 2024
ca9c9a8
application.properties for tests
Mar 28, 2024
9791b4b
Merge pull request #24 from jtiradohernandez/feat_application_propert…
Katenokk Mar 29, 2024
e6965de
library repo
estefaniaemburse Mar 29, 2024
786f27b
Book services
estefaniaemburse Mar 29, 2024
e9b7a72
Merge pull request #25 from jtiradohernandez/create_service_structure
Katenokk Mar 29, 2024
17ba1c2
fix mapping student/issue, add getters, setters to Issue, add test to…
Katenokk Mar 29, 2024
a4b8bb9
arreglado fallo lombok, corrección mapro student-issue, nuevo studen …
Katenokk Mar 29, 2024
a58fce3
métodos issueBook y searchBookByStudentString
Katenokk Mar 30, 2024
0992ef4
Merge pull request #27 from jtiradohernandez/student-mapping
Mar 31, 2024
5b5ccf4
Book services and menu
estefaniaemburse Apr 1, 2024
a4656fb
add try catch
estefaniaemburse Apr 2, 2024
511d6dc
Merge pull request #28 from jtiradohernandez/library_menu
Apr 2, 2024
e165b32
update issuebook & isBookIssued
Katenokk Apr 2, 2024
127f6a9
add updateQuantity a book y actualizar issueBook
Katenokk Apr 2, 2024
2298190
quitar query inutil de IssueRepository
Katenokk Apr 2, 2024
8a86db5
utils and testing
DJH23 Apr 2, 2024
fe052b4
Merge pull request #31 from DJH23/utils
Katenokk Apr 2, 2024
c92a71f
Merge branch 'main' into methods-1
Katenokk Apr 2, 2024
7c6d3ab
arreglar conflictos
Katenokk Apr 2, 2024
b4634fa
arreglar conflictos
Katenokk Apr 2, 2024
4baae7e
comentar test UtilsTest a falta de actualizar github action
Katenokk Apr 2, 2024
68ea9e5
application.properties for tests
Apr 3, 2024
03b2ac0
updated github action for integration tests
Apr 3, 2024
0252b62
updated github action for integration tests
Apr 3, 2024
06bd688
updated github action for integration tests
Apr 3, 2024
5a51fb9
updated github action for integration tests
Apr 3, 2024
6c6f785
Merge pull request #29 from jtiradohernandez/methods-1
ainafetse22 Apr 3, 2024
0173ee0
update searchBooksByUsn() , add 6,8 to libraryMenu
Katenokk Apr 3, 2024
3c99158
Merge pull request #32 from jtiradohernandez/methods-2
sergi-svg Apr 4, 2024
a233e20
addBook (no funciona!) y findAllBooksWithAuthor(), añadido cascade.pe…
Katenokk Apr 4, 2024
554acab
añadir anotaciones a ironlibrary para que funcionen los repository en…
Katenokk Apr 5, 2024
8043787
comentar llamada redundante en ironlibrary
Katenokk Apr 5, 2024
f598bca
arreglado issueBook para que de error al prestar un libro con cantidad 0
Katenokk Apr 5, 2024
6000219
arreglado librarymenu, pequeño cambio en llamada a libraryMenu
Katenokk Apr 5, 2024
6de18ec
Merge pull request #33 from jtiradohernandez/methods-2
Apr 6, 2024
734a7d7
nuevos metodos print en libraryMenu, override toString en Book
Katenokk Apr 6, 2024
17f7f23
Merge pull request #34 from jtiradohernandez/methods-2
Katenokk Apr 6, 2024
a7fbe38
keep changes
Katenokk Apr 6, 2024
132e419
input validations
Katenokk Apr 6, 2024
ea7fd55
añadir print del comando 3 y 4
Katenokk Apr 6, 2024
e4dabd8
Merge pull request #35 from jtiradohernandez/methods-2
Katenokk Apr 6, 2024
831980d
refactorizar metodo getName y corregir error en usnValidator
Katenokk Apr 6, 2024
36779fb
Merge pull request #36 from jtiradohernandez/get-name-feature
Katenokk Apr 6, 2024
5767e48
change mapping from Book to Author to ManyToOne
Katenokk Apr 7, 2024
c27c05a
fix error add book update quantity
Katenokk Apr 7, 2024
79616b0
refactor input validators: getTitle, getAuthorEmail, getName, getQuan…
Katenokk Apr 7, 2024
720f6cb
fix mistake in regex ooops!
Katenokk Apr 7, 2024
37331ff
Merge pull request #38 from jtiradohernandez/fix-mapping
Apr 8, 2024
ace69a5
Merge pull request #39 from jtiradohernandez/get-author-id
Apr 8, 2024
b5c4506
add LibraryServiceTest and 2 tests to UtilsTest
Katenokk Apr 8, 2024
b0d9f76
Merge pull request #41 from jtiradohernandez/test-branch
Apr 9, 2024
2914b64
add 3 new tests by Darren
Katenokk Apr 9, 2024
4a8e219
Merge pull request #43 from jtiradohernandez/test-branch
sergi-svg Apr 9, 2024
25be7dc
refactor test, delete inputValidator
Katenokk Apr 9, 2024
e480643
Merge pull request #44 from jtiradohernandez/test-branch
sergi-svg Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/automationtest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
pull_request:
branches:
- main
- develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn package -Dmaven.test.skip=true
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Maven
log/
target/
!.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### VS Code ###
.vscode

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# Log file
*.log


# MacOS
.DS_Store
75 changes: 75 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<artifactId>ironlibrary</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
<java.version>21</java.version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>
30 changes: 30 additions & 0 deletions src/main/java/com/ironhack/IronLibrary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.ironhack;

import com.ironhack.viewer.LibraryMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.core.env.Environment;

import java.util.Arrays;

@SpringBootApplication
public class IronLibrary implements CommandLineRunner {
@Autowired
private LibraryMenu libraryMenu;

@Autowired
private Environment environment;

public static void main(String[] args) {
SpringApplication.run(IronLibrary.class, args);
}

@Override
public void run(String... args) throws Exception {
if(!Arrays.asList(environment.getActiveProfiles()).contains("test")){
libraryMenu.displayMenu();
}
}
}
39 changes: 39 additions & 0 deletions src/main/java/com/ironhack/model/Author.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.ironhack.model;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Objects;

@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "author")
public class Author {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int authorId;
private String name;
private String email;

public Author(String name, String email) {
setName(name);
setEmail(email);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Author author = (Author) o;
return authorId == author.authorId && Objects.equals(name, author.name) && Objects.equals(email, author.email);
}

@Override
public int hashCode() {
return Objects.hash(authorId, name, email);
}
}
65 changes: 65 additions & 0 deletions src/main/java/com/ironhack/model/Book.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.ironhack.model;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Objects;

@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "book")
public class Book {
@Id
@Column(name = "isbn")
private String isbn;

private String title;

@Enumerated(EnumType.STRING)
private Categories category;

private int quantity;

@ManyToOne(cascade = CascadeType.PERSIST)
@JoinColumn(name = "author_id")
private Author authorBook;

public Book(String isbn, String title, Categories category, int quantity, Author author) {
this.isbn = isbn;
this.title = title;
this.category = category;
this.quantity = quantity;
this.authorBook = author;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Book book)) return false;
return quantity == book.quantity && Objects.equals(isbn, book.isbn) &&
Objects.equals(title, book.title) && category == book.category &&
authorBook.getAuthorId() == book.authorBook.getAuthorId() && Objects.equals(authorBook.getName(), book.authorBook.getName()) &&
book.authorBook.getEmail().equals(authorBook.getEmail());
}

@Override
public int hashCode() {
return Objects.hash(isbn, title, category, quantity, authorBook);
}

public void updateQuantity(int newQuantity) {
this.quantity += newQuantity;
}

@Override
public String toString() {
return String.format("%nISBN: %s%n" +
"Title: %s%n" +
"Category: %s%n" +
"No of Books: %d%n", isbn, title, category, quantity);
}
}
14 changes: 14 additions & 0 deletions src/main/java/com/ironhack/model/Categories.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.ironhack.model;

public enum Categories {
HORROR,
SCIENCE,
ROMANCE,
FICTION,
FANTASY,
ADVENTURE,
BIOGRAPHY,
MISTERY,
OTHERS

}
31 changes: 31 additions & 0 deletions src/main/java/com/ironhack/model/Issue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.ironhack.model;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Getter
@Setter
@NoArgsConstructor // Generates a no-args constructor for JPA
public class Issue {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int issueId;
private String issueDate;
private String returnDate;
@ManyToOne
@JoinColumn(name="issue_student")
private Student issueStudent;
@OneToOne
@JoinColumn(name="issue_book")
private Book issueBook;

public Issue(String issueDate, String returnDate) {
this.issueDate = issueDate;
this.returnDate = returnDate;
}
}



55 changes: 55 additions & 0 deletions src/main/java/com/ironhack/model/Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.ironhack.model;

import jakarta.persistence.*;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Getter
@Setter
@Entity
@Table(name = "student")
@Data
public class Student {
@Id
private String usn;
private String name;

@OneToMany(mappedBy = "issueStudent", cascade = CascadeType.ALL)
private List<Issue> issues;

public Student() {
}

public Student(String usn, String name) {
this.usn = usn;
this.name = name;
}

public void addIssue(Issue issue) {
if (issues == null) {
issues = new ArrayList<>();
}
issues.add(issue);
issue.setIssueStudent(this);
}


@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Student student = (Student) o;
return Objects.equals(usn, student.usn) && Objects.equals(name, student.name);
}

@Override
public int hashCode() {
return Objects.hash(usn, name);
}

}
12 changes: 12 additions & 0 deletions src/main/java/com/ironhack/repository/AuthorRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.ironhack.repository;

import com.ironhack.model.Author;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface AuthorRepository extends JpaRepository<Author, Integer> {
Optional<Author> findByName(String authorName);
}
Loading