|
3 | 3 | */ |
4 | 4 | package com.acminds.acuteauto.ui; |
5 | 5 |
|
| 6 | +import java.util.ArrayList; |
| 7 | +import java.util.List; |
| 8 | + |
6 | 9 | import javax.faces.bean.ApplicationScoped; |
7 | 10 | import javax.faces.bean.ManagedBean; |
| 11 | +import javax.faces.model.SelectItem; |
| 12 | + |
| 13 | +import com.acminds.acuteauto.persistence.BaseDAO; |
| 14 | +import com.acminds.acuteauto.persistence.dto.Enum; |
| 15 | +import com.acminds.acuteauto.persistence.dto.EnumType; |
| 16 | +import com.acminds.acuteauto.utils.EnumConstants; |
| 17 | +import com.acminds.acuteauto.utils.Utils; |
8 | 18 |
|
9 | 19 | /** |
10 | 20 | * @author Mansur |
|
13 | 23 | @ManagedBean(eager=true, name="uiTypes") |
14 | 24 | @ApplicationScoped |
15 | 25 | public class UITypes { |
| 26 | + BaseDAO dao = new BaseDAO(); |
| 27 | + private List<SelectItem> userTypes; |
| 28 | + private List<SelectItem> userStatuses; |
| 29 | + private List<SelectItem> locationTypes; |
| 30 | + private List<SelectItem> styleTypes; |
| 31 | + private List<SelectItem> bodyTypes; |
| 32 | + private List<SelectItem> categoryTypes; |
| 33 | + private List<SelectItem> fuelTypes; |
| 34 | + private List<SelectItem> warrantyTypes; |
| 35 | + private List<SelectItem> vehicleStatus; |
| 36 | + private List<SelectItem> vehicleConditions; |
| 37 | + private List<SelectItem> displayTypes; |
| 38 | + private List<SelectItem> imageTypes; |
| 39 | + private List<SelectItem> adStatuses; |
| 40 | + private List<SelectItem> adUnits; |
| 41 | + private List<SelectItem> loanStatuses; |
| 42 | + private List<SelectItem> financeTypes; |
| 43 | + private List<SelectItem> accountTypes; |
| 44 | + private List<SelectItem> inquiryTypes; |
| 45 | + /** |
| 46 | + * @return the userTypes |
| 47 | + */ |
| 48 | + public List<SelectItem> getUserTypes() { |
| 49 | + if(Utils.isEmpty(userTypes)) { |
| 50 | + userTypes = processEnums(EnumConstants.USER_TYPE); |
| 51 | + } |
| 52 | + return userTypes; |
| 53 | + } |
| 54 | + /** |
| 55 | + * @return the userStatuses |
| 56 | + */ |
| 57 | + public List<SelectItem> getUserStatuses() { |
| 58 | + if(Utils.isEmpty(userStatuses)) { |
| 59 | + userStatuses = processEnums(EnumConstants.USER_STATUS); |
| 60 | + } |
| 61 | + return userStatuses; |
| 62 | + } |
| 63 | + /** |
| 64 | + * @return the locationTypes |
| 65 | + */ |
| 66 | + public List<SelectItem> getLocationTypes() { |
| 67 | + if(Utils.isEmpty(locationTypes)) { |
| 68 | + locationTypes = processEnums(EnumConstants.LOCATION_TYPE); |
| 69 | + } |
| 70 | + return locationTypes; |
| 71 | + } |
| 72 | + /** |
| 73 | + * @return the styleTypes |
| 74 | + */ |
| 75 | + public List<SelectItem> getStyleTypes() { |
| 76 | + if(Utils.isEmpty(styleTypes)) { |
| 77 | + styleTypes = processEnums(EnumConstants.STYLE_TYPE); |
| 78 | + } |
| 79 | + return styleTypes; |
| 80 | + } |
| 81 | + /** |
| 82 | + * @return the bodyTypes |
| 83 | + */ |
| 84 | + public List<SelectItem> getBodyTypes() { |
| 85 | + if(Utils.isEmpty(bodyTypes)) { |
| 86 | + bodyTypes = processEnums(EnumConstants.BODY_TYPE); |
| 87 | + } |
| 88 | + return bodyTypes; |
| 89 | + } |
| 90 | + /** |
| 91 | + * @return the categoryTypes |
| 92 | + */ |
| 93 | + public List<SelectItem> getCategoryTypes() { |
| 94 | + if(Utils.isEmpty(categoryTypes)) { |
| 95 | + categoryTypes = processEnums(EnumConstants.CATEGORY_TYPE); |
| 96 | + } |
| 97 | + return categoryTypes; |
| 98 | + } |
| 99 | + /** |
| 100 | + * @return the fuelTypes |
| 101 | + */ |
| 102 | + public List<SelectItem> getFuelTypes() { |
| 103 | + if(Utils.isEmpty(fuelTypes)) { |
| 104 | + fuelTypes = processEnums(EnumConstants.FUEL_TYPE); |
| 105 | + } |
| 106 | + return fuelTypes; |
| 107 | + } |
| 108 | + /** |
| 109 | + * @return the warrantyTypes |
| 110 | + */ |
| 111 | + public List<SelectItem> getWarrantyTypes() { |
| 112 | + if(Utils.isEmpty(warrantyTypes)) { |
| 113 | + warrantyTypes = processEnums(EnumConstants.WARRANTY_TYPE); |
| 114 | + } |
| 115 | + return warrantyTypes; |
| 116 | + } |
| 117 | + /** |
| 118 | + * @return the vehicleStatus |
| 119 | + */ |
| 120 | + public List<SelectItem> getVehicleStatus() { |
| 121 | + if(Utils.isEmpty(vehicleStatus)) { |
| 122 | + vehicleStatus = processEnums(EnumConstants.VEHICLE_STATUS); |
| 123 | + } |
| 124 | + return vehicleStatus; |
| 125 | + } |
| 126 | + /** |
| 127 | + * @return the vehicleConditionTypes |
| 128 | + */ |
| 129 | + public List<SelectItem> getVehicleConditions() { |
| 130 | + if(Utils.isEmpty(vehicleConditions)) { |
| 131 | + vehicleConditions = processEnums(EnumConstants.VEHICLE_CONDITION); |
| 132 | + } |
| 133 | + return vehicleConditions; |
| 134 | + } |
| 135 | + /** |
| 136 | + * @return the displayTypes |
| 137 | + */ |
| 138 | + public List<SelectItem> getDisplayTypes() { |
| 139 | + if(Utils.isEmpty(displayTypes)) { |
| 140 | + displayTypes = processEnums(EnumConstants.DISPLAY_TYPE); |
| 141 | + } |
| 142 | + return displayTypes; |
| 143 | + } |
| 144 | + /** |
| 145 | + * @return the imageTypes |
| 146 | + */ |
| 147 | + public List<SelectItem> getImageTypes() { |
| 148 | + if(Utils.isEmpty(imageTypes)) { |
| 149 | + imageTypes = processEnums(EnumConstants.IMAGE_TYPE); |
| 150 | + } |
| 151 | + return imageTypes; |
| 152 | + } |
| 153 | + /** |
| 154 | + * @return the adStatuses |
| 155 | + */ |
| 156 | + public List<SelectItem> getAdStatuses() { |
| 157 | + if(Utils.isEmpty(adStatuses)) { |
| 158 | + adStatuses = processEnums(EnumConstants.AD_STATUS); |
| 159 | + } |
| 160 | + return adStatuses; |
| 161 | + } |
| 162 | + /** |
| 163 | + * @return the adUnits |
| 164 | + */ |
| 165 | + public List<SelectItem> getAdUnits() { |
| 166 | + if(Utils.isEmpty(adUnits)) { |
| 167 | + adUnits = processEnums(EnumConstants.AD_UNITS); |
| 168 | + } |
| 169 | + return adUnits; |
| 170 | + } |
| 171 | + /** |
| 172 | + * @return the loanStatuses |
| 173 | + */ |
| 174 | + public List<SelectItem> getLoanStatuses() { |
| 175 | + if(Utils.isEmpty(loanStatuses)) { |
| 176 | + loanStatuses = processEnums(EnumConstants.LOAN_STATUS); |
| 177 | + } |
| 178 | + return loanStatuses; |
| 179 | + } |
| 180 | + /** |
| 181 | + * @return the financeTypes |
| 182 | + */ |
| 183 | + public List<SelectItem> getFinanceTypes() { |
| 184 | + if(Utils.isEmpty(financeTypes)) { |
| 185 | + financeTypes = processEnums(EnumConstants.FINANCE_TYPE); |
| 186 | + } |
| 187 | + return financeTypes; |
| 188 | + } |
| 189 | + /** |
| 190 | + * @return the accountTypes |
| 191 | + */ |
| 192 | + public List<SelectItem> getAccountTypes() { |
| 193 | + if(Utils.isEmpty(accountTypes)) { |
| 194 | + accountTypes = processEnums(EnumConstants.ACCOUNT_TYPE); |
| 195 | + } |
| 196 | + return accountTypes; |
| 197 | + } |
| 198 | + /** |
| 199 | + * @return the inquiryTypes |
| 200 | + */ |
| 201 | + public List<SelectItem> getInquiryTypes() { |
| 202 | + if(Utils.isEmpty(inquiryTypes)) { |
| 203 | + inquiryTypes = processEnums(EnumConstants.INQUIRY_TYPE); |
| 204 | + } |
| 205 | + return inquiryTypes; |
| 206 | + } |
| 207 | + |
| 208 | + private List<SelectItem> processEnums(int enumType) { |
| 209 | + List<Enum> enums = dao.get(EnumType.class, enumType).getEnums(); |
| 210 | + List<SelectItem> list = new ArrayList<SelectItem>(); |
| 211 | + list.add(getDefaultSelectItem()); |
| 212 | + for(Enum e: enums) { |
| 213 | + list.add(new SelectItem(e.getEnumId(), e.getEnumValue())); |
| 214 | + } |
| 215 | + return list; |
| 216 | + } |
| 217 | + |
| 218 | + private SelectItem getDefaultSelectItem() { |
| 219 | + SelectItem si = new SelectItem("Please Select"); |
| 220 | + si.setNoSelectionOption(true); |
| 221 | + return si; |
| 222 | + } |
16 | 223 |
|
| 224 | + |
17 | 225 | } |
0 commit comments