19 package org.turro.indicator;
21 import java.util.Collections;
22 import java.util.List;
23 import java.util.concurrent.locks.Lock;
24 import java.util.concurrent.locks.ReentrantLock;
25 import org.turro.string.Strings;
26 import org.turro.annotation.ElephantIndicator;
27 import org.turro.reflection.Instances;
28 import org.turro.string.Words;
39 return variables.stream().anyMatch(v -> !v.isPreprocess());
71 if(iIndicator.itsMine(root)) {
80 if(iIndicator.itsMine(variable)) {
89 return ei !=
null ? ei.
getValue(variable, entity) : 0.0;
94 return ei !=
null ? ei.
getValue(variable, entity, relatedPath) : 0.0;
100 if(!Strings.isBlank(indicator) && indicator.contains(
":")) {
101 String v[] = indicator.split(
"\\s*:\\s*");
102 if(!Strings.isBlank(v[0]) && !Strings.isBlank(v[1]) && !Strings.isBlank(v[2])) {
104 if(iIndicator.getClass().getSimpleName().equals(v[1])) {
105 return iIndicator.readIndicator(v[0], v[2]);
114 String entityPath, String relatedPath, String indicator) {
116 if(iIndicator.getClass().getSimpleName().equals(indicatorClass)) {
117 return iIndicator.readIndicator(jpaClass,
118 Words.instance(
".", entityPath, relatedPath, indicator).toString());
124 public static List<IndicatorVariable>
getVariables(String indicatorClass) {
126 if(iIndicator.getClass().getSimpleName().equals(indicatorClass)) {
127 return iIndicator.getAllVariables();
130 return Collections.EMPTY_LIST;
135 private static List<IElephantIndicator> _indicators;
136 private static final Lock indicatorLock =
new ReentrantLock();
139 if(_indicators ==
null) {
140 indicatorLock.lock();
142 if(_indicators ==
null) {
144 _indicators.stream().forEach(i -> i.initIndicator());
145 _indicators.stream().forEach(i -> i.prepareIndicator());
148 indicatorLock.unlock();
static IndicatorVariable result(String root, VariableType type)
static List< IndicatorVariable > getVariables(String indicatorClass)
static boolean hasDirectProcess(List< IndicatorVariable > variables)
static double getValue(Object entity, IndicatorVariable variable)
static double getValue(Object entity, String relatedPath, IndicatorVariable variable)
static IndicatorResult readIndicator(String jpaClass, String indicatorClass, String entityPath, String relatedPath, String indicator)
static List< IndicatorVariable > getRankingVariables(String root)
static List< IElephantIndicator > getIndicators()
static IndicatorResult readIndicator(String indicator)
static IElephantIndicator getIndicator(IndicatorVariable variable)
static List< IndicatorVariable > getMatchingVariables(String root)
static IElephantIndicator getIndicator(String root)
static List< IndicatorVariable > getMatchingVariablesFinal(String root)
static List< IndicatorVariable > getRankingVariablesFinal(String root)
static IndicatorVariable getVariable(String root, String name)
IndicatorVariable getVariable(String name)
List< IndicatorVariable > getAllRankingVariables(String root)
List< IndicatorVariable > getAllMatchingVariables(String root)
double getValue(IndicatorVariable variable, Object entity)