Skip to content

Commit 170b8f4

Browse files
authored
Merge pull request #24 from scaleoutsoftware/br-dev
Br dev
2 parents 37c5446 + 12d1ae8 commit 170b8f4

File tree

11 files changed

+285
-29
lines changed

11 files changed

+285
-29
lines changed

Core/src/main/java/com/scaleoutsoftware/digitaltwin/core/InitContext.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ public InitContext() {}
4040
*/
4141
public abstract <T extends DigitalTwinBase> TimerActionResult startTimer(String timerName, Duration interval, TimerType timerType, TimerHandler<T> timerHandler);
4242

43+
/**
44+
* Retrieve a {@link SharedData} accessor for this model's shared data.
45+
* @return a {@link SharedData} instance.
46+
*/
47+
public abstract SharedData getSharedModelData();
48+
49+
/**
50+
* Retrieve a {@link SharedData} accessor for globally shared data.
51+
* @return a {@link SharedData} instance.
52+
*/
53+
public abstract SharedData getSharedGlobalData();
54+
4355
/**
4456
* Get the model-unique Id identifier of the initializing digital twin instance.
4557
* @return the id identifier.

Core/src/main/java/com/scaleoutsoftware/digitaltwin/core/ModelSchema.java

Lines changed: 196 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class ModelSchema {
2727
private final String simulationProcessorType;
2828
private final String messageType;
2929
private final String assemblyName;
30+
private final String entryPoint;
3031
private final String azureDigitalTwinModelName;
3132
private final String persistenceProvider;
3233
private final boolean enablePersistence;
@@ -35,7 +36,7 @@ public class ModelSchema {
3536
private final List<AlertProviderConfiguration> alertProviders;
3637

3738
private ModelSchema() {
38-
modelType = messageProcessorType = simulationProcessorType = messageType = assemblyName = azureDigitalTwinModelName = persistenceProvider = null;
39+
modelType = messageProcessorType = simulationProcessorType = messageType = assemblyName = entryPoint = azureDigitalTwinModelName = persistenceProvider = null;
3940
enablePersistence = false;
4041
enableSimulationSupport = false;
4142
enableMessageRecording = false;
@@ -68,6 +69,36 @@ public ModelSchema(
6869
enableSimulationSupport = false;
6970
messageType = msgClass;
7071
assemblyName = "NOT_USED_BY_JAVA_MODELS";
72+
entryPoint = null;
73+
alertProviders = null;
74+
azureDigitalTwinModelName = null;
75+
enablePersistence = false;
76+
enableMessageRecording = false;
77+
persistenceProvider = null;
78+
}
79+
80+
public ModelSchema(
81+
String dtClass,
82+
String mpClass,
83+
String msgClass,
84+
String ep) {
85+
if( (dtClass == null || dtClass.isEmpty()) ||
86+
(mpClass == null || mpClass.isEmpty()) ||
87+
(msgClass == null || msgClass.isEmpty())
88+
) {
89+
throw new IllegalArgumentException(String.format("Expected value for dtClass, mpClass, and msgClass; actual values: %s, %s, %s",
90+
(dtClass == null ? "null dtClass" : dtClass),
91+
(mpClass == null ? "null mpClass" : mpClass),
92+
(msgClass == null ? "null mpClass" : msgClass)
93+
));
94+
}
95+
modelType = dtClass;
96+
messageProcessorType = mpClass;
97+
simulationProcessorType = null;
98+
enableSimulationSupport = false;
99+
messageType = msgClass;
100+
assemblyName = "NOT_USED_BY_JAVA_MODELS";
101+
entryPoint = ep;
71102
alertProviders = null;
72103
azureDigitalTwinModelName = null;
73104
enablePersistence = false;
@@ -103,13 +134,46 @@ public ModelSchema(
103134
enableSimulationSupport = false;
104135
messageType = msgClass;
105136
assemblyName = "NOT_USED_BY_JAVA_MODELS";
137+
entryPoint = null;
106138
alertProviders = null;
107139
azureDigitalTwinModelName = null;
108140
enablePersistence = false;
109141
enableMessageRecording = emr;
110142
persistenceProvider = null;
111143
}
112144

145+
public ModelSchema(
146+
String dtClass,
147+
String mpClass,
148+
String msgClass,
149+
String ep,
150+
boolean emr) {
151+
if( (dtClass == null || dtClass.isEmpty()) ||
152+
(mpClass == null || mpClass.isEmpty()) ||
153+
(msgClass == null || msgClass.isEmpty())
154+
) {
155+
throw new IllegalArgumentException(String.format("Expected value for dtClass, mpClass, and msgClass; actual values: %s, %s, %s",
156+
(dtClass == null ? "null dtClass" : dtClass),
157+
(mpClass == null ? "null mpClass" : mpClass),
158+
(msgClass == null ? "null mpClass" : msgClass)
159+
));
160+
}
161+
modelType = dtClass;
162+
messageProcessorType = mpClass;
163+
simulationProcessorType = null;
164+
enableSimulationSupport = false;
165+
messageType = msgClass;
166+
assemblyName = "NOT_USED_BY_JAVA_MODELS";
167+
entryPoint = ep;
168+
alertProviders = null;
169+
azureDigitalTwinModelName = null;
170+
enablePersistence = false;
171+
enableMessageRecording = emr;
172+
persistenceProvider = null;
173+
}
174+
175+
// TODO
176+
113177
/**
114178
* Creates a model schema from a digital twin class, a message processor class, a message class, and
115179
* alert provider configurations.
@@ -139,6 +203,7 @@ public ModelSchema(
139203
enableSimulationSupport = false;
140204
messageType = msgClass;
141205
assemblyName = "NOT_USED_BY_JAVA_MODELS";
206+
entryPoint = null;
142207
azureDigitalTwinModelName = null;
143208
enablePersistence = false;
144209
enableMessageRecording = false;
@@ -179,6 +244,40 @@ public ModelSchema(
179244
enableSimulationSupport = true;
180245
messageType = msgClass;
181246
assemblyName = "NOT_USED_BY_JAVA_MODELS";
247+
entryPoint = null;
248+
azureDigitalTwinModelName = null;
249+
enablePersistence = false;
250+
persistenceProvider = null;
251+
enableMessageRecording = false;
252+
alertProviders = alertingProviders;
253+
}
254+
255+
public ModelSchema(
256+
String dtClass,
257+
String mpClass,
258+
String msgClass,
259+
String spClass,
260+
String ep,
261+
List<AlertProviderConfiguration> alertingProviders) {
262+
if( (dtClass == null || dtClass.isEmpty()) ||
263+
(mpClass == null || mpClass.isEmpty()) ||
264+
(msgClass == null || msgClass.isEmpty()) ||
265+
(spClass == null || spClass.isEmpty())
266+
) {
267+
throw new IllegalArgumentException(String.format("Expected value for dtClass, mpClass, and msgClass; actual values: %s, %s, %s",
268+
(dtClass == null ? "null dtClass" : dtClass),
269+
(mpClass == null ? "null mpClass" : mpClass),
270+
(msgClass == null ? "null mpClass" : msgClass),
271+
(spClass == null ? "null mpClass" : msgClass)
272+
));
273+
}
274+
modelType = dtClass;
275+
messageProcessorType = mpClass;
276+
simulationProcessorType = spClass;
277+
enableSimulationSupport = true;
278+
messageType = msgClass;
279+
assemblyName = "NOT_USED_BY_JAVA_MODELS";
280+
entryPoint = ep;
182281
azureDigitalTwinModelName = null;
183282
enablePersistence = false;
184283
persistenceProvider = null;
@@ -221,6 +320,41 @@ public ModelSchema(
221320
enableSimulationSupport = true;
222321
messageType = msgClass;
223322
assemblyName = "NOT_USED_BY_JAVA_MODELS";
323+
entryPoint = null;
324+
azureDigitalTwinModelName = null;
325+
enablePersistence = false;
326+
persistenceProvider = null;
327+
enableMessageRecording = emr;
328+
alertProviders = alertingProviders;
329+
}
330+
331+
public ModelSchema(
332+
String dtClass,
333+
String mpClass,
334+
String msgClass,
335+
String spClass,
336+
String ep,
337+
List<AlertProviderConfiguration> alertingProviders,
338+
boolean emr) {
339+
if( (dtClass == null || dtClass.isEmpty()) ||
340+
(mpClass == null || mpClass.isEmpty()) ||
341+
(msgClass == null || msgClass.isEmpty()) ||
342+
(spClass == null || spClass.isEmpty())
343+
) {
344+
throw new IllegalArgumentException(String.format("Expected value for dtClass, mpClass, and msgClass; actual values: %s, %s, %s",
345+
(dtClass == null ? "null dtClass" : dtClass),
346+
(mpClass == null ? "null mpClass" : mpClass),
347+
(msgClass == null ? "null mpClass" : msgClass),
348+
(spClass == null ? "null mpClass" : msgClass)
349+
));
350+
}
351+
modelType = dtClass;
352+
messageProcessorType = mpClass;
353+
simulationProcessorType = spClass;
354+
enableSimulationSupport = true;
355+
messageType = msgClass;
356+
assemblyName = "NOT_USED_BY_JAVA_MODELS";
357+
entryPoint = ep;
224358
azureDigitalTwinModelName = null;
225359
enablePersistence = false;
226360
persistenceProvider = null;
@@ -262,6 +396,7 @@ public ModelSchema(
262396
messageType = msgClass;
263397
enableMessageRecording = false;
264398
assemblyName = "NOT_USED_BY_JAVA_MODELS";
399+
entryPoint = null;
265400
persistenceProvider = persistenceType.name();
266401
switch (persistenceType) {
267402
case AzureDigitalTwinsService:
@@ -319,6 +454,7 @@ public ModelSchema(
319454
messageType = msgClass;
320455
enableMessageRecording = emr;
321456
assemblyName = "NOT_USED_BY_JAVA_MODELS";
457+
entryPoint = null;
322458
persistenceProvider = persistenceType.name();
323459
switch (persistenceType) {
324460
case AzureDigitalTwinsService:
@@ -377,6 +513,7 @@ public ModelSchema(
377513
enableMessageRecording = false;
378514
messageType = msgClass;
379515
assemblyName = "NOT_USED_BY_JAVA_MODELS";
516+
entryPoint = null;
380517
persistenceProvider = persistenceType.name();
381518
switch (persistenceType) {
382519
case AzureDigitalTwinsService:
@@ -437,6 +574,56 @@ public ModelSchema(
437574
enableMessageRecording = emr;
438575
messageType = msgClass;
439576
assemblyName = "NOT_USED_BY_JAVA_MODELS";
577+
entryPoint = null;
578+
persistenceProvider = persistenceType.name();
579+
switch (persistenceType) {
580+
case AzureDigitalTwinsService:
581+
azureDigitalTwinModelName = adtName;
582+
enablePersistence = true;
583+
break;
584+
case SQLite:
585+
case SQLServer:
586+
case DynamoDb:
587+
case CosmosDb:
588+
enablePersistence = true;
589+
azureDigitalTwinModelName = null;
590+
break;
591+
default:
592+
azureDigitalTwinModelName = null;
593+
enablePersistence = false;
594+
break;
595+
}
596+
alertProviders = alertingProviders;
597+
}
598+
599+
public ModelSchema(
600+
String dtClass,
601+
String mpClass,
602+
String msgClass,
603+
String simulationProcessorClass,
604+
String adtName,
605+
String ep,
606+
PersistenceProviderType persistenceType,
607+
List<AlertProviderConfiguration> alertingProviders,
608+
boolean emr) {
609+
if( (dtClass == null || dtClass.isEmpty()) ||
610+
(mpClass == null || mpClass.isEmpty()) ||
611+
(msgClass == null || msgClass.isEmpty())
612+
) {
613+
throw new IllegalArgumentException(String.format("Expected value for dtClass, mpClass, and msgClass; actual values: %s, %s, %s",
614+
(dtClass == null ? "null dtClass" : dtClass),
615+
(mpClass == null ? "null mpClass" : mpClass),
616+
(msgClass == null ? "null mpClass" : msgClass)
617+
));
618+
}
619+
modelType = dtClass;
620+
messageProcessorType = mpClass;
621+
simulationProcessorType = simulationProcessorClass;
622+
enableSimulationSupport = true;
623+
enableMessageRecording = emr;
624+
messageType = msgClass;
625+
assemblyName = "NOT_USED_BY_JAVA_MODELS";
626+
entryPoint = ep;
440627
persistenceProvider = persistenceType.name();
441628
switch (persistenceType) {
442629
case AzureDigitalTwinsService:
@@ -538,4 +725,12 @@ public String getAzureDigitalTwinModelName() {
538725
public boolean messageRecordingEnabled() {
539726
return enableMessageRecording;
540727
}
728+
729+
/**
730+
* Retrieves the packaged model's entry point (fully-qualified class name -- FQCN -- of a Java main) for launching.
731+
* @return the entry point for launching.
732+
*/
733+
public String getEntryPoint() {
734+
return entryPoint;
735+
}
541736
}

Core/src/main/java/com/scaleoutsoftware/digitaltwin/core/PersistenceProviderType.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,22 @@ public enum PersistenceProviderType implements Serializable {
4949
*/
5050
Unconfigured("", 0);
5151

52-
private String _name;
53-
private int _value;
52+
private final String _name;
53+
private final int _value;
5454
PersistenceProviderType(String name, int ordinal) {
5555
_name = name;
5656
_value = ordinal;
5757
}
5858

59+
60+
public String getName() {
61+
return _name;
62+
}
63+
64+
public int getServiceOrdinalValue() {
65+
return _value;
66+
}
67+
5968
/**
6069
* Return the PersistenceProviderType from a string value. We do not rely on Java's naming
6170
* because the string values need to be cross-platform and the names may be different in each language.

Core/src/main/java/com/scaleoutsoftware/digitaltwin/core/ProcessingContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public ProcessingContext() {}
145145

146146
/**
147147
* <p>
148-
* This method sends an alert message to supported systems. See "TODO: Link to docs" for more details on supported systems.
148+
* This method sends an alert message to supported systems.
149149
* </p>
150150
*
151151
* <p>

Development/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group 'com.scaleoutsoftware.digitaltwin'
7-
version '3.0.7'
7+
version '3.2.1'
88

99
sourceCompatibility = JavaVersion.VERSION_12
1010

@@ -20,8 +20,8 @@ dependencies {
2020
testImplementation group: 'junit', name: 'junit', version: '4.12'
2121
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
2222
// public build configuration
23-
implementation group: 'com.scaleoutsoftware.digitaltwin', name: 'core', version: '3.0.7'
23+
//implementation group: 'com.scaleoutsoftware.digitaltwin', name: 'core', version: '3.0.7'
2424

2525
// local build configuration
26-
//implementation fileTree(dir: '..\\Core\\build\\libs\\', include: '*.jar')
26+
implementation fileTree(dir: '..\\Core\\build\\libs\\', include: '*.jar')
2727
}

0 commit comments

Comments
 (0)