1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/Detail.java Wed Apr 14 00:12:32 2010 +0200
1.3 @@ -0,0 +1,51 @@
1.4 +package cz.frantovo.nekurak.web;
1.5 +
1.6 +import cz.frantovo.nekurak.dto.Podnik;
1.7 +import java.io.UnsupportedEncodingException;
1.8 +import java.net.URLEncoder;
1.9 +import java.util.logging.Level;
1.10 +import java.util.logging.Logger;
1.11 +
1.12 +/**
1.13 + *
1.14 + * @author fiki
1.15 + */
1.16 +public class Detail {
1.17 +
1.18 + private HledacSluzby hledac = new HledacSluzby();
1.19 + private int id;
1.20 + private Podnik podnik;
1.21 +
1.22 + /**
1.23 + * @return URL mapy – obrázku nebo null při chybě nebo absenci souřadnic
1.24 + */
1.25 + public String getMapa() {
1.26 + Podnik p = getPodnik();
1.27 +
1.28 + if (p == null || p.getSirka() == null || p.getDelka() == null) {
1.29 + return null;
1.30 + } else {
1.31 + try {
1.32 + String souradnice = URLEncoder.encode(p.getSirka() + ", " + p.getDelka(), "UTF-8");
1.33 + return "http://maps.google.com/maps/api/staticmap?size=400x400&sensor=false¢er=" + souradnice;
1.34 + } catch (UnsupportedEncodingException e) {
1.35 + return null;
1.36 + }
1.37 + }
1.38 + }
1.39 +
1.40 + public int getId() {
1.41 + return id;
1.42 + }
1.43 +
1.44 + public void setId(int id) {
1.45 + this.id = id;
1.46 + }
1.47 +
1.48 + public Podnik getPodnik() {
1.49 + if (podnik == null) {
1.50 + podnik = hledac.getPodnikEJB().getPodnik(id);
1.51 + }
1.52 + return podnik;
1.53 + }
1.54 +}