001package net.filebot.web; 002 003import java.io.Serializable; 004 005public class SearchResultDetails extends SearchResult implements Serializable { 006 007 // common properties 008 protected SimpleDate firstAired; 009 protected String overview; 010 protected String originalName; 011 protected String originalLanguage; 012 protected String[] country; 013 014 // TheMovieDB properties 015 protected Double popularity; 016 017 // TheTVDB properties 018 protected String slug; 019 protected String network; 020 protected String status; 021 022 public SearchResultDetails() { 023 // used by deserializer 024 } 025 026 public SearchResultDetails(SearchResult base, SearchResultDetails details) { 027 super(base); 028 029 this.firstAired = details.firstAired; 030 this.overview = details.overview; 031 this.originalName = details.originalName; 032 this.originalLanguage = details.originalLanguage; 033 this.country = details.country; 034 035 this.popularity = details.popularity; 036 037 this.slug = details.slug; 038 this.network = details.network; 039 this.status = details.status; 040 } 041 042 // common constructor 043 public SearchResultDetails(int id, String name, String[] aliasNames, SimpleDate firstAired, String overview, String originalName, String originalLanguage, String[] country, Double popularity, String slug, String network, String status) { 044 // common properties 045 super(id, name, aliasNames); 046 this.firstAired = firstAired; 047 this.overview = overview; 048 this.originalName = originalName; 049 this.originalLanguage = originalLanguage; 050 this.country = country; 051 // TheMovieDB properties 052 this.popularity = popularity; 053 // TheTVDB properties 054 this.slug = slug; 055 this.network = network; 056 this.status = status; 057 } 058 059 // common properties 060 061 public SimpleDate getFirstAired() { 062 return firstAired; 063 } 064 065 public String getOverview() { 066 return overview; 067 } 068 069 public String getOriginalName() { 070 return originalName; 071 } 072 073 public String getOriginalLanguage() { 074 return originalLanguage; 075 } 076 077 public String[] getCountry() { 078 return country; 079 } 080 081 // TheMovieDB properties 082 083 public Double getPopularity() { 084 return popularity; 085 } 086 087 // TheTVDB properties 088 089 public String getSlug() { 090 return slug; 091 } 092 093 public String getNetwork() { 094 return network; 095 } 096 097 public String getStatus() { 098 return status; 099 } 100 101 @Override 102 public SearchResultDetails clone() { 103 return new SearchResultDetails(this, this); 104 } 105 106 public String getNameWithYear() { 107 String n = toString(); 108 String y = getFirstAired() != null ? " (" + getFirstAired().getYear() + ")" : ""; 109 return n.endsWith(y) ? n : n + y; 110 } 111 112 public static SearchResultDetails from(SeriesInfo s) { 113 if (s == null) { 114 return null; 115 } 116 117 // extended series information 118 if (s instanceof SeriesDetails) { 119 SeriesDetails d = (SeriesDetails) s; 120 return new SearchResultDetails(s.getId(), s.getName(), s.getAliasNames().toArray(EMPTY_STRING_ARRAY), s.getStartDate(), d.getOverview(), d.getOriginalName(), d.getOriginalLanguage(), d.getCountry().toArray(EMPTY_STRING_ARRAY), d.getPopularity(), d.getSlug(), s.getNetwork(), s.getStatus()); 121 } 122 123 // basic series information 124 return new SearchResultDetails(s.getId(), s.getName(), s.getAliasNames().toArray(EMPTY_STRING_ARRAY), s.getStartDate(), null, null, null, null, null, null, s.getNetwork(), s.getStatus()); 125 } 126 127}