<commit_before>/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */
package org.estatio.dscm.dom.playlist;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

import javax.inject.Inject;
import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.VersionStrategy;

import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;

import org.apache.commons.lang3.ObjectUtils;
import org.joda.time.Interval;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;

import org.apache.isis.applib.AbstractContainedObject;
import org.apache.isis.applib.annotation.BookmarkPolicy;
import org.apache.isis.applib.annotation.CollectionLayout;
import org.apache.isis.applib.annotation.DomainObject;
import org.apache.isis.applib.annotation.DomainObjectLayout;
import org.apache.isis.applib.annotation.Editing;
import org.apache.isis.applib.annotation.MemberOrder;
import org.apache.isis.applib.annotation.Optionality;
import org.apache.isis.applib.annotation.Parameter;
import org.apache.isis.applib.annotation.ParameterLayout;
import org.apache.isis.applib.annotation.Programmatic;
import org.apache.isis.applib.annotation.Property;
import org.apache.isis.applib.annotation.PropertyLayout;
import org.apache.isis.applib.annotation.RenderType;
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.applib.services.clock.ClockService;
import org.apache.isis.applib.util.TitleBuffer;

import org.isisaddons.wicket.fullcalendar2.cpt.applib.CalendarEventable;
import org.isisaddons.wicket.fullcalendar2.cpt.applib.Calendarable;

import org.estatio.dscm.DscmDashboard;
import org.estatio.dscm.dom.asset.Asset;
import org.estatio.dscm.dom.asset.Assets;
import org.estatio.dscm.dom.display.DisplayGroup;
import org.estatio.dscm.utils.CalendarUtils;

@javax.jdo.annotations.PersistenceCapable(
        identityType = IdentityType.DATASTORE)
@javax.jdo.annotations.DatastoreIdentity(
        strategy = javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
        column = "id")
@javax.jdo.annotations.Version(
        strategy = VersionStrategy.VERSION_NUMBER,
        column = "version")
@javax.jdo.annotations.Queries({
        @javax.jdo.annotations.Query(name = "findAll", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "ORDER BY displayGroup.name, startDate, startTime"),
        @javax.jdo.annotations.Query(name = "findAllActive", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE endDate == null || endDate <= :date "
                        + "ORDER BY displayGroup, startDate, startTime"),
        @javax.jdo.annotations.Query(name = "findByDisplayGroupAndStartDateTimeAndType", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE displayGroup == :displayGroup "
                        + "&& startDate == :startDate "
                        + "&& startTime == :startTime "
                        + "&& type == :type"),
        @javax.jdo.annotations.Query(name = "findByDisplayGroupAndDateTimeAndType", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE displayGroup == :displayGroup "
                        + "&& startDate <= :date "
                        + "&& (endDate == null || endDate >= :date) "
                        + "&& startTime <= :time "
                        + "&& type == :type "
                        + "ORDER BY startDate DESC, startTime DESC"),
        @javax.jdo.annotations.Query(name = "findByDisplayGroupAndType", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE displayGroup == :displayGroup "
                        + "&& type == :type"),
        @javax.jdo.annotations.Query(name = "findByDisplayGroupAndStartTimeAndType", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE displayGroup == :displayGroup "
                        + "&& startTime == :startTime "
                        + "&& type == :type"),
        @javax.jdo.annotations.Query(name = "findByDisplayGroupAndTimeAndType", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE displayGroup == :displayGroup "
                        + "&& startTime == :time "
                        + "&& type == :type")
})
//@Unique(name = "Playlist_displayGroup_startDate_startTime_type_repeatRule_UNQ", members = {"displayGroup", "startDate", "startTime", "type", "repeatRule"})
@DomainObject(bounded = true, editing = Editing.DISABLED)
@DomainObjectLayout(bookmarking = BookmarkPolicy.AS_ROOT)
public class Playlist extends AbstractContainedObject implements Comparable<Playlist>, Calendarable {

    public String title() {
        TitleBuffer tb = new TitleBuffer();

        if (this.getItems().size() == 0) {
            return tb
                    .append(getDisplayGroup().getName())
                    .append(" ", getStartDate().toString("yyyy-MM-dd"))
                    .append(" ", getStartTime().toString("HH:mm"))
                    .append(" - ", "WARNING: Playlist is empty!")
                    .toString();
        } else {
            return tb
                    .append(getDisplayGroup().getName())
                    .append(" ", getStartDate().toString("yyyy-MM-dd"))
                    .append(" ", getStartTime().toString("HH:mm"))
                    .toString();
        }
    }

    public boolean isValid() {
        return this.getItems().size() > 0;
    }

    private DisplayGroup displayGroup;

    @javax.jdo.annotations.Column(name = "displayGroupId", allowsNull = "false")
    @MemberOrder(sequence = "1")
    public DisplayGroup getDisplayGroup() {
        return displayGroup;
    }

    public void setDisplayGroup(final DisplayGroup displayGroup) {<commit_msg>show type in title of playlist<commit_after>/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */
package org.estatio.dscm.dom.playlist;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

import javax.inject.Inject;
import javax.jdo.annotations.Column;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.VersionStrategy;

import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;

import org.apache.commons.lang3.ObjectUtils;
import org.joda.time.Interval;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;

import org.apache.isis.applib.AbstractContainedObject;
import org.apache.isis.applib.annotation.BookmarkPolicy;
import org.apache.isis.applib.annotation.CollectionLayout;
import org.apache.isis.applib.annotation.DomainObject;
import org.apache.isis.applib.annotation.DomainObjectLayout;
import org.apache.isis.applib.annotation.Editing;
import org.apache.isis.applib.annotation.MemberOrder;
import org.apache.isis.applib.annotation.Optionality;
import org.apache.isis.applib.annotation.Parameter;
import org.apache.isis.applib.annotation.ParameterLayout;
import org.apache.isis.applib.annotation.Programmatic;
import org.apache.isis.applib.annotation.Property;
import org.apache.isis.applib.annotation.PropertyLayout;
import org.apache.isis.applib.annotation.RenderType;
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.applib.services.clock.ClockService;
import org.apache.isis.applib.util.TitleBuffer;

import org.isisaddons.wicket.fullcalendar2.cpt.applib.CalendarEventable;
import org.isisaddons.wicket.fullcalendar2.cpt.applib.Calendarable;

import org.estatio.dscm.DscmDashboard;
import org.estatio.dscm.dom.asset.Asset;
import org.estatio.dscm.dom.asset.Assets;
import org.estatio.dscm.dom.display.DisplayGroup;
import org.estatio.dscm.utils.CalendarUtils;

@javax.jdo.annotations.PersistenceCapable(
        identityType = IdentityType.DATASTORE)
@javax.jdo.annotations.DatastoreIdentity(
        strategy = javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
        column = "id")
@javax.jdo.annotations.Version(
        strategy = VersionStrategy.VERSION_NUMBER,
        column = "version")
@javax.jdo.annotations.Queries({
        @javax.jdo.annotations.Query(name = "findAll", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "ORDER BY displayGroup.name, startDate, startTime"),
        @javax.jdo.annotations.Query(name = "findAllActive", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE endDate == null || endDate <= :date "
                        + "ORDER BY displayGroup, startDate, startTime"),
        @javax.jdo.annotations.Query(name = "findByDisplayGroupAndStartDateTimeAndType", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE displayGroup == :displayGroup "
                        + "&& startDate == :startDate "
                        + "&& startTime == :startTime "
                        + "&& type == :type"),
        @javax.jdo.annotations.Query(name = "findByDisplayGroupAndDateTimeAndType", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE displayGroup == :displayGroup "
                        + "&& startDate <= :date "
                        + "&& (endDate == null || endDate >= :date) "
                        + "&& startTime <= :time "
                        + "&& type == :type "
                        + "ORDER BY startDate DESC, startTime DESC"),
        @javax.jdo.annotations.Query(name = "findByDisplayGroupAndType", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE displayGroup == :displayGroup "
                        + "&& type == :type"),
        @javax.jdo.annotations.Query(name = "findByDisplayGroupAndStartTimeAndType", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE displayGroup == :displayGroup "
                        + "&& startTime == :startTime "
                        + "&& type == :type"),
        @javax.jdo.annotations.Query(name = "findByDisplayGroupAndTimeAndType", language = "JDOQL",
                value = "SELECT FROM org.estatio.dscm.dom.playlist.Playlist "
                        + "WHERE displayGroup == :displayGroup "
                        + "&& startTime == :time "
                        + "&& type == :type")
})
//@Unique(name = "Playlist_displayGroup_startDate_startTime_type_repeatRule_UNQ", members = {"displayGroup", "startDate", "startTime", "type", "repeatRule"})
@DomainObject(bounded = true, editing = Editing.DISABLED)
@DomainObjectLayout(bookmarking = BookmarkPolicy.AS_ROOT)
public class Playlist extends AbstractContainedObject implements Comparable<Playlist>, Calendarable {

    public String title() {
        TitleBuffer tb = new TitleBuffer();

        if (this.getItems().size() == 0) {
            return tb
                    .append(getDisplayGroup().getName())
                    .append(" ", getStartDate().toString("yyyy-MM-dd"))
                    .append(" ", getStartTime().toString("HH:mm"))
                    .append(" - ", "WARNING: Playlist is empty!")
                    .toString();
        } else {
            return tb
                    .append(getDisplayGroup().getName())
                    .append(" ", getStartDate().toString("yyyy-MM-dd"))
                    .append(" ", getStartTime().toString("HH:mm"))
                    .append(" - ", getType())
                    .toString();
        }
    }

    public boolean isValid() {
        return this.getItems().size() > 0;
    }

    private DisplayGroup displayGroup;

    @javax.jdo.annotations.Column(name = "displayGroupId", allowsNull = "false")
    @MemberOrder(sequence = "1")
    public DisplayGroup getDisplayGroup() {
        return displayGroup;
    }

    public void setDisplayGroup(final DisplayGroup displayGroup) {
{'fraction_non_alphanumeric': 0.11602979049209995, 'fraction_numerical': 0.0013920790700911812, 'mean_word_length': 2.7145811789038263, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1888442', 'n_tokens_mistral': 4132, 'n_tokens_neox': 4018, 'n_words': 831}