Package com.pugh.sockso.db

Examples of com.pugh.sockso.db.Database


        final Properties p = getProperties();

        if ( p.get(Constants.WWW_DOWNLOADS_DISABLE).equals(Properties.YES) )
            throw new BadRequestException( locale.getString("www.error.downloadsDisabled"), 403 );
       
        final Database db = getDatabase();
        final String[] args = req.getPlayParams( false );
        final List<Track> tracks = Track.getTracksFromPlayArgs( db, args );
        final String fileName = getFileName( tracks );

        res.addHeader( "Content-length", Long.toString(getContentLength(tracks)) );
View Full Code Here


            final boolean isArtist = type.equals( "ar" );
            final String typeName = isArtist ? "artist" : "album";
            final String sql = " select t.path as path " +
                               " from tracks t " +
                               " where t." +typeName+ "_id = " +id;
            final Database db = getDatabase();
           
            st = db.prepare( sql );
            rs = st.executeQuery();
       
            while ( rs.next() ) {
                final String path = rs.getString( "path" );
                if ( !taken.contains(path) ) {
View Full Code Here

        // if we get here everything looks good, so lets try and save the file
        try {

            // make sure we've a directory to put the track in
            final Database db = getDatabase();
            final File dir = new File( Utils.getUploadsPath(db,p) + "/"+artist+" - "+album );
            if ( !dir.exists() )
                if ( !dir.mkdir() )
                    throw new BadRequestException( locale.getString("www.error.cantCreateTrackFolder"), 500 );
View Full Code Here

        log.debug( "File content type: " + contentType );
        if ( !Files.isValidMimeType(contentType) )
            throw new BadRequestException( locale.getString("www.error.unsupportedAudioFormat") );
       
        // check required fields
        final Database db = getDatabase();
        final Validater v = new Validater( db );
        final String artist = req.getArgument( "artist" );
        final String album = req.getArgument( "album" );
        final String track = req.getArgument( "title" );
        if ( !v.checkRequiredFields( new String[] { artist, album, track }) )
View Full Code Here

        ResultSet rs = null;
        PreparedStatement st = null;
       
        try {
           
            final Database db = getDatabase();
            final String sql = " select c.id, c.path " +
                               " from collection c ";
            st = db.prepare( sql );

            rs = st.executeQuery();

            final List<Collection> folders = new ArrayList<Collection>();
            while ( rs.next() )
View Full Code Here

        PreparedStatement st = null;
       
        try {

            final Properties p = getProperties();
            final Database db = getDatabase();
            final String sql = Track.getSelectSql() + " , count(l.id) as playCount " +
                        " from tracks t " +
                            " inner join artists ar " +
                            " on ar.id = t.artist_id " +
                            " inner join albums al " +
                            " on al.id = t.album_id " +
                            " inner join genres g " +
                            " on g.id = t.genre_id " +
                            " left outer join play_log l " +
                            " on l.track_id = t.id " +
                        " group by artistId, artistName, albumId, albumName, albumYear, trackId, " +
                            " trackName, trackPath, trackNo, genreId, genreName, dateAdded " +
                        " having count(l.id) > 0 " +
                        " order by count(l.id) desc " +
                        " limit ? ";
            st = db.prepare( sql );
           
            st.setInt( 1, (int) p.get(Constants.WWW_BROWSE_POPULAR_TRACK_COUNT,20) );
           
            rs = st.executeQuery();
View Full Code Here

     */
   
    protected void playlist() throws SQLException, IOException, BadRequestException {
       
        final Request req = getRequest();
        final Database db = getDatabase();
        final int id = Integer.parseInt( req.getUrlParam(2)  );       
        final Playlist playlist = Playlist.find( db, id );
       
        if ( playlist == null ) {
            throw new BadRequestException( "Invalid playlist ID", 404 );
View Full Code Here

        ResultSet rs = null;
        PreparedStatement st = null;
               
        try {
           
            final Database db = getDatabase();

            // Get the count of the albums based on track album_id, NOT the count of
            // album rows for artist, as the artist may appear on albums for which
            // they are NOT the album artist
            final String sql = "" +
                   " select id, name, count(*) as albumCount " +
                   " from (select ar.id as id, ar.name as name, count(tr.album_id) " +
                         " from artists ar " +
                             " left outer join tracks tr " +
                             " on tr.artist_id = ar.id " +
                         " where " +
                         ( letter.equals("")
                                   // doesn't start with a-z
                                   // @TODO ascii() not sqlite compatible
                                   ? " ascii(lower(ar.name)) < 96 " +
                                         " or ascii(lower(ar.name)) > 123 "
                                   // starts with a particular letter
                                   : " ar.browse_name like ? ") +
                         " group by tr.album_id, ar.id, ar.name) " +
                   " group by name, id " +
                   " order by name asc ";

            st = db.prepare( sql );

            if ( !letter.equals("") ) {
                st.setString( 1, letter + "%" );
            }

View Full Code Here

        ResultSet rs = null;
        PreparedStatement st = null;
       
        try {
                       
            final Database db = getDatabase();
            final String sql = " select p.id as id, p.name as name, count(t.id) as trackCount, " +
                            " u.id as userId, u.name as userName " +
                        " from playlists p " +
                            " left outer join playlist_tracks pt " +
                            " on pt.playlist_id = p.id " +
                            " inner join tracks t " +
                            " on t.id = pt.track_id " +
                            " inner join users u " +
                            " on u.id = p.user_id " +
                        " group by p.id, p.name, p.date_created " +
                        " order by p.date_created desc ";
            st = db.prepare( sql );
            rs = st.executeQuery();
           
            final List<Playlist> userPlaylists = new ArrayList<Playlist>();
            while ( rs.next() )
                userPlaylists.add( new Playlist(
View Full Code Here

        ResultSet rs = null;
        PreparedStatement st = null;
       
        try {
           
            final Database db = getDatabase();
            final String sql = " select p.id as id, p.name as name, count(pt.id) as trackCount " +
                        " from playlists p " +
                            " left outer join playlist_tracks pt " +
                            " on pt.playlist_id = p.id " +
                        " where p.user_id is null " +
                        " group by p.id, p.name, p.date_created " +
                        " order by p.date_created desc ";
            st = db.prepare( sql );
            rs = st.executeQuery();
           
            final List<Playlist> sitePlaylists = new ArrayList<Playlist>();

            while ( rs.next() )
View Full Code Here

TOP

Related Classes of com.pugh.sockso.db.Database

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.