Search in sources :

Example 1 with PluginUserSetting

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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) PluginUserSetting(fi.otavanopisto.muikku.model.plugins.PluginUserSetting) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity)

Example 2 with PluginUserSetting

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;
}
Also used : PluginUserSettingKey(fi.otavanopisto.muikku.model.plugins.PluginUserSettingKey) PluginUserSetting(fi.otavanopisto.muikku.model.plugins.PluginUserSetting)

Example 3 with PluginUserSetting

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));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) PluginUserSetting(fi.otavanopisto.muikku.model.plugins.PluginUserSetting)

Example 4 with PluginUserSetting

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;
}
Also used : PluginUserSetting(fi.otavanopisto.muikku.model.plugins.PluginUserSetting)

Aggregations

PluginUserSetting (fi.otavanopisto.muikku.model.plugins.PluginUserSetting)4 EntityManager (javax.persistence.EntityManager)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 PluginUserSettingKey (fi.otavanopisto.muikku.model.plugins.PluginUserSettingKey)1 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)1