All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.moviejukebox.plugin.MovieListingPluginBase Maven / Gradle / Ivy

There is a newer version: 2.9
Show newest version
/*
 *      Copyright (c) 2004-2012 YAMJ Members
 *      http://code.google.com/p/moviejukebox/people/list
 *
 *      Web: http://code.google.com/p/moviejukebox/
 *
 *      This software is licensed under a Creative Commons License
 *      See this page: http://code.google.com/p/moviejukebox/wiki/License
 *
 *      For any reuse or distribution, you must make clear to others the
 *      license terms of this work.
 */
package com.moviejukebox.plugin;

import com.moviejukebox.model.Jukebox;
import com.moviejukebox.model.Library;
import com.moviejukebox.tools.FileTools;
import com.moviejukebox.tools.PropertiesUtil;
import static com.moviejukebox.tools.PropertiesUtil.TRUE;
import java.io.File;
import java.util.ArrayList;
import java.util.StringTokenizer;
import org.apache.log4j.Logger;

/**
 * User: JDGJr
 * Date: Feb 15, 2009
 */
public class MovieListingPluginBase implements MovieListingPlugin {
    private static final Logger logger = Logger.getLogger(MovieListingPluginBase.class);

    protected static final String UNDEFINED = "UNDEFINED";

    protected boolean groupByType = true;
    protected boolean blankUNKNOWN = true;
    protected String baseFilename = "";
    private String destination = "";

    /**
     * @param jukeboxRoot
     */
    protected void initialize(Jukebox jukebox) {
        groupByType = PropertiesUtil.getBooleanProperty("mjb.listing.GroupByType", TRUE);
        blankUNKNOWN = PropertiesUtil.getBooleanProperty("mjb.listing.clear.UNKNOWN", TRUE);
        baseFilename = PropertiesUtil.getProperty("mjb.listing.output.filename", "MovieJukebox-listing");
        destination = PropertiesUtil.getProperty("mjb.listing.output.destination", jukebox.getJukeboxRootLocation());
    } // initialize()

    /**
     * @return ArrayList of selected movie types, possibly from .properties file
     */
    protected ArrayList getSelectedTypes() {
        ArrayList alResult = new ArrayList();

        String types = PropertiesUtil.getProperty("mjb.listing.types", typeAll).trim();
        if (typeAll.equalsIgnoreCase(types)) {
            types = typeMovie + "," + typeExtra + "," + typeTVShow;
        }

        //break into a list
        StringTokenizer tokenizer = new StringTokenizer(types, ",");
        while (tokenizer.hasMoreTokens()) {
            String token = tokenizer.nextToken().trim();

            //easy to skip space
            if (typeTVShowNoSpace.equalsIgnoreCase(token)) {
                token = typeTVShow;
            }
            alResult.add(token);
        }

        return alResult;
    } // getSelectedTypes()

    /**
     * @param file
     */
    protected void copyListingFile(File file, String filename) {
        // move to configured (default) location
        String dest = destination + File.separator + filename;
        logger.info("  Copying to: " + dest);
        FileTools.copyFile(file, new File(dest));
    } // copyListingFile()

    /**
     * @param Jukebox
     * @param library
     */
    @Override
    public void generate(Jukebox jukebox, Library library) {
        logger.info("  MovieListingPluginBase: not generating listing file.");
    } // generate()

} // class MovieListingPluginBase




© 2015 - 2024 Weber Informatics LLC | Privacy Policy