예제 #1
0
        private bool?Matches(Citation citation, string?value, Func <Citation, string, bool> func)
        {
            if (value != null)
            {
                foreach (var split in value.ToLowerInvariant().Split(' '))
                {
                    var result = func(citation, split);

                    if (Match == Match.All)
                    {
                        if (!result)
                        {
                            return(false);
                        }
                    }
                    else if (Match == Match.Any)
                    {
                        if (result)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (result)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(null);
        }
        private HashSet <Person> GetDistinctPreviouslyMentionedOrganizations(Citation citation)
        {
            if (citation == null)
            {
                return(null);
            }

            HashSet <Person> organizationSet = new HashSet <Person>();

            Citation previousCitation = citation.PreviousPrintingCitation;

            while (previousCitation != null)
            {
                Reference previousReference = previousCitation.Reference;
                if (previousReference != null)
                {
                    IEnumerable <Person> previousPersons = previousReference.AuthorsOrEditorsOrOrganizations.AsEnumerable <Person>();
                    if (previousPersons != null)
                    {
                        foreach (Person person in previousPersons)
                        {
                            if (person != null && person.IsOrganization)
                            {
                                organizationSet.Add(person);
                            }
                        }
                    }
                }

                previousCitation = previousCitation.PreviousPrintingCitation;
            }

            return(organizationSet);
        }
예제 #3
0
 /// <summary>
 /// Obfuscates an <see cref="Citation" /> object
 /// </summary>
 /// <param name="thing">The <see cref="Citation" /> to obfuscate.</param>
 private void ObfuscateCitation(Citation thing)
 {
     thing.ShortName = "Hidden Citation";
     thing.Location  = "Hidden Location";
     thing.Remark    = "Hidden Remark";
     this.obfuscatedCache.Add(thing.Iid);
 }
예제 #4
0
        public void TestIsNumberEsque()
        {
            var tests = new[]
            {
                "206(d)",
                "3-54a",
                "121A-5.4(c)",
                "-17",
                "834,",
                "48c(4)",
                "2d",
                "-48a(4)",
                "-16",
                "34",
                "-54.",
                "30:4C-23."
            };

            foreach (var test in tests)
            {
                var rslt = Citation.IsNumberEsque(test);
                Console.WriteLine(new Tuple <string, bool>(test, rslt));
                Assert.IsTrue(rslt);
            }
        }
예제 #5
0
        //Version 1.1 Considers series title of parent reference, if applicable
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            SeriesTitle seriesTitle = null;

            if (citation.Reference.HasCoreField(ReferenceTypeCoreFieldId.SeriesTitle))
            {
                seriesTitle = citation.Reference.SeriesTitle;
            }
            else
            {
                if (citation.Reference.ParentReference != null && citation.Reference.ParentReference.HasCoreField(ReferenceTypeCoreFieldId.SeriesTitle))
                {
                    seriesTitle = citation.Reference.ParentReference.SeriesTitle;
                }
            }

            if (seriesTitle == null)
            {
                return(false);
            }

            return(string.Equals(seriesTitle.Name, "NAME", StringComparison.OrdinalIgnoreCase));
            //return seriesTitle.Name.StartsWith("NAME", StringComparison.OrdinalIgnoreCase);
            //return seriesTitle.Name.EndsWith("NAME", StringComparison.OrdinalIgnoreCase);
        }
        /// <summary>
        /// Create Charge with customer
        /// </summary>
        /// <param name="creditCard"></param>
        /// <returns></returns>
        public async Task <StripeCharge> ChargeCardAsync(CreditCardModel creditCard, Citation citation, CommonAccount account, ChargeTypeEnum chargeType)
        {
            Check.NotNull(creditCard, nameof(creditCard));

            var metaData = new Dictionary <string, string>();

            metaData["Account"]        = account.Name;
            metaData["AccountNumber"]  = account.Number.ToString();
            metaData["CitationNumber"] = citation.CitationNumber.ToString();
            metaData["Type"]           = chargeType.GetDescription();
            // Token is created using Checkout or Elements!
            // Get the payment token submitted by the form:
            var token = creditCard.SourceToken; // Using ASP.NET MVC

            var options = new StripeChargeCreateOptions
            {
                Amount      = creditCard.Amount,
                Currency    = "usd",
                Description = chargeType.GetDescription(),
                SourceTokenOrExistingSourceId = token,
                Metadata = metaData
            };
            var          service = new StripeChargeService();
            StripeCharge charge  = await service.CreateAsync(options);

            return(charge);
        }
예제 #7
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(citation.Reference.YearResolved))
            {
                return(false);
            }

            DateTime result;

            if (!DateTimeInformation.TryParse(citation.Reference.YearResolved, out result))
            {
                return(false);
            }

            if (result.Year > 1800)
            {
                return(false);
            }
            return(true);
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            FootnoteCitation currentFootnoteCitation = citation as FootnoteCitation;

            if (currentFootnoteCitation == null)
            {
                return(false);
            }

            FootnoteCitation previousFootnoteCitation = currentFootnoteCitation.PreviousFootnoteCitation;

            if (previousFootnoteCitation == null)
            {
                //there is no previous citation in a footnote, so this is the first one (disregarding reference-less footnotes)
                return(true);
            }

            while (previousFootnoteCitation != null)
            {
                if (previousFootnoteCitation.FootnoteIndex != currentFootnoteCitation.FootnoteIndex)
                {
                    if (previousFootnoteCitation.PageInPublication == currentFootnoteCitation.PageInPublication)
                    {
                        //a different previous footnote on the same page > this citation cannot be in the first footnote on the page
                        return(false);
                    }
                    else
                    {
                        //a different previous footnote on other page > this citation is in first footnote on page (disregarding reference-less footnotes)
                        return(true);
                    }
                }
                else
                {
                    if (previousFootnoteCitation.PageInPublication == currentFootnoteCitation.PageInPublication)
                    {
                        //the previous citation is in the same footnote on the same page; we cannot say anything yet
                    }
                    else
                    {
                        //the previous citation is in the same footnote, but on a different page: can we really detect page breaks INSIDE footnotes?
                        return(true);
                    }
                }

                previousFootnoteCitation = previousFootnoteCitation.PreviousFootnoteCitation;
            }

            //still here? false!
            return(false);
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            if (citation.Reference.ReferenceType == ReferenceType.LegalCommentary)
            {
                return(string.IsNullOrWhiteSpace(citation.Reference.SpecificField1));
            }

            if (citation.Reference.ReferenceType == ReferenceType.ContributionInLegalCommentary)
            {
                if (citation.Reference.ParentReference == null)
                {
                    return(false);
                }
                return(string.IsNullOrWhiteSpace(citation.Reference.ParentReference.SpecificField1));
            }

            return(false);
        }
예제 #10
0
        private void UpdateContent()
        {
            CitationStyle style = (CitationStyle)cbStyle.SelectedItem;
            CitationType  type  = (CitationType)cbType.SelectedItem;

            citationDetails.title   = tbTitle.Text;
            citationDetails.authors = GetAuthors();
            citationDetails.year    = tbYear.Text;

            if (type == CitationType.Book)
            {
                citationDetails.publisher = new Publisher(tbPublisher.Text);
            }

            if (type == CitationType.Article)
            {
                citationDetails.journal = new Journal(tbJournal.Text);
                citationDetails.doi     = tbDoi.Text;
            }

            citationDetails.style = style;
            citationDetails.type  = type;

            Citation citation = citationFactory.CreateCitation(citationDetails);

            commandFactory.Execute(citation);

            Close();
        }
예제 #11
0
 /*
  * Konstruktor
  */
 public CitationViewModel()
 {
     SelectedCitation = new Citation()
     {
         Content = "To jest treść wylosowanego lub wybranego przez Ciebie cytatu", Author = "Damian Ruta", Id = Guid.NewGuid().ToString()
     };
 }
예제 #12
0
        public ActionResult _AddCitation(int caseId)
        {
            var newCitation = new Citation();

            newCitation.CaseId = caseId;
            return(PartialView(newCitation));
        }
예제 #13
0
        public async Task <IActionResult> PutCitation(int id, Citation citation)
        {
            if (id != citation.ID)
            {
                return(BadRequest());
            }

            _context.Entry(citation).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CitationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #14
0
        protected void ApplyVideoAndImageUrl(Citation citation, CitationViolationListItem model, FileService fileService)
        {
            if (citation.Attachments.Count > 0)
            {
                var citationAttachment = citation.Attachments.OrderByDescending(s => s.CreateUtc).ToList();

                foreach (var ca in citationAttachment)
                {
                    if (ca.Attachment.AttachmentType == CitationAttachmentType.Video)
                    {
                        //Read the file from AWS Bucket
                        model.VideoUrl = fileService.ReadFileUrl(ca.Attachment.Key, AppSettings.AWSAccessKeyID, AppSettings.AWSSecretKey, AppSettings.AmazonS3Bucket);
                        //model.VideoUrl = AWSHelper.GetS3Url(ca.Attachment.Key, _appSettings.AmazonS3Url);
                        model.VideoAttachmentId = ca.Attachment.Id;
                        break;
                    }
                }

                if (string.IsNullOrEmpty(model.VideoUrl))
                {
                    foreach (var ca in citationAttachment)
                    {
                        if (ca.Attachment.AttachmentType == CitationAttachmentType.Image)
                        {
                            //Read the file from AWS Bucket
                            // model.ImageUrl = _fileService.ReadFileUrl(ca.Attachment.Key, _appSettings.AWSAccessKeyID, _appSettings.AWSSecretKey, _appSettings.AmazonS3Bucket);
                            model.ImageUrl = AWSHelper.GetS3Url(ca.Attachment.Key, AppSettings.AmazonS3Url);
                            break;
                        }
                    }
                }
            }
        }
        public Citation GetCitation(int citationId)
        {
            String   commandText = "usp_GetSpeciesCitation";
            Citation citation    = new Citation();

            using (SqlConnection conn = DataContext.GetConnection(this.GetConnectionStringKey(_context)))
            {
                using (SqlCommand cmd = new SqlCommand(commandText, conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@taxonomy_common_name_id", citationId);
                    SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            citation                            = new Citation();
                            citation.ID                         = Int32.Parse(reader["citation_id"].ToString());
                            citation.LiteratureID               = Int32.Parse(reader["literature_id"].ToString());
                            citation.LiteratureReferenceTitle   = reader["reference_title"].ToString();
                            citation.Title                      = reader["citation_title"].ToString();
                            citation.LiteratureEditorAuthorName = reader["author_name"].ToString();
                            citation.CitationYear               = reader["citation_year"].ToString();
                        }
                    }
                }
            }
            return(citation);
        }
예제 #16
0
        public async Task <ActionResult <Citation> > PostCitation(Citation citation)
        {
            _context.Citations.Add(citation);
            await _context.SaveChangesAsync().ConfigureAwait(false);

            return(CreatedAtAction("GetCitation", new { id = citation.ID }, citation));
        }
예제 #17
0
        private Citation GetSelectedCitationFromGrid()
        {
            Citation result = null;
            var      row    = dataGridView1.CurrentRow;

            if (row != null && row.Index - 1 >= 0)
            {
                Id id = ((CitationSelectorModel)row.DataBoundItem)?.Id ?? Id.Empty;
                if (id.IsNotNull)
                {
                    result = m_VolumeService.Citations.SingleOrDefault(c => c.Id == id);
                }
            }

            if (result == null)
            {
                result = VM.CurrentCitation;
            }

            if (result == null)
            {
                result = m_VolumeService.Citations.FirstOrDefault();
            }

            return(result);
        }
예제 #18
0
        private static ItemAndQueries CreateAuditingSession(string name, string email, string title, DateTime date)
        {
            var queries = new List <string>();

            var auditSession = new AuditSession(title);

            queries.AddRange(auditSession.ToInsertQueries());

            var auditor = new Auditor(name, name, new List <char>(), email);

            queries.AddRange(auditor.ToInsertQueries());

            var citation = new Citation("Audit Session_" + title, auditSession.Id);

            queries.AddRange(citation.ToInsertQueries());

            var auditDate = new FuzzyDateTime(date, citation.Id, auditSession.Id);

            queries.AddRange(auditDate.ToInsertQueries());

            queries.AddRange(new WhatHappenedWhen(auditSession.Id, auditDate.Id, citation.Id, auditSession.Id).ToInsertQueries());
            queries.AddRange(new WhoDidWhat(auditor.Id, auditSession.Id, citation.Id, auditSession.Id).ToInsertQueries());

            return(new ItemAndQueries(auditSession, queries));
        }
        public void Verify_that_when_Container_is_ReferenceDataLibrary_and_ReferenceSource_is_not_in_chain_of_Rdls_result_is_returned()
        {
            var otherSiteReferenceDataLibrary = new SiteReferenceDataLibrary();

            this.siteDirectory.SiteReferenceDataLibrary.Add(otherSiteReferenceDataLibrary);
            var referenceSource = new ReferenceSource {
                Iid = Guid.Parse("3c44c0e3-d2de-43f9-9636-8235984dc4bf"), ShortName = "SOURCE"
            };

            otherSiteReferenceDataLibrary.ReferenceSource.Add(referenceSource);

            var siteReferenceDataLibrary = new SiteReferenceDataLibrary();
            var category           = new Category();
            var categoryDefinition = new Definition();
            var categoryCitation   = new Citation();

            categoryCitation.Source = referenceSource;

            this.siteDirectory.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary);
            siteReferenceDataLibrary.DefinedCategory.Add(category);
            category.Definition.Add(categoryDefinition);
            categoryDefinition.Citation.Add(categoryCitation);

            var result = this.citationRuleChecker.CheckWhetherReferencedReferenceSourceIsInChainOfRdls(categoryCitation).Single();

            Assert.That(result.Id, Is.EqualTo("MA-0260"));
            Assert.That(result.Description, Is.EqualTo("The referenced ReferenceSource 3c44c0e3-d2de-43f9-9636-8235984dc4bf:SOURCE of Citation.Source is not in the chain of Reference Data Libraries"));
            Assert.That(result.Severity, Is.EqualTo(SeverityKind.Error));
            Assert.That(result.Thing, Is.EqualTo(categoryCitation));
        }
예제 #20
0
        public static Citation ParseCitation(string input)
        {
            Citation citation = new Citation();
            input = TrimStartingNumers(input);

            GetDOI(input, ref citation);

            if (string.IsNullOrEmpty(citation.Doi))
            {
                try
                {
                    string[] dotArray = input.Split(new char[1] { '.' }, StringSplitOptions.RemoveEmptyEntries);

                    GetAuthorName(dotArray, ref citation);
                    GetYear(dotArray, ref citation);
                    GetTitle(dotArray, ref citation);
                    GetPages(dotArray, ref citation);

                    citation.UnstructuredData = input;
                }
                catch (Exception ex)
                {
                    citation.UnstructuredData = input;
                }
            }

            return citation;
        }
예제 #21
0
 public override void EvaluateOverride(Interpreter interpreter, Citation citation)
 {
     if (HasVariableDefined(interpreter, citation) && Children != null)
     {
         interpreter.Join(citation, this, Delimiter, Children.ToArray());
     }
 }
예제 #22
0
        private static void AddCitation(CitationUniSofiaContext db)
        {
            var sequence    = db.Citations.Count() + 1;
            var citType     = db.CitationTypes.FirstOrDefault();
            var author      = db.Authors.FirstOrDefault();
            var institution = db.Institutions.FirstOrDefault();
            var publication = db.Publications.FirstOrDefault();

            var citation = new Citation
            {
                Sequence       = sequence,
                Name           = "Българско наказателно-процесуално право : Т. 2",
                Year           = "1937",
                Detail         = "София : Печ. Художник",
                Pages          = "с. 434",
                CitationTypeId = citType.Id,
                CitationType   = citType,
                AuthorId       = author.Id,
                Author         = author,
                InstitutionId  = institution.Id,
                Institution    = institution
            };
            var publCitation = new PublicationCitation
            {
                Publication = publication,
                Citation    = citation
            };

            citation.PublicationsCitations.Add(publCitation);

            db.Citations.Add(citation);
            db.SaveChanges();
        }
예제 #23
0
        private Argument PerformDelete(int id)
        {
            var argument = _db.Arguments
                           .Include(a => a.Votes)
                           .FirstOrDefault(a => a.ArgumentId == id);

            argument.AddChildren();
            List <Argument> linked = _db.Arguments.Where(a => a.LinkId == id).ToList();

            foreach (Argument a in linked)
            {
                PerformDelete(a.ArgumentId);
            }
            if (argument.Children.Count == 0)
            {
                foreach (Vote vote in argument.Votes)
                {
                    _db.Votes.Remove(vote);
                }
                if (argument.IsCitation)
                {
                    Citation cite = _db.Citations.FirstOrDefault(c => c.ArgumentId == argument.ArgumentId);
                    _db.Citations.Remove(cite);
                }
                _db.Arguments.Remove(argument);
                _db.SaveChanges();
            }
            return(argument);
        }
예제 #24
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }


            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(false);
            }
            if (!placeholderCitation.NoPar)
            {
                return(false);
            }
            if (!placeholderCitation.PersonOnly)
            {
                return(false);
            }

            //all conditions met
            return(true);
        }
예제 #25
0
        public async Task <IActionResult> Cite(string creator, string title, string format, string url, string date, string institution, string description, string text, int argumentId)
        {
            if (argumentId != 0)
            {
                Argument citationArgument = new Argument();
                citationArgument.ParentId      = argumentId;
                citationArgument.IsCitation    = true;
                citationArgument.IsAffirmative = true;
                citationArgument.Strength      = 1;
                citationArgument.Text          = text;
                ApplicationUser user = await GetCurrentUser();

                citationArgument.UserId = user.Id;
                _db.Arguments.Add(citationArgument);
                _db.SaveChanges();
                Citation newCite = new Citation();
                newCite.Creator     = creator;
                newCite.Title       = title;
                newCite.Format      = format;
                newCite.URL         = url;
                newCite.Date        = date;
                newCite.Institution = institution;
                newCite.Description = description;
                newCite.Text        = text;
                newCite.ArgumentId  = citationArgument.ArgumentId;
                _db.Citations.Add(newCite);
                _db.SaveChanges();
                Argument argument = _db.Arguments.FirstOrDefault(a => a.ArgumentId == argumentId);
                int      rootId   = argument.GetRoot().ArgumentId;
                return(RedirectToAction("Tree", new { id = rootId }));
            }
            return(View("Index"));
        }
예제 #26
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ParentReference == null)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(citation.Reference.ParentReference.CustomField1))
            {
                return(false);
            }

            string test = citation.Reference.ParentReference.CustomField1;

            //note: if you do not specify the whole word, but rather its first characters, do NOT use * as a wildcard, but
            //\\w*, which means "zero or more word characters"
            var wordList = new string[] {
                "Lexikon\\w*",                                  //z.B. auch Wörter wie "Lexikonartikel" usw.
                "Enzyklopädie\\w*",
                "Encyclopedia",
                "encyclopédie"
            };
            var regEx = new Regex(@"\b(" + string.Join("|", wordList) + @")\b", RegexOptions.IgnoreCase);

            return(regEx.IsMatch(test));
        }
예제 #27
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ReferenceType != ReferenceType.CourtDecision)
            {
                return(false);
            }

            var field = citation.Reference.SpecificField3;

            //note: if you do not specify the whole word, but rather its first characters, do NOT use * as a wildcard, but
            //\\w*, which means "zero or more word characters"
            var wordList1 = new string[] {
                "Schreiben",
                "Erlass",
                "Verfügung"
            };

            var regEx1 = new Regex(@"\b(" + string.Join("|", wordList1) + @")\b", RegexOptions.IgnoreCase);

            if (regEx1.IsMatch(field))
            {
                return(true);
            }
            return(false);
        }
예제 #28
0
        /// <summary>
        /// Delete a citation from the current volume.
        /// </summary>
        /// <returns></returns>
        public bool DeleteCitationById(Id id)
        {
            Id volumeId = m_Volumeservice.CurrentVolume.Id;

            if (volumeId.IsNull)
            {
                m_MessageboxService.Show("Must have a Volume selected to delete a citation.", "No current Volume");
                return(false);
            }

            Citation cit = m_CitationService.GetCitation(volumeId, id);

            if (cit == null)
            {
                m_MessageboxService.Show($"Citation with id {id.ToStringShort()} was not found for Volume \"{m_Volumeservice.CurrentVolume.Title}\" with Id {volumeId}.", "Citation not found");
                return(false);
            }


            var result = m_MessageboxService.ShowYesNo($"Do you want to delete citation \"{cit.Citation1.Left(50, true)}\" with id {id.ToStringShort()}?", "Delete citation");

            if (result != DekDialogResult.Yes)
            {
                return(false);
            }

            m_CitationService.DeleteCitation(cit);
            return(true);
        }
예제 #29
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ReferenceType != ReferenceType.InternetDocument)
            {
                return(false);
            }

            var onlineAddress = citation.Reference.OnlineAddress;

            if (string.IsNullOrEmpty(onlineAddress))
            {
                return(false);
            }

            //note: if you do not specify the whole word, but rather its first characters, do NOT use * as a wildcard, but
            //\\w*, which means "zero or more word characters"
            var wordList = new string[] {
                "wikipedia.org"
            };
            var regEx = new Regex(@"\b(" + string.Join("|", wordList) + @")\b");

            return(regEx.IsMatch(onlineAddress));
        }
예제 #30
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ReferenceType != ReferenceType.CourtDecision)
            {
                return(false);
            }

            var organizations = citation.Reference.Organizations;

            if (organizations == null || organizations.Count == 0)
            {
                return(false);
            }

            //note: if you do not specify the whole word, but rather its first characters, do NOT use * as a wildcard, but
            //\\w*, which means "zero or more word characters"
            var wordList = new string[] {
                "BVerfG"
            };
            var regEx = new Regex(@"\b(" + string.Join("|", wordList) + @")\b");

            return(organizations.Any(item => regEx.IsMatch(item.LastName) || regEx.IsMatch(item.Abbreviation)));
        }
예제 #31
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(true);
            }
            if (citation.Reference == null)
            {
                return(true);
            }

            PlaceholderCitation thisCitation = citation as PlaceholderCitation;

            if (thisCitation == null)
            {
                return(true);                                  //only PlaceholderCitations can be part of a caption and can have a predecessor-PlaceholderCitation that can be part of a caption
            }
            //caution: the property thisCitation.PreviousPlaceholderCitation may give wrong results and should currently (C6.7) not be used
            PlaceholderCitation previousCitation = thisCitation.PreviousCitation as PlaceholderCitation;

            if (previousCitation == null)
            {
                return(true);                                      //ditto
            }
            if (previousCitation.IsPartOfCaption)
            {
                return(false);
            }

            return(true);
        }
예제 #32
0
        private static void GetAuthorName(string[] dotArray, ref Citation citation)
        {
            int indexofName = dotArray[0].IndexOf(',');

            if (indexofName >= 0)
            {
                citation.AuthorName = dotArray[0].Substring(0, indexofName);
            }
            else
            {
                citation.AuthorName = dotArray[0];
            }

            // If surname name is incorrect
            if (citation.AuthorName.Length <= 1)
            {
                citation.AuthorName = string.Empty;
            }

            dotArray[0] = string.Empty;
        }
        public void CitationService_Add_Calls_Repository_Add_Method_With_The_Same_Citation_Object_It_Recieved()
        {
            // Create test data
            var newCitation = new Citation
                                    {
                                        Text = "Foo",
                                        Page = "Bar"
                                    };

            //Create Mock
            var mockRepository = new Mock<IRepository<Citation>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Citation>()).Returns(mockRepository.Object);

            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Act
            _service.Add(newCitation);

            //Assert
            mockRepository.Verify(r => r.Add(newCitation));
        }
        public void CitationService_Add_Calls_UnitOfWork_Commit_Method()
        {
            // Create test data
            var newCitation = new Citation
                                    {
                                        Text = "Foo",
                                        Page = "Bar"
                                    };

            //Create Mock
            var mockRepository = new Mock<IRepository<Citation>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Citation>()).Returns(mockRepository.Object);

            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Act
            _service.Add(newCitation);

            //Assert
            _mockUnitOfWork.Verify(db => db.Commit());
        }
예제 #35
0
        private static void GetPages(string[] dotArray, ref Citation citation)
        {
            foreach (string element in dotArray)
            {
                if (element.Contains("pages"))
                {
                    citation.FirstPage = Regex.Replace(element, @"[^\d]", "");
                    break;
                }
                else
                {
                    citation.FirstPage = GetMatch(element, "([0-9]?\\d{1,})(?:[ ]{0,1}-[ ]{0,1}([0-9]?\\d{1,}))");

                    if (!string.IsNullOrEmpty(citation.FirstPage))
                    {
                        citation.FirstPage = citation.FirstPage.Substring(0, citation.FirstPage.IndexOf('-')).Trim();
                        break;
                    }
                }
            }

            if (string.IsNullOrEmpty(citation.FirstPage))
            {
                foreach (string element in dotArray)
                {
                    int page;
                    bool result = Int32.TryParse(element.Trim(' ', ',', ':'), out page);

                    if (result)
                    {
                        citation.FirstPage = page.ToString();
                        break;
                    }
                }
            }
        }
예제 #36
0
        public int Compare(Citation x, Citation y)
        {
            /*
               This is an example of a custom sort macro that sorts all references of type 'court decision' at the bottom of the bibliography.
               The internet documents themselves are sorted according to a different logic than the rest of the cited documents.
               Return values:
               0:                  x is considered the same as y sorting-wise, so we cannot tell a difference based on the algorithm below
               > 0 (positive):     x should go after y, x is greater than y
               < 0 (negative):     x should go before y, x is less than
            */

            //First we make sure we are comparing BibliographyCitations only
            var xBibliographyCitation = x as BibliographyCitation;
            var yBibliographyCitation = y as BibliographyCitation;

            if (xBibliographyCitation == null || yBibliographyCitation == null) return 0;
            var xReference = xBibliographyCitation.Reference;
            var yReference = yBibliographyCitation.Reference;
            if (xReference == null || yReference == null) return 0;

            var defaultCitationComparer = CitationComparer.AuthorYearTitleAscending;

            var xSection = GetBibliographySection(xReference);
            var ySection = GetBibliographySection(yReference);

            var sectionComparison = xSection.CompareTo(ySection);

            if (sectionComparison == 0)
            {
                return defaultCitationComparer.Compare(x, y);
            }
            else
            {
                return sectionComparison;
            }
        }
예제 #37
0
        private static void GetYear(string[] dotArray, ref Citation citation)
        {
            for (int index = dotArray.Length - 1; index >= 0; index--)
            {
                // First find year number as combination
                citation.CYear = GetMatch(dotArray[index], "((18|19|20)\\d{2})(?:[ ]{0,1}-[ ]{0,1}((18|19|20)\\d{2}))");

                if (string.IsNullOrEmpty(citation.CYear))
                {
                    //Find four digit year no.
                    citation.CYear = GetMatch(dotArray[index], "(18|19|20)\\d{2}");

                    if (!string.IsNullOrEmpty(citation.CYear))
                    {
                        //dotArray[index] = string.Empty;
                        break;
                    }
                }
                else
                {
                    //dotArray[index] = string.Empty;
                    break;
                }
            }
        }
예제 #38
0
 private static void GetDOI(string input, ref Citation citation)
 {
     citation.Doi = GetMatch(input, "\\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?![\"&\'<>])\\S)+)\\b");
 }
예제 #39
0
        private static void ParseTitleArnetMinerV7(string filein, string prefixfileout)
        {
            //using (FileStream fs = File.Open(directory + filename, FileMode.Open, FileAccess.Read))
              //using (BufferedStream bs = new BufferedStream(fs))
              // using (StreamReader sr = new StreamReader(bs))
              using (StreamWriter file = new System.IO.StreamWriter(Path.GetFullPath(directory + prefixfileout +
               ".csv")))
              {
            file.WriteLine("ARNETID\tTITLE\tCONF");
            using (StreamReader sr = File.OpenText(filein))
            {
              string s;
              string strcurTitle = "#*";
              int curYear = 0;
              string strcurConfVenue = "#con";
              int curCitationFrom = 0;
              int curCitationTo = -1;
              int curArnetid = -1;
              string strcurAbstract = "#!";
              Citation curCitation = null;
              List<string> strcurAuthors = new List<string>();
              HashSet<int> icurRefId = new HashSet<int>();
              StringBuilder sb = new StringBuilder();
              curCitation = new Citation();

              while ((s = sr.ReadLine()) != null)
              {
            if ((s = s.Trim()).Equals(string.Empty))
            {
              file.WriteLine(string.Format("{0}\t{1}\t{2}", curCitationFrom, strcurTitle, strcurConfVenue));
              continue;
            }
            if (s.StartsWith(strTitle))
            {
              //save current paper
              //RESET create new paper
              curCitation = null;
              icurRefId = new HashSet<int>();
              strcurTitle = s.Substring(strTitle.Length);
              strcurAuthors.Clear();
            }
            else if (s.StartsWith(strAuthors))
            {
              strcurAuthors.AddRange(s.Substring(strAuthors.Length).Split(','));
            }
            else if (s.StartsWith(strYearV7))
            {
              curYear = Convert.ToInt32(s.Substring(strYearV7.Length));
            }
            else if (s.StartsWith(strConfVenueV7))
            {
              strcurConfVenue = s.Substring(strConfVenueV7.Length);
            }
            else if (s.StartsWith(strCitationNumber))
            {
              //curCitationNumber = Convert.ToInt32(s.Substring(strCitationNumber.Length));
            }
            else if (s.StartsWith(strIndex))
            {
              curCitationFrom = Convert.ToInt32(s.Substring(strIndex.Length));
            }
            else if (s.StartsWith(strArnetid))
            {
              curArnetid = Convert.ToInt32(s.Substring(strArnetid.Length));
            }
            else if (s.StartsWith(strRefId))
            {
              if (!s.Substring(strRefId.Length).Trim().Equals(string.Empty))
                icurRefId.Add(Convert.ToInt32(s.Substring(strRefId.Length).Trim()));
            }
            else if (s.StartsWith(strAbstract))
            {
              strcurAbstract = s.Substring(strAbstract.Length);
            }
            else
            {
              if (s.Length != 0)
                Console.WriteLine("Unknown tag: string=" + s);
            }
              }

            }
              }
        }
예제 #40
0
        private static void GetTitle(string[] dotArray, ref Citation citation)
        {
            int titleIndex = GetTitleIndex(dotArray, 1);

            if (!citation.Type.Equals(CitationType.Conference))
            {
                if (titleIndex >= dotArray.Length)
                {
                    citation.VolumeTitle = dotArray[titleIndex - 1].Trim();
                    dotArray[titleIndex-1] = string.Empty;
                }
                else
                {
                    citation.VolumeTitle = dotArray[titleIndex].Trim();
                    dotArray[titleIndex] = string.Empty;
                }
            }
        }
예제 #41
0
        private static void ParseCitationArnetMinerV7(string filein, string prefixfileout)
        {
            //using (FileStream fs = File.Open(directory + filename, FileMode.Open, FileAccess.Read))
              //using (BufferedStream bs = new BufferedStream(fs))
              // using (StreamReader sr = new StreamReader(bs))

              using (StreamReader sr = File.OpenText(filein))
              {
            string s;
            string strcurTitle = "#*";
            int curYear = 0;
            string strcurConfVenue = "#con";
            int curCitationFrom = 0;
            int curCitationTo = -1;
            int curArnetid = -1;
            string strcurAbstract = "#!";
            Citation curCitation = null;
            List<string> strcurAuthors = new List<string>();
            HashSet<int> icurRefId = new HashSet<int>();

            curCitation = new Citation();
            while ((s = sr.ReadLine()) != null)
            {
              if ((s = s.Trim()).Equals(string.Empty))
            continue;
              if (s.StartsWith(strTitle))
              {
            //save current citation
            //if (icurRefId.Count > 0)
            {
              //icurRefId.ToList().ForEach(idTo =>
              {
                if (!Citation.dicAllCitations.Keys.Contains(new Tuple<int, int>(curCitationFrom, curArnetid)))
                  Citation.dicAllCitations.Add(new Tuple<int, int>(curCitationFrom, curArnetid),
                    new Citation() { idArnetFrom = curCitationFrom, idArnetTo = curArnetid });
              }
              //);
            }
            //RESET create new paper
            curCitation = null;
            icurRefId = new HashSet<int>();
            strcurTitle = s.Substring(strTitle.Length);
            strcurAuthors.Clear();
              }
              else if (s.StartsWith(strAuthors))
              {
            strcurAuthors.AddRange(s.Substring(strAuthors.Length).Split(','));
              }
              else if (s.StartsWith(strYearV7))
              {
            curYear = Convert.ToInt32(s.Substring(strYearV7.Length));
              }
              else if (s.StartsWith(strConfVenueV7))
              {
            strcurConfVenue = s.Substring(strConfVenueV7.Length);
              }
              else if (s.StartsWith(strCitationNumber))
              {
            //curCitationNumber = Convert.ToInt32(s.Substring(strCitationNumber.Length));
              }
              else if (s.StartsWith(strIndex))
              {
            curCitationFrom = Convert.ToInt32(s.Substring(strIndex.Length));
              }
              else if (s.StartsWith(strArnetid))
              {
            curArnetid = Convert.ToInt32(s.Substring(strArnetid.Length));
              }
              else if (s.StartsWith(strRefId))
              {
            if (!s.Substring(strRefId.Length).Trim().Equals(string.Empty))
              icurRefId.Add(Convert.ToInt32(s.Substring(strRefId.Length).Trim()));
              }
              else if (s.StartsWith(strAbstract))
              {
            strcurAbstract = s.Substring(strAbstract.Length);
              }
              else
              {
            if (s.Length != 0)
              Console.WriteLine("Unknown tag: string=" + s);
              }
            }
            WriteToFile(Citation.dicAllCitations, prefixfileout);
              }
        }