package org.oregami.data;

import org.oregami.dropwizard.OregamiService;
import org.oregami.entities.datalist.DemoContentType;
import org.oregami.entities.datalist.GameEntryType;
import org.oregami.entities.datalist.ReleaseGroupReason;

import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.persist.PersistService;
import com.google.inject.persist.Transactional;
import com.google.inject.persist.jpa.JpaPersistModule;

public class BaseListFinder {

	private static BaseListFinder instance = null;
	
	public static BaseListFinder instance() {
		if (instance==null) {
			JpaPersistModule jpaPersistModule = new JpaPersistModule(OregamiService.JPA_UNIT);
			Injector injector = Guice.createInjector(jpaPersistModule);
			instance = injector.getInstance(BaseListFinder.class);
			PersistService persistService = injector.getInstance(PersistService.class);
			persistService.start();
		}
		return instance;
	}
	
	@Inject
	GameEntryTypeDao gameEntryTypeDao; 
	
	@Inject
	ReleaseGroupReasonDao releaseGroupReasonDao;

	@Inject
	DemoContentTypeDao demoContentTypeDao;
	
	@Transactional
	public GameEntryType getGameEntryType(String value) {
		return gameEntryTypeDao.findByName(value);
	}

	@Transactional
	public ReleaseGroupReason getReleaseGroupReason(String value) {
		return releaseGroupReasonDao.findByName(value);
	}
	
	@Transactional
	public DemoContentType getDemoContentType(String value) {
		return demoContentTypeDao.findByName(value);
	}
	
}

@@ -228,16 +228,66 @@
 pReason;
+%0Aimport org.oregami.entities.datalist.ReleaseType;
 %0A%0Aimport
@@ -1126,16 +1126,59 @@
 onDao;%0A%0A
+%09@Inject%0A%09ReleaseTypeDao releaseTypeDao;%0A%09%0A
 %09@Inject
@@ -1220,32 +1220,16 @@
 eDao;%0A%09%0A
-%09@Transactional%0A
 %09public 
@@ -1323,32 +1323,115 @@
 ue);%0A%09%7D%0A
+%09
 %0A%09
-@Transactional
+public ReleaseType getReleaseType(String value) %7B%0A%09%09return releaseTypeDao.findByName(value);%0A%09%7D%0A
 %0A%09public

add ReleaseType