use of com.eden.orchid.api.indexing.OrchidIndex in project Orchid by JavaEden.
the class IndexGenerator method generateIndexFiles.
private void generateIndexFiles() {
OrchidRootInternalIndex internalIndex = context.getInternalIndex();
Map<String, OrchidInternalIndex> mappedIndex = internalIndex.getAllIndexedPages();
OrchidIndex indices = new OrchidInternalIndex("indices");
// Render an page for each generator's individual index
mappedIndex.keySet().forEach(key -> {
OrchidResource resource = new JsonResource(new JSONElement(mappedIndex.get(key).toJSON()), new OrchidReference(context, "meta/" + key + ".index.json"));
OrchidPage page = new OrchidPage(resource);
page.renderRaw();
indices.addToIndex(indices.getOwnKey() + "/" + page.getReference().getPath(), page);
});
// Render full composite index page
OrchidResource compositeIndexResource = new JsonResource(new JSONElement(internalIndex.toJSON()), new OrchidReference(context, "meta/index.json"));
OrchidPage compositeIndexPage = new OrchidPage(compositeIndexResource);
compositeIndexPage.renderRaw();
indices.addToIndex(indices.getOwnKey() + "/" + compositeIndexPage.getReference().getPath(), compositeIndexPage);
// Render an index of all indices, so individual index pages can be found
OrchidResource indicesIndexResource = new JsonResource(new JSONElement(indices.toJSON()), new OrchidReference(context, "meta/indices.json"));
OrchidPage indicesPage = new OrchidPage(indicesIndexResource);
indicesPage.renderRaw();
}
use of com.eden.orchid.api.indexing.OrchidIndex in project Orchid by JavaEden.
the class OrchidGenerators method buildExternalIndex.
private void buildExternalIndex() {
this.externalIndex = new OrchidRootExternalIndex();
JSONElement externalIndexReferences = context.query("options.data.externalIndex");
if (OrchidUtils.elementIsArray(externalIndexReferences)) {
JSONArray externalIndex = (JSONArray) externalIndexReferences.getElement();
for (int i = 0; i < externalIndex.length(); i++) {
JSONObject indexJson = this.orchidResources.loadAdditionalFile(externalIndex.getString(i));
if (indexJson != null) {
OrchidIndex index = OrchidIndex.fromJSON(context, indexJson);
this.externalIndex.addChildIndex(index);
}
}
}
}
Aggregations