1313import org .lfenergy .compas .scl2007b4 .model .TExtRef ;
1414import org .lfenergy .compas .scl2007b4 .model .TLNodeType ;
1515import org .lfenergy .compas .sct .commons .DataSetService ;
16- import org .lfenergy .compas .sct .commons .ExtRefReaderService ;
1716import org .lfenergy .compas .sct .commons .LnodeTypeService ;
1817import org .lfenergy .compas .sct .commons .scl .SclRootAdapter ;
1918import org .lfenergy .compas .sct .commons .scl .dtt .DataTypeTemplateAdapter ;
@@ -71,10 +70,11 @@ public class LNodeDTO {
7170
7271 /**
7372 * Constructor
74- * @param inst input
75- * @param lnClass input
73+ *
74+ * @param inst input
75+ * @param lnClass input
7676 * @param lnPrefix input
77- * @param lnType input
77+ * @param lnType input
7878 */
7979 public LNodeDTO (String inst , String lnClass , String lnPrefix , String lnType ) {
8080 this .inst = inst ;
@@ -85,48 +85,49 @@ public LNodeDTO(String inst, String lnClass, String lnPrefix, String lnType) {
8585
8686 /**
8787 * Initialize LN
88+ *
8889 * @param nodeAdapter input
89- * @param options input
90+ * @param options input
91+ * @param <T> LNode type (LLN0 or other LN's)
9092 * @return LNodeDTO object
91- * @param <T> LNode type (LLN0 or other LN's)
9293 */
9394 public static <T extends TAnyLN > LNodeDTO from (AbstractLNAdapter <T > nodeAdapter , LogicalNodeOptions options ) {
9495 log .info (Utils .entering ());
9596 LNodeDTO lNodeDTO = new LNodeDTO ();
96- if (nodeAdapter == null ) return lNodeDTO ;
97+ if (nodeAdapter == null ) return lNodeDTO ;
9798
9899 lNodeDTO .nodeType = nodeAdapter .getLnType ();
99100 lNodeDTO .nodeClass = nodeAdapter .getLNClass ();
100- if (!nodeAdapter .getPrefix ().isBlank ()){
101+ if (!nodeAdapter .getPrefix ().isBlank ()) {
101102 lNodeDTO .prefix = nodeAdapter .getPrefix ();
102103 }
103104 lNodeDTO .inst = nodeAdapter .getLNInst ();
104- if (options == null ) {
105+ if (options == null ) {
105106 log .info (Utils .leaving ());
106107 return lNodeDTO ;
107108 }
108109
109- if (options .isWithExtRef ()) {
110- List <TExtRef > extRefList = nodeAdapter .getExtRefs (null );
110+ if (options .isWithExtRef ()) {
111+ List <TExtRef > extRefList = nodeAdapter .getExtRefs (null );
111112 LDeviceAdapter lDeviceAdapter = nodeAdapter .getParentAdapter ();
112113 String holderIedName = lDeviceAdapter .getParentAdapter ().getName ();
113114 String holderLDInst = lDeviceAdapter .getInst ();
114115 lNodeDTO .extRefs .addAll (
115116 extRefList .stream ()
116117 .map (tExtRef ->
117- ExtRefInfo .from (tExtRef ,holderIedName ,holderLDInst ,lNodeDTO .nodeClass ,
118- lNodeDTO .inst ,lNodeDTO .prefix
119- ))
120- .collect ( Collectors . toList () )
118+ ExtRefInfo .from (tExtRef , holderIedName , holderLDInst , lNodeDTO .nodeClass ,
119+ lNodeDTO .inst , lNodeDTO .prefix
120+ ))
121+ .toList ()
121122 );
122123 }
123124
124- if (options .isWithDatSet ()) {
125+ if (options .isWithDatSet ()) {
125126 DataSetService dataSetService = new DataSetService ();
126127 lNodeDTO .datSets = dataSetService .getDataSets (nodeAdapter .getCurrentElem ()).map (DataSetInfo ::new ).collect (Collectors .toSet ());
127128 }
128129
129- if (options .isWithDataAttributeRef ()) {
130+ if (options .isWithDataAttributeRef ()) {
130131 DataTypeTemplateAdapter dttAdapter = nodeAdapter .getDataTypeTemplateAdapter ();
131132 LNodeTypeAdapter lNodeTypeAdapter = dttAdapter .getLNodeTypeAdapterById (nodeAdapter .getLnType ())
132133 .orElseThrow (
@@ -138,15 +139,15 @@ public static <T extends TAnyLN> LNodeDTO from(AbstractLNAdapter<T> nodeAdapter,
138139 )
139140 );
140141 DataAttributeRef filter = DataAttributeRef .builder ()
141- .lnInst (nodeAdapter .getLNInst ())
142- .lnClass (nodeAdapter .getLNClass ())
143- .prefix (nodeAdapter .getPrefix ())
144- .lnType (nodeAdapter .getLnType ()).build ();
142+ .lnInst (nodeAdapter .getLNInst ())
143+ .lnClass (nodeAdapter .getLNClass ())
144+ .prefix (nodeAdapter .getPrefix ())
145+ .lnType (nodeAdapter .getLnType ()).build ();
145146 List <DataAttributeRef > dataAttributeRefList = lNodeTypeAdapter .getDataAttributeRefs (filter );
146147 lNodeDTO .addAllDataAttributeRef (dataAttributeRefList );
147148 }
148149
149- if (options .isWithCB ()) {
150+ if (options .isWithCB ()) {
150151 //TODO
151152 }
152153 log .info (Utils .leaving ());
@@ -162,9 +163,11 @@ public static LNodeDTO from(TAnyLN tAnyLN, LogicalNodeOptions options, String ie
162163 String lnType = tAnyLN .getLnType ();
163164 LNodeDTO lNodeDTO = new LNodeDTO (inst , lnClass , prefix , lnType );
164165 if (options .isWithExtRef ()) {
165- List <ExtRefInfo > extRefInfos = new ExtRefReaderService ().getExtRefs (tAnyLN )
166- .map (extRef -> ExtRefInfo .from (extRef , iedName , ldInst , lnClass , inst , prefix ))
167- .toList ();
166+ List <ExtRefInfo > extRefInfos = tAnyLN .isSetInputs () ?
167+ tAnyLN .getInputs ().getExtRef ().stream ()
168+ .map (extRef -> ExtRefInfo .from (extRef , iedName , ldInst , lnClass , inst , prefix ))
169+ .toList ()
170+ : List .of ();
168171 lNodeDTO .addAllExtRefInfo (extRefInfos );
169172 }
170173 if (options .isWithDatSet ()) {
@@ -195,45 +198,50 @@ public static LNodeDTO from(TAnyLN tAnyLN, LogicalNodeOptions options, String ie
195198
196199 /**
197200 * Sets LNode Inst value
201+ *
198202 * @param inst input
199203 */
200- public void setInst (String inst ){
204+ public void setInst (String inst ) {
201205 this .inst = inst ;
202206 }
203207
204208 /**
205209 * Sets LNode Class value
210+ *
206211 * @param lnClass input
207212 */
208- public void setNodeClass (String lnClass ){
213+ public void setNodeClass (String lnClass ) {
209214 this .nodeClass = lnClass ;
210215 }
211216
212217 /**
213- * Sets LNode Type
218+ * Sets LNode Type
219+ *
214220 * @param lnType
215221 */
216- public void setNodeType (String lnType ){
222+ public void setNodeType (String lnType ) {
217223 this .nodeType = lnType ;
218224 }
219225
220226 /**
221227 * Sets LNode Prefix value
228+ *
222229 * @param prefix input
223230 */
224- public void setPrefix (String prefix ){
231+ public void setPrefix (String prefix ) {
225232 this .prefix = prefix ;
226233 }
227234
228235 /**
229236 * Extracts LNode ExtRef informations
237+ *
230238 * @param lnAdapter input
231239 * @return LNodeDTO object
232240 */
233241 public static LNodeDTO extractExtRefInfo (LNAdapter lnAdapter ) {
234242 String lnClass = lnAdapter .getLNClass () == null ? "" : lnAdapter .getLNClass ();
235- LNodeDTO lNodeDTO = new LNodeDTO (lnAdapter .getLNInst (),lnClass ,lnAdapter .getPrefix (), lnAdapter .getLnType ());
236- if (lnAdapter .hasInputs ()){
243+ LNodeDTO lNodeDTO = new LNodeDTO (lnAdapter .getLNInst (), lnClass , lnAdapter .getPrefix (), lnAdapter .getLnType ());
244+ if (lnAdapter .hasInputs ()) {
237245 lnAdapter .getExtRefs (null ).forEach (tExtRef -> {
238246 ExtRefInfo extRefInfo = new ExtRefInfo (tExtRef );
239247 lNodeDTO .addExtRefInfo (extRefInfo );
@@ -244,6 +252,7 @@ public static LNodeDTO extractExtRefInfo(LNAdapter lnAdapter) {
244252
245253 /**
246254 * Adds ExtRef Info to LNode ExtRefs
255+ *
247256 * @param extRef input
248257 */
249258 public void addExtRefInfo (ExtRefInfo extRef ) {
@@ -252,6 +261,7 @@ public void addExtRefInfo(ExtRefInfo extRef) {
252261
253262 /**
254263 * Adds list of ExtRef Info into LNode
264+ *
255265 * @param extRefs input
256266 */
257267 public void addAllExtRefInfo (List <ExtRefInfo > extRefs ) {
@@ -260,6 +270,7 @@ public void addAllExtRefInfo(List<ExtRefInfo> extRefs) {
260270
261271 /**
262272 * Adds Control Block to LNode Control Blocks
273+ *
263274 * @param controlBlock input
264275 */
265276 public void addControlBlock (ControlBlock controlBlock ) {
@@ -278,14 +289,16 @@ public void addControlBlock(ControlBlock controlBlock) {
278289
279290 /**
280291 * Adds lis of Control Block to LNode Control Blocks
292+ *
281293 * @param controlBlockInfoList input
282294 */
283- public void addAllControlBlocks (List <ControlBlock > controlBlockInfoList ){
295+ public void addAllControlBlocks (List <ControlBlock > controlBlockInfoList ) {
284296 controlBlockInfoList .forEach (this ::addControlBlock );
285297 }
286298
287299 /**
288300 * Adds list of DataSet to LNode
301+ *
289302 * @param dataSetList input
290303 */
291304 public void addAllDatSets (List <DataSetInfo > dataSetList ) {
@@ -294,6 +307,7 @@ public void addAllDatSets(List<DataSetInfo> dataSetList) {
294307
295308 /**
296309 * Adds DataTypeTemplate's sumarised data
310+ *
297311 * @param dataAttributeRef input
298312 */
299313 public void addDataAttributeRef (DataAttributeRef dataAttributeRef ) {
@@ -302,6 +316,7 @@ public void addDataAttributeRef(DataAttributeRef dataAttributeRef) {
302316
303317 /**
304318 * Adds list of DataTypeTemplate's sumarised data
319+ *
305320 * @param dataAttributeRefs input
306321 */
307322 public void addAllDataAttributeRef (List <DataAttributeRef > dataAttributeRefs ) {
@@ -310,14 +325,16 @@ public void addAllDataAttributeRef(List<DataAttributeRef> dataAttributeRefs) {
310325
311326 /**
312327 * Gets DataTypeTemplate's sumarised data
328+ *
313329 * @return Set of DataAttributeRef object
314330 */
315- public Set <DataAttributeRef > getDataAttributeRefs (){
331+ public Set <DataAttributeRef > getDataAttributeRefs () {
316332 return Set .of (dataAttributeRefs .toArray (new DataAttributeRef [0 ]));
317333 }
318334
319335 /**
320336 * Adds DataSet information to LNode
337+ *
321338 * @param dataSetInfo input
322339 */
323340 public void addDataSet (DataSetInfo dataSetInfo ) {
0 commit comments