Blue Mind
Release 1.0

net.bluemind.core.utils
Class BmHelper

java.lang.Object
  extended by net.bluemind.core.utils.BmHelper

public final class BmHelper
extends Object

Helper functions for datasource management


Constructor Summary
BmHelper()
           
 
Method Summary
static String buildIdList(Set<Integer> set)
          Creates a comma separated list of id usable in IN (x,y,z) SQL queries
static void cleanup(Connection con, Statement st, ResultSet rs)
          Ferme tout le 'JDBC crap' avec les tests qui vont bien.
static void drop(Connection con, String t, Integer uid)
          Delete an entity-based entry.
static Integer fetchEntityId(Connection con, String tt, Integer uid)
          Call with fetchEntityId(con, "User", userId)
static Integer fetchEntityId(String tt, Integer uid)
          Call with fetchEntityId("User", userId)
static Connection getConnection()
          Permet d'obtenir une connection du pool.
static EntityInfo getEntityInfo(Connection con, String tt, Integer entityId)
           
static Map<Integer,EntityInfo> getEntityInfos(Connection con, String tt, Set<Integer> entityId)
           
static BmDbType getType()
           
static UserTransaction getUserTransaction()
          Permet d'accéder à la transaction liée au thread courant.
static int lastInsertId(Connection con)
           
static LinkedEntity linkEntity(Connection con, String linkTable, String targetField, int targetId)
          call as linkEntity(con, "CalendarEntity", "calendar_id", userId) to link an entity to a user
static Map<String,Email> loadEmails(Connection con, int entityId)
           
static void rollback(UserTransaction ut)
           
static Date selectNow(Connection con)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BmHelper

public BmHelper()
Method Detail

cleanup

public static void cleanup(Connection con,
                           Statement st,
                           ResultSet rs)
Ferme tout le 'JDBC crap' avec les tests qui vont bien. Seuls les paramètres non nuls seront fermés.

Parameters:
con -
st -
rs -

getConnection

public static Connection getConnection()
                                throws SQLException
Permet d'obtenir une connection du pool. On obtient la même pendant toute la durée de la transaction.

Returns:
Une connection du pool
Throws:
SQLException

getUserTransaction

public static UserTransaction getUserTransaction()
Permet d'accéder à la transaction liée au thread courant.

Returns:
la transaction courante

rollback

public static void rollback(UserTransaction ut)

lastInsertId

public static int lastInsertId(Connection con)
                        throws SQLException
Parameters:
con -
Returns:
the last inserted id in the current transaction
Throws:
SQLException

linkEntity

public static LinkedEntity linkEntity(Connection con,
                                      String linkTable,
                                      String targetField,
                                      int targetId)
                               throws SQLException
call as linkEntity(con, "CalendarEntity", "calendar_id", userId) to link an entity to a user

Parameters:
con -
linkTable -
targetField -
entityId -
targetId -
Returns:
Throws:
SQLException

selectNow

public static Date selectNow(Connection con)
                      throws SQLException
Throws:
SQLException

fetchEntityId

public static Integer fetchEntityId(Connection con,
                                    String tt,
                                    Integer uid)
                             throws SQLException
Call with fetchEntityId(con, "User", userId)

Parameters:
con -
tt - the table uid comes from
uid - the database id
Returns:
Throws:
SQLException

fetchEntityId

public static Integer fetchEntityId(String tt,
                                    Integer uid)
                             throws SQLException
Call with fetchEntityId("User", userId)

Parameters:
con -
tt -
uid -
Returns:
Throws:
SQLException

getEntityInfo

public static EntityInfo getEntityInfo(Connection con,
                                       String tt,
                                       Integer entityId)
                                throws SQLException
Throws:
SQLException

getEntityInfos

public static Map<Integer,EntityInfo> getEntityInfos(Connection con,
                                                     String tt,
                                                     Set<Integer> entityId)
                                              throws SQLException
Throws:
SQLException

drop

public static void drop(Connection con,
                        String t,
                        Integer uid)
                 throws SQLException
Delete an entity-based entry. Clears the entity row before dealing with the real row. Usage: drop(con, "Host", 123);

Parameters:
con -
t -
uid -
Throws:
SQLException

buildIdList

public static String buildIdList(Set<Integer> set)
Creates a comma separated list of id usable in IN (x,y,z) SQL queries

Parameters:
set -
Returns:

getType

public static BmDbType getType()

loadEmails

public static Map<String,Email> loadEmails(Connection con,
                                           int entityId)
                                    throws SQLException
Throws:
SQLException

Blue Mind
Release 1.0