package vut.msa.helpers;

import java.util.List;
import org.apache.log4j.Logger;
import vut.msa.pojos.Backup;

/**
 * Helper pre objekt Backup.
 */
public class BackupHelper extends Helper {

    private static final Logger llog = Logger.getLogger(BackupHelper.class);

    /**
     * Metoda vytvori zaznam v databaze. Ulozi zaznam o nahrati zalohy na server.
     *
     * @param backup zaznam o ulozeni zalohy
     */
    public void addBackupDisk(Backup backup) {

        try {
            openSession();

            //Jedna sa o transietny objekt, preto treba volat persist
            session.persist(backup);
            llog.info("Ulozenie zaznamu o zalohe do databazy bolo uspesne.");

            endTransaction(session.getTransaction(), true);
        } catch (Exception lex) {
            llog.error(lex.getMessage());
        }
    }
}
