diff --git a/modules/qi-core/src/main/java/org/jpos/qi/QIHelper.java b/modules/qi-core/src/main/java/org/jpos/qi/QIHelper.java index 836b070c26..9a7ce1c18d 100644 --- a/modules/qi-core/src/main/java/org/jpos/qi/QIHelper.java +++ b/modules/qi-core/src/main/java/org/jpos/qi/QIHelper.java @@ -222,6 +222,18 @@ public DataProvider getSysConfigsDataProvider (String prefix) { }); } + public Collection getSysConfigsByValue (String prefix) { + try { + return DB.exec(db -> { + SysConfigManager mgr = new SysConfigManager(db, prefix); + return mgr.getAllByValue(); + }); + } catch (Exception e) { + getApp().getLog().createError(e.getMessage()); + return null; + } + } + private Stream getSysConfigs (int offset,int limit,Map orders, String prefix) throws Exception { return ((List) DB.exec(db -> { SysConfigManager mgr = new SysConfigManager(db, prefix); diff --git a/modules/qi-sysconfig/src/main/java/org/jpos/qi/sysconfig/SysConfigComboBox.java b/modules/qi-sysconfig/src/main/java/org/jpos/qi/sysconfig/SysConfigComboBox.java index fcd1a1f66c..f1aeb613c9 100644 --- a/modules/qi-sysconfig/src/main/java/org/jpos/qi/sysconfig/SysConfigComboBox.java +++ b/modules/qi-sysconfig/src/main/java/org/jpos/qi/sysconfig/SysConfigComboBox.java @@ -3,7 +3,12 @@ import com.vaadin.data.provider.DataProvider; import com.vaadin.ui.ComboBox; import com.vaadin.ui.ItemCaptionGenerator; +import org.jpos.ee.DB; import org.jpos.ee.SysConfig; +import org.jpos.ee.SysConfigManager; + +import java.util.Collection; +import java.util.List; public class SysConfigComboBox extends ComboBox { public SysConfigComboBox (String caption, DataProvider dataProvider) { @@ -12,4 +17,23 @@ public SysConfigComboBox (String caption, DataProvider dataProvider) { setItemCaptionGenerator((ItemCaptionGenerator) SysConfig::getValue); setEmptySelectionAllowed(false); } + + + public SysConfigComboBox (String caption, Collection items) { + super(caption); + setItems(items); + setItemCaptionGenerator((ItemCaptionGenerator) SysConfig::getValue); + setEmptySelectionAllowed(false); + } + + public SysConfigComboBox (String caption, String prefix) throws Exception { + super(caption); + List items = DB.exec(db -> { + SysConfigManager mgr = new SysConfigManager(db, prefix); + return mgr.getAllByValue(); + }); + setItems(items); + setItemCaptionGenerator((ItemCaptionGenerator) SysConfig::getValue); + setEmptySelectionAllowed(false); + } } diff --git a/modules/qi-sysconfig/src/main/java/org/jpos/qi/sysconfig/SysConfigConverter.java b/modules/qi-sysconfig/src/main/java/org/jpos/qi/sysconfig/SysConfigConverter.java index f3497a3188..6b7a08e9ef 100644 --- a/modules/qi-sysconfig/src/main/java/org/jpos/qi/sysconfig/SysConfigConverter.java +++ b/modules/qi-sysconfig/src/main/java/org/jpos/qi/sysconfig/SysConfigConverter.java @@ -41,7 +41,7 @@ public SysConfig convertToPresentation(String value, ValueContext context) { if (value != null) { try { return DB.exec( (db) -> { - SysConfigManager mgr = new SysConfigManager(db); + SysConfigManager mgr = new SysConfigManager(db, prefix); return mgr.getObject(value); }); } catch (Exception e) {