@@ -53,7 +53,7 @@ public class ExtRefEditorService implements ExtRefEditor {
53
53
private final DataTypeTemplatesService dataTypeTemplatesService ;
54
54
55
55
@ Getter
56
- private final List <SclReportItem > errorHandler = new ArrayList <>( );
56
+ private final ThreadLocal < List <SclReportItem >> errorHandler = ThreadLocal . withInitial ( ArrayList :: new );
57
57
58
58
/**
59
59
* Provides valid IED sources according to EPF configuration.<br/>
@@ -100,9 +100,9 @@ private List<ExtRefInfo.ExtRefWithBayReference> getExtRefWithBayReferenceInLDEPF
100
100
String lDevicePath = "SCL/IED[@name=\" " + tied .getName () + "\" ]/AccessPoint/Server/LDevice[@inst=\" " + tlDevice .getInst () + "\" ]" ;
101
101
Optional <TCompasBay > tCompasBay = PrivateUtils .extractCompasPrivate (tied , TCompasBay .class );
102
102
if (tCompasBay .isEmpty ()) {
103
- errorHandler .add (SclReportItem .error (lDevicePath , "The IED has no Private Bay" ));
103
+ errorHandler .get (). add (SclReportItem .error (lDevicePath , "The IED has no Private Bay" ));
104
104
if (PrivateUtils .extractCompasPrivate (tied , TCompasICDHeader .class ).isEmpty ()) {
105
- errorHandler .add (SclReportItem .error (lDevicePath , "The IED has no Private compas:ICDHeader" ));
105
+ errorHandler .get (). add (SclReportItem .error (lDevicePath , "The IED has no Private compas:ICDHeader" ));
106
106
}
107
107
return Collections .emptyList ();
108
108
}
@@ -247,29 +247,33 @@ public TExtRef updateExtRefSource(SCL scd, ExtRefInfo extRefInfo) throws ScdExce
247
247
248
248
@ Override
249
249
public List <SclReportItem > manageBindingForLDEPF (SCL scd , EPF epf ) {
250
- errorHandler .clear ();
251
- if (!epf .isSetChannels ()) return errorHandler ;
252
- log .info ("Processing %d EPF setting channels" .formatted (epf .getChannels ().getChannel ().size ()));
253
- iedService .getFilteredIeds (scd , ied -> !ied .getName ().contains ("TEST" ))
254
- .forEach (tied -> ldeviceService .findLdevice (tied , tlDevice -> tlDevice .getInst ().equals (LDEVICE_LDEPF ))
255
- .filter (ldepfLdevice -> PrivateUtils .extractStringPrivate (ldepfLdevice .getLN0 (), COMPAS_LNODE_STATUS ).map (status -> !status .equals ("off" )).orElse (false ))
256
- .ifPresent (ldepfLdevice -> getExtRefWithBayReferenceInLDEPF (tied , ldepfLdevice )
257
- .forEach (extRefBayRef -> epf .getChannels ().getChannel ().stream ().filter (tChannel -> doesExtRefMatchLDEPFChannel (extRefBayRef .extRef (), tChannel ))
258
- .findFirst ().ifPresent (channel -> {
259
- List <TIED > iedSources = getIedSources (scd , extRefBayRef .compasBay (), channel );
260
- if (iedSources .size () == 1 ) {
261
- updateLDEPFExtRefBinding (extRefBayRef , iedSources .getFirst (), channel );
262
- updateLDEPFDos (scd .getDataTypeTemplates (), tied , ldepfLdevice , extRefBayRef .extRef (), channel );
263
- } else {
264
- if (iedSources .size () > 1 ) {
265
- errorHandler .add (SclReportItem .warning (null , "There is more than one IED source to bind the signal " +
266
- "/IED@name=" + extRefBayRef .iedName () + "/LDevice@inst=LDEPF/LN0" +
267
- "/ExtRef@desc=" + extRefBayRef .extRef ().getDesc ()));
250
+ errorHandler .get ().clear ();
251
+ if (!epf .isSetChannels ()) return List .of ();
252
+ try {
253
+ log .info ("Processing %d EPF setting channels" .formatted (epf .getChannels ().getChannel ().size ()));
254
+ iedService .getFilteredIeds (scd , ied -> !ied .getName ().contains ("TEST" ))
255
+ .forEach (tied -> ldeviceService .findLdevice (tied , tlDevice -> tlDevice .getInst ().equals (LDEVICE_LDEPF ))
256
+ .filter (ldepfLdevice -> PrivateUtils .extractStringPrivate (ldepfLdevice .getLN0 (), COMPAS_LNODE_STATUS ).map (status -> !status .equals ("off" )).orElse (false ))
257
+ .ifPresent (ldepfLdevice -> getExtRefWithBayReferenceInLDEPF (tied , ldepfLdevice )
258
+ .forEach (extRefBayRef -> epf .getChannels ().getChannel ().stream ().filter (tChannel -> doesExtRefMatchLDEPFChannel (extRefBayRef .extRef (), tChannel ))
259
+ .findFirst ().ifPresent (channel -> {
260
+ List <TIED > iedSources = getIedSources (scd , extRefBayRef .compasBay (), channel );
261
+ if (iedSources .size () == 1 ) {
262
+ updateLDEPFExtRefBinding (extRefBayRef , iedSources .getFirst (), channel );
263
+ updateLDEPFDos (scd .getDataTypeTemplates (), tied , ldepfLdevice , extRefBayRef .extRef (), channel );
264
+ } else {
265
+ if (iedSources .size () > 1 ) {
266
+ errorHandler .get ().add (SclReportItem .warning (null , "There is more than one IED source to bind the signal " +
267
+ "/IED@name=" + extRefBayRef .iedName () + "/LDevice@inst=LDEPF/LN0" +
268
+ "/ExtRef@desc=" + extRefBayRef .extRef ().getDesc ()));
269
+ }
270
+ // If the source IED is not found, there will be no update or report message.
268
271
}
269
- // If the source IED is not found, there will be no update or report message.
270
- }
271
- }))));
272
- return errorHandler ;
272
+ }))));
273
+ return errorHandler .get ();
274
+ } finally {
275
+ errorHandler .remove ();
276
+ }
273
277
}
274
278
275
279
@ Override
@@ -388,7 +392,7 @@ private void updateDaiVal(TDataTypeTemplates dtt, TIED tied, TLDevice tlDevice,
388
392
.findFirst ()
389
393
.filter (doLinkedToDa1 -> {
390
394
if (!doLinkedToDa1 .isUpdatable ()){
391
- errorHandler .add (SclReportItem .warning (tied .getName () + "/" + LDEVICE_LDSUIED + "/" + LnId .from (tln ).lnClass () + "/DOI@name=\" " + doLinkedToDaFilter .doName () + "\" /DAI@name=\" " + doLinkedToDaFilter .daName () + "\" /Val" , "The DAI cannot be updated" ));
395
+ errorHandler .get (). add (SclReportItem .warning (tied .getName () + "/" + LDEVICE_LDSUIED + "/" + LnId .from (tln ).lnClass () + "/DOI@name=\" " + doLinkedToDaFilter .doName () + "\" /DAI@name=\" " + doLinkedToDaFilter .daName () + "\" /Val" , "The DAI cannot be updated" ));
392
396
}
393
397
return doLinkedToDa1 .isUpdatable ();
394
398
})
0 commit comments