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;
}
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;
}
}
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;
}
}
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);
}
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);
}
Aggregations