Exemple #1
0
 public static RoleTag CopyTo(this RoleTag v, RoleTag o)
 {
     o.Value           = v.Value;
     o.Role            = v.Role;
     o.RoleDescription = v.RoleDescription;
     o.RolePicture     = v.RolePicture;
     o.TagPicture      = v.TagPicture;
     return(o);
 }
Exemple #2
0
        private static void FillSerie(Video p, SVR_AnimeSeries aser,
                                      Dictionary <SVR_AnimeEpisode, CL_AnimeEpisode_User> eps,
                                      SVR_AniDB_Anime anidb, CL_AnimeSeries_User ser, int userid)
        {
            using (ISession session = DatabaseFactory.SessionFactory.OpenSession())
            {
                ISessionWrapper sessionWrapper = session.Wrap();
                CL_AniDB_Anime  anime          = ser.AniDBAnime.AniDBAnime;
                p.Id        = ser.AnimeSeriesID;
                p.AnimeType = AnimeTypes.AnimeSerie.ToString();
                if (ser.AniDBAnime.AniDBAnime.Restricted > 0)
                {
                    p.ContentRating = "R";
                }
                p.Title   = aser.GetSeriesName();
                p.Summary = SummaryFromAnimeContract(ser);
                p.Type    = "show";
                p.AirDate = DateTime.MinValue;
                TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
                if (anime.GetAllTags().Count > 0)
                {
                    p.Genres = new List <Tag>();
                    anime.GetAllTags()
                    .ToList()
                    .ForEach(a => p.Genres.Add(new Tag {
                        Value = textInfo.ToTitleCase(a.Trim())
                    }));
                }
                //p.OriginalTitle
                if (anime.AirDate.HasValue)
                {
                    p.AirDate = anime.AirDate.Value;
                    p.OriginallyAvailableAt = anime.AirDate.Value.ToPlexDate();
                    p.Year = anime.AirDate.Value.Year;
                }
                p.LeafCount = anime.EpisodeCount;
                //p.ChildCount = p.LeafCount;
                p.ViewedLeafCount = ser.WatchedEpisodeCount;
                p.Rating          = (int)Math.Round((anime.Rating / 100D), 1);
                AniDB_Vote vote = RepoFactory.AniDB_Vote.GetByEntityAndType(anidb.AnimeID, AniDBVoteType.Anime) ??
                                  RepoFactory.AniDB_Vote.GetByEntityAndType(anidb.AnimeID, AniDBVoteType.AnimeTemp);
                if (vote != null)
                {
                    p.UserRating = (int)(vote.VoteValue / 100D);
                }

                List <CrossRef_AniDB_TvDBV2> ls = ser.CrossRefAniDBTvDBV2;
                if (ls != null && ls.Count > 0)
                {
                    foreach (CrossRef_AniDB_TvDBV2 c in ls)
                    {
                        if (c.TvDBSeasonNumber == 0)
                        {
                            continue;
                        }
                        p.Season = c.TvDBSeasonNumber.ToString();
                        p.Index  = c.TvDBSeasonNumber;
                    }
                }
                p.Thumb = p.ParentThumb = anime.DefaultImagePoster.GenPoster(null);
                p.Art   = anime?.DefaultImageFanart?.GenArt(null);
                if (anime?.Fanarts != null)
                {
                    p.Fanarts = new List <Contract_ImageDetails>();
                    anime.Fanarts.ForEach(
                        a =>
                        p.Fanarts.Add(new Contract_ImageDetails
                    {
                        ImageID   = a.AniDB_Anime_DefaultImageID,
                        ImageType = a.ImageType
                    }));
                }
                if (anime?.Banners != null)
                {
                    p.Banners = new List <Contract_ImageDetails>();
                    anime.Banners.ForEach(
                        a =>
                        p.Banners.Add(new Contract_ImageDetails
                    {
                        ImageID   = a.AniDB_Anime_DefaultImageID,
                        ImageType = a.ImageType
                    }));
                }

                if (eps != null)
                {
                    List <EpisodeType> types = eps.Keys.Where(a => a.AniDB_Episode != null)
                                               .Select(a => a.EpisodeTypeEnum).Distinct().ToList();
                    p.ChildCount = types.Count > 1 ? types.Count : eps.Keys.Count;
                }
                p.Roles = new List <RoleTag>();

                //TODO Character implementation is limited in JMM, One Character, could have more than one Seiyuu
                if (anime.Characters != null)
                {
                    foreach (CL_AniDB_Character c in anime.Characters)
                    {
                        string       ch     = c?.CharName;
                        AniDB_Seiyuu seiyuu = c?.Seiyuu;
                        if (String.IsNullOrEmpty(ch))
                        {
                            continue;
                        }
                        RoleTag t = new RoleTag
                        {
                            Value = seiyuu?.SeiyuuName
                        };
                        if (seiyuu != null)
                        {
                            t.TagPicture = ConstructSeiyuuImage(null, seiyuu.AniDB_SeiyuuID);
                        }
                        t.Role            = ch;
                        t.RoleDescription = c?.CharDescription;
                        t.RolePicture     = ConstructCharacterImage(null, c.CharID);
                        p.Roles.Add(t);
                    }
                }
                p.Titles = new List <AnimeTitle>();
                foreach (AniDB_Anime_Title title in anidb.GetTitles())
                {
                    p.Titles.Add(
                        new AnimeTitle {
                        Language = title.Language, Title = title.Title, Type = title.TitleType
                    });
                }
            }
        }
Exemple #3
0
        public static Video GenerateFromAnimeGroup(SVR_AnimeGroup grp, int userid, List <SVR_AnimeSeries> allSeries,
                                                   ISessionWrapper session = null)
        {
            CL_AnimeGroup_User cgrp = grp.GetUserContract(userid);
            int subgrpcnt           = grp.GetAllChildGroups().Count;

            if ((cgrp.Stat_SeriesCount == 1) && (subgrpcnt == 0))
            {
                SVR_AnimeSeries     ser    = ShokoServiceImplementation.GetSeriesForGroup(grp.AnimeGroupID, allSeries);
                CL_AnimeSeries_User cserie = ser?.GetUserContract(userid);
                if (cserie == null)
                {
                    return(null);
                }
                Video v = GenerateFromSeries(cserie, ser, ser.GetAnime(), userid, session);
                v.AirDate   = ser.AirDate;
                v.UpdatedAt = ser.LatestEpisodeAirDate.HasValue
                    ? ser.LatestEpisodeAirDate.Value.ToUnixTime()
                    : null;
                v.Group = cgrp;
                return(v);
            }
            else
            {
                SVR_AnimeSeries ser = grp.DefaultAnimeSeriesID.HasValue
                    ? allSeries.FirstOrDefault(a => a.AnimeSeriesID == grp.DefaultAnimeSeriesID.Value)
                    : allSeries.Find(a => a.AirDate != DateTime.MinValue);
                if (ser == null && allSeries.Count > 0)
                {
                    ser = allSeries[0];
                }
                CL_AnimeSeries_User cserie = ser?.GetUserContract(userid);
                Video v = FromGroup(cgrp, cserie, userid, subgrpcnt);
                v.Group     = cgrp;
                v.AirDate   = cgrp.Stat_AirDate_Min ?? DateTime.MinValue;
                v.UpdatedAt = cgrp.LatestEpisodeAirDate?.ToUnixTime();
                v.Rating    = (int)Math.Round((grp.AniDBRating / 100), 1);
                List <Tag> newTags = new List <Tag>();
                foreach (AniDB_Tag tag in grp.Tags)
                {
                    Tag      newTag   = new Tag();
                    TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
                    newTag.Value = textInfo.ToTitleCase(tag.TagName.Trim());
                    if (!newTags.Contains(newTag))
                    {
                        newTags.Add(newTag);
                    }
                }
                v.Genres = newTags;
                if (ser == null)
                {
                    return(v);
                }
                List <AnimeTitle> newTitles = ser.GetAnime()
                                              .GetTitles()
                                              .Select(title => new AnimeTitle
                {
                    Title    = title.Title,
                    Language = title.Language,
                    Type     = title.TitleType
                })
                                              .ToList();
                v.Titles = newTitles;

                v.Roles = new List <RoleTag>();

                //TODO Character implementation is limited in JMM, One Character, could have more than one Seiyuu
                if (ser.GetAnime()?.Contract?.AniDBAnime?.Characters != null)
                {
                    foreach (CL_AniDB_Character c in ser.GetAnime().Contract.AniDBAnime.Characters)
                    {
                        string       ch     = c?.CharName;
                        AniDB_Seiyuu seiyuu = c?.Seiyuu;
                        if (String.IsNullOrEmpty(ch))
                        {
                            continue;
                        }
                        RoleTag t = new RoleTag
                        {
                            Value = seiyuu?.SeiyuuName
                        };
                        if (seiyuu != null)
                        {
                            t.TagPicture = ConstructSeiyuuImage(null, seiyuu.AniDB_SeiyuuID);
                        }
                        t.Role            = ch;
                        t.RoleDescription = c?.CharDescription;
                        t.RolePicture     = ConstructCharacterImage(null, c.CharID);
                        v.Roles.Add(t);
                    }
                }
                if (cserie?.AniDBAnime?.AniDBAnime?.Fanarts != null)
                {
                    v.Fanarts = new List <Contract_ImageDetails>();
                    cserie?.AniDBAnime?.AniDBAnime?.Fanarts.ForEach(
                        a =>
                        v.Fanarts.Add(new Contract_ImageDetails
                    {
                        ImageID   = a.AniDB_Anime_DefaultImageID,
                        ImageType = a.ImageType
                    }));
                }
                if (cserie?.AniDBAnime?.AniDBAnime?.Banners == null)
                {
                    return(v);
                }
                v.Banners = new List <Contract_ImageDetails>();
                cserie?.AniDBAnime?.AniDBAnime?.Banners.ForEach(
                    a =>
                    v.Banners.Add(new Contract_ImageDetails
                {
                    ImageID   = a.AniDB_Anime_DefaultImageID,
                    ImageType = a.ImageType
                }));
                return(v);
            }
        }
Exemple #4
0
        private static void FillSerie(Video p, AnimeSeries aser, Dictionary <AnimeEpisode, Contract_AnimeEpisode> eps,
                                      AniDB_Anime anidb, Contract_AnimeSeries ser, int userid)
        {
            using (ISession session = JMMService.SessionFactory.OpenSession())
            {
                Contract_AniDBAnime anime = ser.AniDBAnime.AniDBAnime;
                p.Id        = ser.AnimeSeriesID.ToString();
                p.AnimeType = JMMContracts.PlexAndKodi.AnimeTypes.AnimeSerie.ToString();
                if (ser.AniDBAnime.AniDBAnime.Restricted > 0)
                {
                    p.ContentRating = "R";
                }
                p.Title   = aser.GetSeriesName(session);
                p.Summary = SummaryFromAnimeContract(ser);
                p.Type    = "show";
                p.AirDate = DateTime.MinValue;
                TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
                if (anime.AllTags.Count > 0)
                {
                    p.Genres = new List <Tag>();
                    anime.AllTags.ToList().ForEach(a => p.Genres.Add(new Tag {
                        Value = textInfo.ToTitleCase(a.Trim())
                    }));
                }
                //p.OriginalTitle
                if (anime.AirDate.HasValue)
                {
                    p.AirDate = anime.AirDate.Value;
                    p.OriginallyAvailableAt = anime.AirDate.Value.ToPlexDate();
                    p.Year = anime.AirDate.Value.Year.ToString();
                }
                p.LeafCount = anime.EpisodeCount.ToString();
                //p.ChildCount = p.LeafCount;
                p.ViewedLeafCount = ser.WatchedEpisodeCount.ToString();
                p.Rating          = (anime.Rating / 100F).ToString(CultureInfo.InvariantCulture);
                List <Contract_CrossRef_AniDB_TvDBV2> ls = ser.CrossRefAniDBTvDBV2;
                if (ls != null && ls.Count > 0)
                {
                    foreach (Contract_CrossRef_AniDB_TvDBV2 c in ls)
                    {
                        if (c.TvDBSeasonNumber != 0)
                        {
                            p.Season = c.TvDBSeasonNumber.ToString();
                            p.Index  = p.Season;
                        }
                    }
                }
                p.Thumb = p.ParentThumb = anime.DefaultImagePoster.GenPoster();
                p.Art   = anime?.DefaultImageFanart?.GenArt();
                if (eps != null)
                {
                    List <enEpisodeType> types = eps.Keys.Select(a => a.EpisodeTypeEnum).Distinct().ToList();
                    p.ChildCount = types.Count > 1 ? types.Count.ToString() : eps.Keys.Count.ToString();
                }
                p.Roles = new List <RoleTag>();

                //TODO Character implementation is limited in JMM, One Character, could have more than one Seiyuu
                if (anidb.Contract?.AniDBAnime?.Characters != null)
                {
                    foreach (Contract_AniDB_Character c in anidb.Contract.AniDBAnime.Characters)
                    {
                        string ch = c?.CharName;
                        Contract_AniDB_Seiyuu seiyuu = c?.Seiyuu;
                        if (!string.IsNullOrEmpty(ch))
                        {
                            RoleTag t = new RoleTag();
                            t.Value = seiyuu?.SeiyuuName;
                            if (seiyuu != null)
                            {
                                t.TagPicture = Helper.ConstructSeiyuuImage(seiyuu.AniDB_SeiyuuID);
                            }
                            t.Role            = ch;
                            t.RoleDescription = c?.CharDescription;
                            t.RolePicture     = Helper.ConstructCharacterImage(c.CharID);
                            p.Roles.Add(t);
                        }
                    }
                }
                p.Titles = new List <AnimeTitle>();
                foreach (AniDB_Anime_Title title in anidb.GetTitles())
                {
                    p.Titles.Add(new AnimeTitle {
                        Language = title.Language, Title = title.Title, Type = title.TitleType
                    });
                }
            }
        }
Exemple #5
0
        public static Video GenerateFromAnimeGroup(ISession session, AnimeGroup grp, int userid,
                                                   List <AnimeSeries> allSeries)
        {
            Contract_AnimeGroup cgrp = grp.GetUserContract(userid);
            int subgrpcnt            = grp.GetAllChildGroups().Count;

            if ((cgrp.Stat_SeriesCount == 1) && (subgrpcnt == 0))
            {
                AnimeSeries ser = JMMServiceImplementation.GetSeriesForGroup(grp.AnimeGroupID, allSeries);
                if (ser != null)
                {
                    Contract_AnimeSeries cserie = ser.GetUserContract(userid);
                    if (cserie != null)
                    {
                        Video v = GenerateFromSeries(cserie, ser, ser.GetAnime(session), userid);
                        v.AirDate   = ser.AirDate;
                        v.UpdatedAt = ser.LatestEpisodeAirDate.HasValue
                            ? ser.LatestEpisodeAirDate.Value.ToUnixTime()
                            : null;
                        v.Group = cgrp;
                        return(v);
                    }
                }
            }
            else
            {
                AnimeSeries ser = grp.DefaultAnimeSeriesID.HasValue
                    ? allSeries.FirstOrDefault(a => a.AnimeSeriesID == grp.DefaultAnimeSeriesID.Value)
                    : allSeries.Find(a => a.AirDate != DateTime.MinValue);
                if ((ser == null) && (allSeries != null && allSeries.Count > 0))
                {
                    ser = allSeries[0];
                }
                Contract_AnimeSeries cserie = ser?.GetUserContract(userid);
                Video v = FromGroup(cgrp, cserie, userid, subgrpcnt);
                v.Group     = cgrp;
                v.AirDate   = cgrp.Stat_AirDate_Min ?? DateTime.MinValue;
                v.UpdatedAt = cgrp.LatestEpisodeAirDate?.ToUnixTime();
                v.Rating    = "" + Math.Round((grp.AniDBRating / 100), 1);
                List <Tag> newTags = new List <Tag>();
                foreach (AniDB_Tag tag in grp.Tags)
                {
                    Tag      newTag   = new Tag();
                    TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
                    newTag.Value = textInfo.ToTitleCase(tag.TagName.Trim());
                    if (!newTags.Contains(newTag))
                    {
                        newTags.Add(newTag);
                    }
                }
                v.Genres = newTags;
                if (ser != null)
                {
                    List <AnimeTitle> newTitles = new List <AnimeTitle>();
                    foreach (AniDB_Anime_Title title in ser.GetAnime(session).GetTitles())
                    {
                        AnimeTitle newTitle = new AnimeTitle();
                        newTitle.Title    = title.Title;
                        newTitle.Language = title.Language;
                        newTitle.Type     = title.TitleType;
                        newTitles.Add(newTitle);
                    }
                    v.Titles = newTitles;

                    v.Roles = new List <RoleTag>();

                    //TODO Character implementation is limited in JMM, One Character, could have more than one Seiyuu
                    if (ser.GetAnime(session).Contract?.AniDBAnime?.Characters != null)
                    {
                        foreach (Contract_AniDB_Character c in ser.GetAnime(session).Contract.AniDBAnime.Characters)
                        {
                            string ch = c?.CharName;
                            Contract_AniDB_Seiyuu seiyuu = c?.Seiyuu;
                            if (!string.IsNullOrEmpty(ch))
                            {
                                RoleTag t = new RoleTag();
                                t.Value = seiyuu?.SeiyuuName;
                                if (seiyuu != null)
                                {
                                    t.TagPicture = Helper.ConstructSeiyuuImage(seiyuu.AniDB_SeiyuuID);
                                }
                                t.Role            = ch;
                                t.RoleDescription = c?.CharDescription;
                                t.RolePicture     = Helper.ConstructCharacterImage(c.CharID);
                                v.Roles.Add(t);
                            }
                        }
                    }
                }
                return(v);
            }
            return(null);
        }
Exemple #6
0
        /// <inheritdoc />
        public override void Initialize()
        {
            ConnectorEndType  = ConnectorEnd.End == "Supplier" ? "Target" : "Source";
            UMLNameValue      = ConnectorEnd.Role;
            AliasValue        = ConnectorEnd.Alias;
            MultiplicityValue = ConnectorEnd.Cardinality;
            TaggedValues      = ConnectorEnd.TaggedValues;

            //Finalize list of stereotype tags to add
            switch (ConnectorEnd.Stereotype)
            {
            case "RdfsProperty":
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "RangeConnectorEnd"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "DomainConnectorEnd"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SubPropertyOf"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "EquivalentProperty"));
                StereotypeString = (string)ResourceDictionary["RdfsPropertyCharacteristics"];
                break;

            case "ObjectProperty":
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "RangeConnectorEnd"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "DomainConnectorEnd"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SubPropertyOf"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "EquivalentProperty"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "InverseOf"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "FunctionalProperty"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "InverseFunctionalProperty"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "SymmetricProperty"));
                _toAddStereotypeTaggedValues.Add(Definitions.Find(ptv => ptv.Key == "TransitiveProperty"));
                StereotypeString = (string)ResourceDictionary["ObjectPropertyCharacteristics"];
                break;
            }

            //Retrieve all tagged values and store them in a list
            //Tagged values are stored in a list to avoid iterating Collections multiple times, which is very costly
            //In a future iteration of the addin, avoid iterating the collection even once, instead using Repository.SQLQuery to retrieve
            //an XML-formatted list of every Tagged Value where the owner ID is Element.ElementID
            for (short i = 0; i < TaggedValues.Count; i++)
            {
                RoleTag tv = TaggedValues.GetAt(i);
                _taggedValuesList.Add(tv);
            }

            // Retrieve URI tagged value and save it in URIViewmodelTaggedValue
            try
            {
                var result = RetrieveTaggedValues(_taggedValuesList, "URI");
                URIViewmodelTaggedValue = new ViewModelTaggedValue(result.First())
                {
                    ResourceDictionary = ResourceDictionary,
                    Key = Definitions.Find(ptv => ptv.Key == "URI").Key
                };
                URIViewmodelTaggedValue.Initialize();
                URIValue = URIViewmodelTaggedValue.Value;
            }
            catch (ArgumentException)
            {
                //URI does not exist: Do nothing
            }

            // Add tagged values to list of ViewmodelTaggedValues
            DanishViewmodelTaggedValues     = AddTaggedValuesToViewmodelTaggedValues(_toAddDanishTaggedValues, _taggedValuesList);
            EnglishViewmodelTaggedValues    = AddTaggedValuesToViewmodelTaggedValues(_toAddEnglishTaggedValues, _taggedValuesList);
            ProvenanceViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddProvenanceTaggedValues, _taggedValuesList);
            StereotypeViewmodelTaggedValues = AddTaggedValuesToViewmodelTaggedValues(_toAddStereotypeTaggedValues, _taggedValuesList);
        }