1 64 65 package com.jcorporate.expresso.services.controller.dbmaint; 66 67 import com.jcorporate.expresso.core.controller.ControllerException; 68 import com.jcorporate.expresso.core.controller.ControllerRequest; 69 import com.jcorporate.expresso.core.controller.ControllerResponse; 70 import com.jcorporate.expresso.core.controller.ErrorCollection; 71 import com.jcorporate.expresso.core.controller.NonHandleableException; 72 import com.jcorporate.expresso.core.dataobjects.DataObject; 73 import com.jcorporate.expresso.core.dataobjects.DataObjectMetaData; 74 import com.jcorporate.expresso.core.db.DBException; 75 import com.jcorporate.expresso.core.misc.StringUtil; 76 import com.jcorporate.expresso.kernel.util.FastStringBuffer; 77 import com.jcorporate.expresso.services.controller.ui.DefaultAutoElement; 78 import org.apache.log4j.Logger; 79 80 import java.util.Iterator ; 81 82 83 93 public class SearchList 94 extends ListBase { 95 private static Logger log = Logger.getLogger(SearchList.class); 96 97 public SearchList() { 98 99 } 100 101 107 public SearchList(String code, String descrip) { 108 super(code, descrip); 109 } 110 111 117 public void run(ControllerRequest req, ControllerResponse res) 118 throws NonHandleableException, ControllerException { 119 super.run(req, res); 120 121 DataObject myDBObj = this.getDataObject(); 122 DataObjectMetaData metadata = myDBObj.getMetaData(); 123 124 ErrorCollection ee = new ErrorCollection(); 125 126 myDBObj = DefaultAutoElement.getAutoControllerElement().parseDBObject(req, myDBObj, ee, false); 127 128 showNext = true; 129 showPrev = false; 130 131 String oneFieldName = null; 132 String fieldValue = null; 133 FastStringBuffer newFields = FastStringBuffer.getInstance(); 134 135 try { 136 if (!StringUtil.notNull(getFieldsParam()).equals("")) { 137 newFields.append(getFieldsParam()); 138 newFields.append("|"); 139 } 140 try { 141 142 143 for (Iterator e = myDBObj.getMetaData().getFieldListArray().iterator(); e.hasNext();) { 144 oneFieldName = (String ) e.next(); 145 146 if (!metadata.isVirtual(oneFieldName)) { 147 fieldValue = StringUtil.notNull(myDBObj.getDataField(oneFieldName).asString()); 148 149 if (!fieldValue.equals("")) { 150 if (metadata.getAttribute(oneFieldName, "checkbox") != null 151 && myDBObj.getDataField(oneFieldName).asBoolean().booleanValue() == false) { 152 153 if (log.isDebugEnabled()) { 160 log.debug("Received false checkbox. " + 161 " Skipping value and resetting to false"); 162 } 163 myDBObj.set(oneFieldName, null); 164 } else { 165 newFields.append(oneFieldName); 166 newFields.append("|"); 167 newFields.append(fieldValue); 168 newFields.append("|"); 169 } 170 } 171 } 172 } 173 174 setSearchParam(newFields.toString()); 175 showList(); 176 } catch (DBException de) { 177 ee.addError(de); 178 res.saveErrors(ee); 179 transition("Search", req, res); 180 return; 181 } catch (Throwable t) { 182 log.error("Error listing fields", t); 183 throw new ControllerException("Error Listing Fields", t); 184 } 185 } finally { 186 newFields.release(); 187 } 188 } 189 } 190 191 | Popular Tags |