예제 #1
0
 public MediaCopy addCopy(Media media) {
   lastCopyId += 1;
   MediaCopy mediaCopy = new MediaCopy(media, "" + lastCopyId);
   String mediaId = media.getId();
   List copies = (List) mediaCopies.get(mediaId);
   if (copies == null) {
     copies = new LinkedList();
     mediaCopies.put(mediaId, copies);
   }
   copies.add(mediaCopy);
   return mediaCopy;
 }
예제 #2
0
 public Map findAllISBNsAndTitles() {
   List isbns = findAllKeysForValuesOfType(Book.class);
   Map map = new HashMap();
   for (Iterator iter = isbns.iterator(); iter.hasNext(); ) {
     String isbn = (String) iter.next();
     List copies = (List) mediaCopies.get(isbn);
     if (copies.size() > 0) {
       String title = ((MediaCopy) copies.get(0)).getMedia().getTitle();
       map.put(isbn, title);
     }
   }
   return map;
 }