1 56 package org.opencrx.kernel.gui.generic.servlet; 57 58 import java.io.Serializable ; 59 import java.text.DateFormat ; 60 import java.text.DecimalFormat ; 61 import java.util.ArrayList ; 62 import java.util.Collection ; 63 import java.util.HashMap ; 64 import java.util.Iterator ; 65 import java.util.List ; 66 import java.util.Locale ; 67 import java.util.Map ; 68 69 import org.opencrx.kernel.address1.cci.Addressable; 70 import org.opencrx.kernel.address1.cci.RoomAddressable; 71 import org.opencrx.kernel.building1.cci.Building; 72 import org.opencrx.kernel.contract1.cci.ContractPosition; 73 import org.opencrx.kernel.depot1.cci.BundledProductDepotPosition; 74 import org.opencrx.kernel.depot1.cci.Depot; 75 import org.opencrx.kernel.depot1.cci.DepotContract; 76 import org.opencrx.kernel.depot1.cci.DepotEntity; 77 import org.opencrx.kernel.depot1.cci.DepotPosition; 78 import org.opencrx.kernel.depot1.cci.DepotReport; 79 import org.opencrx.kernel.depot1.cci.DepotReportItem; 80 import org.opencrx.kernel.depot1.cci.ProductBundleDepotPosition; 81 import org.opencrx.kernel.depot1.cci.ProductOfferingDepotPosition; 82 import org.opencrx.kernel.product1.cci.BundledProductPosition; 83 import org.opencrx.kernel.product1.cci.Product; 84 import org.opencrx.kernel.product1.cci.ProductBundlePosition; 85 import org.opencrx.kernel.product1.cci.ProductOfferingPosition; 86 import org.opencrx.kernel.product1.cci.SelectableBundledProduct; 87 import org.opencrx.kernel.product1.cci.SelectableItem; 88 import org.opencrx.kernel.product1.cci.SelectableProductBundle; 89 import org.opencrx.kernel.product1.cci.SelectableProductConfiguration; 90 import org.openmdx.application.gui.generic.servlet.ApplicationContext; 91 import org.openmdx.application.gui.generic.servlet.Codes; 92 import org.openmdx.application.gui.generic.servlet.DefaultEvaluator; 93 import org.openmdx.application.gui.generic.servlet.ObjectReference; 94 import org.openmdx.application.log.AppLog; 95 import org.openmdx.base.accessor.jmi.cci.RefObject_1_0; 96 import org.openmdx.base.accessor.jmi.cci.RefPackage_1_0; 97 import org.openmdx.base.exception.ServiceException; 98 import org.openmdx.compatibility.base.dataprovider.cci.Orders; 99 import org.openmdx.compatibility.base.dataprovider.cci.SystemAttributes; 100 import org.openmdx.compatibility.base.naming.Path; 101 import org.openmdx.compatibility.base.query.FilterOperators; 102 103 public class Evaluator 104 extends DefaultEvaluator 105 implements Serializable { 106 107 private DateFormat getDateFormat( 109 String language 110 ) { 111 Map dateFormatters = (Map )Evaluator.cachedDateFormat.get(); 112 DateFormat dateFormat = (DateFormat )dateFormatters.get(language); 113 if(dateFormat == null) { 114 dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, new Locale (language)); 115 dateFormatters.put( 116 language, 117 dateFormat 118 ); 119 } 120 return dateFormat; 121 } 122 123 private DateFormat getTimeFormat( 125 String language 126 ) { 127 Map timeFormatters = (Map )Evaluator.cachedTimeFormat.get(); 128 DateFormat timeFormat = (DateFormat )timeFormatters.get(language); 129 if(timeFormat == null) { 130 timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, new Locale (language)); 131 timeFormatters.put( 132 language, 133 timeFormat 134 ); 135 } 136 return timeFormat; 137 } 138 139 private DecimalFormat getDecimalFormat( 141 String language 142 ) { 143 Map decimalFormatters = (Map )Evaluator.cachedDecimalFormat.get(); 144 DecimalFormat decimalFormat = (DecimalFormat )decimalFormatters.get(language); 145 if(decimalFormat == null) { 146 decimalFormat = (DecimalFormat )DecimalFormat.getInstance(new Locale (language)); 147 decimalFormatters.put( 148 language, 149 decimalFormat 150 ); 151 } 152 return decimalFormat; 153 } 154 155 public String getTitle( 157 RefObject_1_0 refObj, 158 short locale, 159 String localeAsString, 160 Codes codes 161 ) { 162 if(refObj == null) { 163 return "#NULL"; 164 } 165 if(refObj.refIsNew() || !refObj.refIsPersistent()) { 166 return "Untitled"; 167 } 168 try { 169 170 String language = localeAsString.substring(0, 2); 171 DateFormat dateFormat = this.getDateFormat(language); 172 DateFormat timeFormat = this.getTimeFormat(language); 173 DecimalFormat decimalFormat = this.getDecimalFormat(language); 174 175 if(refObj instanceof org.openmdx.base.cci.Segment) { 176 return ""; 177 } 178 else if(refObj instanceof org.opencrx.kernel.account1.cci.Account) { 179 org.opencrx.kernel.account1.cci.Account obj = (org.opencrx.kernel.account1.cci.Account)refObj; 180 return toS(obj.getFullName()); 181 } 182 else if(refObj instanceof org.opencrx.kernel.product1.cci.ProductBasePrice) { 183 org.opencrx.kernel.product1.cci.ProductBasePrice obj = (org.opencrx.kernel.product1.cci.ProductBasePrice)refObj; 184 Map currencyTexts = codes.getLongText("org:opencrx:kernel:product1:AbstractProductPrice:priceCurrency", locale, true, true); 185 try { 186 return toS(obj.getPrice() == null ? "N/A" : decimalFormat.format(obj.getPrice().doubleValue())) + " " + toS(currencyTexts.get(new Short (obj.getPriceCurrency()))); 187 } 188 catch(Exception e) { 189 return toS(obj.getPrice() == null ? "N/A" : decimalFormat.format(obj.getPrice().doubleValue())) + " N/A"; 190 } 191 } 192 else if(refObj instanceof org.opencrx.kernel.product1.cci.PriceListEntry) { 193 org.opencrx.kernel.product1.cci.PriceListEntry obj = (org.opencrx.kernel.product1.cci.PriceListEntry)refObj; 194 return toS(obj.getProductName()); 195 } 196 else if(refObj instanceof org.opencrx.kernel.activity1.cci.Activity) { 197 org.opencrx.kernel.activity1.cci.Activity obj = (org.opencrx.kernel.activity1.cci.Activity)refObj; 198 return toS(obj.getActivityNumber()) + ": " + toS(obj.getName()); 199 } 200 else if(refObj instanceof org.opencrx.kernel.activity1.cci.AddressGroupMember) { 201 return (refObj.refGetValue("address") == null ? "Untitled" : this.getTitle((RefObject_1_0)refObj.refGetValue("address"), locale, localeAsString, codes)); 202 } 203 else if(refObj instanceof org.opencrx.kernel.contract1.cci.AccountAddress) { 204 return (refObj.refGetValue("address") == null ? "Untitled" : this.getTitle((RefObject_1_0)refObj.refGetValue("address"), locale, localeAsString, codes)); 205 } 206 else if(refObj instanceof org.opencrx.kernel.address1.cci.EMailAddressable) { 207 return toS(refObj.refGetValue("emailAddress")); 208 } 209 else if(refObj instanceof org.opencrx.kernel.contract1.cci.ContractPosition) { 210 return toS(refObj.refGetValue("lineItemNumber")); 211 } 212 else if(refObj instanceof org.opencrx.kernel.product1.cci.Product) { 213 Product obj = (Product)refObj; 214 return obj.getProductNumber() == null || obj.getProductNumber().length() == 0 215 ? toS(obj.getName()) 216 : toS(obj.getName() + " / " + obj.getProductNumber()); 217 } 218 else if(refObj instanceof org.opencrx.kernel.address1.cci.PostalAddressable) { 219 String address = ""; 220 int ii = 0; 221 for(Iterator i = ((List )refObj.refGetValue("postalAddressLine")).iterator(); i.hasNext(); ii++) { 222 if(ii > 0) address += "<br />"; 223 address += toS(i.next()); 224 } 225 for(Iterator i = ((List )refObj.refGetValue("postalStreet")).iterator(); i.hasNext(); ii++) { 226 if(ii > 0) address += "<br />"; 227 address += toS(i.next()); 228 } 229 Object postalCountry = refObj.refGetValue("postalCountry"); 230 String postalCountryS = codes == null 231 ? "" + postalCountry 232 : toS(codes.getLongText("org:opencrx:kernel:address1:PostalAddressable:postalCountry", locale, true, true).get(postalCountry)); 233 return address + "<br />" + toS(refObj.refGetValue("postalCode")) + " " + toS(refObj.refGetValue("postalCity")) + "<br />" + postalCountryS; 234 } 235 else if(refObj instanceof org.opencrx.kernel.activity1.cci.MmsSlide) { 236 return toS(refObj.refGetValue("order")); 237 } 238 else if(refObj instanceof org.opencrx.kernel.address1.cci.PhoneNumberAddressable) { 239 return toS(refObj.refGetValue("phoneNumberFull")); 240 } 241 else if(refObj instanceof org.opencrx.kernel.address1.cci.RoomAddressable) { 242 RoomAddressable obj = (RoomAddressable)refObj; 243 if(refObj instanceof Addressable) { 244 Building building = ((Addressable)refObj).getBuilding(); 245 if(building == null) { 246 return toS(obj.getRoomNumber()); 247 } 248 else { 249 return this.getTitle(building, locale, localeAsString, codes) + " " + toS(obj.getRoomNumber()); 250 } 251 } 252 else { 253 return toS(obj.getRoomNumber()); 254 } 255 } 256 else if(refObj instanceof org.opencrx.kernel.generic.cci.Rating) { 257 return toS(refObj.refGetValue("ratingLevel")); 258 } 259 else if(refObj instanceof org.opencrx.kernel.account1.cci.RevenueReport) { 260 return toS(refObj.refGetValue("reportNumber")); 261 } 262 else if(refObj instanceof org.opencrx.kernel.forecast1.cci.Budget) { 263 return toS(refObj.refGetValue("underlying")); 264 } 265 else if(refObj instanceof org.opencrx.kernel.address1.cci.WebAddressable) { 266 return toS(refObj.refGetValue("webUrl")); 267 } 268 else if(refObj instanceof org.opencrx.kernel.code1.cci.CodeValueEntry) { 269 return toS(refObj.refGetValue("shortText")); 270 } 271 else if(refObj instanceof org.opencrx.kernel.generic.cci.Description) { 272 return toS(refObj.refGetValue("language")); 273 } 274 else if(refObj instanceof org.opencrx.kernel.account1.cci.Member) { 275 return (refObj.refGetValue("account") == null ? "Untitled" : this.getTitle((RefObject_1_0)refObj.refGetValue("account"), locale, localeAsString, codes)); 276 } 277 else if(refObj instanceof org.opencrx.kernel.account1.cci.ContactRelationship) { 278 return (refObj.refGetValue("toContact") == null ? "Untitled" : this.getTitle((RefObject_1_0)refObj.refGetValue("toContact"), locale, localeAsString, codes)); 279 } 280 else if(refObj instanceof org.opencrx.kernel.home1.cci.UserHome) { 281 return (refObj.refGetValue("contact") == null ? "Untitled" : this.getTitle((RefObject_1_0)refObj.refGetValue("contact"), locale, localeAsString, codes)); 282 } 283 else if(refObj instanceof org.opencrx.kernel.home1.cci.AccessHistory) { 284 return (refObj.refGetValue("reference") == null ? "Untitled" : this.getTitle((RefObject_1_0)refObj.refGetValue("reference"), locale, localeAsString, codes)); 285 } 286 else if(refObj instanceof org.opencrx.kernel.home1.cci.EMailAccount) { 287 return toS(refObj.refGetValue("eMailAddress")); 288 } 289 else if(refObj instanceof org.opencrx.kernel.home1.cci.WfProcessInstance) { 290 return (refObj.refGetValue("process") == null ? "Untitled" : this.getTitle((RefObject_1_0)refObj.refGetValue("process"), locale, localeAsString, codes) + " " + toS(refObj.refGetValue("startedOn"))); 291 } 292 else if(refObj instanceof org.opencrx.kernel.base.cci.AuditEntry) { 293 Object createdAt = refObj.refGetValue(SystemAttributes.CREATED_AT); 294 return (refObj.refGetValue(SystemAttributes.CREATED_AT) == null) ? "Untitled" : dateFormat.format(createdAt) + " " + timeFormat.format(createdAt); 295 } 296 else if(refObj instanceof org.opencrx.kernel.base.cci.Note) { 297 Object createdAt = refObj.refGetValue(SystemAttributes.CREATED_AT); 298 Object modifiedAt = refObj.refGetValue(SystemAttributes.MODIFIED_AT); 299 return "<b>" + toS(refObj.refGetValue("title")) + "</b><br /><span><b>" + toS(refObj.refGetValue(SystemAttributes.CREATED_BY)) + "</b><br />" + dateFormat.format(createdAt) + " " + timeFormat.format(createdAt) + "<br /><b>" + toS(refObj.refGetValue(SystemAttributes.MODIFIED_BY)) + "</b><br />" + dateFormat.format(modifiedAt) + " " + timeFormat.format(modifiedAt) + "</span>"; 300 } 301 else if(refObj instanceof org.opencrx.kernel.base.cci.Chart) { 302 return toS(refObj.refGetValue("description")); 303 } 304 else if(refObj instanceof org.opencrx.kernel.base.cci.TemplateReplacement) { 305 return toS(refObj.refGetValue("description")); 306 } 307 else if(refObj instanceof org.opencrx.kernel.model1.cci.Element) { 308 String title = toS(refObj.refGetValue("qualifiedName")); 309 if(title.indexOf(":") > 0) { 310 int pos = title.lastIndexOf(":"); 311 title = title.substring(pos + 1) + " (" + title.substring(0, pos) + ")"; 312 } 313 return title; 314 } 315 else if(refObj instanceof DepotEntity) { 316 DepotEntity obj = (DepotEntity)refObj; 317 return obj.getDepotEntityNumber() == null ? toS(obj.getName()) : toS(obj.getDepotEntityNumber()); 318 } 319 else if(refObj instanceof DepotContract) { 320 DepotContract obj = (DepotContract)refObj; 321 return obj.getDepotHolderNumber() == null ? toS(obj.getName()) : toS(obj.getDepotHolderNumber()); 322 } 323 else if(refObj instanceof Depot) { 324 Depot obj = (Depot)refObj; 325 return obj.getDepotNumber() == null ? toS(obj.getName()) : toS(obj.getDepotNumber()); 326 } 327 else if(refObj instanceof DepotPosition) { 328 DepotPosition obj = (DepotPosition)refObj; 329 String depotTitle = this.getTitle(obj.getDepot(), locale, localeAsString, codes); 330 return depotTitle + " / " + toS(obj.getName()); 331 } 332 else if(refObj instanceof DepotReport) { 333 DepotReport obj = (DepotReport)refObj; 334 String depotTitle = this.getTitle(obj.getDepot(), locale, localeAsString, codes); 335 return depotTitle + " / " + toS(obj.getName()); 336 } 337 else if(refObj instanceof DepotReportItem) { 338 DepotReportItem obj = (DepotReportItem)refObj; 339 return obj.getPositionName(); 340 } 341 else { 342 return super.getTitle(refObj, locale, localeAsString, codes); 343 } 344 } 345 catch(Exception e) { 346 ServiceException e0 = new ServiceException(e); 347 AppLog.warning(e0.getMessage(), e0.getCause(), 1); 348 AppLog.warning("can not evaluate. object", refObj.refMofId()); 349 return "#ERR (" + e.getMessage() + ")"; 350 } 351 } 352 353 public boolean isEnabled( 355 String uiElementName, 356 RefObject_1_0 refObj, 357 ApplicationContext context 358 ) { 359 if(refObj instanceof org.opencrx.kernel.depot1.cci.CompoundBooking) { 360 try { 361 org.opencrx.kernel.depot1.cci.CompoundBooking cb = (org.opencrx.kernel.depot1.cci.CompoundBooking)refObj; 362 boolean isPending = cb.getBookingStatus() == 1; 363 boolean isProcessed = cb.getBookingStatus() == 2; 364 boolean isReversal = cb.getBookingType() == 30; 365 if("org:opencrx:kernel:depot1:CompoundBooking:cancelCb".equals(uiElementName)) { 366 return isProcessed && !isReversal; 367 } 368 else if("org:opencrx:kernel:depot1:CompoundBooking:acceptCb".equals(uiElementName)) { 369 return isPending; 370 } 371 else if("org:opencrx:kernel:depot1:CompoundBooking:finalizeCb".equals(uiElementName)) { 372 return isPending; 373 } 374 } 375 catch(Exception e) { 376 ServiceException e0 = new ServiceException(e); 377 AppLog.warning(e0.getMessage(), e0.getCause(), 1); 378 } 379 } 380 else if(refObj instanceof org.opencrx.kernel.base.cci.TemplateEnabled) { 381 try { 382 Boolean isTemplateAsBoolean = ((org.opencrx.kernel.base.cci.TemplateEnabled)refObj).isTemplate(); 383 boolean isTemplate = isTemplateAsBoolean == null ? false : isTemplateAsBoolean.booleanValue(); 384 if("org:opencrx:kernel:base:TemplateEnabled:applyReplacements".equals(uiElementName)) { 385 return !isTemplate; 386 } 387 else if("org:opencrx:kernel:base:TemplateEnabled:createObject".equals(uiElementName)) { 388 return isTemplate; 389 } 390 else if("org:opencrx:kernel:base:TemplateEnabled:deleteObject".equals(uiElementName)) { 391 return !isTemplate; 392 } 393 } 394 catch(Exception e) { 395 ServiceException e0 = new ServiceException(e); 396 AppLog.warning(e0.getMessage(), e0.getCause(), 1); 397 } 398 } 399 return super.isEnabled( 400 uiElementName, 401 refObj, 402 context 403 ); 404 } 405 406 public String getTitleAttribute( 408 String qualifiedReferenceName 409 ) { 410 String referenceName = qualifiedReferenceName.substring(qualifiedReferenceName.lastIndexOf(":") + 1); 411 if( 412 "org:opencrx:kernel:contract1:AbstractContract:salesRep".equals(qualifiedReferenceName) || 413 "org:opencrx:kernel:contract1:AbstractContract:customer".equals(qualifiedReferenceName) || 414 "org:opencrx:kernel:activity1:Activity:assignedTo".equals(qualifiedReferenceName) || 415 "org:opencrx:kernel:activity1:FilteredActivity:assignedTo".equals(qualifiedReferenceName) || 416 "org:opencrx:kernel:activity1:FilteredActivity:activity".equals(qualifiedReferenceName) || 417 "org:opencrx:kernel:product1:PriceListEntry:product".equals(qualifiedReferenceName) || 418 "org:opencrx:kernel:home1:UserHome:contact".equals(qualifiedReferenceName) 419 ) { 420 return "p$$" + referenceName + "Title"; 427 } 428 else { 429 return super.getTitleAttribute(qualifiedReferenceName); 430 } 431 } 432 433 public int getGridRowNestingLevel( 435 RefObject_1_0 refObj 436 ) { 437 if( 438 (refObj instanceof ProductOfferingPosition || 439 refObj instanceof SelectableProductBundle) && 440 !(refObj instanceof ProductOfferingDepotPosition) 441 ) { 442 return 0; 443 } 444 else if( 445 (refObj instanceof ProductBundlePosition || 446 refObj instanceof SelectableBundledProduct) && 447 !(refObj instanceof ProductBundleDepotPosition) 448 ) { 449 return 1; 450 } 451 else if( 452 (refObj instanceof BundledProductPosition || 453 refObj instanceof SelectableProductConfiguration) && 454 !(refObj instanceof BundledProductDepotPosition) 455 ) { 456 return 2; 457 } 458 else { 459 return super.getGridRowNestingLevel(refObj); 460 } 461 } 462 463 public String getGridRowLevelId( 465 RefObject_1_0 refObj 466 ) { 467 if(refObj instanceof ContractPosition) { 468 int lineItemNumber = ((ContractPosition)refObj).getLineItemNumber(); 469 return (lineItemNumber / 100000) + "-" + ((lineItemNumber % 100000) / 100) + "-" + (lineItemNumber % 100); 470 } 471 else if(refObj instanceof SelectableItem) { 472 int itemNumber = ((SelectableItem)refObj).getItemNumber(); 473 return (itemNumber / 100000) + "-" + ((itemNumber % 100000) / 100) + "-" + (itemNumber % 100); 474 } 475 else { 476 return super.getGridRowLevelId(refObj); 477 } 478 } 479 480 public int getGridPageSize( 482 String referencedTypeName 483 ) { 484 if("org:opencrx:kernel:product1:SelectableItem".equals(referencedTypeName)) { 485 return 200; 486 } 487 else if("org:opencrx:kernel:model1:EditableOperation".equals(referencedTypeName)) { 488 return 200; 489 } 490 else if("org:opencrx:kernel:model1:EditableParameter".equals(referencedTypeName)) { 491 return 200; 492 } 493 else if("org:opencrx:kernel:model1:EditableAttribute".equals(referencedTypeName)) { 494 return 200; 495 } 496 else if("org:opencrx:kernel:model1:EditableStructureField".equals(referencedTypeName)) { 497 return 200; 498 } 499 else { 500 return super.getGridPageSize(referencedTypeName); 501 } 502 } 503 504 public List getSelectableValues( 506 ApplicationContext application, 507 RefObject_1_0 context, 508 String qualifiedFeatureName 509 ) { 510 RefPackage_1_0 rootPkg = (RefPackage_1_0)context.refOutermostPackage(); 511 Path contextIdentity = new Path(context.refMofId()); 512 if("org:opencrx:kernel:base:ExecuteWorkflowParams:workflow".equals(qualifiedFeatureName)) { 514 org.opencrx.kernel.workflow1.cci.Segment workflowSegment = 515 (org.opencrx.kernel.workflow1.cci.Segment)rootPkg.refObject( 516 "xri:@openmdx:org.opencrx.kernel.workflow1/provider/" + contextIdentity.get(2) + "/segment/" + contextIdentity.get(4) 517 ); 518 Collection wfProcesses = workflowSegment.getWfProcess(); 519 List selectableValues = new ArrayList (); 520 for(Iterator i = wfProcesses.iterator(); i.hasNext(); ) { 521 selectableValues.add( 522 new ObjectReference((org.opencrx.kernel.workflow1.cci.AbstractTask)i.next(), application) 523 ); 524 } 525 return selectableValues; 526 } 527 else if("org:opencrx:kernel:activity1:ActivityDoFollowUpParams:transition".equals(qualifiedFeatureName)) { 529 List selectableValues = null; 530 if(context instanceof org.opencrx.kernel.activity1.cci.Activity) { 531 org.opencrx.kernel.activity1.cci.Activity activity = (org.opencrx.kernel.activity1.cci.Activity)context; 532 if((activity.getActivityType() != null) && (activity.getProcessState() != null)) { 533 selectableValues = new ArrayList (); 534 org.opencrx.kernel.activity1.cci.ActivityProcess activityProcess = activity.getActivityType().getControlledBy(); 535 org.opencrx.kernel.activity1.cci.ActivityProcessState processState = activity.getProcessState(); 536 for(Iterator i = activityProcess.getTransition().iterator(); i.hasNext(); ) { 537 org.opencrx.kernel.activity1.cci.ActivityProcessTransition transition = 538 (org.opencrx.kernel.activity1.cci.ActivityProcessTransition)i.next(); 539 if(transition.getPrevState().equals(processState)) { 540 selectableValues.add( 541 new ObjectReference(transition, application) 542 ); 543 } 544 } 545 } 546 } 547 return selectableValues; 548 } 549 else if("org:opencrx:kernel:activity1:ActivityAssignToParams:resource".equals(qualifiedFeatureName)) { 551 List selectableValues = null; 552 if(context instanceof org.opencrx.kernel.activity1.cci.Activity) { 553 org.opencrx.kernel.activity1.cci.Activity activity = (org.opencrx.kernel.activity1.cci.Activity)context; 554 selectableValues = new ArrayList (); 555 for(Iterator i = activity.getAssignedResource().iterator(); i.hasNext(); ) { 556 org.opencrx.kernel.activity1.cci.ResourceAssignment resourceAssignment = 557 (org.opencrx.kernel.activity1.cci.ResourceAssignment)i.next(); 558 org.opencrx.kernel.activity1.cci.Resource resource = resourceAssignment.getResource(); 559 if(resource != null) { 560 selectableValues.add( 561 new ObjectReference(resource, application) 562 ); 563 } 564 } 565 } 566 return selectableValues; 567 } 568 else if( 571 "org:opencrx:kernel:activity1:ResourceAddWorkRecordByPeriodParams:activity".equals(qualifiedFeatureName) || 572 "org:opencrx:kernel:activity1:ResourceAddWorkRecordByDurationParams:activity".equals(qualifiedFeatureName) 573 ) { 574 List selectableValues = null; 575 if(context instanceof org.opencrx.kernel.activity1.cci.Resource) { 576 org.opencrx.kernel.activity1.cci.Resource resource = 577 (org.opencrx.kernel.activity1.cci.Resource)context; 578 org.opencrx.kernel.activity1.cci.activity1Package activityPkg = 579 (org.opencrx.kernel.activity1.cci.activity1Package)rootPkg.refPackage( 580 org.opencrx.kernel.activity1.cci.activity1Package.class.getName() 581 ); 582 org.opencrx.kernel.activity1.cci.ActivityFilter filter = activityPkg.createActivityFilter(); 583 filter.thereExistsPercentComplete( 584 FilterOperators.IS_LESS, 585 new short[]{100} 586 ); 587 filter.orderByActivityNumber( 588 Orders.DESCENDING 589 ); 590 selectableValues = new ArrayList (); 591 int count = 0; 592 for( 593 Iterator i = resource.getAssignedActivity(filter).iterator(); 594 i.hasNext() && count < 20; 595 count++ 596 ) { 597 selectableValues.add( 598 new ObjectReference((org.opencrx.kernel.activity1.cci.Activity)i.next(), application) 599 ); 600 } 601 if(count >= 20) { 603 selectableValues = null; 604 } 605 } 606 return selectableValues; 607 } 608 else { 609 return super.getSelectableValues( 610 application, 611 context, 612 qualifiedFeatureName 613 ); 614 } 615 } 616 617 private static final long serialVersionUID = 3761691203816992816L; 619 620 private static ThreadLocal cachedDateFormat = new ThreadLocal () { 621 protected synchronized Object initialValue() { 622 return new HashMap (); 623 } 624 }; 625 private static ThreadLocal cachedTimeFormat = new ThreadLocal () { 626 protected synchronized Object initialValue() { 627 return new HashMap (); 628 } 629 }; 630 private static ThreadLocal cachedDecimalFormat = new ThreadLocal () { 631 protected synchronized Object initialValue() { 632 return new HashMap (); 633 } 634 }; 635 636 } 637 638 | Popular Tags |