Skip to content
This repository has been archived by the owner on Mar 15, 2022. It is now read-only.

[JBEAP-6351] Help text paragraphs when adding group are swapped #320

Open
wants to merge 1 commit into
base: 2.8.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,37 +111,7 @@ public void getAttributeDescriptions(
}
}

dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {
@Override
public void onSuccess(DMRResponse result) {
ModelNode response = result.get();

if(response.isFailure())
{
Log.debug(response.toString());
onFailure(new Exception(response.getFailureDescription()));
}
else
{
LinkedList<FieldDesc> fields = new LinkedList<FieldDesc>();
ModelNode payload = response.get(RESULT);

ModelNode descriptionModel = null;
if(ModelType.LIST.equals(payload.getType()))
descriptionModel = payload.asList().get(0);
else
descriptionModel = payload;

matchSubElements(descriptionModel, fieldNames, fields);
callback.onSuccess(fields);
}
}

@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
});
dispatcher.execute(new DMRAction(operation), new DescriptionsCallback(fieldNames, callback));
}

public interface AddressCallback
Expand Down Expand Up @@ -169,45 +139,54 @@ public void getMetricDescriptions(
operation.get(OP).set(READ_RESOURCE_DESCRIPTION_OPERATION);
operation.get(LOCALE).set(getLocale());

dispatcher.execute(new DMRAction(operation), new AsyncCallback<DMRResponse>() {
@Override
public void onSuccess(DMRResponse result) {
ModelNode response = result.get();
dispatcher.execute(new DMRAction(operation), new DescriptionsCallback(attributeNames, callback));
}

private class DescriptionsCallback implements AsyncCallback<DMRResponse> {

private List<Lookup> fieldNames;
private AsyncCallback<List<FieldDesc>> callback;

if(response.isFailure())
{
Log.debug(response.toString());
onFailure(new Exception(response.getFailureDescription()));
}
else
{
LinkedList<FieldDesc> fields = new LinkedList<FieldDesc>();
public DescriptionsCallback(List<Lookup> fieldNames, AsyncCallback<List<FieldDesc>> callback) {
this.fieldNames = fieldNames;
this.callback = callback;
}

@Override
public void onSuccess(DMRResponse result) {
ModelNode response = result.get();

ModelNode payload = response.get(RESULT);

ModelNode descriptionModel = null;
if(ModelType.LIST.equals(payload.getType()))
descriptionModel = payload.asList().get(0);
else
descriptionModel = payload;
if(response.isFailure())
{
Log.debug(response.toString());
onFailure(new Exception(response.getFailureDescription()));
}
else
{
LinkedList<FieldDesc> fields = new LinkedList<FieldDesc>();

ModelNode payload = response.get(RESULT);

matchSubElements(descriptionModel, attributeNames, fields);
ModelNode descriptionModel = null;
if(ModelType.LIST.equals(payload.getType()))
descriptionModel = payload.asList().get(0);
else
descriptionModel = payload;

callback.onSuccess(fields);
}

}
matchSubElements(descriptionModel, fieldNames, fields);

@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
callback.onSuccess(getOrderedFields(fieldNames, fields));
}
});
}

}

@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
}

private static void matchSubElements(ModelNode descriptionModel, List<Lookup> fieldNames, LinkedList<FieldDesc> fields) {

Expand Down Expand Up @@ -279,4 +258,19 @@ private static void matchSubElements(ModelNode descriptionModel, List<Lookup> fi
Log.error("Failed to read help descriptionModel", e);
}
}

/**
* returns the fields in the requested order
*/
private List<FieldDesc> getOrderedFields(List<Lookup> fieldNames, List<FieldDesc> fields) {
List<FieldDesc> orderedFields = new LinkedList<>();
for (Lookup fieldName : fieldNames) {
for (FieldDesc field : fields) {
if (fieldName.getJavaName().equals(field.getRef()))
orderedFields.add(field);
}
}

return orderedFields;
}
}