Пример #1
0
        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
        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
        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
        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
        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);
        }