View Javadoc

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      super(database, name, definitionSource);
18    }
19  
20  
21    public Integer troidFor(Persistent persistent) {
22      int it = troidColumn().firstFree(null);
23      if (it >= Chapter.ftiTextID_author_limit)
24        throw new TooManyAuthorsException(this, it, Chapter.ftiTextID_author_limit);
25      return new Integer(it);
26    }
27    public Author ensure(String name, Section section) {
28      Author p = (Author)getDisplaynameColumn().firstWhereEq(name);
29      if (p == null) { 
30        p = (Author)newPersistent();
31        p.setDisplayname(name);
32        p.setSection(section);
33        p.setPath(section.getPath() + "/" + BibliomaniaDatabase.toCamelCase(name, false));
34        p.setDeleted(false);
35        p.setNonstandard(false);
36      }
37      return (Author)getDisplaynameColumn().ensure(p);    
38    }
39  }