Skip to content

Commit

Permalink
Merge branch 'release/3.37.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
msqr committed Oct 29, 2024
2 parents 5741fa5 + eaecb33 commit 5204e62
Show file tree
Hide file tree
Showing 63 changed files with 4,116 additions and 495 deletions.
3 changes: 3 additions & 0 deletions solarnet-db-setup/postgres/migrations/migrate-20241029.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Run this script from the parent directory, e.g. psql -f migrations/migrate-20241029.sql

\i updates/NET-414-cloud-integrations-flux.sql
69 changes: 59 additions & 10 deletions solarnet-db-setup/postgres/postgres-init-din.sql
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,29 @@ CREATE TABLE solardin.inin_endpoint_auth_cred (
Cloud Integrations
============================================ */

/**
* Cloud integration user (account) configuration.
*
* @column user_id the ID of the account owner
* @column id the ID of the configuration
* @column created the creation date
* @column modified the modification date
* @column pub_in a flag to publish datum streams to SolarIn
* @column pub_flux a flag to publish datum streams to SolarFlux
*/
CREATE TABLE solardin.cin_user_settings (
user_id BIGINT NOT NULL,
created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
pub_in BOOLEAN NOT NULL DEFAULT TRUE,
pub_flux BOOLEAN NOT NULL DEFAULT FALSE,
CONSTRAINT cin_user_settings_pk PRIMARY KEY (user_id),
CONSTRAINT cin_user_settings_user_fk FOREIGN KEY (user_id)
REFERENCES solaruser.user_user (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE
);


/**
* Cloud integration configuration.
*
Expand Down Expand Up @@ -435,6 +458,30 @@ CREATE TABLE solardin.cin_datum_stream (
);


/**
* Cloud datum stream settings, to override cin_user_settings.
*
* @column user_id the ID of the account owner
* @column ds_id the ID of the datum stream associated with this configuration
* @column created the creation date
* @column modified the modification date
* @column pub_in a flag to publish datum streams to SolarIn
* @column pub_flux a flag to publish datum streams to SolarFlux
*/
CREATE TABLE solardin.cin_datum_stream_settings (
user_id BIGINT NOT NULL,
ds_id BIGINT NOT NULL,
created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
pub_in BOOLEAN NOT NULL DEFAULT TRUE,
pub_flux BOOLEAN NOT NULL DEFAULT TRUE,
CONSTRAINT cin_datum_stream_settings_pk PRIMARY KEY (user_id, ds_id),
CONSTRAINT cin_datum_stream_settings_ds_fk FOREIGN KEY (user_id, ds_id)
REFERENCES solardin.cin_datum_stream (user_id, id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE
);


/**
* Cloud datum stream poll task table.
*
Expand All @@ -460,7 +507,7 @@ CREATE TABLE solardin.cin_datum_stream_poll_task (

-- index to speed up claim task query
CREATE INDEX cin_datum_stream_poll_task_exec_idx ON solardin.cin_datum_stream_poll_task
(exec_at) INCLUDE (status);
(exec_at DESC) INCLUDE (status);


/**************************************************************************************************
Expand Down Expand Up @@ -510,11 +557,12 @@ BEGIN
WHERE status = CASE NEW.enabled WHEN TRUE THEN 'c' ELSE 'q' END
AND user_id = NEW.user_id
AND ds_id IN (
SELECT id
FROM solardin.cin_datum_stream
WHERE user_id = NEW.user_id
AND int_id = NEW.id
AND enabled = TRUE
SELECT cds.id
FROM solardin.cin_datum_stream cds
INNER JOIN solardin.cin_datum_stream_map cdsm ON cdsm.id = cds.map_id
WHERE cds.user_id = NEW.user_id
AND cdsm.int_id = NEW.id
AND cds.enabled = TRUE
);

RETURN NEW;
Expand Down Expand Up @@ -545,10 +593,11 @@ BEGIN
AND ds_id = NEW.id
AND EXISTS (
SELECT 1
FROM solardin.cin_integration
WHERE user_id = NEW.user_id
AND id = NEW.int_id
AND enabled = TRUE
FROM solardin.cin_datum_stream_map cdsm
INNER JOIN solardin.cin_integration ci ON ci.id = cdsm.int_id
WHERE ci.user_id = NEW.user_id
AND cdsm.id = NEW.map_id
AND ci.enabled = TRUE
);

RETURN NEW;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Cloud integration user (account) configuration.
*
* @column user_id the ID of the account owner
* @column id the ID of the configuration
* @column created the creation date
* @column modified the modification date
* @column pub_in a flag to publish datum streams to SolarIn
* @column pub_flux a flag to publish datum streams to SolarFlux
*/
CREATE TABLE solardin.cin_user_settings (
user_id BIGINT NOT NULL,
created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
pub_in BOOLEAN NOT NULL DEFAULT TRUE,
pub_flux BOOLEAN NOT NULL DEFAULT FALSE,
CONSTRAINT cin_user_settings_pk PRIMARY KEY (user_id),
CONSTRAINT cin_user_settings_user_fk FOREIGN KEY (user_id)
REFERENCES solaruser.user_user (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE
);

/**
* Cloud datum stream settings, to override cin_user_settings.
*
* @column user_id the ID of the account owner
* @column ds_id the ID of the datum stream associated with this configuration
* @column created the creation date
* @column modified the modification date
* @column pub_in a flag to publish datum streams to SolarIn
* @column pub_flux a flag to publish datum streams to SolarFlux
*/
CREATE TABLE solardin.cin_datum_stream_settings (
user_id BIGINT NOT NULL,
ds_id BIGINT NOT NULL,
created TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
modified TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
pub_in BOOLEAN NOT NULL DEFAULT TRUE,
pub_flux BOOLEAN NOT NULL DEFAULT TRUE,
CONSTRAINT cin_datum_stream_settings_pk PRIMARY KEY (user_id, ds_id),
CONSTRAINT cin_datum_stream_settings_ds_fk FOREIGN KEY (user_id, ds_id)
REFERENCES solardin.cin_datum_stream (user_id, id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE
);
2 changes: 1 addition & 1 deletion solarnet/cloud-integrations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencyManagement {
}

description = 'SolarNet: Cloud Integrations'
version = '1.6.0'
version = '1.7.0'

base {
archivesName = 'solarnet-cloud-integrations'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* API for a cloud integration service.
*
* @author matt
* @version 1.1
* @version 1.2
*/
public interface CloudIntegrationService
extends Identity<String>, SettingSpecifierProvider, LocalizedServiceInfoProvider {
Expand Down Expand Up @@ -65,6 +65,13 @@ public interface CloudIntegrationService
*/
String BASE_URL_SETTING = "baseUrl";

/**
* The audit service name for content processed (bytes).
*
* @since 1.2
*/
String CONTENT_PROCESSED_AUDIT_SERVICE = "ccio";

/**
* Get a mapping of "well known" service URIs.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import net.solarnetwork.central.biz.UserEventAppenderBiz;
import net.solarnetwork.central.biz.UserServiceAuditor;
import net.solarnetwork.central.c2c.domain.CloudIntegrationsUserEvents;
import net.solarnetwork.settings.SettingSpecifier;
import net.solarnetwork.settings.support.BaseSettingsSpecifierLocalizedServiceInfoProvider;
Expand All @@ -35,7 +36,7 @@
* cloud integration services.
*
* @author matt
* @version 1.0
* @version 1.1
*/
public abstract class BaseCloudIntegrationsIdentifiableService
extends BaseSettingsSpecifierLocalizedServiceInfoProvider<String>
Expand All @@ -53,6 +54,9 @@ public abstract class BaseCloudIntegrationsIdentifiableService
/** The service settings. */
protected final List<SettingSpecifier> settings;

/** A user service auditor. */
protected UserServiceAuditor userServiceAuditor;

/**
* Constructor.
*
Expand Down Expand Up @@ -89,4 +93,25 @@ public final List<SettingSpecifier> getSettingSpecifiers() {
return settings;
}

/**
* Get the user service auditor.
*
* @return the auditor, or {@literal null}
* @since 1.1
*/
public UserServiceAuditor getUserServiceAuditor() {
return userServiceAuditor;
}

/**
* Set the user service auditor.
*
* @param userServiceAuditor
* the auditor to set, or {@literal null}
* @since 1.1
*/
public void setUserServiceAuditor(UserServiceAuditor userServiceAuditor) {
this.userServiceAuditor = userServiceAuditor;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.web.client.RestOperations;
import net.solarnetwork.central.biz.UserEventAppenderBiz;
import net.solarnetwork.central.biz.UserServiceAuditor;
import net.solarnetwork.central.c2c.biz.CloudIntegrationsExpressionService;
import net.solarnetwork.central.c2c.dao.CloudDatumStreamConfigurationDao;
import net.solarnetwork.central.c2c.dao.CloudDatumStreamMappingConfigurationDao;
Expand All @@ -41,7 +42,7 @@
* {@link RestOperations} support.
*
* @author matt
* @version 1.1
* @version 1.2
*/
public abstract class BaseRestOperationsCloudDatumStreamService extends BaseCloudDatumStreamService {

Expand Down Expand Up @@ -89,4 +90,10 @@ public BaseRestOperationsCloudDatumStreamService(String serviceIdentifier, Strin
this.restOpsHelper = requireNonNullArgument(restOpsHelper, "restOpsHelper");
}

@Override
public void setUserServiceAuditor(UserServiceAuditor userServiceAuditor) {
super.setUserServiceAuditor(userServiceAuditor);
restOpsHelper.setUserServiceAuditor(userServiceAuditor);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.web.client.RestOperations;
import net.solarnetwork.central.biz.UserEventAppenderBiz;
import net.solarnetwork.central.biz.UserServiceAuditor;
import net.solarnetwork.central.c2c.biz.CloudDatumStreamService;
import net.solarnetwork.central.c2c.http.RestOperationsHelper;
import net.solarnetwork.settings.SettingSpecifier;
Expand All @@ -40,7 +41,7 @@
* {@link RestOperations} support.
*
* @author matt
* @version 1.0
* @version 1.1
*/
public abstract class BaseRestOperationsCloudIntegrationService extends BaseCloudIntegrationService {

Expand Down Expand Up @@ -79,4 +80,10 @@ public BaseRestOperationsCloudIntegrationService(String serviceIdentifier, Strin
this.restOpsHelper = requireNonNullArgument(restOpsHelper, "restOpsHelper");
}

@Override
public void setUserServiceAuditor(UserServiceAuditor userServiceAuditor) {
super.setUserServiceAuditor(userServiceAuditor);
restOpsHelper.setUserServiceAuditor(userServiceAuditor);
}

}
Loading

0 comments on commit 5204e62

Please sign in to comment.