velosurf.model
Class Action

java.lang.Object
  extended by velosurf.model.Action
Direct Known Subclasses:
Transaction

public class Action
extends java.lang.Object

This class corresponds to custom update, delete and insert queries.

Author:
Claude Brisson

Field Summary
protected  Database db
          The database connection.
private  Entity entity
          The entity this action belongs to.
private  java.lang.String name
          The name of this action.
protected  java.util.List<java.lang.String> paramNames
          Parameter names of this action.
private  java.lang.String query
          Query.
 
Constructor Summary
Action(java.lang.String name, Entity entity)
          Constructor.
 
Method Summary
 void addParamName(java.lang.String paramName)
          Add a parameter name.
 java.util.List<java.lang.Object> buildArrayList(java.util.Map<java.lang.String,java.lang.Object> source)
          Get the list of values for all parameters.
 Database getDB()
          Get the database connection.
 Entity getEntity()
          Gets the parent entity
 java.lang.String getName()
          Get the name of the action.
 int perform(java.util.Map<java.lang.String,java.lang.Object> source)
          Executes this action.
 void setQuery(java.lang.String query)
          Sets the query.
 java.lang.String toString()
          For debugging purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

db

protected Database db
The database connection.


entity

private Entity entity
The entity this action belongs to.


name

private java.lang.String name
The name of this action.


paramNames

protected java.util.List<java.lang.String> paramNames
Parameter names of this action.


query

private java.lang.String query
Query.

Constructor Detail

Action

public Action(java.lang.String name,
              Entity entity)
Constructor.

Parameters:
name - name
entity - entity
Method Detail

getEntity

public Entity getEntity()
Gets the parent entity

Returns:
parent entity

addParamName

public void addParamName(java.lang.String paramName)
Add a parameter name.

Parameters:
paramName -

setQuery

public void setQuery(java.lang.String query)
Sets the query.

Parameters:
query - query

perform

public int perform(java.util.Map<java.lang.String,java.lang.Object> source)
            throws java.sql.SQLException
Executes this action.

Parameters:
source - the object on which apply the action
Returns:
number of impacted rows
Throws:
java.sql.SQLException - an SQL problem occurs

buildArrayList

public java.util.List<java.lang.Object> buildArrayList(java.util.Map<java.lang.String,java.lang.Object> source)
                                                throws java.sql.SQLException
Get the list of values for all parameters.

Parameters:
source - the ReadOnlyMap
Returns:
the list of values
Throws:
java.sql.SQLException - thrown by the ReadOnlyMap

getName

public java.lang.String getName()
Get the name of the action.

Returns:
the name

toString

public java.lang.String toString()
For debugging purposes.

Overrides:
toString in class java.lang.Object
Returns:
definition string

getDB

public Database getDB()
Get the database connection.

Returns:
the database connection


~ooOoo~