Commit 26a399ec authored by Dominique Marcadet's avatar Dominique Marcadet

Merge branch '43-review-use-of-error-in-dobuildexplicitlinks' into 'master'

Resolve "review use of error() in doBuildExplicitLinks()"

Closes #43

See merge request RiseClipseGroup/RiseClipseMetamodel_SCL2003!39
parents abc80b54 c8f00f78
...@@ -1395,14 +1395,24 @@ public abstract class AbstractDataAttributeImpl extends UnNamingImpl implements ...@@ -1395,14 +1395,24 @@ public abstract class AbstractDataAttributeImpl extends UnNamingImpl implements
// A referenced attribute shall exist in the same type definition. The default value 0 states that the attribute is no array. // A referenced attribute shall exist in the same type definition. The default value 0 states that the attribute is no array.
// valKind Determines how the value shall be interpreted if any is given // valKind Determines how the value shall be interpreted if any is given
if( getType() == null ) return; if( ! ( "Enum".equals( getBType() ) || "Struct".equals( getBType() ))) {
return;
}
String messagePrefix = "while resolving link from AbstractDataAttribute on line " + getLineNumber() + ": ";
if(( getType() == null ) || getType().isEmpty() ) {
console.warning( messagePrefix + "type is missing" );
return;
}
DataTypeTemplates dtt = SclUtilities.getSCL( this ).getDataTypeTemplates(); DataTypeTemplates dtt = SclUtilities.getSCL( this ).getDataTypeTemplates();
if( dtt == null ) return; if( dtt == null ) {
console.warning( messagePrefix + "DataTypeTemplates is missing" );
return;
}
String messagePrefix = "while resolving link from AbstractDataAttribute on line " + getLineNumber() + ": "; if( "Enum".equals( getBType() )) {
if( "Enum".equals( getBType() ) ) {
// find an EnumType with // find an EnumType with
// EnumType.id == DA.type // EnumType.id == DA.type
List< EnumType > res = List< EnumType > res =
...@@ -1414,13 +1424,13 @@ public abstract class AbstractDataAttributeImpl extends UnNamingImpl implements ...@@ -1414,13 +1424,13 @@ public abstract class AbstractDataAttributeImpl extends UnNamingImpl implements
String mess = "EnumType( id = " + getType() + " )"; String mess = "EnumType( id = " + getType() + " )";
if( res.size() != 1 ) { if( res.size() != 1 ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess, res.size() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess, res.size() );
return; return;
} }
setRefersToEnumType( res.get( 0 ) ); setRefersToEnumType( res.get( 0 ) );
console.info( "AbstractDataAttribute on line " + getLineNumber() + " refers to " + mess + " on line " + getRefersToEnumType().getLineNumber() ); console.info( "AbstractDataAttribute on line " + getLineNumber() + " refers to " + mess + " on line " + getRefersToEnumType().getLineNumber() );
} }
else if( "Struct".equals( getBType() ) ) { else if( "Struct".equals( getBType() )) {
// find an DAType with // find an DAType with
// DAType.id == DA.type // DAType.id == DA.type
...@@ -1433,7 +1443,7 @@ public abstract class AbstractDataAttributeImpl extends UnNamingImpl implements ...@@ -1433,7 +1443,7 @@ public abstract class AbstractDataAttributeImpl extends UnNamingImpl implements
String mess = "DAType( id = " + getType() + " )"; String mess = "DAType( id = " + getType() + " )";
if( res.size() != 1 ) { if( res.size() != 1 ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess, res.size() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess, res.size() );
return; return;
} }
setRefersToDAType( res.get( 0 ) ); setRefersToDAType( res.get( 0 ) );
......
...@@ -1420,13 +1420,19 @@ public abstract class AnyLNImpl extends UnNamingImpl implements AnyLN { ...@@ -1420,13 +1420,19 @@ public abstract class AnyLNImpl extends UnNamingImpl implements AnyLN {
// lnClass The LN class according to IEC 61850-7-x // lnClass The LN class according to IEC 61850-7-x
// inst The LN instance number identifying this LN – an unsigned integer // inst The LN instance number identifying this LN – an unsigned integer
if( getLnType() == null ) return;
DataTypeTemplates dtt = SclUtilities.getSCL( this ).getDataTypeTemplates();
if( dtt == null ) return;
String messagePrefix = "while resolving link from AnyLN on line " + getLineNumber() + ": "; String messagePrefix = "while resolving link from AnyLN on line " + getLineNumber() + ": ";
List< LNodeType > res = //shallowSearchObjects( dtt.getLNodeType(), s ); if(( getLnType() == null ) || getLnType().isEmpty() ) {
console.warning( messagePrefix + "lnType is missing" );
return;
}
DataTypeTemplates dtt = SclUtilities.getSCL( this ).getDataTypeTemplates();
if( dtt == null ) {
console.warning( messagePrefix + "DataTypeTemplates is missing" );
return;
}
List< LNodeType > res =
dtt dtt
.getLNodeType() .getLNodeType()
.stream() .stream()
...@@ -1435,14 +1441,14 @@ public abstract class AnyLNImpl extends UnNamingImpl implements AnyLN { ...@@ -1435,14 +1441,14 @@ public abstract class AnyLNImpl extends UnNamingImpl implements AnyLN {
String mess = "LNodeType( id = " + getLnType() + " )"; String mess = "LNodeType( id = " + getLnType() + " )";
if( res.size() != 1 ) { if( res.size() != 1 ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess, res.size() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess, res.size() );
return; return;
} }
setRefersToLNodeType( res.get( 0 ) ); setRefersToLNodeType( res.get( 0 ) );
console.info( "AnyLN on line " + getLineNumber() + " refers to " + mess + " on line " + getRefersToLNodeType().getLineNumber() ); console.info( "AnyLN on line " + getLineNumber() + " refers to " + mess + " on line " + getRefersToLNodeType().getLineNumber() );
if(( getLnClass() != null ) && ! getLnClass().equals( getRefersToLNodeType().getLnClass() )) { if(( getLnClass() != null ) && ! getLnClass().equals( getRefersToLNodeType().getLnClass() )) {
console.error( messagePrefix + "lnClass in " + mess + "(" + getRefersToLNodeType().getLnClass() + ") is not " + getLnClass() ); console.warning( messagePrefix + "lnClass in " + mess + "(" + getRefersToLNodeType().getLnClass() + ") is not " + getLnClass() );
} }
} }
......
...@@ -1176,18 +1176,27 @@ public class AssociationImpl extends BaseElementImpl implements Association { ...@@ -1176,18 +1176,27 @@ public class AssociationImpl extends BaseElementImpl implements Association {
// prefix The LN prefix // prefix The LN prefix
// lnInst The instance number of the client LN // lnInst The instance number of the client LN
if( getIedName() == null ) return;
if( getLdInst() == null ) return;
if( getLnClass() == null ) return;
String messagePrefix = "while resolving link from Association on line " + getLineNumber() + ": "; String messagePrefix = "while resolving link from Association on line " + getLineNumber() + ": ";
if(( getIedName() == null ) || getIedName().isEmpty() ) {
console.warning( messagePrefix + "iedName is missing " );
return;
}
if(( getLdInst() == null ) || getLdInst().isEmpty() ) {
console.warning( messagePrefix + "ldInst is missing " );
return;
}
if(( getLnClass() == null ) || getLnClass().isEmpty() ) {
console.warning( messagePrefix + "lnClass is missing " );
return;
}
// find an IED with // find an IED with
// IED.name == Association.iedName // IED.name == Association.iedName
Pair< IED, Integer > ied = SclUtilities.getIED( SclUtilities.getSCL( this ), getIedName() ); Pair< IED, Integer > ied = SclUtilities.getIED( SclUtilities.getSCL( this ), getIedName() );
String mess1 = "IED( name = " + getIedName() + " )"; String mess1 = "IED( name = " + getIedName() + " )";
if( ied.getLeft() == null ) { if( ied.getLeft() == null ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess1, ied.getRight() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess1, ied.getRight() );
return; return;
} }
console.verbose( messagePrefix + "found " + mess1 + " on line " + ied.getLeft().getLineNumber() ); console.verbose( messagePrefix + "found " + mess1 + " on line " + ied.getLeft().getLineNumber() );
...@@ -1197,15 +1206,20 @@ public class AssociationImpl extends BaseElementImpl implements Association { ...@@ -1197,15 +1206,20 @@ public class AssociationImpl extends BaseElementImpl implements Association {
Pair< LDevice, Integer > lDevice = SclUtilities.getLDevice( ied.getLeft(), getLdInst() ); Pair< LDevice, Integer > lDevice = SclUtilities.getLDevice( ied.getLeft(), getLdInst() );
String mess2 = "LDevice( inst = " + getLdInst() + " )"; String mess2 = "LDevice( inst = " + getLdInst() + " )";
if( lDevice.getLeft() == null ) { if( lDevice.getLeft() == null ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess2, lDevice.getRight() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess2, lDevice.getRight() );
return; return;
} }
console.verbose( messagePrefix + "found " + mess2 + " on line " + lDevice.getLeft().getLineNumber() ); console.verbose( messagePrefix + "found " + mess2 + " on line " + lDevice.getLeft().getLineNumber() );
Pair< AnyLN, Integer > anyLN = SclUtilities.getAnyLN( lDevice.getLeft(), getLnClass(), getLnInst(), getPrefix() ); Pair< AnyLN, Integer > anyLN = SclUtilities.getAnyLN( lDevice.getLeft(), getLnClass(), getLnInst(), getPrefix() );
String mess3 = "LN( lnClass = " + getLnClass() + ", inst = " + getLnInst() + " )"; String mess3 = "LN( lnClass = " + getLnClass();
if( getLnInst() != null ) {
mess3 += ", inst = " + getLnInst();
if( getPrefix() != "" ) mess3 += ", prefix = " + getPrefix();
}
mess3 += " )";
if( anyLN.getLeft() == null ) { if( anyLN.getLeft() == null ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess3, anyLN.getRight() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess3, anyLN.getRight() );
return; return;
} }
setRefersToAnyLN( anyLN.getLeft() ); setRefersToAnyLN( anyLN.getLeft() );
......
...@@ -1085,20 +1085,33 @@ public class ClientLNImpl extends SclObjectImpl implements ClientLN { ...@@ -1085,20 +1085,33 @@ public class ClientLNImpl extends SclObjectImpl implements ClientLN {
// lnInst The instance id of this LN instance of below LN class in the IED // lnInst The instance id of this LN instance of below LN class in the IED
// desc optional descriptive text, e.g. about purpose of the client // desc optional descriptive text, e.g. about purpose of the client
if( getIedName() == null ) return;
if( getLdInst() == null ) return;
if( getLnClass() == null ) return;
// If the reference is to an LN at a pure client access point, then the value of ldInst shall be LD0
if( getLdInst().equals( "LD0" )) return;
String messagePrefix = "while resolving link from ClientLN on line " + getLineNumber() + ": "; String messagePrefix = "while resolving link from ClientLN on line " + getLineNumber() + ": ";
if(( getIedName() == null ) || getIedName().isEmpty() ) {
console.warning( messagePrefix + "iedName is missing" );
return;
}
if(( getLdInst() == null ) || getLdInst().isEmpty() ) {
console.warning( messagePrefix + "ldInst is missing" );
return;
}
if(( getLnClass() == null ) || getLnClass().isEmpty() ) {
console.warning( messagePrefix + "lnClass is missing" );
return;
}
// If the reference is to an LN at a pure client access point, then the value of ldInst shall be LD0
if( "LD0".equals( getLdInst() )) {
console.verbose( messagePrefix + "ldInst is LD0: pure client access point, therefore no link" );
return;
}
// find an IED with // find an IED with
// IED.name == ClientLN.iedName // IED.name == ClientLN.iedName
Pair< IED, Integer > ied = SclUtilities.getIED( SclUtilities.getSCL( this ), getIedName() ); Pair< IED, Integer > ied = SclUtilities.getIED( SclUtilities.getSCL( this ), getIedName() );
String mess1 = "IED( name = " + getIedName() + " )"; String mess1 = "IED( name = " + getIedName() + " )";
if( ied.getLeft() == null ) { if( ied.getLeft() == null ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess1, ied.getRight() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess1, ied.getRight() );
return; return;
} }
console.verbose( messagePrefix + "found " + mess1 + " on line " + ied.getLeft().getLineNumber() ); console.verbose( messagePrefix + "found " + mess1 + " on line " + ied.getLeft().getLineNumber() );
...@@ -1106,11 +1119,11 @@ public class ClientLNImpl extends SclObjectImpl implements ClientLN { ...@@ -1106,11 +1119,11 @@ public class ClientLNImpl extends SclObjectImpl implements ClientLN {
Pair< AccessPoint, Integer > ap = null; Pair< AccessPoint, Integer > ap = null;
if(( getApRef() == null ) || getApRef().isEmpty() ) { if(( getApRef() == null ) || getApRef().isEmpty() ) {
if( ied.getLeft().getAccessPoint().size() == 0 ) { if( ied.getLeft().getAccessPoint().size() == 0 ) {
console.error( messagePrefix + "no AccessPoint found in ied ( name = " + ied.getLeft().getName() + " )" ); console.warning( messagePrefix + "no AccessPoint found in ied ( name = " + ied.getLeft().getName() + " )" );
return; return;
} }
if( ied.getLeft().getAccessPoint().size() > 1 ) { if( ied.getLeft().getAccessPoint().size() > 1 ) {
console.error( messagePrefix + "found several AccessPoint in ied ( name = " + ied.getLeft().getName() + " ) but apRef not specified" ); console.warning( messagePrefix + "found several AccessPoint in ied ( name = " + ied.getLeft().getName() + " ) but apRef not specified" );
return; return;
} }
ap = Pair.of( ied.getLeft().getAccessPoint().get( 0 ), 1 ); ap = Pair.of( ied.getLeft().getAccessPoint().get( 0 ), 1 );
...@@ -1119,7 +1132,7 @@ public class ClientLNImpl extends SclObjectImpl implements ClientLN { ...@@ -1119,7 +1132,7 @@ public class ClientLNImpl extends SclObjectImpl implements ClientLN {
ap = SclUtilities.getAccessPoint( ied.getLeft(), getApRef() ); ap = SclUtilities.getAccessPoint( ied.getLeft(), getApRef() );
String mess2 = "AccessPoint( name = " + getApRef() + " )"; String mess2 = "AccessPoint( name = " + getApRef() + " )";
if( ap.getLeft() == null ) { if( ap.getLeft() == null ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess2, ap.getRight() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess2, ap.getRight() );
return; return;
} }
console.verbose( messagePrefix + "found " + mess2 + " on line " + ap.getLeft().getLineNumber() ); console.verbose( messagePrefix + "found " + mess2 + " on line " + ap.getLeft().getLineNumber() );
...@@ -1128,15 +1141,20 @@ public class ClientLNImpl extends SclObjectImpl implements ClientLN { ...@@ -1128,15 +1141,20 @@ public class ClientLNImpl extends SclObjectImpl implements ClientLN {
Pair< LDevice, Integer > lDevice = SclUtilities.getLDevice( ap.getLeft(), getLdInst() ); Pair< LDevice, Integer > lDevice = SclUtilities.getLDevice( ap.getLeft(), getLdInst() );
String mess3 = "LDevice( inst = " + getLdInst() + " )"; String mess3 = "LDevice( inst = " + getLdInst() + " )";
if( lDevice.getLeft() == null ) { if( lDevice.getLeft() == null ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess3, lDevice.getRight() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess3, lDevice.getRight() );
return; return;
} }
console.verbose( messagePrefix + "found " + mess3 + " on line " + lDevice.getLeft().getLineNumber() ); console.verbose( messagePrefix + "found " + mess3 + " on line " + lDevice.getLeft().getLineNumber() );
Pair< AnyLN,Integer > anyLN = SclUtilities.getAnyLN( lDevice.getLeft(), getLnClass(), getLnInst(), getPrefix() ); Pair< AnyLN,Integer > anyLN = SclUtilities.getAnyLN( lDevice.getLeft(), getLnClass(), getLnInst(), getPrefix() );
String mess4 = "LN( lnClass = " + getLnClass() + ", inst = " + getLnInst() + " )"; String mess4 = "LN( lnClass = " + getLnClass();
if( getLnInst() != null ) {
mess4 += ", inst = " + getLnInst();
if( getPrefix() != "" ) mess4 += ", prefix = " + getPrefix();
}
mess4 += " )";
if( anyLN.getLeft() == null ) { if( anyLN.getLeft() == null ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess4, anyLN.getRight() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess4, anyLN.getRight() );
return; return;
} }
setRefersToAnyLN( anyLN.getLeft() ); setRefersToAnyLN( anyLN.getLeft() );
......
...@@ -983,24 +983,30 @@ public class ConnectedAPImpl extends UnNamingImpl implements ConnectedAP { ...@@ -983,24 +983,30 @@ public class ConnectedAPImpl extends UnNamingImpl implements ConnectedAP {
// apName a name identifying this access point within the IED // apName a name identifying this access point within the IED
// desc some descriptive text for this access point at this subnetwork // desc some descriptive text for this access point at this subnetwork
if( getIedName() == null ) return;
if( getApName() == null ) return;
String messagePrefix = "while resolving link from ConnectedAP on line " + getLineNumber() + ": "; String messagePrefix = "while resolving link from ConnectedAP on line " + getLineNumber() + ": ";
if(( getIedName() == null ) || getIedName().isEmpty() ) {
console.warning( messagePrefix + "iedName is missing" );
return;
}
if(( getApName() == null ) || getApName().isEmpty() ) {
console.warning( messagePrefix + "apName is missing" );
return;
}
// find an IED with // find an IED with
// IED.name == ConnectedAP.iedName // IED.name == ConnectedAP.iedName
Pair< IED, Integer > ied = SclUtilities.getIED( SclUtilities.getSCL( this ), getIedName() ); Pair< IED, Integer > ied = SclUtilities.getIED( SclUtilities.getSCL( this ), getIedName() );
String mess1 = "IED( name = " + getIedName() + " )"; String mess1 = "IED( name = " + getIedName() + " )";
if( ied.getLeft() == null ) { if( ied.getLeft() == null ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess1, ied.getRight() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess1, ied.getRight() );
return; return;
} }
console.verbose( messagePrefix + "found " + mess1 + " on line " + ied.getLeft().getLineNumber() ); console.verbose( messagePrefix + "found " + mess1 + " on line " + ied.getLeft().getLineNumber() );
Pair< AccessPoint, Integer > ap = SclUtilities.getAccessPoint( ied.getLeft(), getApName() ); Pair< AccessPoint, Integer > ap = SclUtilities.getAccessPoint( ied.getLeft(), getApName() );
String mess2 = "AccessPoint( name = " + getApName() + " )"; String mess2 = "AccessPoint( name = " + getApName() + " )";
if( ap.getLeft() == null ) { if( ap.getLeft() == null ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess2, ap.getRight() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess2, ap.getRight() );
return; return;
} }
setRefersToAccessPoint( ap.getLeft() ); setRefersToAccessPoint( ap.getLeft() );
......
...@@ -650,15 +650,22 @@ public abstract class ControlBlockImpl extends UnNamingImpl implements ControlBl ...@@ -650,15 +650,22 @@ public abstract class ControlBlockImpl extends UnNamingImpl implements ControlBl
// An LN is not necessary, as these control blocks are only in LLN0. // An LN is not necessary, as these control blocks are only in LLN0.
// cbName The name of the control block within the LLN0 of the LD ldInst. // cbName The name of the control block within the LLN0 of the LD ldInst.
// TODO: update comment // TODO: validate assumption
// Assumption : we need both an ied name and a ld instance to uniquely identify a LDevice. // Assumption : we need both an ied name and a ld instance to uniquely identify a LDevice.
// We will use the iedName provided by the enclosing connectedAP. // We will use the iedName provided by the enclosing connectedAP.
if( getLdInst() == null ) return;
if( getCbName() == null ) return;
String messagePrefix = "while resolving link from ControlBlock on line " + getLineNumber() + ": "; String messagePrefix = "while resolving link from ControlBlock on line " + getLineNumber() + ": ";
if(( getLdInst() == null ) || getLdInst().isEmpty() ) {
console.warning( messagePrefix + "ldInst is missing" );
return;
}
if(( getCbName() == null ) || getCbName().isEmpty() ) {
console.warning( messagePrefix + "cbName is missing" );
return;
}
// No error or warning messages here: if this happens, error should have been detected before
if( getParentConnectedAP() == null ) return; if( getParentConnectedAP() == null ) return;
if( getParentConnectedAP().getRefersToAccessPoint() == null ) return; if( getParentConnectedAP().getRefersToAccessPoint() == null ) return;
IED ied = getParentConnectedAP().getRefersToAccessPoint().getParentIED(); IED ied = getParentConnectedAP().getRefersToAccessPoint().getParentIED();
...@@ -669,14 +676,17 @@ public abstract class ControlBlockImpl extends UnNamingImpl implements ControlBl ...@@ -669,14 +676,17 @@ public abstract class ControlBlockImpl extends UnNamingImpl implements ControlBl
Pair< LDevice, Integer > lDevice = SclUtilities.getLDevice( ied, getLdInst() ); Pair< LDevice, Integer > lDevice = SclUtilities.getLDevice( ied, getLdInst() );
String mess1 = "LDevice( inst = " + getLdInst() + " )"; String mess1 = "LDevice( inst = " + getLdInst() + " )";
if( lDevice.getLeft() == null ) { if( lDevice.getLeft() == null ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess1, lDevice.getRight() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess1, lDevice.getRight() );
return; return;
} }
console.verbose( messagePrefix + "found " + mess1 + " on line " + lDevice.getLeft().getLineNumber() ); console.verbose( messagePrefix + "found " + mess1 + " on line " + lDevice.getLeft().getLineNumber() );
// Find a ControlWithIEDName inside LN0 of LDevice with // Find a ControlWithIEDName inside LN0 of LDevice with
// ControlWithIEDName.name == ControlBlock.bName // ControlWithIEDName.name == ControlBlock.bName
if( lDevice.getLeft().getLN0() == null ) return; if( lDevice.getLeft().getLN0() == null ) {
console.warning( messagePrefix + "LN0 is missing" );
return;
}
List< ControlWithIEDName > l2 = new ArrayList< ControlWithIEDName >(); List< ControlWithIEDName > l2 = new ArrayList< ControlWithIEDName >();
l2.addAll( lDevice.getLeft().getLN0().getGSEControl() ); l2.addAll( lDevice.getLeft().getLN0().getGSEControl() );
...@@ -690,7 +700,7 @@ public abstract class ControlBlockImpl extends UnNamingImpl implements ControlBl ...@@ -690,7 +700,7 @@ public abstract class ControlBlockImpl extends UnNamingImpl implements ControlBl
String mess2 = "ControlWithIEDName( name = " + getCbName() + " )"; String mess2 = "ControlWithIEDName( name = " + getCbName() + " )";
if( res2.size() != 1 ) { if( res2.size() != 1 ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess2, res2.size() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess2, res2.size() );
return; return;
} }
setRefersToControlWithIEDName( res2.get( 0 )); setRefersToControlWithIEDName( res2.get( 0 ));
......
...@@ -573,11 +573,16 @@ public abstract class ControlImpl extends UnNamingImpl implements Control { ...@@ -573,11 +573,16 @@ public abstract class ControlImpl extends UnNamingImpl implements Control {
// datSet The name of the data set to be sent by the report control block; datSet should only be missing within an ICD-File, // datSet The name of the data set to be sent by the report control block; datSet should only be missing within an ICD-File,
// or to indicate an unused control block. The referenced data set must be in the same LN as the control block. // or to indicate an unused control block. The referenced data set must be in the same LN as the control block.
if( getDatSet() == null ) return;
if( getParentAnyLN() == null ) return;
String messagePrefix = "while resolving link from Control on line " + getLineNumber() + ": "; String messagePrefix = "while resolving link from Control on line " + getLineNumber() + ": ";
if(( getDatSet() == null ) || getDatSet().isEmpty() ) {
console.warning( messagePrefix + "datSet is missing" );
return;
}
// No error or warning message here: if this happens, error should have been detected before
if( getParentAnyLN() == null ) return;
// find an DataSet with // find an DataSet with
// DataSet.name == Control.datSet // DataSet.name == Control.datSet
List< DataSet > res = List< DataSet > res =
...@@ -589,7 +594,7 @@ public abstract class ControlImpl extends UnNamingImpl implements Control { ...@@ -589,7 +594,7 @@ public abstract class ControlImpl extends UnNamingImpl implements Control {
String mess = "DataSet( name = " + getDatSet() + " )"; String mess = "DataSet( name = " + getDatSet() + " )";
if( res.size() != 1 ) { if( res.size() != 1 ) {
SclUtilities.displayNotFoundError( console, messagePrefix, mess, res.size() ); SclUtilities.displayNotFoundWarning( console, messagePrefix, mess, res.size() );
return; return;
} }
setRefersToDataSet( res.get( 0 )); setRefersToDataSet( res.get( 0 ));
......
...@@ -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;
}
} }
}
private boolean doBuildExplicitLinkWithParentDOI( IRiseClipseConsole console ) { if( getParentDOI() != null ) {
if( getParentDOI() == null ) return false; doBuildExplicitLinkWithParentDOI( console, messagePrefix );
}
String messagePrefix = "while resolving link from DAI on line " + getLineNumber() + ": "; 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(); 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.error( 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();