view src/main/java/de/intevation/lada/manage/DataManager.java @ 409:183f8116d9a6

Added license header to source files.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 20 Jan 2014 12:27:00 +0100
parents 9d5e4d4eb90f
children
line wrap: on
line source
/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (v>=3) 
 * and comes with ABSOLUTELY NO WARRANTY! Check out 
 * the documentation coming with IMIS-Labordaten-Application for details. 
 */
package de.intevation.lada.manage;

import javax.ejb.EJBTransactionRolledbackException;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityExistsException;
import javax.persistence.EntityManager;
import javax.persistence.TransactionRequiredException;


/**
 * This data manager provides the interface to persist, remove and update
 * database objects.
 *
 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a>
 */
@Stateless
@Named("datamanager")
public class DataManager
implements Manager
{
    @Inject
    private EntityManager em;

    /**
     * Create a new database object.
     *
     * @param object    The new object.
     */
    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void create(Object object)
    throws EntityExistsException,
        IllegalArgumentException,
        EJBTransactionRolledbackException,
        TransactionRequiredException {
        em.merge(object);
    }

    /**
     * Persist a database object.
     *
     * @param object    The new object.
     */
    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void persist(Object object)
    throws EntityExistsException,
        IllegalArgumentException,
        EJBTransactionRolledbackException,
        TransactionRequiredException {
        em.persist(object);
    }
    /**
     * Update a database object.
     *
     * @param object    The object to update.
     */
    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void update(Object object)
    throws EntityExistsException,
        IllegalArgumentException,
        EJBTransactionRolledbackException,
        TransactionRequiredException {
        em.merge(object);
    }

    /**
     * Delete a database object.
     *
     * @param object    The object to delete.
     */
    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void delete(Object object)
    throws IllegalArgumentException,
        TransactionRequiredException {
        em.remove(em.contains(object) ? object : em.merge(object));
    }
}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)