diff -r 000000000000 -r 01be78803f73 java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/Detail.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/Detail.java Wed Apr 14 00:12:32 2010 +0200 @@ -0,0 +1,51 @@ +package cz.frantovo.nekurak.web; + +import cz.frantovo.nekurak.dto.Podnik; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author fiki + */ +public class Detail { + + private HledacSluzby hledac = new HledacSluzby(); + private int id; + private Podnik podnik; + + /** + * @return URL mapy – obrázku nebo null při chybě nebo absenci souřadnic + */ + public String getMapa() { + Podnik p = getPodnik(); + + if (p == null || p.getSirka() == null || p.getDelka() == null) { + return null; + } else { + try { + String souradnice = URLEncoder.encode(p.getSirka() + ", " + p.getDelka(), "UTF-8"); + return "http://maps.google.com/maps/api/staticmap?size=400x400&sensor=false¢er=" + souradnice; + } catch (UnsupportedEncodingException e) { + return null; + } + } + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public Podnik getPodnik() { + if (podnik == null) { + podnik = hledac.getPodnikEJB().getPodnik(id); + } + return podnik; + } +}