package com.dharmab.sheets.server.character;

import com.dharmab.sheets.server.database.DatabaseAccessor;
import com.google.inject.Inject;
import com.google.inject.Singleton;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

@Singleton
public class CharacterService {
    private DatabaseAccessor database;
    private Logger logger;

    @Inject
    public CharacterService(DatabaseAccessor database, Logger logger) {
        this.database = database;
        this.logger = logger;
    }

    public Character get(int id) {
        return database.getCharacter(id).orNull();
    }

    public void persist(Character character) {
        logger.log(Level.FINE, "before database.persist()");
        database.persist(character);
        logger.log(Level.FINE, "after database.persist()");

    }

    public void delete(Character character) {
        database.delete(character);
    }

    public void delete(Integer id) {
        database.delete(id);
    }

    public List<Character> getAll() {
        return database.getAll();
    }
}

@@ -195,73 +195,8 @@
 ist;
-%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;
 %0A%0A@S
@@ -278,35 +278,8 @@
 ase;
-%0A    private Logger logger;
 %0A%0A  
@@ -345,23 +345,8 @@
 base
-, Logger logger
 ) %7B%0A
@@ -383,38 +383,8 @@
 se;%0A
-        this.logger = logger;%0A
     
@@ -538,158 +538,36 @@
     
-logger.log(Level.FINE, %22before database.persist()%22);%0A        database.persist(character);%0A        logger.log(Level.FINE, %22after database.persist()%22);%0A
+database.persist(character);
 %0A   

remove debug logging