java/nekurak.net-web/src/java/cz/frantovo/nekurak/web/Detail.java
author František Kučera <franta-hg@frantovo.cz>
Sun Jun 20 14:46:47 2010 +0200 (2010-06-20)
changeset 145 0efefbf5f8b6
parent 107 e8371105fcc8
child 172 f0852ef58889
permissions -rw-r--r--
Formátování kódu, důsledné používání tabulátorů, drobné úpravy, StringBuilder
     1 package cz.frantovo.nekurak.web;
     2 
     3 import cz.frantovo.nekurak.dto.Podnik;
     4 import java.io.UnsupportedEncodingException;
     5 import java.net.URLEncoder;
     6 
     7 /**
     8  *
     9  * @author fiki
    10  */
    11 public class Detail {
    12 
    13 	private HledacSluzby hledac = new HledacSluzby();
    14 	private int id;
    15 	private Podnik podnik;
    16 
    17 	/**
    18 	 * @return URL mapy – obrázku nebo null při chybě nebo absenci souřadnic
    19 	 */
    20 	public String getMapa() {
    21 		Podnik p = getPodnik();
    22 
    23 		if (p == null || p.getSirka() == null || p.getDelka() == null) {
    24 			return null;
    25 		} else {
    26 			try {
    27 				String souradnice = URLEncoder.encode(p.getSirka() + ", " + p.getDelka(), "UTF-8");
    28 				return "http://maps.google.com/maps/api/staticmap?size=400x400&sensor=false&center=" + souradnice;
    29 			} catch (UnsupportedEncodingException e) {
    30 				return null;
    31 			}
    32 		}
    33 	}
    34 
    35 	public int getId() {
    36 		return id;
    37 	}
    38 
    39 	public void setId(int id) {
    40 		this.id = id;
    41 	}
    42 
    43 	public Podnik getPodnik() {
    44 		if (podnik == null) {
    45 			podnik = hledac.getPodnikEJB().getPodnik(id);
    46 		}
    47 		return podnik;
    48 	}
    49 }