Search in sources :

Example 1 with RealmLocalizationTextsEntity

use of org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity in project keycloak by keycloak.

the class JpaRealmProvider method deleteLocalizationTextsByLocale.

@Override
public boolean deleteLocalizationTextsByLocale(RealmModel realm, String locale) {
    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaDelete<RealmLocalizationTextsEntity> criteriaDelete = builder.createCriteriaDelete(RealmLocalizationTextsEntity.class);
    Root<RealmLocalizationTextsEntity> root = criteriaDelete.from(RealmLocalizationTextsEntity.class);
    criteriaDelete.where(builder.and(builder.equal(root.get("realmId"), realm.getId()), builder.equal(root.get("locale"), locale)));
    int linesUpdated = em.createQuery(criteriaDelete).executeUpdate();
    return linesUpdated == 1 ? true : false;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) RealmLocalizationTextsEntity(org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity)

Example 2 with RealmLocalizationTextsEntity

use of org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity in project keycloak by keycloak.

the class JpaRealmProvider method deleteLocalizationText.

@Override
public boolean deleteLocalizationText(RealmModel realm, String locale, String key) {
    RealmLocalizationTextsEntity entity = getRealmLocalizationTextsEntity(locale, realm.getId());
    if (entity != null && entity.getTexts() != null && entity.getTexts().containsKey(key)) {
        entity.getTexts().remove(key);
        em.persist(entity);
        return true;
    } else {
        return false;
    }
}
Also used : RealmLocalizationTextsEntity(org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity)

Example 3 with RealmLocalizationTextsEntity

use of org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity in project keycloak by keycloak.

the class JpaRealmProvider method updateLocalizationText.

@Override
public boolean updateLocalizationText(RealmModel realm, String locale, String key, String text) {
    RealmLocalizationTextsEntity entity = getRealmLocalizationTextsEntity(locale, realm.getId());
    if (entity != null && entity.getTexts() != null && entity.getTexts().containsKey(key)) {
        entity.getTexts().put(key, text);
        em.persist(entity);
        return true;
    } else {
        return false;
    }
}
Also used : RealmLocalizationTextsEntity(org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity)

Example 4 with RealmLocalizationTextsEntity

use of org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity in project keycloak by keycloak.

the class JpaRealmProvider method saveLocalizationText.

@Override
public void saveLocalizationText(RealmModel realm, String locale, String key, String text) {
    RealmLocalizationTextsEntity entity = getRealmLocalizationTextsEntity(locale, realm.getId());
    if (entity == null) {
        entity = new RealmLocalizationTextsEntity();
        entity.setRealmId(realm.getId());
        entity.setLocale(locale);
        entity.setTexts(new HashMap<>());
    }
    entity.getTexts().put(key, text);
    em.persist(entity);
}
Also used : RealmLocalizationTextsEntity(org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity)

Example 5 with RealmLocalizationTextsEntity

use of org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity in project keycloak by keycloak.

the class JpaRealmProvider method saveLocalizationTexts.

@Override
public void saveLocalizationTexts(RealmModel realm, String locale, Map<String, String> localizationTexts) {
    RealmLocalizationTextsEntity entity = new RealmLocalizationTextsEntity();
    entity.setTexts(localizationTexts);
    entity.setLocale(locale);
    entity.setRealmId(realm.getId());
    em.merge(entity);
}
Also used : RealmLocalizationTextsEntity(org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity)

Aggregations

RealmLocalizationTextsEntity (org.keycloak.models.jpa.entities.RealmLocalizationTextsEntity)5 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1