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