2013-04-12 13:27:30 +02:00
|
|
|
package com.commafeed.backend.services;
|
|
|
|
|
|
2013-04-30 07:11:57 +02:00
|
|
|
import javax.ejb.Singleton;
|
2013-04-12 13:27:30 +02:00
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
|
|
|
|
import com.commafeed.backend.dao.ApplicationSettingsDAO;
|
|
|
|
|
import com.commafeed.backend.model.ApplicationSettings;
|
|
|
|
|
import com.google.common.collect.Iterables;
|
|
|
|
|
|
2013-04-30 07:11:57 +02:00
|
|
|
@Singleton
|
2013-04-12 13:27:30 +02:00
|
|
|
public class ApplicationSettingsService {
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
|
ApplicationSettingsDAO applicationSettingsDAO;
|
|
|
|
|
|
2013-04-30 07:11:57 +02:00
|
|
|
private ApplicationSettings settings;
|
|
|
|
|
|
2013-04-12 13:27:30 +02:00
|
|
|
public void save(ApplicationSettings settings) {
|
2013-04-30 07:11:57 +02:00
|
|
|
this.settings = settings;
|
2013-04-12 13:27:30 +02:00
|
|
|
applicationSettingsDAO.saveOrUpdate(settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ApplicationSettings get() {
|
2013-04-30 07:11:57 +02:00
|
|
|
if (settings == null) {
|
|
|
|
|
settings = Iterables.getFirst(applicationSettingsDAO.findAll(),
|
|
|
|
|
null);
|
|
|
|
|
}
|
|
|
|
|
return settings;
|
2013-04-12 13:27:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|