Ejemplo n.º 1
0
        public void ProcessHeader(StreamReader inStream, ref IGraph stationNameGraph, IUriNode generationActivity, string fileName)
        {
            string firstLine = inStream.ReadLine();

            if (!firstLine.StartsWith("A"))
            {
                throw new ImportFileFormatException(fileName,
                                                    "First character of first line must be A",
                                                    0,
                                                    0
                                                    );
            }
            if (firstLine.Substring(30, 18).TrimEnd() != Properties.Settings.Default.FileSpecString)
            {
                throw new ImportFileFormatException(fileName,
                                                    "Unexpected File version, may not read as expected",
                                                    0,
                                                    30
                                                    );
            }
            string      createTimeStr  = firstLine.Substring(48, 17).Trim();
            CultureInfo provider       = ProgramState.Provider;
            string      formatString   = @"dd/MM/yy HH.mm.ss";
            DateTime    createdTime    = DateTime.ParseExact(createTimeStr, formatString, provider);
            string      sourceFileUri  = Common.ImportFileUriBaseString + "#" + DateTime.Now.ToString("o") + "SourceFile_" + fileName;
            IUriNode    sourceFileNode = stationNameGraph.CreateUriNode(UriFactory.Create(sourceFileUri));

            if (generationActivity != null)
            {
                stationNameGraph.Assert(generationActivity, stationNameGraph.CreateUriNode(Properties.Settings.Default.provUsed), sourceFileNode);
            }
            stationNameGraph.Assert(sourceFileNode, UriNodeExt.RdfType(stationNameGraph), stationNameGraph.CreateUriNode("prov:Entity"));
            stationNameGraph.Assert(sourceFileNode, stationNameGraph.CreateUriNode(UriFactory.Create(Properties.Settings.Default.provGeneratedTime)),
                                    stationNameGraph.CreateLiteralNode(createdTime.ToString(XmlSpecsHelper.XmlSchemaDateTimeFormat), UriFactory.Create(XmlSpecsHelper.XmlSchemaDataTypeDateTime)));
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
        }