# HG changeset patch # User František Kučera # Date 1234387509 -3600 # Node ID 38625daa449bbef46bea42067dc9c27a12c26395 # Parent 62bddd9b51fbf75b6b055cc1a5a342ee2b57bcee Začali jsme používat SuperDAO Umíme načítat data z databáze – zobrazujeme seznam cílů. diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/nbproject/build-impl.xml --- a/java/HrisniciSpameri/nbproject/build-impl.xml Wed Feb 11 20:08:00 2009 +0100 +++ b/java/HrisniciSpameri/nbproject/build-impl.xml Wed Feb 11 22:25:09 2009 +0100 @@ -360,8 +360,12 @@ - - + + + + + + @@ -498,10 +502,15 @@ + - + + + - + + + @@ -777,7 +786,9 @@ CLEANUP SECTION --> - + + + diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/nbproject/genfiles.properties --- a/java/HrisniciSpameri/nbproject/genfiles.properties Wed Feb 11 20:08:00 2009 +0100 +++ b/java/HrisniciSpameri/nbproject/genfiles.properties Wed Feb 11 22:25:09 2009 +0100 @@ -1,8 +1,8 @@ -build.xml.data.CRC32=0d6b07a9 +build.xml.data.CRC32=c00e70e9 build.xml.script.CRC32=20d691ac build.xml.stylesheet.CRC32=c0ebde35 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=0d6b07a9 -nbproject/build-impl.xml.script.CRC32=cde5e1cb +nbproject/build-impl.xml.data.CRC32=c00e70e9 +nbproject/build-impl.xml.script.CRC32=81a189fc nbproject/build-impl.xml.stylesheet.CRC32=174458fc diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/nbproject/private/private.xml --- a/java/HrisniciSpameri/nbproject/private/private.xml Wed Feb 11 20:08:00 2009 +0100 +++ b/java/HrisniciSpameri/nbproject/private/private.xml Wed Feb 11 22:25:09 2009 +0100 @@ -1,12 +1,4 @@ - - file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java - file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dto/Cil.java - file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dto/Souhrn.java - file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/web/index.jsp - file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/web/souhrn.jspx - file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/web/styl.css - diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/nbproject/project.properties --- a/java/HrisniciSpameri/nbproject/project.properties Wed Feb 11 20:08:00 2009 +0100 +++ b/java/HrisniciSpameri/nbproject/project.properties Wed Feb 11 22:25:09 2009 +0100 @@ -23,7 +23,8 @@ j2ee.platform=1.5 j2ee.server.type=J2EE jar.compress=false -javac.classpath= +javac.classpath=\ + ${reference.SuperDAO.jar} # Space-separated list of extra javac options javac.compilerargs= javac.debug=true @@ -51,6 +52,8 @@ lib.dir=${web.docbase.dir}/WEB-INF/lib persistence.xml.dir=${conf.dir} platform.active=default_platform +project.SuperDAO=../../../SuperDAO/java/SuperDAO +reference.SuperDAO.jar=${project.SuperDAO}/dist/SuperDAO.jar resource.dir=setup run.test.classpath=\ ${javac.test.classpath}:\ diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/nbproject/project.xml --- a/java/HrisniciSpameri/nbproject/project.xml Wed Feb 11 20:08:00 2009 +0100 +++ b/java/HrisniciSpameri/nbproject/project.xml Wed Feb 11 22:25:09 2009 +0100 @@ -5,7 +5,12 @@ HrisniciSpameri 1.6.5 - + + + ${reference.SuperDAO.jar} + WEB-INF/lib + + @@ -14,5 +19,15 @@ + + + SuperDAO + jar + + jar + clean + jar + + diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java --- a/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java Wed Feb 11 20:08:00 2009 +0100 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java Wed Feb 11 22:25:09 2009 +0100 @@ -1,11 +1,10 @@ package cz.frantovo.hrisniciSpameri; +import cz.frantovo.hrisniciSpameri.dao.CilDAO; import cz.frantovo.hrisniciSpameri.dto.Cil; import cz.frantovo.hrisniciSpameri.dto.SitovaAdresa; import cz.frantovo.hrisniciSpameri.dto.Souhrn; import java.io.Serializable; -import java.net.InetAddress; -import java.net.UnknownHostException; import java.sql.Date; import java.text.DateFormat; import java.text.ParseException; @@ -79,4 +78,19 @@ return souhrn; } + + /** + * @return Seznam všech cílů. Ale bez těchto hodnot: databáze a selekt. + */ + public Collection getSeznamCilu() { + Collection cile = new CilDAO().getCile(); + + /** ne všechno musíme posílat do JSP vrstvy */ + for (Cil c : cile) { + c.setDatabaze(null); + c.setSelekt(null); + } + + return cile; + } } diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/GenerovaciServlet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/GenerovaciServlet.java Wed Feb 11 22:25:09 2009 +0100 @@ -0,0 +1,11 @@ +package cz.frantovo.hrisniciSpameri; + +/** + * Servlet, který vygeneruje denní souhrn. + * Pokud pro daný den už souhr vygenerovaný byl, smaže ho. + * Vše probíhá v jedné transakci. + * @author fiki + */ +public class GenerovaciServlet { + +} diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/CilDAO.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/CilDAO.java Wed Feb 11 22:25:09 2009 +0100 @@ -0,0 +1,52 @@ +package cz.frantovo.hrisniciSpameri.dao; + +import cz.frantovo.hrisniciSpameri.dto.Cil; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Collection; +import java.util.logging.Level; + +/** + * + * @author fiki + */ +public class CilDAO extends HrisniciSuperDAO { + + private enum SQL { + + VSECHNY_CILE + } + + public Collection getCile() { + Collection cile = new ArrayList(); + + Connection db = getSpojeni(null); + if (db == null) { + return null; + } else { + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = db.prepareStatement(getSQL(SQL.VSECHNY_CILE)); + rs = ps.executeQuery(); + while (rs.next()) { + Cil c = new Cil(); + c.setId(rs.getInt("id")); + c.setNazev(rs.getString("nazev")); + c.setUrl(rs.getString("url")); + c.setSelekt(rs.getString("selekt")); + c.setDatabaze(rs.getString("databaze")); + cile.add(c); + } + } catch (Exception e) { + log.log(Level.SEVERE, "Chyba při získávání seznamu cílů z databáze", e); + } finally { + zavri(db, ps, rs); + } + } + + return cile; + } +} diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/CilDAO.sql.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/CilDAO.sql.xml Wed Feb 11 22:25:09 2009 +0100 @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/HrisniciSuperDAO.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/HrisniciSuperDAO.java Wed Feb 11 22:25:09 2009 +0100 @@ -0,0 +1,60 @@ +package cz.frantovo.hrisniciSpameri.dao; + +import cz.frantovo.superDAO.SuperDAO; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.logging.Level; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.DataSource; + +/** + * + * @author fiki + */ +public class HrisniciSuperDAO extends SuperDAO { + + protected InitialContext kontext = null; + + protected enum DATABAZE { + + HRISNICI + } + + public HrisniciSuperDAO() { + try { + kontext = new InitialContext(); + } catch (NamingException ex) { + log.log(Level.SEVERE, "InitialContext problem", ex); + } + } + + /** + *
    + *
  • Webová část zadává jako parametr null → + * dostane výchozí spojení do PostgreSQL databáze obsahující vygenerované souhrny.
  • + *
  • Generovací servlet zadává JNDI jméno databáze cíle → + * dostane zdrojovou databázi, ze které vygeneruje denní souhrny a výsledek uloží do výchozí databáze.
  • + *
+ * @param jndi JNDI jméno, pokud je null, vrací výchozí spojení. + * @return Databázové spojení + */ + protected Connection getSpojeni(String jndi) { + if (jndi == null || jndi.length() < 1) { + jndi = getVlastnost(DATABAZE.HRISNICI, HrisniciSuperDAO.class); + } + jndi = orizniJNDI(jndi); + DataSource zdroj = null; + try { + System.out.println("XXXXXX:" + jndi + ":XXXXX"); + zdroj = (DataSource) kontext.lookup(jndi); + return zdroj.getConnection(); + } catch (NamingException ex) { + log.log(Level.SEVERE, "getSpojeni: lookup", ex); + return null; + } catch (SQLException ex) { + log.log(Level.SEVERE, "getSpojeni: sql", ex); + return null; + } + } +} diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/HrisniciSuperDAO.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/HrisniciSuperDAO.xml Wed Feb 11 22:25:09 2009 +0100 @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/SouhrnDAO.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/SouhrnDAO.java Wed Feb 11 22:25:09 2009 +0100 @@ -0,0 +1,9 @@ +package cz.frantovo.hrisniciSpameri.dao; + +/** + * + * @author fiki + */ +public class SouhrnDAO extends HrisniciSuperDAO { + +} diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/SouhrnDAO.sql.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dao/SouhrnDAO.sql.xml Wed Feb 11 22:25:09 2009 +0100 @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff -r 62bddd9b51fb -r 38625daa449b java/HrisniciSpameri/web/souhrn.jspx --- a/java/HrisniciSpameri/web/souhrn.jspx Wed Feb 11 20:08:00 2009 +0100 +++ b/java/HrisniciSpameri/web/souhrn.jspx Wed Feb 11 22:25:09 2009 +0100 @@ -14,8 +14,25 @@ +

Seznam cílů

+
    + +
  • + + + + + + + + +
  • +
    +
+

Denní souhrn

+
IP adresa