lass) .stream (). mapToDouble (debt - gt; debt.getUnpaid (x)). sum ();
}
@ OverrideString getRedirect () {«diary»;
}
}. javaru.ulstu.secretary.criteria;
java.util. Collection;
javax.annotation. PostConstruct; javax.persistence. EntityManager; javax.persistence. PersistenceContext; javax.persistence.criteria. CriteriaBuilder; javax.persistence.criteria. CriteriaQuery; javax.persistence.criteria. Predicate; javax.persistence.criteria. Root;
abstract class CriteriaService lt; Entity gt; {
@ PersistenceContextEntityManager entityManager;
CriteriaBuilder builder;
CriteriaQuery lt; Entity gt; query; Root lt; Entity gt; root;
@ PostConstructvoid initCriteriaService () {= entityManager.getCriteriaBuilder ();=builder.createQuery (getType ());=query.from (getType ());
}
abstract Class lt; Entity gt; getType ();
CriteriaBuilder getBuilder () {builder;
}
CriteriaQuery lt; Entity gt; getQuery () {query;
}
Root lt; Entity gt; getRoot () {root;
}
Collection lt; Entity gt; getList (Predicate restriction) {.where (restriction); entityManager.createQuery (query) .getResultList ();
}
}. javaru.ulstu.secretary.criteria; java.util. Collection;
abstract class PropertyCriteriaService lt; Entity, Property gt; extends CriteriaService lt; Entity gt; {
Collection lt; Entity gt; getList (Property property) {getList (getBuilder (). equal (getRoot (). get (getProperty ()), property));
}
abstract String getProperty ();
}. javaru.ulstu.secretary.criteria;
java.util. Collection;
abstract class RangeCriteriaService lt; Entity, Property extends Comparable lt; Property gt; gt; extends CriteriaService lt; Entity gt; {
Collection lt; Entity gt; getAll (Property from, Property to) {getList (getBuilder (). between (getRoot (). get (getProperty ()), from, to));
}
abstract String getProperty ();
}. javaru.ulstu.secretary.criteria;
java.util. Collection; abstract class UpperLimitCriteriaService lt; X extends Comparable lt; X gt ;, Y gt; extends CriteriaService lt; Y gt; {
Collection lt; Y gt; getList (X x) {getList (getBuilder (). lessThanOrEqualTo (getRoot (). get (getProperty ()), x));
}
abstract String getProperty ();
}. javaru.ulstu.secretary.db;
java.util. Date;
javax.ejb. Stateless;
ru.ulstu.secretary.criteria. PropertyCriteriaService; ru.ulstu.secretary.entity. Action;
@ Statelessclass ActionByDateService extends PropertyCriteriaService lt; Action, Date gt; {
@ OverrideString getProperty () {«date»;
}
@ OverrideClass lt; Action gt; getType () {Action.class;
}
}. javaru.ulstu.secretary.db;
java.util. Arrays;
javax.ejb. Stateless; javax.inject. Named;
ru.ulstu.secretary.entity. Category;
@ Named
@ Statelessclass CategoryService {
Iterable lt; Category gt; getList () {Arrays.asList (Category.values ??());
}
}. javaru.ulstu.secretary.db;
java.util. Date;
javax.ejb. Stateless;
ru.ulstu.secretary.criteria. UpperLimitCriteriaService; ru.ulstu.secretary.entity. Debt;
@ Statelessclass DebtByDateService extends UpperLimitCriteriaService lt; Date, Debt gt; {
@ OverrideString getProperty () {«date»;
}
@ OverrideClass lt; Debt gt; getType () {Debt.class;
}
}. javaru.ulstu.secretary.db;
java.util. Collection;
javax.ejb. Stateless; j...