java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/PodnikEJB.java
changeset 130 1bbff3f5181f
parent 123 9135d52e8b0a
child 131 0d1cba59734b
     1.1 --- a/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/PodnikEJB.java	Tue May 25 13:54:21 2010 +0200
     1.2 +++ b/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/PodnikEJB.java	Tue Jun 08 09:09:17 2010 +0200
     1.3 @@ -1,11 +1,15 @@
     1.4  package cz.frantovo.nekurak.ejb;
     1.5  
     1.6  import cz.frantovo.nekurak.dao.PodnikDAO;
     1.7 +import cz.frantovo.nekurak.dto.Komentar;
     1.8  import cz.frantovo.nekurak.dto.Podnik;
     1.9  import cz.frantovo.nekurak.dto.VysledekHlasovani;
    1.10  import cz.frantovo.nekurak.ext.Geo;
    1.11  import cz.frantovo.nekurak.ext.Geo.Souradnice;
    1.12 +import cz.frantovo.nekurak.ext.Texy;
    1.13 +import cz.frantovo.nekurak.util.Komentare;
    1.14  import java.util.Collection;
    1.15 +import java.util.Date;
    1.16  import java.util.logging.Logger;
    1.17  import javax.annotation.Resource;
    1.18  import javax.annotation.security.RolesAllowed;
    1.19 @@ -74,4 +78,27 @@
    1.20      public VysledekHlasovani getVysledekHlasovani(int podnik) {
    1.21  	return podnikDAO.getVysledekHlasovani(podnik);
    1.22      }
    1.23 +
    1.24 +    @RolesAllowed("opravneny")
    1.25 +    public void komentuj(Komentar k) {
    1.26 +	k.setUzivatel(ctx.getCallerPrincipal().getName());
    1.27 +	k.setDatum(new Date());
    1.28 +
    1.29 +	/** Převedeme na XML */
    1.30 +	switch (k.getTyp()) {
    1.31 +	    case PROSTY_TEXT:
    1.32 +		k.setKomentar(Komentare.upravProstyText(k.getKomentar()));
    1.33 +		k.setKomentar(Komentare.obal(k.getKomentar()));
    1.34 +		break;
    1.35 +	    case TEXY:
    1.36 +		Texy t = new Texy();
    1.37 +		k.setKomentar(t.preved(k.getKomentar()));
    1.38 +		k.setKomentar(Komentare.obal(k.getKomentar()));
    1.39 +		break;
    1.40 +	}
    1.41 +
    1.42 +
    1.43 +	/** Zkontrolujeme XML */
    1.44 +	log.severe("Komentář: " + k.getNadpis() + " | " + k.getKomentar() + " | " + k.getTyp());
    1.45 +    }
    1.46  }