コード例 #1
0
ファイル: BaseCrawler.cs プロジェクト: Genometric/TVQ
        public Publication MergePubsIfNecessary(Publication publication)
        {
            if (publication == null)
            {
                return(null);
            }

            if ((publication.DOI != null && PubsByDOI.TryGetValue(publication.DOI, out Publication duplicate) ||
                 (publication.PubMedID != null && PubsByPMID.TryGetValue(publication.PubMedID, out duplicate)) ||
                 (publication.Title != null && PubsByTitle.TryGetValue(publication.Title, out duplicate))) &&
                duplicate.ID != publication.ID)
            {
                // Duplicate found.
                foreach (var association in duplicate.ToolAssociations)
                {
                    publication.ToolAssociations.Add(
                        new ToolPublicationAssociation()
                    {
                        Publication = publication,
                        Tool        = association.Tool
                    });
                }

                TryRemovePublication(duplicate);
                TryAddPublication(publication);
                return(publication);
            }
コード例 #2
0
ファイル: BaseCrawler.cs プロジェクト: Genometric/TVQ
        public Publication GetPublication(Publication publication)
        {
            if (publication == null)
            {
                return(null);
            }

            if (publication.DOI != null &&
                PubsByDOI.ContainsKey(publication.DOI))
            {
                return(PubsByDOI[publication.DOI]);
            }

            if (publication.PubMedID != null &&
                PubsByPMID.ContainsKey(publication.PubMedID))
            {
                return(PubsByPMID[publication.PubMedID]);
            }

            if (publication.Title != null &&
                PubsByTitle.ContainsKey(publication.Title))
            {
                return(PubsByTitle[publication.Title]);
            }

            return(null);
        }
コード例 #3
0
ファイル: BaseCrawler.cs プロジェクト: Genometric/TVQ
        public bool TryRemovePublication(Publication publication)
        {
            if (publication == null)
            {
                return(false);
            }

            if (publication.DOI != null)
            {
                PubsByDOI.TryRemove(publication.DOI, out _);
            }

            if (publication.PubMedID != null)
            {
                PubsByPMID.TryRemove(publication.PubMedID, out _);
            }

            if (publication.Title != null)
            {
                PubsByTitle.TryRemove(publication.Title, out _);
            }

            PublicationsToBeDeleted.Add(publication);

            return(true);
        }
コード例 #4
0
ファイル: BaseCrawler.cs プロジェクト: Genometric/TVQ
        public bool PublicationExists(Publication publication)
        {
            if (publication == null)
            {
                return(false);
            }

            if (publication.DOI != null &&
                PubsByDOI.ContainsKey(publication.DOI))
            {
                return(true);
            }

            if (publication.PubMedID != null &&
                PubsByPMID.ContainsKey(publication.PubMedID))
            {
                return(true);
            }

            if (publication.Title != null &&
                PubsByTitle.ContainsKey(publication.Title))
            {
                return(true);
            }

            return(false);
        }
コード例 #5
0
ファイル: BaseCrawler.cs プロジェクト: Genometric/TVQ
        public bool TryAddPublication(Publication publication)
        {
            if (publication == null || PublicationExists(publication))
            {
                return(false);
            }

            if (publication.DOI != null)
            {
                PubsByDOI.TryAdd(publication.DOI, publication);
            }

            if (publication.PubMedID != null)
            {
                PubsByPMID.TryAdd(publication.PubMedID, publication);
            }

            if (publication.Title != null)
            {
                PubsByTitle.TryAdd(publication.Title, publication);
            }

            return(true);
        }