1 24 package org.ofbiz.widget.screen; 25 26 import java.io.Serializable ; 27 import java.text.MessageFormat ; 28 import java.util.ArrayList ; 29 import java.util.Iterator ; 30 import java.util.List ; 31 import java.util.Locale ; 32 import java.util.Map ; 33 import java.util.regex.PatternSyntaxException ; 34 35 import javax.servlet.ServletContext ; 36 import javax.servlet.http.HttpSession ; 37 38 import javolution.util.FastList; 39 import javolution.util.FastMap; 40 41 import org.ofbiz.base.util.BshUtil; 42 import org.ofbiz.base.util.Debug; 43 import org.ofbiz.base.util.GeneralException; 44 import org.ofbiz.base.util.ObjectType; 45 import org.ofbiz.base.util.StringUtil; 46 import org.ofbiz.base.util.UtilProperties; 47 import org.ofbiz.base.util.UtilValidate; 48 import org.ofbiz.base.util.UtilXml; 49 import org.ofbiz.base.util.collections.FlexibleMapAccessor; 50 import org.ofbiz.base.util.collections.ResourceBundleMapWrapper; 51 import org.ofbiz.base.util.string.FlexibleStringExpander; 52 import org.ofbiz.entity.GenericValue; 53 import org.ofbiz.entity.GenericEntityException; 54 import org.ofbiz.entity.finder.ByAndFinder; 55 import org.ofbiz.entity.finder.ByConditionFinder; 56 import org.ofbiz.entity.finder.EntityFinderUtil; 57 import org.ofbiz.entity.finder.PrimaryKeyFinder; 58 import org.ofbiz.service.GenericServiceException; 59 import org.ofbiz.service.ModelService; 60 import org.w3c.dom.Element ; 61 62 63 70 public abstract class ModelScreenAction implements Serializable { 71 public static final String module = ModelScreenAction.class.getName(); 72 73 protected ModelScreen modelScreen; 74 75 public ModelScreenAction(ModelScreen modelScreen, Element actionElement) { 76 this.modelScreen = modelScreen; 77 if (Debug.verboseOn()) Debug.logVerbose("Reading Screen action with name: " + actionElement.getNodeName(), module); 78 } 79 80 public abstract void runAction(Map context) throws GeneralException; 81 82 public static List readSubActions(ModelScreen modelScreen, Element parentElement) { 83 List actions = FastList.newInstance(); 84 85 List actionElementList = UtilXml.childElementList(parentElement); 86 Iterator actionElementIter = actionElementList.iterator(); 87 while (actionElementIter.hasNext()) { 88 Element actionElement = (Element ) actionElementIter.next(); 89 if ("set".equals(actionElement.getNodeName())) { 90 actions.add(new SetField(modelScreen, actionElement)); 91 } else if ("property-map".equals(actionElement.getNodeName())) { 92 actions.add(new PropertyMap(modelScreen, actionElement)); 93 } else if ("property-to-field".equals(actionElement.getNodeName())) { 94 actions.add(new PropertyToField(modelScreen, actionElement)); 95 } else if ("script".equals(actionElement.getNodeName())) { 96 actions.add(new Script(modelScreen, actionElement)); 97 } else if ("service".equals(actionElement.getNodeName())) { 98 actions.add(new Service(modelScreen, actionElement)); 99 } else if ("entity-one".equals(actionElement.getNodeName())) { 100 actions.add(new EntityOne(modelScreen, actionElement)); 101 } else if ("entity-and".equals(actionElement.getNodeName())) { 102 actions.add(new EntityAnd(modelScreen, actionElement)); 103 } else if ("entity-condition".equals(actionElement.getNodeName())) { 104 actions.add(new EntityCondition(modelScreen, actionElement)); 105 } else if ("get-related-one".equals(actionElement.getNodeName())) { 106 actions.add(new GetRelatedOne(modelScreen, actionElement)); 107 } else if ("get-related".equals(actionElement.getNodeName())) { 108 actions.add(new GetRelated(modelScreen, actionElement)); 109 } else { 110 throw new IllegalArgumentException ("Action element not supported with name: " + actionElement.getNodeName()); 111 } 112 } 113 114 return actions; 115 } 116 117 public static void runSubActions(List actions, Map context) throws GeneralException { 118 if (actions == null) return; 119 120 Iterator actionIter = actions.iterator(); 121 while (actionIter.hasNext()) { 122 ModelScreenAction action = (ModelScreenAction) actionIter.next(); 123 if (Debug.verboseOn()) Debug.logVerbose("Running screen action " + action.getClass().getName(), module); 124 action.runAction(context); 125 } 126 } 127 128 public static class SetField extends ModelScreenAction { 129 protected FlexibleMapAccessor field; 130 protected FlexibleMapAccessor fromField; 131 protected FlexibleStringExpander valueExdr; 132 protected FlexibleStringExpander defaultExdr; 133 protected FlexibleStringExpander globalExdr; 134 protected String type; 135 protected String toScope; 136 protected String fromScope; 137 138 public SetField(ModelScreen modelScreen, Element setElement) { 139 super (modelScreen, setElement); 140 this.field = new FlexibleMapAccessor(setElement.getAttribute("field")); 141 this.fromField = new FlexibleMapAccessor(setElement.getAttribute("from-field")); 142 this.valueExdr = new FlexibleStringExpander(setElement.getAttribute("value")); 143 this.defaultExdr = new FlexibleStringExpander(setElement.getAttribute("default-value")); 144 this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global")); 145 this.type = setElement.getAttribute("type"); 146 this.toScope = setElement.getAttribute("to-scope"); 147 this.fromScope = setElement.getAttribute("from-scope"); 148 if (!this.fromField.isEmpty() && !this.valueExdr.isEmpty()) { 149 throw new IllegalArgumentException ("Cannot specify a from-field [" + setElement.getAttribute("from-field") + "] and a value [" + setElement.getAttribute("value") + "] on the set action in a screen widget"); 150 } 151 } 152 153 public void runAction(Map context) { 154 String globalStr = this.globalExdr.expandString(context); 155 boolean global = "true".equals(globalStr); 157 158 Object newValue = null; 159 if (this.fromScope != null && this.fromScope.equals("user")) { 160 if (!this.fromField.isEmpty()) { 161 HttpSession session = (HttpSession ) context.get("session"); 162 newValue = getInMemoryPersistedFromField(session, context); 163 if (Debug.verboseOn()) Debug.logVerbose("In user getting value for field from [" + this.fromField.getOriginalName() + "]: " + newValue, module); 164 } else if (!this.valueExdr.isEmpty()) { 165 newValue = this.valueExdr.expandString(context); 166 } 167 } else if (this.fromScope != null && this.fromScope.equals("application")) { 168 if (!this.fromField.isEmpty()) { 169 ServletContext servletContext = (ServletContext ) context.get("application"); 170 newValue = getInMemoryPersistedFromField(servletContext, context); 171 if (Debug.verboseOn()) Debug.logVerbose("In application getting value for field from [" + this.fromField.getOriginalName() + "]: " + newValue, module); 172 } else if (!this.valueExdr.isEmpty()) { 173 newValue = this.valueExdr.expandString(context); 174 } 175 } else { 176 if (!this.fromField.isEmpty()) { 177 newValue = this.fromField.get(context); 178 if (Debug.verboseOn()) Debug.logVerbose("In screen getting value for field from [" + this.fromField.getOriginalName() + "]: " + newValue, module); 179 } else if (!this.valueExdr.isEmpty()) { 180 newValue = this.valueExdr.expandString(context); 181 } 182 } 183 184 if (ObjectType.isEmpty(newValue) && !this.defaultExdr.isEmpty()) { 186 newValue = this.defaultExdr.expandString(context); 187 } 188 189 if (UtilValidate.isNotEmpty(this.type)) { 190 try { 191 newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, null); 192 } catch (GeneralException e) { 193 String errMsg = "Could not convert field value for the field: [" + this.field.getOriginalName() + "] to the [" + this.type + "] type for the value [" + newValue + "]: " + e.toString(); 194 Debug.logError(e, errMsg, module); 195 throw new IllegalArgumentException (errMsg); 196 } 197 } 198 199 if (this.toScope != null && this.toScope.equals("user")) { 200 String originalName = this.field.getOriginalName(); 201 List currentWidgetTrail = (List )context.get("_WIDGETTRAIL_"); 202 String newKey = ""; 203 if (currentWidgetTrail != null) { 204 newKey = StringUtil.join(currentWidgetTrail, "|"); 205 } 206 if (UtilValidate.isNotEmpty(newKey)) { 207 newKey += "|"; 208 } 209 newKey += originalName; 210 HttpSession session = (HttpSession )context.get("session"); 211 session.setAttribute(newKey, newValue); 212 if (Debug.verboseOn()) Debug.logVerbose("In user setting value for field from [" + this.field.getOriginalName() + "]: " + newValue, module); 213 } else if (this.toScope != null && this.toScope.equals("application")) { 214 String originalName = this.field.getOriginalName(); 215 List currentWidgetTrail = (List )context.get("_WIDGETTRAIL_"); 216 String newKey = ""; 217 if (currentWidgetTrail != null) { 218 newKey = StringUtil.join(currentWidgetTrail, "|"); 219 } 220 if (UtilValidate.isNotEmpty(newKey)) { 221 newKey += "|"; 222 } 223 newKey += originalName; 224 ServletContext servletContext = (ServletContext )context.get("application"); 225 servletContext.setAttribute(newKey, newValue); 226 if (Debug.verboseOn()) Debug.logVerbose("In application setting value for field from [" + this.field.getOriginalName() + "]: " + newValue, module); 227 } else { 228 if (!global) { 230 if (Debug.verboseOn()) Debug.logVerbose("In screen setting field [" + this.field.getOriginalName() + "] to value: " + newValue, module); 231 this.field.put(context, newValue); 232 } 233 } 234 235 if (global) { 236 Map globalCtx = (Map ) context.get("globalContext"); 237 if (globalCtx != null) { 238 this.field.put(globalCtx, newValue); 239 } else { 240 this.field.put(context, newValue); 241 } 242 } 243 244 Map page = (Map ) context.get("page"); 246 if (page != null) { 247 this.field.put(page, newValue); 248 } 249 } 250 251 public Object getInMemoryPersistedFromField(Object storeAgent, Map context) { 252 Object newValue = null; 253 String originalName = this.fromField.getOriginalName(); 254 List currentWidgetTrail = (List )context.get("_WIDGETTRAIL_"); 255 List trailList = new ArrayList (); 256 if (currentWidgetTrail != null) { 257 trailList.addAll(currentWidgetTrail); 258 } 259 260 for (int i=trailList.size(); i >= 0; i--) { 261 List subTrail = trailList.subList(0,i); 262 String newKey = null; 263 if (subTrail.size() > 0) 264 newKey = StringUtil.join(subTrail, "|") + "|" + originalName; 265 else 266 newKey = originalName; 267 268 if (storeAgent instanceof ServletContext ) { 269 newValue = ((ServletContext )storeAgent).getAttribute(newKey); 270 } else if (storeAgent instanceof HttpSession ) { 271 newValue = ((HttpSession )storeAgent).getAttribute(newKey); 272 } 273 if (newValue != null) { 274 break; 275 } 276 } 277 return newValue; 278 } 279 } 280 281 public static class PropertyMap extends ModelScreenAction { 282 protected FlexibleStringExpander resourceExdr; 283 protected FlexibleMapAccessor mapNameAcsr; 284 protected FlexibleStringExpander globalExdr; 285 286 public PropertyMap(ModelScreen modelScreen, Element setElement) { 287 super (modelScreen, setElement); 288 this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource")); 289 this.mapNameAcsr = new FlexibleMapAccessor(setElement.getAttribute("map-name")); 290 this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global")); 291 } 292 293 public void runAction(Map context) { 294 String globalStr = this.globalExdr.expandString(context); 295 boolean global = "true".equals(globalStr); 297 298 Locale locale = (Locale ) context.get("locale"); 299 String resource = this.resourceExdr.expandString(context, locale); 300 301 ResourceBundleMapWrapper existingPropMap = (ResourceBundleMapWrapper) this.mapNameAcsr.get(context); 302 if (existingPropMap == null) { 303 this.mapNameAcsr.put(context, UtilProperties.getResourceBundleMap(resource, locale)); 304 } else { 305 existingPropMap.addBottomResourceBundle(resource); 306 } 307 308 if (global) { 309 Map globalCtx = (Map ) context.get("globalContext"); 310 if (globalCtx != null) { 311 ResourceBundleMapWrapper globalExistingPropMap = (ResourceBundleMapWrapper) this.mapNameAcsr.get(globalCtx); 312 if (globalExistingPropMap == null) { 313 this.mapNameAcsr.put(globalCtx, UtilProperties.getResourceBundleMap(resource, locale)); 314 } else { 315 if (existingPropMap != globalExistingPropMap) { 317 globalExistingPropMap.addBottomResourceBundle(resource); 318 } 319 } 320 } 321 } 322 } 323 } 324 325 public static class PropertyToField extends ModelScreenAction { 326 327 protected FlexibleStringExpander resourceExdr; 328 protected FlexibleStringExpander propertyExdr; 329 protected FlexibleMapAccessor fieldAcsr; 330 protected FlexibleStringExpander defaultExdr; 331 protected boolean noLocale; 332 protected FlexibleMapAccessor argListAcsr; 333 protected FlexibleStringExpander globalExdr; 334 335 public PropertyToField(ModelScreen modelScreen, Element setElement) { 336 super (modelScreen, setElement); 337 this.resourceExdr = new FlexibleStringExpander(setElement.getAttribute("resource")); 338 this.propertyExdr = new FlexibleStringExpander(setElement.getAttribute("property")); 339 this.fieldAcsr = new FlexibleMapAccessor(setElement.getAttribute("field")); 340 this.defaultExdr = new FlexibleStringExpander(setElement.getAttribute("default")); 341 noLocale = "true".equals(setElement.getAttribute("no-locale")); 342 this.argListAcsr = new FlexibleMapAccessor(setElement.getAttribute("arg-list-name")); 343 this.globalExdr = new FlexibleStringExpander(setElement.getAttribute("global")); 344 } 345 346 public void runAction(Map context) { 347 351 Locale locale = (Locale ) context.get("locale"); 352 String resource = this.resourceExdr.expandString(context, locale); 353 String property = this.propertyExdr.expandString(context, locale); 354 355 String value = null; 356 if (noLocale) { 357 value = UtilProperties.getPropertyValue(resource, property); 358 } else { 359 value = UtilProperties.getMessage(resource, property, locale); 360 } 361 if (value == null || value.length() == 0) { 362 value = this.defaultExdr.expandString(context); 363 } 364 365 value = FlexibleStringExpander.expandString(value, context); 369 370 if (!argListAcsr.isEmpty()) { 371 List argList = (List ) argListAcsr.get(context); 372 if (argList != null && argList.size() > 0) { 373 value = MessageFormat.format(value, argList.toArray()); 374 } 375 } 376 377 fieldAcsr.put(context, value); 378 } 379 } 380 381 public static class Script extends ModelScreenAction { 382 protected String location; 383 384 public Script(ModelScreen modelScreen, Element scriptElement) { 385 super (modelScreen, scriptElement); 386 this.location = scriptElement.getAttribute("location"); 387 } 388 389 public void runAction(Map context) throws GeneralException { 390 if (location.endsWith(".bsh")) { 391 try { 392 BshUtil.runBshAtLocation(location, context); 393 } catch (GeneralException e) { 394 String errMsg = "Error running BSH script at location [" + location + "]: " + e.toString(); 395 throw new GeneralException(errMsg, e); 397 } 398 } else { 399 throw new GeneralException("For screen script actions the script type is not yet support for location:" + location); 400 } 401 } 402 } 403 404 public static class Service extends ModelScreenAction { 405 protected FlexibleStringExpander serviceNameExdr; 406 protected FlexibleMapAccessor resultMapNameAcsr; 407 protected FlexibleStringExpander autoFieldMapExdr; 408 protected Map fieldMap; 409 410 public Service(ModelScreen modelScreen, Element serviceElement) { 411 super (modelScreen, serviceElement); 412 this.serviceNameExdr = new FlexibleStringExpander(serviceElement.getAttribute("service-name")); 413 this.resultMapNameAcsr = UtilValidate.isNotEmpty(serviceElement.getAttribute("result-map-name")) ? new FlexibleMapAccessor(serviceElement.getAttribute("result-map-name")) : null; 414 this.autoFieldMapExdr = new FlexibleStringExpander(serviceElement.getAttribute("auto-field-map")); 415 this.fieldMap = EntityFinderUtil.makeFieldMap(serviceElement); 416 } 417 418 public void runAction(Map context) { 419 String serviceNameExpanded = this.serviceNameExdr.expandString(context); 420 if (UtilValidate.isEmpty(serviceNameExpanded)) { 421 throw new IllegalArgumentException ("Service name was empty, expanded from: " + this.serviceNameExdr.getOriginal()); 422 } 423 424 String autoFieldMapString = this.autoFieldMapExdr.expandString(context); 425 426 try { 427 Map serviceContext = null; 428 if ("true".equals(autoFieldMapString)) { 429 serviceContext = this.modelScreen.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context); 430 } else if (UtilValidate.isNotEmpty(autoFieldMapString) && !"false".equals(autoFieldMapString)) { 431 FlexibleMapAccessor fieldFma = new FlexibleMapAccessor(autoFieldMapString); 432 Map autoFieldMap = (Map ) fieldFma.get(context); 433 if (autoFieldMap != null) { 434 serviceContext = this.modelScreen.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, autoFieldMap); 435 } 436 } 437 if (serviceContext == null) { 438 serviceContext = FastMap.newInstance(); 439 } 440 441 if (this.fieldMap != null) { 442 EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, serviceContext); 443 } 444 445 Map result = this.modelScreen.getDispatcher(context).runSync(serviceNameExpanded, serviceContext); 446 447 if (this.resultMapNameAcsr != null) { 448 this.resultMapNameAcsr.put(context, result); 449 String queryString = (String )result.get("queryString"); 450 context.put("queryString", queryString); 451 context.put("queryStringMap", result.get("queryStringMap")); 452 if (UtilValidate.isNotEmpty(queryString)){ 453 try { 454 String queryStringEncoded = queryString.replaceAll("&", "%26"); 455 context.put("queryStringEncoded", queryStringEncoded); 456 } catch (PatternSyntaxException e) { 457 458 } 459 } 460 } else { 461 context.putAll(result); 462 } 463 } catch (GenericServiceException e) { 464 String errMsg = "Error calling service with name " + serviceNameExpanded + ": " + e.toString(); 465 Debug.logError(e, errMsg, module); 466 throw new IllegalArgumentException (errMsg); 467 } 468 } 469 } 470 471 public static class EntityOne extends ModelScreenAction { 472 protected PrimaryKeyFinder finder; 473 474 public EntityOne(ModelScreen modelScreen, Element entityOneElement) { 475 super (modelScreen, entityOneElement); 476 finder = new PrimaryKeyFinder(entityOneElement); 477 } 478 479 public void runAction(Map context) { 480 try { 481 finder.runFind(context, this.modelScreen.getDelegator(context)); 482 } catch (GeneralException e) { 483 String errMsg = "Error doing entity query by condition: " + e.toString(); 484 Debug.logError(e, errMsg, module); 485 throw new IllegalArgumentException (errMsg); 486 } 487 } 488 } 489 490 public static class EntityAnd extends ModelScreenAction { 491 protected ByAndFinder finder; 492 493 public EntityAnd(ModelScreen modelScreen, Element entityAndElement) { 494 super (modelScreen, entityAndElement); 495 finder = new ByAndFinder(entityAndElement); 496 } 497 498 public void runAction(Map context) { 499 try { 500 finder.runFind(context, this.modelScreen.getDelegator(context)); 501 } catch (GeneralException e) { 502 String errMsg = "Error doing entity query by condition: " + e.toString(); 503 Debug.logError(e, errMsg, module); 504 throw new IllegalArgumentException (errMsg); 505 } 506 } 507 } 508 509 public static class EntityCondition extends ModelScreenAction { 510 ByConditionFinder finder; 511 512 public EntityCondition(ModelScreen modelScreen, Element entityConditionElement) { 513 super (modelScreen, entityConditionElement); 514 finder = new ByConditionFinder(entityConditionElement); 515 } 516 517 public void runAction(Map context) { 518 try { 519 finder.runFind(context, this.modelScreen.getDelegator(context)); 520 } catch (GeneralException e) { 521 String errMsg = "Error doing entity query by condition: " + e.toString(); 522 Debug.logError(e, errMsg, module); 523 throw new IllegalArgumentException (errMsg); 524 } 525 } 526 } 527 528 public static class GetRelatedOne extends ModelScreenAction { 529 protected FlexibleMapAccessor valueNameAcsr; 530 protected FlexibleMapAccessor toValueNameAcsr; 531 protected String relationName; 532 protected boolean useCache; 533 534 public GetRelatedOne(ModelScreen modelScreen, Element getRelatedOneElement) { 535 super (modelScreen, getRelatedOneElement); 536 this.valueNameAcsr = new FlexibleMapAccessor(getRelatedOneElement.getAttribute("value-name")); 537 this.toValueNameAcsr = new FlexibleMapAccessor(getRelatedOneElement.getAttribute("to-value-name")); 538 this.relationName = getRelatedOneElement.getAttribute("relation-name"); 539 this.useCache = "true".equals(getRelatedOneElement.getAttribute("use-cache")); 540 } 541 542 public void runAction(Map context) { 543 Object valueObject = valueNameAcsr.get(context); 544 if (valueObject == null) { 545 Debug.logVerbose("Value not found with name: " + valueNameAcsr + ", not getting related...", module); 546 return; 547 } 548 if (!(valueObject instanceof GenericValue)) { 549 String errMsg = "Env variable for value-name " + valueNameAcsr.toString() + " is not a GenericValue object; for the relation-name: " + relationName + "]"; 550 Debug.logError(errMsg, module); 551 throw new IllegalArgumentException (errMsg); 552 } 553 GenericValue value = (GenericValue) valueObject; 554 try { 555 if (useCache) { 556 toValueNameAcsr.put(context, value.getRelatedOneCache(relationName)); 557 } else { 558 toValueNameAcsr.put(context, value.getRelatedOne(relationName)); 559 } 560 } catch (GenericEntityException e) { 561 String errMsg = "Problem getting related one from entity with name " + value.getEntityName() + " for the relation-name: " + relationName + ": " + e.getMessage(); 562 Debug.logError(e, errMsg, module); 563 throw new IllegalArgumentException (errMsg); 564 } 565 } 566 567 } 568 569 public static class GetRelated extends ModelScreenAction { 570 protected FlexibleMapAccessor valueNameAcsr; 571 protected FlexibleMapAccessor listNameAcsr; 572 protected FlexibleMapAccessor mapAcsr; 573 protected FlexibleMapAccessor orderByListAcsr; 574 protected String relationName; 575 protected boolean useCache; 576 577 public GetRelated(ModelScreen modelScreen, Element getRelatedElement) { 578 super (modelScreen, getRelatedElement); 579 this.valueNameAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("value-name")); 580 this.listNameAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("list-name")); 581 this.relationName = getRelatedElement.getAttribute("relation-name"); 582 this.mapAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("map-name")); 583 this.orderByListAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("order-by-list-name")); 584 this.useCache = "true".equals(getRelatedElement.getAttribute("use-cache")); 585 } 586 587 public void runAction(Map context) { 588 Object valueObject = valueNameAcsr.get(context); 589 if (valueObject == null) { 590 Debug.logVerbose("Value not found with name: " + valueNameAcsr + ", not getting related...", module); 591 return; 592 } 593 if (!(valueObject instanceof GenericValue)) { 594 String errMsg = "Env variable for value-name " + valueNameAcsr.toString() + " is not a GenericValue object; for the relation-name: " + relationName + "]"; 595 Debug.logError(errMsg, module); 596 throw new IllegalArgumentException (errMsg); 597 } 598 GenericValue value = (GenericValue) valueObject; 599 List orderByNames = null; 600 if (!orderByListAcsr.isEmpty()) { 601 orderByNames = (List ) orderByListAcsr.get(context); 602 } 603 Map constraintMap = null; 604 if (!mapAcsr.isEmpty()) { 605 constraintMap = (Map ) mapAcsr.get(context); 606 } 607 try { 608 if (useCache) { 609 listNameAcsr.put(context, value.getRelatedCache(relationName, constraintMap, orderByNames)); 610 } else { 611 listNameAcsr.put(context, value.getRelated(relationName, constraintMap, orderByNames)); 612 } 613 } catch (GenericEntityException e) { 614 String errMsg = "Problem getting related from entity with name " + value.getEntityName() + " for the relation-name: " + relationName + ": " + e.getMessage(); 615 Debug.logError(e, errMsg, module); 616 throw new IllegalArgumentException (errMsg); 617 } 618 } 619 } 620 621 } 622 | Popular Tags |