use of de.herrlock.manga.index.entity.Index in project Manga by herrlock.
the class Indexer method createIndex.
public static Index createIndex(final IndexerConfiguration conf) {
logger.traceEntry("({})", conf);
Iterable<Hoster> values;
if (conf.getUrl() == null) {
values = Hosters.values();
} else {
values = ImmutableSet.of(Hosters.tryGetHostByURL(conf.getUrl()));
}
Collection<HosterList> hosterEntries = new TreeSet<>(HosterList.HOSTER_NAME_COMPARATOR);
for (Hoster hoster : values) {
HosterList indexFor = createIndexFor(hoster, conf);
hosterEntries.add(indexFor);
}
Index index = new Index();
index.setHosters(hosterEntries);
return index;
}
use of de.herrlock.manga.index.entity.Index in project Manga by herrlock.
the class Indexer method createJsonIndex.
public static JsonArray createJsonIndex(final IndexerConfiguration conf) {
Index index = createIndex(conf);
JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
for (HosterList hosterList : index.getHosters()) {
for (HosterListEntry hosterListEntry : hosterList.getMangas()) {
arrayBuilder.add(//
Json.createObjectBuilder().add("hosterName", //
hosterList.getHosterName()).add("name", //
hosterListEntry.getName()).add("url", hosterListEntry.getUrl()));
}
}
return arrayBuilder.build();
}
use of de.herrlock.manga.index.entity.Index in project Manga by herrlock.
the class IndexerMain method exportHtmlIndex.
public static void exportHtmlIndex(final OutputStream out, final IndexerConfiguration conf) {
Index index = Indexer.createIndex(conf);
try (InputStream xmlDocument = Indexer.class.getResourceAsStream("manga2datatable.xsl")) {
Source xsl = new StreamSource(xmlDocument);
Source xml = new JAXBSource(createMarshaller(), index);
Result target = new StreamResult(out);
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer(xsl);
transformer.transform(xml, target);
} catch (TransformerFactoryConfigurationError | TransformerException ex) {
throw new MDRuntimeException(ex);
}
} catch (IOException | JAXBException ex) {
throw new MDRuntimeException(ex);
}
}
Aggregations