| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.rice.kew.rule.bo; |
| 17 |
|
|
| 18 |
|
import org.apache.commons.lang.StringUtils; |
| 19 |
|
import org.kuali.rice.core.api.reflect.ObjectDefinition; |
| 20 |
|
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 21 |
|
import org.kuali.rice.core.util.ConcreteKeyValue; |
| 22 |
|
import org.kuali.rice.core.util.KeyValue; |
| 23 |
|
import org.kuali.rice.core.util.RiceKeyConstants; |
| 24 |
|
import org.kuali.rice.core.web.format.BooleanFormatter; |
| 25 |
|
import org.kuali.rice.core.web.format.CollectionFormatter; |
| 26 |
|
import org.kuali.rice.core.web.format.DateFormatter; |
| 27 |
|
import org.kuali.rice.core.web.format.Formatter; |
| 28 |
|
import org.kuali.rice.kew.exception.WorkflowServiceErrorImpl; |
| 29 |
|
import org.kuali.rice.kew.lookupable.MyColumns; |
| 30 |
|
import org.kuali.rice.kew.rule.OddSearchAttribute; |
| 31 |
|
import org.kuali.rice.kew.rule.RuleBaseValues; |
| 32 |
|
import org.kuali.rice.kew.rule.RuleExtension; |
| 33 |
|
import org.kuali.rice.kew.rule.WorkflowAttribute; |
| 34 |
|
import org.kuali.rice.kew.rule.service.RuleService; |
| 35 |
|
import org.kuali.rice.kew.rule.service.RuleTemplateService; |
| 36 |
|
import org.kuali.rice.kew.rule.web.WebRuleUtils; |
| 37 |
|
import org.kuali.rice.kew.rule.xmlrouting.GenericXMLRuleAttribute; |
| 38 |
|
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 39 |
|
import org.kuali.rice.kew.util.KEWConstants; |
| 40 |
|
import org.kuali.rice.kim.bo.Group; |
| 41 |
|
import org.kuali.rice.kim.bo.Person; |
| 42 |
|
import org.kuali.rice.kim.service.IdentityManagementService; |
| 43 |
|
import org.kuali.rice.kim.service.KIMServiceLocator; |
| 44 |
|
import org.kuali.rice.kim.service.KIMServiceLocatorInternal; |
| 45 |
|
import org.kuali.rice.kim.util.KimConstants; |
| 46 |
|
import org.kuali.rice.kns.authorization.BusinessObjectRestrictions; |
| 47 |
|
import org.kuali.rice.kns.bo.BusinessObject; |
| 48 |
|
import org.kuali.rice.kns.bo.PersistableBusinessObject; |
| 49 |
|
import org.kuali.rice.kns.exception.ValidationException; |
| 50 |
|
import org.kuali.rice.kns.lookup.HtmlData; |
| 51 |
|
import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl; |
| 52 |
|
import org.kuali.rice.kns.lookup.LookupableHelperService; |
| 53 |
|
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
| 54 |
|
import org.kuali.rice.kns.util.GlobalVariables; |
| 55 |
|
import org.kuali.rice.kns.util.KNSConstants; |
| 56 |
|
import org.kuali.rice.kns.util.ObjectUtils; |
| 57 |
|
import org.kuali.rice.kns.web.comparator.CellComparatorHelper; |
| 58 |
|
import org.kuali.rice.kns.web.struts.form.LookupForm; |
| 59 |
|
import org.kuali.rice.kns.web.ui.Column; |
| 60 |
|
import org.kuali.rice.kns.web.ui.Field; |
| 61 |
|
import org.kuali.rice.kns.web.ui.ResultRow; |
| 62 |
|
import org.kuali.rice.kns.web.ui.Row; |
| 63 |
|
|
| 64 |
|
import java.sql.Date; |
| 65 |
|
import java.util.*; |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
@author |
| 71 |
|
|
| 72 |
|
|
|
|
|
| 0% |
Uncovered Elements: 457 (457) |
Complexity: 110 |
Complexity Density: 0.36 |
|
| 73 |
|
public class RuleBaseValuesLookupableHelperServiceImpl extends KualiLookupableHelperServiceImpl { |
| 74 |
|
private List<Row> rows = new ArrayList<Row>(); |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
private LookupableHelperService ruleDelegationLookupableHelperService; |
| 78 |
|
private List<?> delegationPkNames; |
| 79 |
|
|
| 80 |
|
private static final String RULE_TEMPLATE_PROPERTY_NAME = "ruleTemplate.name"; |
| 81 |
|
private static final String RULE_ID_PROPERTY_NAME = "ruleBaseValuesId"; |
| 82 |
|
private static final String RULE_TEMPLATE_ID_PROPERTY_NAME = "ruleTemplateId"; |
| 83 |
|
private static final String ACTIVE_IND_PROPERTY_NAME = "activeInd"; |
| 84 |
|
private static final String DELEGATE_RULE_PROPERTY_NAME = "delegateRule"; |
| 85 |
|
private static final String GROUP_REVIEWER_PROPERTY_NAME = "groupReviewer"; |
| 86 |
|
private static final String GROUP_REVIEWER_NAME_PROPERTY_NAME = "groupReviewerName"; |
| 87 |
|
private static final String GROUP_REVIEWER_NAMESPACE_PROPERTY_NAME = "groupReviewerNamespace"; |
| 88 |
|
private static final String PERSON_REVIEWER_PROPERTY_NAME = "personReviewer"; |
| 89 |
|
private static final String PERSON_REVIEWER_TYPE_PROPERTY_NAME = "personReviewerType"; |
| 90 |
|
private static final String DOC_TYP_NAME_PROPERTY_NAME = "documentType.name"; |
| 91 |
|
private static final String RULE_DESC_PROPERTY_NAME = "description"; |
| 92 |
|
|
| 93 |
|
private static final String BACK_LOCATION = "backLocation"; |
| 94 |
|
private static final String DOC_FORM_KEY = "docFormKey"; |
| 95 |
|
private static final String INVALID_WORKGROUP_ERROR = "The Group Reviewer Namespace and Name combination is not valid"; |
| 96 |
|
private static final String INVALID_PERSON_ERROR = "The Person Reviewer is not valid"; |
| 97 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 98 |
0
|
@Override... |
| 99 |
|
public List<Row> getRows() { |
| 100 |
0
|
List<Row> superRows = super.getRows(); |
| 101 |
0
|
List<Row> returnRows = new ArrayList<Row>(); |
| 102 |
0
|
returnRows.addAll(superRows); |
| 103 |
0
|
returnRows.addAll(rows); |
| 104 |
0
|
return returnRows; |
| 105 |
|
} |
| 106 |
|
|
|
|
|
| 0% |
Uncovered Elements: 60 (60) |
Complexity: 10 |
Complexity Density: 0.23 |
|
| 107 |
0
|
@Override... |
| 108 |
|
public boolean checkForAdditionalFields(Map fieldValues) { |
| 109 |
0
|
String ruleTemplateNameParam = (String) fieldValues.get(RULE_TEMPLATE_PROPERTY_NAME); |
| 110 |
|
|
| 111 |
0
|
if (ruleTemplateNameParam != null && !ruleTemplateNameParam.equals("")) { |
| 112 |
0
|
rows = new ArrayList<Row>(); |
| 113 |
0
|
RuleTemplate ruleTemplate = null; |
| 114 |
|
|
| 115 |
0
|
ruleTemplate = getRuleTemplateService().findByRuleTemplateName(ruleTemplateNameParam); |
| 116 |
|
|
| 117 |
0
|
for (Object element : ruleTemplate.getActiveRuleTemplateAttributes()) { |
| 118 |
0
|
RuleTemplateAttribute ruleTemplateAttribute = (RuleTemplateAttribute) element; |
| 119 |
0
|
if (!ruleTemplateAttribute.isWorkflowAttribute()) { |
| 120 |
0
|
continue; |
| 121 |
|
} |
| 122 |
0
|
WorkflowAttribute attribute = ruleTemplateAttribute.getWorkflowAttribute(); |
| 123 |
0
|
RuleAttribute ruleAttribute = ruleTemplateAttribute.getRuleAttribute(); |
| 124 |
0
|
if (ruleAttribute.getType().equals(KEWConstants.RULE_XML_ATTRIBUTE_TYPE)) { |
| 125 |
0
|
((GenericXMLRuleAttribute) attribute).setRuleAttribute(ruleAttribute); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
|
| 129 |
0
|
List<Row> searchRows = null; |
| 130 |
0
|
if (attribute instanceof OddSearchAttribute) { |
| 131 |
0
|
searchRows = ((OddSearchAttribute) attribute).getSearchRows(); |
| 132 |
|
} else { |
| 133 |
0
|
searchRows = attribute.getRuleRows(); |
| 134 |
|
} |
| 135 |
0
|
for (Row row : searchRows) { |
| 136 |
0
|
List<Field> fields = new ArrayList<Field>(); |
| 137 |
0
|
for (Field field2 : row.getFields()) { |
| 138 |
0
|
Field field = field2; |
| 139 |
0
|
if (fieldValues.get(field.getPropertyName()) != null) { |
| 140 |
0
|
field.setPropertyValue(fieldValues.get(field.getPropertyName())); |
| 141 |
|
} |
| 142 |
0
|
fields.add(field); |
| 143 |
0
|
fieldValues.put(field.getPropertyName(), field.getPropertyValue()); |
| 144 |
|
} |
| 145 |
|
} |
| 146 |
|
|
| 147 |
0
|
if (attribute instanceof OddSearchAttribute) { |
| 148 |
0
|
((OddSearchAttribute) attribute).validateSearchData(fieldValues); |
| 149 |
|
} else { |
| 150 |
0
|
attribute.validateRuleData(fieldValues); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
0
|
if (attribute instanceof OddSearchAttribute) { |
| 154 |
0
|
searchRows = ((OddSearchAttribute) attribute).getSearchRows(); |
| 155 |
|
} else { |
| 156 |
0
|
searchRows = attribute.getRuleRows(); |
| 157 |
|
} |
| 158 |
0
|
for (Object element2 : searchRows) { |
| 159 |
0
|
Row row = (Row) element2; |
| 160 |
0
|
List<Field> fields = new ArrayList<Field>(); |
| 161 |
0
|
for (Field field : row.getFields()) { |
| 162 |
0
|
if (fieldValues.get(field.getPropertyName()) != null) { |
| 163 |
0
|
field.setPropertyValue(fieldValues.get(field.getPropertyName())); |
| 164 |
|
} |
| 165 |
0
|
fields.add(field); |
| 166 |
0
|
fieldValues.put(field.getPropertyName(), field.getPropertyValue()); |
| 167 |
|
} |
| 168 |
0
|
row.setFields(fields); |
| 169 |
0
|
rows.add(row); |
| 170 |
|
|
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
} |
| 174 |
|
|
| 175 |
0
|
return true; |
| 176 |
|
} |
| 177 |
0
|
rows.clear(); |
| 178 |
0
|
return false; |
| 179 |
|
} |
| 180 |
|
|
|
|
|
| 0% |
Uncovered Elements: 193 (193) |
Complexity: 50 |
Complexity Density: 0.37 |
|
| 181 |
0
|
@Override... |
| 182 |
|
public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) { |
| 183 |
0
|
new ArrayList(); |
| 184 |
|
|
| 185 |
0
|
String docTypeNameParam = fieldValues.get(DOC_TYP_NAME_PROPERTY_NAME); |
| 186 |
0
|
String ruleTemplateIdParam = fieldValues.get(RULE_TEMPLATE_ID_PROPERTY_NAME); |
| 187 |
0
|
String ruleTemplateNameParam = fieldValues.get(RULE_TEMPLATE_PROPERTY_NAME); |
| 188 |
0
|
String groupIdParam = fieldValues.get(GROUP_REVIEWER_PROPERTY_NAME); |
| 189 |
0
|
String groupNameParam = fieldValues.get(GROUP_REVIEWER_NAME_PROPERTY_NAME); |
| 190 |
0
|
String groupNamespaceParam = fieldValues.get(GROUP_REVIEWER_NAMESPACE_PROPERTY_NAME); |
| 191 |
0
|
String networkIdParam = fieldValues.get(PERSON_REVIEWER_PROPERTY_NAME); |
| 192 |
0
|
String userDirectiveParam = fieldValues.get(PERSON_REVIEWER_TYPE_PROPERTY_NAME); |
| 193 |
0
|
String activeParam = fieldValues.get(ACTIVE_IND_PROPERTY_NAME); |
| 194 |
0
|
String ruleIdParam = fieldValues.get(RULE_ID_PROPERTY_NAME); |
| 195 |
0
|
String ruleDescription = fieldValues.get(RULE_DESC_PROPERTY_NAME); |
| 196 |
0
|
String deleteSelection = fieldValues.get(DELEGATE_RULE_PROPERTY_NAME); |
| 197 |
|
|
| 198 |
0
|
String docTypeSearchName = null; |
| 199 |
0
|
String workflowId = null; |
| 200 |
0
|
String workgroupId = null; |
| 201 |
0
|
Long ruleTemplateId = null; |
| 202 |
0
|
Boolean isDelegateRule = null; |
| 203 |
0
|
Boolean isActive = null; |
| 204 |
0
|
Long ruleId = null; |
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
0
|
if(deleteSelection != null && !"".equals(deleteSelection.trim())) |
| 209 |
|
{ |
| 210 |
0
|
if(deleteSelection.equalsIgnoreCase("Y")) { |
| 211 |
0
|
isDelegateRule = Boolean.TRUE; |
| 212 |
|
} else { |
| 213 |
0
|
isDelegateRule = Boolean.FALSE; |
| 214 |
|
} |
| 215 |
|
} |
| 216 |
|
|
| 217 |
0
|
if (ruleIdParam != null && !"".equals(ruleIdParam.trim())) { |
| 218 |
0
|
try { |
| 219 |
0
|
ruleId = new Long(ruleIdParam.trim()); |
| 220 |
|
} catch (NumberFormatException e) { |
| 221 |
0
|
ruleId = new Long(-1); |
| 222 |
|
} |
| 223 |
|
} |
| 224 |
|
|
| 225 |
0
|
if (!activeParam.equals("")) { |
| 226 |
0
|
if (activeParam.equals("Y")) { |
| 227 |
0
|
isActive = Boolean.TRUE; |
| 228 |
|
} else { |
| 229 |
0
|
isActive = Boolean.FALSE; |
| 230 |
|
} |
| 231 |
|
} |
| 232 |
|
|
| 233 |
0
|
if (docTypeNameParam != null && !"".equals(docTypeNameParam.trim())) { |
| 234 |
0
|
docTypeSearchName = docTypeNameParam.replace('*', '%'); |
| 235 |
0
|
docTypeSearchName = "%" + docTypeSearchName.trim() + "%"; |
| 236 |
|
} |
| 237 |
|
|
| 238 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(networkIdParam)) { |
| 239 |
0
|
Person person = KIMServiceLocator.getPersonService().getPersonByPrincipalName(networkIdParam); |
| 240 |
0
|
if (person != null) { |
| 241 |
0
|
workflowId = person.getPrincipalId(); |
| 242 |
|
} |
| 243 |
|
} |
| 244 |
|
|
| 245 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(groupIdParam) || !org.apache.commons.lang.StringUtils.isEmpty(groupNameParam)) { |
| 246 |
0
|
Group group = null; |
| 247 |
0
|
if (groupIdParam != null && !"".equals(groupIdParam)) { |
| 248 |
0
|
group = getIdentityManagementService().getGroup(groupIdParam.trim()); |
| 249 |
|
} else { |
| 250 |
0
|
if (groupNamespaceParam == null) { |
| 251 |
0
|
groupNamespaceParam = KimConstants.KIM_GROUP_DEFAULT_NAMESPACE_CODE; |
| 252 |
|
} |
| 253 |
0
|
group = getIdentityManagementService().getGroupByName(groupNamespaceParam, groupNameParam.trim()); |
| 254 |
0
|
if (group == null) { |
| 255 |
0
|
GlobalVariables.getMessageMap().putError(GROUP_REVIEWER_NAMESPACE_PROPERTY_NAME, RiceKeyConstants.ERROR_CUSTOM, INVALID_WORKGROUP_ERROR); |
| 256 |
|
} else { |
| 257 |
0
|
workgroupId = group.getGroupId(); |
| 258 |
|
} |
| 259 |
|
} |
| 260 |
|
} |
| 261 |
|
|
| 262 |
0
|
Map attributes = null; |
| 263 |
0
|
MyColumns myColumns = new MyColumns(); |
| 264 |
0
|
if (ruleTemplateNameParam != null && !ruleTemplateNameParam.trim().equals("") || ruleTemplateIdParam != null && !"".equals(ruleTemplateIdParam) && !"null".equals(ruleTemplateIdParam)) { |
| 265 |
0
|
RuleTemplate ruleTemplate = null; |
| 266 |
0
|
if (ruleTemplateIdParam != null && !"".equals(ruleTemplateIdParam)) { |
| 267 |
0
|
ruleTemplateId = new Long(ruleTemplateIdParam); |
| 268 |
0
|
ruleTemplate = getRuleTemplateService().findByRuleTemplateId(ruleTemplateId); |
| 269 |
|
} else { |
| 270 |
0
|
ruleTemplate = getRuleTemplateService().findByRuleTemplateName(ruleTemplateNameParam.trim()); |
| 271 |
0
|
ruleTemplateId = new Long(ruleTemplate.getRuleTemplateId().longValue()); |
| 272 |
|
} |
| 273 |
|
|
| 274 |
0
|
attributes = new HashMap(); |
| 275 |
0
|
for (Iterator iter = ruleTemplate.getActiveRuleTemplateAttributes().iterator(); iter.hasNext();) { |
| 276 |
0
|
RuleTemplateAttribute ruleTemplateAttribute = (RuleTemplateAttribute) iter.next(); |
| 277 |
0
|
if (!ruleTemplateAttribute.isWorkflowAttribute()) { |
| 278 |
0
|
continue; |
| 279 |
|
} |
| 280 |
0
|
WorkflowAttribute attribute = (WorkflowAttribute)GlobalResourceLoader.getObject(new ObjectDefinition(ruleTemplateAttribute.getRuleAttribute().getClassName(), ruleTemplateAttribute.getRuleAttribute().getServiceNamespace())); |
| 281 |
0
|
RuleAttribute ruleAttribute = ruleTemplateAttribute.getRuleAttribute(); |
| 282 |
0
|
if (ruleAttribute.getType().equals(KEWConstants.RULE_XML_ATTRIBUTE_TYPE)) { |
| 283 |
0
|
((GenericXMLRuleAttribute) attribute).setRuleAttribute(ruleAttribute); |
| 284 |
|
} |
| 285 |
0
|
attribute.setRequired(false); |
| 286 |
0
|
List<Row> searchRows = null; |
| 287 |
0
|
long curExtId = 0; |
| 288 |
0
|
if (attribute instanceof OddSearchAttribute) { |
| 289 |
0
|
for (WorkflowServiceErrorImpl wsei : (List<WorkflowServiceErrorImpl>)((OddSearchAttribute)attribute).validateSearchData(fieldValues)) { |
| 290 |
0
|
GlobalVariables.getMessageMap().putError(wsei.getMessage(), RiceKeyConstants.ERROR_CUSTOM, wsei.getArg1()); |
| 291 |
|
} |
| 292 |
0
|
try { |
| 293 |
0
|
List<RuleExtension> curExts = ruleTemplateAttribute.getRuleExtensions(); |
| 294 |
0
|
for (Object element : curExts) { |
| 295 |
0
|
RuleExtension curExt = (RuleExtension) iter.next(); |
| 296 |
0
|
curExtId = curExt.getRuleExtensionId(); |
| 297 |
0
|
RuleBaseValues curRule = curExt.getRuleBaseValues(); |
| 298 |
0
|
attribute.validateRuleData(WebRuleUtils.getFieldMapForRuleTemplateAttribute(curRule, ruleTemplateAttribute)); |
| 299 |
|
} |
| 300 |
|
} catch (Exception e) { |
| 301 |
0
|
LOG.warn("Exception caught attempting to validate attribute data for extension id:" + curExtId + ". Reason: " + e.getCause()); |
| 302 |
|
} |
| 303 |
|
|
| 304 |
0
|
searchRows = ((OddSearchAttribute) attribute).getSearchRows(); |
| 305 |
|
} else { |
| 306 |
0
|
for (WorkflowServiceErrorImpl wsei : (List<WorkflowServiceErrorImpl>)attribute.validateRuleData(fieldValues)) { |
| 307 |
0
|
GlobalVariables.getMessageMap().putError(wsei.getMessage(), RiceKeyConstants.ERROR_CUSTOM, wsei.getArg1()); |
| 308 |
|
} |
| 309 |
|
|
| 310 |
0
|
try { |
| 311 |
0
|
List<RuleExtension> curExts = ruleTemplateAttribute.getRuleExtensions(); |
| 312 |
0
|
for (Object element : curExts) { |
| 313 |
0
|
RuleExtension curExt = (RuleExtension) iter.next(); |
| 314 |
0
|
curExtId = curExt.getRuleExtensionId(); |
| 315 |
0
|
RuleBaseValues curRule = curExt.getRuleBaseValues(); |
| 316 |
0
|
attribute.validateRuleData(WebRuleUtils.getFieldMapForRuleTemplateAttribute(curRule, ruleTemplateAttribute)); |
| 317 |
|
} |
| 318 |
|
} catch (Exception e) { |
| 319 |
0
|
LOG.warn("Exception caught attempting to validate attribute data for extension id:" + curExtId + ". Reason: " + e.getCause()); |
| 320 |
|
} |
| 321 |
|
|
| 322 |
0
|
searchRows = attribute.getRuleRows(); |
| 323 |
|
} |
| 324 |
0
|
for (Row row : searchRows) { |
| 325 |
0
|
for (Field field : row.getFields()) { |
| 326 |
0
|
if (fieldValues.get(field.getPropertyName()) != null) { |
| 327 |
0
|
String attributeParam = fieldValues.get(field.getPropertyName()); |
| 328 |
0
|
if (!attributeParam.equals("")) { |
| 329 |
0
|
if (ruleAttribute.getType().equals(KEWConstants.RULE_XML_ATTRIBUTE_TYPE)) { |
| 330 |
0
|
attributes.put(field.getPropertyName(), attributeParam.trim()); |
| 331 |
|
} else { |
| 332 |
0
|
attributes.put(field.getPropertyName(), attributeParam.trim()); |
| 333 |
|
} |
| 334 |
|
} |
| 335 |
|
} |
| 336 |
0
|
if (field.getFieldType().equals(Field.TEXT) || field.getFieldType().equals(Field.DROPDOWN) || field.getFieldType().equals(Field.DROPDOWN_REFRESH) || field.getFieldType().equals(Field.RADIO)) { |
| 337 |
0
|
if (ruleAttribute.getType().equals(KEWConstants.RULE_XML_ATTRIBUTE_TYPE)) { |
| 338 |
0
|
myColumns.getColumns().add(new ConcreteKeyValue(field.getPropertyName(), ruleTemplateAttribute.getRuleTemplateAttributeId()+"")); |
| 339 |
|
} else { |
| 340 |
0
|
myColumns.getColumns().add(new ConcreteKeyValue(field.getPropertyName(), ruleTemplateAttribute.getRuleTemplateAttributeId()+"")); |
| 341 |
|
} |
| 342 |
|
} |
| 343 |
|
} |
| 344 |
|
} |
| 345 |
|
} |
| 346 |
|
} |
| 347 |
|
|
| 348 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(ruleDescription)) { |
| 349 |
0
|
ruleDescription = ruleDescription.replace('*', '%'); |
| 350 |
0
|
ruleDescription = "%" + ruleDescription.trim() + "%"; |
| 351 |
|
} |
| 352 |
|
|
| 353 |
0
|
if (!GlobalVariables.getMessageMap().hasNoErrors()) { |
| 354 |
0
|
throw new ValidationException("errors in search criteria"); |
| 355 |
|
} |
| 356 |
|
|
| 357 |
|
|
| 358 |
0
|
Iterator rules = getRuleService().search(docTypeSearchName, ruleId, ruleTemplateId, ruleDescription, workgroupId, workflowId, isDelegateRule, isActive, attributes, userDirectiveParam).iterator(); |
| 359 |
0
|
List displayList = new ArrayList(); |
| 360 |
|
|
| 361 |
0
|
while (rules.hasNext()) { |
| 362 |
0
|
RuleBaseValues record = (RuleBaseValues) rules.next(); |
| 363 |
|
|
| 364 |
0
|
if (org.apache.commons.lang.StringUtils.isEmpty(record.getDescription())) { |
| 365 |
|
|
| 366 |
0
|
record.setDescription(""); |
| 367 |
|
} |
| 368 |
|
|
| 369 |
0
|
if (ruleTemplateNameParam != null && !ruleTemplateNameParam.trim().equals("") || ruleTemplateIdParam != null && !"".equals(ruleTemplateIdParam) && !"null".equals(ruleTemplateIdParam)) { |
| 370 |
0
|
MyColumns myNewColumns = new MyColumns(); |
| 371 |
0
|
for (KeyValue pair : myColumns.getColumns()) { |
| 372 |
0
|
final KeyValue newPair; |
| 373 |
0
|
if (record.getRuleExtensionValue(new Long(pair.getValue()), pair.getKey().toString()) != null) { |
| 374 |
0
|
newPair = new ConcreteKeyValue(pair.getKey(), record.getRuleExtensionValue(new Long(pair.getValue()), pair.getKey().toString()).getValue()); |
| 375 |
|
} else { |
| 376 |
0
|
newPair = new ConcreteKeyValue(pair.getKey(), ""); |
| 377 |
|
} |
| 378 |
0
|
myNewColumns.getColumns().add(newPair); |
| 379 |
0
|
record.getFieldValues().put(newPair.getKey(), newPair.getValue()); |
| 380 |
|
} |
| 381 |
0
|
record.setMyColumns(myNewColumns); |
| 382 |
|
} |
| 383 |
|
|
| 384 |
0
|
StringBuffer returnUrl = new StringBuffer("<a href=\""); |
| 385 |
0
|
returnUrl.append(fieldValues.get(BACK_LOCATION)).append("?methodToCall=refresh&docFormKey=").append(fieldValues.get(DOC_FORM_KEY)).append("&"); |
| 386 |
|
|
| 387 |
0
|
returnUrl.append(RULE_ID_PROPERTY_NAME); |
| 388 |
0
|
returnUrl.append("=").append(record.getRuleBaseValuesId()).append("\">return value</a>"); |
| 389 |
0
|
record.setReturnUrl(returnUrl.toString()); |
| 390 |
|
|
| 391 |
0
|
String destinationUrl = "<a href=\"Rule.do?methodToCall=report¤tRuleId=" + record.getRuleBaseValuesId() + "\">report</a>"; |
| 392 |
|
|
| 393 |
0
|
record.setDestinationUrl(destinationUrl); |
| 394 |
|
|
| 395 |
0
|
displayList.add(record); |
| 396 |
|
} |
| 397 |
0
|
return displayList; |
| 398 |
|
|
| 399 |
|
} |
| 400 |
|
|
| 401 |
|
|
| 402 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 403 |
0
|
private IdentityManagementService getIdentityManagementService() {... |
| 404 |
0
|
return KIMServiceLocator.getIdentityManagementService(); |
| 405 |
|
} |
| 406 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 407 |
0
|
private RuleTemplateService getRuleTemplateService() {... |
| 408 |
0
|
return (RuleTemplateService) KEWServiceLocator.getService(KEWServiceLocator.RULE_TEMPLATE_SERVICE); |
| 409 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 410 |
0
|
private RuleService getRuleService() {... |
| 411 |
0
|
return (RuleService) KEWServiceLocator.getService(KEWServiceLocator.RULE_SERVICE); |
| 412 |
|
} |
| 413 |
|
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 11 |
Complexity Density: 0.55 |
|
| 414 |
0
|
@Override... |
| 415 |
|
public void validateSearchParameters(Map fieldValues) { |
| 416 |
0
|
super.validateSearchParameters(fieldValues); |
| 417 |
|
|
| 418 |
|
|
| 419 |
0
|
String groupName = (String)fieldValues.get(GROUP_REVIEWER_NAME_PROPERTY_NAME); |
| 420 |
0
|
String groupNamespace = (String)fieldValues.get(GROUP_REVIEWER_NAMESPACE_PROPERTY_NAME); |
| 421 |
0
|
String principalName = (String)fieldValues.get(PERSON_REVIEWER_PROPERTY_NAME); |
| 422 |
|
|
| 423 |
0
|
if (org.apache.commons.lang.StringUtils.isEmpty(groupName) && !org.apache.commons.lang.StringUtils.isEmpty(groupNamespace)) { |
| 424 |
0
|
String attributeLabel = getDataDictionaryService().getAttributeLabel(getBusinessObjectClass(), GROUP_REVIEWER_NAME_PROPERTY_NAME); |
| 425 |
0
|
GlobalVariables.getMessageMap().putError(GROUP_REVIEWER_NAME_PROPERTY_NAME, RiceKeyConstants.ERROR_REQUIRED, attributeLabel); |
| 426 |
|
} |
| 427 |
|
|
| 428 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(groupName) && org.apache.commons.lang.StringUtils.isEmpty(groupNamespace)) { |
| 429 |
0
|
String attributeLabel = getDataDictionaryService().getAttributeLabel(getBusinessObjectClass(), GROUP_REVIEWER_NAMESPACE_PROPERTY_NAME); |
| 430 |
0
|
GlobalVariables.getMessageMap().putError(GROUP_REVIEWER_NAMESPACE_PROPERTY_NAME, RiceKeyConstants.ERROR_REQUIRED, attributeLabel); |
| 431 |
|
} |
| 432 |
|
|
| 433 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(groupName) && !org.apache.commons.lang.StringUtils.isEmpty(groupNamespace)) { |
| 434 |
0
|
Group group = KIMServiceLocator.getIdentityManagementService().getGroupByName(groupNamespace, groupName); |
| 435 |
0
|
if (group == null) { |
| 436 |
0
|
GlobalVariables.getMessageMap().putError(GROUP_REVIEWER_NAME_PROPERTY_NAME, RiceKeyConstants.ERROR_CUSTOM, INVALID_WORKGROUP_ERROR); |
| 437 |
|
} |
| 438 |
|
} |
| 439 |
|
|
| 440 |
0
|
if (!org.apache.commons.lang.StringUtils.isEmpty(principalName)) { |
| 441 |
0
|
Person person = KIMServiceLocator.getPersonService().getPersonByPrincipalName(principalName); |
| 442 |
0
|
if (person == null) { |
| 443 |
0
|
GlobalVariables.getMessageMap().putError(PERSON_REVIEWER_PROPERTY_NAME, RiceKeyConstants.ERROR_CUSTOM, INVALID_PERSON_ERROR); |
| 444 |
|
} |
| 445 |
|
} |
| 446 |
0
|
if (!GlobalVariables.getMessageMap().hasNoErrors()) { |
| 447 |
0
|
throw new ValidationException("errors in search criteria"); |
| 448 |
|
} |
| 449 |
|
} |
| 450 |
|
|
|
|
|
| 0% |
Uncovered Elements: 111 (111) |
Complexity: 24 |
Complexity Density: 0.32 |
|
| 451 |
0
|
@Override... |
| 452 |
|
public Collection performLookup(LookupForm lookupForm, |
| 453 |
|
Collection resultTable, boolean bounded) { |
| 454 |
|
|
| 455 |
|
|
| 456 |
0
|
setBackLocation((String) lookupForm.getFieldsForLookup().get(KNSConstants.BACK_LOCATION)); |
| 457 |
0
|
setDocFormKey((String) lookupForm.getFieldsForLookup().get(KNSConstants.DOC_FORM_KEY)); |
| 458 |
0
|
Collection displayList; |
| 459 |
|
|
| 460 |
|
|
| 461 |
0
|
if (bounded) { |
| 462 |
0
|
displayList = getSearchResults(lookupForm.getFieldsForLookup()); |
| 463 |
|
} |
| 464 |
|
else { |
| 465 |
0
|
displayList = getSearchResultsUnbounded(lookupForm.getFieldsForLookup()); |
| 466 |
|
} |
| 467 |
|
|
| 468 |
0
|
HashMap<String,Class> propertyTypes = new HashMap<String, Class>(); |
| 469 |
|
|
| 470 |
0
|
boolean hasReturnableRow = false; |
| 471 |
|
|
| 472 |
0
|
List returnKeys = getReturnKeys(); |
| 473 |
0
|
List pkNames = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(getBusinessObjectClass()); |
| 474 |
0
|
Person user = GlobalVariables.getUserSession().getPerson(); |
| 475 |
|
|
| 476 |
|
|
| 477 |
0
|
for (Iterator iter = displayList.iterator(); iter.hasNext();) { |
| 478 |
0
|
BusinessObject element = (BusinessObject) iter.next(); |
| 479 |
0
|
if(element instanceof PersistableBusinessObject){ |
| 480 |
0
|
lookupForm.setLookupObjectId(((PersistableBusinessObject)element).getObjectId()); |
| 481 |
|
} |
| 482 |
|
|
| 483 |
0
|
BusinessObjectRestrictions businessObjectRestrictions = getBusinessObjectAuthorizationService().getLookupResultRestrictions(element, user); |
| 484 |
|
|
| 485 |
0
|
HtmlData returnUrl = getReturnUrl(element, lookupForm, returnKeys, businessObjectRestrictions); |
| 486 |
|
|
| 487 |
0
|
String actionUrls = getActionUrls(element, pkNames, businessObjectRestrictions); |
| 488 |
|
|
| 489 |
0
|
if("".equals(actionUrls)){ |
| 490 |
0
|
actionUrls = ACTION_URLS_EMPTY; |
| 491 |
|
} |
| 492 |
|
|
| 493 |
|
|
| 494 |
0
|
boolean isRuleDelegation = (element instanceof RuleBaseValues && ((RuleBaseValues) element).getDelegateRule().booleanValue()); |
| 495 |
|
|
| 496 |
0
|
List<Column> columns = getColumns(); |
| 497 |
0
|
for (Object element2 : columns) { |
| 498 |
|
|
| 499 |
0
|
Column col = (Column) element2; |
| 500 |
0
|
Formatter formatter = col.getFormatter(); |
| 501 |
|
|
| 502 |
|
|
| 503 |
0
|
String propValue = KNSConstants.EMPTY_STRING; |
| 504 |
0
|
Object prop = null; |
| 505 |
0
|
boolean skipPropTypeCheck = false; |
| 506 |
|
|
| 507 |
0
|
if (element instanceof RuleBaseValues) { |
| 508 |
0
|
prop = ((RuleBaseValues)element).getFieldValues().get(col.getPropertyName()); |
| 509 |
0
|
skipPropTypeCheck = true; |
| 510 |
|
} |
| 511 |
0
|
if (prop == null) { |
| 512 |
0
|
prop = ObjectUtils.getPropertyValue(element, col.getPropertyName()); |
| 513 |
|
} |
| 514 |
|
|
| 515 |
|
|
| 516 |
0
|
Class propClass = propertyTypes.get(col.getPropertyName()); |
| 517 |
0
|
if ( propClass == null && !skipPropTypeCheck) { |
| 518 |
0
|
try { |
| 519 |
0
|
propClass = ObjectUtils.getPropertyType( element, col.getPropertyName(), getPersistenceStructureService() ); |
| 520 |
0
|
propertyTypes.put( col.getPropertyName(), propClass ); |
| 521 |
|
} catch (Exception e) { |
| 522 |
0
|
throw new RuntimeException("Cannot access PropertyType for property " + "'" + col.getPropertyName() + "' " + " on an instance of '" + element.getClass().getName() + "'.", e); |
| 523 |
|
} |
| 524 |
|
} |
| 525 |
|
|
| 526 |
|
|
| 527 |
0
|
if (prop != null) { |
| 528 |
|
|
| 529 |
0
|
if (prop instanceof Boolean) { |
| 530 |
0
|
formatter = new BooleanFormatter(); |
| 531 |
|
} |
| 532 |
|
|
| 533 |
|
|
| 534 |
0
|
if (prop instanceof Date) { |
| 535 |
0
|
formatter = new DateFormatter(); |
| 536 |
|
} |
| 537 |
|
|
| 538 |
|
|
| 539 |
0
|
if (prop instanceof Collection && formatter == null) { |
| 540 |
0
|
formatter = new CollectionFormatter(); |
| 541 |
|
} |
| 542 |
|
|
| 543 |
0
|
if (formatter != null) { |
| 544 |
0
|
propValue = (String) formatter.format(prop); |
| 545 |
|
} |
| 546 |
|
else { |
| 547 |
0
|
propValue = prop.toString(); |
| 548 |
|
} |
| 549 |
|
} |
| 550 |
|
|
| 551 |
|
|
| 552 |
0
|
col.setComparator(CellComparatorHelper.getAppropriateComparatorForPropertyClass(propClass)); |
| 553 |
0
|
col.setValueComparator(CellComparatorHelper.getAppropriateValueComparatorForPropertyClass(propClass)); |
| 554 |
|
|
| 555 |
0
|
propValue = maskValueIfNecessary(element.getClass(), col.getPropertyName(), propValue, businessObjectRestrictions); |
| 556 |
|
|
| 557 |
0
|
col.setPropertyValue(propValue); |
| 558 |
|
|
| 559 |
0
|
if (StringUtils.isNotBlank(propValue)) { |
| 560 |
0
|
if (RULE_ID_PROPERTY_NAME.equals(col.getPropertyName()) && isRuleDelegation) { |
| 561 |
|
|
| 562 |
0
|
List<?> delegationList = KEWServiceLocator.getRuleDelegationService().findByDelegateRuleId( |
| 563 |
|
((RuleBaseValues) element).getRuleBaseValuesId()); |
| 564 |
0
|
if (ObjectUtils.isNotNull(delegationList) && !delegationList.isEmpty()) { |
| 565 |
0
|
BusinessObject ruleDelegation = (BusinessObject) delegationList.get(0); |
| 566 |
0
|
col.setColumnAnchor(getInquiryUrl(ruleDelegation, "ruleDelegationId")); |
| 567 |
|
} else { |
| 568 |
0
|
col.setColumnAnchor(getInquiryUrl(element, col.getPropertyName())); |
| 569 |
|
} |
| 570 |
|
}else { |
| 571 |
0
|
col.setColumnAnchor(getInquiryUrl(element, col.getPropertyName())); |
| 572 |
|
} |
| 573 |
|
|
| 574 |
|
} |
| 575 |
|
} |
| 576 |
|
|
| 577 |
0
|
ResultRow row = new ResultRow(columns, returnUrl.constructCompleteHtmlTag(), actionUrls); |
| 578 |
0
|
row.setRowId(returnUrl.getName()); |
| 579 |
0
|
row.setReturnUrlHtmlData(returnUrl); |
| 580 |
|
|
| 581 |
|
|
| 582 |
0
|
if (getBusinessObjectDictionaryService().isExportable(getBusinessObjectClass())) { |
| 583 |
0
|
row.setBusinessObject(element); |
| 584 |
|
} |
| 585 |
0
|
if(element instanceof PersistableBusinessObject){ |
| 586 |
0
|
row.setObjectId((((PersistableBusinessObject)element).getObjectId())); |
| 587 |
|
} |
| 588 |
|
|
| 589 |
|
|
| 590 |
0
|
boolean rowReturnable = isResultReturnable(element); |
| 591 |
0
|
row.setRowReturnable(rowReturnable); |
| 592 |
0
|
if (rowReturnable) { |
| 593 |
0
|
hasReturnableRow = true; |
| 594 |
|
} |
| 595 |
0
|
resultTable.add(row); |
| 596 |
|
} |
| 597 |
|
|
| 598 |
0
|
lookupForm.setHasReturnableRow(hasReturnableRow); |
| 599 |
|
|
| 600 |
0
|
return displayList; |
| 601 |
|
} |
| 602 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
| 603 |
0
|
@Override... |
| 604 |
|
public List<Column> getColumns() { |
| 605 |
0
|
List<Column> columns = super.getColumns(); |
| 606 |
0
|
for (Row row : rows) { |
| 607 |
0
|
for (Field field : row.getFields()) { |
| 608 |
0
|
Column newColumn = new Column(); |
| 609 |
0
|
newColumn.setColumnTitle(field.getFieldLabel()); |
| 610 |
0
|
newColumn.setMaxLength(field.getMaxLength()); |
| 611 |
0
|
newColumn.setPropertyName(field.getPropertyName()); |
| 612 |
0
|
columns.add(newColumn); |
| 613 |
|
} |
| 614 |
|
} |
| 615 |
0
|
return columns; |
| 616 |
|
} |
| 617 |
|
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 10 |
Complexity Density: 0.56 |
|
| 618 |
0
|
@Override... |
| 619 |
|
public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, |
| 620 |
|
List pkNames) { |
| 621 |
0
|
RuleBaseValues ruleBaseValues = (RuleBaseValues)businessObject; |
| 622 |
0
|
List<HtmlData> htmlDataList = new ArrayList<HtmlData>(); |
| 623 |
0
|
if (StringUtils.isNotBlank(ruleBaseValues.getRuleTemplateName()) && StringUtils.isNotBlank(getMaintenanceDocumentTypeName())) { |
| 624 |
0
|
if (ruleBaseValues.getDelegateRule().booleanValue()) { |
| 625 |
|
|
| 626 |
0
|
List<?> delegationList = KEWServiceLocator.getRuleDelegationService().findByDelegateRuleId(ruleBaseValues.getRuleBaseValuesId()); |
| 627 |
0
|
if (ObjectUtils.isNotNull(delegationList) && !delegationList.isEmpty()) { |
| 628 |
0
|
BusinessObject ruleDelegation = (BusinessObject) delegationList.get(0); |
| 629 |
|
|
| 630 |
0
|
if (ruleDelegationLookupableHelperService == null) { |
| 631 |
0
|
ruleDelegationLookupableHelperService = KNSServiceLocatorWeb.getLookupable( |
| 632 |
|
KNSServiceLocatorWeb.getBusinessObjectDictionaryService().getLookupableID( |
| 633 |
|
ruleDelegation.getClass())).getLookupableHelperService(); |
| 634 |
0
|
if (ruleDelegationLookupableHelperService.getBusinessObjectClass() == null) { |
| 635 |
0
|
ruleDelegationLookupableHelperService.setBusinessObjectClass(ruleDelegation.getClass()); |
| 636 |
|
} |
| 637 |
0
|
delegationPkNames = getBusinessObjectMetaDataService().listPrimaryKeyFieldNames(ruleDelegation.getClass()); |
| 638 |
|
} |
| 639 |
|
|
| 640 |
0
|
htmlDataList = ruleDelegationLookupableHelperService.getCustomActionUrls(ruleDelegation, delegationPkNames); |
| 641 |
|
} |
| 642 |
|
} else { |
| 643 |
|
|
| 644 |
0
|
if (allowsMaintenanceEditAction(businessObject)) { |
| 645 |
0
|
htmlDataList.add(getUrlData(businessObject, KNSConstants.MAINTENANCE_EDIT_METHOD_TO_CALL, pkNames)); |
| 646 |
|
} |
| 647 |
0
|
if (allowsMaintenanceNewOrCopyAction()) { |
| 648 |
0
|
htmlDataList.add(getUrlData(businessObject, KNSConstants.MAINTENANCE_COPY_METHOD_TO_CALL, pkNames)); |
| 649 |
|
} |
| 650 |
|
} |
| 651 |
|
} |
| 652 |
|
|
| 653 |
0
|
return htmlDataList; |
| 654 |
|
} |
| 655 |
|
|
| 656 |
|
|
| 657 |
|
|
| 658 |
|
} |