Skip to content

Commit

Permalink
Release 3.2.0: Add Spring Modulith dependency and refactor to clarify…
Browse files Browse the repository at this point in the history
… app modules
  • Loading branch information
dmkeen committed Oct 21, 2024
1 parent 4f62e86 commit ff4b199
Show file tree
Hide file tree
Showing 51 changed files with 197 additions and 118 deletions.
28 changes: 26 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@

<groupId>org.keen</groupId>
<artifactId>solar</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>

<name>solar</name>
<description>Retrieves solar data from a Fronius inverter and persists it to a data store.</description>

<properties>
<java.version>21</java.version>

<spring-modulith-bom.version>1.2.4</spring-modulith-bom.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -69,8 +71,30 @@
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-api</artifactId>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.modulith</groupId>
<artifactId>spring-modulith-bom</artifactId>
<version>${spring-modulith-bom.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
Expand All @@ -88,7 +112,7 @@
<exclude>**/ForecastRetrieverIT.java</exclude>
<!-- Excluding tests which call the Fronius API and hence will only run locally -->
<exclude>**/CurrentPowerRetrieverIT.java</exclude>
<exclude>**/StringDataRetrieverIT.java</exclude>
<exclude>**/StringPowerRetrieverIT.java</exclude>
</excludes>
</configuration>
<executions>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/keen/solar/config/DalConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import javax.sql.DataSource;

@Configuration
@EnableJdbcRepositories({"org.keen.solar.forecast.dal","org.keen.solar.power.dal"})
@EnableJdbcRepositories({"org.keen.solar.solcast.forecast.dal",
"org.keen.solar.string.dal",
"org.keen.solar.system.dal"})
public class DalConfiguration extends AbstractJdbcConfiguration {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.keen.solar.forecast.solcast;
package org.keen.solar.solcast.forecast;

import org.keen.solar.forecast.dal.ForecastRepository;
import org.keen.solar.forecast.domain.GenerationForecast;
import org.keen.solar.solcast.forecast.dal.ForecastRepository;
import org.keen.solar.solcast.forecast.domain.GenerationForecast;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.keen.solar.forecast.solcast;
package org.keen.solar.solcast.forecast;

import org.keen.solar.forecast.domain.Forecasts;
import org.keen.solar.forecast.domain.GenerationForecast;
import org.keen.solar.solcast.forecast.domain.Forecasts;
import org.keen.solar.solcast.forecast.domain.GenerationForecast;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.keen.solar.forecast.solcast;
package org.keen.solar.solcast.forecast;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import org.keen.solar.forecast.domain.Forecasts;
import org.keen.solar.forecast.domain.GenerationForecast;
import org.keen.solar.solcast.forecast.domain.Forecasts;
import org.keen.solar.solcast.forecast.domain.GenerationForecast;

import java.io.IOException;
import java.time.Duration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.keen.solar.forecast.dal;
package org.keen.solar.solcast.forecast.dal;

import org.keen.solar.forecast.domain.GenerationForecast;
import org.keen.solar.solcast.forecast.domain.GenerationForecast;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.keen.solar.forecast.domain;
package org.keen.solar.solcast.forecast.domain;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.keen.solar.forecast.solcast.ForecastsDeserializer;
import org.keen.solar.solcast.forecast.ForecastsDeserializer;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.keen.solar.forecast.domain;
package org.keen.solar.solcast.forecast.domain;

import org.springframework.data.annotation.Id;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* This package provides functionality to retrieve and persist solar forecasts
* from Solcast.
*/
package org.keen.solar.solcast.forecast;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.keen.solar.power.solcast;
package org.keen.solar.solcast.measurement;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.keen.solar.power.domain.Measurement;
import org.keen.solar.solcast.measurement.domain.Measurement;

import java.io.IOException;
import java.time.format.DateTimeFormatter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.keen.solar.power.solcast;
package org.keen.solar.solcast.measurement;

import org.keen.solar.power.dal.CurrentPowerRepository;
import org.keen.solar.power.domain.CurrentPower;
import org.keen.solar.power.domain.Measurement;
import org.keen.solar.power.domain.MeasurementResponse;
import org.keen.solar.power.domain.Measurements;
import org.keen.solar.system.dal.CurrentPowerRepository;
import org.keen.solar.system.domain.CurrentPower;
import org.keen.solar.solcast.measurement.domain.Measurement;
import org.keen.solar.solcast.measurement.domain.MeasurementResponse;
import org.keen.solar.solcast.measurement.domain.Measurements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.keen.solar.power.solcast;
package org.keen.solar.solcast.measurement;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.keen.solar.power.domain.Measurements;
import org.keen.solar.solcast.measurement.domain.Measurements;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.keen.solar.power.solcast;
package org.keen.solar.solcast.measurement;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.keen.solar.power.domain;
package org.keen.solar.solcast.measurement.domain;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.keen.solar.power.solcast.MeasurementSerializer;
import org.keen.solar.system.domain.CurrentPower;
import org.keen.solar.solcast.measurement.MeasurementSerializer;

import java.time.Duration;
import java.time.OffsetDateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.keen.solar.power.domain;
package org.keen.solar.solcast.measurement.domain;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.keen.solar.power.domain;
package org.keen.solar.solcast.measurement.domain;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.keen.solar.power.solcast.MeasurementsSerializer;
import org.keen.solar.solcast.measurement.MeasurementsSerializer;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* This package provides functionality to retrieve persisted power generation
* information, summarise it and upload it to Solcast.
*/
package org.keen.solar.solcast.measurement;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.keen.solar.power.dal;
package org.keen.solar.string.dal;

import org.keen.solar.power.domain.StringPower;
import org.keen.solar.string.domain.StringPower;
import org.springframework.data.repository.CrudRepository;

public interface StringPowerRepository extends CrudRepository<StringPower, Long> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.keen.solar.power.domain;
package org.keen.solar.string.domain;


import org.springframework.data.annotation.Id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.keen.solar.power.domain;
package org.keen.solar.string.domain;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.keen.solar.power.fronius.StringPowersDeserializer;
import org.keen.solar.string.fronius.StringPowersDeserializer;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.keen.solar.string.fronius;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@Configuration
@EnableScheduling
@EnableAsync
public class StringPowerConfiguration {

@Bean
public StringPowerPersister stringPowerPersister() {
return new StringPowerPersister();
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.keen.solar.power.fronius;
package org.keen.solar.string.fronius;

import org.keen.solar.power.dal.StringPowerRepository;
import org.keen.solar.string.dal.StringPowerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;

public class StringPowerPersister {

@Autowired
private StringDataRetriever retriever;
private StringPowerRetriever retriever;

@Autowired
private StringPowerRepository repository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.keen.solar.power.fronius;
package org.keen.solar.string.fronius;

import org.keen.solar.power.domain.StringPower;
import org.keen.solar.power.domain.StringPowers;
import org.keen.solar.string.domain.StringPower;
import org.keen.solar.string.domain.StringPowers;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.stereotype.Service;
Expand All @@ -17,7 +17,7 @@
* Retrieves the power output per "string" of panels
*/
@Service
public class StringDataRetriever {
public class StringPowerRetriever {

public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ISO_OFFSET_DATE_TIME;

Expand All @@ -26,7 +26,7 @@ public class StringDataRetriever {
@Value("${app.inverter.host}")
private String inverterApiHost;

public StringDataRetriever(RestTemplateBuilder restTemplateBuilder) {
public StringPowerRetriever(RestTemplateBuilder restTemplateBuilder) {
this.restTemplate = restTemplateBuilder.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.keen.solar.power.fronius;
package org.keen.solar.string.fronius;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import org.keen.solar.power.domain.StringPower;
import org.keen.solar.power.domain.StringPowers;
import org.keen.solar.string.domain.StringPower;
import org.keen.solar.string.domain.StringPowers;

import java.io.IOException;
import java.time.OffsetDateTime;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/keen/solar/string/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* This package provides functionality to retrieve and persist power generation
* per "string" of panels attached to an inverter.<br/>
* A string of solar panels is formed when multiple panels are connected
* together in series and then connected into the string inverter.
* String inverters can support multiple strings.
*/
package org.keen.solar.string;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.keen.solar.power.dal;
package org.keen.solar.system.dal;

import org.keen.solar.power.domain.CurrentPower;
import org.keen.solar.system.domain.CurrentPower;
import org.springframework.data.repository.CrudRepository;

import java.util.List;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/keen/solar/system/dal/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@org.springframework.modulith.NamedInterface("dal")
package org.keen.solar.system.dal;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.keen.solar.power.domain;
package org.keen.solar.system.domain;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.keen.solar.power.fronius.GetPowerFlowRealtimeDataDeserializer;
import org.keen.solar.system.fronius.GetPowerFlowRealtimeDataDeserializer;
import org.springframework.data.annotation.Id;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/keen/solar/system/domain/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@org.springframework.modulith.NamedInterface("domain")
package org.keen.solar.system.domain;
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.keen.solar.config;
package org.keen.solar.system.fronius;

import org.keen.solar.power.fronius.CurrentPowerPersister;
import org.keen.solar.power.fronius.StringPowerPersister;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
Expand All @@ -10,15 +8,11 @@
@Configuration
@EnableScheduling
@EnableAsync
public class ApplicationConfiguration {
public class CurrentPowerConfiguration {

@Bean
public CurrentPowerPersister currentPowerPersister() {
return new CurrentPowerPersister();
}

@Bean
public StringPowerPersister stringPowerPersister() {
return new StringPowerPersister();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.keen.solar.power.fronius;
package org.keen.solar.system.fronius;

import org.keen.solar.power.dal.CurrentPowerRepository;
import org.keen.solar.system.dal.CurrentPowerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
Expand Down
Loading

0 comments on commit ff4b199

Please sign in to comment.