/** * @param session the hibernate session * @return a string listing the different subscribers present in the database */ @SuppressWarnings("unchecked") public String toString(Session session) { List<Media> medias = (List<Media>) session.createQuery("from Media").list(); String s = "List of medias (" + medias.size() + ") present in the library:\n"; for (Media m : medias) s += "\t" + m.toString() + "\n"; return s; }
public static void main(String[] args) throws SdpParseException, SdpException { String sdpFields = "v=0\r\n" + "o=4855 13760799956958020 13760799956958020 IN IP4 166.35.224.216\r\n" + "s=nortelnetworks\r\n" + "p=+1 972 684 1000\r\n" + "c=IN IP4 166.35.224.216\r\n" + "t=0 0\r\n" + "m=audio 50006 RTP/AVP 0 8 4 18\r\n" + "a=rtpmap:0 PCMU/8000\r\n" + "a=rtpmap:8 PCMA/8000\r\n" + "a=rtpmap:4 G723/8000\r\n" + "a=rtpmap:18 G729A/8000\r\n" + "a=ptime:30\r\n"; SdpFactory sdpFactory = new SdpFactory(); SessionDescription sessionDescription = sdpFactory.createSessionDescription(sdpFields); System.out.println("sessionDescription = " + sessionDescription); Vector mediaDescriptions = sessionDescription.getMediaDescriptions(true); for (int i = 0; i < mediaDescriptions.size(); i++) { MediaDescription m = (MediaDescription) mediaDescriptions.elementAt(i); System.out.println("m = " + m.toString()); Media media = m.getMedia(); Vector formats = media.getMediaFormats(false); System.out.println("formats = " + formats); } }
protected List findAllKeysForValuesOfType(Class type) { List list = new ArrayList(); for (Iterator iter = mediaCopies.keySet().iterator(); iter.hasNext(); ) { String key = (String) iter.next(); Media media = getFirstInList((List) mediaCopies.get(key)); if (media != null && media.getClass().equals(type)) list.add(key); } return list; }
@Override public void writeToParcel(Parcel parcel, int flags) { super.writeToParcel(parcel, flags); parcel.writeParcelable(contentUri, flags); parcel.writeString(source); parcel.writeSerializable(timestamp); parcel.writeInt(state); parcel.writeLong(transferred); parcel.writeInt(isMultiple ? 1 : 0); }
/** * @param session the hibernate session * @return a string in HTML listing the different subscribers present in the database */ @SuppressWarnings("unchecked") public String toHTML(Session session) { List<Media> medias = (List<Media>) session.createQuery("from Media").list(); if (medias.size() <= 0) return "No media present in the library."; StringBuilder sb = new StringBuilder(); sb.append("<p>List of medias (" + medias.size() + ") present in the library:</p>"); sb.append(Media.toHTML(medias)); return sb.toString(); }
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; }
public Boolean addOrUpdateMedia(Session session, Media media) { try { // Need to save the loans before saving the media Map<Integer, Loan> tabEx = media.getTabExemplaries(); for (Iterator<Loan> i = tabEx.values().iterator(); i.hasNext(); ) session.saveOrUpdate(i.next()); // Persist the media session.saveOrUpdate(media); } catch (HibernateException pe) { System.err.println("Problème dans la sauvegarde "); pe.printStackTrace(); return false; } return true; }
@SuppressWarnings("unchecked") public Boolean delMedia(Session session, Media media) { try { // Need to delete the loans before deleting the media Map<Integer, Loan> tabEx = media.getTabExemplaries(); for (Iterator<Loan> i = tabEx.values().iterator(); i.hasNext(); ) session.delete(i.next()); // Also, all the bookings of the media need to be deleted List<Booking> bookings = (List<Booking>) session.createQuery("from Booking where media=:m").setParameter("m", media).list(); for (Booking b : bookings) session.delete(b); session.delete(media); } catch (HibernateException pe) { System.err.println("Problème dans la suppression "); pe.printStackTrace(); return false; } return true; }
public Media copy() { Media dst = new Media(); copyValues(dst); dst.type = type == null ? null : type.copy(); dst.subtype = subtype == null ? null : subtype.copy(); if (identifier != null) { dst.identifier = new ArrayList<Identifier>(); for (Identifier i : identifier) dst.identifier.add(i.copy()); } ; dst.subject = subject == null ? null : subject.copy(); dst.operator = operator == null ? null : operator.copy(); dst.view = view == null ? null : view.copy(); dst.deviceName = deviceName == null ? null : deviceName.copy(); dst.height = height == null ? null : height.copy(); dst.width = width == null ? null : width.copy(); dst.frames = frames == null ? null : frames.copy(); dst.duration = duration == null ? null : duration.copy(); dst.content = content == null ? null : content.copy(); return dst; }