Package de.linwave.music

Source Code of de.linwave.music.QueryMusic

package de.linwave.music;

import org.odbms.ObjectContainer;
import org.odbms.ObjectSet;
import org.odbms.Query;

import de.linwave.gtm.GTM;

public class QueryMusic
{
  private static ObjectContainer gtm = GTM.getInstance();

  private void showAlbum()
  {
    try {
      Query query = gtm.query(Album.class);
      query.sortBy("year");

      ObjectSet<Album> items = query.execute();

      int cnt = 0;
      for (Album album : items) {
        System.out.println("  [ALBUM " + album.OID + "] " + album.name + " (" + album.year + ")");
        String albumArtist = "          Artist=";
        if (album.artist != null)
          albumArtist += album.artist.getName();
        else
          albumArtist = "<NULL>";
        System.out.println(albumArtist);

        for (Track track : album.getTracks()) {
          System.out.println("      [TRACK " + track.OID + "] " + track.title);
          if (track.artist != null) {
            System.out.println("         Artist=" + track.artist.name);
          }
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

  }

  public static void main(String[] args)
  {
    try {
      QueryMusic music = new QueryMusic();
      music.showAlbum();

      gtm.printCacheStatistics();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}
TOP

Related Classes of de.linwave.music.QueryMusic

TOP
Copyright © 2018 www.massapi.com. 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.