@@ -335,7 +335,7 @@ public boolean isIdAssigned() {
335
335
return true ;
336
336
}
337
337
338
- private void recordInternalAttribute (String propertyName , Object finalValue ) {
338
+ protected void recordInternalAttribute (String propertyName , Object finalValue ) {
339
339
if (propertyName .startsWith (INTERNAL_PROPERTY_KEY_PREFIX )) {
340
340
RequestContext context = RequestContext .get ();
341
341
String entityGuid = this .getProperty (GUID_PROPERTY_KEY , String .class );
@@ -351,4 +351,69 @@ private void recordInternalAttribute(String propertyName, Object finalValue) {
351
351
}
352
352
}
353
353
}
354
+
355
+ protected void recordInternalAttributeIncrementalAdd (String propertyName , Object value , Class cardinality ) {
356
+ if (propertyName .startsWith (INTERNAL_PROPERTY_KEY_PREFIX )) {
357
+ String entityGuid = this .getProperty (GUID_PROPERTY_KEY , String .class );
358
+
359
+ if (StringUtils .isNotEmpty (entityGuid )) {
360
+ Collection <Object > currentValues = null ;
361
+
362
+ if (cardinality == List .class ) {
363
+ currentValues = getMultiValuedProperty (propertyName , Object .class );
364
+ } else {
365
+ currentValues = getMultiValuedSetProperty (propertyName , Object .class );
366
+ }
367
+
368
+ // Assumption: This method is being called after setting the property on element,
369
+ // hence assuming currentValues is the final expected state and not adding `value` to `currentValues`
370
+
371
+ if (StringUtils .isNotEmpty (entityGuid )) {
372
+ RequestContext context = RequestContext .get ();
373
+
374
+ if (context .getAllInternalAttributesMap ().get (entityGuid ) != null ) {
375
+ context .getAllInternalAttributesMap ().get (entityGuid ).put (propertyName , currentValues );
376
+ } else {
377
+ Map <String , Object > map = new HashMap <>();
378
+ map .put (propertyName , currentValues );
379
+ context .getAllInternalAttributesMap ().put (entityGuid , map );
380
+ }
381
+ }
382
+ }
383
+ }
384
+ }
385
+
386
+ protected void recordInternalAttributeIncremental2 (String propertyName , Object value , Class cardinality ) {
387
+ if (propertyName .startsWith (INTERNAL_PROPERTY_KEY_PREFIX )) {
388
+ RequestContext context = RequestContext .get ();
389
+ String entityGuid = this .getProperty (GUID_PROPERTY_KEY , String .class );
390
+ Collection <Object > values = null ;
391
+
392
+ if (cardinality == List .class ) {
393
+ values = new ArrayList <>();
394
+ } else {
395
+ values = new HashSet <>();
396
+ }
397
+
398
+ if (StringUtils .isNotEmpty (entityGuid )) {
399
+ if (context .getAllInternalAttributesMap ().get (entityGuid ) != null ) {
400
+ Collection <Object > currentValueInRecord = (Collection ) context .getAllInternalAttributesMap ().get (entityGuid ).get (propertyName );
401
+
402
+ if (currentValueInRecord == null ) {
403
+ values .add (value );
404
+ context .getAllInternalAttributesMap ().get (entityGuid ).put (propertyName , values );
405
+ } else {
406
+ currentValueInRecord .add (value );
407
+ context .getAllInternalAttributesMap ().get (entityGuid ).put (propertyName , currentValueInRecord );
408
+ }
409
+ } else {
410
+ values .add (value );
411
+
412
+ Map <String , Object > map = new HashMap <>();
413
+ map .put (propertyName , values );
414
+ context .getAllInternalAttributesMap ().put (entityGuid , map );
415
+ }
416
+ }
417
+ }
418
+ }
354
419
}
0 commit comments