Skip to content

Commit 1d666bf

Browse files
Feature/sonar issue java s6813 adapter domain smartmetering2 (#1576)
* sonar-issue-java-s6813-adapter-domain-smartmetering Signed-off-by: Harry Middelburg <harry.middelburg@alliander.com>
1 parent e20b337 commit 1d666bf

File tree

46 files changed

+484
-346
lines changed

Some content is hidden

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

46 files changed

+484
-346
lines changed

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/mapping/customconverters/ActualMeterReadsRequestGasRequestDataConverter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@
1313
import org.opensmartgridplatform.shared.exceptionhandling.ComponentType;
1414
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
1515
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType;
16-
import org.springframework.beans.factory.annotation.Autowired;
1716
import org.springframework.stereotype.Component;
1817

1918
@Component
2019
public class ActualMeterReadsRequestGasRequestDataConverter
2120
implements CustomValueToDtoConverter<
2221
ActualMeterReadsGasRequestData, ActualMeterReadsDataGasDto> {
2322

24-
@Autowired private DomainHelperService domainHelperService;
23+
private final DomainHelperService domainHelperService;
24+
25+
public ActualMeterReadsRequestGasRequestDataConverter(
26+
final DomainHelperService domainHelperService) {
27+
this.domainHelperService = domainHelperService;
28+
}
2529

2630
@Override
2731
public ActualMeterReadsDataGasDto convert(

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/mapping/customconverters/GetFirmwareVersionGasRequestDataConverter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@
1313
import org.opensmartgridplatform.shared.exceptionhandling.ComponentType;
1414
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
1515
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType;
16-
import org.springframework.beans.factory.annotation.Autowired;
1716
import org.springframework.stereotype.Component;
1817

1918
@Component
2019
public class GetFirmwareVersionGasRequestDataConverter
2120
implements CustomValueToDtoConverter<
2221
GetFirmwareVersionGasRequestData, GetFirmwareVersionGasRequestDto> {
2322

24-
@Autowired private DomainHelperService domainHelperService;
23+
private final DomainHelperService domainHelperService;
24+
25+
public GetFirmwareVersionGasRequestDataConverter(final DomainHelperService domainHelperService) {
26+
this.domainHelperService = domainHelperService;
27+
}
2528

2629
/**
2730
* This overridden convert is used from the bundle flow where the deviceIdentification from the

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/mapping/customconverters/PeriodicReadsRequestGasDataConverter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@
1313
import org.opensmartgridplatform.shared.exceptionhandling.ComponentType;
1414
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
1515
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType;
16-
import org.springframework.beans.factory.annotation.Autowired;
1716
import org.springframework.stereotype.Component;
1817

1918
@Component
2019
public class PeriodicReadsRequestGasDataConverter
2120
implements CustomValueToDtoConverter<
2221
PeriodicMeterReadsGasRequestData, PeriodicMeterReadsGasRequestDto> {
2322

24-
@Autowired private DomainHelperService domainHelperService;
23+
private final DomainHelperService domainHelperService;
24+
25+
public PeriodicReadsRequestGasDataConverter(final DomainHelperService domainHelperService) {
26+
this.domainHelperService = domainHelperService;
27+
}
2528

2629
@Override
2730
public PeriodicMeterReadsGasRequestDto convert(

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/mapping/customconverters/SetKeyOnGMeterDataConverter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@
1313
import org.opensmartgridplatform.shared.exceptionhandling.ComponentType;
1414
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
1515
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType;
16-
import org.springframework.beans.factory.annotation.Autowired;
1716
import org.springframework.stereotype.Component;
1817

1918
@Component
2019
public class SetKeyOnGMeterDataConverter
2120
implements CustomValueToDtoConverter<SetKeyOnGMeterRequestData, SetKeyOnGMeterRequestDto> {
2221

23-
@Autowired private DomainHelperService domainHelperService;
22+
private final DomainHelperService domainHelperService;
23+
24+
public SetKeyOnGMeterDataConverter(final DomainHelperService domainHelperService) {
25+
this.domainHelperService = domainHelperService;
26+
}
2427

2528
@Override
2629
public SetKeyOnGMeterRequestDto convert(

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/services/ActionMapperResponseService.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,18 @@
7474
import org.opensmartgridplatform.shared.exceptionhandling.ComponentType;
7575
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
7676
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType;
77-
import org.springframework.beans.factory.annotation.Autowired;
7877
import org.springframework.stereotype.Service;
7978
import org.springframework.validation.annotation.Validated;
8079

8180
@Service(value = "domainSmartMeteringActionMapperResponseService")
8281
@Validated
8382
public class ActionMapperResponseService {
8483

85-
@Autowired private ManagementMapper managementMapper;
86-
87-
@Autowired private ConfigurationMapper configurationMapper;
88-
89-
@Autowired private MonitoringMapper monitoringMapper;
90-
91-
@Autowired private CommonMapper commonMapper;
92-
93-
@Autowired private InstallationMapper installationMapper;
84+
private final ManagementMapper managementMapper;
85+
private final ConfigurationMapper configurationMapper;
86+
private final MonitoringMapper monitoringMapper;
87+
private final CommonMapper commonMapper;
88+
private final InstallationMapper installationMapper;
9489

9590
private static final Map<Class<? extends ActionResponseDto>, ConfigurableMapper>
9691
classToMapperMap = new HashMap<>();
@@ -135,6 +130,19 @@ public class ActionMapperResponseService {
135130
classMap.put(GetKeysResponseDto.class, GetKeysResponseData.class);
136131
}
137132

133+
public ActionMapperResponseService(
134+
final ManagementMapper managementMapper,
135+
final ConfigurationMapper configurationMapper,
136+
final MonitoringMapper monitoringMapper,
137+
final CommonMapper commonMapper,
138+
final InstallationMapper installationMapper) {
139+
this.managementMapper = managementMapper;
140+
this.configurationMapper = configurationMapper;
141+
this.monitoringMapper = monitoringMapper;
142+
this.commonMapper = commonMapper;
143+
this.installationMapper = installationMapper;
144+
}
145+
138146
/** Specifies which mapper to use for the DTO class received. */
139147
@PostConstruct
140148
private void postConstruct() {

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/services/AdhocService.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.opensmartgridplatform.shared.infra.jms.MessageMetadata;
3333
import org.opensmartgridplatform.shared.infra.jms.ResponseMessage;
3434
import org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType;
35-
import org.springframework.beans.factory.annotation.Autowired;
3635
import org.springframework.beans.factory.annotation.Qualifier;
3736
import org.springframework.stereotype.Service;
3837
import org.springframework.transaction.annotation.Transactional;
@@ -45,22 +44,25 @@ public class AdhocService {
4544
private static final String DEVICE_RESPONSE_NOT_OK_UNEXPECTED_EXCEPTION =
4645
"Device Response not ok. Unexpected Exception";
4746

48-
@Autowired
49-
@Qualifier(value = "domainSmartMeteringOutboundOsgpCoreRequestsMessageSender")
50-
private JmsMessageSender osgpCoreRequestMessageSender;
51-
52-
@Autowired
53-
@Qualifier(value = "domainSmartMeteringOutboundWebServiceResponsesMessageSender")
54-
private WebServiceResponseMessageSender webServiceResponseMessageSender;
55-
56-
@Autowired private DomainHelperService domainHelperService;
57-
58-
@Autowired private MapperFactory mapperFactory;
59-
60-
@Autowired private ConfigurationMapper configurationMapper;
61-
62-
public AdhocService() {
63-
// Parameterless constructor required for transactions...
47+
private final JmsMessageSender osgpCoreRequestMessageSender;
48+
private final WebServiceResponseMessageSender webServiceResponseMessageSender;
49+
private final DomainHelperService domainHelperService;
50+
private final MapperFactory mapperFactory;
51+
private final ConfigurationMapper configurationMapper;
52+
53+
public AdhocService(
54+
@Qualifier(value = "domainSmartMeteringOutboundOsgpCoreRequestsMessageSender")
55+
final JmsMessageSender osgpCoreRequestMessageSender,
56+
@Qualifier(value = "domainSmartMeteringOutboundWebServiceResponsesMessageSender")
57+
final WebServiceResponseMessageSender webServiceResponseMessageSender,
58+
final DomainHelperService domainHelperService,
59+
final MapperFactory mapperFactory,
60+
final ConfigurationMapper configurationMapper) {
61+
this.osgpCoreRequestMessageSender = osgpCoreRequestMessageSender;
62+
this.webServiceResponseMessageSender = webServiceResponseMessageSender;
63+
this.domainHelperService = domainHelperService;
64+
this.mapperFactory = mapperFactory;
65+
this.configurationMapper = configurationMapper;
6466
}
6567

6668
public void synchronizeTime(

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/services/BundleService.java

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType;
3434
import org.slf4j.Logger;
3535
import org.slf4j.LoggerFactory;
36-
import org.springframework.beans.factory.annotation.Autowired;
3736
import org.springframework.beans.factory.annotation.Qualifier;
3837
import org.springframework.stereotype.Service;
3938
import org.springframework.transaction.annotation.Transactional;
@@ -44,33 +43,40 @@ public class BundleService {
4443
private static final String SMART_METER_G = "SMART_METER_G";
4544
private static final Logger LOGGER = LoggerFactory.getLogger(BundleService.class);
4645

47-
@Autowired
48-
@Qualifier(value = "domainSmartMeteringOutboundOsgpCoreRequestsMessageSender")
49-
private JmsMessageSender osgpCoreRequestMessageSender;
50-
51-
@Autowired
52-
@Qualifier(value = "domainSmartMeteringOutboundWebServiceResponsesMessageSender")
53-
private WebServiceResponseMessageSender webServiceResponseMessageSender;
54-
55-
@Autowired private DomainHelperService domainHelperService;
56-
57-
@Autowired private ActionMapperService actionMapperService;
58-
59-
@Autowired private ActionMapperResponseService actionMapperResponseService;
60-
61-
@Autowired private MBusGatewayService mBusGatewayService;
62-
63-
@Autowired private ManagementService managementService;
64-
65-
@Autowired private ConfigurationMapper configurationMapper;
66-
67-
@Autowired private FirmwareService firmwareService;
68-
69-
@Autowired private EventService eventService;
70-
71-
public BundleService() {
72-
73-
// Parameterless constructor required for transactions...
46+
private final JmsMessageSender osgpCoreRequestMessageSender;
47+
private final WebServiceResponseMessageSender webServiceResponseMessageSender;
48+
private final DomainHelperService domainHelperService;
49+
private final ActionMapperService actionMapperService;
50+
private final ActionMapperResponseService actionMapperResponseService;
51+
private final MBusGatewayService mBusGatewayService;
52+
private final ManagementService managementService;
53+
private final ConfigurationMapper configurationMapper;
54+
private final FirmwareService firmwareService;
55+
private final EventService eventService;
56+
57+
public BundleService(
58+
@Qualifier(value = "domainSmartMeteringOutboundOsgpCoreRequestsMessageSender")
59+
final JmsMessageSender osgpCoreRequestMessageSender,
60+
@Qualifier(value = "domainSmartMeteringOutboundWebServiceResponsesMessageSender")
61+
final WebServiceResponseMessageSender webServiceResponseMessageSender,
62+
final DomainHelperService domainHelperService,
63+
final ActionMapperService actionMapperService,
64+
final ActionMapperResponseService actionMapperResponseService,
65+
final MBusGatewayService mBusGatewayService,
66+
final ManagementService managementService,
67+
final ConfigurationMapper configurationMapper,
68+
final FirmwareService firmwareService,
69+
final EventService eventService) {
70+
this.osgpCoreRequestMessageSender = osgpCoreRequestMessageSender;
71+
this.webServiceResponseMessageSender = webServiceResponseMessageSender;
72+
this.domainHelperService = domainHelperService;
73+
this.actionMapperService = actionMapperService;
74+
this.actionMapperResponseService = actionMapperResponseService;
75+
this.mBusGatewayService = mBusGatewayService;
76+
this.managementService = managementService;
77+
this.configurationMapper = configurationMapper;
78+
this.firmwareService = firmwareService;
79+
this.eventService = eventService;
7480
}
7581

7682
@Transactional(value = "transactionManager")

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/services/ConfigurationService.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
import org.opensmartgridplatform.shared.infra.jms.MessageMetadata;
8686
import org.opensmartgridplatform.shared.infra.jms.ResponseMessage;
8787
import org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType;
88-
import org.springframework.beans.factory.annotation.Autowired;
8988
import org.springframework.beans.factory.annotation.Qualifier;
9089
import org.springframework.stereotype.Service;
9190
import org.springframework.transaction.annotation.Transactional;
@@ -98,22 +97,25 @@ public class ConfigurationService {
9897
private static final String DEVICE_RESPONSE_NOT_OK_LOG_MSG =
9998
"Device Response not ok. Unexpected Exception";
10099

101-
@Autowired
102-
@Qualifier(value = "domainSmartMeteringOutboundOsgpCoreRequestsMessageSender")
103-
private JmsMessageSender osgpCoreRequestMessageSender;
104-
105-
@Autowired private ConfigurationMapper configurationMapper;
106-
107-
@Autowired
108-
@Qualifier(value = "domainSmartMeteringOutboundWebServiceResponsesMessageSender")
109-
private WebServiceResponseMessageSender webServiceResponseMessageSender;
110-
111-
@Autowired private DomainHelperService domainHelperService;
112-
113-
@Autowired private FirmwareService firmwareService;
114-
115-
public ConfigurationService() {
116-
// Parameterless constructor required for transactions...
100+
private final JmsMessageSender osgpCoreRequestMessageSender;
101+
private final ConfigurationMapper configurationMapper;
102+
private final WebServiceResponseMessageSender webServiceResponseMessageSender;
103+
private final DomainHelperService domainHelperService;
104+
private final FirmwareService firmwareService;
105+
106+
public ConfigurationService(
107+
@Qualifier(value = "domainSmartMeteringOutboundOsgpCoreRequestsMessageSender")
108+
final JmsMessageSender osgpCoreRequestMessageSender,
109+
final ConfigurationMapper configurationMapper,
110+
@Qualifier(value = "domainSmartMeteringOutboundWebServiceResponsesMessageSender")
111+
final WebServiceResponseMessageSender webServiceResponseMessageSender,
112+
final DomainHelperService domainHelperService,
113+
final FirmwareService firmwareService) {
114+
this.osgpCoreRequestMessageSender = osgpCoreRequestMessageSender;
115+
this.configurationMapper = configurationMapper;
116+
this.webServiceResponseMessageSender = webServiceResponseMessageSender;
117+
this.domainHelperService = domainHelperService;
118+
this.firmwareService = firmwareService;
117119
}
118120

119121
public void setSpecialDays(

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/services/DomainHelperService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@
1111
import org.opensmartgridplatform.shared.exceptionhandling.ComponentType;
1212
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
1313
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType;
14-
import org.springframework.beans.factory.annotation.Autowired;
1514
import org.springframework.stereotype.Service;
1615

1716
@Service(value = "domainSmartMeteringHelperService")
1817
public class DomainHelperService {
1918

2019
private static final ComponentType COMPONENT_TYPE = ComponentType.DOMAIN_SMART_METERING;
2120

22-
@Autowired private SmartMeterDomainService smartMeteringDeviceDomainService;
21+
private final SmartMeterDomainService smartMeteringDeviceDomainService;
22+
23+
public DomainHelperService(final SmartMeterDomainService smartMeteringDeviceDomainService) {
24+
this.smartMeteringDeviceDomainService = smartMeteringDeviceDomainService;
25+
}
2326

2427
/**
2528
* @param deviceIdentification

osgp/platform/osgp-adapter-domain-smartmetering/src/main/java/org/opensmartgridplatform/adapter/domain/smartmetering/application/services/FirmwareService.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalException;
2222
import org.opensmartgridplatform.shared.exceptionhandling.FunctionalExceptionType;
2323
import org.opensmartgridplatform.shared.exceptionhandling.OsgpException;
24-
import org.springframework.beans.factory.annotation.Autowired;
2524
import org.springframework.stereotype.Service;
2625
import org.springframework.transaction.annotation.Transactional;
2726

@@ -35,16 +34,20 @@ public class FirmwareService {
3534
public static final String MODULE_DESCRIPTION_ACTIVE_FIRMWARE = "active_firmware";
3635
public static final String MODULE_DESCRIPTION_MODULE_ACTIVE_FIRMWARE = "module_active_firmware";
3736

38-
@Autowired private FirmwareFileRepository firmwareFileRepository;
39-
40-
@Autowired private FirmwareModuleRepository firmwareModuleRepository;
41-
42-
@Autowired private DeviceFirmwareModuleRepository deviceFirmwareModuleRepository;
43-
44-
@Autowired private SmartMeterRepository smartMeterRepository;
45-
46-
public FirmwareService() {
47-
// Parameterless constructor required for transactions...
37+
private final FirmwareFileRepository firmwareFileRepository;
38+
private final FirmwareModuleRepository firmwareModuleRepository;
39+
private final DeviceFirmwareModuleRepository deviceFirmwareModuleRepository;
40+
private final SmartMeterRepository smartMeterRepository;
41+
42+
public FirmwareService(
43+
final FirmwareFileRepository firmwareFileRepository,
44+
final FirmwareModuleRepository firmwareModuleRepository,
45+
final DeviceFirmwareModuleRepository deviceFirmwareModuleRepository,
46+
final SmartMeterRepository smartMeterRepository) {
47+
this.firmwareFileRepository = firmwareFileRepository;
48+
this.firmwareModuleRepository = firmwareModuleRepository;
49+
this.deviceFirmwareModuleRepository = deviceFirmwareModuleRepository;
50+
this.smartMeterRepository = smartMeterRepository;
4851
}
4952

5053
public FirmwareFile getFirmwareFile(final String firmwareIdentification)

0 commit comments

Comments
 (0)