vice;
abstract class GridBacking lt; Entity gt; implements Serializable {
static final long serialVersionUID=- 2639437488394357753L;
@ InjectEntityService entityService;
Entity blank;
@ PostConstructvoid init () throws Exception {= getNewBlank ();
}
abstract Class lt; Entity gt; getType ();
Entity getNewBlank () throws Exception {getType (). getConstructor (). newInstance ();
}
Collection lt; Entity gt; getList () {entityService.getList (getType ());
}
Entity getBlank () {blank;
}
public void save () throws Exception {.save (blank);=getNewBlank ();
}
void remove (Entity obj) {.remove (obj);
}
}. javaru.ulstu.secretary.grid;
javax.faces.view. ViewScoped; javax.inject. Named;
ru.ulstu.secretary.entity. Pay; static ru.ulstu.secretary.utils. DateUtil.getToday;
@ Named
@ ViewScopedclass PayBacking extends GridBacking lt; Pay gt; {
static final long serialVersionUID=- 520158973748994729L;
@ OverrideClass lt; Pay gt; getType () {Pay.class;
}
Pay getNewBlank () {pay=new Pay () ;. setDate (getToday ()); pay;
}
int getCount () {getList (). size ();
}
double getBalance () {getList (). stream (). mapToDouble (pay - gt; pay.getBalance ()). sum ();
}
}. javaru.ulstu.secretary.grid;
java.util. Collection;
javax.faces.view. ViewScoped; javax.inject. Inject; javax.inject. Named;
ru.ulstu.secretary.entity. Repay;
@ Named
@ ViewScopedclass RepayBacking extends GridBacking lt; Repay gt; {
static final long serialVersionUID=- 5042825198701507477L;
@ InjectDebtBacking debtBacking;
@ OverrideClass lt; Repay gt; getType () {Repay.class;
}
@ OverrideCollection lt; Repay gt; getList () {debtBacking.getDebt () == null? null: debtBacking.getDebt (). getRepays ();
}
}. javaru.ulstu.secretary.grid;
java.io. Serializable;
javax.faces.view. ViewScoped; javax.inject. Inject; javax.inject. Named;
ru.ulstu.secretary.db. TaskByDateService; ru.ulstu.secretary.utils. DateUtil;
@ Named
@ ViewScopedclass TodayBacking implements Serializable {
private static final long serialVersionUID=- 6983619217861517215L;
@ InjectTaskByDateService taskByDateService;
int getCount () {taskByDateService.getList (DateUtil.getToday ()). size ();
}
}. javaru.ulstu.secretary.utils;
java.util. Calendar; java.util. Date; java.util. GregorianCalendar;
class DateUtil {
static Date getToday () {calendar=new GregorianCalendar () ;. set (Calendar.HOUR_OF_DAY, 0) ;. set (Calendar.MINUTE, 0) ;. set (Calendar.SECOND, 0) ; .set (Calendar.MILLISECOND, 0); calendar.getTime ();
}
}. xhtml
lt; ui: composition template=»/ WEB-INF/tpl/base.xhtml» xmlns: ui=«# justify gt; lt; ui: define name =« title » gt ; # {i18n.balance} lt;/ui: define gt;
lt; ui: define name=«body» gt;
lt; s: chart backing= # {balanceBacking} / gt;
lt;/ui: define gt;
lt;/ui: composition gt; .xhtml
lt; ui: composition template=»/ WEB-INF/tpl/base.xhtml» xmlns: ui=«# justify gt; lt; ui: define name =« title » gt ; # {i18n.category} lt;/ui: define gt;
lt; ui: define name=«body» gt;
lt; s: chart backing="# {categoryBalanceBacking}» hasPeriod=«false»/?? gt;
lt;/ui: define gt;
lt;/ui: composition gt; .xhtml