Commit 5c9ccb39 authored by Dominique Marcadet's avatar Dominique Marcadet

refactoring of Terminal.doBuildExplicitLinks()

parent 9a813f17
......@@ -1107,6 +1107,21 @@ public class TerminalImpl extends UnNamingImpl implements Terminal {
// see Issue #13
super.doBuildExplicitLinks( console );
String messagePrefix = "while resolving link from Terminal on line " + getLineNumber() + ": ";
if( getSubstationName() != null ) {
doBuildExplicitLinkWithSubstation( console, messagePrefix );
}
else if( getLineName() != null ) {
doBuildExplicitLinkWithLine( console, messagePrefix );
}
else {
// TODO: processName ?
}
}
private void doBuildExplicitLinkWithSubstation( IRiseClipseConsole console, String messagePrefix ) {
// name The optional relative name of the terminal at this Equipment. The default is the empty string, which means that the name
// of the ConnectivityNode is also the terminal identification.
// desc Descriptive text to the terminal
......@@ -1118,19 +1133,10 @@ public class TerminalImpl extends UnNamingImpl implements Terminal {
// cNodeName The (relative) name of the connectivityNode within its bay
// neutralPoint If true, this terminal connects to a neutral (star) point of all power transformer windings. Default value is false.
String messagePrefix = "while resolving link from Terminal on line " + getLineNumber() + ": ";
if(( getCNodeName() == null ) || getCNodeName().isEmpty() ) {
console.warning( messagePrefix + "cNodeName is missing" );
return;
}
if( getSubstationName() != null && ! getSubstationName().isEmpty() ) {
if( isSetLineName() || isSetProcessName() ) {
// TODO: this error should be detected in OCL
}
if(( getVoltageLevelName() == null ) || getVoltageLevelName().isEmpty() ) {
console.warning( messagePrefix + "voltageLevelName is missing" );
return;
......@@ -1142,7 +1148,6 @@ public class TerminalImpl extends UnNamingImpl implements Terminal {
// find a Substation with
// Substation.name == Terminal.substationName
Substation substation = null;
List< Substation > res1 =
SclUtilities
.getSCL( this )
......@@ -1156,12 +1161,11 @@ public class TerminalImpl extends UnNamingImpl implements Terminal {
SclUtilities.displayNotFoundWarning( console, messagePrefix, mess1, res1.size() );
return;
}
substation = res1.get( 0 );
Substation substation = res1.get( 0 );
console.verbose( messagePrefix + "found " + mess1 + " on line " + substation.getLineNumber() );
// find a VoltageLevel with
// VoltageLevel.name == Terminal.voltageLevelName
VoltageLevel voltageLevel = null;
List< VoltageLevel > res2 =
substation
.getVoltageLevel()
......@@ -1174,12 +1178,11 @@ public class TerminalImpl extends UnNamingImpl implements Terminal {
SclUtilities.displayNotFoundWarning( console, messagePrefix, mess2, res2.size() );
return;
}
voltageLevel = res2.get( 0 );
VoltageLevel voltageLevel = res2.get( 0 );
console.verbose( messagePrefix + "found " + mess2 + " on line " + voltageLevel.getLineNumber() );
// find a Bay with
// Bay.name == Terminal.bayName
Bay bay = null;
List< Bay > res3 =
voltageLevel
.getBay()
......@@ -1192,7 +1195,7 @@ public class TerminalImpl extends UnNamingImpl implements Terminal {
SclUtilities.displayNotFoundWarning( console, messagePrefix, mess3, res3.size() );
return;
}
bay = res3.get( 0 );
Bay bay = res3.get( 0 );
console.verbose( messagePrefix + "found " + mess3 + " on line " + voltageLevel.getLineNumber() );
// find a ConnectivityNode with
......@@ -1209,18 +1212,19 @@ public class TerminalImpl extends UnNamingImpl implements Terminal {
SclUtilities.displayNotFoundWarning( console, messagePrefix, mess4, res4.size() );
return;
}
setRefersToConnectivityNode( res4.get( 0 ) );
setRefersToConnectivityNode( res4.get( 0 ));
console.info( "Terminal on line " + getLineNumber() + " refers to " + mess4 + " on line " + getRefersToConnectivityNode().getLineNumber() );
}
else if( getLineName() != null && ! getLineName().isEmpty() ) {
if( getProcessName() == null ) return;
if( getProcessName().isEmpty() ) return;
private void doBuildExplicitLinkWithLine( IRiseClipseConsole console, String messagePrefix ) {
if(( getCNodeName() == null ) || getCNodeName().isEmpty() ) {
console.warning( messagePrefix + "cNodeName is missing" );
return;
}
// find a Line with
// Line.name == Terminal.lineName
Line line = null;
List< Line > res5 =
List< Line > res1 =
SclUtilities
.getSCL( this )
.getLine()
......@@ -1228,31 +1232,30 @@ public class TerminalImpl extends UnNamingImpl implements Terminal {
.filter( l -> getLineName().equals( l.getName() ))
.collect( Collectors.toList() );
String mess5 = "Line( name = " + getLineName() + " )";
if( res5.size() != 1 ) {
SclUtilities.displayNotFoundWarning( console, messagePrefix, mess5, res5.size() );
String mess1 = "Line( name = " + getLineName() + " )";
if( res1.size() != 1 ) {
SclUtilities.displayNotFoundWarning( console, messagePrefix, mess1, res1.size() );
return;
}
line = res5.get( 0 );
console.verbose( messagePrefix + "found " + mess5 + " on line " + line.getLineNumber() );
Line line = res1.get( 0 );
console.verbose( messagePrefix + "found " + mess1 + " on line " + line.getLineNumber() );
// find a ConnectivityNode with
// ConnectivityNode.name == Terminal.bayName
List< ConnectivityNode > res6 =
List< ConnectivityNode > res2 =
line.
getConnectivityNode()
.stream()
.filter( cn -> getCNodeName().equals( cn.getName() ))
.collect( Collectors.toList() );
String mess6 = "ConnectivityNode( name = " + getCNodeName() + " )";
if( res6.size() != 1 ) {
SclUtilities.displayNotFoundWarning( console, messagePrefix, mess6, res6.size() );
String mess2 = "ConnectivityNode( name = " + getCNodeName() + " )";
if( res2.size() != 1 ) {
SclUtilities.displayNotFoundWarning( console, messagePrefix, mess2, res2.size() );
return;
}
setRefersToConnectivityNode( res6.get( 0 ));
console.info( "Terminal on line " + getLineNumber() + " refers to " + mess6 + " on line " + getRefersToConnectivityNode().getLineNumber() );
}
setRefersToConnectivityNode( res2.get( 0 ));
console.info( "Terminal on line " + getLineNumber() + " refers to " + mess2 + " on line " + getRefersToConnectivityNode().getLineNumber() );
}
} //TerminalImpl
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