1 package org.paneris.jammyjoes.model;
2
3 import java.util.Enumeration;
4
5 import org.melati.poem.Database;
6 import org.melati.poem.DefinitionSource;
7 import org.melati.poem.PoemException;
8 import org.paneris.jammyjoes.controller.ParameterProvider;
9 import org.paneris.jammyjoes.controller.SearchMaufacturer;
10 import org.paneris.jammyjoes.model.generated.ManufacturerTableBase;
11
12 public class ManufacturerTable extends ManufacturerTableBase {
13
14 public ManufacturerTable(
15 Database database, String name,
16 DefinitionSource definitionSource) throws PoemException {
17 super(database, name, definitionSource);
18 }
19
20 public SearchMaufacturer fromParameter(ParameterProvider provider) {
21 String param = provider.getParam("field_manufacturer", 8);
22 if (param != null) {
23 try {
24 return new SearchMaufacturer((Manufacturer)getObject(asInt(param)));
25 } catch (NumberFormatException e) {
26 Enumeration en = getNameColumn().selectionWhereEq(param);
27 if (en.hasMoreElements()) {
28 return new SearchMaufacturer((Manufacturer)en.nextElement());
29 }
30 }
31 }
32 return new SearchMaufacturer();
33 }
34
35 public Integer asInt(String in) {
36 return in == null ? null : new Integer(in);
37 }
38
39 }