@Override public Boolean apply(Catalog catalog) { return flavor.equals(catalog.getFlavor()); } };
/** * {@inheritDoc} * * @see org.opencastproject.metadata.api.CatalogService#accepts(org.opencastproject.mediapackage.Catalog) */ @Override public boolean accepts(Catalog catalog) { if (catalog == null) throw new IllegalArgumentException("Catalog must not be null"); MediaPackageElementFlavor flavor = catalog.getFlavor(); return flavor != null && (flavor.equals(DublinCoreCatalog.ANY_DUBLINCORE)); }
@Override public int compare(Catalog c1, Catalog c2) { if (MediaPackageElements.EPISODE.equals(c1.getFlavor())) return 1; return -1; } };
/** * {@inheritDoc} * * @see org.opencastproject.metadata.api.CatalogService#accepts(org.opencastproject.mediapackage.Catalog) */ @Override public boolean accepts(Catalog catalog) { if (catalog == null) throw new IllegalArgumentException("Catalog must not be null"); MediaPackageElementFlavor flavor = catalog.getFlavor(); return flavor != null && (flavor.equals(Mpeg7Catalog.ANY_MPEG7)); }
/** * Adds the given flavor to the list of flavors. * <p> * Note that the order is relevant to the selection of the track returned by this selector. * * @param index * the position in the list * @param flavor * the flavor to add */ public void addFlavorAt(int index, MediaPackageElementFlavor flavor) { if (flavor == null) throw new IllegalArgumentException("Flavor must not be null"); flavors.add(index, flavor); for (int i = index + 1; i < flavors.size(); i++) { if (flavors.get(i).equals(flavor)) flavors.remove(i); } }
/** * Adds the given flavor to the list of flavors. * <p> * Note that the order is relevant to the selection of the track returned by this selector. * * @param index * the position in the list * @param flavor * the flavor to add */ public void addFlavorAt(int index, String flavor) { if (flavor == null) throw new IllegalArgumentException("Flavor must not be null"); MediaPackageElementFlavor f = MediaPackageElementFlavor.parseFlavor(flavor); flavors.add(index, f); for (int i = index + 1; i < flavors.size(); i++) { if (flavors.get(i).equals(f)) flavors.remove(i); } }
/** * {@inheritDoc} * * @see org.opencastproject.mediapackage.MediaPackage#getUnclassifiedElements(org.opencastproject.mediapackage.MediaPackageElementFlavor) */ @Override public MediaPackageElement[] getUnclassifiedElements(MediaPackageElementFlavor flavor) { List<MediaPackageElement> unclassifieds = new ArrayList<MediaPackageElement>(); synchronized (elements) { for (MediaPackageElement e : elements) { if (!(e instanceof Attachment) && !(e instanceof Catalog) && !(e instanceof Track)) { if (flavor == null || flavor.equals(e.getFlavor())) { unclassifieds.add(e); } } } } return unclassifieds.toArray(new MediaPackageElement[unclassifieds.size()]); }
/** * {@inheritDoc} * * @see org.opencastproject.mediapackage.MediaPackage#hasUnclassifiedElements(org.opencastproject.mediapackage.MediaPackageElementFlavor) */ @Override public boolean hasUnclassifiedElements(MediaPackageElementFlavor type) { if (type == null) return others > 0; synchronized (elements) { for (MediaPackageElement e : elements) { if (!(e instanceof Attachment) && !(e instanceof Catalog) && !(e instanceof Track)) { if (type.equals(e.getFlavor())) { return true; } } } } return false; }
/** * This implementation of <code>accept</code> tests for the element type (attachment). * * @see org.opencastproject.mediapackage.elementbuilder.MediaPackageElementBuilderPlugin#accept(org.opencastproject.mediapackage.MediaPackageElement.Type * , org.opencastproject.mediapackage.MediaPackageElementFlavor) */ @Override public boolean accept(MediaPackageElement.Type type, MediaPackageElementFlavor flavor) { if (this.flavor != null && !this.flavor.equals(flavor)) return false; return type == null || MediaPackageElement.Type.Attachment.toString().equalsIgnoreCase(type.toString()); }
/** * {@inheritDoc} * * @see org.opencastproject.mediapackage.MediaPackageElementSelector#select(org.opencastproject.mediapackage.MediaPackage, * boolean) */ public Collection<T> select(MediaPackage mediaPackage, boolean withTagsAndFlavors) { Set<T> candidates = new HashSet<T>(); Set<T> result = new HashSet<T>(); // Have the super implementation match type, flavor and tags candidates.addAll(super.select(mediaPackage, withTagsAndFlavors)); if (flavors.isEmpty()) return candidates; // Return the first element based on the flavor buildResult: for (MediaPackageElementFlavor flavor : flavors) { for (T element : candidates) { if (flavor.equals(element.getFlavor())) { result.add(element); break buildResult; } } } return result; }
/** * {@inheritDoc} * * @see org.opencastproject.mediapackage.MediaPackage#getDerived(org.opencastproject.mediapackage.MediaPackageElement, * org.opencastproject.mediapackage.MediaPackageElementFlavor) */ @Override public MediaPackageElement[] getDerived(MediaPackageElement sourceElement, MediaPackageElementFlavor derivateFlavor) { if (sourceElement == null) throw new IllegalArgumentException("Source element cannot be null"); if (derivateFlavor == null) throw new IllegalArgumentException("Derivate flavor cannot be null"); MediaPackageReference reference = new MediaPackageReferenceImpl(sourceElement); List<MediaPackageElement> elements = new ArrayList<MediaPackageElement>(); for (MediaPackageElement element : getElements()) { if (derivateFlavor.equals(element.getFlavor()) && reference.equals(element.getReference())) elements.add(element); } return elements.toArray(new MediaPackageElement[elements.size()]); }
/** * {@inheritDoc} * * @see org.opencastproject.mediapackage.MediaPackage#getAttachments(org.opencastproject.mediapackage.MediaPackageElementFlavor, * org.opencastproject.mediapackage.MediaPackageReference) */ @Override public Attachment[] getAttachments(MediaPackageElementFlavor flavor, MediaPackageReference reference) { if (flavor == null) throw new IllegalArgumentException("Unable to filter by null criterion"); if (reference == null) throw new IllegalArgumentException("Unable to filter by null reference"); // Go through attachments and remove those that don't match Collection<Attachment> attachments = loadAttachments(); List<Attachment> candidates = new ArrayList<Attachment>(attachments); for (Attachment a : attachments) { if (!flavor.equals(a.getFlavor()) || !reference.matches(a.getReference())) { candidates.remove(a); } } return candidates.toArray(new Attachment[candidates.size()]); }
/** * {@inheritDoc} * * @see org.opencastproject.mediapackage.MediaPackage#getTracks(org.opencastproject.mediapackage.MediaPackageElementFlavor, * org.opencastproject.mediapackage.MediaPackageReference) */ @Override public Track[] getTracks(MediaPackageElementFlavor flavor, MediaPackageReference reference) { if (flavor == null) throw new IllegalArgumentException("Unable to filter by null criterion"); if (reference == null) throw new IllegalArgumentException("Unable to filter by null reference"); // Go through tracks and remove those that don't match Collection<Track> tracks = loadTracks(); List<Track> candidates = new ArrayList<Track>(tracks); for (Track a : tracks) { if (!flavor.equals(a.getFlavor()) || !reference.matches(a.getReference())) { candidates.remove(a); } } return candidates.toArray(new Track[candidates.size()]); }
/** * Returns a track or a number of tracks from the media package that together contain audio and video. If no such * combination can be found, e. g. there is no audio or video at all, an empty array is returned. * * @see org.opencastproject.mediapackage.selector.AbstractMediaPackageElementSelector#select(org.opencastproject.mediapackage.MediaPackage, boolean) */ @Override public Collection<Track> select(MediaPackage mediaPackage, boolean withTagsAndFlavors) { // instead of relying on the broken superclass, we'll inspect every track // Collection<Track> candidates = super.select(mediaPackage); Collection<Track> candidates = Arrays.asList(mediaPackage.getTracks()); Set<Track> result = new HashSet<Track>(); boolean foundAudio = false; // Look for a track containing audio for (Track t : candidates) { if (t.hasAudio() && !foundAudio && (audioFlavor == null || audioFlavor.equals(t.getFlavor()))) { result.add(t); foundAudio = true; } } return result; }
/** * Returns a track or a number of tracks from the media package that together contain video and video. If no such * combination can be found, e. g. there is no video or video at all, an empty array is returned. * * @see org.opencastproject.mediapackage.selector.AbstractMediaPackageElementSelector#select(org.opencastproject.mediapackage.MediaPackage, boolean) */ @Override public Collection<Track> select(MediaPackage mediaPackage, boolean withTagsAndFlavors) { // instead of relying on the broken superclass, we'll inspect every track // Collection<Track> candidates = super.select(mediaPackage); Set<Track> result = new HashSet<Track>(); boolean foundVideo = false; // Look for a track containing video for (Track t : mediaPackage.getTracks()) { if (t.hasVideo() && !foundVideo && (videoFlavor == null || videoFlavor.equals(t.getFlavor()))) { result.add(t); foundVideo = true; } } return result; }
/** * @see org.opencastproject.mediapackage.MediaPackage#getCatalogs(org.opencastproject.mediapackage.MediaPackageElementFlavor, * org.opencastproject.mediapackage.MediaPackageReference) */ @Override public Catalog[] getCatalogs(MediaPackageElementFlavor flavor, MediaPackageReference reference) { if (flavor == null) throw new IllegalArgumentException("Unable to filter by null criterion"); if (reference == null) throw new IllegalArgumentException("Unable to filter by null reference"); // Go through catalogs and remove those that don't match Collection<Catalog> catalogs = loadCatalogs(); List<Catalog> candidates = new ArrayList<Catalog>(catalogs); for (Catalog c : catalogs) { if (!flavor.equals(c.getFlavor()) || (c.getReference() != null && !c.getReference().matches(reference))) { candidates.remove(c); } } return candidates.toArray(new Catalog[candidates.size()]); }
/** * @see org.opencastproject.mediapackage.elementbuilder.AbstractAttachmentBuilderPlugin#accept(URI, * org.opencastproject.mediapackage.MediaPackageElement.Type , * org.opencastproject.mediapackage.MediaPackageElementFlavor) */ @Override public boolean accept(URI uri, MediaPackageElement.Type type, MediaPackageElementFlavor flavor) { if (type != null && flavor != null) { if (!type.equals(MediaPackageElement.Type.Attachment)) return false; } else if (type != null && !type.equals(MediaPackageElement.Type.Attachment)) { return false; } else if (flavor != null && !flavor.equals(Attachment.FLAVOR)) { return false; } return super.accept(uri, type, flavor); }
for (Catalog catalog : Stream.$(mp.getCatalogs(DublinCoreCatalog.ANY_DUBLINCORE)).sort(COMPARE_BY_FLAVOR)) { DublinCoreCatalog dc = DublinCoreUtil.loadDublinCore(workspace, catalog); if (MediaPackageElements.EPISODE.equals(catalog.getFlavor())) { } else if (MediaPackageElements.SERIES.equals(catalog.getFlavor())) {