use of org.teiid.translator.document.Document in project teiid by teiid.
the class SwaggerBodyInputDocument method addArgument.
private void addArgument(Document document, String nis, Object payload) {
int index = nis.indexOf('/');
if (index == -1) {
if (payload instanceof Object[]) {
Object[] array = (Object[]) payload;
for (Object anObj : array) {
document.addArrayProperty(nis, anObj);
}
} else {
document.addProperty(nis, payload);
}
} else {
String childPath = nis.substring(0, index);
List<? extends Document> child = document.getChildDocuments(childPath);
String propertyName = nis.substring(index + 1);
if (child == null) {
boolean array = false;
if (childPath.endsWith("[]")) {
childPath = childPath.substring(0, childPath.length() - 2);
propertyName = nis.substring(nis.indexOf("/", index + 1) + 1);
array = true;
}
Document d = new Document(childPath, array, this);
child = document.addChildDocument(childPath, d);
}
addArgument(child.get(0), propertyName, payload);
}
}
use of org.teiid.translator.document.Document in project teiid by teiid.
the class SwaggerResponse method getNext.
public Map<String, Object> getNext() throws TranslatorException {
if (this.currentDocumentRows != null && !this.currentDocumentRows.isEmpty()) {
return this.currentDocumentRows.remove(0);
}
if (this.results.hasNext()) {
Document d = this.results.next();
List<Map<String, Object>> rows = d.flatten();
List<Map<String, Object>> mapResults = new ArrayList<Map<String, Object>>();
if (this.mapResponse && !rows.isEmpty()) {
for (String key : rows.get(0).keySet()) {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put(key, rows.get(0).get(key));
mapResults.add(map);
}
rows = mapResults;
}
this.currentDocumentRows = rows;
return getNext();
}
return null;
}
Aggregations