Coverage Report - org.paneris.bibliomania.SectionTable
 
Classes in this File Line Coverage Branch Coverage Complexity
SectionTable
33%
5/15
25%
1/4
1.75
 
 1  
 package org.paneris.bibliomania;
 2  
 
 3  
 import org.melati.poem.Database;
 4  
 import org.melati.poem.DefinitionSource;
 5  
 import org.melati.poem.Persistent;
 6  
 import org.melati.poem.PoemException;
 7  
 import org.melati.poem.Table;
 8  
 import org.paneris.bibliomania.generated.SectionTableBase;
 9  
 
 10  
 public class SectionTable<T extends Section> extends SectionTableBase<Section> {
 11  
 
 12  
   public SectionTable(
 13  
       Database database, String name,
 14  
       DefinitionSource definitionSource) throws PoemException {
 15  2
     super(database, name, definitionSource);
 16  2
   }
 17  
 
 18  
 
 19  
   public Integer troidFor(Persistent persistent) {
 20  0
     int it = troidColumn().firstFree(null);
 21  0
     if (it >= Chapter.ftiTextID_section_limit)
 22  0
       throw new TooManySectionsException(this, it, Chapter.ftiTextID_section_limit);
 23  0
     return new Integer(it);
 24  
   }
 25  
 
 26  
   public Unit unitWithPath(String path) {
 27  0
     return (Section)getPathColumn().firstWhereEq(path);
 28  
   }
 29  
   
 30  
   public Section ensure(String name, SectionGroup sectionGroup) {
 31  2
     Section p = (Section)getDisplaynameColumn().firstWhereEq(name);
 32  2
     if (p == null) { 
 33  0
       p = (Section)newPersistent();
 34  0
       p.setDisplayname(name);
 35  0
       p.setGroup(sectionGroup);
 36  0
       p.setPath(name);
 37  0
       p.setDeleted(false);
 38  
     }
 39  2
     return (Section)getDisplaynameColumn().ensure(p);
 40  
     
 41  
   }
 42  
 }