@@ -120,7 +120,7 @@ private int getRuntimeResourcesCount(List<RuntimeModification> runtimeModificati
120
120
int count = 0 ;
121
121
for (RuntimeModification eachModification : CollectionUtils .emptyIfNull (runtimeModifications ).stream ()
122
122
.filter (modification -> !modification .getResourceModificationType ().equals (ResourceModificationType .REMOVE ))
123
- .collect ( Collectors . toList () )) {
123
+ .toList ()) {
124
124
int newCount = ((eachModification .getEndAfterMinutes () - eachModification .getStartAfterMinutes ())
125
125
/ eachModification .getModificationFrequencyMinutes ()) * eachModification .getModificationQuantity ();
126
126
count = count + newCount ;
@@ -135,7 +135,7 @@ private void mapChildResources() {
135
135
//We will do this only for resources that have some children defined
136
136
for (ResourceDefinition parentType : allResources .values ().stream ()
137
137
.filter (resource -> !MapUtils .emptyIfNull (resource .getChildrenDistribution ()).isEmpty ())
138
- .collect ( Collectors . toList () )) {
138
+ .toList ()) {
139
139
setParentToChildrenTypes (parentType .getName (), parentType .getChildrenDistribution ().keySet ());
140
140
//For each childType-distribution expression pair
141
141
for (Map .Entry <String , String > eachChildTypeExpr : parentType .getChildrenDistribution ().entrySet ()) {
@@ -192,6 +192,8 @@ private void executeAttributeOperations() {
192
192
jelProcessor .eval (expression );
193
193
}
194
194
}));
195
+ //We also want to set the evaluated attributes at this stage
196
+ resourceModel .values ().forEach (resourceList -> resourceList .forEach (GeneratorResource ::setEvaluatedAttributes ));
195
197
}
196
198
197
199
private void setParentToChildrenTypes (String parentType , Set <String > childTypes ) {
@@ -265,14 +267,15 @@ private int getResourceLevel(String resurceType) {
265
267
*/
266
268
@ SuppressWarnings ("unused" )
267
269
public static void copyFromParent (String parentType , String attribute ) {
268
- for (GeneratorResource eachResource : resourceModel .get (ResourceModelExpressions .expressionsGlobalKey .split (":" )[1 ]).stream ()
270
+ for (GeneratorResource eachResource : resourceModel
271
+ .get (ResourceModelExpressions .expressionsGlobalKey .split (":" )[1 ]).stream ()
269
272
.filter (resource -> resource .getParentsByType ()!=null )
270
273
.filter (resource -> resource .getParentsByType ().containsKey (parentType ))
271
- .collect ( Collectors . toList () )) {
274
+ .toList ()) {
272
275
Optional <KeyValue > parentAttribute = eachResource .getParentsByType ().get (parentType ).get (0 )
273
276
.getOTelResource ().getAttributesList ().stream ()
274
277
.filter (attrKV -> attrKV .getKey ().equals (attribute )).findAny ();
275
- String attributeValue = parentAttribute .isEmpty () ? "" : parentAttribute . get ().getValue (). getStringValue ( );
278
+ String attributeValue = parentAttribute .map ( keyValue -> keyValue . getValue ().getStringValue ()). orElse ( "" );
276
279
eachResource .getOTelResourceBuilder ().addAttributes (KeyValue .newBuilder ()
277
280
.setKey (attribute )
278
281
.setValue (CommonUtils .buildAnyValue (attributeValue ))
@@ -292,11 +295,12 @@ public static void copyFromParent(String parentType, String attribute) {
292
295
*/
293
296
@ SuppressWarnings ("unused" )
294
297
public static void modifyFromParent (String parentType , String sourceAttribute , String targetAttribute , String suffixExpression ) {
295
- for (GeneratorResource eachResource : resourceModel .get (ResourceModelExpressions .expressionsGlobalKey .split (":" )[1 ])) {
298
+ for (GeneratorResource eachResource : resourceModel .get (ResourceModelExpressions
299
+ .expressionsGlobalKey .split (":" )[1 ])) {
296
300
Optional <KeyValue > parentAttribute = eachResource .getParentsByType ().get (parentType ).get (0 )
297
301
.getOTelResource ().getAttributesList ().stream ()
298
302
.filter (attrKV -> attrKV .getKey ().equals (sourceAttribute )).findAny ();
299
- String attributeValue = parentAttribute .isEmpty () ? "" : parentAttribute . get ().getValue (). getStringValue ( );
303
+ String attributeValue = parentAttribute .map ( keyValue -> keyValue . getValue ().getStringValue ()). orElse ( "" );
300
304
if (suffixExpression .length () > 0 ) {
301
305
attributeValue = attributeValue + jelProcessor .eval (suffixExpression );
302
306
}
0 commit comments