franta-hg@100: package cz.frantovo.nekurak.web; franta-hg@100: franta-hg@100: import cz.frantovo.nekurak.dto.Podnik; franta-hg@100: import java.io.UnsupportedEncodingException; franta-hg@100: import java.net.URLEncoder; franta-hg@100: import java.util.logging.Level; franta-hg@100: import java.util.logging.Logger; franta-hg@100: franta-hg@100: /** franta-hg@100: * franta-hg@100: * @author fiki franta-hg@100: */ franta-hg@100: public class Detail { franta-hg@100: franta-hg@100: private HledacSluzby hledac = new HledacSluzby(); franta-hg@100: private int id; franta-hg@100: private Podnik podnik; franta-hg@100: franta-hg@100: /** franta-hg@100: * @return URL mapy – obrázku nebo null při chybě nebo absenci souřadnic franta-hg@100: */ franta-hg@100: public String getMapa() { franta-hg@100: Podnik p = getPodnik(); franta-hg@100: franta-hg@100: if (p == null || p.getSirka() == null || p.getDelka() == null) { franta-hg@100: return null; franta-hg@100: } else { franta-hg@100: try { franta-hg@100: String souradnice = URLEncoder.encode(p.getSirka() + ", " + p.getDelka(), "UTF-8"); franta-hg@100: return "http://maps.google.com/maps/api/staticmap?size=400x400&sensor=false¢er=" + souradnice; franta-hg@100: } catch (UnsupportedEncodingException e) { franta-hg@100: return null; franta-hg@100: } franta-hg@100: } franta-hg@100: } franta-hg@100: franta-hg@100: public int getId() { franta-hg@100: return id; franta-hg@100: } franta-hg@100: franta-hg@100: public void setId(int id) { franta-hg@100: this.id = id; franta-hg@100: } franta-hg@100: franta-hg@100: public Podnik getPodnik() { franta-hg@100: if (podnik == null) { franta-hg@100: podnik = hledac.getPodnikEJB().getPodnik(id); franta-hg@100: } franta-hg@100: return podnik; franta-hg@100: } franta-hg@100: }