org.nuiton.topia.framework
Class TopiaUtil

java.lang.Object
  extended by org.nuiton.topia.framework.TopiaUtil

public class TopiaUtil
extends Object

TODO-fdesbois-20100507 : Need javadoc + translations for existing methods.

Version:
$Id: TopiaUtil.java 2378 2011-11-12 19:21:01Z tchemit $
Author:
bpoussin , tchemit

Field Summary
static String HIBERNATE_DEFAULT_SCHEMA
          Deprecated. since 2.5.3, use now the constant TopiaContextFactory.CONFIG_DEFAULT_SCHEMA.
static String TOPIA_PERSISTENCE_CLASSES
          Deprecated. since 2.5.3, use the already present TopiaContextImpl.TOPIA_PERSISTENCE_CLASSES.
 
Constructor Summary
TopiaUtil()
           
 
Method Summary
static Properties getProperties(Properties parent, String pathOrUrl)
          Permet de récupérer le fichier de propriété ayant le nom passé en argument.
static Properties getProperties(String pathOrUrl)
          Permet de récupérer le fichier de propriété ayant le nom passé en argument.
static String getSchemaName(org.hibernate.cfg.Configuration config)
          Return hibernate schema name
static String getTopiaIdPattern(Class<? extends TopiaEntity> klass)
          Compute the pattern to be used to capture a topia id for a given entity class.
static Pattern getTopiaPattern(String format, Class<? extends TopiaEntity>... classes)
          Compute a regex pattern given a format string.
static boolean isSchemaEmpty(org.hibernate.cfg.Configuration configuration)
          Test if the db associated to the given configuration contaisn any of the dealed entities.
static boolean isSchemaExist(org.hibernate.cfg.Configuration configuration, String entityName)
          Test si une entite donnee correspondant a une configuration existe en base.
static boolean isSchemaExist(TopiaContext tx, String entityName)
          Test si une entite donnee correspondant a une configuration existe en base.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIBERNATE_DEFAULT_SCHEMA

@Deprecated
public static final String HIBERNATE_DEFAULT_SCHEMA
Deprecated. since 2.5.3, use now the constant TopiaContextFactory.CONFIG_DEFAULT_SCHEMA.
See Also:
Constant Field Values

TOPIA_PERSISTENCE_CLASSES

@Deprecated
public static final String TOPIA_PERSISTENCE_CLASSES
Deprecated. since 2.5.3, use the already present TopiaContextImpl.TOPIA_PERSISTENCE_CLASSES.
See Also:
Constant Field Values
Constructor Detail

TopiaUtil

public TopiaUtil()
Method Detail

getProperties

public static Properties getProperties(String pathOrUrl)
                                throws TopiaNotFoundException
Permet de récupérer le fichier de propriété ayant le nom passé en argument.

Parameters:
pathOrUrl - le nom du fichier de propriété à charger, s'il est null ou vide retourne un objet Properties vide.
Returns:
Un nouvel objet de propriete
Throws:
TopiaNotFoundException - Si pathOrUrl n'est pas null ou vide et que le fichier devant contenir les propriétés n'est pas retrouvé.

getProperties

public static Properties getProperties(Properties parent,
                                       String pathOrUrl)
                                throws TopiaNotFoundException
Permet de récupérer le fichier de propriété ayant le nom passé en argument.

Parameters:
parent - l'objet properties utilisé comme parent de l'objet retourné
pathOrUrl - le nom du fichier de propriété à charger, s'il est null ou vide retourne un objet Properties vide.
Returns:
Un nouvel objet de propriete
Throws:
TopiaNotFoundException - Si pathOrUrl n'est pas null ou vide et que le fichier devant contenir les propriétés n'est pas retrouvé.

getTopiaPattern

public static Pattern getTopiaPattern(String format,
                                      Class<? extends TopiaEntity>... classes)
Compute a regex pattern given a format string.

A String.format(String, Object...) will be apply to format, with for parameters the list of klass transformed in topia pattern via method getTopiaIdPattern(Class) ready to be capture (enclosed by ()).

Parameters:
format - the format
classes - the list of class to use
Returns:
the pattern computed

getTopiaIdPattern

public static String getTopiaIdPattern(Class<? extends TopiaEntity> klass)
Compute the pattern to be used to capture a topia id for a given entity class.

Parameters:
klass - the entity class
Returns:
the pattern to capture a topia id for the given entity class.

isSchemaExist

public static boolean isSchemaExist(TopiaContext tx,
                                    String entityName)
Test si une entite donnee correspondant a une configuration existe en base.

Parameters:
tx - la session topia
entityName - le nom de l'entite a tester
Returns:
true si le schema de la table existe
Since:
2.6.4

isSchemaExist

public static boolean isSchemaExist(org.hibernate.cfg.Configuration configuration,
                                    String entityName)
Test si une entite donnee correspondant a une configuration existe en base.

Parameters:
configuration - la configuration hibernate
entityName - le nom de l'entite a tester
Returns:
true si le schema de la table existe

isSchemaEmpty

public static boolean isSchemaEmpty(org.hibernate.cfg.Configuration configuration)
Test if the db associated to the given configuration contaisn any of the dealed entities.

Parameters:
configuration - hibernate db configuration
Returns:
true if there is no schema for any of the dealed entities, false otherwise.
Since:
2.5.3

getSchemaName

public static String getSchemaName(org.hibernate.cfg.Configuration config)
Return hibernate schema name

Parameters:
config - of hibernate
Returns:
schema name


Copyright © 2004-2011 CodeLutin. All Rights Reserved.