Package models

Examples of models.Album


     *
     * @param id
     */
    @Check("admin")
    public static void delete(Long id) {
        Album album = Album.findById(id);
        album.delete();
        Application.list();
    }
View Full Code Here


     *
     * @param id
     */
    @Check("admin")
    public static void form(Long id) {
        Album album = Album.findById(id);
        render("@Application.form", album);
    }
View Full Code Here

    /**
     * Save album via JSON API
     */
    private static void saveAlbumJson() {
        Gson gson = new Gson();
        Album album = gson.fromJson(new InputStreamReader(request.body), Album.class);
        album.replaceDuplicateArtist();
        album.save();
    }
View Full Code Here

        Node artistNode = XPath.selectNode("artist", albumNode);
        String artistName = XPath.selectText("name",artistNode);
        Artist artist = new Artist(artistName);
        //get the name
        String albumName = XPath.selectText("name", albumNode);
        Album album = new Album(albumName);
        //get the date
        String date = XPath.selectText("release-date",albumNode);
        DateFormat dateFormat = new SimpleDateFormat("yyyy");
        try {
            album.releaseDate = dateFormat.parse(date);
        } catch (ParseException e) {
            Logger.error(e.getMessage());
        }
        //get the genre
        String genre = XPath.selectText("genre", albumNode);
        Genre genreEnum = Genre.valueOf(genre.toString().toUpperCase());
        album.genre = genreEnum;

        //save in db
        album.artist = artist;
        album.save();
    }
View Full Code Here

    /**
     * @param id
     */
    public static void vote(String id) {
        Album album = Album.findById(Long.parseLong(id));
        album.vote();
        renderText(album.nbVotes);
    }
View Full Code Here


    @Test
    public void testUniqueArtist() {
        Artist artist1 = new Artist("john");
        Album album1 = new Album("coolAlbum");
        album1.artist=artist1;
        album1.replaceDuplicateArtist();
        album1.save();
        // name must be unique
        Artist artist2 = new Artist("john");
        Album album2 = new Album("coolAlbum2");
        album2.artist=artist2;
        album2.replaceDuplicateArtist();
        album2.save();
        // check artist is unique
        assertEquals(Artist.find("byName", "john").fetch().size(),1);
    }
View Full Code Here

TOP

Related Classes of models.Album

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.