* @param modelQualifier Fully qualified name of the model to read
* @return The new model or null (error messages go to the message container)
*/
protected Model readModelFromStore(ModelQualifier modelQualifier)
{
PersistenceContext pc = getPersistenceContextProvider().obtainPersistenceContext();
TransactionGuard tg = new TransactionGuard(pc);
try
{
DbModel dbModel = findDbModel(pc, modelQualifier.getModel());
Model model = dbModelToModel(dbModel);
// Register the model
try
{
registerModel(model);
}
catch (ModelException e)
{
getMsgContainer().addMsg(null, "Error registering model $0 in model manager $1", new Object[]
{
model.getName(), getClass().getName(), e
});
return null;
}
PersistenceQuery query = pc.createQuery(DbModelItem.class);
query.eq("modelName", model.getName());
for (Iterator it = pc.runQuery(query); it.hasNext();)
{
DbModelItem dbModelItem = (DbModelItem) it.next();
registerDbModelItem(dbModelItem, model);
}