コード例 #1
0
 public override void Query(IRdfHandler rdfHandler, ISparqlResultsHandler resultsHandler, String sparqlQuery)
 {
     if (this._processor == null)
     {
         AlexandriaMongoDBDataset dataset = new AlexandriaMongoDBDataset(this);
         this._processor = new LeviathanQueryProcessor(dataset);
     }
     if (this._parser == null)
     {
         this._parser = new SparqlQueryParser();
     }
     this._processor.ProcessQuery(rdfHandler, resultsHandler, this._parser.ParseFromString(sparqlQuery));
 }
コード例 #2
0
 public override object Query(string sparqlQuery)
 {
     if (this._processor == null)
     {
         AlexandriaMongoDBDataset dataset = new AlexandriaMongoDBDataset(this);
         this._processor = new LeviathanQueryProcessor(dataset);
     }
     if (this._parser == null)
     {
         this._parser = new SparqlQueryParser();
     }
     return(this._processor.ProcessQuery(this._parser.ParseFromString(sparqlQuery)));
 }
コード例 #3
0
        public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out object obj)
        {
            switch (targetType.FullName)
            {
            case MongoDBManager:
                String server       = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServer));
                String storeID      = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDatabase));
                String collectionID = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyCatalog));
                String loadMode     = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyLoadMode));

                MongoDBSchemas schema = MongoDBDocumentManager.DefaultSchema;
                if (loadMode != null)
                {
                    switch (loadMode)
                    {
                    case "GraphCentric":
                        schema = MongoDBSchemas.GraphCentric;
                        break;

                    case "TripleCentric":
                        schema = MongoDBSchemas.TripleCentric;
                        break;
                    }
                }

                if (storeID != null)
                {
                    AlexandriaMongoDBManager manager;
                    if (server == null)
                    {
                        if (collectionID == null)
                        {
                            manager = new AlexandriaMongoDBManager(storeID, schema);
                        }
                        else
                        {
                            manager = new AlexandriaMongoDBManager(new MongoDBDocumentManager(new MongoConfiguration(), storeID, collectionID, schema));
                        }
                    }
                    else
                    {
                        //Have a Custom Connection String
                        if (collectionID == null)
                        {
                            manager = new AlexandriaMongoDBManager(new MongoDBDocumentManager(server, storeID, schema));
                        }
                        else
                        {
                            manager = new AlexandriaMongoDBManager(new MongoDBDocumentManager(server, storeID, collectionID, schema));
                        }
                    }

                    obj = manager;
                    return(true);
                }

                //If we get here then the required dnr:database property was missing
                throw new DotNetRdfConfigurationException("Unable to load the MongoDB Manager identified by the Node '" + objNode.ToString() + "' since there was no value given for the required property dnr:database");
                break;

            case MongoDBDataset:
                INode managerNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, "dnr:genericManager"));
                if (managerNode == null)
                {
                    throw new DotNetRdfConfigurationException("Unable to load the MongoDB Dataset identified by the Node '" + objNode.ToString() + "' since there we no value for the required property dnr:genericManager");
                }

                Object temp = ConfigurationLoader.LoadObject(g, managerNode);
                if (temp is AlexandriaMongoDBManager)
                {
                    obj = new AlexandriaMongoDBDataset((AlexandriaMongoDBManager)temp);
                    return(true);
                }
                else
                {
                    throw new DotNetRdfConfigurationException("Unable to load the MongoDB Dataset identified by the Node '" + objNode.ToString() + "' since the value for the dnr:genericManager property pointed to an Object which could not be loaded as an object of type AlexandriaMongoDBManager");
                }

                break;
            }

            obj = null;
            return(false);
        }
コード例 #4
0
        public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out object obj)
        {
            switch (targetType.FullName)
            {
                case MongoDBManager:
                    String server = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyServer));
                    String storeID = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyDatabase));
                    String collectionID = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyCatalog));
                    String loadMode = ConfigurationLoader.GetConfigurationString(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.PropertyLoadMode));

                    MongoDBSchemas schema = MongoDBDocumentManager.DefaultSchema;
                    if (loadMode != null)
                    {
                        switch (loadMode)
                        {
                            case "GraphCentric":
                                schema = MongoDBSchemas.GraphCentric;
                                break;
                            case "TripleCentric":
                                schema = MongoDBSchemas.TripleCentric;
                                break;
                        }
                    }

                    if (storeID != null)
                    {
                        AlexandriaMongoDBManager manager;
                        if (server == null)
                        {
                            if (collectionID == null)
                            {
                                manager = new AlexandriaMongoDBManager(storeID, schema);
                            }
                            else
                            {
                                manager = new AlexandriaMongoDBManager(new MongoDBDocumentManager(new MongoConfiguration(), storeID, collectionID, schema));
                            }
                        }
                        else
                        {
                            //Have a Custom Connection String
                            if (collectionID == null)
                            {
                                manager = new AlexandriaMongoDBManager(new MongoDBDocumentManager(server, storeID, schema));
                            }
                            else
                            {
                                manager = new AlexandriaMongoDBManager(new MongoDBDocumentManager(server, storeID, collectionID, schema));
                            }
                        }

                        obj = manager;
                        return true;
                    }

                    //If we get here then the required dnr:database property was missing
                    throw new DotNetRdfConfigurationException("Unable to load the MongoDB Manager identified by the Node '" + objNode.ToString() + "' since there was no value given for the required property dnr:database");
                    break;

                case MongoDBDataset:
                    INode managerNode = ConfigurationLoader.GetConfigurationNode(g, objNode, ConfigurationLoader.CreateConfigurationNode(g, "dnr:genericManager"));
                    if (managerNode == null)
                    {
                        throw new DotNetRdfConfigurationException("Unable to load the MongoDB Dataset identified by the Node '" + objNode.ToString() + "' since there we no value for the required property dnr:genericManager");
                    }

                    Object temp = ConfigurationLoader.LoadObject(g, managerNode);
                    if (temp is AlexandriaMongoDBManager)
                    {
                        obj = new AlexandriaMongoDBDataset((AlexandriaMongoDBManager)temp);
                        return true;
                    }
                    else
                    {
                        throw new DotNetRdfConfigurationException("Unable to load the MongoDB Dataset identified by the Node '" + objNode.ToString() + "' since the value for the dnr:genericManager property pointed to an Object which could not be loaded as an object of type AlexandriaMongoDBManager");
                    }

                    break;
            }

            obj = null;
            return false;
        }