Skip to content

Commit

Permalink
Merge pull request #6176 from IQSS/6173-fix-settings-api
Browse files Browse the repository at this point in the history
6173 fix settings api
  • Loading branch information
kcondon authored Sep 17, 2019
2 parents cf4b864 + 83de8c0 commit 210499a
Showing 1 changed file with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,46 @@ public String getValueForKey( Key key, String lang, String defaultValue ) {
}

public Setting set( String name, String content ) {
Setting s = new Setting( name, content );
Setting s = null;

List<Setting> tokens = em.createNamedQuery("Setting.findByName", Setting.class)
.setParameter("name", name )
.getResultList();

if(tokens.size() > 0) {
s = tokens.get(0);
}

if (s == null) {
s = new Setting( name, content );
} else {
s.setContent(content);
}

s = em.merge(s);
actionLogSvc.log( new ActionLogRecord(ActionLogRecord.ActionType.Setting, "set")
.setInfo(name + ": " + content));
return s;
}

public Setting set( String name, String lang, String content ) {
Setting s = new Setting( name, lang, content );
Setting s = null;

List<Setting> tokens = em.createNamedQuery("Setting.findByNameAndLang", Setting.class)
.setParameter("name", name )
.setParameter("lang", lang )
.getResultList();

if(tokens.size() > 0) {
s = tokens.get(0);
}

if (s == null) {
s = new Setting( name, lang, content );
} else {
s.setContent(content);
}

em.merge(s);
actionLogSvc.log( new ActionLogRecord(ActionLogRecord.ActionType.Setting, "set")
.setInfo(name + ": " +lang + ": " + content));
Expand Down

0 comments on commit 210499a

Please sign in to comment.