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
franta-hg@100
     1
package cz.frantovo.nekurak.web;
franta-hg@100
     2
franta-hg@100
     3
import cz.frantovo.nekurak.dto.Podnik;
franta-hg@100
     4
import java.io.UnsupportedEncodingException;
franta-hg@100
     5
import java.net.URLEncoder;
franta-hg@100
     6
franta-hg@100
     7
/**
franta-hg@100
     8
 *
franta-hg@100
     9
 * @author fiki
franta-hg@100
    10
 */
franta-hg@100
    11
public class Detail {
franta-hg@100
    12
franta-hg@145
    13
	private HledacSluzby hledac = new HledacSluzby();
franta-hg@145
    14
	private int id;
franta-hg@145
    15
	private Podnik podnik;
franta-hg@100
    16
franta-hg@145
    17
	/**
franta-hg@145
    18
	 * @return URL mapy – obrázku nebo null při chybě nebo absenci souřadnic
franta-hg@145
    19
	 */
franta-hg@145
    20
	public String getMapa() {
franta-hg@145
    21
		Podnik p = getPodnik();
franta-hg@100
    22
franta-hg@145
    23
		if (p == null || p.getSirka() == null || p.getDelka() == null) {
franta-hg@145
    24
			return null;
franta-hg@145
    25
		} else {
franta-hg@145
    26
			try {
franta-hg@145
    27
				String souradnice = URLEncoder.encode(p.getSirka() + ", " + p.getDelka(), "UTF-8");
franta-hg@145
    28
				return "http://maps.google.com/maps/api/staticmap?size=400x400&sensor=false&center=" + souradnice;
franta-hg@145
    29
			} catch (UnsupportedEncodingException e) {
franta-hg@145
    30
				return null;
franta-hg@145
    31
			}
franta-hg@145
    32
		}
franta-hg@100
    33
	}
franta-hg@100
    34
franta-hg@145
    35
	public int getId() {
franta-hg@145
    36
		return id;
franta-hg@145
    37
	}
franta-hg@100
    38
franta-hg@145
    39
	public void setId(int id) {
franta-hg@145
    40
		this.id = id;
franta-hg@145
    41
	}
franta-hg@100
    42
franta-hg@145
    43
	public Podnik getPodnik() {
franta-hg@145
    44
		if (podnik == null) {
franta-hg@145
    45
			podnik = hledac.getPodnikEJB().getPodnik(id);
franta-hg@145
    46
		}
franta-hg@145
    47
		return podnik;
franta-hg@100
    48
	}
franta-hg@100
    49
}