예제 #1
0
            public void Compose(IServiceRegistry serviceRegistry)
            {
                serviceRegistry.RegisterInstance<IRdfTypeCache>(_typeCache);
                serviceRegistry.RegisterInstance(_baseUriSelectionPolicy.Object);

                var repository = new TestMappingsRepository(new TestPersonMap(), new TestTypedEntityMap());
                serviceRegistry.RegisterInstance<IMappingsRepository>(repository);

                serviceRegistry.Register<INamedGraphSelector, TestGraphSelector>();

                var store = new TripleStore();
                store.LoadTestFile("SuperTripleOperations.trig");
                serviceRegistry.RegisterInstance<ITripleStore>(store);
                serviceRegistry.Register<IEntitySource, TripleStoreAdapter>();
            }
예제 #2
0
        public void Setup()
        {
            _store = new TripleStore();
            _store.LoadTestFile("TriplesWithLiteralSubjects.trig");

            var container = new ServiceContainer();

            container.RegisterInstance <ITripleStore>(_store);

            IEntityContextFactory factory = new EntityContextFactory(container)
                                            .WithDefaultOntologies()
                                            .WithEntitySource <TripleStoreAdapter>()
                                            .WithMetaGraphUri(new Uri("http://app.magi/graphs"))
                                            .WithDependenciesInternal <Dependencies>();

            _typeCache = (TestCache)container.GetInstance <IRdfTypeCache>();

            _entityContext = factory.CreateContext();
        }
예제 #3
0
        private void LoadEntities(string fileName)
        {
            var store = new TripleStore();

            store.LoadTestFile(fileName);

            Console.WriteLine("Loading data with {0} triples in {1} graphs", store.Triples.Count(), store.Graphs.Count);

            var data = from metaTriple in store[MetaGraphNode.Uri].GetTriplesWithPredicate(Foaf.primaryTopic)
                       let entityGraph = store[((IUriNode)metaTriple.Subject).Uri]
                                         from entityTriple in entityGraph.Triples
                                         let entityId = new EntityId(((IUriNode)metaTriple.Object).Uri)
                                                        let entityQuad = entityTriple.ToEntityQuad(entityId)
                                                                         group entityQuad by entityId into g
                                                                         select g;

            foreach (var entityQuads in data)
            {
                _entityStore.AssertEntity(entityQuads.Key, entityQuads);
            }
        }