Commit a1db4c12 authored by Dominique Marcadet's avatar Dominique Marcadet

improve getNamespace() of LDevice, AnyLN and DOI

parent 0fb2fa80
......@@ -21,7 +21,9 @@ package fr.centralesupelec.edf.riseclipse.iec61850.scl.impl;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.AnyLN;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.Association;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.ClientLN;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DA;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DAI;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DO;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DOI;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DataSet;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DataTypeTemplates;
......@@ -1071,33 +1073,80 @@ public abstract class AnyLNImpl extends UnNamingImpl implements AnyLN {
*/
@Override
public String getNamespace() {
List< DOI > lplDoi =
List< DOI > namPltDoi =
getDOI()
.stream()
.filter( doi -> "NamPlt".equals( doi.getName() ))
.collect( Collectors.toList() );
if( lplDoi.size() == 1 ) {
List< DAI > ldNsDai =
lplDoi
if( namPltDoi.size() == 1 ) {
List< DAI > lnNsDai =
namPltDoi
.get( 0 )
.getDAI()
.stream()
.filter( dai -> "lnNs".equals( dai.getName() ))
.collect( Collectors.toList() );
if( ldNsDai.size() == 1 ) {
if(( ldNsDai.get( 0 ).getVal().size() == 1 )
&& ( ldNsDai.get( 0 ).getVal().get( 0 ).getValue() != null )
&& ( ldNsDai.get( 0 ).getVal().get( 0 ).getValue().length() != 0 )) {
return ldNsDai.get( 0 ).getVal().get( 0 ).getValue();
if( lnNsDai.size() == 1 ) {
if(( lnNsDai.get( 0 ).getVal().size() == 1 )
&& ( lnNsDai.get( 0 ).getVal().get( 0 ).getValue() != null )
&& ( lnNsDai.get( 0 ).getVal().get( 0 ).getValue().length() != 0 )) {
return lnNsDai.get( 0 ).getVal().get( 0 ).getValue();
}
if(( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute() != null )
&& ( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().size() == 1 )
&& ( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue() != null )
&& ( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue().length() != 0 )) {
return ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue();
if(( lnNsDai.get( 0 ).getRefersToAbstractDataAttribute() != null )
&& ( lnNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().size() == 1 )
&& ( lnNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue() != null )
&& ( lnNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue().length() != 0 )) {
return lnNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue();
}
}
if( namPltDoi.get( 0 ).getRefersToDO() != null ) {
List< DA > lnNsDa =
namPltDoi
.get( 0 )
.getRefersToDO()
.getRefersToDOType()
.getDA()
.stream()
.filter( da -> "lnNs".equals( da.getName() ))
.collect( Collectors.toList() );
if( lnNsDa.size() == 1 ) {
if(( lnNsDa.get( 0 ).getVal().size() == 1 )
&& ( lnNsDa.get( 0 ).getVal().get( 0 ).getValue() != null )
&& ( lnNsDa.get( 0 ).getVal().get( 0 ).getValue().length() != 0 )) {
return lnNsDa.get( 0 ).getVal().get( 0 ).getValue();
}
}
}
}
if( getRefersToLNodeType() != null ) {
List< DO > namPltDo =
getRefersToLNodeType()
.getDO()
.stream()
.filter( doi -> "NamPlt".equals( doi.getName() ))
.collect( Collectors.toList() );
if( namPltDo.size() == 1 ) {
if( namPltDo.get( 0 ).getRefersToDOType() != null ) {
List< DA > lnNsDa =
namPltDo
.get( 0 )
.getRefersToDOType()
.getDA()
.stream()
.filter( da -> "lnNs".equals( da.getName() ))
.collect( Collectors.toList() );
if( lnNsDa.size() == 1 ) {
if(( lnNsDa.get( 0 ).getVal().size() == 1 )
&& ( lnNsDa.get( 0 ).getVal().get( 0 ).getValue() != null )
&& ( lnNsDa.get( 0 ).getVal().get( 0 ).getValue().length() != 0 )) {
return lnNsDa.get( 0 ).getVal().get( 0 ).getValue();
}
}
}
}
}
if( getParentLDevice() == null ) return null;
return getParentLDevice().getNamespace();
}
......
......@@ -33,6 +33,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.AnyLN;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DA;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DAI;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DO;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DOI;
......@@ -590,6 +591,24 @@ public class DOIImpl extends UnNamingImpl implements DOI {
return ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue();
}
}
if( getRefersToDO() != null ) {
List< DA > lnNsDa =
getRefersToDO()
.getRefersToDOType()
.getDA()
.stream()
.filter( da -> "dataNs".equals( da.getName() ))
.collect( Collectors.toList() );
if( lnNsDa.size() == 1 ) {
if(( lnNsDa.get( 0 ).getVal().size() == 1 )
&& ( lnNsDa.get( 0 ).getVal().get( 0 ).getValue() != null )
&& ( lnNsDa.get( 0 ).getVal().get( 0 ).getValue().length() != 0 )) {
return lnNsDa.get( 0 ).getVal().get( 0 ).getValue();
}
}
}
if( getParentAnyLN() == null ) return null;
return getParentAnyLN().getNamespace();
}
......
......@@ -34,7 +34,9 @@ import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.AccessControl;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DA;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DAI;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DO;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.DOI;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.IED;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.IEDName;
......@@ -585,35 +587,82 @@ public class LDeviceImpl extends UnNamingImpl implements LDevice {
*/
@Override
public String getNamespace() {
List< DOI > lplDoi =
getLN0()
.getDOI()
.stream()
.filter( doi -> "NamPlt".equals( doi.getName() ))
.collect( Collectors.toList() );
if( lplDoi.size() == 1 ) {
List< DAI > ldNsDai =
lplDoi
.get( 0 )
.getDAI()
.stream()
.filter( dai -> "ldNs".equals( dai.getName() ))
.collect( Collectors.toList() );
if( ldNsDai.size() == 1 ) {
if(( ldNsDai.get( 0 ).getVal().size() == 1 )
&& ( ldNsDai.get( 0 ).getVal().get( 0 ).getValue() != null )
&& ( ldNsDai.get( 0 ).getVal().get( 0 ).getValue().length() != 0 )) {
return ldNsDai.get( 0 ).getVal().get( 0 ).getValue();
}
if(( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute() != null )
&& ( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().size() == 1 )
&& ( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue() != null )
&& ( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue().length() != 0 )) {
return ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue();
}
}
}
return null;
if( getLN0() == null ) return null;
List< DOI > namPltDoi =
getLN0()
.getDOI()
.stream()
.filter( doi -> "NamPlt".equals( doi.getName() ))
.collect( Collectors.toList() );
if( namPltDoi.size() == 1 ) {
List< DAI > ldNsDai =
namPltDoi
.get( 0 )
.getDAI()
.stream()
.filter( dai -> "ldNs".equals( dai.getName() ))
.collect( Collectors.toList() );
if( ldNsDai.size() == 1 ) {
if(( ldNsDai.get( 0 ).getVal().size() == 1 )
&& ( ldNsDai.get( 0 ).getVal().get( 0 ).getValue() != null )
&& ( ldNsDai.get( 0 ).getVal().get( 0 ).getValue().length() != 0 )) {
return ldNsDai.get( 0 ).getVal().get( 0 ).getValue();
}
if(( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute() != null )
&& ( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().size() == 1 )
&& ( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue() != null )
&& ( ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue().length() != 0 )) {
return ldNsDai.get( 0 ).getRefersToAbstractDataAttribute().getVal().get( 0 ).getValue();
}
}
if( namPltDoi.get( 0 ).getRefersToDO() != null ) {
List< DA > lnNsDa =
namPltDoi
.get( 0 )
.getRefersToDO()
.getRefersToDOType()
.getDA()
.stream()
.filter( da -> "ldNs".equals( da.getName() ))
.collect( Collectors.toList() );
if( lnNsDa.size() == 1 ) {
if(( lnNsDa.get( 0 ).getVal().size() == 1 )
&& ( lnNsDa.get( 0 ).getVal().get( 0 ).getValue() != null )
&& ( lnNsDa.get( 0 ).getVal().get( 0 ).getValue().length() != 0 )) {
return lnNsDa.get( 0 ).getVal().get( 0 ).getValue();
}
}
}
}
if( getLN0().getRefersToLNodeType() == null ) return null;
List< DO > namPltDo =
getLN0()
.getRefersToLNodeType()
.getDO()
.stream()
.filter( do_ -> "NamPlt".equals( do_.getName() ))
.collect( Collectors.toList() );
if( namPltDo.size() == 1 ) {
if( namPltDo.get( 0 ).getRefersToDOType() == null ) return null;
List< DA > ldNsDa =
namPltDo
.get( 0 )
.getRefersToDOType()
.getDA()
.stream()
.filter( da -> "ldNs".equals( da.getName() ))
.collect( Collectors.toList() );
if( ldNsDa.size() == 1 ) {
if(( ldNsDa.get( 0 ).getVal().size() == 1 )
&& ( ldNsDa.get( 0 ).getVal().get( 0 ).getValue() != null )
&& ( ldNsDa.get( 0 ).getVal().get( 0 ).getValue().length() != 0 )) {
return ldNsDa.get( 0 ).getVal().get( 0 ).getValue();
}
}
}
return null;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment