diff options
| -rw-r--r-- | .devcontainer/Dockerfile | 33 | ||||
| -rw-r--r-- | .devcontainer/devcontainer.json | 24 | ||||
| -rw-r--r-- | liquibase.properties | 76 | ||||
| -rw-r--r-- | package.json | 10 | ||||
| -rw-r--r-- | pom.xml | 38 | ||||
| -rw-r--r-- | src/main/java/dev/submelon/rest/json/PantryItem.java | 24 | ||||
| -rw-r--r-- | src/main/java/dev/submelon/rest/json/PantryItemResource.java | 20 | ||||
| -rw-r--r-- | src/main/resources/application.properties | 5 | ||||
| -rw-r--r-- | src/main/resources/db/changeLog.xml | 9 | ||||
| -rw-r--r-- | src/main/resources/db/changelogs/20220804-add-pantryitem.xml | 30 | ||||
| -rw-r--r-- | src/main/resources/db/changelogs/20220814-test-data.xml | 93 |
11 files changed, 69 insertions, 293 deletions
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index a1aa4f0..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/java/.devcontainer/base.Dockerfile - -# [Choice] Java version (use -bullseye variants on local arm64/Apple Silicon): 11, 17, 11-bullseye, 17-bullseye, 11-buster, 17-buster -ARG VARIANT="17-bullseye" -FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT} - -# [Option] Install Maven -ARG INSTALL_MAVEN="false" -ARG MAVEN_VERSION="" -# [Option] Install Gradle -ARG INSTALL_GRADLE="false" -ARG GRADLE_VERSION="" -RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \ - && if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi - -# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 -ARG NODE_VERSION="none" -RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi - -# Liquibase CLI -ARG LIQUIBASE_VERSION="4.14.0" -RUN mkdir -p /opt/liquibase && cd /opt/liquibase \ - && curl -GL https://github.com/liquibase/liquibase/releases/download/v${LIQUIBASE_VERSION}/liquibase-${LIQUIBASE_VERSION}.tar.gz -o ./liquibase.tar.gz \ - && tar xvf ./liquibase.tar.gz \ - && rm liquibase.tar.gz -ENV PATH $PATH:/opt/liquibase - -# [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends <your-package-list-here> - -# [Optional] Uncomment this line to install global node packages. -# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
\ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e4580f7..36e9c21 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,15 +1,14 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/java { "name": "Pantry", - "build": { - "dockerfile": "Dockerfile", - "args": { - "VARIANT": "17-bullseye", - "INSTALL_MAVEN": "true", - "INSTALL_GRADLE": "false", - "NODE_VERSION": "lts/*", - "LIQUIBASE_VERSION": "4.14.0" + "image": "mcr.microsoft.com/devcontainers/java:17-bullseye", + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "none", + "installMaven": "true" + }, + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/node:1": { + "version": "latest" } }, @@ -37,8 +36,5 @@ // "postCreateCommand": "mvn compile", // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode", - "features": { - "docker-from-docker": "latest" - } + "remoteUser": "vscode" } diff --git a/liquibase.properties b/liquibase.properties deleted file mode 100644 index a3a381e..0000000 --- a/liquibase.properties +++ /dev/null @@ -1,76 +0,0 @@ -#### _ _ _ _ -## | | (_) (_) | -## | | _ __ _ _ _ _| |__ __ _ ___ ___ -## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ -## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ -## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| -## | | -## |_| -## -## The liquibase.properties file stores properties which do not change often, -## such as database connection information. Properties stored here save time -## and reduce risk of mistyped command line arguments. -## Learn more: https://docs.liquibase.com/concepts/connections/creating-config-properties.html -#### -#### -## Note about relative and absolute paths: -## The liquibase.properties file requires paths for some properties. -## The classpath is the path/to/resources (ex. src/main/resources). -## The changeLogFile path is relative to the classpath. -## The url H2 example below is relative to 'pwd' resource. -#### -# Enter the path for your changelog file. -changeLogFile=src/main/resources/db/changeLog.xml - -#### Enter the Target database 'url' information #### -liquibase.command.url=jdbc:postgresql://172.17.0.1:49167/quarkus?loggerLevel=OFF - -# Enter the username for your Target database. -liquibase.command.username: quarkus - -# Enter the password for your Target database. -liquibase.command.password: quarkus - -#### Enter the Source Database 'referenceUrl' information #### -## The source database is the baseline or reference against which your target database is compared for diff/diffchangelog commands. - -# Enter URL for the source database -#liquibase.command.referenceUrl: jdbc:h2:tcp://localhost:9090/mem:integration - -# Enter the username for your source database -#liquibase.command.referenceUsername: dbuser - -# Enter the password for your source database -#liquibase.command.referencePassword: letmein - -# Logging Configuration -# logLevel controls the amount of logging information generated. If not set, the default logLevel is INFO. -# Valid values, from least amount of logging to most, are: -# OFF, ERROR, WARN, INFO, DEBUG, TRACE, ALL -# If you are having problems, setting the logLevel to DEBUG and re-running the command can be helpful. -# logLevel: DEBUG - -# The logFile property controls where logging messages are sent. If this is not set, then logging messages are -# displayed on the console. If this is set, then messages will be sent to a file with the given name. -# logFile: liquibase.log - - -#### Liquibase Pro Key Information #### -# Learn more, contact support, or get or renew a Pro Key at https://www.liquibase.com/trial -# liquibase.licenseKey: - -#### Liquibase Hub Information #### -# Liquibase Hub is a free secure SaaS portal providing status reporting, monitoring & insights -# into your Liquibase database release automation. -# https://hub.liquibase.com - -## Add your free Hub API key here -# liquibase.hub.apikey: -# liquibase.hub.mode:all - - - - -## Get documentation at docs.liquibase.com ## -## Get certified courses at learn.liquibase.com ## -## Get support at liquibase.com/support ## diff --git a/package.json b/package.json index 0a3b50c..fef0ae1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,13 @@ { "name": "pantry", + "version": "0.1.0", + "description": "Kitchen inventory organizer and planner", + "repository": { + "type": "git", + "url": "https://github.com/kjhoerr/pantry.git" + }, + "author": "Kevin J Hoerr <kjhoerr@submelon.tech>", + "license": "BlueOak-1.0.0", "scripts": { "dev:fe": "mkdir -p src/main/resources/META-INF/resources && nodemon --watch src/conf --watch src/components --watch src/model --watch src/pages --watch src/styles --watch src/util -e ts,tsx,css -x 'APP_ENV=development yarn inject'", "dev:be": "mvn quarkus:dev", @@ -33,4 +41,4 @@ "npm-run-all2": "^6.0.1", "typescript": "4.7.4" } -} +}
\ No newline at end of file @@ -4,9 +4,31 @@ <modelVersion>4.0.0</modelVersion> <groupId>dev.submelon</groupId> <artifactId>pantry</artifactId> - <version>1.0.0-SNAPSHOT</version> + <version>0.1.0-SNAPSHOT</version> + <licenses> + <license> + <name>Blue Oak Model License 1.0.0</name> + <url>https://blueoakcouncil.org/license/1.0.0</url> + <distribution>repo</distribution> + <comments>A permissive and clearly-written license</comments> + </license> + </licenses> + <developers> + <developer> + <id>kjhoerr</id> + <name>Kevin J Hoerr</name> + <email>kjhoerr@submelon.tech</email> + <url>https://submelon.dev/</url> + </developer> + </developers> + <scm> + <connection>scm:git:https://github.com/kjhoerr/pantry</connection> + <developerConnection>scm:git:https://github.com/kjhoerr/pantry</developerConnection> + <url>https://github.com/kjhoerr/pantry</url> + </scm> <properties> <compiler-plugin.version>3.8.1</compiler-plugin.version> + <lombok.version>1.18.24</lombok.version> <maven.compiler.release>11</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> @@ -42,10 +64,6 @@ </dependency> <dependency> <groupId>io.quarkus</groupId> - <artifactId>quarkus-liquibase</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> <artifactId>quarkus-smallrye-jwt</artifactId> </dependency> <dependency> @@ -54,10 +72,6 @@ </dependency> <dependency> <groupId>io.quarkus</groupId> - <artifactId>quarkus-jdbc-postgresql</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> <artifactId>quarkus-arc</artifactId> </dependency> <dependency> @@ -67,11 +81,7 @@ </dependency> <dependency> <groupId>io.quarkus</groupId> - <artifactId>quarkus-reactive-pg-client</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-hibernate-orm-panache</artifactId> + <artifactId>quarkus-mongodb-panache</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> diff --git a/src/main/java/dev/submelon/rest/json/PantryItem.java b/src/main/java/dev/submelon/rest/json/PantryItem.java index d476e3c..6a30031 100644 --- a/src/main/java/dev/submelon/rest/json/PantryItem.java +++ b/src/main/java/dev/submelon/rest/json/PantryItem.java @@ -1,29 +1,29 @@ package dev.submelon.rest.json; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; +import java.util.UUID; -import io.quarkus.hibernate.orm.panache.PanacheEntity; +import org.bson.codecs.pojo.annotations.BsonId; + +import io.quarkus.mongodb.panache.PanacheMongoEntityBase; +import io.quarkus.mongodb.panache.common.MongoEntity; import lombok.Data; import lombok.EqualsAndHashCode; -@Entity -@Table(name = "pantryitem") @Data -@EqualsAndHashCode(callSuper = false) -public class PantryItem extends PanacheEntity { +@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true) +@MongoEntity(collection = "item") +public class PantryItem extends PanacheMongoEntityBase { - @Column(nullable = false) + @BsonId + @EqualsAndHashCode.Include + private UUID id; + private String name; - @Column private String description; - @Column(nullable = false) private double quantity; - @Column(nullable = false) private String quantityUnitType; } diff --git a/src/main/java/dev/submelon/rest/json/PantryItemResource.java b/src/main/java/dev/submelon/rest/json/PantryItemResource.java index 4bb51c0..75a986d 100644 --- a/src/main/java/dev/submelon/rest/json/PantryItemResource.java +++ b/src/main/java/dev/submelon/rest/json/PantryItemResource.java @@ -1,6 +1,7 @@ package dev.submelon.rest.json; import java.util.List; +import java.util.UUID; import javax.transaction.Transactional; import javax.ws.rs.DELETE; @@ -16,7 +17,7 @@ import javax.ws.rs.core.Response; @Path("/items") public class PantryItemResource { - + @GET @Produces(MediaType.APPLICATION_JSON) public List<PantryItem> getItems() { @@ -36,8 +37,9 @@ public class PantryItemResource { @PUT @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) - public PantryItem putItem(@PathParam("id") Long id, PantryItem item) { - if (item.id.equals(id)) { + public PantryItem putItem(@PathParam("id") String id, PantryItem item) { + UUID _id = UUID.fromString(id); + if (item.getId().equals(_id)) { PantryItem.persist(item); } else { throw new WebApplicationException(Response.status(400).entity("ID does not match body").build()); @@ -49,11 +51,13 @@ public class PantryItemResource { @Transactional @DELETE @Path("/{id}") - public void deleteItem(@PathParam("id") Long id) { - boolean result = PantryItem.deleteById(id); - - if (!result) { - throw new WebApplicationException(Response.status(404).entity("Could not find item").build()); + public Response deleteItem(@PathParam("id") String id) { + UUID _id = UUID.fromString(id); + boolean result = PantryItem.deleteById(_id); + if (result) { + return Response.ok().build(); + } else { + return Response.status(404).entity("Could not find item").build(); } } } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f36fb33..81f5248 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,2 @@ -quarkus.liquibase.clean-at-start=true -quarkus.liquibase.migrate-at-start=true -quarkus.liquibase.contexts=migrate,test +#quarkus.mongodb.connection-string=mongodb://localhost:27017 +quarkus.mongodb.database = pantry diff --git a/src/main/resources/db/changeLog.xml b/src/main/resources/db/changeLog.xml deleted file mode 100644 index 870baf4..0000000 --- a/src/main/resources/db/changeLog.xml +++ /dev/null @@ -1,9 +0,0 @@ -<databaseChangeLog - xmlns="http://www.liquibase.org/xml/ns/dbchangelog" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" - xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd - http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> - <include file="db/changelogs/20220804-add-pantryitem.xml" /> - <include file="db/changelogs/20220814-test-data.xml" /> -</databaseChangeLog>
\ No newline at end of file diff --git a/src/main/resources/db/changelogs/20220804-add-pantryitem.xml b/src/main/resources/db/changelogs/20220804-add-pantryitem.xml deleted file mode 100644 index f6ab0ee..0000000 --- a/src/main/resources/db/changelogs/20220804-add-pantryitem.xml +++ /dev/null @@ -1,30 +0,0 @@ -<databaseChangeLog - xmlns="http://www.liquibase.org/xml/ns/dbchangelog" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" - xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd - http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> - <changeSet id="20220804-add-pantryitem" author="kjhoerr" context="migrate"> - <validCheckSum>8:350c0b8d4ff8ce36a2453a0fe2373684</validCheckSum> - <createSequence - sequenceName="hibernate_sequence" - incrementBy="1" - startValue="1" - /> - <createTable tableName="pantryitem"> - <column name="id" type="int8"> - <constraints primaryKey="true" primaryKeyName="pk_pantryitem_id" nullable="false" /> - </column> - <column name="name" type="varchar(80)"> - <constraints nullable="false" /> - </column> - <column name="description" type="varchar(1000)" /> - <column name="quantity" type="float8"> - <constraints nullable="false" /> - </column> - <column name="quantityunittype" type="varchar(40)"> - <constraints nullable="false" /> - </column> - </createTable> - </changeSet> -</databaseChangeLog>
\ No newline at end of file diff --git a/src/main/resources/db/changelogs/20220814-test-data.xml b/src/main/resources/db/changelogs/20220814-test-data.xml deleted file mode 100644 index b8b9ad3..0000000 --- a/src/main/resources/db/changelogs/20220814-test-data.xml +++ /dev/null @@ -1,93 +0,0 @@ -<databaseChangeLog - xmlns="http://www.liquibase.org/xml/ns/dbchangelog" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" - xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd - http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> - <changeSet id="20220814-test-data" author="kjhoerr" context="test"> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Flour"/> - <column name="description" value="Unbleached white"/> - <column name="quantity" value="2.3"/> - <column name="quantityunittype" value="lb"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Sugar"/> - <column name="description" value="Granulated"/> - <column name="quantity" value="9.3"/> - <column name="quantityunittype" value="oz"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Eggs"/> - <column name="description" value="Large white"/> - <column name="quantity" value="10"/> - <column name="quantityunittype" value="ct"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Baking Powder"/> - <column name="description" value="Double acting"/> - <column name="quantity" value="3.3"/> - <column name="quantityunittype" value="oz"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Oat Milk"/> - <column name="description" value="Unsweetened/no flavoring"/> - <column name="quantity" value="107"/> - <column name="quantityunittype" value="oz"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Vanilla Extract"/> - <column name="description" value=""/> - <column name="quantity" value="8.8"/> - <column name="quantityunittype" value="oz"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Almond Extract"/> - <column name="description" value=""/> - <column name="quantity" value="1.07"/> - <column name="quantityunittype" value="oz"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Canola Oil"/> - <column name="description" value=""/> - <column name="quantity" value="51"/> - <column name="quantityunittype" value="oz"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Salt"/> - <column name="description" value="Iodized"/> - <column name="quantity" value="4.5"/> - <column name="quantityunittype" value="oz"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Baking Soda"/> - <column name="description" value=""/> - <column name="quantity" value="6.5"/> - <column name="quantityunittype" value="oz"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Butter"/> - <column name="description" value="Salted"/> - <column name="quantity" value="3.5"/> - <column name="quantityunittype" value="cups"/> - </insert> - <insert tableName="pantryitem"> - <column name="id" valueSequenceNext="hibernate_sequence"/> - <column name="name" value="Brown Sugar"/> - <column name="description" value=""/> - <column name="quantity" value="15"/> - <column name="quantityunittype" value="oz"/> - </insert> - </changeSet> -</databaseChangeLog>
\ No newline at end of file |
