Mercurial > dive4elements > river
changeset 8287:4c1f57839ae9
Avoid NPE if river is not accessible.
author | "Tom Gottfried <tom@intevation.de>" |
---|---|
date | Wed, 17 Sep 2014 13:00:14 +0200 |
parents | 62b4f3ca99ed |
children | 2f7f9ced46a5 |
files | artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java |
diffstat | 1 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java Wed Sep 17 12:32:24 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java Wed Sep 17 13:00:14 2014 +0200 @@ -12,6 +12,9 @@ import java.util.Map; import org.apache.log4j.Logger; + +import org.dive4elements.river.model.River; + import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.D4EArtifact; @@ -19,7 +22,6 @@ import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.model.Unit; import org.dive4elements.river.themes.ThemeDocument; -import org.dive4elements.river.utils.RiverUtils; import org.jfree.data.xy.XYDataItem; import org.jfree.data.xy.XYSeries; @@ -140,21 +142,25 @@ Artifact artifact, CallContext context) { this.metaData = metaData; - D4EArtifact d4e = (D4EArtifact) artifact; - RiverAccess access = new RiverAccess(d4e); - Unit unit = RiverUtils.getRiver(d4e).getWstUnit(); + River river = new RiverAccess((D4EArtifact)artifact).getRiver(); + String rivername = ""; + String unit = ""; + if (river != null) { + rivername = river.getName(); + unit = river.getWstUnit().getName(); + } if (metaData.containsKey("X")) { this.metaData.put("X", Resources.getMsg( context.getMeta(), metaData.get("X"), - new Object[] { access.getRiverName() })); + new Object[] { rivername })); } if (metaData.containsKey("Y")) { this.metaData.put("Y", Resources.getMsg( context.getMeta(), - metaData.get("Y"), new Object[] { unit.getName() })); + metaData.get("Y"), new Object[] { unit })); } } }