2424
2525import org .jboss .hal .dmr .ModelNode ;
2626import org .jboss .hal .dmr .ModelNodeHelper ;
27- import org .jboss .hal .dmr .Property ;
2827import org .jboss .hal .meta .Metadata ;
2928import org .jboss .hal .meta .description .AttributeDescription ;
3029import org .jboss .hal .meta .description .AttributeDescriptions ;
@@ -64,7 +63,7 @@ static List<ResourceAttribute> resourceAttributes(OperationDescription operation
6463 Predicate <AttributeDescription > predicate ) {
6564 List <ResourceAttribute > resourceAttributes = new ArrayList <>();
6665 for (AttributeDescription description : operationDescription .parameters ()) {
67- if (description .simpleValueType ()) {
66+ if (description .simpleRecord ()) {
6867 AttributeDescriptions nestedDescriptions = description .valueTypeAttributeDescriptions ();
6968 for (AttributeDescription nestedDescription : nestedDescriptions ) {
7069 if (predicate .test (nestedDescription )) {
@@ -81,7 +80,7 @@ static List<ResourceAttribute> resourceAttributes(OperationDescription operation
8180 }
8281
8382 /**
84- * Collects and returns a list of resource attributes based on an existing resource.
83+ * Collects and returns a list of resource attributes based on an existing resource and its metadata .
8584 *
8685 * @param resource The model node representing the resource.
8786 * @param metadata The metadata containing resource descriptions and attribute descriptions.
@@ -91,22 +90,19 @@ static List<ResourceAttribute> resourceAttributes(OperationDescription operation
9190 static List <ResourceAttribute > resourceAttributes (ModelNode resource , Metadata metadata ,
9291 Predicate <AttributeDescription > predicate ) {
9392 List <ResourceAttribute > resourceAttributes = new ArrayList <>();
94- for (Property property : resource .asPropertyList ()) {
95- String name = property .getName ();
96- AttributeDescription description = metadata .resourceDescription ().attributes ().get (name );
97- if (description .simpleValueType ()) {
98- AttributeDescriptions nestedDescriptions = description .valueTypeAttributeDescriptions ();
99- for (AttributeDescription nestedDescription : nestedDescriptions ) {
100- if (predicate .test (nestedDescription )) {
101- ModelNode nestedValue = ModelNodeHelper .nested (resource , nestedDescription .fullyQualifiedName ());
102- resourceAttributes .add (
103- new ResourceAttribute (nestedValue , nestedDescription , metadata .securityContext ()));
93+ for (AttributeDescription ad : metadata .resourceDescription ().attributes ()) {
94+ if (ad .simpleRecord ()) {
95+ AttributeDescriptions nads = ad .valueTypeAttributeDescriptions ();
96+ for (AttributeDescription nad : nads ) {
97+ if (predicate .test (nad )) {
98+ ModelNode nestedValue = ModelNodeHelper .nested (resource , nad .fullyQualifiedName ());
99+ resourceAttributes .add (new ResourceAttribute (nestedValue , nad , metadata .securityContext ()));
104100 }
105101 }
106102 } else {
107- if (predicate .test (description )) {
108- ModelNode value = property . getValue ( );
109- resourceAttributes .add (new ResourceAttribute (value , description , metadata .securityContext ()));
103+ if (predicate .test (ad )) {
104+ ModelNode value = resource . get ( ad . name () );
105+ resourceAttributes .add (new ResourceAttribute (value , ad , metadata .securityContext ()));
110106 }
111107 }
112108 }
0 commit comments