diff --git a/Core/pom.xml b/Core/pom.xml index 494a614..cd0cc67 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -5,7 +5,7 @@ Gaps com.jasonhhouse - 0.1.3 + 0.1.4 4.0.0 diff --git a/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java b/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java index b6864fe..336116a 100644 --- a/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java +++ b/Core/src/main/java/com/jasonhhouse/gaps/GapsService.java @@ -26,9 +26,9 @@ public interface GapsService { /** * Updates PlexLibrary's to add them if not added and set them selected or unselected if added * - * @param plexLibraries The libraries to add or update + * @param selectedLibraries The libraries to update */ - void updateLibrarySelections(@NotNull List plexLibraries); + void updateLibrarySelections(@NotNull List selectedLibraries); /** * Updates the plex search object itself to the singleton object diff --git a/Dockerfile.no-ssl b/Dockerfile.no-ssl index 946061c..3702116 100644 --- a/Dockerfile.no-ssl +++ b/Dockerfile.no-ssl @@ -12,6 +12,6 @@ RUN mkdir -p /usr/app WORKDIR /usr/app -COPY GapsWeb/target/GapsWeb-0.1.3.jar /usr/app/ +COPY GapsWeb/target/GapsWeb-0.1.4.jar /usr/app/ -ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=no-ssl", "GapsWeb-0.1.3.jar"] \ No newline at end of file +ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=no-ssl", "GapsWeb-0.1.4.jar"] \ No newline at end of file diff --git a/Dockerfile.ssl b/Dockerfile.ssl index 0e173cf..b3d5838 100644 --- a/Dockerfile.ssl +++ b/Dockerfile.ssl @@ -12,6 +12,6 @@ RUN mkdir -p /usr/app WORKDIR /usr/app -COPY GapsWeb/target/GapsWeb-0.1.3.jar /usr/app/ +COPY GapsWeb/target/GapsWeb-0.1.4.jar /usr/app/ -ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=ssl", "GapsWeb-0.1.3.jar"] \ No newline at end of file +ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=ssl", "GapsWeb-0.1.4.jar"] \ No newline at end of file diff --git a/GapsOnWindows/GapsOnWindows.xml b/GapsOnWindows/GapsOnWindows.xml index f2a0551..759ffe9 100644 --- a/GapsOnWindows/GapsOnWindows.xml +++ b/GapsOnWindows/GapsOnWindows.xml @@ -2,8 +2,8 @@ false console - C:\Users\jh597\Code\Gaps\GapsWeb\target\GapsWeb-0.1.3.jar - C:\Users\jh597\Desktop\Gaps-v0.1.3.exe + C:\Users\jh597\Code\Gaps\GapsWeb\target\GapsWeb-0.1.4.jar + C:\Users\jh597\Desktop\Gaps-v0.1.4.exe . @@ -28,16 +28,16 @@ 64/32 - 0.1.3.0 + 0.1.4.0 Free Form Gaps 2019 - 0.1.3.0 + 0.1.4.0 Free Form Gaps Gaps - Gaps-v0.1.3.exe + Gaps-v0.1.4.exe ENGLISH_US diff --git a/GapsWeb/pom.xml b/GapsWeb/pom.xml index 896b910..669143c 100644 --- a/GapsWeb/pom.xml +++ b/GapsWeb/pom.xml @@ -5,7 +5,7 @@ Gaps com.jasonhhouse - 0.1.3 + 0.1.4 4.0.0 @@ -19,7 +19,7 @@ com.jasonhhouse Core - 0.1.3 + 0.1.4 diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexLibrariesController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexLibrariesController.java index 06066b6..ddf5d04 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexLibrariesController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexLibrariesController.java @@ -10,6 +10,8 @@ package com.jasonhhouse.gaps.controller; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.jasonhhouse.gaps.GapsService; import com.jasonhhouse.gaps.PlexLibrary; import com.jasonhhouse.gaps.PlexQuery; @@ -19,6 +21,8 @@ import com.jasonhhouse.gaps.service.BindingErrorsService; import com.jasonhhouse.gaps.service.IoService; import com.jasonhhouse.gaps.validator.PlexPropertiesValidator; import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import javax.validation.Valid; import org.slf4j.Logger; @@ -72,8 +76,6 @@ public class PlexLibrariesController { List plexLibraries = plexQuery.getLibraries(plexSearch); gapsService.getPlexSearch().getLibraries().addAll(plexLibraries); - LOGGER.info(gapsService.getPlexSearch().toString()); - ModelAndView modelAndView = new ModelAndView("plexLibraries"); modelAndView.addObject("plexSearch", gapsService.getPlexSearch()); return modelAndView; @@ -94,4 +96,79 @@ public class PlexLibrariesController { binder.addCustomFormatter(new PlexSearchFormatter(), "plexSearch"); binder.setValidator(new PlexPropertiesValidator()); } + + private void setPlexSearch() { + String json = "[\n" + + " {\n" + + " \"key\": 23,\n" + + " \"title\": \"BM\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 22,\n" + + " \"title\": \"Family Videos\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 13,\n" + + " \"title\": \"Grandad Movies\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 2,\n" + + " \"title\": \"Movies\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 14,\n" + + " \"title\": \"Movies - 3D\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 11,\n" + + " \"title\": \"Movies - 4K\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 16,\n" + + " \"title\": \"Stand Up Comedy\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 6,\n" + + " \"title\": \"Workout Videos\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 9,\n" + + " \"title\": \"Bassnectar\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 10,\n" + + " \"title\": \"Halloween\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 20,\n" + + " \"title\": \"Home Theater Demos\",\n" + + " \"selected\": false\n" + + " },\n" + + " {\n" + + " \"key\": 19,\n" + + " \"title\": \"Pre-Rolls\",\n" + + " \"selected\": false\n" + + " }\n" + + "]"; + + ObjectMapper objectMapper = new ObjectMapper(); + List plexLibraries; + try { + plexLibraries = Arrays.asList(objectMapper.readValue(json, PlexLibrary[].class)); + gapsService.getPlexSearch().getLibraries().addAll(plexLibraries); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + } } diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java index ef25df6..536e7b6 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java @@ -17,8 +17,10 @@ import com.jasonhhouse.gaps.PlexSearch; import com.jasonhhouse.gaps.PlexSearchFormatter; import com.jasonhhouse.gaps.service.BindingErrorsService; import com.jasonhhouse.gaps.validator.PlexLibrariesValidator; +import java.util.ArrayList; import java.util.List; import javax.validation.Valid; +import org.apache.commons.collections4.CollectionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -49,17 +51,15 @@ public class PlexMovieListController { } @RequestMapping(method = RequestMethod.POST, - consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE) - public ModelAndView postPlexMovieList(@Valid PlexSearch plexSearch, BindingResult bindingResult) { - LOGGER.info("postPlexMovieList( " + plexSearch + " )"); + public ModelAndView postPlexMovieList(@RequestParam ArrayList selectedLibraries) { + LOGGER.info("postPlexMovieList( " + selectedLibraries + " )"); - if (bindingErrorsService.hasBindingErrors(bindingResult)) { + if(CollectionUtils.isEmpty(selectedLibraries)) { return bindingErrorsService.getErrorPage(); } - gapsService.updateLibrarySelections(plexSearch.getLibraries()); - gapsService.updatePlexSearch(plexSearch); + gapsService.updateLibrarySelections(selectedLibraries); ModelAndView modelAndView = new ModelAndView("plexMovieList"); LOGGER.info(gapsService.getPlexSearch().toString()); diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsServiceImpl.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsServiceImpl.java index 81e1531..7d8a9d2 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsServiceImpl.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsServiceImpl.java @@ -14,6 +14,7 @@ import com.jasonhhouse.gaps.GapsService; import com.jasonhhouse.gaps.PlexLibrary; import com.jasonhhouse.gaps.PlexSearch; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; @@ -39,16 +40,17 @@ public class GapsServiceImpl implements GapsService { } @Override - public void updateLibrarySelections(@NotNull List plexLibraries) { - LOGGER.info("updateLibrarySelections( " + plexLibraries + " )"); + public void updateLibrarySelections(@NotNull List selectedLibraries) { + LOGGER.info("updateLibrarySelections( " + selectedLibraries + " )"); LOGGER.info("BEFORE:" + getPlexSearch().getLibraries().toString()); - for (PlexLibrary plexLibrary : plexLibraries) { - int index = getPlexSearch().getLibraries().indexOf(plexLibrary); - LOGGER.info("Index of plexLibrary: " + index + " - " + plexLibrary); - if (index == -1) { - getPlexSearch().getLibraries().add(plexLibrary); + for (String selectedLibrary : selectedLibraries) { + + Optional library = getPlexSearch().getLibraries().stream().filter(plexLibrary -> plexLibrary.getKey().equals(Integer.valueOf(selectedLibrary))).findFirst(); + + if (!library.isPresent()) { + LOGGER.warn("Can't find library"); } else { - getPlexSearch().getLibraries().get(index).setSelected(plexLibrary.getSelected()); + library.get().setSelected(true); } } diff --git a/GapsWeb/src/main/resources/application.yaml b/GapsWeb/src/main/resources/application.yaml index bf9aa0e..963e497 100644 --- a/GapsWeb/src/main/resources/application.yaml +++ b/GapsWeb/src/main/resources/application.yaml @@ -47,7 +47,7 @@ info: app: name: Gaps description: Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course. - version: 0.1.3 + version: 0.1.4 --- spring: @@ -79,5 +79,5 @@ info: app: name: Gaps description: Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course. - version: 0.1.3 + version: 0.1.4 diff --git a/GapsWeb/src/main/resources/templates/folder.html b/GapsWeb/src/main/resources/templates/folder.html index 1434823..e80b977 100644 --- a/GapsWeb/src/main/resources/templates/folder.html +++ b/GapsWeb/src/main/resources/templates/folder.html @@ -155,7 +155,7 @@
-
Gaps v0.1.3
+
Gaps v0.1.4
diff --git a/GapsWeb/src/main/resources/templates/index.html b/GapsWeb/src/main/resources/templates/index.html index 106a82f..28d1439 100644 --- a/GapsWeb/src/main/resources/templates/index.html +++ b/GapsWeb/src/main/resources/templates/index.html @@ -39,7 +39,7 @@

Welcome to Gaps

-

v0.1.3

+

v0.1.4

Gaps searches through your Plex Server. It then queries for known diff --git a/GapsWeb/src/main/resources/templates/plexLibraries.html b/GapsWeb/src/main/resources/templates/plexLibraries.html index f9f4b66..a6fcc38 100644 --- a/GapsWeb/src/main/resources/templates/plexLibraries.html +++ b/GapsWeb/src/main/resources/templates/plexLibraries.html @@ -49,12 +49,10 @@

These are the movie libraries we found in your Plex Server. Select any and all you would like to look for gaps in.

-
-
- - - - + +
+ +
diff --git a/GapsWeb/src/test/java/com/jasonhhouse/gaps/GapsServiceTest.java b/GapsWeb/src/test/java/com/jasonhhouse/gaps/GapsServiceTest.java index b40bc6a..b082318 100644 --- a/GapsWeb/src/test/java/com/jasonhhouse/gaps/GapsServiceTest.java +++ b/GapsWeb/src/test/java/com/jasonhhouse/gaps/GapsServiceTest.java @@ -29,7 +29,7 @@ public class GapsServiceTest implements GapsService { } @Override - public void updateLibrarySelections(@NotNull List plexLibraries) { + public void updateLibrarySelections(@NotNull List plexLibraries) { } diff --git a/build.sh b/build.sh index e4be076..529dfee 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,5 @@ #!/bin/bash -VERSION=0.1.3 +VERSION=0.1.4 DOCKER_SSL_LATEST="housewrecker/gaps:latest" DOCKER_NO_SSL_LATEST="housewrecker/gaps:latest-no-ssl" JAR_VERSION="GapsWeb/target/GapsWeb-$VERSION.jar" diff --git a/buildVersion.sh b/buildVersion.sh index 3c7ae14..f5a2d3e 100755 --- a/buildVersion.sh +++ b/buildVersion.sh @@ -1,5 +1,5 @@ #!/bin/bash -VERSION=0.1.3 +VERSION="-v0.1.4" DOCKER_SSL_VERSION="housewrecker/gaps:v$VERSION" DOCKER_NO_SSL_VERSION="housewrecker/gaps:v$VERSION-no-ssl" JAR_VERSION="GapsWeb/target/GapsWeb-$VERSION.jar" diff --git a/pom.xml b/pom.xml index 2e3f29c..07965b3 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ com.jasonhhouse Gaps - 0.1.3 + 0.1.4 Gaps Demo project for Spring Boot