Class MediaObjects

    • Field Detail

      • autoCorrectPredictions

        public static boolean autoCorrectPredictions
    • Method Detail

      • forOwner

        public static void forOwner​(MediaObject media,
                                    nl.vpro.domain.media.support.OwnerType owner)
        Sets the owner of all titles, descriptions, locations and images found in given MediaObject
      • deepCopy

        public static <T extends MediaObject> T deepCopy​(T media)
        Perfomrs of deep copy of the media object, this is currently implemented by serializing/deserializing it.
      • copy

        public static void copy​(@NonNull MediaObject from,
                                @NonNull MediaObject to)
        Copies most field values from one media object to another.

        Principally, this should be all fields of which the value logically can exist on more than one mediaobject the same time, so not unique fields like id and mid.

        Also, membership of groups will not be automatically filled. This would need write access on those objects.

        ScheduleEvents, workflow, subtitles status are not copied too, since this would not make sense.

        See Also:
        copyFull(MediaObject, MediaObject)
      • copyFull

        public static void copyFull​(@NonNull MediaObject from,
                                    @NonNull MediaObject to)
        A more full copy, also copying field that you could normally would not copy, like MID.

        The assumption is that both objects are not yet persistent, or e.g. a type conversion is happening

        Since:
        5.11
        See Also:
        copy(MediaObject, MediaObject)
      • copyFullProgram

        public static void copyFullProgram​(@NonNull Program from,
                                           @NonNull Program to)
        A more full copy, also copying field that you could normally not copy, like MID.

        The assumption is that both objects are not yet persistent

        Since:
        5.11
      • hasChannel

        public static boolean hasChannel​(Program media,
                                         Channel... channels)
      • getChannel

        public static Channel getChannel​(@NonNull Program program)
        Returns the channel associated with this program. That is the channel of the earliest schedule event that is not a rerun.
      • getRelationText

        public static String getRelationText​(@NonNull MediaObject object,
                                             String relationType)
        Since:
        2.2.3
      • idFromUrn

        public static Long idFromUrn​(String urn)
      • removeLocations

        public static void removeLocations​(@NonNull MediaObject mediaObject)
      • trim

        public static boolean trim​(@NonNull Collection<?> collection)
      • markForRepublication

        public static boolean markForRepublication​(@NonNull MediaObject media,
                                                   String reason,
                                                   Object... args)
      • markForDeletionIfNeeded

        public static boolean markForDeletionIfNeeded​(@NonNull MediaObject media,
                                                      @Pattern(regexp="[a-z, ]+",flags=CASE_INSENSITIVE)
                                                      @Pattern(regexp="[a-z, ]+",flags=CASE_INSENSITIVE) String reason)
      • markForUnDeletionIfNeeded

        public static boolean markForUnDeletionIfNeeded​(@NonNull MediaObject media,
                                                        String reason)
      • markPublished

        public static void markPublished​(@NonNull MediaObject media,
                                         @NonNull Instant now)
        Marks the fields of the media object related to publishing as published.

        the last publish instant will be set, and the reason and destinations will be cleared.

        The workflow itself will remain untouched, and would be set to Workflow.PUBLISHED, Workflow.REVOKED or Workflow.MERGED

      • getPlannedPlatformNamesInLowerCaseOrAll

        public static List<String> getPlannedPlatformNamesInLowerCaseOrAll​(MediaObject media)
      • subtitlesMayBePublished

        public static boolean subtitlesMayBePublished​(MediaObject media)
      • filterPublishable

        public static <T extends PublishableObject<?>> T filterPublishable​(T object,
                                                                           Instant now)
        Filters a PublishableObject. Removes all subobject which dont' have a correct workflow.

        TODO work in progress. This may replace the hibernate filter solution now in place.

      • isWebonly

        public static boolean isWebonly​(MediaObject media)
      • updateLocationsForOwner

        public static <T extends MediaObject> void updateLocationsForOwner​(T incomingMedia,
                                                                           T mediaToUpdate,
                                                                           Predicate<nl.vpro.domain.media.support.Ownable> owns,
                                                                           nl.vpro.domain.media.support.OwnerType owner,
                                                                           boolean steal)
      • updateLocationsForOwner

        public static <T extends MediaObject> void updateLocationsForOwner​(T incomingMedia,
                                                                           T mediaToUpdate,
                                                                           nl.vpro.domain.media.support.OwnerType owner,
                                                                           boolean steal)
      • updateAndRemoveLocationsForOwner

        public static <T extends MediaObjectList<Location> updateAndRemoveLocationsForOwner​(T incomingMedia,
                                                                                              T mediaToUpdate,
                                                                                              Predicate<nl.vpro.domain.media.support.Ownable> owns,
                                                                                              nl.vpro.domain.media.support.OwnerType owner)
      • updateAndRemoveLocationsForOwner

        public static <T extends MediaObjectList<Location> updateAndRemoveLocationsForOwner​(T incomingMedia,
                                                                                              T mediaToUpdate,
                                                                                              nl.vpro.domain.media.support.OwnerType owner)
      • mergeAvAttributes

        public static void mergeAvAttributes​(Location incomingLocation,
                                             Location locationToUpdate)
      • mergeAudioAttributes

        public static void mergeAudioAttributes​(AVAttributes incomingAttributes,
                                                AVAttributes attributesToUpdate)
      • mergeVideoAttributes

        public static void mergeVideoAttributes​(AVAttributes incomingAttributes,
                                                AVAttributes attributesToUpdate)
      • revokeRelatedPublishables

        public static boolean revokeRelatedPublishables​(MediaObject media,
                                                        Instant now)
      • isPlayable

        public static boolean isPlayable​(MediaObject media)
        Whether this mediaobject is playable in a NPO player.
        Since:
        5.11
      • nowPlayable

        public static boolean nowPlayable​(@NonNull Platform platform,
                                          @NonNull MediaObject mediaObject)
        Whether the given mediaobject is now playable at given platform
        Since:
        5.31
      • wasPlayable

        public static boolean wasPlayable​(@NonNull Platform platform,
                                          @NonNull MediaObject mediaObject)
        Since:
        5.31
      • willBePlayable

        public static boolean willBePlayable​(@NonNull Platform platform,
                                             @NonNull MediaObject mediaObject)
        Returns whether the mediaobject for given platform is now not playable, but will be.
        Since:
        5.31
      • willBePlayable

        public static Set<Platform> willBePlayable​(@NonNull MediaObject mediaObject)
        Determines on which Platforms the given MediaObject will be playable.
        Since:
        5.31
      • playableRange

        public static Optional<com.google.common.collect.Range<Instant>> playableRange​(@NonNull Platform platform,
                                                                                       @NonNull MediaObject mediaObject)
        Returns for a certain platform the range it which a mediaobject is playable.
        Returns:
        An Optional of a Range of Instant. The optional is empty if the mediaobject was never announced, and is, was and probably will be unplayable.
        Since:
        5.31
      • playableRanges

        public static Map<Platform,​com.google.common.collect.Range<LocalDateTime>> playableRanges​(@NonNull MediaObject mediaObject,
                                                                                                        ZoneId zoneId)
        Given a MediaObject returns a map with for every platform for which that is relevant a Range of LocalDateTime is return indicating the period this object is playable at that platform
        Parameters:
        zoneId - The timezone for which this must be evaluated or null, to fall back to Schedule.ZONE_ID
        Since:
        5.31
      • locationFilter

        protected static boolean locationFilter​(Location l)
        Return false if the given location is not actually playable.

        Either it is PublishableObject.isDeleted(), which may occur if dealing with unpublished data, or we're dealing with some legacy and the location has a format which is known not to be playable any more (like WMV)

        Since:
        5.31
      • correctPrediction

        protected static void correctPrediction​(Prediction prediction,
                                                MediaObject mediaObject)
        // TODO: I think is is a bit odd that this kind of logic happens here. It ensures consistency, that's the good thing, but it seems a patch any way!