Skip to content

Commit

Permalink
User sortered by value method. Constructors for sysconfigCombo
Browse files Browse the repository at this point in the history
  • Loading branch information
sprevilla committed Sep 5, 2019
1 parent 513a0b4 commit 4f8d3af
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
12 changes: 12 additions & 0 deletions modules/qi-core/src/main/java/org/jpos/qi/QIHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ public DataProvider getSysConfigsDataProvider (String prefix) {
});
}

public Collection<SysConfig> 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<String,Boolean> orders, String prefix) throws Exception {
return ((List) DB.exec(db -> {
SysConfigManager mgr = new SysConfigManager(db, prefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -12,4 +17,23 @@ public SysConfigComboBox (String caption, DataProvider dataProvider) {
setItemCaptionGenerator((ItemCaptionGenerator<SysConfig>) SysConfig::getValue);
setEmptySelectionAllowed(false);
}


public SysConfigComboBox (String caption, Collection<SysConfig> items) {
super(caption);
setItems(items);
setItemCaptionGenerator((ItemCaptionGenerator<SysConfig>) 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>) SysConfig::getValue);
setEmptySelectionAllowed(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4f8d3af

Please # to comment.