Skip to content

Commit b74e19e

Browse files
authored
0.70.4
* Fix DSAction.prepareParameters() not being called.
2 parents 417a7bc + 8970132 commit b74e19e

File tree

5 files changed

+35
-16
lines changed

5 files changed

+35
-16
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subprojects {
55
apply plugin: 'maven'
66

77
group 'org.iot-dsa'
8-
version '0.70.3'
8+
version '0.70.4'
99

1010
targetCompatibility = JavaVersion.VERSION_1_8
1111
sourceCompatibility = JavaVersion.VERSION_1_8

dslink-v2-api/src/main/java/org/iot/dsa/dslink/Value.java

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public interface Value extends Node {
1717
/**
1818
* Does not have to be the current value, used to determine the type
1919
* of the value.
20-
* @return
2120
*/
2221
public DSIValue toValue();
2322

dslink-v2-api/src/main/java/org/iot/dsa/node/action/DSAction.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.iot.dsa.node.DSIMetadata;
77
import org.iot.dsa.node.DSIObject;
88
import org.iot.dsa.node.DSIValue;
9+
import org.iot.dsa.node.DSInfo;
910
import org.iot.dsa.node.DSMap;
1011
import org.iot.dsa.node.DSMetadata;
1112

@@ -208,9 +209,15 @@ public int getParameterCount() {
208209
return -1;
209210
}
210211

212+
/**
213+
* Puts the metadata from an already added parameter into the bucket, and calls prepareParameter
214+
* so that is can be updated for any current state.
215+
* @see #prepareParameter(DSInfo, DSMap)
216+
*/
211217
@Override
212-
public void getParameterMetadata(int idx, DSMap bucket) {
218+
public void getParameterMetadata(DSInfo target, int idx, DSMap bucket) {
213219
bucket.putAll(parameters.get(idx));
220+
prepareParameter(target, bucket);
214221
}
215222

216223
@Override
@@ -228,6 +235,17 @@ public ActionResults invoke(DSIActionRequest request) {
228235
return null;
229236
}
230237

238+
/**
239+
* Called for each parameter as it is being sent to the requester in response to a list
240+
* request. The intent is to update the default value to represent the current state of the
241+
* target. Does nothing by default.
242+
*
243+
* @param target The target of the action.
244+
* @param parameter Map representing a single parameter.
245+
*/
246+
public void prepareParameter(DSInfo target, DSMap parameter) {
247+
}
248+
231249
/**
232250
* Sets the action group, which is null by default.
233251
*/

dslink-v2-api/src/main/java/org/iot/dsa/node/action/DSIAction.java

-11
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,6 @@ public default ActionResults makeResults(DSIActionRequest req, DSIResults res) {
100100
return toResults(req, res);
101101
}
102102

103-
/**
104-
* Called for each parameter as it is being sent to the requester in response to a list
105-
* request. The intent is to update the default value to represent the current state of the
106-
* target. Does nothing by default.
107-
*
108-
* @param target The info about the target of the action (its parent).
109-
* @param parameter Map representing a single parameter.
110-
*/
111-
public default void prepareParameter(DSInfo target, DSMap parameter) {
112-
}
113-
114103
/**
115104
* Makes an aync action result for the given parameters. If the DIResult defines columns those
116105
* will be used, otherwise the columns defined by the action will be used.

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/responder/DSInboundList.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.iot.dsa.node.DSNode;
3030
import org.iot.dsa.node.DSPath;
3131
import org.iot.dsa.node.DSString;
32+
import org.iot.dsa.node.action.DSIAction;
3233
import org.iot.dsa.node.event.DSEvent;
3334
import org.iot.dsa.node.event.DSISubscriber;
3435
import org.iot.dsa.node.event.DSISubscription;
@@ -451,14 +452,22 @@ private void encodeAction(Action action, DSMap cacheMap) {
451452
enqueue("$invokable", "read");
452453
}
453454
}
455+
DSIAction dsiAction = null;
456+
if (action instanceof DSIAction) {
457+
dsiAction = (DSIAction) action;
458+
}
454459
e = cacheMap.remove("$params");
455460
if (e != null) {
456461
enqueue("$params", e);
457462
} else {
458463
DSList list = new DSList();
459464
for (int i = 0, len = action.getParameterCount(); i < len; i++) {
460465
DSMap param = new DSMap();
461-
action.getParameterMetadata(i, param);
466+
if (dsiAction != null) {
467+
dsiAction.getParameterMetadata(target.getParentInfo(), i, param);
468+
} else {
469+
action.getParameterMetadata(i, param);
470+
}
462471
fixRangeTypes(param);
463472
list.add(param);
464473
}
@@ -471,7 +480,11 @@ private void encodeAction(Action action, DSMap cacheMap) {
471480
DSList list = new DSList();
472481
for (int i = 0, len = action.getColumnCount(); i < len; i++) {
473482
DSMap col = new DSMap();
474-
action.getColumnMetadata(i, col);
483+
if (dsiAction != null) {
484+
dsiAction.getColumnMetadata(target.getParentInfo(), i, col);
485+
} else {
486+
action.getColumnMetadata(i, col);
487+
}
475488
fixRangeTypes(col);
476489
list.add(col);
477490
}

0 commit comments

Comments
 (0)