1 package org.paneris.jammyjoes.model; 2 3 import java.sql.ResultSet; 4 import java.util.LinkedList; 5 import java.util.List; 6 7 import org.melati.poem.Database; 8 import org.melati.poem.DefinitionSource; 9 import org.melati.poem.PoemException; 10 import org.paneris.jammyjoes.model.generated.OrderStatusTableBase; 11 12 public class OrderStatusTable extends OrderStatusTableBase { 13 14 OrderStatus Incomplete; 15 OrderStatus Paid; 16 OrderStatus Fufilled; 17 OrderStatus Outstanding; 18 19 public OrderStatusTable( 20 Database database, String name, 21 DefinitionSource definitionSource) throws PoemException { 22 super(database, name, definitionSource); 23 } 24 25 public synchronized void unifyWithDB(ResultSet colDescs) 26 throws PoemException { 27 super.unifyWithDB(colDescs); 28 Incomplete = ensure("Incomplete"); 29 Paid = ensure("Paid"); 30 Fufilled = ensure("Fulfilled"); 31 Outstanding = ensure("Outstanding"); 32 } 33 34 public OrderStatus ensure(String s) { 35 OrderStatus status = (OrderStatus)getStatusColumn().firstWhereEq(s); 36 if (status != null) 37 return status; 38 else { 39 status = (OrderStatus)newPersistent(); 40 status.setStatus(s); 41 return (OrderStatus)getStatusColumn().ensure(status); 42 } 43 } 44 45 public OrderStatus getIncomplete() { 46 return Incomplete; 47 } 48 49 public OrderStatus getPaid() { 50 return Paid; 51 } 52 53 public OrderStatus getFufilled() { 54 return Fufilled; 55 } 56 57 public OrderStatus getOutstanding() { 58 return Outstanding; 59 } 60 61 public List paidStatuses() { 62 List statuses = new LinkedList(); 63 statuses.add(getFufilled()); 64 statuses.add(getPaid()); 65 statuses.add(getOutstanding()); 66 return statuses; 67 } 68 69 }