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

Classes

class  RoutinesTableContainer
 

Public Member Functions

 RoutineManager (ITransaction transaction)
 
void Dispose ()
 
void Create ()
 Initializes the manager into the underlying system. More...
 
void CreateRoutine (RoutineInfo routineInfo)
 
bool RoutineExists (ObjectName objName)
 
IRoutine GetRoutine (ObjectName routineName)
 
bool AlterRoutine (RoutineInfo routineInfo)
 
bool DropRoutine (ObjectName objName)
 
ObjectName ResolveName (ObjectName objName, bool ignoreCase)
 Normalizes the input object name using the case sensitivity specified. More...
 
IRoutine ResolveRoutine (Invoke request, IQuery context)
 Resolves a routine that matches the given invocation within the context provided. More...
 

Properties

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

ITable FindEntry (Table table, ObjectName routineName)
 
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...
 

Private Attributes

const string ProcedureType = "procedure"
 
const string ExternalProcedureType = "ext_procedure"
 
const string FunctionType = "function"
 
const string ExtrernalFunctionType = "ext_function"
 
ITransaction transaction
 

Detailed Description

Definition at line 29 of file RoutineManager.cs.

Constructor & Destructor Documentation

Deveel.Data.Routines.RoutineManager.RoutineManager ( ITransaction  transaction)
inline

Definition at line 37 of file RoutineManager.cs.

37  {
38  if (transaction == null)
39  throw new ArgumentNullException("transaction");
40 
41  this.transaction = transaction;
42  }

Member Function Documentation

bool IObjectManager. Deveel.Data.Routines.RoutineManager.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 141 of file RoutineManager.cs.

141  {
142  var routineInfo = objInfo as RoutineInfo;
143  if (routineInfo == null)
144  throw new ArgumentException();
145 
146  return AlterRoutine(routineInfo);
147  }
bool AlterRoutine(RoutineInfo routineInfo)
bool Deveel.Data.Routines.RoutineManager.AlterRoutine ( RoutineInfo  routineInfo)
inline

Definition at line 153 of file RoutineManager.cs.

153  {
154  // TODO: implement
155  return false;
156  }
void Deveel.Data.Routines.RoutineManager.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 74 of file RoutineManager.cs.

74  {
75  // SYSTEM.ROUTINE
76  var tableInfo = new TableInfo(SystemSchema.RoutineTableName);
77  tableInfo.AddColumn("schema", PrimitiveTypes.String());
78  tableInfo.AddColumn("name", PrimitiveTypes.String());
79  tableInfo.AddColumn("type", PrimitiveTypes.String());
80  tableInfo.AddColumn("location", PrimitiveTypes.String());
81  tableInfo.AddColumn("return_type", PrimitiveTypes.String());
82  tableInfo.AddColumn("username", PrimitiveTypes.String());
83  transaction.CreateTable(tableInfo);
84 
85  // SYSTEM.ROUTINE_PARAM
87  tableInfo.AddColumn("schema", PrimitiveTypes.String());
88  tableInfo.AddColumn("name", PrimitiveTypes.String());
89  tableInfo.AddColumn("arg_name", PrimitiveTypes.String());
90  tableInfo.AddColumn("arg_type", PrimitiveTypes.String());
91  tableInfo.AddColumn("in_out", PrimitiveTypes.String());
92  tableInfo.AddColumn("offset", PrimitiveTypes.Integer());
93  transaction.CreateTable(tableInfo);
94 
95  var fkCol = new[] {"routine_schema", "routine_name"};
96  var refCol = new[] {"schema", "name"};
97  const ForeignKeyAction onUpdate = ForeignKeyAction.NoAction;
98  const ForeignKeyAction onDelete = ForeignKeyAction.Cascade;
99 
101  onDelete, onUpdate, "ROUTINE_PARAMS_FK");
102  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
ForeignKeyAction
Enumerates the foreign key referential trigger actions.
static readonly ObjectName RoutineTableName
Provides utilities and properties for handling the SYSTEN schema of a database.
Definition: SystemSchema.cs:37
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41
static readonly ObjectName RoutineParameterTableName
void IObjectManager. Deveel.Data.Routines.RoutineManager.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 104 of file RoutineManager.cs.

104  {
105  if (objInfo == null)
106  throw new ArgumentNullException("objInfo");
107 
108  var routineInfo = objInfo as RoutineInfo;
109  if (routineInfo == null)
110  throw new ArgumentException();
111 
112  CreateRoutine(routineInfo);
113  }
void CreateRoutine(RoutineInfo routineInfo)
void Deveel.Data.Routines.RoutineManager.CreateRoutine ( RoutineInfo  routineInfo)
inline

Definition at line 115 of file RoutineManager.cs.

115  {
116  throw new NotImplementedException();
117  }
void Deveel.Data.Routines.RoutineManager.Dispose ( )
inline

Definition at line 66 of file RoutineManager.cs.

66  {
67  transaction = null;
68  }
bool IObjectManager. Deveel.Data.Routines.RoutineManager.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 149 of file RoutineManager.cs.

149  {
150  return DropRoutine(objName);
151  }
bool DropRoutine(ObjectName objName)
bool Deveel.Data.Routines.RoutineManager.DropRoutine ( ObjectName  objName)
inline

Definition at line 158 of file RoutineManager.cs.

158  {
159  // TODO: implement
160  return false;
161  }
ITable Deveel.Data.Routines.RoutineManager.FindEntry ( Table  table,
ObjectName  routineName 
)
inlineprivate

Definition at line 44 of file RoutineManager.cs.

44  {
45  var schemav = table.GetResolvedColumnName(0);
46  var namev = table.GetResolvedColumnName(1);
47 
48  using (var session = new SystemSession(transaction)) {
49  using (var context = session.CreateQuery()) {
50  var t = table.SimpleSelect(context, namev, SqlExpressionType.Equal,
52  t = t.ExhaustiveSelect(context,
55 
56  // This should be at most 1 row in size
57  if (t.RowCount > 1)
58  throw new Exception("Assert failed: multiple procedure names for " + routineName);
59 
60  // Return the entries found.
61  return t;
62  }
63  }
64  }
static SqlBinaryExpression Equal(SqlExpression left, SqlExpression right)
static DataObject String(string s)
Definition: DataObject.cs:592
SqlExpressionType
All the possible type of SqlExpression supported
virtual ObjectName GetResolvedColumnName(int column)
Definition: Table.cs:101
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
string Name
Gets the name of the object being referenced.
Definition: ObjectName.cs:108
static SqlReferenceExpression Reference(ObjectName objectName)
Defines the base class for instances that represent SQL expression tree nodes.
static SqlConstantExpression Constant(object value)
IDbObject IObjectManager. Deveel.Data.Routines.RoutineManager.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 132 of file RoutineManager.cs.

132  {
133  return GetRoutine(objName);
134  }
IRoutine GetRoutine(ObjectName routineName)
IRoutine Deveel.Data.Routines.RoutineManager.GetRoutine ( ObjectName  routineName)
inline

Definition at line 136 of file RoutineManager.cs.

136  {
137  // TODO: implement!
138  return null;
139  }
bool IObjectManager. Deveel.Data.Routines.RoutineManager.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 123 of file RoutineManager.cs.

123  {
124  return RoutineExists(objName);
125  }
bool RoutineExists(ObjectName objName)
bool IObjectManager. Deveel.Data.Routines.RoutineManager.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 119 of file RoutineManager.cs.

119  {
120  return RoutineExists(objName);
121  }
bool RoutineExists(ObjectName objName)
ObjectName Deveel.Data.Routines.RoutineManager.ResolveName ( ObjectName  objName,
bool  ignoreCase 
)
inline

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 163 of file RoutineManager.cs.

163  {
164  throw new NotImplementedException();
165  }
IRoutine Deveel.Data.Routines.RoutineManager.ResolveRoutine ( Invoke  request,
IQuery  query 
)
inline

Resolves a routine that matches the given invocation within the context provided.

Parameters
requestThe routine invocation request used to resolve the routine.
queryThe parent query context.
Returns
Returns an instance of IRoutine that matches the given request, or null if no routine was found in the underlying context.

Implements Deveel.Data.Routines.IRoutineResolver.

Definition at line 167 of file RoutineManager.cs.

167  {
168  // TODO: implement
169  return null;
170  }
bool Deveel.Data.Routines.RoutineManager.RoutineExists ( ObjectName  objName)
inline

Definition at line 127 of file RoutineManager.cs.

127  {
128  // TODO: implement
129  return false;
130  }

Member Data Documentation

const string Deveel.Data.Routines.RoutineManager.ExternalProcedureType = "ext_procedure"
private

Definition at line 31 of file RoutineManager.cs.

const string Deveel.Data.Routines.RoutineManager.ExtrernalFunctionType = "ext_function"
private

Definition at line 33 of file RoutineManager.cs.

const string Deveel.Data.Routines.RoutineManager.FunctionType = "function"
private

Definition at line 32 of file RoutineManager.cs.

const string Deveel.Data.Routines.RoutineManager.ProcedureType = "procedure"
private

Definition at line 30 of file RoutineManager.cs.

ITransaction Deveel.Data.Routines.RoutineManager.transaction
private

Definition at line 35 of file RoutineManager.cs.

Property Documentation

DbObjectType IObjectManager. Deveel.Data.Routines.RoutineManager.ObjectType
getprivate

Definition at line 70 of file RoutineManager.cs.


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