1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.lookup; |
17 | |
|
18 | |
import org.apache.commons.collections.CollectionUtils; |
19 | |
import org.apache.commons.lang.StringUtils; |
20 | |
import org.kuali.rice.core.util.ClassLoaderUtils; |
21 | |
import org.kuali.rice.core.util.ConcreteKeyValue; |
22 | |
import org.kuali.rice.core.util.KeyValue; |
23 | |
import org.kuali.rice.core.web.format.BooleanFormatter; |
24 | |
import org.kuali.rice.core.web.format.CollectionFormatter; |
25 | |
import org.kuali.rice.core.web.format.DateFormatter; |
26 | |
import org.kuali.rice.core.web.format.Formatter; |
27 | |
import org.kuali.rice.kew.util.KEWConstants; |
28 | |
import org.kuali.rice.kim.api.group.Group; |
29 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
30 | |
import org.kuali.rice.kim.api.type.KimType; |
31 | |
import org.kuali.rice.kim.bo.Person; |
32 | |
import org.kuali.rice.kim.bo.types.dto.AttributeDefinitionMap; |
33 | |
import org.kuali.rice.kim.impl.group.GroupBo; |
34 | |
import org.kuali.rice.kim.impl.group.GroupDao; |
35 | |
import org.kuali.rice.kim.service.KIMServiceLocatorWeb; |
36 | |
import org.kuali.rice.kim.service.support.KimTypeService; |
37 | |
import org.kuali.rice.kim.util.KIMPropertyConstants; |
38 | |
import org.kuali.rice.kim.util.KimCommonUtilsInternal; |
39 | |
import org.kuali.rice.kim.util.KimConstants; |
40 | |
import org.kuali.rice.kns.authorization.BusinessObjectRestrictions; |
41 | |
import org.kuali.rice.kns.bo.BusinessObject; |
42 | |
import org.kuali.rice.kns.bo.PersistableBusinessObject; |
43 | |
import org.kuali.rice.kns.datadictionary.AttributeDefinition; |
44 | |
import org.kuali.rice.kns.datadictionary.KimDataDictionaryAttributeDefinition; |
45 | |
import org.kuali.rice.kns.datadictionary.KimNonDataDictionaryAttributeDefinition; |
46 | |
import org.kuali.rice.kns.lookup.HtmlData; |
47 | |
import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData; |
48 | |
import org.kuali.rice.kns.lookup.keyvalues.IndicatorValuesFinder; |
49 | |
import org.kuali.rice.kns.lookup.keyvalues.KeyValuesFinder; |
50 | |
import org.kuali.rice.kns.lookup.keyvalues.KimAttributeValuesFinder; |
51 | |
import org.kuali.rice.kns.util.GlobalVariables; |
52 | |
import org.kuali.rice.kns.util.KNSConstants; |
53 | |
import org.kuali.rice.kns.util.ObjectUtils; |
54 | |
import org.kuali.rice.kns.util.UrlFactory; |
55 | |
import org.kuali.rice.kns.web.comparator.CellComparatorHelper; |
56 | |
import org.kuali.rice.kns.web.struts.form.LookupForm; |
57 | |
import org.kuali.rice.kns.web.ui.Column; |
58 | |
import org.kuali.rice.kns.web.ui.Field; |
59 | |
import org.kuali.rice.kns.web.ui.ResultRow; |
60 | |
import org.kuali.rice.kns.web.ui.Row; |
61 | |
|
62 | |
import java.sql.Date; |
63 | |
import java.util.ArrayList; |
64 | |
import java.util.Collection; |
65 | |
import java.util.Collections; |
66 | |
import java.util.Comparator; |
67 | |
import java.util.HashMap; |
68 | |
import java.util.Iterator; |
69 | |
import java.util.List; |
70 | |
import java.util.Map; |
71 | |
import java.util.Properties; |
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | 0 | public class GroupLookupableHelperServiceImpl extends KimLookupableHelperServiceImpl { |
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | 0 | private static String KIM_TYPE_ID_PROPERTY_NAME = "kimTypeId"; |
85 | 0 | private List<Row> grpRows = new ArrayList<Row>(); |
86 | 0 | private List<Row> attrRows = new ArrayList<Row>(); |
87 | |
private GroupDao groupDao; |
88 | 0 | private String typeId = ""; |
89 | |
private AttributeDefinitionMap attrDefinitions; |
90 | 0 | private Map<String, String> groupTypeValuesCache = new HashMap<String, String>(); |
91 | |
|
92 | |
@Override |
93 | |
public List<HtmlData> getCustomActionUrls(BusinessObject bo, List pkNames) { |
94 | 0 | GroupBo groupImpl = (GroupBo) bo; |
95 | 0 | List<HtmlData> anchorHtmlDataList = new ArrayList<HtmlData>(); |
96 | 0 | if(allowsNewOrCopyAction(KimConstants.KimUIConstants.KIM_GROUP_DOCUMENT_TYPE_NAME)){ |
97 | 0 | anchorHtmlDataList.add(getEditGroupUrl(groupImpl)); |
98 | |
} |
99 | 0 | return anchorHtmlDataList; |
100 | |
} |
101 | |
|
102 | |
protected HtmlData getEditGroupUrl(GroupBo groupBo) { |
103 | 0 | String href = ""; |
104 | |
|
105 | 0 | Properties parameters = new Properties(); |
106 | 0 | parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, KNSConstants.DOC_HANDLER_METHOD); |
107 | 0 | parameters.put(KNSConstants.PARAMETER_COMMAND, KEWConstants.INITIATE_COMMAND); |
108 | 0 | parameters.put(KNSConstants.DOCUMENT_TYPE_NAME, KimConstants.KimUIConstants.KIM_GROUP_DOCUMENT_TYPE_NAME); |
109 | 0 | parameters.put(KimConstants.PrimaryKeyConstants.GROUP_ID, groupBo.getId()); |
110 | 0 | if (StringUtils.isNotBlank(getReturnLocation())) { |
111 | 0 | parameters.put(KNSConstants.RETURN_LOCATION_PARAMETER, getReturnLocation()); |
112 | |
} |
113 | 0 | href = UrlFactory.parameterizeUrl(KimCommonUtilsInternal.getKimBasePath()+KimConstants.KimUIConstants.KIM_GROUP_DOCUMENT_ACTION, parameters); |
114 | |
|
115 | 0 | AnchorHtmlData anchorHtmlData = new AnchorHtmlData(href, |
116 | |
KNSConstants.DOC_HANDLER_METHOD, KNSConstants.MAINTENANCE_EDIT_METHOD_TO_CALL); |
117 | 0 | return anchorHtmlData; |
118 | |
} |
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
@Override |
127 | |
public List<GroupBo> getSearchResults(java.util.Map<String,String> fieldValues) { |
128 | 0 | List<? extends Group> groupInfoObjs = KimApiServiceLocator.getGroupService().lookupGroups(fieldValues); |
129 | 0 | List<GroupBo> groupBoList = new ArrayList<GroupBo>(); |
130 | |
|
131 | 0 | for(Group g : groupInfoObjs){ |
132 | 0 | groupBoList.add(GroupBo.from(g)); |
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
} |
138 | 0 | return groupBoList; |
139 | |
} |
140 | |
|
141 | |
@Override |
142 | |
public boolean checkForAdditionalFields(Map fieldValues) { |
143 | 0 | List<Row> attributeRows = setupAttributeRows(fieldValues); |
144 | 0 | if (attributeRows.isEmpty()) { |
145 | 0 | setAttrRows(attributeRows); |
146 | 0 | } else if (CollectionUtils.isEmpty(getAttrRows())) { |
147 | 0 | setAttrRows(attributeRows); |
148 | |
} |
149 | 0 | if (getAttrRows().size() > 0) { |
150 | 0 | return true; |
151 | |
} |
152 | 0 | return false; |
153 | |
} |
154 | |
|
155 | |
|
156 | |
@Override |
157 | |
public List<Row> getRows() { |
158 | 0 | if (getGrpRows().isEmpty()) { |
159 | 0 | List<Row> rows = super.getRows(); |
160 | 0 | List<Row> returnRows = new ArrayList<Row>(); |
161 | 0 | for (Row row : rows) { |
162 | 0 | for (int i = row.getFields().size() - 1; i >= 0; i--) { |
163 | 0 | Field field = row.getFields().get(i); |
164 | 0 | if (field.getPropertyName().equals(KIM_TYPE_ID_PROPERTY_NAME)) { |
165 | 0 | Field typeField = new Field(); |
166 | 0 | typeField.setFieldLabel("Type"); |
167 | 0 | typeField.setPropertyName(KIM_TYPE_ID_PROPERTY_NAME); |
168 | 0 | typeField.setFieldValidValues(getGroupTypeOptions()); |
169 | 0 | typeField.setFieldType(Field.DROPDOWN); |
170 | 0 | row.getFields().set(i, typeField); |
171 | |
} |
172 | |
} |
173 | 0 | returnRows.add(row); |
174 | |
} |
175 | |
|
176 | 0 | Field typeField = new Field(); |
177 | 0 | typeField.setFieldLabel("Principal Name"); |
178 | 0 | typeField.setPropertyName(KIMPropertyConstants.Person.PRINCIPAL_NAME); |
179 | 0 | typeField.setFieldType(Field.TEXT); |
180 | 0 | typeField.setMaxLength(40); |
181 | 0 | typeField.setSize(20); |
182 | 0 | typeField.setQuickFinderClassNameImpl("org.kuali.rice.kim.bo.Person"); |
183 | 0 | typeField.setFieldConversions( "principalName:principalName" ); |
184 | 0 | typeField.setLookupParameters( "principalName:principalName" ); |
185 | |
|
186 | |
|
187 | |
|
188 | 0 | List<Field> fields = (returnRows.isEmpty()) ? new ArrayList<Field>() : returnRows.get(returnRows.size() - 1).getFields(); |
189 | 0 | if (!fields.isEmpty() && fields.get(fields.size() - 1).getFieldType().equals(Field.BLANK_SPACE)) { |
190 | |
|
191 | 0 | int insertLoc = fields.size() - 1; |
192 | 0 | while (insertLoc >= 0 && fields.get(insertLoc).getFieldType().equals(Field.BLANK_SPACE)) { |
193 | 0 | insertLoc--; |
194 | |
} |
195 | 0 | fields.set(insertLoc + 1, typeField); |
196 | 0 | returnRows.get(returnRows.size() - 1).setFields(fields); |
197 | 0 | } else { |
198 | |
|
199 | 0 | int fieldLen = fields.size(); |
200 | 0 | fields = new ArrayList<Field>(); |
201 | 0 | fields.add(typeField); |
202 | 0 | for (int i = 1; i < fieldLen; i++) { |
203 | 0 | Field blankSpace = new Field(); |
204 | 0 | blankSpace.setFieldType(Field.BLANK_SPACE); |
205 | 0 | blankSpace.setPropertyName(Field.BLANK_SPACE); |
206 | 0 | fields.add(blankSpace); |
207 | |
} |
208 | 0 | returnRows.add(new Row(fields)); |
209 | |
} |
210 | |
|
211 | 0 | setGrpRows(returnRows); |
212 | |
} |
213 | 0 | if (getAttrRows().isEmpty()) { |
214 | 0 | setAttrDefinitions(new AttributeDefinitionMap()); |
215 | 0 | return getGrpRows(); |
216 | |
} |
217 | 0 | List<Row> fullRows = new ArrayList<Row>(); |
218 | 0 | fullRows.addAll(getGrpRows()); |
219 | 0 | fullRows.addAll(getAttrRows()); |
220 | 0 | return fullRows; |
221 | |
} |
222 | |
|
223 | |
|
224 | |
@Override |
225 | |
public List<Column> getColumns() { |
226 | 0 | List<Column> columns = super.getColumns(); |
227 | 0 | for (Row row : attrRows) { |
228 | 0 | for (Field field : row.getFields()) { |
229 | 0 | Column newColumn = new Column(); |
230 | 0 | newColumn.setColumnTitle(field.getFieldLabel()); |
231 | 0 | newColumn.setMaxLength(getColumnMaxLength(field.getPropertyName())); |
232 | 0 | newColumn.setPropertyName(field.getPropertyName()); |
233 | 0 | newColumn.setFormatter(field.getFormatter()); |
234 | 0 | columns.add(newColumn); |
235 | 0 | } |
236 | |
} |
237 | 0 | return columns; |
238 | |
} |
239 | |
|
240 | |
@Override |
241 | |
public Collection performLookup(LookupForm lookupForm, Collection resultTable, boolean bounded) { |
242 | 0 | setBackLocation((String) lookupForm.getFieldsForLookup().get(KNSConstants.BACK_LOCATION)); |
243 | 0 | setDocFormKey((String) lookupForm.getFieldsForLookup().get(KNSConstants.DOC_FORM_KEY)); |
244 | |
Collection displayList; |
245 | |
|
246 | |
|
247 | 0 | if (bounded) { |
248 | 0 | displayList = getSearchResults(lookupForm.getFieldsForLookup()); |
249 | |
} |
250 | |
else { |
251 | 0 | displayList = getSearchResultsUnbounded(lookupForm.getFieldsForLookup()); |
252 | |
} |
253 | |
|
254 | 0 | HashMap<String,Class> propertyTypes = new HashMap<String, Class>(); |
255 | |
|
256 | 0 | boolean hasReturnableRow = false; |
257 | |
|
258 | 0 | List returnKeys = getReturnKeys(); |
259 | 0 | List pkNames = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(getBusinessObjectClass()); |
260 | 0 | Person user = GlobalVariables.getUserSession().getPerson(); |
261 | |
|
262 | |
|
263 | 0 | for (Iterator iter = displayList.iterator(); iter.hasNext();) { |
264 | 0 | BusinessObject element = (BusinessObject) iter.next(); |
265 | 0 | if(element instanceof PersistableBusinessObject){ |
266 | 0 | lookupForm.setLookupObjectId(((PersistableBusinessObject)element).getObjectId()); |
267 | |
} |
268 | |
|
269 | 0 | BusinessObjectRestrictions businessObjectRestrictions = getBusinessObjectAuthorizationService().getLookupResultRestrictions(element, user); |
270 | |
|
271 | 0 | HtmlData returnUrl = getReturnUrl(element, lookupForm, returnKeys, businessObjectRestrictions); |
272 | |
|
273 | 0 | String actionUrls = getActionUrls(element, pkNames, businessObjectRestrictions); |
274 | |
|
275 | 0 | if("".equals(actionUrls)){ |
276 | 0 | actionUrls = ACTION_URLS_EMPTY; |
277 | |
} |
278 | |
|
279 | 0 | List<Column> columns = getColumns(); |
280 | 0 | for (Object element2 : columns) { |
281 | |
|
282 | 0 | Column col = (Column) element2; |
283 | 0 | Formatter formatter = col.getFormatter(); |
284 | |
|
285 | |
|
286 | 0 | String propValue = KNSConstants.EMPTY_STRING; |
287 | 0 | Object prop = null; |
288 | 0 | if (col.getPropertyName().matches("\\w+\\.\\d+$")) { |
289 | 0 | String id = col.getPropertyName().substring(col.getPropertyName().lastIndexOf('.') + 1); |
290 | 0 | prop = ((GroupBo)element).getGroupAttributeValueById(id); |
291 | |
} |
292 | 0 | if (prop == null) { |
293 | 0 | prop = ObjectUtils.getPropertyValue(element, col.getPropertyName()); |
294 | |
} else { |
295 | |
} |
296 | |
|
297 | |
|
298 | 0 | Class propClass = propertyTypes.get(col.getPropertyName()); |
299 | 0 | if ( propClass == null ) { |
300 | |
try { |
301 | 0 | propClass = ObjectUtils.getPropertyType( element, col.getPropertyName(), getPersistenceStructureService() ); |
302 | 0 | propertyTypes.put( col.getPropertyName(), propClass ); |
303 | 0 | } catch (Exception e) { |
304 | 0 | throw new RuntimeException("Cannot access PropertyType for property " + "'" + col.getPropertyName() + "' " + " on an instance of '" + element.getClass().getName() + "'.", e); |
305 | 0 | } |
306 | |
} |
307 | |
|
308 | |
|
309 | 0 | if (prop != null) { |
310 | |
|
311 | 0 | if (prop instanceof Boolean) { |
312 | 0 | formatter = new BooleanFormatter(); |
313 | |
} |
314 | |
|
315 | |
|
316 | 0 | if (prop instanceof Date) { |
317 | 0 | formatter = new DateFormatter(); |
318 | |
} |
319 | |
|
320 | |
|
321 | 0 | if (prop instanceof Collection && formatter == null) { |
322 | 0 | formatter = new CollectionFormatter(); |
323 | |
} |
324 | |
|
325 | 0 | if (formatter != null) { |
326 | 0 | propValue = (String) formatter.format(prop); |
327 | |
} |
328 | |
else { |
329 | 0 | propValue = prop.toString(); |
330 | 0 | if (col.getPropertyName().equals(KIM_TYPE_ID_PROPERTY_NAME)) { |
331 | 0 | propValue = groupTypeValuesCache.get(prop.toString()); |
332 | |
} |
333 | |
} |
334 | |
} |
335 | |
|
336 | |
|
337 | 0 | col.setComparator(CellComparatorHelper.getAppropriateComparatorForPropertyClass(propClass)); |
338 | 0 | col.setValueComparator(CellComparatorHelper.getAppropriateValueComparatorForPropertyClass(propClass)); |
339 | |
|
340 | 0 | propValue = maskValueIfNecessary(element.getClass(), col.getPropertyName(), propValue, businessObjectRestrictions); |
341 | |
|
342 | 0 | col.setPropertyValue(propValue); |
343 | |
|
344 | 0 | if (StringUtils.isNotBlank(propValue)) { |
345 | 0 | col.setColumnAnchor(getInquiryUrl(element, col.getPropertyName())); |
346 | |
|
347 | |
} |
348 | 0 | } |
349 | |
|
350 | 0 | ResultRow row = new ResultRow(columns, returnUrl.constructCompleteHtmlTag(), actionUrls); |
351 | 0 | row.setRowId(returnUrl.getName()); |
352 | 0 | row.setReturnUrlHtmlData(returnUrl); |
353 | |
|
354 | |
|
355 | 0 | if (getBusinessObjectDictionaryService().isExportable(getBusinessObjectClass())) { |
356 | 0 | row.setBusinessObject(element); |
357 | |
} |
358 | 0 | if(element instanceof PersistableBusinessObject){ |
359 | 0 | row.setObjectId((((PersistableBusinessObject)element).getObjectId())); |
360 | |
} |
361 | |
|
362 | |
|
363 | 0 | boolean rowReturnable = isResultReturnable(element); |
364 | 0 | row.setRowReturnable(rowReturnable); |
365 | 0 | if (rowReturnable) { |
366 | 0 | hasReturnableRow = true; |
367 | |
} |
368 | 0 | resultTable.add(row); |
369 | 0 | } |
370 | |
|
371 | 0 | lookupForm.setHasReturnableRow(hasReturnableRow); |
372 | |
|
373 | 0 | return displayList; |
374 | |
} |
375 | |
|
376 | |
private List<KeyValue> getGroupTypeOptions() { |
377 | 0 | List<KeyValue> options = new ArrayList<KeyValue>(); |
378 | 0 | options.add(new ConcreteKeyValue("", "")); |
379 | |
|
380 | 0 | Collection<KimType> kimGroupTypes = KimApiServiceLocator.getKimTypeInfoService().findAllKimTypes(); |
381 | |
|
382 | 0 | for (KimType kimType : kimGroupTypes) { |
383 | 0 | if (KimTypeLookupableHelperServiceImpl.hasGroupTypeService(kimType) && groupTypeValuesCache.get(kimType.getId()) == null) { |
384 | 0 | String value = kimType.getNamespaceCode().trim() + KNSConstants.FIELD_CONVERSION_PAIR_SEPARATOR + kimType.getName().trim(); |
385 | 0 | options.add(new ConcreteKeyValue(kimType.getId(), value)); |
386 | 0 | } |
387 | |
} |
388 | 0 | Collections.sort(options, new Comparator<KeyValue>() { |
389 | |
@Override |
390 | |
public int compare(KeyValue k1, KeyValue k2) { |
391 | 0 | return k1.getValue().compareTo(k2.getValue()); |
392 | |
} |
393 | |
}); |
394 | 0 | return options; |
395 | |
} |
396 | |
|
397 | |
private List<Row> setupAttributeRows(Map fieldValues) { |
398 | 0 | List<Row> returnRows = new ArrayList<Row>(); |
399 | 0 | for (Row row : getGrpRows()) { |
400 | 0 | Field field = row.getFields().get(0); |
401 | 0 | if (field.getPropertyName().equals(KIM_TYPE_ID_PROPERTY_NAME) && StringUtils.isNotBlank(field.getPropertyValue())) { |
402 | 0 | if (!StringUtils.isBlank(getTypeId()) || !getTypeId().equals(field.getPropertyValue())) { |
403 | 0 | setTypeId(field.getPropertyValue()); |
404 | 0 | setAttrRows(new ArrayList<Row>()); |
405 | 0 | KimType kimType = getTypeInfoService().getKimType( field.getPropertyValue() ); |
406 | 0 | KimTypeService kimTypeService = KIMServiceLocatorWeb.getKimTypeService(kimType); |
407 | 0 | AttributeDefinitionMap definitions = kimTypeService.getAttributeDefinitions(kimType.getId()); |
408 | 0 | setAttrDefinitions(definitions); |
409 | 0 | for (AttributeDefinition definition : definitions.values()) { |
410 | 0 | List<Field> fields = new ArrayList<Field>(); |
411 | 0 | Field typeField = new Field(); |
412 | |
|
413 | 0 | String attrDefnId = getAttrDefnId(definition); |
414 | 0 | typeField.setFieldLabel(definition.getLabel()); |
415 | 0 | typeField.setPropertyName(definition.getName()+"."+attrDefnId); |
416 | 0 | typeField.setPropertyValue(fieldValues.get(typeField.getPropertyName())); |
417 | 0 | if (definition.getControl().isSelect()) { |
418 | |
try { |
419 | 0 | KeyValuesFinder finder = (KeyValuesFinder) ClassLoaderUtils.getClass(definition.getControl().getValuesFinderClass()).newInstance(); |
420 | |
|
421 | 0 | if (finder instanceof KimAttributeValuesFinder) { |
422 | 0 | ((KimAttributeValuesFinder) finder).setKimTypeId(field.getPropertyValue()); |
423 | 0 | ((KimAttributeValuesFinder) finder).setKimAttributeName(definition.getName()); |
424 | |
} |
425 | 0 | typeField.setFieldValidValues(finder.getKeyValues()); |
426 | 0 | typeField.setFieldType(Field.DROPDOWN); |
427 | |
} |
428 | 0 | catch (InstantiationException e) { |
429 | 0 | throw new RuntimeException(e.getMessage()); |
430 | |
} |
431 | 0 | catch (IllegalAccessException e) { |
432 | 0 | throw new RuntimeException(e.getMessage()); |
433 | 0 | } |
434 | 0 | } else if (definition.getControl().isText()){ |
435 | 0 | typeField.setMaxLength(definition.getMaxLength()); |
436 | 0 | if (definition.getControl().getSize() != null) { |
437 | 0 | typeField.setSize(definition.getControl().getSize()); |
438 | |
} |
439 | 0 | typeField.setFieldType(Field.TEXT); |
440 | 0 | } else if (definition.getControl().isRadio()) { |
441 | |
try { |
442 | 0 | KeyValuesFinder finder = (KeyValuesFinder) ClassLoaderUtils.getClass(definition.getControl().getValuesFinderClass()).newInstance(); |
443 | 0 | typeField.setFieldValidValues(finder.getKeyValues()); |
444 | 0 | typeField.setFieldType(Field.RADIO); |
445 | |
} |
446 | 0 | catch (InstantiationException e) { |
447 | 0 | throw new RuntimeException(e.getMessage()); |
448 | |
} |
449 | 0 | catch (IllegalAccessException e) { |
450 | 0 | throw new RuntimeException(e.getMessage()); |
451 | 0 | } |
452 | 0 | } else if (definition.getControl().isCheckbox()) { |
453 | 0 | KeyValuesFinder finder = new IndicatorValuesFinder(); |
454 | 0 | typeField.setFieldValidValues(finder.getKeyValues()); |
455 | 0 | typeField.setFieldType(Field.RADIO); |
456 | |
|
457 | 0 | } else if (definition.getControl().isHidden()) { |
458 | 0 | typeField.setFieldType(Field.HIDDEN); |
459 | 0 | } else if (definition.getControl().isLookupReadonly()) { |
460 | 0 | typeField.setFieldType(Field.LOOKUP_READONLY); |
461 | 0 | } else if (definition.getControl().isTextarea()) { |
462 | 0 | typeField.setMaxLength(definition.getMaxLength()); |
463 | 0 | if (definition.getControl().getSize() != null) { |
464 | 0 | typeField.setSize(definition.getControl().getSize()); |
465 | |
} |
466 | 0 | typeField.setFieldType(Field.TEXT_AREA); |
467 | |
} |
468 | 0 | fields.add(typeField); |
469 | 0 | returnRows.add(new Row(fields)); |
470 | 0 | } |
471 | 0 | } else { |
472 | 0 | return getAttrRows(); |
473 | |
} |
474 | 0 | } else if (field.getPropertyName().equals(KIM_TYPE_ID_PROPERTY_NAME) && StringUtils.isBlank(field.getPropertyValue())) { |
475 | 0 | setTypeId(""); |
476 | |
} |
477 | 0 | } |
478 | 0 | return returnRows; |
479 | |
} |
480 | |
|
481 | |
private String getAttrDefnId(AttributeDefinition definition) { |
482 | 0 | if (definition instanceof KimDataDictionaryAttributeDefinition) { |
483 | 0 | return ((KimDataDictionaryAttributeDefinition)definition).getKimAttrDefnId(); |
484 | |
} else { |
485 | 0 | return ((KimNonDataDictionaryAttributeDefinition)definition).getKimAttrDefnId(); |
486 | |
|
487 | |
} |
488 | |
} |
489 | |
|
490 | |
public List<Row> getGrpRows() { |
491 | 0 | return this.grpRows; |
492 | |
} |
493 | |
|
494 | |
public void setGrpRows(List<Row> grpRows) { |
495 | 0 | this.grpRows = grpRows; |
496 | 0 | } |
497 | |
|
498 | |
public GroupDao getGroupDao() { |
499 | 0 | return this.groupDao; |
500 | |
} |
501 | |
|
502 | |
public void setGroupDao(GroupDao groupDao) { |
503 | 0 | this.groupDao = groupDao; |
504 | 0 | } |
505 | |
|
506 | |
public AttributeDefinitionMap getAttrDefinitions() { |
507 | 0 | return this.attrDefinitions; |
508 | |
} |
509 | |
|
510 | |
public void setAttrDefinitions(AttributeDefinitionMap attrDefinitions) { |
511 | 0 | this.attrDefinitions = attrDefinitions; |
512 | 0 | } |
513 | |
|
514 | |
public List<Row> getAttrRows() { |
515 | 0 | return this.attrRows; |
516 | |
} |
517 | |
|
518 | |
public void setAttrRows(List<Row> attrRows) { |
519 | 0 | this.attrRows = attrRows; |
520 | 0 | } |
521 | |
|
522 | |
public String getTypeId() { |
523 | 0 | return this.typeId; |
524 | |
} |
525 | |
|
526 | |
public void setTypeId(String typeId) { |
527 | 0 | this.typeId = typeId; |
528 | 0 | } |
529 | |
|
530 | |
@Override |
531 | |
public void performClear(LookupForm lookupForm) { |
532 | 0 | super.performClear(lookupForm); |
533 | 0 | this.attrRows = new ArrayList<Row>(); |
534 | 0 | } |
535 | |
|
536 | |
} |