package de.thpeetz.kontor.infrastructure;

import java.util.Properties;

import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.schema.Action;

import de.thpeetz.kontor.models.comics.Artist;
import de.thpeetz.kontor.models.comics.Comic;
import de.thpeetz.kontor.models.comics.ComicWork;
import de.thpeetz.kontor.models.comics.Issue;
import de.thpeetz.kontor.models.comics.IssueWork;
import de.thpeetz.kontor.models.comics.Publisher;
import de.thpeetz.kontor.models.comics.StoryArc;
import de.thpeetz.kontor.models.comics.TradePaperback;
import de.thpeetz.kontor.models.comics.Volume;
import de.thpeetz.kontor.models.comics.Worktype;
import de.thpeetz.kontor.models.media.MediaActor;
import de.thpeetz.kontor.models.media.MediaActorFile;
import de.thpeetz.kontor.models.media.MediaArticle;
import de.thpeetz.kontor.models.media.MediaFile;
import de.thpeetz.kontor.models.media.MediaVideo;

public class AppHibernateConfig {
    public static Configuration configuration() {
        var configuration = new Configuration();
        var settings = new Properties();
        settings.put(AvailableSettings.JAKARTA_JDBC_DRIVER, "org.postgresql.Driver");
        settings.put(AvailableSettings.JAKARTA_JDBC_URL, "jdbc:postgresql://postgres:5432/kontor");
        settings.put(AvailableSettings.JAKARTA_JDBC_USER, "kontor");
        settings.put(AvailableSettings.JAKARTA_JDBC_PASSWORD, "kontor");
        settings.put(AvailableSettings.HIGHLIGHT_SQL, true);
        settings.put(AvailableSettings.HBM2DDL_AUTO, Action.ACTION_UPDATE);

        configuration.setProperties(settings);
        configuration.addAnnotatedClass(MediaFile.class);
        configuration.addAnnotatedClass(MediaActorFile.class);
        configuration.addAnnotatedClass(MediaActor.class);
        configuration.addAnnotatedClass(MediaArticle.class);
        configuration.addAnnotatedClass(MediaVideo.class);
        configuration.addAnnotatedClass(Comic.class);
        configuration.addAnnotatedClass(Publisher.class);
        configuration.addAnnotatedClass(Artist.class);
        configuration.addAnnotatedClass(ComicWork.class);
        configuration.addAnnotatedClass(Issue.class);
        configuration.addAnnotatedClass(IssueWork.class);
        configuration.addAnnotatedClass(StoryArc.class);
        configuration.addAnnotatedClass(TradePaperback.class);
        configuration.addAnnotatedClass(Volume.class);
        configuration.addAnnotatedClass(Worktype.class);
        return configuration;
    }
}
