コード例 #1
0
        /// <summary>
        /// Creates a new store.
        /// </summary>
        /// <param name="storeName">Name of the store to create.</param>
        /// <param name="optimisticLockingEnabled">Optional parameter to override the default optimistic locking setting for the context</param>
        /// <param name="namespaceMappings">Namespace mappings that can be used by CURIE's.</param>
        /// <param name="persistenceType">The type of persistence to use in the newly created store. If not specified, defaults to the value specified in the application configuration file or <see cref="PersistenceType.AppendOnly"/></param>
        /// <param name="updateGraph">OPTIONAL: The URI identifier of the graph to be updated with any new triples created by operations on the store. If
        /// not defined, the default graph in the store will be updated.</param>
        /// <param name="versionTrackingGraph">OPTIONAL: The URI identifier of the graph that contains version number statements for data objects.
        /// If not defined, the <paramref name="updateGraph"/> will be used.</param>
        /// <returns>A new store instance.</returns>
        public IDataObjectStore CreateStore(string storeName,
                                            Dictionary <string, string> namespaceMappings = null,
                                            bool?optimisticLockingEnabled   = null,
                                            PersistenceType?persistenceType = null,
                                            string updateGraph          = null,
                                            string versionTrackingGraph = null)
        {
            if (namespaceMappings == null)
            {
                namespaceMappings = new Dictionary <string, string>();
            }

            namespaceMappings["rdf"]  = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
            namespaceMappings["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#";

            _serverCore.CreateStore(storeName, persistenceType.HasValue ? persistenceType.Value : Configuration.PersistenceType);

            if (String.IsNullOrEmpty(updateGraph))
            {
                updateGraph = Constants.DefaultGraphUri;
            }

            return(new EmbeddedDataObjectStore(_serverCore, storeName, namespaceMappings,
                                               optimisticLockingEnabled.HasValue ? optimisticLockingEnabled.Value : _optimisticLockingEnabled,
                                               updateGraph, new [] { updateGraph }, versionTrackingGraph));
        }
コード例 #2
0
 /// <summary>
 /// Create a new store with a specific persistence type for the main indexes
 /// </summary>
 /// <param name="storeName">The name of the store to create.</param>
 /// <param name="persistenceType">The type of persistence to use for the main store indexes</param>
 /// <exception cref="ArgumentNullException">Raised if <paramref name="storeName"/> is NULL</exception>
 /// <exception cref="ArgumentException">Raised if <paramref name="storeName"/> is an empty string or does not match the allowed regular expression production for store names.</exception>
 /// <remarks>See <see cref="Constants.StoreNameRegex"/> for the regular expression used to validate store names.</remarks>
 public void CreateStore(string storeName, PersistenceType persistenceType)
 {
     try
     {
         if (storeName == null)
         {
             throw new ArgumentNullException("storeName", Strings.BrightstarServiceClient_StoreNameMustNotBeNull);
         }
         if (String.IsNullOrEmpty(storeName))
         {
             throw new ArgumentException(Strings.BrightstarServiceClient_StoreNameMustNotBeEmptyString,
                                         "storeName");
         }
         if (!System.Text.RegularExpressions.Regex.IsMatch(storeName, Constants.StoreNameRegex))
         {
             throw new ArgumentException(Strings.BrightstarServiceClient_InvalidStoreName, "storeName");
         }
         _serverCore.CreateStore(storeName, persistenceType);
     }
     catch (Exception ex)
     {
         Logging.LogError(BrightstarEventId.ServerCoreException, "Error Creating Store {0}", storeName);
         throw new BrightstarClientException("Error creating store " + storeName + ". " + ex.Message, ex);
     }
 }
コード例 #3
0
        /// <summary>
        /// Creates a new store.
        /// </summary>
        /// <param name="storeName">Name of the store to create.</param>
        /// <param name="optimisticLockingEnabled">Optional parameter to override the default optimistic locking setting for the context</param>
        /// <param name="namespaceMappings">Namespace mappings that can be used by CURIE's.</param>
        /// <param name="persistenceType">The type of persistence to use in the newly created store. If not specified, defaults to the value specified in the application configuration file or <see cref="PersistenceType.AppendOnly"/></param>
        /// <returns>A new store instance.</returns>
        public IDataObjectStore CreateStore(string storeName, Dictionary <string, string> namespaceMappings = null, bool?optimisticLockingEnabled = null, PersistenceType?persistenceType = null)
        {
            if (namespaceMappings == null)
            {
                namespaceMappings = new Dictionary <string, string>();
            }

            namespaceMappings["rdf"]  = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
            namespaceMappings["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#";

            _serverCore.CreateStore(storeName, persistenceType.HasValue ? persistenceType.Value : Configuration.PersistenceType);
            return(new EmbeddedDataObjectStore(_serverCore, storeName, namespaceMappings,
                                               optimisticLockingEnabled.HasValue ? optimisticLockingEnabled.Value : _optimisticLockingEnabled));
        }
コード例 #4
0
ファイル: NodeCore.cs プロジェクト: zhuliangbing/BrightstarDB
 public bool CreateStore(string storeName)
 {
     try
     {
         _serverCore.CreateStore(storeName, PersistenceType.AppendOnly);
         _stores.Add(storeName);
         _storeInfo.Add(storeName, new StoreTransactionInfo(new HashSet <Guid> {
             Guid.Empty
         }, Guid.Empty));
         return(true);
     }
     catch (Exception ex)
     {
         // TODO: Log failure
         return(false);
     }
 }