DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Properties | Private Member Functions | List of all members
Deveel.Data.Sql.Schemas.SchemaManager Class Reference
Inheritance diagram for Deveel.Data.Sql.Schemas.SchemaManager:
Deveel.Data.Sql.IObjectManager

Public Member Functions

 SchemaManager (ITransaction transaction)
 
void Dispose ()
 
void Create ()
 Initializes the manager into the underlying system. More...
 
ObjectName ResolveSchemaName (string name, bool ignoreCase)
 
void CreateSchema (SchemaInfo schemaInfo)
 
bool SchemaExists (string name)
 
bool DropSchema (string name)
 
Schema GetSchema (string name)
 

Properties

ITransaction Transaction [get, private set]
 
DbObjectType IObjectManager. ObjectType [get]
 
- Properties inherited from Deveel.Data.Sql.IObjectManager
DbObjectType ObjectType [get]
 Gets the type of objects managed by this instance. More...
 

Private Member Functions

 ~SchemaManager ()
 
void Dispose (bool disposing)
 
void IObjectManager. CreateObject (IObjectInfo objInfo)
 Create a new object of the ObjectType given the specifications given. More...
 
bool IObjectManager. RealObjectExists (ObjectName objName)
 Checks if an object really exists in the system. More...
 
bool IObjectManager. ObjectExists (ObjectName objName)
 Checks if an object identified by the given name is managed by this instance. More...
 
IDbObject IObjectManager. GetObject (ObjectName objName)
 Gets a database object managed by this manager. More...
 
bool IObjectManager. AlterObject (IObjectInfo objInfo)
 Modifies an existing object managed, identified by IObjectInfo.FullName component of the given specification, with the format given. More...
 
bool IObjectManager. DropObject (ObjectName objName)
 Deletes a database object handled by this manager from the system. More...
 
ObjectName IObjectManager. ResolveName (ObjectName objName, bool ignoreCase)
 Normalizes the input object name using the case sensitivity specified. More...
 

Detailed Description

Definition at line 24 of file SchemaManager.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Schemas.SchemaManager.SchemaManager ( ITransaction  transaction)
inline

Definition at line 25 of file SchemaManager.cs.

25  {
26  if (transaction == null)
27  throw new ArgumentNullException("transaction");
28 
29  Transaction = transaction;
30  }
The system implementation of a transaction model that handles isolated operations within a database c...
Definition: Transaction.cs:35
Deveel.Data.Sql.Schemas.SchemaManager.~SchemaManager ( )
inlineprivate

Definition at line 32 of file SchemaManager.cs.

32  {
33  Dispose(false);
34  }

Member Function Documentation

bool IObjectManager. Deveel.Data.Sql.Schemas.SchemaManager.AlterObject ( IObjectInfo  objInfo)
inlineprivate

Modifies an existing object managed, identified by IObjectInfo.FullName component of the given specification, with the format given.

Parameters
objInfoThe object specification used to alter an existing object.
Returns
Returns true an object was identified and successfully altered, or false if none database object was found for the unique name given.
Exceptions
ArgumentNullExceptionIf the given objInfo object is null.
ArgumentExceptionIf the type of the object specified (IObjectInfo.ObjectType) is different than the type of objects handled by this manager.

Implements Deveel.Data.Sql.IObjectManager.

Definition at line 87 of file SchemaManager.cs.

87  {
88  throw new NotImplementedException();
89  }
void Deveel.Data.Sql.Schemas.SchemaManager.Create ( )
inline

Initializes the manager into the underlying system.

Typically this method generates the tables required to manage the features relative to the objects.

Implements Deveel.Data.Sql.IObjectManager.

Definition at line 55 of file SchemaManager.cs.

55  {
56  // SYSTEM.SCHEMA_INFO
57  var tableInfo = new TableInfo(SystemSchema.SchemaInfoTableName);
58  tableInfo.AddColumn("id", PrimitiveTypes.Numeric());
59  tableInfo.AddColumn("name", PrimitiveTypes.String());
60  tableInfo.AddColumn("type", PrimitiveTypes.String());
61  tableInfo.AddColumn("culture", PrimitiveTypes.String());
62  tableInfo.AddColumn("other", PrimitiveTypes.String());
63  tableInfo = tableInfo.AsReadOnly();
64  Transaction.CreateTable(tableInfo);
65  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
The system implementation of a transaction model that handles isolated operations within a database c...
Definition: Transaction.cs:35
static NumericType Numeric()
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41
void IObjectManager. Deveel.Data.Sql.Schemas.SchemaManager.CreateObject ( IObjectInfo  objInfo)
inlineprivate

Create a new object of the ObjectType given the specifications given.

Parameters
objInfoThe object specifications used to create a new object.
Exceptions
ArgumentNullExceptionIf the given objInfo is null.
ArgumentExceptionIf the object type of the specification (IObjectInfo.ObjectType) is different than the ObjectType of this manager.

Implements Deveel.Data.Sql.IObjectManager.

Definition at line 67 of file SchemaManager.cs.

67  {
68  var schemaInfo = objInfo as SchemaInfo;
69  if (schemaInfo == null)
70  throw new ArgumentException();
71 
72  CreateSchema(schemaInfo);
73  }
void CreateSchema(SchemaInfo schemaInfo)
void Deveel.Data.Sql.Schemas.SchemaManager.CreateSchema ( SchemaInfo  schemaInfo)
inline

Definition at line 119 of file SchemaManager.cs.

119  {
120  if (schemaInfo == null)
121  throw new ArgumentNullException("schemaInfo");
122 
123  var tableName = SystemSchema.SchemaInfoTableName;
124  var t = Transaction.GetMutableTable(tableName);
125 
126  var nameObj = DataObject.String(schemaInfo.Name);
127 
128  if (t.Exists(1, nameObj))
129  throw new DatabaseSystemException(String.Format("Schema '{0}' already defined in the database.", schemaInfo.Name));
130 
131  var row = t.NewRow();
132  var uniqueId = Transaction.NextTableId(tableName);
133  row.SetValue(0, DataObject.Number(uniqueId));
134  row.SetValue(1, DataObject.String(schemaInfo.Name));
135  row.SetValue(2, DataObject.String(schemaInfo.Type));
136  row.SetValue(3, DataObject.String(schemaInfo.Culture));
137 
138  t.AddRow(row);
139  }
A long string in the system.
The system implementation of a transaction model that handles isolated operations within a database c...
Definition: Transaction.cs:35
void Deveel.Data.Sql.Schemas.SchemaManager.Dispose ( bool  disposing)
inlineprivate

Definition at line 38 of file SchemaManager.cs.

38  {
39  if (disposing) {
40  // TODO: Additional disposals ...
41  }
42 
43  Transaction = null;
44  }
The system implementation of a transaction model that handles isolated operations within a database c...
Definition: Transaction.cs:35
void Deveel.Data.Sql.Schemas.SchemaManager.Dispose ( )
inline

Definition at line 46 of file SchemaManager.cs.

46  {
47  Dispose(true);
48  GC.SuppressFinalize(this);
49  }
bool IObjectManager. Deveel.Data.Sql.Schemas.SchemaManager.DropObject ( ObjectName  objName)
inlineprivate

Deletes a database object handled by this manager from the system.

Parameters
objNameThe unique name of the object to be deleted.
Returns
Returns true if a database object was found with the given unique name and successfully deleted from the system, or false if none object was found.

Implements Deveel.Data.Sql.IObjectManager.

Definition at line 91 of file SchemaManager.cs.

91  {
92  return DropSchema(objName.Name);
93  }
bool Deveel.Data.Sql.Schemas.SchemaManager.DropSchema ( string  name)
inline

Definition at line 150 of file SchemaManager.cs.

150  {
151  var tableName = SystemSchema.SchemaInfoTableName;
152  var t = Transaction.GetMutableTable(tableName);
153 
154  // Drop a single entry from dt where column 1 = name
155  var nameObj = DataObject.String(name);
156  return t.Delete(1, nameObj);
157  }
The system implementation of a transaction model that handles isolated operations within a database c...
Definition: Transaction.cs:35
IDbObject IObjectManager. Deveel.Data.Sql.Schemas.SchemaManager.GetObject ( ObjectName  objName)
inlineprivate

Gets a database object managed by this manager.

Parameters
objNameThe name that uniquely identifies the object to get.
Returns
Returns a IDbObject instance that is identified by the given unique name, or null if this manager was not able to map any object to the name specified.

Implements Deveel.Data.Sql.IObjectManager.

Definition at line 83 of file SchemaManager.cs.

83  {
84  return GetSchema(objName.Name);
85  }
Schema Deveel.Data.Sql.Schemas.SchemaManager.GetSchema ( string  name)
inline

Definition at line 159 of file SchemaManager.cs.

159  {
160  if (String.IsNullOrEmpty(name))
161  throw new ArgumentNullException("name");
162 
163  throw new NotImplementedException();
164  }
A long string in the system.
bool IObjectManager. Deveel.Data.Sql.Schemas.SchemaManager.ObjectExists ( ObjectName  objName)
inlineprivate

Checks if an object identified by the given name is managed by this instance.

Parameters
objNameThe name that uniquely identifies the object.
Returns

Implements Deveel.Data.Sql.IObjectManager.

Definition at line 79 of file SchemaManager.cs.

79  {
80  return SchemaExists(objName.Name);
81  }
bool IObjectManager. Deveel.Data.Sql.Schemas.SchemaManager.RealObjectExists ( ObjectName  objName)
inlineprivate

Checks if an object really exists in the system.

Parameters
objNameThe unique name of the object to check.
Returns
Returns true if an object with the given name concretely exists in the system, or false otherwise.

Implements Deveel.Data.Sql.IObjectManager.

Definition at line 75 of file SchemaManager.cs.

75  {
76  return SchemaExists(objName.Name);
77  }
ObjectName IObjectManager. Deveel.Data.Sql.Schemas.SchemaManager.ResolveName ( ObjectName  objName,
bool  ignoreCase 
)
inlineprivate

Normalizes the input object name using the case sensitivity specified.

Parameters
objNameThe input object name, that can be partial or complete, to be normalized to the real name of an object.
ignoreCaseThe case sensitivity specification used to compare the input name with the names of the existing objects handled by this manager.
Returns
Returns the fully normalized ObjectName that is the real name of an object matching the input name, or null if the input name was not possible to be resolved.

Implements Deveel.Data.Sql.IObjectManager.

Definition at line 95 of file SchemaManager.cs.

95  {
96  return ResolveSchemaName(objName.Name, ignoreCase);
97  }
ObjectName ResolveSchemaName(string name, bool ignoreCase)
ObjectName Deveel.Data.Sql.Schemas.SchemaManager.ResolveSchemaName ( string  name,
bool  ignoreCase 
)
inline

Definition at line 99 of file SchemaManager.cs.

99  {
100  var table = Transaction.GetTable(SystemSchema.SchemaInfoTableName);
101 
102  var comparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
103 
104  foreach (var row in table) {
105  var objSchemaName = row.GetValue(1);
106  if (!(objSchemaName.Type is StringType))
107  throw new InvalidOperationException("Invalid column type for SCHEMA name table.");
108  if (objSchemaName.IsNull)
109  throw new InvalidOperationException();
110 
111  var schemaName = objSchemaName.Value.ToString();
112  if (String.Equals(schemaName, name, comparison))
113  return new ObjectName(schemaName);
114  }
115 
116  return null;
117  }
A long string in the system.
The system implementation of a transaction model that handles isolated operations within a database c...
Definition: Transaction.cs:35
bool Deveel.Data.Sql.Schemas.SchemaManager.SchemaExists ( string  name)
inline

Definition at line 141 of file SchemaManager.cs.

141  {
142  var tableName = SystemSchema.SchemaInfoTableName;
143  var t = Transaction.GetMutableTable(tableName);
144 
145  var nameObj = DataObject.String(name);
146 
147  return t.Exists(1, nameObj);
148  }
The system implementation of a transaction model that handles isolated operations within a database c...
Definition: Transaction.cs:35

Property Documentation

DbObjectType IObjectManager. Deveel.Data.Sql.Schemas.SchemaManager.ObjectType
getprivate

Definition at line 51 of file SchemaManager.cs.

ITransaction Deveel.Data.Sql.Schemas.SchemaManager.Transaction
getprivate set

Definition at line 36 of file SchemaManager.cs.


The documentation for this class was generated from the following file: