use of org.apache.geode.management.internal.cli.json.GfJsonArray in project geode by apache.
the class CommandResult method buildObjectResultOutput.
/* private */
void buildObjectResultOutput() {
try {
Table resultTable = TableBuilder.newTable();
resultTable.setColumnSeparator(" : ");
addHeaderInTable(resultTable, getGfJsonObject());
GfJsonObject content = getContent();
GfJsonArray objectsArray = content.getJSONArray(ObjectResultData.OBJECTS_ACCESSOR);
if (objectsArray != null) {
int numOfObjects = objectsArray.size();
for (int i = 0; i < numOfObjects; i++) {
GfJsonObject object = objectsArray.getJSONObject(i);
buildObjectSection(resultTable, null, object, 0);
}
}
/*
* else { // GfJsonObject jsonObject =
* content.getJSONObject(ObjectResultData.ROOT_OBJECT_ACCESSOR); //
* buildObjectSection(resultTable, null, jsonObject, 0); }
*/
addFooterInTable(resultTable, getGfJsonObject());
resultLines.addAll(resultTable.buildTableList());
} catch (GfJsonException e) {
resultLines.add("Error occurred while processing Command Result. Internal Error - Invalid Result.");
// TODO - Abhishek. Add stack trace when 'debug' is enabled. Log to LogWrapper always
} finally {
isDataBuilt = true;
}
}
use of org.apache.geode.management.internal.cli.json.GfJsonArray in project geode by apache.
the class TabularResultData method retrieveAllValues.
public List<String> retrieveAllValues(String columnName) {
List<String> values = new ArrayList<>();
try {
GfJsonArray jsonArray = contentObject.getJSONArray(columnName);
int size = jsonArray.size();
for (int i = 0; i < size; i++) {
values.add(String.valueOf(jsonArray.get(i)));
}
} catch (GfJsonException e) {
throw new ResultDataException(e.getMessage());
}
return values;
}
use of org.apache.geode.management.internal.cli.json.GfJsonArray in project geode by apache.
the class JsonUtil method getStringArray.
public static String[] getStringArray(GfJsonObject jsonObject, String byName) {
String[] stringArray = null;
try {
GfJsonArray jsonArray = jsonObject.getJSONArray(byName);
stringArray = GfJsonArray.toStringArray(jsonArray);
} catch (GfJsonException e) {
throw new ResultDataException(e.getMessage());
}
return stringArray;
}
use of org.apache.geode.management.internal.cli.json.GfJsonArray in project geode by apache.
the class JsonUtil method getList.
public static List<CliJsonSerializable> getList(GfJsonObject jsonObject, String byName) {
List<CliJsonSerializable> cliJsonSerializables = Collections.emptyList();
try {
GfJsonArray cliJsonSerializableArray = jsonObject.getJSONArray(byName);
int size = cliJsonSerializableArray.size();
if (size > 0) {
cliJsonSerializables = new ArrayList<CliJsonSerializable>();
}
for (int i = 0; i < size; i++) {
GfJsonObject cliJsonSerializableState = cliJsonSerializableArray.getJSONObject(i);
int jsId = cliJsonSerializableState.getInt(CliJsonSerializable.JSID);
CliJsonSerializable cliJsonSerializable = CliJsonSerializableFactory.getCliJsonSerializable(jsId);
cliJsonSerializable.fromJson(cliJsonSerializableState);
cliJsonSerializables.add(cliJsonSerializable);
}
} catch (GfJsonException e) {
throw new ResultDataException(e.getMessage());
}
return cliJsonSerializables;
}
use of org.apache.geode.management.internal.cli.json.GfJsonArray in project geode by apache.
the class JsonUtil method getSet.
public static Set<CliJsonSerializable> getSet(GfJsonObject jsonObject, String byName) {
Set<CliJsonSerializable> cliJsonSerializables = Collections.emptySet();
try {
GfJsonArray cliJsonSerializableArray = jsonObject.getJSONArray(byName);
int size = cliJsonSerializableArray.size();
if (size > 0) {
cliJsonSerializables = new HashSet<CliJsonSerializable>();
}
for (int i = 0; i < size; i++) {
GfJsonObject cliJsonSerializableState = cliJsonSerializableArray.getJSONObject(i);
int jsId = cliJsonSerializableState.getInt(CliJsonSerializable.JSID);
CliJsonSerializable cliJsonSerializable = CliJsonSerializableFactory.getCliJsonSerializable(jsId);
cliJsonSerializable.fromJson(cliJsonSerializableState);
cliJsonSerializables.add(cliJsonSerializable);
}
} catch (GfJsonException e) {
throw new ResultDataException(e.getMessage());
}
return cliJsonSerializables;
}
Aggregations