* @return DataMartModelStructure
*/
public IModelStructure build() {
ModelStructure modelStructure;
String modelName;
Metamodel jpaMetamodel;
Set<EntityType<?>> jpaEntities;
logger.debug("IN");
try {
modelStructure = new ModelStructure();
modelName = getDataSource().getConfiguration().getModelName();
Assert.assertNotNull(getDataSource(), "datasource cannot be null");
setEntityManager(getDataSource().getEntityManager());
Assert.assertNotNull(getEntityManager(), "Impossible to find the jar file associated to datamart named: [" + modelName + "]");
propertiesInitializer.addProperties(modelStructure);
Map calculatedFields = getDataSource().getConfiguration().loadCalculatedFields();
modelStructure.setCalculatedFields(calculatedFields);
jpaMetamodel = getEntityManager().getMetamodel();
jpaEntities = jpaMetamodel.getEntities();
logger.debug("Jpa metamodel contains ["+ jpaEntities.size() + "] entity types");
for(EntityType<?> entityType: jpaEntities) {
logger.debug("Adding entity type [" + entityType + "] to model structure");
String entityTypeName = entityType.getJavaType().getName();