use of fi.otavanopisto.muikku.model.plugins.PluginUserSetting in project muikku by otavanopisto.
the class PluginUserSettingDAO method listUsersByKey.
public List<UserEntity> listUsersByKey(PluginUserSettingKey key) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<UserEntity> criteria = criteriaBuilder.createQuery(UserEntity.class);
Root<PluginUserSetting> root = criteria.from(PluginUserSetting.class);
criteria.select(root.get(PluginUserSetting_.user));
criteria.where(criteriaBuilder.equal(root.get(PluginUserSetting_.key), key));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.model.plugins.PluginUserSetting in project muikku by otavanopisto.
the class PluginSettingsController method getPluginUserSetting.
public String getPluginUserSetting(String plugin, String name, UserEntity user) {
PluginUserSettingKey key = findPluginUserSettingKey(plugin, name);
if (key == null) {
key = pluginUserSettingKeyDAO.create(plugin, name);
}
PluginUserSetting setting = findPluginUserSetting(key, user);
if (setting != null) {
return setting.getValue();
}
return null;
}
use of fi.otavanopisto.muikku.model.plugins.PluginUserSetting in project muikku by otavanopisto.
the class PluginUserSettingDAO method findByKeyAndUser.
public PluginUserSetting findByKeyAndUser(PluginUserSettingKey key, UserEntity user) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<PluginUserSetting> criteria = criteriaBuilder.createQuery(PluginUserSetting.class);
Root<PluginUserSetting> root = criteria.from(PluginUserSetting.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(PluginUserSetting_.key), key), criteriaBuilder.equal(root.get(PluginUserSetting_.user), user)));
return getSingleResult(entityManager.createQuery(criteria));
}
use of fi.otavanopisto.muikku.model.plugins.PluginUserSetting in project muikku by otavanopisto.
the class PluginUserSettingDAO method create.
public PluginUserSetting create(PluginUserSettingKey key, UserEntity user, String value) {
PluginUserSetting pluginUserSetting = new PluginUserSetting();
pluginUserSetting.setKey(key);
pluginUserSetting.setUser(user);
pluginUserSetting.setValue(value);
getEntityManager().persist(pluginUserSetting);
return pluginUserSetting;
}
Aggregations