/// <summary> /// Read the Publication Harvester database and export RDF /// </summary> public void ExportRdf() { if (_storage != null) { PreviouslyAddedChecker.SkipAddedPeopleAndPublications(_storage); } DateTime startTime = DateTime.Now; IGraph g = Ontology.GetNewGraph(); People people = new People(_db); int total = people.PersonList.Count - PreviouslyAddedChecker._PeopleSkipped; foreach (Person person in people.PersonList) { if (!PreviouslyAddedChecker.CheckPerson(person.Setnb)) { PreviouslyAddedChecker.AddPerson(person.Setnb); peopleAddedThisRun++; logger.Info(String.Format("Processing #{0} of {1}: {2}", peopleAddedThisRun, total, person.ToString())); _personGraphCreator.AddPersonToGraph(g, person); if (peopleAddedThisRun % _peoplePerWrite == 0) { PersonGraphWriter.Write(g); g.Dispose(); g = Ontology.GetNewGraph(); } if ((PreviouslyAddedChecker.PeopleAdded - PreviouslyAddedChecker._PeopleSkipped) % 10 == 0) { LogTiming(startTime, total); } } } g.Dispose(); logger.Info("Finished writing RDF to {0}", PersonGraphWriter.Filename); LogTiming(startTime, total); }
private void AddPublicationAssertions(IGraph g, Publication pub) { if (!PreviouslyAddedChecker.CheckPublication(pub.PMID)) { PreviouslyAddedChecker.AddPublication(pub.PMID); IUriNode publicationNode = g.CreateUriNode(new Uri("http://www.stellman-greene.com/publication/" + pub.PMID)); g.Assert(new Triple(publicationNode, g.CreateUriNode(new Uri(OntologyHelper.PropertyType)), g.GetClassNode("publication:Publication"))); g.Assert(new Triple(publicationNode, g.GetPropertyNode("publication:year"), g.CreateLiteralNode(pub.Year.ToString(), new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger)))); if (pub.Journal != null) { g.Assert(new Triple(publicationNode, g.GetPropertyNode("publication:journal"), g.CreateLiteralNode(pub.Journal))); } if (pub.Issue != null) { g.Assert(new Triple(publicationNode, g.GetPropertyNode("publication:issue"), g.CreateLiteralNode(pub.Issue))); } if (pub.Title != null) { g.Assert(new Triple(publicationNode, g.GetPropertyNode("publication:title"), g.CreateLiteralNode(pub.Title))); } if (pub.PubType != null) { g.Assert(new Triple(publicationNode, g.GetPropertyNode("publication:publicationType"), g.CreateLiteralNode(pub.PubType))); } if (pub.Authors != null) { g.Assert(new Triple(publicationNode, g.GetPropertyNode("publication:authorCount"), g.CreateLiteralNode(pub.Authors.Length.ToString(), new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger)))); } if (pub.MeSHHeadings != null) { foreach (var meshHeading in pub.MeSHHeadings) { if (meshHeading != null) { g.Assert(new Triple(publicationNode, g.GetPropertyNode("publication:meshHeading"), g.CreateLiteralNode(meshHeading.ToString()))); } } } var data = _db.ExecuteQuery("SELECT Setnb, AuthorPosition, PositionType FROM PeoplePublications WHERE PMID = " + pub.PMID); foreach (DataRow row in data.Rows) { var authorNode = g.CreateUriNode(new Uri("http://www.stellman-greene.com/person/" + row.Field <String>("Setnb"))); g.Assert(authorNode, g.GetPropertyNode("person:authorOf"), publicationNode); var publicationAuthorNode = g.CreateBlankNode(); g.Assert(publicationAuthorNode, g.CreateUriNode(new Uri(OntologyHelper.PropertyType)), g.GetClassNode("publication:PublicationAuthor")); g.Assert(publicationNode, g.GetPropertyNode("publication:hasAuthor"), publicationAuthorNode); g.Assert(publicationAuthorNode, g.GetPropertyNode("publication:author"), authorNode); var authorPosition = row["AuthorPosition"]; if (authorPosition != null && authorPosition is System.Int32) { g.Assert(publicationAuthorNode, g.GetPropertyNode("publication:authorPosition"), g.CreateLiteralNode(authorPosition.ToString(), new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger))); } var positionType = row["PositionType"]; if (positionType != null && positionType is System.Int16 && Enum.IsDefined(typeof(Harvester.AuthorPositions), Convert.ToInt32(positionType))) { g.Assert(publicationAuthorNode, g.GetPropertyNode("publication:authorPositionType"), g.GetAuthorPositionEntityNode((Harvester.AuthorPositions)Convert.ToInt32(positionType))); } } } }