Coverage Report - org.trails.component.HibernateAssociationSelect
 
Classes in this File Line Coverage Branch Coverage Complexity
HibernateAssociationSelect
85% 
100% 
0
 
 1  0
 package org.trails.component;
 2  
 
 3  
 import org.apache.commons.logging.Log;
 4  
 import org.apache.commons.logging.LogFactory;
 5  
 import org.apache.tapestry.annotations.ComponentClass;
 6  
 import org.apache.tapestry.annotations.InjectObject;
 7  
 import org.apache.tapestry.annotations.Parameter;
 8  
 import org.apache.tapestry.form.IPropertySelectionModel;
 9  
 import org.hibernate.criterion.DetachedCriteria;
 10  
 import org.trails.persistence.HibernatePersistenceService;
 11  
 
 12  
 /**
 13  
  * This guy interacts with persistence service to produce a Select
 14  
  * containing all the elements of the PropertyDescriptor's type.  If
 15  
  * a criteria is specified, it will filter the list by it.
 16  
  */
 17  
 @ComponentClass(allowBody = false, allowInformalParameters = true)
 18  3
 public abstract class HibernateAssociationSelect extends AssociationSelect
 19  
 {
 20  1
         private static final Log LOG = LogFactory.getLog(HibernateAssociationSelect.class);
 21  
 
 22  
         /**
 23  
          * @todo: remove when the components reuse issue goes away
 24  
          */
 25  
         @InjectObject("spring:persistenceService")
 26  
         public abstract HibernatePersistenceService getHibernatePersistenceService();
 27  
 
 28  
         /**
 29  
          * @todo: remove when the components reuse issue goes away
 30  
          */
 31  
         @Override
 32  
         public HibernatePersistenceService getPersistenceService()
 33  
         {
 34  3
                 return getHibernatePersistenceService();
 35  
         }
 36  
 
 37  
         @Parameter(required = false)
 38  
         public abstract DetachedCriteria getCriteria();
 39  
 
 40  
         @Override
 41  
         public IPropertySelectionModel buildSelectionModel()
 42  
         {
 43  3
                 if (LOG.isDebugEnabled())
 44  
                 {
 45  0
                         LOG.debug("Building propertySelectionModel for " + getClassDescriptor().getDisplayName());
 46  
                 }
 47  
 
 48  3
                 DetachedCriteria criteria = getCriteria() != null ? getCriteria() : DetachedCriteria.forClass(getClassDescriptor().getType());
 49  6
                 IdentifierSelectionModel selectionModel = new IdentifierSelectionModel(
 50  3
                         getPersistenceService().getInstances(getClassDescriptor().getType(), criteria),
 51  3
                         getClassDescriptor().getIdentifierDescriptor().getName(),
 52  3
                         isAllowNone());
 53  3
                 selectionModel.setNoneLabel(getNoneLabel());
 54  3
                 return selectionModel;
 55  
         }
 56  
 }