Search in sources :

Example 1 with Graph

use of cwms.radar.api.graph.Graph in project cwms-radar-api by USACE.

the class NamedPgJsonFormatter method format.

@Override
public String format(CwmsDTO dto) {
    String retVal;
    try {
        if (dto instanceof Basin) {
            Basin basin = (Basin) dto;
            Graph graph = new BasinConnectivityGraph.Builder(basin).build();
            String name = basin.getBasinName();
            retVal = formatNamedGraph(name, graph);
        } else {
            throw new FormattingException(dto.getClass().getSimpleName() + " is not currently supported for Named-PG-JSON format.");
        }
    } catch (JsonProcessingException e) {
        throw new FormattingException(e.getMessage());
    }
    return retVal;
}
Also used : BasinConnectivityGraph(cwms.radar.api.graph.basinconnectivity.BasinConnectivityGraph) Graph(cwms.radar.api.graph.Graph) FormattingException(cwms.radar.formatters.FormattingException) Basin(cwms.radar.data.dto.basinconnectivity.Basin) BasinConnectivityGraph(cwms.radar.api.graph.basinconnectivity.BasinConnectivityGraph) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 2 with Graph

use of cwms.radar.api.graph.Graph in project cwms-radar-api by USACE.

the class PgJsonFormatter method format.

@Override
public String format(CwmsDTO dto) {
    String retVal;
    Graph graph;
    if (dto instanceof Basin) {
        Basin basin = (Basin) dto;
        graph = new BasinConnectivityGraph.Builder(basin).build();
    } else {
        throw new FormattingException(dto.getClass().getSimpleName() + " is not currently supported for PG-JSON format.");
    }
    try {
        retVal = formatGraph(graph);
    } catch (JsonProcessingException e) {
        throw new FormattingException(e.getMessage());
    }
    return retVal;
}
Also used : BasinConnectivityGraph(cwms.radar.api.graph.basinconnectivity.BasinConnectivityGraph) Graph(cwms.radar.api.graph.Graph) FormattingException(cwms.radar.formatters.FormattingException) Basin(cwms.radar.data.dto.basinconnectivity.Basin) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 Graph (cwms.radar.api.graph.Graph)2 BasinConnectivityGraph (cwms.radar.api.graph.basinconnectivity.BasinConnectivityGraph)2 Basin (cwms.radar.data.dto.basinconnectivity.Basin)2 FormattingException (cwms.radar.formatters.FormattingException)2