Commit 9a813f17 authored by Dominique Marcadet's avatar Dominique Marcadet

refactoring of SDII.doBuildExplicitLinks()

parent 09bcf6e7
...@@ -978,27 +978,27 @@ public class SDIImpl extends UnNamingImpl implements SDI { ...@@ -978,27 +978,27 @@ public class SDIImpl extends UnNamingImpl implements SDI {
return; return;
} }
if( ! doResolveLinkWithParentDOI( console )) { if( getParentDOI() != null ) {
if( ! doResolveLinkWithParentSDI( console )) { doResolveLinkWithParentDOI( console, messagePrefix );
// }
} else if( getParentSDI() != null ) {
doResolveLinkWithParentSDI( console, messagePrefix );
}
else {
// Unexpected
} }
} }
private boolean doResolveLinkWithParentDOI( IRiseClipseConsole console ) { private void doResolveLinkWithParentDOI( IRiseClipseConsole console, String messagePrefix ) {
if( getParentDOI() == null ) return false;
String messagePrefix = "while resolving link from SDI on line " + getLineNumber() + ": ";
DO do_ = getParentDOI().getRefersToDO(); DO do_ = getParentDOI().getRefersToDO();
// No error or warning message here: if this happens, error should have been detected before // No error or warning message here: if this happens, error should have been detected before
if( do_ == null ) return false; if( do_ == null ) return;
console.verbose( messagePrefix + "found DO on line " + do_.getLineNumber() ); console.verbose( messagePrefix + "found DO on line " + do_.getLineNumber() );
do_.buildExplicitLinks( console, false ); do_.buildExplicitLinks( console, false );
DOType dot = do_.getRefersToDOType(); DOType dot = do_.getRefersToDOType();
// No error or warning message here: if this happens, error should have been detected before // No error or warning message here: if this happens, error should have been detected before
if( dot == null ) return false; if( dot == null ) return;
console.verbose( messagePrefix + "found DOType on line " + dot.getLineNumber() ); console.verbose( messagePrefix + "found DOType on line " + dot.getLineNumber() );
List< SDO > res1 = List< SDO > res1 =
...@@ -1011,11 +1011,13 @@ public class SDIImpl extends UnNamingImpl implements SDI { ...@@ -1011,11 +1011,13 @@ public class SDIImpl extends UnNamingImpl implements SDI {
String mess1 = "SDO( name = " + getName() + " )"; String mess1 = "SDO( name = " + getName() + " )";
// Not an error if res1.size() == 0: will look for a DA // Not an error if res1.size() == 0: will look for a DA
if( res1.size() > 1 ) { if( res1.size() > 1 ) {
console.warning( messagePrefix + "found several " + mess1 ); console.warning( messagePrefix + "found several " + mess1 + " using ParentDOI" );
return;
} }
else if( res1.size() == 1 ) { if( res1.size() == 1 ) {
setRefersToSDO( res1.get( 0 ) ); setRefersToSDO( res1.get( 0 ));
console.info( "SDI on line " + getLineNumber() + " refers to " + mess1 + " on line " + getRefersToSDO().getLineNumber() ); console.info( "SDI on line " + getLineNumber() + " refers to " + mess1 + " on line " + getRefersToSDO().getLineNumber() );
return;
} }
List< DA > res2 = List< DA > res2 =
...@@ -1026,35 +1028,28 @@ public class SDIImpl extends UnNamingImpl implements SDI { ...@@ -1026,35 +1028,28 @@ public class SDIImpl extends UnNamingImpl implements SDI {
.collect( Collectors.toList() ); .collect( Collectors.toList() );
String mess2 = "DA( name = " + getName() + " )"; String mess2 = "DA( name = " + getName() + " )";
if( res2.size() > 1 ) { // Specific message if res2.size() == 0
console.warning( messagePrefix + "found several " + mess2 ); if( res2.size() == 0 ) {
}
else if( res2.size() == 1 ) {
setRefersToAbstractDataAttribute( res2.get( 0 ));
console.info( "SDI on line " + getLineNumber() + " refers to " + mess2 + " on line " + getRefersToAbstractDataAttribute().getLineNumber() );
}
if(( getRefersToSDO() == null ) && ( getRefersToAbstractDataAttribute() == null )) {
console.warning( messagePrefix + "no SDO or DA found using ParentDOI" ); console.warning( messagePrefix + "no SDO or DA found using ParentDOI" );
return false; return;
} }
return true; if( res2.size() > 1 ) {
console.warning( messagePrefix + "found several " + mess2 + " using ParentDOI" );
return;
}
setRefersToAbstractDataAttribute( res2.get( 0 ));
console.info( "SDI on line " + getLineNumber() + " refers to " + mess2 + " on line " + getRefersToAbstractDataAttribute().getLineNumber() );
} }
private boolean doResolveLinkWithParentSDI( IRiseClipseConsole console ) { private void doResolveLinkWithParentSDI( IRiseClipseConsole console, String messagePrefix ) {
if( getParentSDI() == null ) return false; SDO sdo = getParentSDI().getRefersToSDO();
String messagePrefix = "while resolving link from SDI on line " + getLineNumber() + ": ";
SDO sdo = getParentSDI().getRefersToSDO();
if( sdo != null ) { if( sdo != null ) {
console.verbose( messagePrefix + "found SDO on line " + sdo.getLineNumber() ); console.verbose( messagePrefix + "found SDO on line " + sdo.getLineNumber() );
sdo.buildExplicitLinks( console, false ); sdo.buildExplicitLinks( console, false );
DOType dot = sdo.getRefersToDOType(); DOType dot = sdo.getRefersToDOType();
// No error or warning message here: if this happens, error should have been detected before // No error or warning message here: if this happens, error should have been detected before
if( dot == null ) return false; if( dot == null ) return;
console.verbose( messagePrefix + "found DOType on line " + dot.getLineNumber() ); console.verbose( messagePrefix + "found DOType on line " + dot.getLineNumber() );
List< SDO > res1 = List< SDO > res1 =
...@@ -1067,13 +1062,13 @@ public class SDIImpl extends UnNamingImpl implements SDI { ...@@ -1067,13 +1062,13 @@ public class SDIImpl extends UnNamingImpl implements SDI {
String mess1 = "SDO( name = " + getName() + " )"; String mess1 = "SDO( name = " + getName() + " )";
// Not an error if res1.size() == 0: will look for a DA // Not an error if res1.size() == 0: will look for a DA
if( res1.size() > 1 ) { if( res1.size() > 1 ) {
console.warning( messagePrefix + "found several " + mess1 ); console.warning( messagePrefix + "found several " + mess1 + " using ParentSDI" );
return false; return;
} }
if( res1.size() == 1 ) { if( res1.size() == 1 ) {
setRefersToSDO( res1.get( 0 )); setRefersToSDO( res1.get( 0 ));
console.info( "SDI on line " + getLineNumber() + " refers to " + mess1 + " on line " + getRefersToSDO().getLineNumber() ); console.info( "SDI on line " + getLineNumber() + " refers to " + mess1 + " on line " + getRefersToSDO().getLineNumber() );
return true; return;
} }
List< DA > res2 = List< DA > res2 =
...@@ -1087,28 +1082,30 @@ public class SDIImpl extends UnNamingImpl implements SDI { ...@@ -1087,28 +1082,30 @@ public class SDIImpl extends UnNamingImpl implements SDI {
// Specific message if res2.size() == 0 // Specific message if res2.size() == 0
if( res2.size() == 0 ) { if( res2.size() == 0 ) {
console.warning( messagePrefix + "no SDO or DA found using ParentSDI" ); console.warning( messagePrefix + "no SDO or DA found using ParentSDI" );
return false; return;
} }
if( res2.size() > 1 ) { if( res2.size() > 1 ) {
console.warning( messagePrefix + "found several " + mess2 + " using ParentSDI" ); console.warning( messagePrefix + "found several " + mess2 + " using ParentSDI" );
return false; return;
} }
setRefersToAbstractDataAttribute( res2.get( 0 )); setRefersToAbstractDataAttribute( res2.get( 0 ));
console.info( "SDI on line " + getLineNumber() + " refers to " + mess2 + " on line " + getRefersToAbstractDataAttribute().getLineNumber() ); console.info( "SDI on line " + getLineNumber() + " refers to " + mess2 + " on line " + getRefersToAbstractDataAttribute().getLineNumber() );
return true; return;
} }
// When getParentSDI().getRefersToSDO() == null
AbstractDataAttribute att = getParentSDI().getRefersToAbstractDataAttribute(); AbstractDataAttribute att = getParentSDI().getRefersToAbstractDataAttribute();
if( att == null ) { if( att == null ) {
console.warning( messagePrefix + "cannot find SDO or AbstractDataAttribute using ParentSDI" ); console.warning( messagePrefix + "cannot find SDO or AbstractDataAttribute using ParentSDI" );
return false; return;
} }
att.buildExplicitLinks( console, false );
console.verbose( messagePrefix + "found AbstractDataAttribute on line " + att.getLineNumber() ); console.verbose( messagePrefix + "found AbstractDataAttribute on line " + att.getLineNumber() );
att.buildExplicitLinks( console, false );
DAType dat = att.getRefersToDAType(); DAType dat = att.getRefersToDAType();
// No error or warning message here: if this happens, error should have been detected before // No error or warning message here: if this happens, error should have been detected before
if( dat == null ) return false; if( dat == null ) return;
console.verbose( messagePrefix + "found DAType on line " + dat.getLineNumber() ); console.verbose( messagePrefix + "found DAType on line " + dat.getLineNumber() );
List< BDA > res = List< BDA > res =
...@@ -1121,11 +1118,10 @@ public class SDIImpl extends UnNamingImpl implements SDI { ...@@ -1121,11 +1118,10 @@ public class SDIImpl extends UnNamingImpl implements SDI {
String mess = "BDA( name = " + getName() + " )"; String mess = "BDA( name = " + getName() + " )";
if( res.size() != 1 ) { if( res.size() != 1 ) {
SclUtilities.displayNotFoundWarning( console, messagePrefix, mess, res.size() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess, res.size() );
return false; return;
} }
setRefersToAbstractDataAttribute( res.get( 0 )); setRefersToAbstractDataAttribute( res.get( 0 ));
console.info( "SDI on line " + getLineNumber() + " refers to " + mess + " on line " + getRefersToAbstractDataAttribute().getLineNumber() ); console.info( "SDI on line " + getLineNumber() + " refers to " + mess + " on line " + getRefersToAbstractDataAttribute().getLineNumber() );
return true;
} }
} //SDIImpl } //SDIImpl
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