Skip to content

Commit 537f1e9

Browse files
committed
Merge branch 'release/4.17.0'
2 parents 2c99610 + 2ed1a28 commit 537f1e9

File tree

379 files changed

+33871
-2920
lines changed

Some content is hidden

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

379 files changed

+33871
-2920
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Run this script from the parent directory, e.g. psql -f migrations/migrate-20251201.sql
2+
3+
\i updates/NET-486-cloud-controls.sql

solarnet-db-setup/postgres/postgres-init-din.sql

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,3 +715,47 @@ CREATE TRIGGER change_datum_stream_enabled
715715
FOR EACH ROW
716716
WHEN (OLD.enabled IS DISTINCT FROM NEW.enabled)
717717
EXECUTE PROCEDURE solardin.change_datum_stream_enabled();
718+
719+
720+
/**
721+
* Cloud control configuration.
722+
*
723+
* @column user_id the ID of the account owner
724+
* @column id the ID of the configuration
725+
* @column created the creation date
726+
* @column modified the modification date
727+
* @column enabled a flag to mark the configuration as enabled for use by application or not
728+
* @column cname a name for the configuration
729+
* @column int_id the ID of the integration associated with this configuration
730+
* @column node_id the control node ID
731+
* @column control_id the control ID (does NOT support placeholders)
732+
* @column cref the cloud control reference
733+
* @column sident the cloud integration service identifier
734+
* @column sprops the cloud integration service properties
735+
*/
736+
CREATE TABLE solardin.cin_control (
737+
user_id BIGINT NOT NULL,
738+
id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
739+
created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
740+
modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
741+
enabled BOOLEAN NOT NULL DEFAULT FALSE,
742+
cname CHARACTER VARYING(64) NOT NULL,
743+
int_id BIGINT NOT NULL,
744+
node_id BIGINT NOT NULL,
745+
control_id CHARACTER VARYING(64) NOT NULL,
746+
cref CHARACTER VARYING(4096),
747+
sident CHARACTER VARYING(128) NOT NULL,
748+
sprops JSONB,
749+
CONSTRAINT cin_control_pk PRIMARY KEY (user_id, id),
750+
CONSTRAINT cin_control_user_fk FOREIGN KEY (user_id)
751+
REFERENCES solaruser.user_user (id) MATCH SIMPLE
752+
ON UPDATE NO ACTION ON DELETE CASCADE,
753+
CONSTRAINT cin_control_int_fk FOREIGN KEY (user_id, int_id)
754+
REFERENCES solardin.cin_integration (user_id, id) MATCH SIMPLE
755+
ON UPDATE NO ACTION ON DELETE CASCADE
756+
);
757+
758+
-- add index on node + control for fast lookup
759+
CREATE INDEX IF NOT EXISTS cin_control_control_idx ON solardin.cin_control (node_id, control_id);
760+
761+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* Node instruction task configuration.
3+
*
4+
* @column user_id the ID of the account owner
5+
* @column id the ID of the configuration
6+
* @column enabled a flag to mark the configuration as enabled for use by application or not
7+
* @column cname a name for the configuration
8+
* @column node_id the associted node ID
9+
* @column topic the instruction topic
10+
* @column schedule a cron schedule or number of seconds
11+
* @column status task status, e.g. queued, executing, error
12+
* @column exec_at the next scheduled time for the task to execute
13+
* @column sprops task service properties
14+
* @column last_exec_at last execution time
15+
* @column message result message
16+
* @column rprops execution result properties
17+
*/
18+
CREATE TABLE solaruser.user_node_instr_task (
19+
user_id BIGINT NOT NULL,
20+
id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
21+
enabled BOOLEAN NOT NULL DEFAULT FALSE,
22+
cname CHARACTER VARYING(64) NOT NULL,
23+
node_id BIGINT NOT NULL,
24+
topic CHARACTER VARYING(64) NOT NULL,
25+
schedule CHARACTER VARYING(64) NOT NULL,
26+
status CHARACTER(1) NOT NULL,
27+
exec_at TIMESTAMP WITH TIME ZONE NOT NULL,
28+
sprops JSONB,
29+
last_exec_at TIMESTAMP WITH TIME ZONE,
30+
message TEXT,
31+
rprops JSONB,
32+
CONSTRAINT user_instr_task_pk PRIMARY KEY (user_id, id),
33+
CONSTRAINT user_node_instr_task_user_node_fk FOREIGN KEY (user_id, node_id)
34+
REFERENCES solaruser.user_node (user_id, node_id) MATCH SIMPLE
35+
ON UPDATE CASCADE ON DELETE CASCADE
36+
);
37+
38+
-- indexes to speed up claim task query
39+
CREATE INDEX user_node_instr_task_exec_idx ON solaruser.user_node_instr_task
40+
(exec_at) WHERE (status = 'q' AND enabled);
41+
42+
43+
/**************************************************************************************************
44+
* FUNCTION solaruser.claim_node_instr_task()
45+
*
46+
* "Claim" an instruction task from the user_instr_task table that has a status of 'q'
47+
* and change the status to 'p' and return it. The tasks will be claimed from oldest to newest
48+
* based on the exec_at column.
49+
*
50+
* @return the claimed row, if one was able to be claimed
51+
*/
52+
CREATE OR REPLACE FUNCTION solaruser.claim_node_instr_task()
53+
RETURNS SETOF solaruser.user_node_instr_task LANGUAGE plpgsql VOLATILE ROWS 1 AS
54+
$$
55+
DECLARE
56+
rec solaruser.user_node_instr_task;
57+
58+
-- include ORDER BY here to encourage user_instr_task_exec_idx to be used
59+
curs CURSOR FOR SELECT * FROM solaruser.user_node_instr_task t
60+
WHERE t.status = 'q'
61+
AND t.enabled
62+
AND t.exec_at <= CURRENT_TIMESTAMP
63+
ORDER BY t.exec_at
64+
LIMIT 1
65+
FOR UPDATE SKIP LOCKED;
66+
BEGIN
67+
OPEN curs;
68+
FETCH NEXT FROM curs INTO rec;
69+
IF FOUND THEN
70+
UPDATE solaruser.user_node_instr_task SET status = 'p' WHERE CURRENT OF curs;
71+
rec.status = 'p';
72+
RETURN NEXT rec;
73+
END IF;
74+
CLOSE curs;
75+
RETURN;
76+
END
77+
$$;

solarnet-db-setup/postgres/postgres-init.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
\i postgres-init-user-datum-import.sql
3636
\i postgres-init-user-event-hook.sql
3737
\i postgres-init-user-events.sql
38+
\i postgres-init-user-instr.sql
3839
\i postgres-init-ocpp-schema.sql
3940
\i postgres-init-ocpp.sql
4041
\i postgres-init-oscp-schema.sql
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/**
2+
* Cloud control configuration.
3+
*
4+
* @column user_id the ID of the account owner
5+
* @column id the ID of the configuration
6+
* @column created the creation date
7+
* @column modified the modification date
8+
* @column enabled a flag to mark the configuration as enabled for use by application or not
9+
* @column cname a name for the configuration
10+
* @column int_id the ID of the integration associated with this configuration
11+
* @column node_id the control node ID
12+
* @column control_id the control ID (does NOT support placeholders)
13+
* @column cref the cloud control reference
14+
* @column sident the cloud integration service identifier
15+
* @column sprops the cloud integration service properties
16+
*/
17+
CREATE TABLE solardin.cin_control (
18+
user_id BIGINT NOT NULL,
19+
id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
20+
created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
21+
modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
22+
enabled BOOLEAN NOT NULL DEFAULT FALSE,
23+
cname CHARACTER VARYING(64) NOT NULL,
24+
int_id BIGINT NOT NULL,
25+
node_id BIGINT NOT NULL,
26+
control_id CHARACTER VARYING(64) NOT NULL,
27+
cref CHARACTER VARYING(4096),
28+
sident CHARACTER VARYING(128) NOT NULL,
29+
sprops JSONB,
30+
CONSTRAINT cin_control_pk PRIMARY KEY (user_id, id),
31+
CONSTRAINT cin_control_user_fk FOREIGN KEY (user_id)
32+
REFERENCES solaruser.user_user (id) MATCH SIMPLE
33+
ON UPDATE NO ACTION ON DELETE CASCADE,
34+
CONSTRAINT cin_control_int_fk FOREIGN KEY (user_id, int_id)
35+
REFERENCES solardin.cin_integration (user_id, id) MATCH SIMPLE
36+
ON UPDATE NO ACTION ON DELETE CASCADE
37+
);
38+
39+
-- add index on node + control for fast lookup
40+
CREATE INDEX IF NOT EXISTS cin_control_control_idx ON solardin.cin_control (node_id, control_id);
41+
42+
43+
/**
44+
* Node instruction task configuration.
45+
*
46+
* @column user_id the ID of the account owner
47+
* @column id the ID of the configuration
48+
* @column enabled a flag to mark the configuration as enabled for use by application or not
49+
* @column cname a name for the configuration
50+
* @column node_id the associted node ID
51+
* @column topic the instruction topic
52+
* @column schedule a cron schedule or number of seconds
53+
* @column status task status, e.g. queued, executing, error
54+
* @column exec_at the next scheduled time for the task to execute
55+
* @column sprops task service properties
56+
* @column last_exec_at last execution time
57+
* @column message result message
58+
* @column rprops execution result properties
59+
*/
60+
CREATE TABLE solaruser.user_node_instr_task (
61+
user_id BIGINT NOT NULL,
62+
id BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
63+
enabled BOOLEAN NOT NULL DEFAULT FALSE,
64+
cname CHARACTER VARYING(64) NOT NULL,
65+
node_id BIGINT NOT NULL,
66+
topic CHARACTER VARYING(64) NOT NULL,
67+
schedule CHARACTER VARYING(64) NOT NULL,
68+
status CHARACTER(1) NOT NULL,
69+
exec_at TIMESTAMP WITH TIME ZONE NOT NULL,
70+
sprops JSONB,
71+
last_exec_at TIMESTAMP WITH TIME ZONE,
72+
message TEXT,
73+
rprops JSONB,
74+
CONSTRAINT user_instr_task_pk PRIMARY KEY (user_id, id),
75+
CONSTRAINT user_node_instr_task_user_node_fk FOREIGN KEY (user_id, node_id)
76+
REFERENCES solaruser.user_node (user_id, node_id) MATCH SIMPLE
77+
ON UPDATE CASCADE ON DELETE CASCADE
78+
);
79+
80+
-- indexes to speed up claim task query
81+
CREATE INDEX user_node_instr_task_exec_idx ON solaruser.user_node_instr_task
82+
(exec_at) WHERE (status = 'q' AND enabled);
83+
84+
85+
/**************************************************************************************************
86+
* FUNCTION solaruser.claim_node_instr_task()
87+
*
88+
* "Claim" an instruction task from the user_instr_task table that has a status of 'q'
89+
* and change the status to 'p' and return it. The tasks will be claimed from oldest to newest
90+
* based on the exec_at column.
91+
*
92+
* @return the claimed row, if one was able to be claimed
93+
*/
94+
CREATE OR REPLACE FUNCTION solaruser.claim_node_instr_task()
95+
RETURNS SETOF solaruser.user_node_instr_task LANGUAGE plpgsql VOLATILE ROWS 1 AS
96+
$$
97+
DECLARE
98+
rec solaruser.user_node_instr_task;
99+
100+
-- include ORDER BY here to encourage user_instr_task_exec_idx to be used
101+
curs CURSOR FOR SELECT * FROM solaruser.user_node_instr_task t
102+
WHERE t.status = 'q'
103+
AND t.enabled
104+
AND t.exec_at <= CURRENT_TIMESTAMP
105+
ORDER BY t.exec_at
106+
LIMIT 1
107+
FOR UPDATE SKIP LOCKED;
108+
BEGIN
109+
OPEN curs;
110+
FETCH NEXT FROM curs INTO rec;
111+
IF FOUND THEN
112+
UPDATE solaruser.user_node_instr_task SET status = 'p' WHERE CURRENT OF curs;
113+
rec.status = 'p';
114+
RETURN NEXT rec;
115+
END IF;
116+
CLOSE curs;
117+
RETURN;
118+
END
119+
$$;

solarnet/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ subprojects {
9494
myBatisStarterVersion = '3.0.4'
9595
okhttp3Mockwebserver = '4.12.0'
9696
saxonVersion = '12.5'
97-
snCommonVersion = '4.7.0'
97+
snCommonVersion = '4.11.0'
9898
snCommonExprSpelVersion = '4.1.0'
9999
snCommonMqttVersion = '5.0.0'
100100
snCommonMqttNettyVersion = '5.0.0'
@@ -103,7 +103,7 @@ subprojects {
103103
snCommonOcpp201Version = '2.0.1'
104104
snCommonOcppWebJakartaVersion = '3.3.0'
105105
snCommonPkiBcVersion = '4.0.0'
106-
snCommonWebJakartaVersion = '2.1.1'
106+
snCommonWebJakartaVersion = '2.1.2'
107107
snExternalOcpp16JakartaVersion = '1.0.1'
108108
snExternalOcpp201Version = '1.0.0'
109109
springdocStarterVersion = '2.8.8'
@@ -128,18 +128,18 @@ subprojects {
128128
]
129129
}
130130

131-
ext['netty.version'] = '4.2.6.Final'
132-
ext['jackson-bom.version'] = '2.20.0'
131+
ext['netty.version'] = '4.2.9.Final'
132+
ext['jackson-bom.version'] = '2.20.1'
133133

134134
dependencies {
135135
testImplementation libraries.hamcrest,
136136
libraries.mockito,
137137
libraries.mockitoJupiter,
138138
libraries.easymock,
139-
'net.javacrumbs.json-unit:json-unit-assertj:4.1.1',
139+
'net.javacrumbs.json-unit:json-unit-assertj:5.1.0',
140140
'org.junit.platform:junit-platform-launcher'
141141

142-
errorprone 'com.google.errorprone:error_prone_core:2.42.0'
142+
errorprone 'com.google.errorprone:error_prone_core:2.45.0'
143143
}
144144

145145
configurations {

solarnet/cloud-integrations/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
id 'java-library'
33
id 'eclipse'
4-
id 'org.springframework.boot' version '3.5.6' apply false
4+
id 'org.springframework.boot' version '3.5.9' apply false
55
}
66

77
apply plugin: 'java-library'
@@ -14,7 +14,7 @@ dependencyManagement {
1414
}
1515

1616
description = 'SolarNet: Cloud Integrations'
17-
version = '2.7.1'
17+
version = '2.8.0'
1818

1919
base {
2020
archivesName = 'solarnet-cloud-integrations'

0 commit comments

Comments
 (0)