Exemplo n.º 1
0
        ///Editor. Binds the target graph (null to delete current bound).
        internal void SetBoundGraphReference(Graph target)
        {
            if (UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode)
            {
                Debug.LogError("SetBoundGraphReference method is an Editor only method!");
                return;
            }

            //cleanup
            graph = null;
            boundGraphInstance = null;
            if (target == null)
            {
                boundGraphSource           = null;
                boundGraphSerialization    = null;
                boundGraphObjectReferences = null;
                return;
            }

            //serialize target and store boundGraphSerialization data
            target.SelfSerialize();
            _boundGraphSerialization    = target.GetSerializedJsonData();
            _boundGraphObjectReferences = target.GetSerializedReferencesData();
            _boundGraphSource           = target.GetGraphSourceMetaDataCopy();
            Validate(); //validate to handle bound graph instance
        }
Exemplo n.º 2
0
        public void InteropSemWebGraphQuery()
        {
            Graph g = new Graph();

            FileLoader.Load(g, "InferenceTest.ttl");
            GraphSource source = new GraphSource(g);

            Console.WriteLine("Query for Cars and their Speeds");
            Console.WriteLine();
            SemWeb.Query.SparqlXmlQuerySink sink = new SemWeb.Query.SparqlXmlQuerySink(Console.Out);
            Variable car = new Variable("car");

            Statement[] graphPattern = new Statement[]
            {
                new Statement(car, new Entity(RdfSpecsHelper.RdfType), new Entity("http://example.org/vehicles/Car")),
                new Statement(car, new Entity("http://example.org/vehicles/Speed"), new Variable("speed"))
            };

            source.Query(graphPattern, new SemWeb.Query.QueryOptions(), sink);

            Console.WriteLine("Query for the 1st Car and it's Speed");
            Console.WriteLine();
            sink         = new SemWeb.Query.SparqlXmlQuerySink(Console.Out);
            graphPattern = new Statement[]
            {
                new Statement(car, new Entity(RdfSpecsHelper.RdfType), new Entity("http://example.org/vehicles/Car")),
                new Statement(car, new Entity("http://example.org/vehicles/Speed"), new Variable("speed"))
            };
            SemWeb.Query.QueryOptions options = new SemWeb.Query.QueryOptions();
            options.Limit = 1;
            source.Query(graphPattern, options, sink);
        }
Exemplo n.º 3
0
		public MainViewModel()
		{
		   this.LoadToolBoxGalleries();
		   this.AddToGalleryCommand = new DelegateCommand((param) => 
		   {
			   this.CreateToolBoxItemFromGeometry(param);
		   });
		   this.GraphSource = new GraphSource();
		}
        public static void Convert(GraphSource source)
        {
            if (source == GraphSource.Embed)
            {
                ConvertToEmbed();
            }

            if (source == GraphSource.Macro)
            {
                ConvertToMacro();
            }
        }
Exemplo n.º 5
0
        public void ClassQuery()
        {
            var graphSource   = new GraphSource("http://localhost:7200/repositories/Pets");
            var graphProvider = new GraphProvider <SparqlBgpEvaluator>(graphSource);

            var classGraph = (new LabelledTreeNode <object, Term>(new Variable())).AddChild(new Rdfs("subClassOf"), new Variable());
            var query      = new QueryableGraph(graphProvider, new GraphExpression(classGraph));

            int count = 0;

            foreach (var item in query)
            {
                count++;
            }
            Assert.Equal(291, count);
        }
Exemplo n.º 6
0
        public void InteropSemWebGraphSource()
        {
            Graph g = new Graph();
            //FileLoader.Load(g, "InferenceTest.ttl");
            GraphSource source = new GraphSource(g);

            Console.WriteLine("Reading the input using SemWeb");
            N3Reader reader = new N3Reader("InferenceTest.ttl");

            reader.Select(source);
            Console.WriteLine();

            Console.WriteLine("Outputting all Triples using N3Writer");
            N3Writer writer = new N3Writer(Console.Out);

            source.Select(writer);
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Outputting all Triples of the form ?s rdf:type ?type");
            Statement template = new Statement(new Variable(), new Entity(RdfSpecsHelper.RdfType), new Variable());

            source.Select(template, writer);
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Outputting all Triples of the form ?s rdf:type ?car");
            template = new Statement(new Variable(), new Entity(RdfSpecsHelper.RdfType), new Entity("http://example.org/vehicles/Car"));
            source.Select(template, writer);
            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Outputting all Triples for Cars and Planes");
            SelectFilter filter = new SelectFilter();

            filter.Predicates = new Entity[] { new Entity(RdfSpecsHelper.RdfType) };
            filter.Objects    = new Entity[] { new Entity("http://example.org/vehicles/Car"), new Entity("http://example.org/vehicles/Plane") };
            source.Select(filter, writer);
            Console.WriteLine();
            Console.WriteLine();

            writer.Close();
        }
Exemplo n.º 7
0
        public void LeftJoinTest()
        {
            var graphSource   = new GraphSource("http://localhost:7200/repositories/Pets");
            var graphProvider = new GraphProvider <SparqlBgpEvaluator>(graphSource);

            var propertyGraph = (new LabelledTreeNode <object, Term>(new Variable()))
                                .AddChild(new Rdf("type"), new Rdf("Property"));
            var propertyQuery = new QueryableGraph(graphProvider, new GraphExpression(propertyGraph));

            var classGraph = (new LabelledTreeNode <object, Term>(new Variable()))
                             .AddChild(new Rdfs("subClassOf"), new Variable());
            var classQuery = new QueryableGraph(graphProvider, new GraphExpression(classGraph));

            var query = propertyQuery.Expand(new Rdfs("range"), classQuery);

            int count = 0;

            foreach (var item in query)
            {
                count++;
                Debug.WriteLine(item);
            }
            Assert.Equal(79, count);
        }
Exemplo n.º 8
0
 public MainViewModel()
 {
     this.DiagramSource = new GraphSource();
     this.DiagramSource.PopulateGraphSource();
 }