use of de.janrufmonitor.repository.filter.IFilter in project janrufmonitor by tbrandt77.
the class Journal method createFieldEditors.
protected void createFieldEditors() {
this.setTitle(this.m_i18n.getString(this.getNamespace(), "title", "label", this.m_language));
this.noDefaultAndApplyButton();
List l = new ArrayList();
l.add(new IFilter[0]);
IFilterManager jfm = new JournalFilterManager();
Properties c = getRuntime().getConfigManagerFactory().getConfigManager().getProperties(this.getConfigNamespace());
Iterator iter = c.keySet().iterator();
String key = null;
while (iter.hasNext()) {
key = (String) iter.next();
if (key.startsWith("filter_")) {
String filter = c.getProperty(key);
l.add(jfm.getFiltersFromString(filter));
}
}
// added 2015/04/03: added runtime filters
if (jfm.hasRuntimeFilters()) {
IFilter[][] rf = jfm.getRuntimeFilters();
if (rf != null && rf.length > 0) {
for (int i = 0; i < rf.length; i++) l.add(rf[i]);
}
}
// added 2015/04/01: sort filter list
Collections.sort(l, new Comparator() {
public int compare(Object f1, Object f2) {
if (f1 != null && f2 != null && f1 instanceof IFilter[] && f2 instanceof IFilter[]) {
if (((IFilter[]) f1).length == ((IFilter[]) f2).length) {
return (((IFilter[]) f2)[0].toString().compareTo(((IFilter[]) f1)[0].toString()));
}
if (((IFilter[]) f1).length < ((IFilter[]) f2).length)
return -1;
return 1;
}
return 0;
}
});
String[][] filters = new String[l.size()][2];
for (int i = 0; i < l.size(); i++) {
filters[i][0] = getFilterLabel(jfm, (IFilter[]) l.get(i));
filters[i][1] = jfm.getFiltersToString((IFilter[]) l.get(i));
}
ComboFieldEditor cfe = new ComboFieldEditor(this.getConfigNamespace() + SEPARATOR + "filter", this.m_i18n.getString(getNamespace(), "filter", "label", this.m_language), filters, this.getFieldEditorParent());
addField(cfe);
StringFieldEditor sfe = new StringFieldEditor(getConfigNamespace() + SEPARATOR + "rt_filters_years", this.m_i18n.getString(this.getNamespace(), "rt_filters_years", "label", this.m_language), 2, this.getFieldEditorParent());
sfe.setTextLimit(2);
addField(sfe);
}
use of de.janrufmonitor.repository.filter.IFilter in project janrufmonitor by tbrandt77.
the class JournalFilterManager method getRuntimeFilters.
@Override
public IFilter[][] getRuntimeFilters() {
String cfg = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(Journal.NAMESPACE, "rt_filters_years");
int years = 1;
if (cfg != null && cfg.length() > 0) {
years = Integer.parseInt(cfg);
}
if (years < 0)
return new IFilter[][] {};
int c_y = Calendar.getInstance().get(Calendar.YEAR);
int c_m = Calendar.getInstance().get(Calendar.MONTH);
List filters = new ArrayList(years * 12 + years);
for (int y = c_y - years; y <= c_y; y++) {
filters.add(new YearFilter(y));
int max_month = 12;
if (y == c_y)
max_month = c_m + 1;
for (int m = 1; m <= max_month; m++) {
filters.add(new MonthYearFilter(y, m));
}
}
IFilter[][] filters2 = new IFilter[filters.size()][1];
for (int i = 0; i < filters2.length; i++) filters2[i][0] = (IFilter) filters.get(i);
return filters2;
}
use of de.janrufmonitor.repository.filter.IFilter in project janrufmonitor by tbrandt77.
the class Last10Calls method getConfiguration.
public Properties getConfiguration() {
Properties saved = super.getConfiguration();
Properties journalConfig = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperties(Journal.NAMESPACE);
if (journalConfig != null && journalConfig.size() > 0) {
saved.setProperty(JournalConfigConst.CFG_REPOSITORY, journalConfig.getProperty(JournalConfigConst.CFG_REPOSITORY));
}
IFilter[] filters = new IFilter[1];
int count = 10;
try {
count = Integer.parseInt(saved.getProperty(CFG_COUNT, "10"));
} catch (Exception e) {
}
filters[0] = new ItemCountFilter(count);
saved.setProperty("filter", new JournalFilterManager().getFiltersToString(filters));
return saved;
}
Aggregations