diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/BookstoreApplication.java b/bookstore/src/main/java/com/fjordtek/bookstore/BookstoreApplication.java index 1cdab98..f912da8 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/BookstoreApplication.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/BookstoreApplication.java @@ -21,6 +21,15 @@ import com.fjordtek.bookstore.model.BookRepository; import com.fjordtek.bookstore.model.Category; import com.fjordtek.bookstore.model.CategoryRepository; +/** +* +* This is the main Spring Boot application class for the bookstore project. +*
+* Initializes and handles initialization of the application. +* +* @author Pekka Helenius +*/ + @SpringBootApplication public class BookstoreApplication extends SpringBootServletInitializer { private static final Logger commonLogger = LoggerFactory.getLogger(BookstoreApplication.class); diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/Author.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/Author.java index da371e6..89c29bd 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/Author.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/Author.java @@ -19,6 +19,16 @@ import javax.validation.constraints.Size; import com.fasterxml.jackson.annotation.JsonIgnore; +/** + * This class implements Author entity which forms + * core structure for the corresponding AUTHOR table in a database. + *
+ * Additionally, Author entity objects are Java objects having + * methods, attributes and other class-related additions within them. + * + * @author Pekka Helenius + */ + @Entity public class Author { diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/AuthorJsonSerializer.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/AuthorJsonSerializer.java index 399a267..f6b7d75 100644 --- a/bookstore/src/main/java/com/fjordtek/bookstore/model/AuthorJsonSerializer.java +++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/AuthorJsonSerializer.java @@ -8,6 +8,20 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; +/** + * This class implements Jackson JSON serializer for Author entity class. + *
+ * When writing a JSON output based on a Author entity object, the processing + * is handled in the way described in this class. + *
+ * Unless specifically instructed, customization defined in this class
+ * does not affect native Spring REST API JSON outputs generated
+ * by a controller having either @BasePathAwareController
+ * or @RepositoryRestController annotation.
+ *
+ * @author Pekka Helenius
+ */
+
public class AuthorJsonSerializer extends StdSerializer
+ * Additionally, Book entity objects are Java objects having
+ * methods, attributes and other class-related additions within them.
+ *
+ * @author Pekka Helenius
+ */
+
@Entity
public class Book {
diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookEventHandler.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookEventHandler.java
index 6feba42..bcdeaff 100644
--- a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookEventHandler.java
+++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookEventHandler.java
@@ -7,6 +7,22 @@ import org.springframework.data.rest.core.annotation.HandleAfterCreate;
import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
import org.springframework.stereotype.Component;
+/**
+ * This class is part of Spring framework, having @Component
+ * annotation.
+ *
+ * The class implements @RepositoryEventHandler annotation
+ * for Book class which instructs Spring to use custom method
+ * implementations for events annotated with specific event
+ * handlers in the class.
+ *
+ * @see https://docs.spring.io/spring-data/rest/docs/current/reference/html/#events
+ * @see https://stackoverflow.com/questions/49504103/override-spring-data-rest-post-method
+ * @see https://www.baeldung.com/spring-data-rest-events
+ *
+ * @author Pekka Helenius
+ */
+
@Component
@RepositoryEventHandler(Book.class)
public class BookEventHandler {
@@ -22,9 +38,6 @@ public class BookEventHandler {
* curl --request POST --header "Content-Type: application/json" --data
* '{"title":"Bloody Chamber", ...}' http://localhost:8080/api/booklist
*
- * Ref: https://docs.spring.io/spring-data/rest/docs/current/reference/html/#events
- * https://stackoverflow.com/questions/49504103/override-spring-data-rest-post-method
- * https://www.baeldung.com/spring-data-rest-events
*/
@HandleAfterCreate
public void handleAfterCreate(Book book) {
diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHash.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHash.java
index 4fc222c..6e6bec1 100644
--- a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHash.java
+++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHash.java
@@ -19,19 +19,27 @@ import org.hibernate.annotations.Parameter;
import com.fasterxml.jackson.annotation.JsonIgnore;
-/*
+/**
+ * This class implements BookHash entity which forms
+ * core structure for the corresponding BOOK_HASH table in a database.
+ *
+ * Additionally, BookHash entity objects are Java objects having
+ * methods, attributes and other class-related additions within them.
+ *
* This entity shares same primary key with the Book entity
* which is simultaneously a foreign key (unidirectional mapping)
* for this one.
- * For implementation reference, see also:
- * https://www.programmersought.com/article/1610322983/
- *
+ *
* This entity generates a table which holds auto-generated
* random string values associated to each book.
- *
+ *
* These random string values represent difficult-to-enumerate
* unique book IDs used for front-end purposes. Main purpose
* is not to expose real Book entity id value.
+ *
+ * @see https://www.programmersought.com/article/1610322983/
+ *
+ * @author Pekka Helenius
*/
@Entity
diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHashRepository.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHashRepository.java
index 1f552e7..301df54 100644
--- a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHashRepository.java
+++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookHashRepository.java
@@ -8,6 +8,13 @@ import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+/**
+ * This interface extends CrudRepository interface, implementing
+ * custom methods for a repository containing BookHash entities.
+ *
+ * @author Pekka Helenius
+ */
+
@RepositoryRestResource(
path = "bookhashes",
itemResourceRel = "bookhashes",
diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java
index 145c8b1..f93df03 100644
--- a/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java
+++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/BookRepository.java
@@ -12,6 +12,13 @@ import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.data.rest.core.annotation.RestResource;
+/**
+ * This interface extends CrudRepository interface, implementing
+ * custom methods for a repository containing Book entities.
+ *
+ * @author Pekka Helenius
+ */
+
@RepositoryRestResource(
path = "booklist",
itemResourceRel = "booklist",
diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java
index b3ab1d9..b948867 100644
--- a/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java
+++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/Category.java
@@ -16,6 +16,16 @@ import javax.persistence.SequenceGenerator;
import com.fasterxml.jackson.annotation.JsonIgnore;
+/**
+ * This class implements Category entity which forms
+ * core structure for the corresponding CATEGORY table in a database.
+ *
+ * Additionally, Category entity objects are Java objects having
+ * methods, attributes and other class-related additions within them.
+ *
+ * @author Pekka Helenius
+ */
+
@Entity
public class Category {
diff --git a/bookstore/src/main/java/com/fjordtek/bookstore/model/CategoryJsonSerializer.java b/bookstore/src/main/java/com/fjordtek/bookstore/model/CategoryJsonSerializer.java
index d7c71c0..f6faf5a 100644
--- a/bookstore/src/main/java/com/fjordtek/bookstore/model/CategoryJsonSerializer.java
+++ b/bookstore/src/main/java/com/fjordtek/bookstore/model/CategoryJsonSerializer.java
@@ -8,6 +8,20 @@ import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+/**
+ * This class implements Jackson JSON serializer for Category entity class.
+ *
+ * When writing a JSON output based on a Category entity object, the processing
+ * is handled in the way described in this class.
+ *
+ * Unless specifically instructed, customization defined in this class
+ * does not affect native Spring REST API JSON outputs generated
+ * by a controller having either @BasePathAwareController
+ * or @RepositoryRestController annotation.
+ *
+ * @author Pekka Helenius
+ */
+
public class CategoryJsonSerializer extends StdSerializer