Coverage Report - org.paneris.bibliomania.AuthorTable
 
Classes in this File Line Coverage Branch Coverage Complexity
AuthorTable
33%
5/15
25%
1/4
2
 
 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.AuthorTableBase;
 9  
 
 10  
 public class AuthorTable<T extends Author> extends AuthorTableBase<Author> {
 11  
 
 12  
   //private Author none = null;
 13  
 
 14  
   public AuthorTable(
 15  
     Database database, String name,
 16  
     DefinitionSource definitionSource) throws PoemException {
 17  2
     super(database, name, definitionSource);
 18  2
   }
 19  
 
 20  
 
 21  
   public Integer troidFor(Persistent persistent) {
 22  0
     int it = troidColumn().firstFree(null);
 23  0
     if (it >= Chapter.ftiTextID_author_limit)
 24  0
       throw new TooManyAuthorsException(this, it, Chapter.ftiTextID_author_limit);
 25  0
     return new Integer(it);
 26  
   }
 27  
   public Author ensure(String name, Section section) {
 28  2
     Author p = (Author)getDisplaynameColumn().firstWhereEq(name);
 29  2
     if (p == null) { 
 30  0
       p = (Author)newPersistent();
 31  0
       p.setDisplayname(name);
 32  0
       p.setSection(section);
 33  0
       p.setPath(section.getPath() + "/" + BibliomaniaDatabase.toCamelCase(name, false));
 34  0
       p.setDeleted(false);
 35  0
       p.setNonstandard(false);
 36  
     }
 37  2
     return (Author)getDisplaynameColumn().ensure(p);    
 38  
   }
 39  
 }