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.Triggers.Trigger Class Reference

Represents an event fired at a given modification event (either INSERT, DELETE or UPDATE) at a given time (BEFORE or AFTER). More...

Inheritance diagram for Deveel.Data.Sql.Triggers.Trigger:
Deveel.Data.Sql.IDbObject

Public Member Functions

 Trigger (TriggerInfo triggerInfo)
 Constructs a trigger with the given information. More...
 
bool CanInvoke (TableEvent context)
 
void Invoke (IQuery context, TableEvent tableEvent)
 

Properties

TriggerInfo TriggerInfo [get, private set]
 Gets the information describing the dynamics of this trigger. More...
 
ObjectName TriggerName [get]
 Gets the fully qualified name of the trigger, as defined in TriggerInfo More...
 
TriggerType TriggerType [get]
 Gets the type of the trigger, as defined in TriggerInfo More...
 
DbObjectType IDbObject. ObjectType [get]
 
ObjectName IDbObject. FullName [get]
 
- Properties inherited from Deveel.Data.Sql.IDbObject
ObjectName FullName [get]
 Gets the fully qualified name of the object used to resolve it uniquely within the database. More...
 
DbObjectType ObjectType [get]
 Gets the type of database object that the implementation is for More...
 

Private Member Functions

void FireTrigger (IQuery context, TableEvent tableEvent)
 
void ExecuteProcedure (IQuery context)
 
void NotifyTriggerEvent (IQuery context, TableEvent tableEvent)
 

Detailed Description

Represents an event fired at a given modification event (either INSERT, DELETE or UPDATE) at a given time (BEFORE or AFTER).

Event triggers can be of two different main categories:

Definition at line 38 of file Trigger.cs.

Constructor & Destructor Documentation

Deveel.Data.Sql.Triggers.Trigger.Trigger ( TriggerInfo  triggerInfo)
inline

Constructs a trigger with the given information.

Parameters
triggerInfoThe object defining the information of this trigger.
Exceptions
ArgumentNullExceptionIf the provided triggerInfo is null.

Definition at line 47 of file Trigger.cs.

47  {
48  if (triggerInfo == null)
49  throw new ArgumentNullException("triggerInfo");
50 
51  TriggerInfo = triggerInfo;
52  }
TriggerInfo TriggerInfo
Gets the information describing the dynamics of this trigger.
Definition: Trigger.cs:57

Member Function Documentation

bool Deveel.Data.Sql.Triggers.Trigger.CanInvoke ( TableEvent  context)
inline

Definition at line 106 of file Trigger.cs.

106  {
107  if ((TriggerInfo.EventType & context.EventType) == 0)
108  return false;
109 
110  var tableName = context.Table.TableInfo.TableName;
111  return TriggerInfo.TableName == null ||
112  TriggerInfo.TableName.Equals(tableName, true);
113  }
override bool Equals(object obj)
Definition: ObjectName.cs:241
TriggerEventType EventType
Gets the modification event on the attached table at which to fire the trigger.
Definition: TriggerInfo.cs:84
TriggerInfo TriggerInfo
Gets the information describing the dynamics of this trigger.
Definition: Trigger.cs:57
ObjectName TableName
Gets the fully qualified name of the database table on which to attach the trigger.
Definition: TriggerInfo.cs:96
void Deveel.Data.Sql.Triggers.Trigger.ExecuteProcedure ( IQuery  context)
inlineprivate

Definition at line 93 of file Trigger.cs.

93  {
94  throw new NotImplementedException();
95  }
void Deveel.Data.Sql.Triggers.Trigger.FireTrigger ( IQuery  context,
TableEvent  tableEvent 
)
inlineprivate

Definition at line 85 of file Trigger.cs.

85  {
86  if (TriggerType == TriggerType.Callback) {
87  NotifyTriggerEvent(context, tableEvent);
88  } else {
89  ExecuteProcedure(context);
90  }
91  }
void NotifyTriggerEvent(IQuery context, TableEvent tableEvent)
Definition: Trigger.cs:97
TriggerType TriggerType
Gets the type of the trigger, as defined in TriggerInfo
Definition: Trigger.cs:73
void ExecuteProcedure(IQuery context)
Definition: Trigger.cs:93
void Deveel.Data.Sql.Triggers.Trigger.Invoke ( IQuery  context,
TableEvent  tableEvent 
)
inline

Definition at line 115 of file Trigger.cs.

115  {
116  var isBefore = (tableEvent.EventType & TriggerEventType.Before) != 0;
117 
118  var transaction = context.Session.Transaction;
119  if (transaction is ITableStateHandler) {
120  var stateHandler = (ITableStateHandler) transaction;
121  var oldState = stateHandler.TableState;
122  var newState = new OldNewTableState(tableEvent.Table.FullName, tableEvent.OldRowId.RowNumber, tableEvent.NewRow,
123  isBefore);
124 
125  stateHandler.SetTableState(newState);
126 
127  try {
128  FireTrigger(context, tableEvent);
129  } finally {
130  stateHandler.SetTableState(oldState);
131  }
132  } else {
133  FireTrigger(context, tableEvent);
134  }
135  }
TriggerEventType
The different types of high layer trigger events.
void FireTrigger(IQuery context, TableEvent tableEvent)
Definition: Trigger.cs:85
void Deveel.Data.Sql.Triggers.Trigger.NotifyTriggerEvent ( IQuery  context,
TableEvent  tableEvent 
)
inlineprivate

Definition at line 97 of file Trigger.cs.

97  {
98  var tableName = tableEvent.Table.FullName;
99  var eventType = tableEvent.EventType;
100 
101  var triggerEvent = new TriggerEvent(context.Session, TriggerName, tableName, eventType, tableEvent.OldRowId,
102  tableEvent.NewRow);
103  // TODO: context.RegisterEvent(triggerEvent);
104  }
ObjectName TriggerName
Gets the fully qualified name of the trigger, as defined in TriggerInfo
Definition: Trigger.cs:64

Property Documentation

ObjectName IDbObject. Deveel.Data.Sql.Triggers.Trigger.FullName
getprivate

Definition at line 81 of file Trigger.cs.

DbObjectType IDbObject. Deveel.Data.Sql.Triggers.Trigger.ObjectType
getprivate

Definition at line 77 of file Trigger.cs.

TriggerInfo Deveel.Data.Sql.Triggers.Trigger.TriggerInfo
getprivate set

Gets the information describing the dynamics of this trigger.

Definition at line 57 of file Trigger.cs.

ObjectName Deveel.Data.Sql.Triggers.Trigger.TriggerName
get

Gets the fully qualified name of the trigger, as defined in TriggerInfo

See also
TriggerInfo, Triggers.TriggerInfo.TriggerName

Definition at line 64 of file Trigger.cs.

TriggerType Deveel.Data.Sql.Triggers.Trigger.TriggerType
get

Gets the type of the trigger, as defined in TriggerInfo

See also
TriggerInfo, Triggers.TriggerInfo.TriggerType

Definition at line 73 of file Trigger.cs.


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