Skip to content

Commit 3621701

Browse files
authored
0.45.0
* DSInfo Metadata * Trend Implementations
2 parents df28d64 + 0f93032 commit 3621701

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2431
-465
lines changed

build.gradle

Lines changed: 9 additions & 1 deletion
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.44.0'
8+
version '0.45.0'
99

1010
sourceCompatibility = 1.6
1111
targetCompatibility = 1.6
@@ -38,6 +38,14 @@ subprojects {
3838

3939
}
4040

41+
if (JavaVersion.current().isJava8Compatible()) {
42+
allprojects {
43+
tasks.withType(Javadoc) {
44+
options.addStringOption('Xdoclint:none', '-quiet')
45+
}
46+
}
47+
}
48+
4149
wrapper {
4250
gradleVersion = '4.10.2'
4351
}

dslink-v2-poc/src/main/java/org/iot/dsa/dslink/poc/MainNode.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ public class MainNode extends DSMainNode implements Runnable {
3838
@Override
3939
protected void declareDefaults() {
4040
super.declareDefaults();
41-
declareDefault("Incrementing Int", DSLong.valueOf(1)).setReadOnly(true);
41+
declareDefault("Incrementing Int", DSLong.valueOf(1)).setReadOnly(true)
42+
.getMetadata()
43+
.setDescription("this is a description")
44+
.setUnit("ms");
4245
declareDefault("Writable Boolean", DSBool.valueOf(true)).setAdmin(true);
4346
declareDefault("Writable Enum",
4447
DSFlexEnum.valueOf("On",
@@ -72,7 +75,7 @@ public ActionResult invoke(DSInfo info, ActionInvocation invocation) {
7275
@Override
7376
public void prepareParameter(DSInfo info, DSMap parameter) {
7477
}
75-
});
78+
}).getMetadata().setActionGroup("Tests", "List");
7679
}
7780

7881
private class ListHandler implements OutboundListHandler {

dslink-v2/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ test {
1414
javadoc {
1515
exclude("**/com/**")
1616
}
17-

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/sys/logging/DSLevel.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public enum DSLevel implements DSIEnum, DSIValue {
2323
INFO(LoggingConstants.info),
2424
WARN(LoggingConstants.warn),
2525
ERROR(LoggingConstants.error),
26-
ADMIN(LoggingConstants.admin),
2726
OFF(LoggingConstants.off);
2827

2928
///////////////////////////////////////////////////////////////////////////
@@ -137,8 +136,6 @@ public static DSLevel valueOf(Level arg) {
137136
return WARN;
138137
case LoggingConstants.SEVERE: //error
139138
return ERROR;
140-
case LoggingConstants.ADMIN: //admin
141-
return ADMIN;
142139
case LoggingConstants.OFF: //off
143140
return OFF;
144141
}

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/sys/logging/LoggerNodeLevel.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public enum LoggerNodeLevel implements DSIEnum, DSIValue {
2424
INFO(LoggingConstants.info),
2525
WARN(LoggingConstants.warn),
2626
ERROR(LoggingConstants.error),
27-
ADMIN(LoggingConstants.admin),
2827
OFF(LoggingConstants.off);
2928

3029
///////////////////////////////////////////////////////////////////////////
@@ -138,8 +137,6 @@ public static LoggerNodeLevel valueOf(Level arg) {
138137
return WARN;
139138
case LoggingConstants.SEVERE: //error
140139
return ERROR;
141-
case LoggingConstants.ADMIN: //admin
142-
return ADMIN;
143140
case LoggingConstants.OFF: //off
144141
return OFF;
145142
}

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/sys/logging/LoggingConstants.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ public class LoggingConstants {
1212
static final int INFO = 800;
1313
static final int WARN = 900;
1414
static final int SEVERE = 1000;
15-
static final int ADMIN = 2000;
1615
static final int OFF = Integer.MAX_VALUE;
1716

1817
public static final Level all = Level.ALL;
@@ -21,7 +20,6 @@ public class LoggingConstants {
2120
public static final Level info = Level.INFO;
2221
public static final Level warn = Level.WARNING;
2322
public static final Level error = Level.SEVERE;
24-
public static final Level admin = new CustomLevel("ADMIN", ADMIN);
2523
public static final Level off = Level.OFF;
2624

2725
}

dslink-v2/src/main/java/org/iot/dsa/io/AbstractReader.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ public Token last() {
217217
* Subclasses must override this, read the next item from the stream, then call one of the
218218
* setXxx methods.
219219
* <p>
220-
* <p>
221-
* <p>
222220
* {@inheritDoc}
223221
*/
224222
@Override

dslink-v2/src/main/java/org/iot/dsa/io/DSIReader.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,19 @@
1010
* between. To get an entire graph, call getElement(), getMap() or getList(). Otherwise, use the
1111
* next() method to iterate the elements of the input.
1212
* <p>
13-
* <p>
14-
* <p>
1513
* When next() returns:
16-
*
1714
* <ul>
18-
*
1915
* <li>ROOT - The initial state, not in a list or map, call next() or getElement().
20-
*
2116
* <li>BEGIN_LIST - Call getList() to decodeKeys the entire list, or call next again to get the
2217
* first element of the list (or END_LIST if empty).
23-
*
2418
* <li>BEGIN_MAP - Call getMap() to decodeKeys the entire map, or call next again to get the first
2519
* key of the map (or END_MAP if empty).
26-
*
2720
* <li>END_INPUT - Parsing is finished, close the reader.
28-
*
2921
* <li>END_LIST - The current list is complete, call next again.
30-
*
3122
* <li>END_MAP - The current map is complete, call next again.
32-
*
3323
* <li>BOOLEAN,DOUBLE,LONG,NULL,STRING - Call getElement() or the corresponding getter.
34-
*
3524
* </ul>
3625
* <p>
37-
* <p>
38-
* <p>
3926
* Be aware that if the underlying encoding (such as JSON) doesn't provide a mechanism to
4027
* differentiate between data types (such as numbers), values might not get as the same type they
4128
* were encoded.

dslink-v2/src/main/java/org/iot/dsa/io/DSIWriter.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,18 @@
66
/**
77
* An encoder that can be used to encode large graphs with or without object instances.
88
* <p>
9-
* <p>
10-
* <p>
119
* To simply encode a DSMap or DSList, use the value(DSElement) method.
1210
* <p>
1311
* For example:
14-
*
1512
* <ul>
16-
*
1713
* <li>new JsonWriter(out).value(myMap).close();
18-
*
1914
* </ul>
2015
* <p>
21-
* <p>
22-
* <p>
2316
* Otherwise, you can stream data struct without using any DSIObject instances:
24-
*
2517
* <ul>
26-
*
2718
* <li>out.newMap().key("a").value(1).key("b").value(2).key("c").value(3).endMap();
28-
*
2919
* </ul>
3020
* <p>
31-
* <p>
32-
* <p>
3321
* Be aware that if the underlying encoding (such as JSON) doesn't provide a mechanism to
3422
* differentiate between data types (such as numbers), values might not get as the same type they
3523
* were encoded.

dslink-v2/src/main/java/org/iot/dsa/io/NodeDecoder.java

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
package org.iot.dsa.io;
22

3+
import java.io.ByteArrayInputStream;
34
import java.util.HashMap;
45
import org.iot.dsa.io.DSIReader.Token;
6+
import org.iot.dsa.io.json.JsonReader;
57
import org.iot.dsa.node.DSElement;
68
import org.iot.dsa.node.DSIObject;
79
import org.iot.dsa.node.DSIStorable;
810
import org.iot.dsa.node.DSIValue;
911
import org.iot.dsa.node.DSInfo;
12+
import org.iot.dsa.node.DSMap;
1013
import org.iot.dsa.node.DSNode;
1114
import org.iot.dsa.node.DSRegistry;
1215
import org.iot.dsa.util.DSException;
1316

1417
/**
1518
* Decodes a node (tree) that was encoded with NodeEncoder.
1619
* <p>
17-
* <p>
18-
* <p>
1920
* This is for storing the configuration database, not for DSA interop.
2021
*
2122
* @author Aaron Hansen
@@ -50,6 +51,17 @@ public static DSNode decode(DSIReader in) {
5051
return decoder.read();
5152
}
5253

54+
/**
55+
* Reads a node tree from the give byte array.
56+
*/
57+
public static DSNode decode(byte[] bytes) {
58+
ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
59+
JsonReader reader = new JsonReader(bin, "UTF-8");
60+
DSNode ret = decode(reader);
61+
reader.close();
62+
return ret;
63+
}
64+
5365
/**
5466
* Will create new instances for anything without a decoder, otherwise returns the decoder
5567
* instance.
@@ -105,6 +117,7 @@ private void readChild(DSNode parent) {
105117
DSElement state = null;
106118
String type = null;
107119
DSInfo info = null;
120+
DSMap meta = null;
108121
DSIObject obj = null;
109122
while (in.next() != Token.END_MAP) {
110123
validateEqual(in.last(), Token.STRING);
@@ -116,12 +129,12 @@ private void readChild(DSNode parent) {
116129
validateEqual(in.next(), Token.STRING);
117130
name = in.getString();
118131
info = parent.getInfo(name);
119-
if (info != null) {
120-
;//TODO parent.reorderToLast(info);
121-
}
122132
} else if ("i".equals(key)) {
123133
in.next();
124134
state = in.getElement();
135+
} else if ("m".equals(key)) {
136+
validateEqual(in.next(), Token.BEGIN_MAP);
137+
meta = in.getMap();
125138
} else if ("v".equals(key)) {
126139
if (name == null) {
127140
throw new IllegalStateException("Missing name");
@@ -133,14 +146,8 @@ private void readChild(DSNode parent) {
133146
} else {
134147
parent.put(info, obj);
135148
}
136-
}
137-
if (info != null) {
138-
if (obj == null) {
139-
obj = info.getObject();
140-
}
141-
if (state != null) {
142-
info.decodeState(state);
143-
}
149+
} else if (info != null) {
150+
obj = info.getObject();
144151
}
145152
if (obj == null) { //dynamic, or declareDefaults was modified
146153
in.next();
@@ -170,19 +177,22 @@ private void readChild(DSNode parent) {
170177
} else {
171178
parent.put(info, obj);
172179
}
180+
} else if (info != null) {
181+
obj = info.getObject();
173182
}
174-
if (info != null) {
175-
if (obj == null) {
176-
obj = info.getObject();
177-
}
178-
if (state != null) {
179-
info.decodeState(state);
180-
}
183+
}
184+
if (info != null) {
185+
if (state != null) {
186+
info.decodeState(state);
187+
}
188+
if (meta != null) {
189+
info.setMetadata(meta);
181190
}
182191
}
183192
if (obj == null) {
184193
throw new IllegalStateException("Could not decode " + parent.getPath() + "/" + name);
185194
}
195+
//TODO parent.reorderToLast(info);
186196
}
187197

188198
private void readChildren(DSNode parent) {

0 commit comments

Comments
 (0)