Skip to content

Commit

Permalink
Merge branch 'release/3.34.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
msqr committed Oct 22, 2024
2 parents c88eb26 + 43c6e40 commit 863d297
Show file tree
Hide file tree
Showing 14 changed files with 169 additions and 108 deletions.
2 changes: 1 addition & 1 deletion solarnet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ subprojects {
jsonSchemaValidatorVersion = '1.3.2'
myBatisStarterVersion = '3.0.3'
saxonVersion = '12.4'
snCommonVersion = '3.24.0'
snCommonVersion = '3.24.1'
snCommonExprSpelVersion = '3.1.0'
snCommonMqttVersion = '5.0.0'
snCommonMqttNettyVersion = '4.0.2'
Expand Down
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.3.1'
version = '1.4.0'

base {
archivesName = 'solarnet-cloud-integrations'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.solarnetwork.central.c2c.domain.CloudDatumStreamConfiguration;
import net.solarnetwork.central.c2c.domain.CloudDatumStreamQueryFilter;
import net.solarnetwork.central.c2c.domain.CloudDatumStreamQueryResult;
import net.solarnetwork.central.c2c.domain.CloudIntegrationConfiguration;
import net.solarnetwork.central.domain.UserLongCompositePK;
import net.solarnetwork.domain.Identity;
import net.solarnetwork.domain.LocalizedServiceInfo;
Expand All @@ -39,7 +40,7 @@
* API for a cloud datum stream service.
*
* @author matt
* @version 1.1
* @version 1.2
*/
public interface CloudDatumStreamService
extends Identity<String>, SettingSpecifierProvider, LocalizedServiceInfoProvider {
Expand All @@ -62,8 +63,8 @@ public interface CloudDatumStreamService
/**
* List data values.
*
* @param datumStreamId
* the ID of the {@link CloudDatumStreamConfiguration} to get the
* @param integrationId
* the ID of the {@link CloudIntegrationConfiguration} to get the
* data values for
* @param filters
* an optional set of search filters to limit the data value groups
Expand All @@ -72,7 +73,7 @@ public interface CloudDatumStreamService
* @return the available values, never {@literal null}
*
*/
Iterable<CloudDataValue> dataValues(UserLongCompositePK datumStreamId, Map<String, ?> filters);
Iterable<CloudDataValue> dataValues(UserLongCompositePK integrationId, Map<String, ?> filters);

/**
* Get the latest available datum for a datum stream configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static net.solarnetwork.central.domain.BasicClaimableJobState.Executing;
import static net.solarnetwork.central.domain.BasicClaimableJobState.Queued;
import static net.solarnetwork.util.ObjectUtils.requireNonNullArgument;
import java.io.IOException;
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
Expand All @@ -44,6 +45,8 @@
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.support.PeriodicTrigger;
import org.springframework.scheduling.support.SimpleTriggerContext;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestClientException;
import net.solarnetwork.central.biz.UserEventAppenderBiz;
import net.solarnetwork.central.c2c.biz.CloudDatumStreamPollService;
import net.solarnetwork.central.c2c.biz.CloudDatumStreamService;
Expand All @@ -67,7 +70,7 @@
* DAO based implementation of {@link CloudDatumStreamPollService}.
*
* @author matt
* @version 1.0
* @version 1.1
*/
public class DaoCloudDatumStreamPollService
implements CloudDatumStreamPollService, ServiceLifecycleObserver, CloudIntegrationsUserEvents {
Expand Down Expand Up @@ -205,7 +208,11 @@ public CloudDatumStreamPollTaskEntity call() throws Exception {
var oldState = taskInfo.getState();
taskInfo.setMessage(errMsg);
taskInfo.putServiceProps(errData);
taskInfo.setState(Completed); // stop processing job
if ( !((e instanceof RestClientException && !(e instanceof HttpClientErrorException))
|| t instanceof IOException) ) {
// stop processing job if not what appears to be a API IO exception
taskInfo.setState(Completed);
}
userEventAppenderBiz.addEvent(taskInfo.getUserId(),
eventForConfiguration(taskInfo.getId(), POLL_ERROR_TAGS, errMsg, errData));
taskDao.updateTask(taskInfo, oldState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@
import net.solarnetwork.domain.datum.DatumSamples;
import net.solarnetwork.domain.datum.DatumSamplesType;
import net.solarnetwork.domain.datum.GeneralDatum;
import net.solarnetwork.settings.KeyedSettingSpecifier;
import net.solarnetwork.settings.MultiValueSettingSpecifier;
import net.solarnetwork.settings.SettingSpecifier;
import net.solarnetwork.settings.support.BasicMultiValueSettingSpecifier;

Expand Down Expand Up @@ -139,7 +137,7 @@
* }}</pre>
*
* @author matt
* @version 1.5
* @version 1.7
*/
public class LocusEnergyCloudDatumStreamService extends BaseOAuth2ClientCloudDatumStreamService {

Expand Down Expand Up @@ -218,21 +216,6 @@ public LocusEnergyCloudDatumStreamService(AsyncTaskExecutor executor,
this.executor = requireNonNullArgument(executor, "executor");
}

@Override
protected void populateInfoMessages(Locale locale, SettingSpecifier spec, Map<String, String> msgs,
MessageSource ms) {
super.populateInfoMessages(locale, spec, msgs, ms);
if ( spec instanceof KeyedSettingSpecifier<?> k ) {
if ( GRANULARITY_SETTING.equals(k.getKey()) ) {
MultiValueSettingSpecifier mv = (MultiValueSettingSpecifier) spec;
for ( String valueKey : mv.getValueTitles().keySet() ) {
String titleKey = "granularity." + valueKey;
msgs.put(titleKey, ms.getMessage(titleKey, null, valueKey, locale));
}
}
}
}

@Override
public Iterable<LocalizedServiceInfo> dataValueFilters(Locale locale) {
MessageSource ms = requireNonNullArgument(getMessageSource(), "messageSource");
Expand All @@ -246,15 +229,11 @@ public Iterable<LocalizedServiceInfo> dataValueFilters(Locale locale) {
}

@Override
public Iterable<CloudDataValue> dataValues(UserLongCompositePK id, Map<String, ?> filters) {
final CloudDatumStreamConfiguration datumStream = requireNonNullObject(
datumStreamDao.get(requireNonNullArgument(id, "id")), "datumStream");
final CloudDatumStreamMappingConfiguration mapping = requireNonNullObject(
datumStreamMappingDao.get(new UserLongCompositePK(datumStream.getUserId(),
datumStream.getDatumStreamMappingId())),
"datumStreamMapping");
final CloudIntegrationConfiguration integration = integrationDao
.get(new UserLongCompositePK(datumStream.getUserId(), mapping.getIntegrationId()));
public Iterable<CloudDataValue> dataValues(UserLongCompositePK integrationId,
Map<String, ?> filters) {
final CloudIntegrationConfiguration integration = requireNonNullObject(
integrationDao.get(requireNonNullArgument(integrationId, "integrationId")),
"integration");
List<CloudDataValue> result = Collections.emptyList();
if ( filters != null && filters.get(SITE_ID_FILTER) != null
&& filters.get(COMPONENT_ID_FILTER) != null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ public Iterable<LocalizedServiceInfo> dataValueFilters(Locale locale) {
}

@Override
public Iterable<CloudDataValue> dataValues(UserLongCompositePK id, Map<String, ?> filters) {
final CloudDatumStreamConfiguration datumStream = requireNonNullObject(
datumStreamDao.get(requireNonNullArgument(id, "id")), "datumStream");
final CloudIntegrationConfiguration integration = integrationDao.get(
new UserLongCompositePK(datumStream.getUserId(), datumStream.getDatumStreamMappingId()));
public Iterable<CloudDataValue> dataValues(UserLongCompositePK integrationId,
Map<String, ?> filters) {
final CloudIntegrationConfiguration integration = requireNonNullObject(
integrationDao.get(requireNonNullArgument(integrationId, "integrationId")),
"integration");
List<CloudDataValue> result = Collections.emptyList();
if ( filters != null && filters.get(SITE_ID_FILTER) != null ) {
// TODO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
import net.solarnetwork.service.RemoteServiceException;
import net.solarnetwork.settings.SettingSpecifier;
import net.solarnetwork.settings.support.BasicMultiValueSettingSpecifier;
import net.solarnetwork.settings.support.BasicTextAreaSettingSpecifier;
import net.solarnetwork.support.XmlSupport;
import net.solarnetwork.util.StringUtils;

Expand Down Expand Up @@ -191,7 +192,7 @@
* </ul>
*
* @author matt
* @version 1.3
* @version 1.5
*/
public class SolrenViewCloudDatumStreamService extends BaseRestOperationsCloudDatumStreamService {

Expand Down Expand Up @@ -221,7 +222,9 @@ public class SolrenViewCloudDatumStreamService extends BaseRestOperationsCloudDa
(l, r) -> r, () -> new LinkedHashMap<>(SolrenViewGranularity.values().length))));
granularitySpec.setValueTitles(granularityTitles);

SETTINGS = List.of(granularitySpec);
var sourceIdMapSpec = new BasicTextAreaSettingSpecifier(SOURCE_ID_MAP_SETTING, null, true);

SETTINGS = List.of(granularitySpec, sourceIdMapSpec);
}

private static final XmlSupport XML_SUPPORT;
Expand Down Expand Up @@ -290,20 +293,14 @@ public Iterable<LocalizedServiceInfo> dataValueFilters(Locale locale) {
}

@Override
public Iterable<CloudDataValue> dataValues(UserLongCompositePK datumStreamId,
public Iterable<CloudDataValue> dataValues(UserLongCompositePK integrationId,
Map<String, ?> filters) {
final CloudDatumStreamConfiguration datumStream = requireNonNullObject(
datumStreamDao.get(requireNonNullArgument(datumStreamId, "datumStreamId")),
"datumStream");
final CloudDatumStreamMappingConfiguration mapping = requireNonNullObject(
datumStreamMappingDao.get(new UserLongCompositePK(datumStream.getUserId(),
datumStream.getDatumStreamMappingId())),
"datumStreamMapping");
final CloudIntegrationConfiguration integration = integrationDao
.get(new UserLongCompositePK(datumStream.getUserId(), mapping.getIntegrationId()));
final CloudIntegrationConfiguration integration = requireNonNullObject(
integrationDao.get(requireNonNullArgument(integrationId, "integrationId")),
"integration");
List<CloudDataValue> result = Collections.emptyList();
if ( filters != null && filters.get(SITE_ID_FILTER) != null ) {
result = componentsForSite(integration, datumStream, filters);
result = componentsForSite(integration, filters);
}
Collections.sort(result);
return result;
Expand Down Expand Up @@ -492,8 +489,8 @@ private Instant nextDate(Instant date, SolrenViewGranularity granularity) {
}

private List<CloudDataValue> componentsForSite(CloudIntegrationConfiguration integration,
CloudDatumStreamConfiguration datumStream, Map<String, ?> filters) {
final SolrenViewGranularity granularity = resolveGranularity(datumStream, null);
Map<String, ?> filters) {
final SolrenViewGranularity granularity = resolveGranularity(null, filters);
final Clock queryClock = Clock.tick(clock, granularity.getTickDuration());
final Instant endDate = queryEndDate(queryClock, granularity);
final Instant startDate = queryStartDate(endDate, granularity);
Expand Down Expand Up @@ -539,14 +536,13 @@ private Instant queryStartDate(Instant endDate, SolrenViewGranularity granularit
}

private SolrenViewGranularity resolveGranularity(CloudDatumStreamConfiguration datumStream,
CloudDatumStreamQueryFilter filter) {
Map<String, ?> parameters) {
SolrenViewGranularity granularity = null;
try {
String granSetting = null;
if ( filter != null && filter.hasParameterCriteria()
&& filter.getParameters().get(GRANULARITY_SETTING) instanceof String s ) {
if ( parameters != null && parameters.get(GRANULARITY_SETTING) instanceof String s ) {
granSetting = s;
} else {
} else if ( datumStream != null ) {
granSetting = datumStream.serviceProperty(GRANULARITY_SETTING, String.class);
}
if ( granSetting != null && !granSetting.isEmpty() ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ title = Locus Energy Datum Stream
granularity.key = Granularity
granularity.desc = The resolution of the data to request.

granularity.latest = Latest
granularity.1min = 1 minute
granularity.5min = 5 minute
granularity.15min = 15 minute
granularity.hourly = Hourly
granularity.daily = Daily
granularity.monthly = Monthly
granularity.yearly = Yearly
granularity.latest.key = Latest
granularity.1min.key = 1 minute
granularity.5min.key = 5 minute
granularity.15min.key = 15 minute
granularity.hourly.key = Hourly
granularity.daily.key = Daily
granularity.monthly.key = Monthly
granularity.yearly.key = Yearly

dataValueFilter.siteId.key = Site ID
dataValueFilter.siteId.desc = The site identifier to restrict the results to.

dataValueFilter.componentId.key = Collection ID
dataValueFilter.componentId.key = Component ID
dataValueFilter.componentId.desc = The component identifier to restrict the results to.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,23 @@ title = SolrenView Datum Stream
dataValueFilter.siteId.key = Site ID
dataValueFilter.siteId.desc = The site identifier to restrict the results to.

granularity.key = Granularity
granularity.desc = The resolution of the data to request.

granularity.latest.key = Latest
granularity.1min.key = 1 minute
granularity.5min.key = 5 minute
granularity.10min.key = 10 minute
granularity.15min.key = 15 minute
granularity.20min.key = 15 minute
granularity.30min.key = 15 minute
granularity.hourly.key = Hourly
granularity.daily.key = Daily
granularity.monthly.key = Monthly
granularity.yearly.key = Yearly

sourceIdMap.key = Source ID Mapping
sourceIdMap.desc = A map or comma-delimited mapping list of component IDs to associated source ID values. \
For example as JSON <code>{"12345":"INV/1","23456":"INV/2"}</code> or as a string \
<code>12345=INV/1,23456=INV/2</code>.

2 changes: 1 addition & 1 deletion solarnet/solaruser/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

description = 'SolarUser'
version = '2.21.0'
version = '2.22.0'

base {
archivesName = 'solaruser'
Expand Down
Loading

0 comments on commit 863d297

Please sign in to comment.