public class TopiaEntityHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ASSOCIATION_PATTERN
Le pattern d'une reference sur une association
|
Constructor and Description |
---|
TopiaEntityHelper() |
Modifier and Type | Method and Description |
---|---|
protected static void |
addInterface(Set<Class<? extends TopiaEntity>> interfaces,
Class<? extends TopiaEntity> klass) |
static void |
bindTechnical(TopiaEntity from,
TopiaEntity dst)
Bind les valeurs techniques depuis une entitée vers une autre.
|
static <E extends TopiaEntity> |
buildDifferentiel(List<E> referentiel,
List<E> locale)
Construit le dictionnaire des differences entre deux listes d'entites.
|
static void |
checkNotNull(String methodName,
String parameterName,
Object value) |
static <E extends TopiaEntity> |
checkNotNullAndExistingEntity(String paramName,
E bean)
Teste si une entité possède un topiaId.
|
static <E extends TopiaEntity> |
checkNotNullAndNoneExistingEntity(String paramName,
E bean)
Teste si une entité ne possède pas un topiaId.
|
static void |
checkParameters(Class<?>[] paramsType,
Object... params) |
static void |
checkSize(int size,
Object[] params) |
static void |
checkType(Class<?>[] paramsType,
int index,
Object[] params) |
static void |
createDBFromSQL(File dbDirectory,
TopiaContext topiaContext,
URI resource)
Create a new database from a sql dump locating in a gzip file.
|
static Map<Class<? extends TopiaEntity>,List<TopiaEntity>> |
detectEntities(TopiaEntityEnum[] contracts,
Set<Class<? extends TopiaEntity>> types,
TopiaEntity... entities)
Collecte l'ensemble des entites (via un parcours en profondeur) avec un
filtrage sur les types d'entites a retourner.
|
static TopiaEntityIdsMap |
detectEntityIds(TopiaEntityEnum[] contracts,
Set<Class<? extends TopiaEntity>> types,
TopiaEntity... entities)
Collecte l'ensemble des ids d'entites (via un parcours en profondeur)
avec un filtrage sur les types d'entites a retourner.
|
static SortedMap<TopiaEntity,List<TopiaEntityRef>> |
detectReferences(TopiaEntityEnum[] contracts,
String[] expressions,
Collection<? extends TopiaEntity> entities)
Collecte toutes les references d'un ensemble d'entites donnees par leur
topiaId sur un ensemble d'entites donne.
|
static SortedMap<TopiaEntity,List<TopiaEntityRef>> |
detectReferences(TopiaEntityEnum[] contracts,
String[] expressions,
TopiaEntity entities)
Collecte toutes les references d'un ensemble d'entites donnees par leur
topiaId sur un ensemble d'entites donne.
|
static Set<Class<? extends TopiaEntity>> |
detectTypes(TopiaEntityEnum[] contracts,
TopiaEntity... entities)
Collecte l'ensemble des types d'entites (via un parcours en profondeur).
|
static List<TopiaEntity> |
filter(Collection<TopiaEntity> entities,
Class<? extends TopiaEntity> filterClass)
Filter a list of entities, and keep only the ones from a given type.
|
static Class<? extends TopiaEntity> |
getContractClass(TopiaEntityEnum[] contracts,
Class<? extends TopiaEntity> klass) |
static Set<Class<? extends TopiaEntity>> |
getContractClasses(TopiaEntityEnum[] contracts,
Iterable<Class<? extends TopiaEntity>> klasses) |
static Class<? extends TopiaEntity>[] |
getContracts(TopiaEntityEnum[] contracts)
Ontenir l'ensemble des contrats d'entites a partir des descriptions
d'entites.
|
static <E extends TopiaEntity> |
getEntities(TopiaContextImplementor srcCtxt,
List<E> entityList,
boolean canBeNull) |
static TopiaEntity[] |
getEntities(TopiaContext srcCtxt,
String... entityList) |
static List<? extends TopiaEntity> |
getEntitiesList(TopiaContext srcCtxt,
String... entityList) |
static <E extends TopiaEntity> |
getEntityByTopiaId(Collection<E> entities,
String topiaId)
Récupère une entité dans une liste d'entités à partir de son
TopiaEntity.getTopiaId() . |
static TopiaEntityEnum |
getEntityEnum(Class<? extends TopiaEntity> klass,
TopiaEntityEnum... contracts) |
static <E extends TopiaEntity> |
getExistingEntity(TopiaDAO<E> dao,
String topiaId)
Récupère une entité qui doit exister à partir de son id.
|
static Set<Class<? extends TopiaEntity>> |
getInterfaces(Class<? extends TopiaEntity> klass,
Set<Class<? extends TopiaEntity>> klassInterfaces) |
static String |
getNormalizedAssociationTableName(String table1,
String table2)
Given two names (representing two types of entity), obtains the
association table name in the format
X_Y where X est the table
name smaller (in natural order on String ). |
static String[] |
getTopiaIdArray(List<? extends TopiaEntity> entities)
Construit un tableau des topiaId d'une liste donnée d'entités.
|
static Comparator<TopiaEntity> |
getTopiaIdComparator()
|
static List<String> |
getTopiaIdList(Collection<? extends TopiaEntity> entities)
Construit la liste des topiaId d'une liste donnée d'entités.
|
static Set<Class<? extends TopiaEntity>> |
retainContracts(TopiaEntityEnum[] contracts,
Set<Class<? extends TopiaEntity>> classes)
Filtre un ensemble de classes d'entites en ne conservant que les contrats
des entites.
|
static <E extends TopiaEntity> |
retainEntities(List<E> list,
List<String> topiaIds)
Construit une list d'entite dont les ids sont tous dans la liste d'ids
donnee.
|
static void |
saveDB(File gzipFile,
TopiaContext topiaContext)
Save the given database to a gzip file.
|
public static final String ASSOCIATION_PATTERN
public static void bindTechnical(TopiaEntity from, TopiaEntity dst)
from
- l'entité sourcedst
- l'entité destinationpublic static <E extends TopiaEntity> E getExistingEntity(TopiaDAO<E> dao, String topiaId) throws TopiaException, IllegalArgumentException
IllegalArgumentException
.E
- le type de l'entitédao
- la dao pour récupérer la valeurtopiaId
- l'id de l'entité recherchéeTopiaException
- pour tout pb lors de la récupération de
l'entitéIllegalArgumentException
- si l'entité n'existe pas.public static <E extends TopiaEntity> E getEntityByTopiaId(Collection<E> entities, String topiaId)
TopiaEntity.getTopiaId()
.E
- le type de l'entitéentities
- la liste des entités à scannertopiaId
- l'id de l'entité recherchéenull
si elle n'est pas
trouvée.public static <E extends TopiaEntity> void checkNotNullAndExistingEntity(String paramName, E bean) throws IllegalStateException, NullPointerException
E
- le type de l'entitéparamName
- le nom du paramètre à afficher en casd'erreurbean
- l'entité à testerIllegalStateException
- si l'entité n'a pas de topiaIdNullPointerException
- si l'entité est nullpublic static <E extends TopiaEntity> void checkNotNullAndNoneExistingEntity(String paramName, E bean) throws NullPointerException, IllegalStateException
E
- le type del'entitéparamName
- le nom de paramètre à afficher en cas d'erreurbean
- l'entité à testerNullPointerException
- si l'entité est nulleIllegalStateException
- si l'entité possède un topiaId.public static void createDBFromSQL(File dbDirectory, TopiaContext topiaContext, URI resource) throws IOException, TopiaException, NullPointerException
dbDirectory
- the directory where to create the dbtopiaContext
- the topiaContext to use to create the databseresource
- the url of the sql dump gzip file to useTopiaException
- if any pb while creating dbIOException
- if any io exceptionNullPointerException
- if parameters are nullpublic static void saveDB(File gzipFile, TopiaContext topiaContext) throws TopiaException, IOException, NullPointerException
gzipFile
- the file where to store dbtopiaContext
- the topiaContext of the db to storeTopiaException
- if any pb while saving dbNullPointerException
- if parameters are nullIOException
- if could not create gzipFile container
directorypublic static Comparator<TopiaEntity> getTopiaIdComparator()
public static List<TopiaEntity> filter(Collection<TopiaEntity> entities, Class<? extends TopiaEntity> filterClass)
entities
- the list of entities to filterfilterClass
- the type of entities to keeppublic static Class<? extends TopiaEntity> getContractClass(TopiaEntityEnum[] contracts, Class<? extends TopiaEntity> klass)
public static Set<Class<? extends TopiaEntity>> getContractClasses(TopiaEntityEnum[] contracts, Iterable<Class<? extends TopiaEntity>> klasses)
public static TopiaEntityEnum getEntityEnum(Class<? extends TopiaEntity> klass, TopiaEntityEnum... contracts)
public static Set<Class<? extends TopiaEntity>> retainContracts(TopiaEntityEnum[] contracts, Set<Class<? extends TopiaEntity>> classes)
contracts
- les contracts connusclasses
- l'ensemble des classes a filterpublic static Class<? extends TopiaEntity>[] getContracts(TopiaEntityEnum[] contracts)
contracts
- les contracts connuspublic static Set<Class<? extends TopiaEntity>> detectTypes(TopiaEntityEnum[] contracts, TopiaEntity... entities) throws TopiaException
contracts
- les definitions d'entites connuesentities
- les entites a parcourirTopiaException
- if a problem while visiting entitiespublic static Map<Class<? extends TopiaEntity>,List<TopiaEntity>> detectEntities(TopiaEntityEnum[] contracts, Set<Class<? extends TopiaEntity>> types, TopiaEntity... entities) throws TopiaException
contracts
- les definitions d'entites connuestypes
- l'ensemble des types acceptablesentities
- les entites a parcourirTopiaException
- if a pb while visiting entitiespublic static TopiaEntityIdsMap detectEntityIds(TopiaEntityEnum[] contracts, Set<Class<? extends TopiaEntity>> types, TopiaEntity... entities) throws TopiaException
contracts
- les definitions d'entites connuestypes
- l'ensemble des types acceptablesentities
- les entites a parcourirTopiaException
- if a pb while visiting entitiespublic static SortedMap<TopiaEntity,List<TopiaEntityRef>> detectReferences(TopiaEntityEnum[] contracts, String[] expressions, TopiaEntity entities) throws TopiaException
contracts
- les definitions d'entites connuesexpressions
- l'ensemble des ids a detecterentities
- les entites a parcourirTopiaException
- if a pb while visiting entitiesTopiaEntityRef
public static SortedMap<TopiaEntity,List<TopiaEntityRef>> detectReferences(TopiaEntityEnum[] contracts, String[] expressions, Collection<? extends TopiaEntity> entities) throws TopiaException
contracts
- les definitions d'entites connuesexpressions
- l'ensemble des ids a detecterentities
- les entites a parcourirTopiaException
- if a pb while visiting entitiesTopiaEntityRef
public static List<String> getTopiaIdList(Collection<? extends TopiaEntity> entities)
entities
- la liste des entitéspublic static String[] getTopiaIdArray(List<? extends TopiaEntity> entities)
entities
- la liste des entitéspublic static <E extends TopiaEntity> List<E> retainEntities(List<E> list, List<String> topiaIds)
E
- le type des entites de la listelist
- la liste a filtertopiaIds
- la liste des ids a retenirpublic static <E extends TopiaEntity> DiffState.DiffStateMap buildDifferentiel(List<E> referentiel, List<E> locale)
E
- le type des entitesreferentiel
- la liste considere comme referencelocale
- la liste a mettre a jourDiffState
public static Set<Class<? extends TopiaEntity>> getInterfaces(Class<? extends TopiaEntity> klass, Set<Class<? extends TopiaEntity>> klassInterfaces)
protected static void addInterface(Set<Class<? extends TopiaEntity>> interfaces, Class<? extends TopiaEntity> klass)
public static <E extends TopiaEntity> List<E> getEntities(TopiaContextImplementor srcCtxt, List<E> entityList, boolean canBeNull) throws TopiaException
TopiaException
public static TopiaEntity[] getEntities(TopiaContext srcCtxt, String... entityList) throws TopiaException
TopiaException
public static List<? extends TopiaEntity> getEntitiesList(TopiaContext srcCtxt, String... entityList) throws TopiaException
TopiaException
public static void checkSize(int size, Object[] params)
public static String getNormalizedAssociationTableName(String table1, String table2)
X_Y
where X est the table
name smaller (in natural order on String
).
Example: from A
and B
, we get A_B
.table1
- the first tabletable2
- the second tableCopyright © 2004–2022 Code Lutin. All rights reserved.