7258a.patch
new/src/com/goldencode/p2j/persist/AbstractQuery.java 2023-04-20 11:02:33 +0000 | ||
---|---|---|
233 | 233 |
** does not match. Also, buffer match check must include the DMO alias. |
234 | 234 |
** 088 CA 20230323 Prevent NPE if the field in EXCEPT/FIELDS can't be resolved in that buffer. |
235 | 235 |
** 089 IAS 20230405 Fixed FILL support for recursive DATA-RELATION |
236 |
** 090 AL2 20230411 Support query close listeners. |
|
236 | 237 |
*/ |
237 | 238 | |
238 | 239 |
/* |
... | ... | |
377 | 378 |
private WeakList<RepositionListener> repoRegistry = null; |
378 | 379 |
|
379 | 380 |
/** Registry of listeners who are notified of query is about to (re-)open. */ |
380 |
private List<QueryOpenListener> openListeners = null;
|
|
381 |
private List<QueryEventListener> eventListeners = null;
|
|
381 | 382 |
|
382 | 383 |
/** Flag to avoid infinite recursion in reposition notification */ |
383 | 384 |
private boolean notificationActive = false; |
... | ... | |
963 | 964 |
* The listener to be notified. |
964 | 965 |
*/ |
965 | 966 |
@Override |
966 |
public void addQueryOpenListener(QueryOpenListener listener)
|
|
967 |
public void addQueryEventListener(QueryEventListener listener)
|
|
967 | 968 |
{ |
968 |
if (openListeners == null)
|
|
969 |
if (eventListeners == null)
|
|
969 | 970 |
{ |
970 |
openListeners = new LinkedList<>();
|
|
971 |
eventListeners = new LinkedList<>();
|
|
971 | 972 |
} |
972 | 973 |
|
973 |
openListeners.add(listener);
|
|
974 |
eventListeners.add(listener);
|
|
974 | 975 |
} |
975 | 976 |
|
976 | 977 |
/** |
... | ... | |
983 | 984 |
@Override |
984 | 985 |
public void notifyQueryOpenListeners(boolean evaluate) |
985 | 986 |
{ |
986 |
if (openListeners != null)
|
|
987 |
if (eventListeners != null)
|
|
987 | 988 |
{ |
988 |
Iterator<QueryOpenListener> iter = openListeners.iterator();
|
|
989 |
Iterator<QueryEventListener> iter = eventListeners.iterator();
|
|
989 | 990 |
while (iter.hasNext()) |
990 | 991 |
{ |
991 | 992 |
iter.next().onQueryOpen(evaluate); |
... | ... | |
994 | 995 |
} |
995 | 996 |
|
996 | 997 |
/** |
998 |
* Notifies the registered QUERY-CLOSE listeners that the event is about to happen. |
|
999 |
*/ |
|
1000 |
@Override |
|
1001 |
public void notifyQueryCloseListeners() |
|
1002 |
{ |
|
1003 |
if (eventListeners != null) |
|
1004 |
{ |
|
1005 |
Iterator<QueryEventListener> iter = eventListeners.iterator(); |
|
1006 |
while (iter.hasNext()) |
|
1007 |
{ |
|
1008 |
iter.next().onQueryClose(); |
|
1009 |
} |
|
1010 |
} |
|
1011 |
} |
|
1012 |
|
|
1013 |
/** |
|
997 | 1014 |
* Register a listener to receive notifications reposition events for this |
998 | 1015 |
* query. |
999 | 1016 |
* |
new/src/com/goldencode/p2j/persist/DynamicQueryHelper.java 2023-04-20 11:04:15 +0000 | ||
---|---|---|
84 | 84 |
** SVL 20230113 Improved performance by replacing some "for-each" loops with indexed "for" loops. |
85 | 85 |
** CA 20230116 Avoid using handle.unwrap, handle.getReference or other BDT usage from within FWD runtime. |
86 | 86 |
** 043 OM 20230215 Handled collision of temporary buffers and tables with same name. |
87 |
** 044 AL2 20230411 Ensure delayed execute is run only once. The flag is reset on query close. |
|
87 | 88 |
*/ |
88 | 89 | |
89 | 90 |
/* |
... | ... | |
154 | 155 |
import com.goldencode.p2j.convert.*; |
155 | 156 |
import com.goldencode.p2j.directory.*; |
156 | 157 |
import com.goldencode.p2j.jmx.*; |
158 |
import com.goldencode.p2j.persist.P2JQuery.QueryEventListener; |
|
157 | 159 |
import com.goldencode.p2j.persist.lock.LockType; |
158 | 160 |
import com.goldencode.p2j.schema.*; |
159 | 161 |
import com.goldencode.p2j.security.*; |
... | ... | |
625 | 627 |
|
626 | 628 |
if (processor.delayedExecute() && query0 != null) |
627 | 629 |
{ |
628 |
query0.addQueryOpenListener((evaluate) -> |
|
629 |
{ |
|
630 |
interpreter.processInstancesWith((o) -> |
|
631 |
{ |
|
632 |
if (o instanceof P2JQuery) |
|
633 |
{ |
|
634 |
((P2JQuery) o).setDynamicPredicate(query0.isDynamicPredicate()); |
|
635 |
} |
|
636 |
}); |
|
637 |
interpreter.interpret("execute"); |
|
638 |
|
|
639 |
if (evaluate) |
|
640 |
{ |
|
641 |
interpreter.evaluateDynamicCalls(); |
|
642 |
} |
|
630 |
query0.addQueryEventListener(new QueryEventListener() { |
|
631 |
|
|
632 |
private boolean executedOnce = false; |
|
633 | ||
634 |
@Override |
|
635 |
public void onQueryOpen(boolean evaluate) |
|
636 |
{ |
|
637 |
if (!executedOnce || evaluate) |
|
638 |
{ |
|
639 |
executedOnce = true; |
|
640 |
interpreter.processInstancesWith((o) -> |
|
641 |
{ |
|
642 |
if (o instanceof P2JQuery) |
|
643 |
{ |
|
644 |
((P2JQuery) o).setDynamicPredicate(query0.isDynamicPredicate()); |
|
645 |
} |
|
646 |
}); |
|
647 |
interpreter.interpret("execute"); |
|
648 |
} |
|
649 |
|
|
650 |
if (evaluate) |
|
651 |
{ |
|
652 |
interpreter.evaluateDynamicCalls(); |
|
653 |
} |
|
654 |
} |
|
655 | ||
656 |
@Override |
|
657 |
public void onQueryClose() |
|
658 |
{ |
|
659 |
executedOnce = false; |
|
660 |
} |
|
661 |
|
|
643 | 662 |
}); |
644 | 663 |
} |
645 | 664 |
return query0; |
new/src/com/goldencode/p2j/persist/P2JQuery.java 2023-04-20 11:02:51 +0000 | ||
---|---|---|
134 | 134 |
** buffer list). |
135 | 135 |
** OM 20220112 Added default implementation for new property 'fillingBrowseRows'. |
136 | 136 |
** 062 IAS 20230105 Fixed FILL support for recursive DATA-RELATION |
137 |
** 063 AL2 20230411 Added query close listeners. |
|
137 | 138 |
*/ |
138 | 139 | |
139 | 140 |
/* |
... | ... | |
2263 | 2264 |
public void clearDynamicFilters(); |
2264 | 2265 |
|
2265 | 2266 |
/** |
2266 |
* Adds a listener to be notified when this query is open. |
|
2267 |
* Adds a listener to be notified when this query is opened or closed.
|
|
2267 | 2268 |
* <p> |
2268 | 2269 |
* Note that this method is only called for dynamic queries only (for the moment). |
2269 | 2270 |
* |
2270 |
* @param qol
|
|
2271 |
* @param qel
|
|
2271 | 2272 |
* The listener to be notified. |
2272 | 2273 |
*/ |
2273 |
public default void addQueryOpenListener(QueryOpenListener qol) {}
|
|
2274 |
public default void addQueryEventListener(QueryEventListener qel) {}
|
|
2274 | 2275 |
|
2275 | 2276 |
/** |
2276 | 2277 |
* Notifies the registered QUERY-OPEN listeners that the even is about to happen. |
... | ... | |
2280 | 2281 |
* in the WHERE clause. |
2281 | 2282 |
*/ |
2282 | 2283 |
public default void notifyQueryOpenListeners(boolean evaluate) {} |
2284 |
|
|
2285 |
/** |
|
2286 |
* Notifies the registered QUERY-CLOSE listeners that the even is about to happen. |
|
2287 |
*/ |
|
2288 |
public default void notifyQueryCloseListeners() {} |
|
2283 | 2289 | |
2284 | 2290 |
/** |
2285 | 2291 |
* Getter for the BASIC-LOGGING attribute. |
... | ... | |
2345 | 2351 |
} |
2346 | 2352 |
|
2347 | 2353 |
/** |
2348 |
* Interface for receiving query open events.
|
|
2354 |
* Interface for receiving query events. |
|
2349 | 2355 |
*/ |
2350 |
public interface QueryOpenListener
|
|
2356 |
public interface QueryEventListener
|
|
2351 | 2357 |
{ |
2352 | 2358 |
/** |
2353 | 2359 |
* Implement this method to receive the notification that the query IS ABOUT TO open. |
... | ... | |
2357 | 2363 |
* in the WHERE clause. |
2358 | 2364 |
*/ |
2359 | 2365 |
public void onQueryOpen(boolean evaluate); |
2366 |
|
|
2367 |
/** |
|
2368 |
* Implement this method to receive the notification that the query IS ABOUT TO close. |
|
2369 |
*/ |
|
2370 |
public void onQueryClose(); |
|
2360 | 2371 |
} |
2361 | 2372 |
|
2362 | 2373 |
/** |
new/src/com/goldencode/p2j/persist/QueryWrapper.java 2023-04-20 11:03:02 +0000 | ||
---|---|---|
277 | 277 |
** HC 20230118 Eliminated some of the uses of String.toUpperCase and/or |
278 | 278 |
** String.toLowerCase for performance. |
279 | 279 |
** 094 IAS 20230405 Fixed FILL support for recursive DATA-RELATION |
280 |
** 095 AL2 20230411 Notify query close listeners. |
|
280 | 281 |
*/ |
281 | 282 | |
282 | 283 |
/* |
... | ... | |
2861 | 2862 |
} |
2862 | 2863 |
|
2863 | 2864 |
/** |
2864 |
* Adds a listener to be notified when this query is open. |
|
2865 |
* Adds a listener to be notified when this query is opened or closed.
|
|
2865 | 2866 |
* <p> |
2866 | 2867 |
* Note that this method is only called for dynamic queries only (for the moment). |
2867 | 2868 |
* |
... | ... | |
2869 | 2870 |
* The listener to be notified. |
2870 | 2871 |
*/ |
2871 | 2872 |
@Override |
2872 |
public void addQueryOpenListener(QueryOpenListener listener)
|
|
2873 |
public void addQueryEventListener(QueryEventListener listener)
|
|
2873 | 2874 |
{ |
2874 | 2875 |
// for the moment the QueryOpen notification only handles dynamic queries. The wrapper does |
2875 | 2876 |
// not notify about the event BUT will propagate the event to its [delegate] if any, and |
2876 | 2877 |
// that query will notify its listeners. |
2877 | 2878 |
if (delegate != null) |
2878 | 2879 |
{ |
2879 |
getDelegate().addQueryOpenListener(listener);
|
|
2880 |
getDelegate().addQueryEventListener(listener);
|
|
2880 | 2881 |
} |
2881 | 2882 |
} |
2882 | 2883 |
|
... | ... | |
3779 | 3780 |
{ |
3780 | 3781 |
boolean success = true; |
3781 | 3782 | |
3783 |
if (delegate != null) |
|
3784 |
{ |
|
3785 |
delegate.notifyQueryCloseListeners(); |
|
3786 |
} |
|
3787 |
|
|
3782 | 3788 |
try |
3783 | 3789 |
{ |
3784 | 3790 |
close(); |