diff --git a/.vscode/launch.json b/.vscode/launch.json index d85a026..d3f95d1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,23 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "type": "java", + "name": "ApiController", + "request": "launch", + "mainClass": "edu.inventorym.ApiController", + "projectName": "Ui" + }, + { + "type": "java", + "name": "Application", + "request": "launch", + "mainClass": "edu.inventorym.Application", + "projectName": "Ui", + "noDebug": false, + "__progressId": "ac782dee-a961-4892-9b94-9090bfdfcbda", + "__origin": "internal" + }, { "type": "java", "name": "ApplicationView", @@ -11,7 +28,6 @@ "mainClass": "edu.inventorym.ApplicationView", "projectName": "UiView", "vmArgs": " --module-path /home/sherwinp/workspace/javafx-sdk/lib --add-modules ALL-MODULE-PATH --enable-native-access=javafx.web,javafx.controls,javafx.media,javafx.graphics -Dcom.sun.management.jmxremote=false -Djava.awt.headless=true -XX:+DisableAttachMechanism" - }, - + } ] } \ No newline at end of file diff --git a/Api/.gitignore b/Api/.gitignore deleted file mode 100644 index 68f70f3..0000000 --- a/Api/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Ignore Gradle project-specific cache directory -.gradle - -# Ignore Gradle build output directory -build - -# Ignore bin -bin diff --git a/Api/bin/main/edu/inventorym/Api.class b/Api/bin/main/edu/inventorym/Api.class deleted file mode 100644 index f0fe5ba..0000000 Binary files a/Api/bin/main/edu/inventorym/Api.class and /dev/null differ diff --git a/Api/build.gradle b/Api/build.gradle deleted file mode 100644 index 132654f..0000000 --- a/Api/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file was generated by the Gradle 'init' task. - * - */ - -plugins { - // Apply the application plugin to add support for building a CLI application in Java. - id 'java' - id 'application' -} - -// Apply a specific Java toolchain to ease working on different environments. -java { - toolchain { - languageVersion = JavaLanguageVersion.of(25) - } - - sourceCompatibility = JavaVersion.toVersion("25") - targetCompatibility = JavaVersion.toVersion("25") -} - -application { - // Define the main class for the application. - mainClass = 'edu.inventorym.Api' -} - -repositories { - // Use Maven Central for resolving dependencies. - mavenCentral() -} - -dependencies { - implementation 'jakarta.json.bind:jakarta.json.bind-api:3.0.1' - implementation project(':Model') -} - diff --git a/Api/src/resources/db/customers.json b/Api/src/resources/db/customers.json deleted file mode 100644 index f453b45..0000000 --- a/Api/src/resources/db/customers.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "email": "kate@museum.com", - "id": "4659170390", - "nameFirst": "Kate", - "nameLast": "Demsey", - "phone": "310-676-4844" - }, - { - "email": "jim@homedeco.com", - "id": "3722574478", - "nameFirst": "Jim", - "nameLast": "Gumbly", - "phone": "203-676-4844" - }, - { - "email": "evan@homedeco.com", - "id": "3611023109", - "nameFirst": "Evan", - "nameLast": "Hao", - "phone": "203-676-8943" - } -] \ No newline at end of file diff --git a/Api/src/resources/db/inventory.json b/Api/src/resources/db/inventory.json deleted file mode 100644 index 32960f8..0000000 --- a/Api/src/resources/db/inventory.json +++ /dev/null @@ -1,2 +0,0 @@ -[ -] \ No newline at end of file diff --git a/Api/src/resources/db/transactions.json b/Api/src/resources/db/transactions.json deleted file mode 100644 index d51fbc4..0000000 --- a/Api/src/resources/db/transactions.json +++ /dev/null @@ -1,31 +0,0 @@ -[ - { - "completed": "2025-12-24T17:58:48.979740808-05:00[America/New_York]", - "created": "2025-12-24T17:58:48.979723067-05:00[America/New_York]", - "customerId": "4659170390", - "customerInventoryList": [ - { - "Author": "Dave Janson", - "author": "Dave Janson", - "created": "2025-10-30T13:47:16.4766896-04:00[America/New_York]", - "description": "East Market Square find. Local Author.", - "id": "1829220534", - "price": 92.0, - "title": "Windy Rowing", - "type": "DRAWING" - }, - { - "Author": "Dave Janson", - "author": "Dave Janson", - "created": "2025-10-30T13:47:16.4766896-04:00[America/New_York]", - "description": "East Market Square find. Local Author.", - "id": "1829220534", - "price": 92.0, - "title": "Windy Rowing", - "type": "DRAWING" - } - ], - "id": "LRlFXsGy8F0Vq6caT5hYKQ", - "totalPrice": 184.0 - } -] \ No newline at end of file diff --git a/Ui/build.gradle b/Ui/build.gradle index 14cfa53..d02b38b 100644 --- a/Ui/build.gradle +++ b/Ui/build.gradle @@ -36,11 +36,16 @@ configurations { } dependencies { + + implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17' + implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.17' + implementation 'io.netty:netty-common:4.2.8.Final' implementation 'org.springframework.boot:spring-boot-starter-webflux:4.0.0' implementation 'org.springdoc:springdoc-openapi-starter-webflux-api:3.0.0' implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:3.0.0' - implementation 'jakarta.json.bind:jakarta.json.bind-api:3.0.1' + implementation 'jakarta.json.bind:jakarta.json.bind-api:3.0.1' + implementation project(':Model') } diff --git a/Api/src/main/java/edu/inventorym/Api.java b/Ui/src/main/java/edu/inventorym/ApiController.java similarity index 86% rename from Api/src/main/java/edu/inventorym/Api.java rename to Ui/src/main/java/edu/inventorym/ApiController.java index b9d50e0..c588283 100644 --- a/Api/src/main/java/edu/inventorym/Api.java +++ b/Ui/src/main/java/edu/inventorym/ApiController.java @@ -6,6 +6,12 @@ package edu.inventorym; import java.time.ZonedDateTime; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import edu.inventorym.model.Customer; import edu.inventorym.model.CustomerManager; import edu.inventorym.model.Drawing; @@ -18,22 +24,17 @@ import edu.inventorym.model.Sculpture; import edu.inventorym.model.Transaction; import edu.inventorym.model.TransactionList; import edu.inventorym.model.TransactionManager; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; -public interface Api { - - public static void main(String[] args) { - - callerInterface(); - - } - - static void callerInterface() { - // @Comment - /* - * 1. Add new art object to the inventory. Your manager must check that the art - * is not already in the inventory before adding - */ +@RestController +@RequestMapping("/api") +public interface ApiController { // SINGLETON + @Operation(summary = "Get status Inventory Loaded", description = "Returns status Inventory Loaded.") + @ApiResponse(responseCode = "200", description = "loaded") + @GetMapping + public static ResponseEntity getInventory() { /* Inventory pieces */ InventoryManager.getInstance().load(); if (InventoryManager.getInstance().INVENTORY.isEmpty()) { @@ -45,6 +46,16 @@ public interface Api { InventoryManager.getInstance().add(make(new Sculpture())); InventoryManager.getInstance().add(make(new Sculpture())); } + return new ResponseEntity<>("Resource loaded!", HttpStatus.OK); + } + + static void callerInterface() { + // @Comment + /* + * 1. Add new art object to the inventory. Your manager must check that the art + * is not already in the inventory before adding + */ + /* Customers */ CustomerManager.getInstance().load(); if (CustomerManager.getInstance().CUSTOMERS.isEmpty()) { @@ -75,7 +86,7 @@ public interface Api { System.out.println("\n"); if (imgr.INVENTORY.isEmpty()) { - System.out.println(String.format("%s: No Inventoried Art Piecies Available !!!. ", Api.class)); + System.out.println(String.format("%s: No Inventoried Art Piecies Available !!!. ", ApiController.class)); return; } @@ -98,7 +109,7 @@ public interface Api { */ tmgr.compute(tran); tmgr.complete(tran); - //tmgr.remove(tran); + // tmgr.remove(tran); /* * 7. Format and return transaction data in print format */ diff --git a/Ui/src/main/java/edu/inventorym/Application.java b/Ui/src/main/java/edu/inventorym/BackendService.java similarity index 68% rename from Ui/src/main/java/edu/inventorym/Application.java rename to Ui/src/main/java/edu/inventorym/BackendService.java index 9a4ad9f..cda60cb 100644 --- a/Ui/src/main/java/edu/inventorym/Application.java +++ b/Ui/src/main/java/edu/inventorym/BackendService.java @@ -4,6 +4,8 @@ */ package edu.inventorym; +import java.util.concurrent.CompletableFuture; + import org.springframework.boot.WebApplicationType; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -17,18 +19,21 @@ import io.swagger.v3.oas.annotations.info.Info; @EnableWebFlux @SpringBootApplication @OpenAPIDefinition(info = @Info(title = "Model API", version = "3.0.0", description = "Documentation Model API v1.0")) -public class Application { +public class BackendService { - public static void main(String[] args) { - new SpringApplicationBuilder() + public static final void BackendServiceStart(String[] args){ + CompletableFuture.runAsync(() -> { + // Long-running background operation + new SpringApplicationBuilder() .profiles("dev") .web(WebApplicationType.REACTIVE) - .sources(Application.class, Controller.class) + .sources(BackendService.class, Controller.class, ApiController.class) .run(args); + }); } @Bean - public NettyReactiveWebServerFactory nettyServerFactory() { + public static final NettyReactiveWebServerFactory nettyServerFactory() { NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory(); return factory; } diff --git a/UiView/build.gradle b/UiView/build.gradle index de5360f..70beae3 100644 --- a/UiView/build.gradle +++ b/UiView/build.gradle @@ -55,18 +55,21 @@ javafx { dependencies { + implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17' + implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.17' + //https://mvnrepository.com/artifact/com.google.code.gson/gson implementation 'com.google.code.gson:gson:2.13.2' + implementation 'org.openjfx:javafx-base:25.0.1' implementation 'org.openjfx:javafx-fxml:25.0.1' implementation 'org.openjfx:javafx-controls:25.0.1' implementation 'org.openjfx:javafx-graphics:25.0.1' implementation 'org.openjfx:javafx-web:25.0.1' - implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17' - implementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.17' + implementation project(':Model') - implementation project(':Api') + implementation project(':Ui') } diff --git a/UiView/src/main/java/edu/inventorym/ApplicationView.java b/UiView/src/main/java/edu/inventorym/ApplicationView.java index 74c34d2..1facad9 100644 --- a/UiView/src/main/java/edu/inventorym/ApplicationView.java +++ b/UiView/src/main/java/edu/inventorym/ApplicationView.java @@ -43,6 +43,7 @@ public class ApplicationView extends Application { } public static void main(String[] args) { + BackendService.BackendServiceStart(args); launch(args); } } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 1ff5f20..9061f1c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,6 +6,5 @@ plugins { rootProject.name = 'inventorym' include('Model') -include('Api') include('Ui') include('UiView')