| | |
| | | import de.uhilger.radiozentrale.web.Initialiser; |
| | | import java.sql.Connection; |
| | | import java.util.List; |
| | | import java.util.logging.Logger; |
| | | |
| | | /** |
| | | * |
| | | */ |
| | | public class SenderApi extends DbApi { |
| | | |
| | | private static final Logger logger = Logger.getLogger(SenderApi.class.getName()); |
| | | |
| | | public static final String SQL_GET_SENDER = "getSender"; |
| | | |
| | | public static final String KEY_SENDER_ID = "sender_id"; |
| | | |
| | | |
| | | public Sender neuerSender(Sender sender) { |
| | | Sender neuerSender = null; |
| | |
| | | if(o instanceof Sender) { |
| | | neuerSender = (Sender) o; |
| | | db.commit(c); |
| | | logger.fine("Sender erstellt: " + sender.getId() + " " + sender.getName()); |
| | | } else { |
| | | db.rollback(c); |
| | | logger.info("Sender konnte nicht erstellt werden: " + sender.getName()); |
| | | } |
| | | } else { |
| | | db.rollback(c); |
| | | logger.info("Sender konnte nicht erstellt werden, nextKey ist -1"); |
| | | } |
| | | return neuerSender; |
| | | } |
| | |
| | | Object o = getDb().update(sender, getMapper(Initialiser.MP_SENDER)); |
| | | if(o instanceof Sender) { |
| | | geaendert = (Sender) o; |
| | | logger.fine("Sender geaendert: " + sender.getId() + " " + sender.getName()); |
| | | } |
| | | return geaendert; |
| | | } |
| | |
| | | Object o = getDb().delete(sender, getMapper(Initialiser.MP_SENDER)); |
| | | if(o instanceof Sender) { |
| | | geloescht = (Sender) o; |
| | | logger.fine("Sender geloescht: " + sender.getId() + " " + sender.getName()); |
| | | } |
| | | return geloescht; |
| | | } |