Search in sources :

Example 1 with KibanaConfigEntryDto

use of org.n52.iceland.statistics.api.utils.dto.KibanaConfigEntryDto in project arctic-sea by 52North.

the class KibanaImporter method importJson.

public void importJson(String jsonString) throws JsonParseException, JsonMappingException, IOException {
    Objects.requireNonNull(jsonString);
    // delete .kibana index
    try {
        client.admin().indices().prepareDelete(kibanaIndexName).get();
    } catch (ElasticsearchException ex) {
        LOG.debug("Tried to delete kibana index " + kibanaIndexName + " but it is not exists", ex);
    }
    ObjectMapper mapper = new ObjectMapper();
    KibanaConfigHolderDto holder = mapper.readValue(jsonString, KibanaConfigHolderDto.class);
    for (KibanaConfigEntryDto dto : holder.getEntries()) {
        processDto(dto);
        LOG.debug("Importing {}", dto);
        client.prepareIndex(kibanaIndexName, dto.getType(), dto.getId()).setSource(dto.getSource()).get();
    }
}
Also used : KibanaConfigHolderDto(org.n52.iceland.statistics.api.utils.dto.KibanaConfigHolderDto) KibanaConfigEntryDto(org.n52.iceland.statistics.api.utils.dto.KibanaConfigEntryDto) ElasticsearchException(org.elasticsearch.ElasticsearchException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 KibanaConfigEntryDto (org.n52.iceland.statistics.api.utils.dto.KibanaConfigEntryDto)1 KibanaConfigHolderDto (org.n52.iceland.statistics.api.utils.dto.KibanaConfigHolderDto)1