use of com.eden.orchid.impl.indexing.OrchidExternalIndex in project Orchid by JavaEden.
the class OrchidIndex method fromJSON.
public static OrchidIndex fromJSON(OrchidContext context, JSONObject source) {
OrchidExternalIndex index = new OrchidExternalIndex(source.getString("ownKey"));
if (source.has("ownPages")) {
JSONArray ownPagesJson = source.getJSONArray("ownPages");
List<OrchidPage> ownPages = new ArrayList<>();
for (int i = 0; i < ownPagesJson.length(); i++) {
OrchidPage externalPage = OrchidPage.fromJSON(context, ownPagesJson.getJSONObject(i));
ownPages.add(externalPage);
}
index.ownPages = ownPages;
}
if (source.has("childrenPages")) {
JSONObject childrenPagesJson = source.getJSONObject("childrenPages");
Map<String, OrchidIndex> childrenPages = new HashMap<>();
for (String key : childrenPagesJson.keySet()) {
OrchidIndex childIndex = OrchidIndex.fromJSON(context, childrenPagesJson.getJSONObject(key));
childrenPages.put(key, childIndex);
}
index.childrenPages = childrenPages;
}
return index;
}
Aggregations