1 20 21 package com.methodhead.reg; 22 23 import com.methodhead.aikp.AutoIntKeyPersistable; 24 25 import org.apache.commons.beanutils.DynaClass; 26 import org.apache.commons.beanutils.DynaProperty; 27 import org.apache.commons.beanutils.BasicDynaClass; 28 import org.apache.commons.lang.StringUtils; 29 30 50 public class Contact 51 extends 52 AutoIntKeyPersistable { 53 54 private static DynaClass dynaClass_ = null; 55 56 static { 57 DynaProperty[] dynaProperties = 58 new DynaProperty[] { 59 new DynaProperty( "id", Integer .class ), 60 new DynaProperty( "firstname", String .class ), 61 new DynaProperty( "middlename", String .class ), 62 new DynaProperty( "lastname", String .class ), 63 new DynaProperty( "company", String .class ), 64 new DynaProperty( "address1", String .class ), 65 new DynaProperty( "address2", String .class ), 66 new DynaProperty( "city", String .class ), 67 new DynaProperty( "state", String .class ), 68 new DynaProperty( "zip", String .class ), 69 new DynaProperty( "country", String .class ), 70 new DynaProperty( "phone", String .class ), 71 new DynaProperty( "fax", String .class ), 72 new DynaProperty( "email", String .class ), 73 new DynaProperty( "url", String .class ) 74 }; 75 76 dynaClass_ = 77 new BasicDynaClass( 78 "reg_contact", Contact.class, dynaProperties ); 79 } 80 81 83 public Contact() { 84 super( dynaClass_ ); 85 init(); 86 } 87 88 public Contact( DynaClass dynaClass ) { 89 super( dynaClass ); 90 init(); 91 } 92 93 95 97 99 protected void init() { 100 setInt( "id", 0 ); 101 setString( "firstname", "" ); 102 setString( "middlename", "" ); 103 setString( "lastname", "" ); 104 setString( "company", "" ); 105 setString( "address1", "" ); 106 setString( "address2", "" ); 107 setString( "city", "" ); 108 setString( "state", "" ); 109 setString( "zip", "" ); 110 setString( "country", "" ); 111 setString( "phone", "" ); 112 setString( "fax", "" ); 113 setString( "email", "" ); 114 setString( "url", "" ); 115 } 116 117 122 public String getFullName() { 123 if ( StringUtils.isBlank( getString( "firstname" ) ) && StringUtils.isBlank( getString( "lastname" ) ) ) { 124 return "[Missing Name]"; 125 } 126 127 if ( StringUtils.isBlank( getString( "firstname" ) ) ) { 128 return getString( "lastname" ); 129 } 130 131 if ( StringUtils.isBlank( getString( "lastname" ) ) ) { 132 return getString( "firstname" ); 133 } 134 135 return getString( "lastname" ) + ", " + getString( "firstname" ); 136 } 137 138 140 } 142 | Popular Tags |