public void SaveToGraph(VDS.RDF.IGraph target, VDS.RDF.IUriNode provCreatingAction) { createIdentityNode(target, provCreatingAction); //Set the type target.Assert(IdentityNode, UriNodeExt.RdfType(target), target.CreateUriNode(UriFactory.Create(Properties.Settings.Default.ScheduledService))); IdentityNode.IdentifyNode(target.CreateLiteralNode(TrainUID)); IUriNode serviceNodePredicate = target.CreateUriNode(Properties.Settings.Default.serviceNodePredicate); //TODO: most of the save to graph! foreach (ServiceNodeBase node in ServiceNodes) { //Note that order is crucail here: parent must be set before you try to save to graph and serviceAsNode will be null and afterwards //This feels some what fragile and probably needs a good look taking at it node.Parent = this; node.SaveToGraph(target, provCreatingAction); target.Assert(IdentityNode, serviceNodePredicate, node.ServiceAsNode); } }
public virtual void SaveToGraph(VDS.RDF.IGraph target, VDS.RDF.IUriNode provCreatingAction) { createLocationNode(target); //assert that it is a location target.Assert(locationNode, UriNodeExt.RdfType(target), target.CreateUriNode(Properties.Settings.Default.Location)); //assert that it is a tiploc location target.Assert(locationNode, UriNodeExt.RdfType(target), target.CreateUriNode(Properties.Settings.Default.TiplocLocation)); //link to the tiploc code ILiteralNode tiplockCodeNode = target.CreateLiteralNode(Tiploc); IUriNode tiplockUriNode = target.CreateUriNode(Properties.Settings.Default.tiplocCode); target.Assert(locationNode, tiplockUriNode, tiplockCodeNode); //set the id locationNode.IdentifyNode(tiplockCodeNode); //lastly, do the prov if (provCreatingAction != null) { locationNode.AssertResponibility(provCreatingAction); } }
public void ProcessHeader(System.IO.StreamReader inStream, ref VDS.RDF.IGraph targetGraph, VDS.RDF.IUriNode generationActivity, string fileName) { string firstLine = inStream.ReadLine(); if (!firstLine.StartsWith("HD"))//header record type is HD { throw new ImportFileFormatException(fileName, "File must include a header, denoted HD", 0, 0 ); } string mainframe_id = firstLine.Substring(2, 20); DateTime date_extract = DateTime.ParseExact(firstLine.Substring(22, 10), dtFormat, ProgramState.Provider); string curr_file_ref = firstLine.Substring(32, 7); string last_file_ref = firstLine.Substring(39, 7); // char update_type = firstLine[46];//not going to use this DateTime extract_start = DateTime.ParseExact(firstLine.Substring(48, 6), dateFormat, ProgramState.Provider); DateTime extract_end = DateTime.ParseExact(firstLine.Substring(54, 6), dateFormat, ProgramState.Provider); //Now put that in the graph string sourceFileUri = Common.ImportFileUriBaseString + "#" + DateTime.Now.ToString("o") + "SourceFile_" + fileName; IUriNode sourceFileNode = targetGraph.CreateUriNode(UriFactory.Create(sourceFileUri)); targetGraph.Assert(sourceFileNode, UriNodeExt.RdfType(targetGraph), targetGraph.CreateUriNode("prov:Entity")); if (generationActivity != null) { targetGraph.Assert(generationActivity, targetGraph.CreateUriNode(Properties.Settings.Default.provUsed), sourceFileNode); } ILiteralNode sourceID = targetGraph.CreateLiteralNode(mainframe_id); sourceFileNode.IdentifyNode(sourceID); //IUriNode idNode = targetGraph.CreateUriNode(Properties.Settings.Default.ID); //targetGraph.Assert(sourceFileNode, idNode, sourceID); targetGraph.Assert(sourceFileNode, targetGraph.CreateUriNode(UriFactory.Create(Properties.Settings.Default.provGeneratedTime)), targetGraph.CreateLiteralNode(date_extract.ToString(XmlSpecsHelper.XmlSchemaDateTimeFormat), UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeDateTime))); IUriNode invalidatedNote = targetGraph.CreateUriNode(Properties.Settings.Default.provInvalidAtTime); ILiteralNode timeInvalid = targetGraph.CreateLiteralNode(extract_end.ToString(XmlSpecsHelper.XmlSchemaDateTimeFormat), UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeDateTime)); targetGraph.Assert(sourceFileNode, invalidatedNote, timeInvalid); }
public override void SaveToGraph(VDS.RDF.IGraph target, VDS.RDF.IUriNode provCreatingAction) { /*DO NOT call base.SaveToGraph at this juncture * It will save it as if it's a tiploc * and it's not, it merely has one as a location * */ //Create the identifying node for this service thisServiceNode = createSerivceNode(target /*,provCreatingAction*/); //set the location base.createLocationNode(target); IUriNode locationLink = target.CreateUriNode(Properties.Settings.Default.locationPredicate); target.Assert(thisServiceNode, locationLink, locationNode); //save the calling point number IUriNode order = target.CreateUriNode(Properties.Settings.Default.NodeOrder); ILiteralNode callingPointNode = CallNumber.ToLiteral(target); target.Assert(thisServiceNode, order, callingPointNode); //platform if (!string.IsNullOrWhiteSpace(Platform)) { IUriNode hasaplatform = target.CreateUriNode(Properties.Settings.Default.Platform); target.Assert(thisServiceNode, hasaplatform, platform.ToLiteral(target)); } //public arrival if (PublicArrival.HasValue) { IUriNode haspublicArrivalTime = target.CreateUriNode(Properties.Settings.Default.PublicArrival); ILiteralNode pubArrivalTime = target.CreateLiteralNode(PublicArrival.Value.ToString(XmlSpecsHelper.XmlSchemaTimeFormat), UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeTime)); target.Assert(thisServiceNode, haspublicArrivalTime, pubArrivalTime); } //scheduled arrival if (ScheduledArrival.HasValue) { IUriNode hasArrivalTime = target.CreateUriNode(Properties.Settings.Default.ttArrival); ILiteralNode arrivalTime = target.CreateLiteralNode(ScheduledArrival.Value.ToString(XmlSpecsHelper.XmlSchemaTimeFormat), UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeTime)); target.Assert(thisServiceNode, hasArrivalTime, arrivalTime); } //passing time if (PassingTime.HasValue) { IUriNode hasPassingTime = target.CreateUriNode(Properties.Settings.Default.PassingTime); ILiteralNode passingTime = target.CreateLiteralNode(PassingTime.Value.ToString(XmlSpecsHelper.XmlSchemaTimeFormat), UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeTime)); target.Assert(thisServiceNode, hasPassingTime, passingTime); } //Departure Time if (ScheduledDep.HasValue) { IUriNode hasdeptTime = target.CreateUriNode(Properties.Settings.Default.ttDeparture); ILiteralNode deptTime = target.CreateLiteralNode(ScheduledDep.Value.ToString(XmlSpecsHelper.XmlSchemaTimeFormat), UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeTime)); target.Assert(thisServiceNode, hasdeptTime, deptTime); } //Public Depture Time if (PublicDep.HasValue) { IUriNode hasdeptTime = target.CreateUriNode(Properties.Settings.Default.PublicDeparture); ILiteralNode deptTime = target.CreateLiteralNode(PublicDep.Value.ToString(XmlSpecsHelper.XmlSchemaTimeFormat), UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeTime)); target.Assert(thisServiceNode, hasdeptTime, deptTime); } //line if (!string.IsNullOrWhiteSpace(Line)) { IUriNode hasaLine = target.CreateUriNode(Properties.Settings.Default.Line); target.Assert(thisServiceNode, hasaLine, Line.ToLiteral(target)); } //Path if (!string.IsNullOrWhiteSpace(Path)) { IUriNode hasaPath = target.CreateUriNode(Properties.Settings.Default.Path); target.Assert(thisServiceNode, hasaPath, Path.ToLiteral(target)); } //Time table fudge factor if (Performance.HasValue) { IUriNode hasaPerformance = target.CreateUriNode(Properties.Settings.Default.Performance); target.Assert(thisServiceNode, hasaPerformance, Performance.Value.ToLiteral(target)); } //Engineering Allowance if (Engineering.HasValue) { IUriNode hasaEngineeringAllowance = target.CreateUriNode(Properties.Settings.Default.Engineering); target.Assert(thisServiceNode, hasaEngineeringAllowance, Engineering.Value.ToLiteral(target)); } }