From 7f64b2d5a31c95958b323343ba8e440051699fb5 Mon Sep 17 00:00:00 2001
From: Dominique Marcadet <Dominique.Marcadet@centralesupelec.fr>
Date: Wed, 12 Feb 2020 15:51:50 +0100
Subject: [PATCH] first trial to take SDO into account

---
 .../iec61850/scl/impl/FCDAImpl.java           | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/fr.centralesupelec.edf.riseclipse.iec61850.scl/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/impl/FCDAImpl.java b/fr.centralesupelec.edf.riseclipse.iec61850.scl/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/impl/FCDAImpl.java
index 4950f4f..4733272 100644
--- a/fr.centralesupelec.edf.riseclipse.iec61850.scl/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/impl/FCDAImpl.java
+++ b/fr.centralesupelec.edf.riseclipse.iec61850.scl/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/impl/FCDAImpl.java
@@ -1091,6 +1091,8 @@ public class FCDAImpl extends SclObjectImpl implements FCDA {
 
     @Override
     protected void doBuildExplicitLinks( IRiseClipseConsole console ) {
+        //@formatter:off
+        
         // see Issue #13
         super.doBuildExplicitLinks( console );
 
@@ -1263,13 +1265,29 @@ public class FCDAImpl extends SclObjectImpl implements FCDA {
 
         else {
             // daName – if missing, all attributes with functional characteristic given by fc are selected.
-            if( getFc() == null ) return;
+            if( getFc() == null ) {
+                console.warning( "[SCL links] FCDA (line ", getLineNumber(),
+                        ") does not refer to any AbstractDataAttribute because FC is empty" );
+                return;
+            }
 
-            doType
+            // We select either DAs contained in DOType or DAs contained in SDOs contained in DOType
+            if( doType.getDA().size() > 0 ) {
+                doType
                     .getDA()
                     .stream()
                     .filter( da -> da.getFc().equals( getFc() ) )
                     .collect( Collectors.toCollection( () -> getRefersToAbstractDataAttribute() ) );
+            }
+            else {
+                doType
+                    .getSDO()
+                    .stream()
+                    .map( sdo -> sdo.getRefersToDOType() )
+                    .flatMap( dotype -> dotype.getDA().stream() )
+                    .filter( da -> da.getFc().equals( getFc() ) )
+                    .collect( Collectors.toCollection( () -> getRefersToAbstractDataAttribute() ) );
+            }
 
             if( getRefersToAbstractDataAttribute().size() > 0 ) {
                 for( AbstractDataAttribute a : getRefersToAbstractDataAttribute() ) {
@@ -1284,6 +1302,7 @@ public class FCDAImpl extends SclObjectImpl implements FCDA {
             }
         }
 
+        //@formatter:on
     }
 
 } //FCDAImpl
-- 
GitLab