19 package org.turro.matching;
21 import org.turro.string.Strings;
22 import org.turro.auth.Authentication;
23 import org.turro.elephant.db.WhereClause;
24 import org.turro.entities.EntityCombobox;
25 import org.turro.indicator.Formulas;
26 import org.turro.indicator.Indicators;
27 import org.turro.indicator.VariablesListbox;
28 import org.turro.log.SystemLogType;
29 import org.turro.log.SystemLogger;
30 import org.turro.path.Path;
31 import org.turro.reflection.Instances;
32 import org.turro.reflection.Reflections;
33 import org.zkoss.zk.ui.Executions;
34 import org.zkoss.zk.ui.IdSpace;
35 import org.zkoss.zk.ui.event.Event;
36 import org.zkoss.zk.ui.select.Selectors;
37 import org.zkoss.zk.ui.select.annotation.Listen;
38 import org.zkoss.zk.ui.select.annotation.Wire;
39 import org.zkoss.zul.Checkbox;
40 import org.zkoss.zul.Grid;
41 import org.zkoss.zul.ListModel;
42 import org.zkoss.zul.ListModelList;
43 import org.zkoss.zul.Panel;
44 import org.zkoss.zul.Textbox;
56 private Textbox formula;
68 private Checkbox reversed;
73 @Listen(
"onSelect = #matching")
76 if(getProcess() !=
null) {
83 @Listen(
"onSelect = #orderBy")
88 @Listen(
"onSelect = #variables")
91 formula.setValue(formula.getValue() +
" " + variables.
getObjectValue().getName());
95 @Listen(
"onSelect = #related")
100 @Listen(
"onCheck = #reversed")
106 Path path =
new Path((String) evt.getData());
107 related.
setRoot(path.getRoot());
109 reversed.setChecked(!reversed.isChecked());
113 @Listen(
"onClick = #execute")
123 private void updateControls() {
124 if(getProcess() !=
null) {
130 formula.setValue(Formulas.load().getFormula(Reflections.of(matching.
getObjectValue()).simpleName()));
131 result.setModel(getModel());
133 formula.setValue(
null);
134 variables.setModel(
new ListModelList());
135 orderBy.setModel(
new ListModelList());
136 result.setModel(
new ListModelList());
140 private ListModel<?> getModel() {
141 ListModelList list =
new ListModelList();
143 WhereClause wc =
new WhereClause();
144 wc.addClause(
"select m from " + getProcess().instanceClass().getSimpleName() +
" m");
145 wc.addClause(
"where m.concept = :concept");
147 wc.addNamedValue(
"concept",
"*");
151 if(reversed.isChecked()) {
152 wc.addClause(
"and m.entityPath = :related");
154 wc.addClause(
"and m.relatedPath = :related");
157 wc.addClause(
"order by m.matching DESC");
158 list.addAll(getProcess().createDao().getResultList(wc));
163 private void executeFor(String matchingEntity) {
164 if(getProcess() !=
null) {
171 private ProcessMatching currentProcess;
173 private void resetProcess() {
174 currentProcess =
null;
177 private ProcessMatching getProcess() {
178 if(currentProcess ==
null) {
179 for(ProcessMatching process : Instances.cached().byAnnotation(ElephantMatching.class, ProcessMatching.class)) {
180 if(process.instanceClass().getName().equals(matching.
getObjectValue())) {
181 currentProcess = process;
185 return currentProcess;
191 Executions.createComponents(
"/WEB-INF/_zul/bs/comps/matching/matchingControl.zul",
this,
null);
192 Selectors.wireComponents(
this,
this,
false);
193 Selectors.wireEventListeners(
this,
this);
static IContact getIContact()
void setRoot(String root)
void setEntityPath(String entityPath)
static List< IndicatorVariable > getMatchingVariables(String root)
static List< IndicatorVariable > getMatchingVariablesFinal(String root)
static ISystemLogger getInstance()
void onSelectItem(Event evt)
abstract String indicatorsRoot()
abstract String relatedRoot()
void doLog(SystemLogType type, Object entity, String comment, Serializable data)