master
Stuart Boston 11 years ago
parent 69d2eba4db
commit 410df1f056

@ -46,7 +46,7 @@ import com.omertron.themoviedbapi.model.Certification;
import com.omertron.themoviedbapi.model.change.ChangedMedia; import com.omertron.themoviedbapi.model.change.ChangedMedia;
import com.omertron.themoviedbapi.model2.collection.Collection; import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model2.collection.CollectionInfo; import com.omertron.themoviedbapi.model2.collection.CollectionInfo;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model2.Configuration; import com.omertron.themoviedbapi.model2.Configuration;
import com.omertron.themoviedbapi.model.discover.Discover; import com.omertron.themoviedbapi.model.discover.Discover;
import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Genre;
@ -602,7 +602,7 @@ public class TheMovieDbApi {
* @return * @return
* @throws MovieDbException * @throws MovieDbException
*/ */
public TmdbResultsList<MovieDb> getCompanyMovies(int companyId, String language, int page) throws MovieDbException { public List<MovieFavorite> getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
return tmdbCompany.getCompanyMovies(companyId, language, page); return tmdbCompany.getCompanyMovies(companyId, language, page);
} }
//</editor-fold> //</editor-fold>

@ -20,18 +20,17 @@
package com.omertron.themoviedbapi.methods; package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.tools.ApiUrl; import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools; import com.omertron.themoviedbapi.tools.HttpTools;
import com.omertron.themoviedbapi.tools.MethodBase; import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub; import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param; import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters; import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.List;
import org.yamj.api.common.exception.ApiExceptionType; import org.yamj.api.common.exception.ApiExceptionType;
/** /**
@ -52,8 +51,7 @@ public class TmdbCompanies extends AbstractMethod {
} }
/** /**
* This method is used to retrieve the basic information about a production * This method is used to retrieve the basic information about a production company on TMDb.
* company on TMDb.
* *
* @param companyId * @param companyId
* @return * @return
@ -76,8 +74,7 @@ public class TmdbCompanies extends AbstractMethod {
/** /**
* This method is used to retrieve the movies associated with a company. * This method is used to retrieve the movies associated with a company.
* *
* These movies are returned in order of most recently released to oldest. * These movies are returned in order of most recently released to oldest. The default response will return 20 movies per page.
* The default response will return 20 movies per page.
* *
* TODO: Implement more than 20 movies * TODO: Implement more than 20 movies
* *
@ -87,7 +84,7 @@ public class TmdbCompanies extends AbstractMethod {
* @return * @return
* @throws MovieDbException * @throws MovieDbException
*/ */
public TmdbResultsList<MovieDb> getCompanyMovies(int companyId, String language, int page) throws MovieDbException { public List<MovieFavorite> getCompanyMovies(int companyId, String language, Integer page) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters(); TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, companyId); parameters.add(Param.ID, companyId);
parameters.add(Param.LANGUAGE, language); parameters.add(Param.LANGUAGE, language);
@ -95,15 +92,7 @@ public class TmdbCompanies extends AbstractMethod {
URL url = new ApiUrl(apiKey, MethodBase.COMPANY).setSubMethod(MethodSub.MOVIES).buildUrl(parameters); URL url = new ApiUrl(apiKey, MethodBase.COMPANY).setSubMethod(MethodSub.MOVIES).buildUrl(parameters);
String webpage = httpTools.getRequest(url); String webpage = httpTools.getRequest(url);
return processWrapperList(TR_MOVIE_FAV, url, webpage);
try {
WrapperCompanyMovies wrapper = MAPPER.readValue(webpage, WrapperCompanyMovies.class);
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getResults());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get company movies", url, ex);
}
} }
} }

@ -21,7 +21,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model2.collection.Collection; import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model.keyword.Keyword; import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.MovieList;

@ -17,10 +17,11 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model2.company;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping; import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
/** /**
* Company information * Company information

@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model2.company.Company;
import java.util.List; import java.util.List;
/** /**

@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import java.util.List; import java.util.List;
/** /**
@ -30,13 +30,13 @@ import java.util.List;
public class WrapperCompanyMovies extends AbstractWrapperAll { public class WrapperCompanyMovies extends AbstractWrapperAll {
@JsonProperty("results") @JsonProperty("results")
private List<MovieDb> results; private List<MovieFavorite> results;
public List<MovieDb> getResults() { public List<MovieFavorite> getResults() {
return results; return results;
} }
public void setResults(List<MovieDb> results) { public void setResults(List<MovieFavorite> results) {
this.results = results; this.results = results;
} }
} }

@ -24,7 +24,7 @@ import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.change.ChangedMedia; import com.omertron.themoviedbapi.model.change.ChangedMedia;
import com.omertron.themoviedbapi.model2.collection.Collection; import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model2.collection.CollectionInfo; import com.omertron.themoviedbapi.model2.collection.CollectionInfo;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model.discover.Discover; import com.omertron.themoviedbapi.model.discover.Discover;
import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Genre;
import com.omertron.themoviedbapi.model2.JobDepartment; import com.omertron.themoviedbapi.model2.JobDepartment;

@ -21,11 +21,12 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests; import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import com.omertron.themoviedbapi.results.TmdbResultsList; import java.util.List;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
@ -83,7 +84,7 @@ public class TmdbCompaniesTest extends AbstractTests {
@Test @Test
public void testGetCompanyMovies() throws MovieDbException { public void testGetCompanyMovies() throws MovieDbException {
LOG.info("getCompanyMovies"); LOG.info("getCompanyMovies");
TmdbResultsList<MovieDb> result = instance.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0); List<MovieFavorite> result = instance.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
assertTrue("No company movies found", !result.isEmpty()); assertFalse("No company movies found", result.isEmpty());
} }
} }

@ -22,7 +22,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests; import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model2.collection.Collection; import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model.keyword.Keyword; import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.MovieList;

Loading…
Cancel
Save