From 0b5ddd4b0ac0b886e8892aa6786a2dfe36cdd3e2 Mon Sep 17 00:00:00 2001 From: Jason House Date: Tue, 4 Aug 2020 22:40:49 +0900 Subject: [PATCH] Hackathon start Spring Boot 2.3.2-RELEASE Apache Commons Text 1.9 SQLite3 Integration for Mislabeled --- .../jasonhhouse/gaps/MovieFromCollection.java | 16 +-- .../gaps/json/MovieSerializer.java | 2 +- Dockerfile | 4 + Dockerfile.armhf | 2 +- GapsWeb/pom.xml | 38 +++++- .../com/jasonhhouse/gaps/GapsApplication.java | 7 +- .../gaps/controller/MislabeledController.java | 51 ++++++- .../gaps/service/MediaContainerService.java | 32 +++++ .../gaps/service/MislabeledService.java | 6 +- .../gaps/sql/MediaContainerRepository.java | 8 ++ .../com/jasonhhouse/gaps/sql/SQLDialect.java | 129 ++++++++++++++++++ GapsWeb/src/main/resources/application.yaml | 9 ++ .../src/main/resources/templates/updates.html | 10 ++ GapsWeb/src/test/resources/application.yaml | 12 +- Plex/pom.xml | 6 +- .../java/com/jasonhhouse/plex/Collection.java | 17 +++ .../java/com/jasonhhouse/plex/Country.java | 17 +++ .../java/com/jasonhhouse/plex/Director.java | 17 +++ .../main/java/com/jasonhhouse/plex/Genre.java | 18 +++ .../main/java/com/jasonhhouse/plex/Media.java | 5 + .../com/jasonhhouse/plex/MediaContainer.java | 18 ++- .../main/java/com/jasonhhouse/plex/Part.java | 4 + .../main/java/com/jasonhhouse/plex/Role.java | 17 +++ .../main/java/com/jasonhhouse/plex/Video.java | 20 +++ .../java/com/jasonhhouse/plex/Writer.java | 17 +++ pom.xml | 4 +- start.sh | 8 +- 27 files changed, 463 insertions(+), 31 deletions(-) create mode 100644 GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MediaContainerService.java create mode 100644 GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/MediaContainerRepository.java create mode 100644 GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/SQLDialect.java diff --git a/Core/src/main/java/com/jasonhhouse/gaps/MovieFromCollection.java b/Core/src/main/java/com/jasonhhouse/gaps/MovieFromCollection.java index 2e79158..eca6d8d 100644 --- a/Core/src/main/java/com/jasonhhouse/gaps/MovieFromCollection.java +++ b/Core/src/main/java/com/jasonhhouse/gaps/MovieFromCollection.java @@ -7,13 +7,13 @@ public final class MovieFromCollection { @NotNull private final String title; @NotNull - private final String id; + private final String tmdbId; @NotNull private final Boolean owned; - public MovieFromCollection(@NotNull String title, @NotNull String id, @NotNull Boolean owned) { + public MovieFromCollection(@NotNull String title, @NotNull String tmdbId, @NotNull Boolean owned) { this.title = title; - this.id = id; + this.tmdbId = tmdbId; this.owned = owned; } @@ -23,8 +23,8 @@ public final class MovieFromCollection { } @NotNull - public String getId() { - return id; + public String getTmdbId() { + return tmdbId; } @NotNull @@ -38,20 +38,20 @@ public final class MovieFromCollection { if (o == null || getClass() != o.getClass()) return false; MovieFromCollection that = (MovieFromCollection) o; return title.equals(that.title) && - id.equals(that.id) && + tmdbId.equals(that.tmdbId) && owned.equals(that.owned); } @Override public int hashCode() { - return Objects.hash(title, id, owned); + return Objects.hash(title, tmdbId, owned); } @Override public String toString() { return "MovieFromCollection{" + "title='" + title + '\'' + - ", id='" + id + '\'' + + ", id='" + tmdbId + '\'' + ", owned=" + owned + '}'; } diff --git a/Core/src/main/java/com/jasonhhouse/gaps/json/MovieSerializer.java b/Core/src/main/java/com/jasonhhouse/gaps/json/MovieSerializer.java index 1fb7933..8f3f1f9 100755 --- a/Core/src/main/java/com/jasonhhouse/gaps/json/MovieSerializer.java +++ b/Core/src/main/java/com/jasonhhouse/gaps/json/MovieSerializer.java @@ -42,7 +42,7 @@ public class MovieSerializer extends StdSerializer { for (MovieFromCollection movieInCollection : movie.getMoviesInCollection()) { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("title", movieInCollection.getTitle()); - jsonGenerator.writeStringField("id", movieInCollection.getId()); + jsonGenerator.writeStringField("id", movieInCollection.getTmdbId()); jsonGenerator.writeBooleanField("owned", movieInCollection.getOwned()); jsonGenerator.writeEndObject(); } diff --git a/Dockerfile b/Dockerfile index 7c2d436..ebdbfd5 100755 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,10 @@ LABEL github="https://github.com/JasonHHouse/Gaps" EXPOSE 32400 +RUN apt-get -y update + +RUN apt-get -y upgrade + ENV JAR_FILE gaps.jar ENV ENABLE_SSL false diff --git a/Dockerfile.armhf b/Dockerfile.armhf index ed4aa80..6197bdc 100755 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -4,7 +4,7 @@ LABEL maintainer="jh5975@gmail.com" LABEL name="Jason House" LABEL github="https://github.com/JasonHHouse/Gaps" -RUN echo "**** install jre 11 ****" && apt-get update && apt-get install -y openjdk-11-jre +RUN echo "**** install jre 11 ****" && apt-get -y update && apt-get -y install -y openjdk-11-jre EXPOSE 32400 diff --git a/GapsWeb/pom.xml b/GapsWeb/pom.xml index f441557..b7f075f 100755 --- a/GapsWeb/pom.xml +++ b/GapsWeb/pom.xml @@ -64,6 +64,42 @@ spring-boot-starter-security + + org.springframework.boot + spring-boot-starter-jdbc + + + + org.xerial + sqlite-jdbc + 3.32.3.2 + + + + + com.zsoltfabok + sqlite-dialect + 1.0 + + + + + org.hibernate + hibernate-core + 5.2.12.Final + + + + com.h2database + h2 + test + + + + org.springframework.boot + spring-boot-starter-data-jpa + + org.webjars webjars-locator-core @@ -163,7 +199,7 @@ org.apache.commons commons-text - 1.8 + 1.9 diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsApplication.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsApplication.java index 5c2d1ba..52d96ac 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsApplication.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsApplication.java @@ -14,11 +14,9 @@ import com.jasonhhouse.gaps.service.GapsServiceImpl; import java.util.concurrent.Executor; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.MessageSource; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.Scope; +import org.springframework.context.annotation.*; import org.springframework.context.support.ReloadableResourceBundleMessageSource; import org.springframework.format.FormatterRegistry; import org.springframework.scheduling.annotation.EnableAsync; @@ -29,6 +27,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; * Search for all missing movies in your plex collection by MovieDB collection. */ @SpringBootApplication +@EntityScan("com.jasonhhouse.plex") @EnableAsync public class GapsApplication { diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/MislabeledController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/MislabeledController.java index ae97c83..f4c702e 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/MislabeledController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/MislabeledController.java @@ -12,9 +12,11 @@ package com.jasonhhouse.gaps.controller; import com.jasonhhouse.gaps.GapsService; import com.jasonhhouse.gaps.Mislabeled; import com.jasonhhouse.gaps.PlexQuery; +import com.jasonhhouse.gaps.service.MediaContainerService; import com.jasonhhouse.gaps.service.MislabeledService; import com.jasonhhouse.plex.MediaContainer; import java.util.List; +import org.apache.commons.lang3.time.StopWatch; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -35,12 +37,14 @@ public class MislabeledController { private final GapsService gapsService; private final PlexQuery plexQuery; private final MislabeledService mislabeledService; + private final MediaContainerService mediaContainerService; @Autowired - public MislabeledController(GapsService gapsService, PlexQuery plexQuery, MislabeledService mislabeledService) { + public MislabeledController(GapsService gapsService, PlexQuery plexQuery, MislabeledService mislabeledService, MediaContainerService mediaContainerService) { this.gapsService = gapsService; this.plexQuery = plexQuery; this.mislabeledService = mislabeledService; + this.mediaContainerService = mediaContainerService; } @GetMapping(produces = MediaType.TEXT_HTML_VALUE) @@ -50,16 +54,61 @@ public class MislabeledController { return new ModelAndView("mislabeled"); } + @GetMapping(value = "/{machineIdentifier}/{key}") + @ResponseBody + public ResponseEntity getMisMatched(@PathVariable("machineIdentifier") final String machineIdentifier, @PathVariable("key") final Integer key) { + LOGGER.info("getPlexMovies( {}, {} )", machineIdentifier, key); + + StopWatch watch = new StopWatch(); + watch.start(); + + String url = generatePlexUrl(machineIdentifier, key); + MediaContainer mediaContainer = plexQuery.findAllPlexVideos(url); + mediaContainerService.deleteAll(); + mediaContainerService.save(mediaContainer); + + watch.stop(); + LOGGER.info("SQLite3 Update {}", watch.getNanoTime()); + + return ResponseEntity.ok().body("Success"); + } + @GetMapping(value = "/{machineIdentifier}/{key}/{percentage}") @ResponseBody public ResponseEntity> getMisMatched(@PathVariable("machineIdentifier") final String machineIdentifier, @PathVariable("key") final Integer key, @PathVariable("percentage") final Double percentage) { LOGGER.info("getPlexMovies( {}, {}, {} )", machineIdentifier, key, percentage); + StopWatch watch = new StopWatch(); + watch.start(); + + //ToDo Hardcoded + MediaContainer mediaContainer = mediaContainerService.list().get(0); + mediaContainerService.save(mediaContainer); + List mislabeled = mislabeledService.findMatchPercentage(mediaContainer, percentage); + + watch.stop(); + LOGGER.info("SQLite3 Find All {}", watch.getNanoTime()); + + return ResponseEntity.ok().body(mislabeled); + } + + @GetMapping(value = "/plex/{machineIdentifier}/{key}/{percentage}") + @ResponseBody + public ResponseEntity> getPlexMisMatched(@PathVariable("machineIdentifier") final String machineIdentifier, @PathVariable("key") final Integer key, + @PathVariable("percentage") final Double percentage) { + LOGGER.info("getPlexMovies( {}, {}, {} )", machineIdentifier, key, percentage); + + StopWatch watch = new StopWatch(); + watch.start(); + String url = generatePlexUrl(machineIdentifier, key); MediaContainer mediaContainer = plexQuery.findAllPlexVideos(url); List mislabeled = mislabeledService.findMatchPercentage(mediaContainer, percentage); + watch.stop(); + LOGGER.info("Plex Runtime {}", watch.getNanoTime()); + return ResponseEntity.ok().body(mislabeled); } diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MediaContainerService.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MediaContainerService.java new file mode 100644 index 0000000..33828ff --- /dev/null +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MediaContainerService.java @@ -0,0 +1,32 @@ +package com.jasonhhouse.gaps.service; + +import com.jasonhhouse.gaps.sql.MediaContainerRepository; +import com.jasonhhouse.plex.MediaContainer; +import java.util.List; +import org.springframework.stereotype.Service; + +@Service +public class MediaContainerService { + private final MediaContainerRepository mediaContainerRepository; + + public MediaContainerService(MediaContainerRepository mediaContainerRepository) { + this.mediaContainerRepository = mediaContainerRepository; + } + + public List list() { + return mediaContainerRepository.findAll(); + } + + public void saveAll(List mediaContainers) { + mediaContainerRepository.saveAll(mediaContainers); + } + + public void save(MediaContainer mediaContainer) { + mediaContainerRepository.save(mediaContainer); + } + + public void deleteAll() { + mediaContainerRepository.deleteAll(); + } + +} diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MislabeledService.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MislabeledService.java index e28b8e4..1b44494 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MislabeledService.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MislabeledService.java @@ -23,8 +23,10 @@ import org.springframework.stereotype.Service; public class MislabeledService { private static final Logger LOGGER = LoggerFactory.getLogger(MislabeledService.class); + private static final LevenshteinDistance levenshteinDistance = new LevenshteinDistance(); public List findMatchPercentage(MediaContainer mediaContainer, Double percentage) { + LOGGER.info("findMatchPercentage( {} )", percentage); List mislabeled = new ArrayList<>(); for (Video video : mediaContainer.getVideos()) { String file = video.getMedia().get(0).getParts().get(0).getFile(); @@ -36,8 +38,6 @@ public class MislabeledService { file = file.substring(file.lastIndexOf('/') + 1); String title = video.getTitle(); title = title.replace(":", ""); - LOGGER.info("title:{}", title); - LOGGER.info("file:{}", file); Double matchPercentage = similarity(title, file); if (matchPercentage < percentage) { Mislabeled mislabeledItem = new Mislabeled(file, title, matchPercentage); @@ -58,7 +58,7 @@ public class MislabeledService { if (longerLength == 0) { return 1.0; /* both strings are zero length */ } - LevenshteinDistance levenshteinDistance = new LevenshteinDistance(); + return (longerLength - levenshteinDistance.apply(longer, shorter)) / (double) longerLength; } diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/MediaContainerRepository.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/MediaContainerRepository.java new file mode 100644 index 0000000..3c48ebe --- /dev/null +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/MediaContainerRepository.java @@ -0,0 +1,8 @@ +package com.jasonhhouse.gaps.sql; + +import com.jasonhhouse.plex.MediaContainer; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MediaContainerRepository extends JpaRepository { + +} diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/SQLDialect.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/SQLDialect.java new file mode 100644 index 0000000..73554b2 --- /dev/null +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/SQLDialect.java @@ -0,0 +1,129 @@ +package com.jasonhhouse.gaps.sql; + +import org.hibernate.dialect.Dialect; +import org.hibernate.dialect.function.SQLFunctionTemplate; +import org.hibernate.dialect.function.StandardSQLFunction; +import org.hibernate.dialect.function.VarArgsSQLFunction; +import org.hibernate.type.StringType; + +import java.sql.Types; + +public class SQLDialect extends Dialect { + + public SQLDialect() { + registerColumnType(Types.BIT, "integer"); + registerColumnType(Types.TINYINT, "tinyint"); + registerColumnType(Types.SMALLINT, "smallint"); + registerColumnType(Types.INTEGER, "integer"); + registerColumnType(Types.BIGINT, "bigint"); + registerColumnType(Types.FLOAT, "float"); + registerColumnType(Types.REAL, "real"); + registerColumnType(Types.DOUBLE, "double"); + registerColumnType(Types.NUMERIC, "numeric"); + registerColumnType(Types.DECIMAL, "decimal"); + registerColumnType(Types.CHAR, "char"); + registerColumnType(Types.VARCHAR, "varchar"); + registerColumnType(Types.LONGVARCHAR, "longvarchar"); + registerColumnType(Types.DATE, "date"); + registerColumnType(Types.TIME, "time"); + registerColumnType(Types.TIMESTAMP, "timestamp"); + registerColumnType(Types.BINARY, "blob"); + registerColumnType(Types.VARBINARY, "blob"); + registerColumnType(Types.LONGVARBINARY, "blob"); + // registerColumnType(Types.NULL, "null"); + registerColumnType(Types.BLOB, "blob"); + registerColumnType(Types.CLOB, "clob"); + registerColumnType(Types.BOOLEAN, "integer"); + + registerFunction("concat", new VarArgsSQLFunction(StringType.INSTANCE, "", "||", "")); + registerFunction("mod", new SQLFunctionTemplate(StringType.INSTANCE, "?1 % ?2")); + registerFunction("substr", new StandardSQLFunction("substr", StringType.INSTANCE)); + registerFunction("substring", new StandardSQLFunction("substr", StringType.INSTANCE)); + } + + public boolean supportsIdentityColumns() { + return true; + } + + public boolean hasDataTypeInIdentityColumn() { + return false; // As specify in NHibernate dialect + } + + public String getIdentityColumnString() { + // return "integer primary key autoincrement"; + return "integer"; + } + + public String getIdentitySelectString() { + return "select last_insert_rowid()"; + } + + public boolean supportsTemporaryTables() { + return true; + } + + public String getCreateTemporaryTableString() { + return "create temporary table if not exists"; + } + + public boolean dropTemporaryTableAfterUse() { + return false; + } + + public boolean supportsCurrentTimestampSelection() { + return true; + } + + public boolean isCurrentTimestampSelectStringCallable() { + return false; + } + + public String getCurrentTimestampSelectString() { + return "select current_timestamp"; + } + + public boolean supportsUnionAll() { + return true; + } + + public boolean hasAlterTable() { + return false; // As specify in NHibernate dialect + } + + public boolean dropConstraints() { + return false; + } + + public String getAddColumnString() { + return "add column"; + } + + public String getForUpdateString() { + return ""; + } + + public boolean supportsOuterJoinForUpdate() { + return false; + } + + public String getDropForeignKeyString() { + throw new UnsupportedOperationException("No drop foreign key syntax supported by SQLiteDialect"); + } + + public String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, + String[] primaryKey, boolean referencesPrimaryKey) { + throw new UnsupportedOperationException("No add foreign key syntax supported by SQLiteDialect"); + } + + public String getAddPrimaryKeyConstraintString(String constraintName) { + throw new UnsupportedOperationException("No add primary key syntax supported by SQLiteDialect"); + } + + public boolean supportsIfExistsBeforeTableName() { + return true; + } + + public boolean supportsCascadeDelete() { + return false; + } +} \ No newline at end of file diff --git a/GapsWeb/src/main/resources/application.yaml b/GapsWeb/src/main/resources/application.yaml index f3ea3c5..82f3c58 100755 --- a/GapsWeb/src/main/resources/application.yaml +++ b/GapsWeb/src/main/resources/application.yaml @@ -23,6 +23,15 @@ spring: max-age: 120 must-revalidate: true cache-public: true + jpa: + database-platform: com.jasonhhouse.gaps.sql.SQLDialect + hibernate: + ddl-auto: update + datasource: + url: jdbc:sqlite:/usr/data/gaps.db + driver-class-name: org.sqlite.JDBC + username: admin + password: admin server: http2: enabled: true diff --git a/GapsWeb/src/main/resources/templates/updates.html b/GapsWeb/src/main/resources/templates/updates.html index 3fc5c59..96d0a31 100755 --- a/GapsWeb/src/main/resources/templates/updates.html +++ b/GapsWeb/src/main/resources/templates/updates.html @@ -78,6 +78,16 @@ Gaps Logo

Updates

+

v0.5.0

+
    +
  • Spring Boot 2.3.2-RELEASE
  • +
  • Apache Commons Text 1.9
  • +
  • Adding SQLite3 to store instead of JSON files
  • +
  • *New* Mislabeled Tab
  • +
  • Automatic running of Gaps
  • +
  • Notification Support
  • +
+

v0.4.8

  • Switching to using IDs instead of names for movies in collections
  • diff --git a/GapsWeb/src/test/resources/application.yaml b/GapsWeb/src/test/resources/application.yaml index b19828f..fd70901 100755 --- a/GapsWeb/src/test/resources/application.yaml +++ b/GapsWeb/src/test/resources/application.yaml @@ -14,4 +14,14 @@ info: 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.4.8 - loginEnabled: false \ No newline at end of file + loginEnabled: false +spring: + jpa: + database-platform: com.jasonhhouse.gaps.sql.SQLDialect + hibernate: + ddl-auto: update + datasource: + url: jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 + driver-class-name: org.h2.Driver + username: admin + password: admin \ No newline at end of file diff --git a/Plex/pom.xml b/Plex/pom.xml index e6485bd..5e6bdeb 100755 --- a/Plex/pom.xml +++ b/Plex/pom.xml @@ -15,7 +15,7 @@ org.apache.commons commons-text - 1.8 + 1.9 @@ -36,6 +36,10 @@ ${jaxb.api.version} + + org.springframework.boot + spring-boot-starter-data-jpa + commons-io diff --git a/Plex/src/main/java/com/jasonhhouse/plex/Collection.java b/Plex/src/main/java/com/jasonhhouse/plex/Collection.java index d2f0da5..3335164 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/Collection.java +++ b/Plex/src/main/java/com/jasonhhouse/plex/Collection.java @@ -9,11 +9,28 @@ */ package com.jasonhhouse.plex; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.xml.bind.annotation.XmlAttribute; +@Entity public final class Collection { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Integer id; private String tag; + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + public String getTag() { return tag; } diff --git a/Plex/src/main/java/com/jasonhhouse/plex/Country.java b/Plex/src/main/java/com/jasonhhouse/plex/Country.java index eda2ce6..cac9532 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/Country.java +++ b/Plex/src/main/java/com/jasonhhouse/plex/Country.java @@ -9,11 +9,28 @@ */ package com.jasonhhouse.plex; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.xml.bind.annotation.XmlAttribute; +@Entity public final class Country { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Integer id; private String tag; + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + public String getTag() { return tag; } diff --git a/Plex/src/main/java/com/jasonhhouse/plex/Director.java b/Plex/src/main/java/com/jasonhhouse/plex/Director.java index b7aea6d..951b7fc 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/Director.java +++ b/Plex/src/main/java/com/jasonhhouse/plex/Director.java @@ -9,11 +9,28 @@ */ package com.jasonhhouse.plex; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.xml.bind.annotation.XmlAttribute; +@Entity public final class Director { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Integer id; private String tag; + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + public String getTag() { return tag; } diff --git a/Plex/src/main/java/com/jasonhhouse/plex/Genre.java b/Plex/src/main/java/com/jasonhhouse/plex/Genre.java index 3b2843b..96c0957 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/Genre.java +++ b/Plex/src/main/java/com/jasonhhouse/plex/Genre.java @@ -9,11 +9,29 @@ */ package com.jasonhhouse.plex; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.xml.bind.annotation.XmlAttribute; +@Entity public final class Genre { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Integer id; + private String tag; + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + public String getTag() { return tag; } diff --git a/Plex/src/main/java/com/jasonhhouse/plex/Media.java b/Plex/src/main/java/com/jasonhhouse/plex/Media.java index 8246c5b..c60fb91 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/Media.java +++ b/Plex/src/main/java/com/jasonhhouse/plex/Media.java @@ -11,10 +11,14 @@ package com.jasonhhouse.plex; import java.util.List; import java.util.Objects; +import javax.persistence.*; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; +@Entity public final class Media { + + @Id private Integer id; private Integer duration; private Integer bitrate; @@ -27,6 +31,7 @@ public final class Media { private String videoResolution; private String container; private String videoProfile; + @OneToMany(cascade = CascadeType.ALL) private List parts; public Integer getId() { diff --git a/Plex/src/main/java/com/jasonhhouse/plex/MediaContainer.java b/Plex/src/main/java/com/jasonhhouse/plex/MediaContainer.java index dbb86ca..4502854 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/MediaContainer.java +++ b/Plex/src/main/java/com/jasonhhouse/plex/MediaContainer.java @@ -9,15 +9,21 @@ */ package com.jasonhhouse.plex; -import java.util.ArrayList; -import java.util.List; +import javax.persistence.*; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; +@Entity @XmlRootElement(name = "MediaContainer") public final class MediaContainer { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Integer id; + @OneToMany(cascade = CascadeType.ALL) private List