Commit 09bcf6e7 authored by Dominique Marcadet's avatar Dominique Marcadet

refactoring of DAII.doBuildExplicitLinks()

parent 29834915
...@@ -963,27 +963,34 @@ public class DAIImpl extends UnNamingImpl implements DAI { ...@@ -963,27 +963,34 @@ public class DAIImpl extends UnNamingImpl implements DAI {
// see Issue #13 // see Issue #13
super.doBuildExplicitLinks( console ); super.doBuildExplicitLinks( console );
if(( getName() == null ) || getName().isEmpty() ) return; String messagePrefix = "while resolving link from DAI on line " + getLineNumber() + ": ";
if( ! doBuildExplicitLinkWithParentDOI( console )) { if(( getName() == null ) || getName().isEmpty() ) {
if( ! doBuildExplicitLinkWithParentSDI( console )) { console.warning( messagePrefix + "name is missing" );
// return;
} }
if( getParentDOI() != null ) {
doBuildExplicitLinkWithParentDOI( console, messagePrefix );
}
else if( getParentSDI() != null ) {
doBuildExplicitLinkWithParentSDI( console, messagePrefix );
}
else {
// Unexpected
} }
} }
private boolean doBuildExplicitLinkWithParentDOI( IRiseClipseConsole console ) { private void doBuildExplicitLinkWithParentDOI( IRiseClipseConsole console, String messagePrefix ) {
if( getParentDOI() == null ) return false; // No error or warning messages here: if this happens, error should have been detected before
String messagePrefix = "while resolving link from DAI on line " + getLineNumber() + ": ";
DO do_ = getParentDOI().getRefersToDO(); DO do_ = getParentDOI().getRefersToDO();
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();
if( dot == null ) return false; // No error or warning message here: if this happens, error should have been detected before
if( dot == null ) return;
console.verbose( messagePrefix + "found DOType on line " + dot.getLineNumber() ); console.verbose( messagePrefix + "found DOType on line " + dot.getLineNumber() );
List< DA > res = List< DA > res =
...@@ -994,34 +1001,24 @@ public class DAIImpl extends UnNamingImpl implements DAI { ...@@ -994,34 +1001,24 @@ public class DAIImpl extends UnNamingImpl implements DAI {
.collect( Collectors.toList() ); .collect( Collectors.toList() );
String mess = "DA( name = " + getName() + " )"; String mess = "DA( name = " + getName() + " )";
if( res.isEmpty() ) { if( res.size() != 1 ) {
// Not an error : will look for using ParentSDI SclUtilities.displayNotFoundWarning( console, messagePrefix, mess, res.size() );
// TODO: must validate return;
//console.error( messagePrefix + "cannot find " + mess );
return false;
}
if( res.size() > 1 ) {
console.warning( messagePrefix + "found several " + mess );
return false;
} }
setRefersToAbstractDataAttribute( res.get( 0 ) ); setRefersToAbstractDataAttribute( res.get( 0 ) );
console.info( "DAI on line " + getLineNumber() + " refers to " + mess + " on line " + getRefersToAbstractDataAttribute().getLineNumber() ); console.info( "DAI on line " + getLineNumber() + " refers to " + mess + " on line " + getRefersToAbstractDataAttribute().getLineNumber() );
return true;
} }
private boolean doBuildExplicitLinkWithParentSDI( IRiseClipseConsole console ) { private void doBuildExplicitLinkWithParentSDI( IRiseClipseConsole console, String messagePrefix ) {
if( getParentSDI() == null ) return false; // No error or warning messages here: if this happens, error should have been detected before
String messagePrefix = "while resolving link from DAI on line " + getLineNumber() + ": ";
AbstractDataAttribute att = getParentSDI().getRefersToAbstractDataAttribute(); AbstractDataAttribute att = getParentSDI().getRefersToAbstractDataAttribute();
if( att == null ) return false; if( att == null ) return;
att.buildExplicitLinks( console, false ); att.buildExplicitLinks( console, false );
console.verbose( messagePrefix + "found AbstractDataAttribute on line " + att.getLineNumber() ); console.verbose( messagePrefix + "found AbstractDataAttribute on line " + att.getLineNumber() );
DAType dat = att.getRefersToDAType(); DAType dat = att.getRefersToDAType();
if( dat == null ) return false; // No error or warning message here: if this happens, error should have been detected before
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 =
...@@ -1034,11 +1031,10 @@ public class DAIImpl extends UnNamingImpl implements DAI { ...@@ -1034,11 +1031,10 @@ public class DAIImpl extends UnNamingImpl implements DAI {
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( "DAI on line " + getLineNumber() + " refers to " + mess + " on line " + getRefersToAbstractDataAttribute().getLineNumber() ); console.info( "DAI on line " + getLineNumber() + " refers to " + mess + " on line " + getRefersToAbstractDataAttribute().getLineNumber() );
return true;
} }
} //DAIImpl } //DAIImpl
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