Search in sources :

Example 1 with PluginUserSettingKey

use of fi.otavanopisto.muikku.model.plugins.PluginUserSettingKey in project muikku by otavanopisto.

the class PluginUserSettingKeyDAO method create.

public PluginUserSettingKey create(String plugin, String name) {
    PluginUserSettingKey pluginSettingKey = new PluginUserSettingKey();
    pluginSettingKey.setName(name);
    pluginSettingKey.setPlugin(plugin);
    getEntityManager().persist(pluginSettingKey);
    return pluginSettingKey;
}
Also used : PluginUserSettingKey(fi.otavanopisto.muikku.model.plugins.PluginUserSettingKey)

Example 2 with PluginUserSettingKey

use of fi.otavanopisto.muikku.model.plugins.PluginUserSettingKey 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 PluginUserSettingKey

use of fi.otavanopisto.muikku.model.plugins.PluginUserSettingKey in project muikku by otavanopisto.

the class PluginUserSettingKeyDAO method findByPluginAndName.

public PluginUserSettingKey findByPluginAndName(String plugin, String name) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<PluginUserSettingKey> criteria = criteriaBuilder.createQuery(PluginUserSettingKey.class);
    Root<PluginUserSettingKey> root = criteria.from(PluginUserSettingKey.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(PluginUserSettingKey_.name), name), criteriaBuilder.equal(root.get(PluginUserSettingKey_.plugin), plugin)));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) PluginUserSettingKey(fi.otavanopisto.muikku.model.plugins.PluginUserSettingKey)

Example 4 with PluginUserSettingKey

use of fi.otavanopisto.muikku.model.plugins.PluginUserSettingKey in project muikku by otavanopisto.

the class PluginSettingsController method setPluginUserSetting.

public void setPluginUserSetting(String plugin, String name, String value, UserEntity user) {
    PluginUserSettingKey key = findPluginUserSettingKey(plugin, name);
    if (key == null) {
        key = pluginUserSettingKeyDAO.create(plugin, name);
    }
    updatePluginUserSetting(key, value, user);
}
Also used : PluginUserSettingKey(fi.otavanopisto.muikku.model.plugins.PluginUserSettingKey)

Aggregations

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